[Openmp-commits] [openmp] 3244a8b - [OpenMP][CMake] Pass --cuda-path to regression tests.

Michael Kruse via Openmp-commits openmp-commits at lists.llvm.org
Tue Apr 27 14:29:37 PDT 2021


Author: Michael Kruse
Date: 2021-04-27T16:27:40-05:00
New Revision: 3244a8b5366dcd7a840963a6a2ae2c7ffe50de2c

URL: https://github.com/llvm/llvm-project/commit/3244a8b5366dcd7a840963a6a2ae2c7ffe50de2c
DIFF: https://github.com/llvm/llvm-project/commit/3244a8b5366dcd7a840963a6a2ae2c7ffe50de2c.diff

LOG: [OpenMP][CMake] Pass --cuda-path to regression tests.

The OpenMP runtime can be compiled using a CUDA installed at non-default
location with the -DCUDA_TOOLKIT_ROOT_DIR setting. However, check-openmp
will fail afterwards because Clang needs to know where to find the CUDA
headers.

Fix by passing -cuda-path to Clang using the value of
CUDA_TOOLKIT_ROOT_DIR which has been determined by CMake. Also set
LD_LIBRARY_PATH such that it can find the cuda runtime when executing.
This will ensure that the regression test do not depend on the current
environment, but use the environment it was configured for.

Reviewed By: tianshilei1992

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

Added: 
    

Modified: 
    openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg
    openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in
    openmp/libomptarget/test/CMakeLists.txt
    openmp/libomptarget/test/lit.cfg
    openmp/libomptarget/test/lit.site.cfg.in

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg b/openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg
index 5b9be32db55f5..954059bd02c2e 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg
+++ b/openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg
@@ -44,6 +44,8 @@ config.test_flags = config.test_flags + " " + config.test_extra_flags
 prepend_library_path('LIBRARY_PATH', config.library_dir, ":")
 prepend_library_path('LD_LIBRARY_PATH', config.library_dir, ":")
 prepend_library_path('LD_LIBRARY_PATH', config.omp_host_rtl_directory, ":")
+if config.cuda_libdir:
+    prepend_library_path('LD_LIBRARY_PATH', config.cuda_libdir, ":")
 
 # Forbid fallback to host.
 config.environment["OMP_TARGET_OFFLOAD"] = "MANDATORY"
@@ -57,13 +59,17 @@ config.substitutions.append(("%compilexx-and-run", "%compilexx && %run"))
 config.substitutions.append(("%compile-and-run", "%compile && %run"))
 
 config.substitutions.append(("%compilexx",
-    "%clangxx %openmp_flags %flags %s -o %t"))
+    "%clangxx %openmp_flags %cuda_flags %flags %s -o %t"))
 config.substitutions.append(("%compile",
-    "%clang %openmp_flags %flags %s -o %t"))
+    "%clang %openmp_flags %cuda_flags %flags %s -o %t"))
 
 config.substitutions.append(("%clangxx", config.test_cxx_compiler))
 config.substitutions.append(("%clang", config.test_c_compiler))
 config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
+if config.cuda_path:
+  config.substitutions.append(("%cuda_flags", "--cuda-path=" + config.cuda_path))
+else:
+  config.substitutions.append(("%cuda_flags", ""))
 config.substitutions.append(("%flags", config.test_flags))
 
 config.substitutions.append(("%run", "%t"))

diff  --git a/openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in b/openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in
index f0e02e5d46ac2..22374d5e3566c 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in
+++ b/openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in
@@ -4,6 +4,8 @@ config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@"
 config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@"
 config.test_openmp_flags = "@LIBOMPTARGET_NVPTX_TEST_OPENMP_FLAGS@"
 config.test_extra_flags = "@LIBOMPTARGET_NVPTX_TEST_FLAGS@"
+config.cuda_path = "@CUDA_TOOLKIT_ROOT_DIR@"
+config.cuda_libdir = "@CUDA_LIBDIR@"
 config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@"
 config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
 config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"

diff  --git a/openmp/libomptarget/test/CMakeLists.txt b/openmp/libomptarget/test/CMakeLists.txt
index 08425c7a09ec1..ddc05e82ef9e6 100644
--- a/openmp/libomptarget/test/CMakeLists.txt
+++ b/openmp/libomptarget/test/CMakeLists.txt
@@ -20,6 +20,7 @@ foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
 
   # Configure the lit.site.cfg.in file
   set(AUTO_GEN_COMMENT "## Autogenerated by libomptarget configuration.\n# Do not edit!")
+  get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
   configure_file(lit.site.cfg.in ${CURRENT_TARGET}/lit.site.cfg @ONLY)
 endforeach()
 

diff  --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg
index 0a43103cccd9d..0e3fc88dad9b0 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -73,6 +73,8 @@ else: # Unices
     append_dynamic_library_path('LD_LIBRARY_PATH', config.library_dir, ":")
     append_dynamic_library_path('LD_LIBRARY_PATH', \
         config.omp_host_rtl_directory, ":")
+    if config.cuda_libdir:
+        append_dynamic_library_path('LD_LIBRARY_PATH', config.cuda_libdir, ":")
     append_dynamic_library_path('LIBRARY_PATH', config.library_dir, ":")
     append_dynamic_library_path('LIBRARY_PATH', \
         config.omp_host_rtl_directory, ":")
@@ -140,9 +142,9 @@ for libomptarget_target in config.libomptarget_all_targets:
             libomptarget_target, \
             "%not --crash %t"))
         config.substitutions.append(("%clangxx-" + libomptarget_target, \
-            "%clangxx %openmp_flags %flags -fopenmp-targets=" + libomptarget_target))
+            "%clangxx %openmp_flags %cuda_flags %flags -fopenmp-targets=" + libomptarget_target))
         config.substitutions.append(("%clang-" + libomptarget_target, \
-            "%clang %openmp_flags %flags -fopenmp-targets=" + libomptarget_target))
+            "%clang %openmp_flags %cuda_flags %flags -fopenmp-targets=" + libomptarget_target))
         config.substitutions.append(("%fcheck-" + libomptarget_target, \
             config.libomptarget_filecheck + " %s"))
     else:
@@ -180,5 +182,9 @@ for libomptarget_target in config.libomptarget_all_targets:
 config.substitutions.append(("%clangxx", config.test_cxx_compiler))
 config.substitutions.append(("%clang", config.test_c_compiler))
 config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
+if config.cuda_path:
+  config.substitutions.append(("%cuda_flags", "--cuda-path=" + config.cuda_path))
+else:
+  config.substitutions.append(("%cuda_flags", ""))
 config.substitutions.append(("%flags", config.test_flags))
 config.substitutions.append(("%not", config.libomptarget_not))

diff  --git a/openmp/libomptarget/test/lit.site.cfg.in b/openmp/libomptarget/test/lit.site.cfg.in
index 08acdd2907740..cc5194b0f07d5 100644
--- a/openmp/libomptarget/test/lit.site.cfg.in
+++ b/openmp/libomptarget/test/lit.site.cfg.in
@@ -5,6 +5,8 @@ config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@"
 config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@
 config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@"
 config.test_extra_flags = "@OPENMP_TEST_FLAGS@"
+config.cuda_path = "@CUDA_TOOLKIT_ROOT_DIR@"
+config.cuda_libdir = "@CUDA_LIBDIR@"
 config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@/@CURRENT_TARGET@"
 config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
 config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"


        


More information about the Openmp-commits mailing list