tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
rocm-comgr: 5.2.0 → 5.3.0
Sebastian Neubauer
3 years ago
6bd35937
1d6f9948
+239
-99
2 changed files
expand all
collapse all
unified
split
pkgs
development
libraries
rocm-comgr
cmake.patch
default.nix
+236
-95
pkgs/development/libraries/rocm-comgr/cmake.patch
···
1
1
diff --git a/CMakeLists.txt b/CMakeLists.txt
2
2
-
index eac270a..27610ec 100644
2
2
+
index 62b857b..d21c7f4 100644
3
3
--- a/CMakeLists.txt
4
4
+++ b/CMakeLists.txt
5
5
-
@@ -53,10 +53,6 @@ set(SOURCES
6
6
-
7
7
-
if(COMGR_BUILD_SHARED_LIBS)
8
8
-
add_library(amd_comgr SHARED ${SOURCES})
9
9
-
- # Windows doesn't have a strip utility, so CMAKE_STRIP won't be set.
10
10
-
- if((CMAKE_BUILD_TYPE STREQUAL "Release") AND NOT ("${CMAKE_STRIP}" STREQUAL ""))
11
11
-
- add_custom_command(TARGET amd_comgr POST_BUILD COMMAND ${CMAKE_STRIP} $<TARGET_FILE:amd_comgr>)
12
12
-
- endif()
13
13
-
else()
14
14
-
add_library(amd_comgr STATIC ${SOURCES})
15
15
-
endif()
16
16
-
@@ -141,8 +137,8 @@ if (UNIX)
5
5
+
@@ -147,8 +147,8 @@ if (UNIX)
17
6
list(APPEND AMD_COMGR_PUBLIC_LINKER_OPTIONS -pthread)
18
7
if (NOT APPLE AND COMGR_BUILD_SHARED_LIBS)
19
8
configure_file(
···
24
13
list(APPEND AMD_COMGR_PRIVATE_LINKER_OPTIONS
25
14
"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/src/exportmap")
26
15
# When building a shared library with -fsanitize=address we can't be
27
27
-
@@ -154,6 +150,9 @@ if (UNIX)
28
28
-
-Wl,--no-undefined)
29
29
-
endif()
30
30
-
endif()
31
31
-
+
32
32
-
+ # Strip in release build
33
33
-
+ set_target_properties(amd_comgr PROPERTIES LINK_FLAGS_RELEASE -s)
34
34
-
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
35
35
-
list(APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS
36
36
-
"/wd4244" #[[Suppress 'argument' : conversion from 'type1' to 'type2', possible loss of data]]
37
37
-
@@ -169,10 +168,6 @@ endif()
16
16
+
@@ -175,10 +175,6 @@ endif()
38
17
# the shared header.
39
18
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS AMD_COMGR_EXPORT)
40
19
···
45
24
include(bc2h)
46
25
include(opencl_pch)
47
26
include(DeviceLibs)
48
48
-
@@ -203,8 +198,11 @@ target_compile_definitions(amd_comgr
49
49
-
PRIVATE "${AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS}")
50
50
-
target_include_directories(amd_comgr
51
51
-
PUBLIC
52
52
-
- $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
53
53
-
- $<INSTALL_INTERFACE:include>)
54
54
-
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)
55
55
-
+
27
27
+
@@ -212,10 +208,14 @@ target_include_directories(amd_comgr
28
28
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
29
29
+
$<INSTALL_INTERFACE:include>)
30
30
+
56
31
+configure_file(
57
32
+ include/amd_comgr.h.in
58
33
+ include/amd_comgr.h @ONLY)
59
59
-
34
34
+
+
60
35
set(AMD_COMGR_CONFIG_NAME amd_comgr-config.cmake)
61
36
set(AMD_COMGR_TARGETS_NAME amd_comgr-targets.cmake)
62
62
-
@@ -220,29 +218,30 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
37
37
+
set(AMD_COMGR_VERSION_NAME amd_comgr-config-version.cmake)
38
38
+
-set(AMD_COMGR_PACKAGE_PREFIX ${CMAKE_INSTALL_LIBDIR}/cmake/amd_comgr)
39
39
+
+set(AMD_COMGR_PACKAGE_PREFIX cmake/amd_comgr)
40
40
+
41
41
+
# Generate the build-tree package.
42
42
+
set(AMD_COMGR_PREFIX_CODE)
43
43
+
@@ -226,13 +226,13 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
63
44
endif()
64
45
65
46
set(AMD_COMGR_TARGETS_PATH
66
47
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
67
67
-
-set(AMD_COMGR_VERSION_PATH
48
48
+
+ "${CMAKE_CURRENT_BINARY_DIR}/lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
49
49
+
set(AMD_COMGR_VERSION_PATH
68
50
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}")
69
69
-
-export(TARGETS amd_comgr
51
51
+
+ "${CMAKE_CURRENT_BINARY_DIR}/lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}")
52
52
+
export(TARGETS amd_comgr
70
53
- FILE "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
71
71
-
+ "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
54
54
+
+ FILE "lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
72
55
configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
73
56
- "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}"
74
74
-
+ ${AMD_COMGR_CONFIG_NAME}
57
57
+
+ "lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}"
75
58
@ONLY)
76
76
-
-write_basic_package_version_file("${AMD_COMGR_VERSION_PATH}"
77
77
-
+write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_VERSION_NAME}"
59
59
+
write_basic_package_version_file("${AMD_COMGR_VERSION_PATH}"
78
60
VERSION "${amd_comgr_VERSION}"
79
79
-
COMPATIBILITY SameMajorVersion)
80
80
-
81
81
-
install(TARGETS amd_comgr
82
82
-
EXPORT amd_comgr_export
83
83
-
- COMPONENT amd-comgr
84
84
-
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
85
85
-
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
86
86
-
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
87
87
-
+ COMPONENT amd-comgr)
88
88
-
+install(EXPORT amd_comgr_export
89
89
-
+ DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
90
90
-
+ FILE "${AMD_COMGR_TARGETS_NAME}")
61
61
+
@@ -266,7 +266,7 @@ install(FILES
62
62
+
set(AMD_COMGR_PREFIX_CODE "
63
63
+
# Derive absolute install prefix from config file path.
64
64
+
get_filename_component(AMD_COMGR_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
65
65
+
-string(REGEX REPLACE "/" ";" count "${AMD_COMGR_PACKAGE_PREFIX}")
66
66
+
+string(REGEX REPLACE "/" ";" count "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}")
67
67
+
foreach(p ${count})
68
68
+
set(AMD_COMGR_PREFIX_CODE "${AMD_COMGR_PREFIX_CODE}
69
69
+
get_filename_component(AMD_COMGR_PREFIX \"\${AMD_COMGR_PREFIX}\" PATH)")
70
70
+
@@ -278,20 +278,20 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
71
71
+
string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(LLD REQUIRED)\n")
72
72
+
endif()
91
73
74
74
+
-set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
75
75
+
+set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
76
76
+
configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
77
77
+
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
78
78
+
+ "${AMD_COMGR_CONFIG_NAME}.install"
79
79
+
@ONLY)
92
80
install(FILES
93
93
-
"${CMAKE_CURRENT_BINARY_DIR}/include/amd_comgr.h"
94
94
-
COMPONENT amd-comgr
95
95
-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
96
96
-
+install(FILES
97
97
-
+ "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}"
98
98
-
+ "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_VERSION_NAME}"
99
99
-
+ COMPONENT amd-comgr
100
100
-
+ DESTINATION ${AMD_COMGR_PACKAGE_PREFIX})
81
81
+
"${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
82
82
+
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
83
83
+
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}"
84
84
+
RENAME "${AMD_COMGR_CONFIG_NAME}")
85
85
+
install(EXPORT amd_comgr_export
86
86
+
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
87
87
+
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}"
88
88
+
FILE "${AMD_COMGR_TARGETS_NAME}")
89
89
+
install(FILES
90
90
+
"${AMD_COMGR_VERSION_PATH}"
91
91
+
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
92
92
+
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}")
93
93
+
94
94
+
if(TARGET clangFrontendTool)
95
95
+
set(CLANG_LIBS
96
96
+
diff --git a/cmake/DeviceLibs.cmake b/cmake/DeviceLibs.cmake
97
97
+
index 27e9546..dfe1b57 100644
98
98
+
--- a/cmake/DeviceLibs.cmake
99
99
+
+++ b/cmake/DeviceLibs.cmake
100
100
+
@@ -1,8 +1,7 @@
101
101
+
set(INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
102
102
+
103
103
+
set(GEN_LIBRARY_INC_FILE ${INC_DIR}/libraries.inc)
104
104
+
-
105
105
+
-file(WRITE ${GEN_LIBRARY_INC_FILE} "// Automatically generated file; DO NOT EDIT.\n")
106
106
+
+set(GEN_LIBRARY_DEFS_INC_FILE ${INC_DIR}/libraries_defs.inc)
107
107
+
108
108
+
# cmake does not provide a way to query targets produced by a project,
109
109
+
# so we have to make one up. Ordinarily, individual library target
110
110
+
@@ -23,6 +22,7 @@ if(NOT AMD_DEVICE_LIBS_TARGETS)
111
111
+
message(FATAL_ERROR "Could not find list of device libraries")
112
112
+
endif()
113
113
+
114
114
+
+set(TARGETS_INCLUDES "")
115
115
+
foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
116
116
+
set(header ${AMDGCN_LIB_TARGET}.inc)
117
117
+
118
118
+
@@ -54,75 +54,52 @@ foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
119
119
+
add_custom_target(${AMDGCN_LIB_TARGET}_header DEPENDS ${INC_DIR}/${header})
120
120
+
add_dependencies(amd_comgr ${AMDGCN_LIB_TARGET}_header)
101
121
102
102
-
install(FILES
103
103
-
"README.md"
104
104
-
@@ -251,37 +250,6 @@ install(FILES
105
105
-
COMPONENT amd-comgr
106
106
-
DESTINATION ${CMAKE_INSTALL_DATADIR}/amd_comgr)
122
122
+
- file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"${header}\"\n")
123
123
+
+ list(APPEND TARGETS_INCLUDES "#include \"${header}\"")
124
124
+
+endforeach()
125
125
+
+
126
126
+
+list(JOIN TARGETS_INCLUDES "\n" TARGETS_INCLUDES)
127
127
+
+file(GENERATE OUTPUT ${GEN_LIBRARY_INC_FILE} CONTENT "${TARGETS_INCLUDES}")
128
128
+
+
129
129
+
+foreach(OPENCL_VERSION 1.2 2.0)
130
130
+
+ string(REPLACE . _ OPENCL_UNDERSCORE_VERSION ${OPENCL_VERSION})
131
131
+
+ add_custom_command(OUTPUT ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc
132
132
+
+ COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl${OPENCL_VERSION}-c.pch
133
133
+
+ ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc
134
134
+
+ opencl${OPENCL_UNDERSCORE_VERSION}_c
135
135
+
+ DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl${OPENCL_VERSION}-c.pch
136
136
+
+ COMMENT "Generating opencl${OPENCL_VERSION}-c.inc"
137
137
+
+ )
138
138
+
+ set_property(DIRECTORY APPEND PROPERTY
139
139
+
+ ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc)
140
140
+
+ add_custom_target(opencl${OPENCL_VERSION}-c.inc_target DEPENDS ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc)
141
141
+
+ add_dependencies(amd_comgr opencl${OPENCL_VERSION}-c.inc_target)
142
142
+
endforeach()
107
143
108
108
-
-# Generate the install-tree package.
109
109
-
-set(AMD_COMGR_PREFIX_CODE "
110
110
-
-# Derive absolute install prefix from config file path.
111
111
-
-get_filename_component(AMD_COMGR_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
112
112
-
-string(REGEX REPLACE "/" ";" count "${AMD_COMGR_PACKAGE_PREFIX}")
113
113
-
-foreach(p ${count})
114
114
-
- set(AMD_COMGR_PREFIX_CODE "${AMD_COMGR_PREFIX_CODE}
115
115
-
-get_filename_component(AMD_COMGR_PREFIX \"\${AMD_COMGR_PREFIX}\" PATH)")
116
116
-
-endforeach()
144
144
+
-add_custom_command(OUTPUT ${INC_DIR}/opencl1.2-c.inc
145
145
+
- COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.pch
146
146
+
- ${INC_DIR}/opencl1.2-c.inc
147
147
+
- opencl1_2_c
148
148
+
- DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.pch
149
149
+
- COMMENT "Generating opencl1.2-c.inc"
150
150
+
-)
151
151
+
-set_property(DIRECTORY APPEND PROPERTY
152
152
+
- ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl1.2-c.inc)
153
153
+
-add_custom_target(opencl1.2-c.inc_target DEPENDS ${INC_DIR}/opencl1.2-c.inc)
154
154
+
-add_dependencies(amd_comgr opencl1.2-c.inc_target)
155
155
+
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"opencl1.2-c.inc\"\n")
117
156
-
118
118
-
-if (NOT COMGR_BUILD_SHARED_LIBS)
119
119
-
- string(APPEND AMD_COMGR_PREFIX_CODE "\ninclude(CMakeFindDependencyMacro)\n")
120
120
-
- string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(Clang REQUIRED)\n")
121
121
-
- string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(LLD REQUIRED)\n")
122
122
-
-endif()
157
157
+
-add_custom_command(OUTPUT ${INC_DIR}/opencl2.0-c.inc
158
158
+
- COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.pch
159
159
+
- ${INC_DIR}/opencl2.0-c.inc
160
160
+
- opencl2_0_c
161
161
+
- DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.pch
162
162
+
- COMMENT "Generating opencl2.0-c.inc"
163
163
+
-)
164
164
+
-set_property(DIRECTORY APPEND PROPERTY
165
165
+
- ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl2.0-c.inc)
166
166
+
-add_custom_target(opencl2.0-c.inc_target DEPENDS ${INC_DIR}/opencl2.0-c.inc)
167
167
+
-add_dependencies(amd_comgr opencl2.0-c.inc_target)
168
168
+
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"opencl2.0-c.inc\"\n")
123
169
-
124
124
-
-set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
125
125
-
-configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
126
126
-
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
127
127
-
- @ONLY)
128
128
-
-install(FILES
129
129
-
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
130
130
-
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
131
131
-
- RENAME "${AMD_COMGR_CONFIG_NAME}")
132
132
-
-install(EXPORT amd_comgr_export
133
133
-
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
134
134
-
- FILE "${AMD_COMGR_TARGETS_NAME}")
135
135
-
-install(FILES
136
136
-
- "${AMD_COMGR_VERSION_PATH}"
137
137
-
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
170
170
+
-# Generate function to select libraries for a given GFXIP number.
171
171
+
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"llvm/ADT/StringRef.h\"\n")
172
172
+
-file(APPEND ${GEN_LIBRARY_INC_FILE}
173
173
+
- "static std::tuple<const char*, const void*, size_t> get_oclc_isa_version(llvm::StringRef gfxip) {")
174
174
+
+set(TARGETS_DEFS "")
175
175
+
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_TARGET\n#define AMD_DEVICE_LIBS_TARGET(t)\n#endif")
176
176
+
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_GFXIP\n#define AMD_DEVICE_LIBS_GFXIP(t, g)\n#endif")
177
177
+
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_FUNCTION\n#define AMD_DEVICE_LIBS_FUNCTION(t, f)\n#endif")
178
178
+
+list(APPEND TARGETS_DEFS "")
179
179
+
foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
180
180
+
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_TARGET(${AMDGCN_LIB_TARGET})")
181
181
+
+ # Generate function to select libraries for a given GFXIP number.
182
182
+
if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_isa_version_.+$")
183
183
+
string(REGEX REPLACE "^oclc_isa_version_(.+)$" "\\1" gfxip ${AMDGCN_LIB_TARGET})
184
184
+
- file(APPEND ${GEN_LIBRARY_INC_FILE}
185
185
+
- "if (gfxip == \"${gfxip}\") return std::make_tuple(\"${AMDGCN_LIB_TARGET}.bc\", ${AMDGCN_LIB_TARGET}_lib, ${AMDGCN_LIB_TARGET}_lib_size);")
186
186
+
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_GFXIP(${AMDGCN_LIB_TARGET}, \"${gfxip}\")")
187
187
+
endif()
188
188
+
-endforeach()
189
189
+
-file(APPEND ${GEN_LIBRARY_INC_FILE}
190
190
+
- "return std::make_tuple(nullptr, nullptr, 0); }")
138
191
-
139
139
-
set(CLANG_LIBS
140
140
-
clangFrontendTool)
192
192
+
-# Generate function to select libraries for given feature.
193
193
+
-foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
194
194
+
+ # Generate function to select libraries for given feature.
195
195
+
if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_.*_on$")
196
196
+
string(REGEX REPLACE "^oclc_(.*)_on" "\\1" function ${AMDGCN_LIB_TARGET})
197
197
+
- file(APPEND ${GEN_LIBRARY_INC_FILE}
198
198
+
- "static std::tuple<const char*, const void*, size_t> get_oclc_${function}(bool on) { \
199
199
+
- return std::make_tuple( \
200
200
+
- on ? \"oclc_${function}_on_lib.bc\" : \"oclc_${function}_off_lib.bc\", \
201
201
+
- on ? oclc_${function}_on_lib : oclc_${function}_off_lib, \
202
202
+
- on ? oclc_${function}_on_lib_size : oclc_${function}_off_lib_size \
203
203
+
- ); }")
204
204
+
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_FUNCTION(${AMDGCN_LIB_TARGET}, ${function})")
205
205
+
endif()
206
206
+
endforeach()
207
207
+
208
208
+
-# Generate function yield all libraries.
209
209
+
-file(APPEND ${GEN_LIBRARY_INC_FILE} "\n#include \"llvm/ADT/ArrayRef.h\"\n")
210
210
+
-file(APPEND ${GEN_LIBRARY_INC_FILE}
211
211
+
- "llvm::ArrayRef<std::tuple<llvm::StringRef, llvm::StringRef>> COMGR::getDeviceLibraries() { \
212
212
+
- static std::tuple<llvm::StringRef, llvm::StringRef> DeviceLibs[] = {")
213
213
+
-foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
214
214
+
- file(APPEND ${GEN_LIBRARY_INC_FILE}
215
215
+
- "{\"${AMDGCN_LIB_TARGET}.bc\", llvm::StringRef(reinterpret_cast<const char *>(${AMDGCN_LIB_TARGET}_lib), ${AMDGCN_LIB_TARGET}_lib_size)},")
216
216
+
-endforeach()
217
217
+
-file(APPEND ${GEN_LIBRARY_INC_FILE}
218
218
+
- "}; \
219
219
+
- return DeviceLibs; \
220
220
+
- }")
221
221
+
+list(APPEND TARGETS_DEFS "")
222
222
+
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_TARGET")
223
223
+
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_GFXIP")
224
224
+
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_FUNCTION")
225
225
+
+
226
226
+
+list(JOIN TARGETS_DEFS "\n" TARGETS_DEFS)
227
227
+
+file(GENERATE OUTPUT ${GEN_LIBRARY_DEFS_INC_FILE} CONTENT "${TARGETS_DEFS}")
141
228
229
229
+
include_directories(${INC_DIR})
142
230
diff --git a/cmake/bc2h.cmake b/cmake/bc2h.cmake
143
231
index 146fe2b..9134985 100644
144
232
--- a/cmake/bc2h.cmake
···
222
310
223
311
add_executable(bc2h ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c)
224
312
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
313
313
+
diff --git a/src/comgr-device-libs.cpp b/src/comgr-device-libs.cpp
314
314
+
index 4d2b914..80786d1 100644
315
315
+
--- a/src/comgr-device-libs.cpp
316
316
+
+++ b/src/comgr-device-libs.cpp
317
317
+
@@ -35,7 +35,7 @@
318
318
+
319
319
+
#include "comgr-device-libs.h"
320
320
+
#include "comgr.h"
321
321
+
-#include "libraries.inc"
322
322
+
+#include "comgr-libraries.h"
323
323
+
#include "llvm/ADT/StringSwitch.h"
324
324
+
#include <cstdint>
325
325
+
326
326
+
diff --git a/src/comgr-libraries.h b/src/comgr-libraries.h
327
327
+
new file mode 100644
328
328
+
index 0000000..3caa0a0
329
329
+
--- /dev/null
330
330
+
+++ b/src/comgr-libraries.h
331
331
+
@@ -0,0 +1,34 @@
332
332
+
+#include "libraries.inc"
333
333
+
+#include "opencl1.2-c.inc"
334
334
+
+#include "opencl2.0-c.inc"
335
335
+
+#include "llvm/ADT/StringRef.h"
336
336
+
+#include "llvm/ADT/ArrayRef.h"
337
337
+
+
338
338
+
+static std::tuple<const char*, const void*, size_t> get_oclc_isa_version(llvm::StringRef gfxip) {
339
339
+
+#define AMD_DEVICE_LIBS_GFXIP(target, target_gfxip) \
340
340
+
+ if (gfxip == target_gfxip) return std::make_tuple(#target ".bc", target##_lib, target##_lib_size);
341
341
+
+#include "libraries_defs.inc"
342
342
+
+
343
343
+
+ return std::make_tuple(nullptr, nullptr, 0);
344
344
+
+}
345
345
+
+
346
346
+
+#define AMD_DEVICE_LIBS_FUNCTION(target, function) \
347
347
+
+ static std::tuple<const char*, const void*, size_t> get_oclc_##function(bool on) { \
348
348
+
+ return std::make_tuple( \
349
349
+
+ on ? "oclc_" #function "_on_lib.bc" : "oclc_" #function "_off_lib.bc", \
350
350
+
+ on ? oclc_##function##_on_lib : oclc_##function##_off_lib, \
351
351
+
+ on ? oclc_##function##_on_lib_size : oclc_##function##_off_lib_size \
352
352
+
+ ); \
353
353
+
+ }
354
354
+
+#include "libraries_defs.inc"
355
355
+
+
356
356
+
+llvm::ArrayRef<std::tuple<llvm::StringRef, llvm::StringRef>> COMGR::getDeviceLibraries() {
357
357
+
+ static std::tuple<llvm::StringRef, llvm::StringRef> DeviceLibs[] = {
358
358
+
+#define AMD_DEVICE_LIBS_TARGET(target) \
359
359
+
+ {#target ".bc", llvm::StringRef(reinterpret_cast<const char *>(target##_lib), target##_lib_size)},
360
360
+
+#include "libraries_defs.inc"
361
361
+
+ };
362
362
+
+ return DeviceLibs;
363
363
+
+}
364
364
+
+
365
365
+
+
+3
-4
pkgs/development/libraries/rocm-comgr/default.nix
···
2
2
3
3
stdenv.mkDerivation rec {
4
4
pname = "rocm-comgr";
5
5
-
version = "5.2.0";
5
5
+
version = "5.3.0";
6
6
7
7
src = fetchFromGitHub {
8
8
owner = "RadeonOpenCompute";
9
9
repo = "ROCm-CompilerSupport";
10
10
rev = "rocm-${version}";
11
11
-
hash = "sha256-5C5bRdrt3xZAlRgtiIRTMAuwsFvVM4Win96P5+Pf5ZM=";
11
11
+
hash = "sha256-LQyMhqcWm8zqt6138fnT7EOq/F8bG3Iuf04PTemVQmg=";
12
12
};
13
13
14
14
sourceRoot = "source/lib/comgr";
···
18
18
buildInputs = [ clang rocm-device-libs llvm ];
19
19
20
20
cmakeFlags = [
21
21
-
"-DCMAKE_BUILD_TYPE=Release"
22
21
"-DCMAKE_C_COMPILER=${clang}/bin/clang"
23
22
"-DCMAKE_CXX_COMPILER=${clang}/bin/clang++"
24
23
"-DCMAKE_PREFIX_PATH=${llvm}/lib/cmake/llvm"
···
39
38
description = "APIs for compiling and inspecting AMDGPU code objects";
40
39
homepage = "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr";
41
40
license = licenses.ncsa;
42
42
-
maintainers = with maintainers; [ lovesegfault ];
41
41
+
maintainers = with maintainers; [ lovesegfault Flakebi ];
43
42
platforms = platforms.linux;
44
43
};
45
44
}