[Openmp-commits] [PATCH] D101266: [OpenMP][CMake] Pass --cuda-path to regression tests.

Michael Kruse via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sun Apr 25 15:52:16 PDT 2021


Meinersbur created this revision.
Meinersbur added reviewers: jdoerfert, tianshilei1992, ye-luo.
Meinersbur added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
Meinersbur requested review of this revision.
Herald added a subscriber: sstefan1.

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.

See the current builder <http://meinersbur.de:8011/#/builders/142> and the build with this patch applied <http://meinersbur.de:8011/#/builders/142/builds/220>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101266

Files:
  openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg
  openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in
  openmp/libomptarget/test/lit.cfg
  openmp/libomptarget/test/lit.site.cfg.in


Index: openmp/libomptarget/test/lit.site.cfg.in
===================================================================
--- openmp/libomptarget/test/lit.site.cfg.in
+++ openmp/libomptarget/test/lit.site.cfg.in
@@ -5,6 +5,8 @@
 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@"
 config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
 config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"
Index: openmp/libomptarget/test/lit.cfg
===================================================================
--- openmp/libomptarget/test/lit.cfg
+++ openmp/libomptarget/test/lit.cfg
@@ -71,6 +71,8 @@
     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, ":")
@@ -116,9 +118,9 @@
             libomptarget_target, \
             "%not --crash %t-" + libomptarget_target))
         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:
@@ -156,5 +158,9 @@
 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))
Index: openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in
+++ openmp/libomptarget/deviceRTLs/nvptx/test/lit.site.cfg.in
@@ -4,6 +4,8 @@
 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@"
Index: openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg
+++ openmp/libomptarget/deviceRTLs/nvptx/test/lit.cfg
@@ -44,6 +44,8 @@
 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(("%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"))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101266.340388.patch
Type: text/x-patch
Size: 4818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210425/2a6b0620/attachment.bin>


More information about the Openmp-commits mailing list