Merge pull request #195403 from Flakebi/rocm

This commit is contained in:
Bernardo Meurer 2022-10-13 14:56:18 -03:00 committed by GitHub
commit 2196a95e68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 462 additions and 170 deletions

View File

@ -29,13 +29,13 @@
let
hip = stdenv.mkDerivation rec {
pname = "hip";
version = "5.2.3";
version = "5.3.0";
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "HIP";
rev = "rocm-${version}";
hash = "sha256-QaN666Rku2Tkio2Gm5/3RD8D5JgmCZLe0Yun1fGxa8U=";
hash = "sha256-UAodlVUiTU4n/EyvTIuQekTGh4izmBjKCRXOHXVKY4M=";
};
patches = [
@ -102,20 +102,20 @@ let
description = "C++ Heterogeneous-Compute Interface for Portability";
homepage = "https://github.com/ROCm-Developer-Tools/HIP";
license = licenses.mit;
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
platforms = platforms.linux;
};
};
in
stdenv.mkDerivation rec {
pname = "hip";
version = "5.2.3";
version = "5.3.0";
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "hipamd";
rev = "rocm-${version}";
hash = "sha256-9YZBFn1jpOiX0X9rcpsFDNhas9vfxNkNnbsWSi7unPU=";
hash = "sha256-gZGZiDP/HbdmzLQkG9Jq9lyMP9hoD6UzTMiX9cUmQNA=";
};
nativeBuildInputs = [ cmake python3 makeWrapper perl ];
@ -133,11 +133,16 @@ stdenv.mkDerivation rec {
patches = [
(substituteAll {
src = ./hipamd-config-paths.patch;
inherit llvm hip;
inherit clang llvm hip;
rocm_runtime = rocm-runtime;
})
];
prePatch = ''
sed -e 's,#!/bin/bash,#!${stdenv.shell},' \
-i src/hip_embed_pch.sh
'';
preConfigure = ''
export HIP_CLANG_PATH=${clang}/bin
export DEVICE_LIB_PATH=${rocm-device-libs}/lib
@ -189,7 +194,7 @@ stdenv.mkDerivation rec {
description = "C++ Heterogeneous-Compute Interface for Portability";
homepage = "https://github.com/ROCm-Developer-Tools/hipamd";
license = licenses.mit;
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
platforms = platforms.linux;
};
}

View File

@ -2,7 +2,7 @@ diff --git a/hip-lang-config.cmake.in b/hip-lang-config.cmake.in
index 1a72643a..7f35031f 100644
--- a/hip-lang-config.cmake.in
+++ b/hip-lang-config.cmake.in
@@ -72,8 +72,8 @@ get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH)
@@ -71,8 +71,8 @@ get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH)
#need _IMPORT_PREFIX to be set #FILE_REORG_BACKWARD_COMPATIBILITY
@ -13,19 +13,18 @@ index 1a72643a..7f35031f 100644
find_path(HIP_CLANG_INCLUDE_PATH __clang_cuda_math.h
HINTS ${HIP_CLANG_INCLUDE_SEARCH_PATHS}
${HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG}
@@ -88,10 +88,7 @@ endif()
@@ -87,9 +87,7 @@ endif()
#if HSA is not under ROCm then provide CMAKE_PREFIX_PATH=<HSA_PATH>
find_path(HSA_HEADER hsa/hsa.h
PATHS
- "${_IMPORT_PREFIX}/../include" #FILE_REORG_BACKWARD_COMPATIBILITY
- "${_IMPORT_PREFIX}/include"
- "${ROCM_PATH}/include"
- /opt/rocm/include
+ "@rocm_runtime@/include"
)
if (HSA_HEADER-NOTFOUND)
@@ -99,7 +96,7 @@ if (HSA_HEADER-NOTFOUND)
if (NOT HSA_HEADER)
@@ -97,7 +94,7 @@ if (HSA_HEADER-NOTFOUND)
endif()
get_filename_component(HIP_COMPILER_INSTALL_PATH ${CMAKE_HIP_COMPILER} DIRECTORY)

View File

@ -7,7 +7,7 @@ index 89d1224e..120b68c6 100755
endif()
else()
- set(HIP_CLANG_ROOT "${ROCM_PATH}/llvm")
+ set(HIP_CLANG_ROOT "@llvm@")
+ set(HIP_CLANG_ROOT "@clang@")
endif()
if(NOT HIP_CXX_COMPILER)
set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER})
@ -45,3 +45,29 @@ index 89d1224e..120b68c6 100755
)
endif()
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 83866d83..4125d3aa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -178,7 +178,7 @@ if(__HIP_ENABLE_PCH)
${ROCM_PATH}/llvm)
# find_package(LLVM) returns the lib/cmake/llvm location. We require the root.
if(NOT DEFINED HIP_LLVM_ROOT)
- set(HIP_LLVM_ROOT "${LLVM_DIR}/../../..")
+ set(HIP_LLVM_ROOT "@clang@")
endif()
execute_process(COMMAND sh -c "${CMAKE_CURRENT_SOURCE_DIR}/hip_embed_pch.sh ${HIP_COMMON_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/include ${HIP_LLVM_ROOT}" COMMAND_ECHO STDERR RESULT_VARIABLE EMBED_PCH_RC)
diff --git a/src/hip_embed_pch.sh b/src/hip_embed_pch.sh
index 0a1572b2..aa855d63 100755
--- a/src/hip_embed_pch.sh
+++ b/src/hip_embed_pch.sh
@@ -149,7 +149,7 @@ EOF
$LLVM_DIR/bin/clang -cc1 -O3 -emit-pch -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -std=c++17 -fgnuc-version=4.2.1 -o $tmp/hip_wave64.pch -x hip-cpp-output - <$tmp/pch_wave64.cui &&
- $LLVM_DIR/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj &&
+ @llvm@/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj &&
rm -rf $tmp
}

View File

@ -1,12 +1,12 @@
{ stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }:
let
version = "5.2.3";
version = "5.3.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "llvm-project";
rev = "rocm-${version}";
hash = "sha256-sudH8hnjReyuCFm2CBEPd8W88SjAARgCd1MTIJaDjTI=";
hash = "sha256-MN7W4Gl6+a1nCozdn9gMzIXOiBPquoOP87x26boeSCA=";
};
in rec {
clang = wrapCCWith rec {

View File

@ -7,13 +7,13 @@
stdenv.mkDerivation rec {
pname = "rocclr";
version = "5.2.3";
version = "5.3.0";
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "ROCclr";
rev = "rocm-${version}";
hash = "sha256-DER6PBYXmZRgwFNVU5rpn87HrXMR+HnQf8cwHioUals=";
hash = "sha256-l14+l8FkiFmGuRZ9dyD/PEYH9nHVRRg1vMXMnVhg3K4=";
};
patches = [
@ -53,7 +53,7 @@ stdenv.mkDerivation rec {
description = "Source package of the Radeon Open Compute common language runtime";
homepage = "https://github.com/ROCm-Developer-Tools/ROCclr";
license = licenses.mit;
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
# rocclr seems to have some AArch64 ifdefs, but does not seem
# to be supported yet by the build infrastructure. Recheck in
# the future.

View File

@ -1,19 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eac270a..27610ec 100644
index 62b857b..d21c7f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,10 +53,6 @@ set(SOURCES
if(COMGR_BUILD_SHARED_LIBS)
add_library(amd_comgr SHARED ${SOURCES})
- # Windows doesn't have a strip utility, so CMAKE_STRIP won't be set.
- if((CMAKE_BUILD_TYPE STREQUAL "Release") AND NOT ("${CMAKE_STRIP}" STREQUAL ""))
- add_custom_command(TARGET amd_comgr POST_BUILD COMMAND ${CMAKE_STRIP} $<TARGET_FILE:amd_comgr>)
- endif()
else()
add_library(amd_comgr STATIC ${SOURCES})
endif()
@@ -141,8 +137,8 @@ if (UNIX)
@@ -147,8 +147,8 @@ if (UNIX)
list(APPEND AMD_COMGR_PUBLIC_LINKER_OPTIONS -pthread)
if (NOT APPLE AND COMGR_BUILD_SHARED_LIBS)
configure_file(
@ -24,17 +13,7 @@ index eac270a..27610ec 100644
list(APPEND AMD_COMGR_PRIVATE_LINKER_OPTIONS
"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/src/exportmap")
# When building a shared library with -fsanitize=address we can't be
@@ -154,6 +150,9 @@ if (UNIX)
-Wl,--no-undefined)
endif()
endif()
+
+ # Strip in release build
+ set_target_properties(amd_comgr PROPERTIES LINK_FLAGS_RELEASE -s)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
list(APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS
"/wd4244" #[[Suppress 'argument' : conversion from 'type1' to 'type2', possible loss of data]]
@@ -169,10 +168,6 @@ endif()
@@ -175,10 +175,6 @@ endif()
# the shared header.
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS AMD_COMGR_EXPORT)
@ -45,100 +24,209 @@ index eac270a..27610ec 100644
include(bc2h)
include(opencl_pch)
include(DeviceLibs)
@@ -203,8 +198,11 @@ target_compile_definitions(amd_comgr
PRIVATE "${AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS}")
target_include_directories(amd_comgr
PUBLIC
- $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
- $<INSTALL_INTERFACE:include>)
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)
+
@@ -212,10 +208,14 @@ target_include_directories(amd_comgr
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
+configure_file(
+ include/amd_comgr.h.in
+ include/amd_comgr.h @ONLY)
+
set(AMD_COMGR_CONFIG_NAME amd_comgr-config.cmake)
set(AMD_COMGR_TARGETS_NAME amd_comgr-targets.cmake)
@@ -220,29 +218,30 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
set(AMD_COMGR_VERSION_NAME amd_comgr-config-version.cmake)
-set(AMD_COMGR_PACKAGE_PREFIX ${CMAKE_INSTALL_LIBDIR}/cmake/amd_comgr)
+set(AMD_COMGR_PACKAGE_PREFIX cmake/amd_comgr)
# Generate the build-tree package.
set(AMD_COMGR_PREFIX_CODE)
@@ -226,13 +226,13 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
endif()
set(AMD_COMGR_TARGETS_PATH
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
-set(AMD_COMGR_VERSION_PATH
+ "${CMAKE_CURRENT_BINARY_DIR}/lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
set(AMD_COMGR_VERSION_PATH
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}")
-export(TARGETS amd_comgr
+ "${CMAKE_CURRENT_BINARY_DIR}/lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}")
export(TARGETS amd_comgr
- FILE "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
+ "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
+ FILE "lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
- "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}"
+ ${AMD_COMGR_CONFIG_NAME}
+ "lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}"
@ONLY)
-write_basic_package_version_file("${AMD_COMGR_VERSION_PATH}"
+write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_VERSION_NAME}"
write_basic_package_version_file("${AMD_COMGR_VERSION_PATH}"
VERSION "${amd_comgr_VERSION}"
COMPATIBILITY SameMajorVersion)
install(TARGETS amd_comgr
EXPORT amd_comgr_export
- COMPONENT amd-comgr
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ COMPONENT amd-comgr)
+install(EXPORT amd_comgr_export
+ DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
+ FILE "${AMD_COMGR_TARGETS_NAME}")
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/include/amd_comgr.h"
COMPONENT amd-comgr
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_VERSION_NAME}"
+ COMPONENT amd-comgr
+ DESTINATION ${AMD_COMGR_PACKAGE_PREFIX})
install(FILES
"README.md"
@@ -251,37 +250,6 @@ install(FILES
COMPONENT amd-comgr
DESTINATION ${CMAKE_INSTALL_DATADIR}/amd_comgr)
-# Generate the install-tree package.
-set(AMD_COMGR_PREFIX_CODE "
-# Derive absolute install prefix from config file path.
-get_filename_component(AMD_COMGR_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
@@ -266,7 +266,7 @@ install(FILES
set(AMD_COMGR_PREFIX_CODE "
# Derive absolute install prefix from config file path.
get_filename_component(AMD_COMGR_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-string(REGEX REPLACE "/" ";" count "${AMD_COMGR_PACKAGE_PREFIX}")
-foreach(p ${count})
- set(AMD_COMGR_PREFIX_CODE "${AMD_COMGR_PREFIX_CODE}
-get_filename_component(AMD_COMGR_PREFIX \"\${AMD_COMGR_PREFIX}\" PATH)")
-endforeach()
-
-if (NOT COMGR_BUILD_SHARED_LIBS)
- string(APPEND AMD_COMGR_PREFIX_CODE "\ninclude(CMakeFindDependencyMacro)\n")
- string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(Clang REQUIRED)\n")
- string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(LLD REQUIRED)\n")
-endif()
-
-set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
-configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
- @ONLY)
-install(FILES
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
- RENAME "${AMD_COMGR_CONFIG_NAME}")
-install(EXPORT amd_comgr_export
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
- FILE "${AMD_COMGR_TARGETS_NAME}")
-install(FILES
- "${AMD_COMGR_VERSION_PATH}"
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
-
set(CLANG_LIBS
clangFrontendTool)
+string(REGEX REPLACE "/" ";" count "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}")
foreach(p ${count})
set(AMD_COMGR_PREFIX_CODE "${AMD_COMGR_PREFIX_CODE}
get_filename_component(AMD_COMGR_PREFIX \"\${AMD_COMGR_PREFIX}\" PATH)")
@@ -278,20 +278,20 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(LLD REQUIRED)\n")
endif()
-set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
+set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
+ "${AMD_COMGR_CONFIG_NAME}.install"
@ONLY)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}"
RENAME "${AMD_COMGR_CONFIG_NAME}")
install(EXPORT amd_comgr_export
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}"
FILE "${AMD_COMGR_TARGETS_NAME}")
install(FILES
"${AMD_COMGR_VERSION_PATH}"
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}")
if(TARGET clangFrontendTool)
set(CLANG_LIBS
diff --git a/cmake/DeviceLibs.cmake b/cmake/DeviceLibs.cmake
index 27e9546..dfe1b57 100644
--- a/cmake/DeviceLibs.cmake
+++ b/cmake/DeviceLibs.cmake
@@ -1,8 +1,7 @@
set(INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
set(GEN_LIBRARY_INC_FILE ${INC_DIR}/libraries.inc)
-
-file(WRITE ${GEN_LIBRARY_INC_FILE} "// Automatically generated file; DO NOT EDIT.\n")
+set(GEN_LIBRARY_DEFS_INC_FILE ${INC_DIR}/libraries_defs.inc)
# cmake does not provide a way to query targets produced by a project,
# so we have to make one up. Ordinarily, individual library target
@@ -23,6 +22,7 @@ if(NOT AMD_DEVICE_LIBS_TARGETS)
message(FATAL_ERROR "Could not find list of device libraries")
endif()
+set(TARGETS_INCLUDES "")
foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
set(header ${AMDGCN_LIB_TARGET}.inc)
@@ -54,75 +54,52 @@ foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
add_custom_target(${AMDGCN_LIB_TARGET}_header DEPENDS ${INC_DIR}/${header})
add_dependencies(amd_comgr ${AMDGCN_LIB_TARGET}_header)
- file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"${header}\"\n")
+ list(APPEND TARGETS_INCLUDES "#include \"${header}\"")
+endforeach()
+
+list(JOIN TARGETS_INCLUDES "\n" TARGETS_INCLUDES)
+file(GENERATE OUTPUT ${GEN_LIBRARY_INC_FILE} CONTENT "${TARGETS_INCLUDES}")
+
+foreach(OPENCL_VERSION 1.2 2.0)
+ string(REPLACE . _ OPENCL_UNDERSCORE_VERSION ${OPENCL_VERSION})
+ add_custom_command(OUTPUT ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc
+ COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl${OPENCL_VERSION}-c.pch
+ ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc
+ opencl${OPENCL_UNDERSCORE_VERSION}_c
+ DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl${OPENCL_VERSION}-c.pch
+ COMMENT "Generating opencl${OPENCL_VERSION}-c.inc"
+ )
+ set_property(DIRECTORY APPEND PROPERTY
+ ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc)
+ add_custom_target(opencl${OPENCL_VERSION}-c.inc_target DEPENDS ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc)
+ add_dependencies(amd_comgr opencl${OPENCL_VERSION}-c.inc_target)
endforeach()
-add_custom_command(OUTPUT ${INC_DIR}/opencl1.2-c.inc
- COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.pch
- ${INC_DIR}/opencl1.2-c.inc
- opencl1_2_c
- DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.pch
- COMMENT "Generating opencl1.2-c.inc"
-)
-set_property(DIRECTORY APPEND PROPERTY
- ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl1.2-c.inc)
-add_custom_target(opencl1.2-c.inc_target DEPENDS ${INC_DIR}/opencl1.2-c.inc)
-add_dependencies(amd_comgr opencl1.2-c.inc_target)
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"opencl1.2-c.inc\"\n")
-
-add_custom_command(OUTPUT ${INC_DIR}/opencl2.0-c.inc
- COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.pch
- ${INC_DIR}/opencl2.0-c.inc
- opencl2_0_c
- DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.pch
- COMMENT "Generating opencl2.0-c.inc"
-)
-set_property(DIRECTORY APPEND PROPERTY
- ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl2.0-c.inc)
-add_custom_target(opencl2.0-c.inc_target DEPENDS ${INC_DIR}/opencl2.0-c.inc)
-add_dependencies(amd_comgr opencl2.0-c.inc_target)
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"opencl2.0-c.inc\"\n")
-
-# Generate function to select libraries for a given GFXIP number.
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"llvm/ADT/StringRef.h\"\n")
-file(APPEND ${GEN_LIBRARY_INC_FILE}
- "static std::tuple<const char*, const void*, size_t> get_oclc_isa_version(llvm::StringRef gfxip) {")
+set(TARGETS_DEFS "")
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_TARGET\n#define AMD_DEVICE_LIBS_TARGET(t)\n#endif")
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_GFXIP\n#define AMD_DEVICE_LIBS_GFXIP(t, g)\n#endif")
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_FUNCTION\n#define AMD_DEVICE_LIBS_FUNCTION(t, f)\n#endif")
+list(APPEND TARGETS_DEFS "")
foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_TARGET(${AMDGCN_LIB_TARGET})")
+ # Generate function to select libraries for a given GFXIP number.
if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_isa_version_.+$")
string(REGEX REPLACE "^oclc_isa_version_(.+)$" "\\1" gfxip ${AMDGCN_LIB_TARGET})
- file(APPEND ${GEN_LIBRARY_INC_FILE}
- "if (gfxip == \"${gfxip}\") return std::make_tuple(\"${AMDGCN_LIB_TARGET}.bc\", ${AMDGCN_LIB_TARGET}_lib, ${AMDGCN_LIB_TARGET}_lib_size);")
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_GFXIP(${AMDGCN_LIB_TARGET}, \"${gfxip}\")")
endif()
-endforeach()
-file(APPEND ${GEN_LIBRARY_INC_FILE}
- "return std::make_tuple(nullptr, nullptr, 0); }")
-
-# Generate function to select libraries for given feature.
-foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
+ # Generate function to select libraries for given feature.
if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_.*_on$")
string(REGEX REPLACE "^oclc_(.*)_on" "\\1" function ${AMDGCN_LIB_TARGET})
- file(APPEND ${GEN_LIBRARY_INC_FILE}
- "static std::tuple<const char*, const void*, size_t> get_oclc_${function}(bool on) { \
- return std::make_tuple( \
- on ? \"oclc_${function}_on_lib.bc\" : \"oclc_${function}_off_lib.bc\", \
- on ? oclc_${function}_on_lib : oclc_${function}_off_lib, \
- on ? oclc_${function}_on_lib_size : oclc_${function}_off_lib_size \
- ); }")
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_FUNCTION(${AMDGCN_LIB_TARGET}, ${function})")
endif()
endforeach()
-# Generate function yield all libraries.
-file(APPEND ${GEN_LIBRARY_INC_FILE} "\n#include \"llvm/ADT/ArrayRef.h\"\n")
-file(APPEND ${GEN_LIBRARY_INC_FILE}
- "llvm::ArrayRef<std::tuple<llvm::StringRef, llvm::StringRef>> COMGR::getDeviceLibraries() { \
- static std::tuple<llvm::StringRef, llvm::StringRef> DeviceLibs[] = {")
-foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
- file(APPEND ${GEN_LIBRARY_INC_FILE}
- "{\"${AMDGCN_LIB_TARGET}.bc\", llvm::StringRef(reinterpret_cast<const char *>(${AMDGCN_LIB_TARGET}_lib), ${AMDGCN_LIB_TARGET}_lib_size)},")
-endforeach()
-file(APPEND ${GEN_LIBRARY_INC_FILE}
- "}; \
- return DeviceLibs; \
- }")
+list(APPEND TARGETS_DEFS "")
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_TARGET")
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_GFXIP")
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_FUNCTION")
+
+list(JOIN TARGETS_DEFS "\n" TARGETS_DEFS)
+file(GENERATE OUTPUT ${GEN_LIBRARY_DEFS_INC_FILE} CONTENT "${TARGETS_DEFS}")
include_directories(${INC_DIR})
diff --git a/cmake/bc2h.cmake b/cmake/bc2h.cmake
index 146fe2b..9134985 100644
--- a/cmake/bc2h.cmake
@ -222,3 +310,56 @@ index 146fe2b..9134985 100644
add_executable(bc2h ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
diff --git a/src/comgr-device-libs.cpp b/src/comgr-device-libs.cpp
index 4d2b914..80786d1 100644
--- a/src/comgr-device-libs.cpp
+++ b/src/comgr-device-libs.cpp
@@ -35,7 +35,7 @@
#include "comgr-device-libs.h"
#include "comgr.h"
-#include "libraries.inc"
+#include "comgr-libraries.h"
#include "llvm/ADT/StringSwitch.h"
#include <cstdint>
diff --git a/src/comgr-libraries.h b/src/comgr-libraries.h
new file mode 100644
index 0000000..3caa0a0
--- /dev/null
+++ b/src/comgr-libraries.h
@@ -0,0 +1,34 @@
+#include "libraries.inc"
+#include "opencl1.2-c.inc"
+#include "opencl2.0-c.inc"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/ArrayRef.h"
+
+static std::tuple<const char*, const void*, size_t> get_oclc_isa_version(llvm::StringRef gfxip) {
+#define AMD_DEVICE_LIBS_GFXIP(target, target_gfxip) \
+ if (gfxip == target_gfxip) return std::make_tuple(#target ".bc", target##_lib, target##_lib_size);
+#include "libraries_defs.inc"
+
+ return std::make_tuple(nullptr, nullptr, 0);
+}
+
+#define AMD_DEVICE_LIBS_FUNCTION(target, function) \
+ static std::tuple<const char*, const void*, size_t> get_oclc_##function(bool on) { \
+ return std::make_tuple( \
+ on ? "oclc_" #function "_on_lib.bc" : "oclc_" #function "_off_lib.bc", \
+ on ? oclc_##function##_on_lib : oclc_##function##_off_lib, \
+ on ? oclc_##function##_on_lib_size : oclc_##function##_off_lib_size \
+ ); \
+ }
+#include "libraries_defs.inc"
+
+llvm::ArrayRef<std::tuple<llvm::StringRef, llvm::StringRef>> COMGR::getDeviceLibraries() {
+ static std::tuple<llvm::StringRef, llvm::StringRef> DeviceLibs[] = {
+#define AMD_DEVICE_LIBS_TARGET(target) \
+ {#target ".bc", llvm::StringRef(reinterpret_cast<const char *>(target##_lib), target##_lib_size)},
+#include "libraries_defs.inc"
+ };
+ return DeviceLibs;
+}
+
+

View File

@ -2,13 +2,13 @@
stdenv.mkDerivation rec {
pname = "rocm-comgr";
version = "5.2.0";
version = "5.3.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCm-CompilerSupport";
rev = "rocm-${version}";
hash = "sha256-5C5bRdrt3xZAlRgtiIRTMAuwsFvVM4Win96P5+Pf5ZM=";
hash = "sha256-LQyMhqcWm8zqt6138fnT7EOq/F8bG3Iuf04PTemVQmg=";
};
sourceRoot = "source/lib/comgr";
@ -18,7 +18,6 @@ stdenv.mkDerivation rec {
buildInputs = [ clang rocm-device-libs llvm ];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_C_COMPILER=${clang}/bin/clang"
"-DCMAKE_CXX_COMPILER=${clang}/bin/clang++"
"-DCMAKE_PREFIX_PATH=${llvm}/lib/cmake/llvm"
@ -39,7 +38,7 @@ stdenv.mkDerivation rec {
description = "APIs for compiling and inspecting AMDGPU code objects";
homepage = "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr";
license = licenses.ncsa;
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
platforms = platforms.linux;
};
}

View File

@ -0,0 +1,43 @@
diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake
index 07c60eb..c736b3e 100644
--- a/cmake/Packages.cmake
+++ b/cmake/Packages.cmake
@@ -12,24 +12,29 @@ set_target_properties(${target} PROPERTIES
IMPORTED_LOCATION \"${target_path}\")")
endforeach()
configure_file(AMDDeviceLibsConfig.cmake.in
- ${PACKAGE_PREFIX}/AMDDeviceLibsConfig.cmake
+ lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake
@ONLY)
set(install_path_suffix "amdgcn/bitcode")
# Generate the install-tree package.
-# We do not know the absolute path to the intall tree until we are installed,
-# so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use
-# relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE.
-set(AMD_DEVICE_LIBS_PREFIX_CODE "
+if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
+ set(AMD_DEVICE_LIBS_PREFIX_CODE "set(AMD_DEVICE_LIBS_PREFIX \"${CMAKE_INSTALL_PREFIX}\")")
+else()
+ # We do not know the absolute path to the install tree until we are installed,
+ # so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use
+ # relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE.
+ set(AMD_DEVICE_LIBS_PREFIX_CODE "
# Derive absolute install prefix from config file path.
get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}")
-foreach(p ${count})
- set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE}
+ string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}")
+ foreach(p ${count})
+ set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE}
get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${AMD_DEVICE_LIBS_PREFIX}\" PATH)")
-endforeach()
+ endforeach()
+endif()
+
set(AMD_DEVICE_LIBS_TARGET_CODE)
foreach(target ${AMDGCN_LIB_LIST})
get_target_property(target_name ${target} ARCHIVE_OUTPUT_NAME)

View File

@ -8,13 +8,13 @@
stdenv.mkDerivation rec {
pname = "rocm-device-libs";
version = "5.2.0";
version = "5.3.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCm-Device-Libs";
rev = "rocm-${version}";
hash = "sha256-TBCSznHyiaiOcBR9irybCnOgfqPiNNn4679PCQwrLhA=";
hash = "sha256-rKMe0B/pkDek/ZU37trnJNa8aqvlwxobPb1+VTx/bJU=";
};
nativeBuildInputs = [ cmake ];
@ -27,6 +27,8 @@ stdenv.mkDerivation rec {
"-DCLANG=${clang}/bin/clang"
];
patches = [ ./cmake.patch ];
passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts
@ -38,7 +40,7 @@ stdenv.mkDerivation rec {
description = "Set of AMD-specific device-side language runtime libraries";
homepage = "https://github.com/RadeonOpenCompute/ROCm-Device-Libs";
license = licenses.ncsa;
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
platforms = platforms.linux;
};
}

View File

@ -22,13 +22,13 @@
stdenv.mkDerivation rec {
pname = "rocm-opencl-runtime";
version = "5.2.1";
version = "5.3.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCm-OpenCL-Runtime";
rev = "rocm-${version}";
hash = "sha256-Mk7Wssz34Uxtb9PRIEGrTn/tXtqxLMrq0damA/p/DsY=";
hash = "sha256-QvAF25Zfq9d1M/KIsr2S+Ggxzqw/MQ2OVcm9ZNfjTa8=";
};
nativeBuildInputs = [ cmake rocm-cmake ];
@ -79,7 +79,7 @@ stdenv.mkDerivation rec {
description = "OpenCL runtime for AMD GPUs, part of the ROCm stack";
homepage = "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime";
license = with licenses; [ asl20 mit ];
maintainers = with maintainers; [ acowley lovesegfault ];
maintainers = with maintainers; [ acowley lovesegfault Flakebi ];
platforms = platforms.linux;
};
}

View File

@ -4,8 +4,10 @@
, writeScript
, addOpenGLRunpath
, cmake
, pkg-config
, xxd
, elfutils
, libdrm
, llvm
, numactl
, rocm-device-libs
@ -13,28 +15,33 @@
stdenv.mkDerivation rec {
pname = "rocm-runtime";
version = "5.2.0";
version = "5.3.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCR-Runtime";
rev = "rocm-${version}";
hash = "sha256-TY0YPgNzxBLXAj7fncLQ01cSJyydveOLHrimCmLS32o=";
hash = "sha256-26E7vA2JlC50zmpaQfDrFMlgjAqmfTdp9/A8g5caDqI=";
};
sourceRoot = "source/src";
nativeBuildInputs = [ cmake xxd ];
nativeBuildInputs = [ cmake pkg-config xxd ];
buildInputs = [ elfutils llvm numactl ];
buildInputs = [ elfutils libdrm llvm numactl ];
cmakeFlags = [
"-DBITCODE_DIR=${rocm-device-libs}/amdgcn/bitcode"
"-DCMAKE_PREFIX_PATH=${rocm-thunk}"
];
cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${rocm-thunk}" ];
postPatch = ''
patchShebangs image/blit_src/create_hsaco_ascii_file.sh
patchShebangs core/runtime/trap_handler/create_trap_handler_header.sh
substituteInPlace CMakeLists.txt \
--replace 'hsa/include/hsa' 'include/hsa'
# We compile clang before rocm-device-libs, so patch it in afterwards
substituteInPlace image/blit_src/CMakeLists.txt \
--replace '-cl-denorms-are-zero' '-cl-denorms-are-zero --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode'
'';
fixupPhase = ''
@ -52,6 +59,6 @@ stdenv.mkDerivation rec {
description = "Platform runtime for ROCm";
homepage = "https://github.com/RadeonOpenCompute/ROCR-Runtime";
license = with licenses; [ ncsa ];
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
};
}

View File

@ -9,13 +9,13 @@
stdenv.mkDerivation rec {
pname = "rocm-thunk";
version = "5.2.1";
version = "5.3.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCT-Thunk-Interface";
rev = "rocm-${version}";
hash = "sha256-iXhlEofPAQNxeZzDgdF1DdflIKfSI7rHGTqOybHnnHM=";
hash = "sha256-cM78Bx6uYsxhvdqSVNgmqOUYQnUJVCA7mNpRNNSFv6k=";
};
preConfigure = ''
@ -48,6 +48,6 @@ stdenv.mkDerivation rec {
description = "Radeon open compute thunk interface";
homepage = "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface";
license = with licenses; [ bsd2 mit ];
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
};
}

View File

@ -2,13 +2,13 @@
stdenv.mkDerivation rec {
pname = "rocm-cmake";
version = "5.2.0";
version = "5.3.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "rocm-cmake";
rev = "rocm-${version}";
hash = "sha256-2YALk3G5BhrsXZZHjGSSuk8tCi5sNGuB2VB4uvozyZo=";
hash = "sha256-AOn3SLprHdeo2FwojQdhRAttUHuaWkO6WlymK8Q8lbc=";
};
nativeBuildInputs = [ cmake ];
@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
description = "CMake modules for common build tasks for the ROCm stack";
homepage = "https://github.com/RadeonOpenCompute/rocm-cmake";
license = licenses.mit;
maintainers = with maintainers; [ ];
maintainers = with maintainers; [ Flakebi ];
platforms = platforms.unix;
};
}

View File

@ -7,13 +7,13 @@
# compilers to determine the desired target.
, defaultTargets ? []}:
stdenv.mkDerivation rec {
version = "5.1.1";
version = "5.3.0";
pname = "rocminfo";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "rocminfo";
rev = "rocm-${version}";
sha256 = "sha256-x+QJJtUvgtNS4116tJFWdJOUS8yV4o10mbTAUuxerkE=";
sha256 = "sha256-4wZTm5AZgG8xEd6uYqxWq4bWZgcSYZ2WYA1z4RAPF8U=";
};
enableParallelBuilding = true;
@ -48,7 +48,7 @@ stdenv.mkDerivation rec {
description = "ROCm Application for Reporting System Info";
homepage = "https://github.com/RadeonOpenCompute/rocminfo";
license = licenses.ncsa;
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
platforms = platforms.linux;
};
}

View File

@ -0,0 +1,89 @@
diff --git a/rocm_smi-backward-compat.cmake b/rocm_smi-backward-compat.cmake
index aa8fd9c..59afce5 100644
--- a/rocm_smi-backward-compat.cmake
+++ b/rocm_smi-backward-compat.cmake
@@ -72,7 +72,12 @@ function(generate_wrapper_header)
set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H")
#set #include statement
get_filename_component(file_name ${header_file} NAME)
- set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${ROCM_SMI}/${file_name}\"\n")
+ if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
+ set(include_dir "${CMAKE_INSTALL_INCLUDEDIR}")
+ else()
+ set(include_dir "../../../${CMAKE_INSTALL_INCLUDEDIR}")
+ endif()
+ set(include_statements "${include_statements}#include \"${include_dir}/${ROCM_SMI}/${file_name}\"\n")
configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${RSMI_WRAPPER_INC_DIR}/${file_name})
unset(include_guard)
unset(include_statements)
@@ -90,7 +95,12 @@ function(generate_wrapper_header)
set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H")
#set #include statement
get_filename_component(file_name ${header_file} NAME)
- set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${OAM_TARGET_NAME}/${file_name}\"\n")
+ if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
+ set(include_dir "${CMAKE_INSTALL_INCLUDEDIR}")
+ else()
+ set(include_dir "../../../${CMAKE_INSTALL_INCLUDEDIR}")
+ endif()
+ set(include_statements "${include_statements}#include \"${include_dir}/${OAM_TARGET_NAME}/${file_name}\"\n")
configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${OAM_WRAPPER_INC_DIR}/${file_name})
unset(include_guard)
unset(include_statements)
@@ -123,11 +133,16 @@ function(create_library_symlink)
set(library_files "${LIB_RSMI}")
endif()
+ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
+ set(install_libdir "${CMAKE_INSTALL_LIBDIR}")
+ else()
+ set(install_libdir "../../${CMAKE_INSTALL_LIBDIR}")
+ endif()
foreach(file_name ${library_files})
add_custom_target(link_${file_name} ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E create_symlink
- ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name})
+ ${install_libdir}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name})
endforeach()
file(MAKE_DIRECTORY ${OAM_WRAPPER_LIB_DIR})
@@ -151,11 +166,16 @@ function(create_library_symlink)
set(library_files "${LIB_OAM}")
endif()
+ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
+ set(install_libdir "${CMAKE_INSTALL_LIBDIR}")
+ else()
+ set(install_libdir "../../${CMAKE_INSTALL_LIBDIR}")
+ endif()
foreach(file_name ${library_files})
add_custom_target(link_${file_name} ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E create_symlink
- ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name})
+ ${install_libdir}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name})
endforeach()
endfunction()
diff --git a/rocm_smi/CMakeLists.txt b/rocm_smi/CMakeLists.txt
index c594eeb..d3ed39d 100755
--- a/rocm_smi/CMakeLists.txt
+++ b/rocm_smi/CMakeLists.txt
@@ -105,10 +105,15 @@ endif ()
#file reorganization changes
#rocm_smi.py moved to libexec/rocm_smi. so creating rocm-smi symlink
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
+if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBEXECDIR})
+ set(install_libexecdir "${CMAKE_INSTALL_LIBEXECDIR}")
+else()
+ set(install_libexecdir "../${CMAKE_INSTALL_LIBEXECDIR}")
+endif()
add_custom_target(link-rocm-smi ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E create_symlink
- ../${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi)
+ ${install_libexecdir}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi)
## Add the install directives for the runtime library.
install(TARGETS ${ROCM_SMI_TARGET}

View File

@ -2,37 +2,18 @@
stdenv.mkDerivation rec {
pname = "rocm-smi";
version = "5.2.3";
version = "5.3.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "rocm_smi_lib";
rev = "rocm-${version}";
hash = "sha256-D3ZH6xJe2C9rUCsJPOf9QlStecU90/iYi4wrXVvPff0=";
hash = "sha256-UbGbkH2vhQ9gv3sSoG+mXap+MdcrP61TN5DcP5F/5nQ=";
};
nativeBuildInputs = [ cmake wrapPython ];
postPatch = ''
# Upstream ROCm is installed in an /opt directory. For this reason,
# it does not completely follow FHS layout, creating top-level
# rocm_smi, oam, and bindings top-level directories. Since rocm-smi
# is a package that is typically installed, we change the paths to
# follow FHS more closely.
# rocm_smi libraries and headers go into lib and include. Bindings
# go into lib/rocm_smi/bindings.
substituteInPlace rocm_smi/CMakeLists.txt \
--replace "DESTINATION rocm_smi/" "DESTINATION " \
--replace "DESTINATION bindings" "DESTINATION lib/rocm_smi/bindings" \
--replace "../rocm_smi/bindings/rsmiBindings.py" "../lib/rocm_smi/bindings/rsmiBindings.py" \
--replace 'DESTINATION ''${ROCM_SMI}/' "DESTINATION "
# oam libraries and headers go into lib and include.
substituteInPlace oam/CMakeLists.txt \
--replace "DESTINATION oam/" "DESTINATION " \
--replace 'DESTINATION ''${OAM_NAME}/' "DESTINATION "
'';
patches = [ ./cmake.patch ];
postInstall = ''
wrapPythonProgramsIn $out
@ -49,7 +30,7 @@ stdenv.mkDerivation rec {
description = "System management interface for AMD GPUs supported by ROCm";
homepage = "https://github.com/RadeonOpenCompute/rocm_smi_lib";
license = with licenses; [ mit ];
maintainers = with maintainers; [ lovesegfault ];
maintainers = with maintainers; [ lovesegfault Flakebi ];
platforms = [ "x86_64-linux" ];
};
}