@@ -42,38 +42,6 @@ set(devicertl_base_directory ${CMAKE_CURRENT_SOURCE_DIR})
42
42
set (include_directory ${devicertl_base_directory} /include )
43
43
set (source_directory ${devicertl_base_directory} /src )
44
44
45
- set (all_amdgpu_architectures "gfx700;gfx701;gfx801;gfx803;gfx900;gfx902;gfx906"
46
- "gfx908;gfx90a;gfx90c;gfx940;gfx941;gfx942;gfx950;gfx1010"
47
- "gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035"
48
- "gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150"
49
- "gfx1151;gfx1152;gfx1153" )
50
- set (all_nvptx_architectures "sm_35;sm_37;sm_50;sm_52;sm_53;sm_60;sm_61;sm_62"
51
- "sm_70;sm_72;sm_75;sm_80;sm_86;sm_87;sm_89;sm_90" )
52
- set (all_gpu_architectures
53
- "${all_amdgpu_architectures} ;${all_nvptx_architectures} " )
54
-
55
- set (LIBOMPTARGET_DEVICE_ARCHITECTURES "all" CACHE STRING
56
- "List of device architectures to be used to compile the OpenMP DeviceRTL." )
57
-
58
- if (LIBOMPTARGET_DEVICE_ARCHITECTURES STREQUAL "all" )
59
- set (LIBOMPTARGET_DEVICE_ARCHITECTURES ${all_gpu_architectures} )
60
- elseif (LIBOMPTARGET_DEVICE_ARCHITECTURES STREQUAL "amdgpu" )
61
- set (LIBOMPTARGET_DEVICE_ARCHITECTURES ${all_amdgpu_architectures} )
62
- elseif (LIBOMPTARGET_DEVICE_ARCHITECTURES STREQUAL "nvptx" )
63
- set (LIBOMPTARGET_DEVICE_ARCHITECTURES ${all_nvptx_architectures} )
64
- elseif (LIBOMPTARGET_DEVICE_ARCHITECTURES STREQUAL "auto" OR
65
- LIBOMPTARGET_DEVICE_ARCHITECTURES STREQUAL "native" )
66
- if (NOT LIBOMPTARGET_NVPTX_ARCH AND NOT LIBOMPTARGET_AMDGPU_ARCH )
67
- message (FATAL_ERROR
68
- "Could not find 'amdgpu-arch' and 'nvptx-arch' tools required for 'auto'" )
69
- elseif (NOT LIBOMPTARGET_FOUND_NVIDIA_GPU AND NOT LIBOMPTARGET_FOUND_AMDGPU_GPU )
70
- message (FATAL_ERROR "No AMD or NVIDIA GPU found on the system when using 'auto'" )
71
- endif ()
72
- set (LIBOMPTARGET_DEVICE_ARCHITECTURES
73
- "${LIBOMPTARGET_NVPTX_DETECTED_ARCH_LIST} ;${LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST} " )
74
- endif ()
75
- list (REMOVE_DUPLICATES LIBOMPTARGET_DEVICE_ARCHITECTURES )
76
-
77
45
set (include_files
78
46
${include_directory} /Allocator.h
79
47
${include_directory} /Configuration.h
@@ -141,20 +109,22 @@ set(bc_flags -c -foffload-lto -std=c++17 -fvisibility=hidden
141
109
142
110
# first create an object target
143
111
add_library (omptarget.devicertl.all_objs OBJECT IMPORTED )
144
- function (compileDeviceRTLLibrary target_cpu target_name target_triple )
112
+ function (compileDeviceRTLLibrary target_name target_triple )
145
113
set (target_bc_flags ${ARGN} )
146
114
147
115
set (bc_files "" )
148
116
foreach (src ${src_files} )
149
117
get_filename_component (infile ${src} ABSOLUTE )
150
118
get_filename_component (outfile ${src} NAME )
151
- set (outfile "${outfile} -${target_cpu } .bc" )
119
+ set (outfile "${outfile} -${target_name } .bc" )
152
120
set (depfile "${outfile} .d" )
153
121
122
+ # Passing an empty CPU to -march= suppressed target specific metadata.
154
123
add_custom_command (OUTPUT ${outfile}
155
124
COMMAND ${CLANG_TOOL}
156
125
${bc_flags}
157
- --offload-arch=${target_cpu}
126
+ -fopenmp-targets=${target_triple}
127
+ -Xopenmp-target=${target_triple} -march=
158
128
${target_bc_flags}
159
129
-MD -MF ${depfile}
160
130
${infile} -o ${outfile}
@@ -177,7 +147,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
177
147
list (APPEND bc_files ${outfile} )
178
148
endforeach ()
179
149
180
- set (bclib_name "libomptarget-${target_name} - ${target_cpu} .bc" )
150
+ set (bclib_name "libomptarget-${target_name} .bc" )
181
151
182
152
# Link to a bitcode library.
183
153
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /linked_${bclib_name}
@@ -217,7 +187,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
217
187
APPEND )
218
188
endif ()
219
189
220
- set (bclib_target_name "omptarget-${target_name} -${target_cpu} - bc" )
190
+ set (bclib_target_name "omptarget-${target_name} -bc" )
221
191
add_custom_target (${bclib_target_name} DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /${bclib_name} )
222
192
223
193
# Copy library to destination.
@@ -239,7 +209,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
239
209
# Package the bitcode in the bitcode and embed it in an ELF for the static library
240
210
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /packaged_${bclib_name}
241
211
COMMAND ${PACKAGER_TOOL} -o ${CMAKE_CURRENT_BINARY_DIR} /packaged_${bclib_name}
242
- "--image=file=${CMAKE_CURRENT_BINARY_DIR} /${bclib_name} ,${target_feature} ,triple=${target_triple} ,arch=${target_cpu} ,kind=openmp"
212
+ "--image=file=${CMAKE_CURRENT_BINARY_DIR} /${bclib_name} ,${target_feature} ,triple=${target_triple} ,arch=generic ,kind=openmp"
243
213
DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /${bclib_name}
244
214
COMMENT "Packaging LLVM offloading binary ${bclib_name} .out"
245
215
)
@@ -249,14 +219,14 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
249
219
APPEND )
250
220
endif ()
251
221
252
- set (output_name "${CMAKE_CURRENT_BINARY_DIR} /devicertl-${target_name} - ${target_cpu} .o" )
222
+ set (output_name "${CMAKE_CURRENT_BINARY_DIR} /devicertl-${target_name} .o" )
253
223
add_custom_command (OUTPUT ${output_name}
254
224
COMMAND ${CLANG_TOOL} --std=c++17 -c -nostdlib
255
225
-Xclang -fembed-offload-object=${CMAKE_CURRENT_BINARY_DIR}/packaged_${bclib_name}
256
226
-o ${output_name}
257
227
${source_directory} /Stub.cpp
258
228
DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /packaged_${bclib_name} ${source_directory} /Stub.cpp
259
- COMMENT "Embedding LLVM offloading binary in devicertl-${target_name} - ${target_cpu} .o"
229
+ COMMENT "Embedding LLVM offloading binary in devicertl-${target_name} .o"
260
230
VERBATIM
261
231
)
262
232
if (TARGET clang )
@@ -269,11 +239,11 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
269
239
set_property (TARGET omptarget.devicertl.all_objs APPEND PROPERTY IMPORTED_OBJECTS ${output_name} )
270
240
271
241
if (CMAKE_EXPORT_COMPILE_COMMANDS )
272
- set (ide_target_name omptarget-ide-${target_name}-${target_cpu} )
242
+ set (ide_target_name omptarget-ide-${target_name} )
273
243
add_library (${ide_target_name} STATIC EXCLUDE_FROM_ALL ${src_files} )
274
244
target_compile_options (${ide_target_name} PRIVATE
275
- -fopenmp --offload-arch =${target_cpu } -fopenmp-cuda-mode
276
- -mllvm -openmp-opt-disable
245
+ -fopenmp-targets=${target_triple} -Xopenmp-target =${target_triple } -march=
246
+ -fopenmp -fopenmp-cuda-mode - mllvm -openmp-opt-disable
277
247
-foffload-lto -fvisibility=hidden --offload-device-only
278
248
-nocudalib -nogpulib -nogpuinc -nostdlibinc -Wno-unknown-cuda-version
279
249
)
@@ -288,18 +258,11 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
288
258
endif ()
289
259
endfunction ()
290
260
291
- # Generate a Bitcode library for all the gpu architectures the user requested.
292
- add_custom_target (omptarget.devicertl.nvptx )
293
261
add_custom_target (omptarget.devicertl.amdgpu )
294
- foreach (gpu_arch ${LIBOMPTARGET_DEVICE_ARCHITECTURES} )
295
- if ("${gpu_arch} " IN_LIST all_amdgpu_architectures )
296
- compileDeviceRTLLibrary (${gpu_arch} amdgpu amdgcn-amd-amdhsa -Xclang -mcode-object-version=none )
297
- elseif ("${gpu_arch} " IN_LIST all_nvptx_architectures )
298
- compileDeviceRTLLibrary (${gpu_arch} nvptx nvptx64-nvidia-cuda --cuda-feature=+ptx63 )
299
- else ()
300
- message (FATAL_ERROR "Unknown GPU architecture '${gpu_arch} '" )
301
- endif ()
302
- endforeach ()
262
+ compileDeviceRTLLibrary (amdgpu amdgcn-amd-amdhsa -Xclang -mcode-object-version=none )
263
+
264
+ add_custom_target (omptarget.devicertl.nvptx )
265
+ compileDeviceRTLLibrary (nvptx nvptx64-nvidia-cuda --cuda-feature=+ptx63 )
303
266
304
267
# Archive all the object files generated above into a static library
305
268
add_library (omptarget.devicertl STATIC )
0 commit comments