Files
test/build_files/cmake/Modules/FindHIP.cmake
Sahar A. Kashi 6363181af9 Cycles: HIP-RT 2.5 integration and gfx12 support
This change brings the following improvements on the user level
- Support of GPUs with gfx12 architecture
- New HIP-RT library which in addition to the gfx12 support brings
  various bug-fixes.

The known limitation of gfx12 is that OpenImageDenoiser does not yet
support this GPU architecture. This means that while Cycles will use the
full advantage of the gfx12 (including hardware accelerated ray-tracing),
denoising will only be possible on CPU, or secondary gfx11 or below GPU.
This is something that requires a change in OIDN and it is to late to do
it for Blender 4.4, but it is something to look forward for Blender 4.5.

The gfx12 changes for the pre-compiled kernels is rather trivial,
so it comes together (in the same PR) as the bigger HIP-RT change.

On the development side this change brings the following improvements:
- One step compile and link (much simpler CMake rules)
- Embedding BVH binaries in hiprt dll (which makes it easier to package
  and load, without relying on special path configuration)

Co-authored-by: Sahar Kashi <sahar.kashi@amd.com>
Co-authored-by: Sergey Sharybin <sergey@blender.org>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/133129
2025-02-20 17:34:14 +01:00

77 lines
2.1 KiB
CMake

# SPDX-FileCopyrightText: 2021 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# Find HIP compiler. This module defines
# HIP_HIPCC_EXECUTABLE, the full path to the hipcc executable
# HIP_VERSION, the HIP compiler version
# HIP_FOUND, if the HIP toolkit is found.
if(NOT (DEFINED HIP_ROOT_DIR))
set(HIP_ROOT_DIR "")
endif()
# If `HIP_ROOT_DIR` was defined in the environment, use it.
if(HIP_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{HIP_ROOT_DIR})
set(HIP_ROOT_DIR $ENV{HIP_ROOT_DIR})
elseif(DEFINED ENV{HIP_PATH})
# Built-in environment variable from SDK.
set(HIP_ROOT_DIR $ENV{HIP_PATH})
endif()
set(_hip_SEARCH_DIRS
${HIP_ROOT_DIR}
/opt/rocm
/opt/rocm/hip
"C:/Program Files/AMD/ROCm/*"
)
find_program(HIP_HIPCC_EXECUTABLE
NAMES
hipcc
HINTS
${_hip_SEARCH_DIRS}
PATH_SUFFIXES
bin
)
if(HIP_HIPCC_EXECUTABLE)
if(NOT HIP_ROOT_DIR)
get_filename_component(HIP_ROOT_DIR ${HIP_HIPCC_EXECUTABLE} DIRECTORY)
get_filename_component(HIP_ROOT_DIR ${HIP_ROOT_DIR} DIRECTORY)
endif()
set(HIP_VERSION_MAJOR 0)
set(HIP_VERSION_MINOR 0)
set(HIP_VERSION_PATCH 0)
set(_hipcc_executable ${HIP_HIPCC_EXECUTABLE})
# Get version from the header.
file(STRINGS "${HIP_ROOT_DIR}/include/hip/hip_version.h" _tmp REGEX "^#define HIP_VERSION_MAJOR.*$")
string(REGEX MATCHALL "[0-9]+" HIP_VERSION_MAJOR ${_tmp})
file(STRINGS "${HIP_ROOT_DIR}/include/hip/hip_version.h" _tmp REGEX "^#define HIP_VERSION_MINOR.*$")
string(REGEX MATCHALL "[0-9]+" HIP_VERSION_MINOR ${_tmp})
file(STRINGS "${HIP_ROOT_DIR}/include/hip/hip_version.h" _tmp REGEX "^#define HIP_VERSION_PATCH.*$")
string(REGEX MATCHALL "[0-9]+" HIP_VERSION_PATCH ${_tmp})
unset(_tmp)
# Construct full semantic version.
set(HIP_VERSION "${HIP_VERSION_MAJOR}.${HIP_VERSION_MINOR}.${HIP_VERSION_PATCH}")
set(HIP_VERSION_SHORT "${HIP_VERSION_MAJOR}.${HIP_VERSION_MINOR}")
unset(_hip_version_raw)
unset(_hipcc_executable)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HIP
REQUIRED_VARS HIP_HIPCC_EXECUTABLE
VERSION_VAR HIP_VERSION)
mark_as_advanced(
HIP_HIPCC_EXECUTABLE
)
unset(_hip_SEARCH_DIRS)