[Openmp-commits] [openmp] 554d8ab - [OpenMP] Enable the IDE support for the device runtime

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Fri Apr 21 11:13:53 PDT 2023


Author: Shilei Tian
Date: 2023-04-21T14:13:48-04:00
New Revision: 554d8ab63268f1edfff4b59f5613a3a06d4dca4d

URL: https://github.com/llvm/llvm-project/commit/554d8ab63268f1edfff4b59f5613a3a06d4dca4d
DIFF: https://github.com/llvm/llvm-project/commit/554d8ab63268f1edfff4b59f5613a3a06d4dca4d.diff

LOG: [OpenMP] Enable the IDE support for the device runtime

Currently the device runtime is built as a custom target, which will not be included
in the compile commands. Those language servers using compile commands cannot
handle device runtime correctly.

In this patch, when `CMAKE_EXPORT_COMPILE_COMMANDS` is turned on, dummy
targets that will be excluded from all will be added. Those targets will not be
built or installed if we just simply do `make` or `make install`, but their
compilation will be included in the compile commands.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D148870

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index f123105fc21b0..8419b87ef6222 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -268,6 +268,24 @@ function(compileDeviceRTLLibrary target_cpu target_name target_triple)
 
   set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${output_name})
   set_property(TARGET omptarget.devicertl.all_objs APPEND PROPERTY IMPORTED_OBJECTS ${output_name})
+
+  if (CMAKE_EXPORT_COMPILE_COMMANDS)
+    set(ide_target_name omptarget-ide-${target_name}-${target_cpu})
+    add_library(${ide_target_name} STATIC EXCLUDE_FROM_ALL ${src_files})
+    target_compile_options(${ide_target_name} PRIVATE
+      -fopenmp --offload-arch=${target_cpu} -fopenmp-cuda-mode
+      -mllvm -openmp-opt-disable
+      -foffload-lto -fvisibility=hidden --offload-device-only
+      -nocudalib -nogpulib -nostdinc -Wno-unknown-cuda-version
+    )
+    target_compile_definitions(${ide_target_name} PRIVATE SHARED_SCRATCHPAD_SIZE=512)
+    target_include_directories(${ide_target_name} PRIVATE
+      ${include_directory}
+      ${devicertl_base_directory}/../include
+      ${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
+    )
+    install(TARGETS ${ide_target_name} EXCLUDE_FROM_ALL)
+  endif()
 endfunction()
 
 # Generate a Bitcode library for all the gpu architectures the user requested.


        


More information about the Openmp-commits mailing list