@@ -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,21 @@ 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
154
122
add_custom_command (OUTPUT ${outfile}
155
123
COMMAND ${CLANG_TOOL}
156
124
${bc_flags}
157
- --offload-arch=${target_cpu}
125
+ -fopenmp-targets=${target_triple}
126
+ -Xopenmp-target=${target_triple} -march=
158
127
${target_bc_flags}
159
128
-MD -MF ${depfile}
160
129
${infile} -o ${outfile}
@@ -177,7 +146,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
177
146
list (APPEND bc_files ${outfile} )
178
147
endforeach ()
179
148
180
- set (bclib_name "libomptarget-${target_name} - ${target_cpu} .bc" )
149
+ set (bclib_name "libomptarget-${target_name} .bc" )
181
150
182
151
# Link to a bitcode library.
183
152
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /linked_${bclib_name}
@@ -217,7 +186,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
217
186
APPEND )
218
187
endif ()
219
188
220
- set (bclib_target_name "omptarget-${target_name} -${target_cpu} - bc" )
189
+ set (bclib_target_name "omptarget-${target_name} -bc" )
221
190
add_custom_target (${bclib_target_name} DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /${bclib_name} )
222
191
223
192
# Copy library to destination.
@@ -239,7 +208,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
239
208
# Package the bitcode in the bitcode and embed it in an ELF for the static library
240
209
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /packaged_${bclib_name}
241
210
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"
211
+ "--image=file=${CMAKE_CURRENT_BINARY_DIR} /${bclib_name} ,${target_feature} ,triple=${target_triple} ,arch=generic ,kind=openmp"
243
212
DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /${bclib_name}
244
213
COMMENT "Packaging LLVM offloading binary ${bclib_name} .out"
245
214
)
@@ -249,14 +218,14 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
249
218
APPEND )
250
219
endif ()
251
220
252
- set (output_name "${CMAKE_CURRENT_BINARY_DIR} /devicertl-${target_name} - ${target_cpu} .o" )
221
+ set (output_name "${CMAKE_CURRENT_BINARY_DIR} /devicertl-${target_name} .o" )
253
222
add_custom_command (OUTPUT ${output_name}
254
223
COMMAND ${CLANG_TOOL} --std=c++17 -c -nostdlib
255
224
-Xclang -fembed-offload-object=${CMAKE_CURRENT_BINARY_DIR}/packaged_${bclib_name}
256
225
-o ${output_name}
257
226
${source_directory} /Stub.cpp
258
227
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"
228
+ COMMENT "Embedding LLVM offloading binary in devicertl-${target_name} .o"
260
229
VERBATIM
261
230
)
262
231
if (TARGET clang )
@@ -269,11 +238,11 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
269
238
set_property (TARGET omptarget.devicertl.all_objs APPEND PROPERTY IMPORTED_OBJECTS ${output_name} )
270
239
271
240
if (CMAKE_EXPORT_COMPILE_COMMANDS )
272
- set (ide_target_name omptarget-ide-${target_name}-${target_cpu} )
241
+ set (ide_target_name omptarget-ide-${target_name} )
273
242
add_library (${ide_target_name} STATIC EXCLUDE_FROM_ALL ${src_files} )
274
243
target_compile_options (${ide_target_name} PRIVATE
275
- -fopenmp --offload-arch =${target_cpu } -fopenmp-cuda-mode
276
- -mllvm -openmp-opt-disable
244
+ -fopenmp-targets=${target_triple} -Xopenmp-target =${target_triple } -march=
245
+ -fopenmp -fopenmp-cuda-mode - mllvm -openmp-opt-disable
277
246
-foffload-lto -fvisibility=hidden --offload-device-only
278
247
-nocudalib -nogpulib -nogpuinc -nostdlibinc -Wno-unknown-cuda-version
279
248
)
@@ -288,18 +257,11 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
288
257
endif ()
289
258
endfunction ()
290
259
291
- # Generate a Bitcode library for all the gpu architectures the user requested.
292
- add_custom_target (omptarget.devicertl.nvptx )
293
260
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 ()
261
+ compileDeviceRTLLibrary (amdgpu amdgcn-amd-amdhsa -Xclang -mcode-object-version=none )
262
+
263
+ add_custom_target (omptarget.devicertl.nvptx )
264
+ compileDeviceRTLLibrary (nvptx nvptx64-nvidia-cuda --cuda-feature=+ptx63 )
303
265
304
266
# Archive all the object files generated above into a static library
305
267
add_library (omptarget.devicertl STATIC )
0 commit comments