@@ -42,38 +42,6 @@ set(devicertl_base_directory ${CMAKE_CURRENT_SOURCE_DIR})
4242set (include_directory ${devicertl_base_directory} /include )
4343set (source_directory ${devicertl_base_directory} /src)
4444
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-
7745set (include_files
7846 ${include_directory} /Allocator.h
7947 ${include_directory} /Configuration .h
@@ -141,20 +109,21 @@ set(bc_flags -c -foffload-lto -std=c++17 -fvisibility=hidden
141109
142110# first create an object target
143111add_library (omptarget.devicertl.all_objs OBJECT IMPORTED )
144- function (compileDeviceRTLLibrary target_cpu target_name target_triple)
112+ function (compileDeviceRTLLibrary target_name target_triple)
145113 set (target_bc_flags ${ARGN} )
146114
147115 set (bc_files "" )
148116 foreach (src ${src_files} )
149117 get_filename_component (infile ${src} ABSOLUTE )
150118 get_filename_component (outfile ${src} NAME )
151- set (outfile "${outfile} -${target_cpu } .bc" )
119+ set (outfile "${outfile} -${target_name } .bc" )
152120 set (depfile "${outfile} .d" )
153121
154122 add_custom_command (OUTPUT ${outfile}
155123 COMMAND ${CLANG_TOOL}
156124 ${bc_flags}
157- --offload-arch=${target_cpu}
125+ -fopenmp-targets=${target_triple}
126+ -Xopenmp-target =${target_triple} -march=
158127 ${target_bc_flags}
159128 -MD -MF ${depfile}
160129 ${infile} -o ${outfile}
@@ -177,7 +146,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
177146 list (APPEND bc_files ${outfile} )
178147 endforeach ()
179148
180- set (bclib_name "libomptarget-${target_name} - ${target_cpu} .bc" )
149+ set (bclib_name "libomptarget-${target_name} .bc" )
181150
182151 # Link to a bitcode library.
183152 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /linked_${bclib_name}
@@ -217,7 +186,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
217186 APPEND )
218187 endif ()
219188
220- set (bclib_target_name "omptarget-${target_name} -${target_cpu} - bc" )
189+ set (bclib_target_name "omptarget-${target_name} -bc" )
221190 add_custom_target (${bclib_target_name} DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /${bclib_name} )
222191
223192 # Copy library to destination.
@@ -239,7 +208,7 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
239208 # Package the bitcode in the bitcode and embed it in an ELF for the static library
240209 add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /packaged_${bclib_name}
241210 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"
243212 DEPENDS ${CMAKE_CURRENT_BINARY_DIR} /${bclib_name}
244213 COMMENT "Packaging LLVM offloading binary ${bclib_name} .out"
245214 )
@@ -249,14 +218,14 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
249218 APPEND )
250219 endif ()
251220
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" )
253222 add_custom_command (OUTPUT ${output_name}
254223 COMMAND ${CLANG_TOOL} --std=c++17 -c -nostdlib
255224 -Xclang -fembed-offload-object=${CMAKE_CURRENT_BINARY_DIR} /packaged_${bclib_name}
256225 -o ${output_name}
257226 ${source_directory} /Stub.cpp
258227 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"
260229 VERBATIM
261230 )
262231 if (TARGET clang)
@@ -269,11 +238,11 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
269238 set_property (TARGET omptarget.devicertl.all_objs APPEND PROPERTY IMPORTED_OBJECTS ${output_name} )
270239
271240 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} )
273242 add_library (${ide_target_name} STATIC EXCLUDE_FROM_ALL ${src_files} )
274243 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
277246 -foffload-lto -fvisibility=hidden --offload-device-only
278247 -nocudalib -nogpulib -nogpuinc -nostdlibinc -Wno-unknown-cuda-version
279248 )
@@ -288,18 +257,11 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
288257 endif ()
289258endfunction ()
290259
291- # Generate a Bitcode library for all the gpu architectures the user requested.
292- add_custom_target (omptarget.devicertl.nvptx)
293260add_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)
303265
304266# Archive all the object files generated above into a static library
305267add_library (omptarget.devicertl STATIC )
0 commit comments