diff --git a/CMakeLists.txt b/CMakeLists.txt index 1861d941c20..86573a90bb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -529,8 +529,8 @@ if(NOT APPLE) mark_as_advanced(WITH_CYCLES_DEVICE_HIP) mark_as_advanced(CYCLES_HIP_BINARIES_ARCH) - # HIPRT is only available on Windows for now. - if(WIN32) + # HIPRT is only available on Windows and Linux for now. + if(NOT APPLE) option(WITH_CYCLES_DEVICE_HIPRT "Enable Cycles AMD HIPRT support" OFF) mark_as_advanced(WITH_CYCLES_DEVICE_HIPRT) endif() @@ -2002,8 +2002,6 @@ if(FIRST_RUN) info_cfg_option(WITH_CYCLES_ONEAPI_BINARIES) info_cfg_option(WITH_CYCLES_DEVICE_HIP) info_cfg_option(WITH_CYCLES_HIP_BINARIES) - endif() - if(WIN32) info_cfg_option(WITH_CYCLES_DEVICE_HIPRT) endif() endif() diff --git a/build_files/cmake/Modules/FindHIPRT.cmake b/build_files/cmake/Modules/FindHIPRT.cmake index c6b46b5a445..18dee6024da 100644 --- a/build_files/cmake/Modules/FindHIPRT.cmake +++ b/build_files/cmake/Modules/FindHIPRT.cmake @@ -38,9 +38,11 @@ if(HIPRT_INCLUDE_DIR) find_file(HIPRT_BITCODE NAMES hiprt${_hiprt_version}_amd_lib_win.bc + hiprt${_hiprt_version}_amd_lib_linux.bc HINTS ${HIPRT_ROOT_DIR}/bin ${HIPRT_ROOT_DIR}/dist/bin/Release + ${HIPRT_ROOT_DIR}/share/hiprt NO_DEFAULT_PATH ) diff --git a/extern/hipew/src/hiprtew.cc b/extern/hipew/src/hiprtew.cc index 5844d6466b3..e7102f5a64b 100644 --- a/extern/hipew/src/hiprtew.cc +++ b/extern/hipew/src/hiprtew.cc @@ -61,7 +61,6 @@ bool hiprtewInit() return result; } -#ifdef _WIN32 initialized = true; if (atexit(hipewHipRtExit)) { @@ -69,7 +68,11 @@ bool hiprtewInit() } std::string hiprt_ver(HIPRT_VERSION_STR); +#ifdef _WIN32 std::string hiprt_path = "hiprt" + hiprt_ver + "64.dll"; +#else + std::string hiprt_path = "libhiprt" + hiprt_ver + "64.so"; +#endif hiprt_lib = dynamic_library_open(hiprt_path.c_str()); @@ -93,7 +96,6 @@ bool hiprtewInit() HIPRT_LIBRARY_FIND(hiprtSetLogLevel) result = true; -#endif return result; } diff --git a/intern/cycles/device/hiprt/device_impl.cpp b/intern/cycles/device/hiprt/device_impl.cpp index 120fd17be8f..cc41977771f 100644 --- a/intern/cycles/device/hiprt/device_impl.cpp +++ b/intern/cycles/device/hiprt/device_impl.cpp @@ -262,9 +262,13 @@ string HIPRTDevice::compile_kernel(const uint kernel_features, const char *name, linker_options.append(" --offload-arch=").append(arch); linker_options.append(" -fgpu-rdc --hip-link --cuda-device-only "); string hiprt_ver(HIPRT_VERSION_STR); +# ifdef _WIN32 string hiprt_bc = hiprt_path + "\\dist\\bin\\Release\\hiprt" + hiprt_ver + "_amd_lib_win.bc"; +# else + string hiprt_bc = hiprt_path + "/share/hiprt/hiprt" + hiprt_ver + "_amd_lib_linux.bc"; +# endif - string linker_command = string_printf("clang++ %s \"%s\" %s -o \"%s\"", + string linker_command = string_printf("clang++-rocm %s \"%s\" %s -o \"%s\"", linker_options.c_str(), bitcode.c_str(), hiprt_bc.c_str(), diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 2f7b1e59bf4..9911aed6159 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -727,7 +727,7 @@ if(WITH_CYCLES_DEVICE_HIPRT AND WITH_CYCLES_HIP_BINARIES) -o ${hiprt_file}) add_custom_command( OUTPUT ${hiprt_file} - COMMAND ${hiprt_link_command} ${hiprt_link_flags} + COMMAND ${hiprt_compile_command} ${hiprt_link_command} ${hiprt_link_flags} DEPENDS ${bitcode_file}) delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${hiprt_file}" ${CYCLES_INSTALL_PATH}/lib) add_custom_target(cycles_kernel_hiprt ALL DEPENDS ${hiprt_file})