[Openmp-commits] [openmp] 34ed3e6 - [OpenMP] Test unified shared memory tests only on systems that support it.

Michael Kruse via Openmp-commits openmp-commits at lists.llvm.org
Thu May 13 09:08:21 PDT 2021


Author: Michael Kruse
Date: 2021-05-13T11:08:04-05:00
New Revision: 34ed3e63378e34f93ada56a19cebc68cf1498092

URL: https://github.com/llvm/llvm-project/commit/34ed3e63378e34f93ada56a19cebc68cf1498092
DIFF: https://github.com/llvm/llvm-project/commit/34ed3e63378e34f93ada56a19cebc68cf1498092.diff

LOG: [OpenMP] Test unified shared memory tests only on systems that support it.

Add a `REQUIRES: unified_shared_memory` option to tests that use `#pragma omp requires unified_shared_memory`.

For CUDA, the feature tag is derived from LIBOMPTARGET_DEP_CUDA_ARCH which itself is derived using [[ https://cmake.org/cmake/help/latest/module/FindCUDA.html#commands | cuda_select_nvcc_arch_flags ]]. The latter determines which compute capability the GPU in the system supports. To ensure that this is the CUDA arch being used, we could also set the `-Xopenmp-target -march=` flag.
In the absence of an NVIDIA GPU, LIBOMPTARGET_DEP_CUDA_ARCH will be 35. That is, in that case we are assuming unified_shared_memory is not available. CUDA plugin testing could be disabled entirely in this case, but this currently depends on `LIBOMPTARGET_CAN_LINK_LIBCUDA OR LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA`, not on whether the hardware is actually available.

For all other targets, nothing changes and we are assuming unified shared memory is available. This might need refinement if not the case.

This tries to fix the [[ http://meinersbur.de:8011/#/builders/143 | OpenMP Offloading Buildbot ]] that, although brand-new, only has a Pascal-generation (sm_61) GPU installed. Hence, tests that require unified shared memory are currently failing. I wish I had known in advance.

Reviewed By: protze.joachim, tianshilei1992

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

Added: 
    

Modified: 
    openmp/libomptarget/test/lit.cfg
    openmp/libomptarget/test/lit.site.cfg.in
    openmp/libomptarget/test/mapping/present/unified_shared_memory.c
    openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
    openmp/libomptarget/test/unified_shared_memory/close_manual.c
    openmp/libomptarget/test/unified_shared_memory/close_modifier.c
    openmp/libomptarget/test/unified_shared_memory/shared_update.c

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg
index 0e3fc88dad9b0..f1aa9176fb909 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -59,6 +59,21 @@ if config.libomptarget_debug:
 
 config.available_features.add(config.libomptarget_current_target)
 
+# Determine whether the test system supports unified memory.
+# For CUDA, this is the case with compute capability 70 (Volta) or higher.
+# For all other targets, we currently assume it is.
+supports_unified_shared_memory = True
+if config.libomptarget_current_target.startswith('nvptx'):
+  try:
+    cuda_arch = int(config.cuda_test_arch)
+    if cuda_arch < 70:
+      supports_unified_shared_memory = False
+  except ValueError:
+    # If the architecture is invalid, assume it is supported.
+    supports_unified_shared_memory = True
+if supports_unified_shared_memory:
+   config.available_features.add('unified_shared_memory')
+
 # Setup environment to find dynamic library at runtime
 if config.operating_system == 'Windows':
     append_dynamic_library_path('PATH', config.library_dir, ";")

diff  --git a/openmp/libomptarget/test/lit.site.cfg.in b/openmp/libomptarget/test/lit.site.cfg.in
index cc5194b0f07d5..5b131b6202100 100644
--- a/openmp/libomptarget/test/lit.site.cfg.in
+++ b/openmp/libomptarget/test/lit.site.cfg.in
@@ -7,6 +7,7 @@ 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.cuda_test_arch = "@LIBOMPTARGET_DEP_CUDA_ARCH@"
 config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@/@CURRENT_TARGET@"
 config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
 config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"

diff  --git a/openmp/libomptarget/test/mapping/present/unified_shared_memory.c b/openmp/libomptarget/test/mapping/present/unified_shared_memory.c
index e0e7b64d38b95..2493685607cd5 100644
--- a/openmp/libomptarget/test/mapping/present/unified_shared_memory.c
+++ b/openmp/libomptarget/test/mapping/present/unified_shared_memory.c
@@ -2,6 +2,8 @@
 // RUN: %libomptarget-run-generic 2>&1 \
 // RUN: | %fcheck-generic
 
+// REQUIRES: unified_shared_memory
+
 
 #include <stdio.h>
 

diff  --git a/openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c b/openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
index d11531cbe74c3..006fd39e6bd32 100644
--- a/openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
+++ b/openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compile-run-and-check-generic
 
+// REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
-// XFAIL: nvptx64-nvidia-cuda
 
 // Fails on amdgcn with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa

diff  --git a/openmp/libomptarget/test/unified_shared_memory/close_manual.c b/openmp/libomptarget/test/unified_shared_memory/close_manual.c
index 9c21224b5ecd9..9985e822c05d7 100644
--- a/openmp/libomptarget/test/unified_shared_memory/close_manual.c
+++ b/openmp/libomptarget/test/unified_shared_memory/close_manual.c
@@ -1,5 +1,7 @@
 // RUN: %libomptarget-compile-run-and-check-generic
 
+// REQUIRES: unified_shared_memory
+
 #include <omp.h>
 #include <stdio.h>
 

diff  --git a/openmp/libomptarget/test/unified_shared_memory/close_modifier.c b/openmp/libomptarget/test/unified_shared_memory/close_modifier.c
index d25831952ba56..6667fd85ec532 100644
--- a/openmp/libomptarget/test/unified_shared_memory/close_modifier.c
+++ b/openmp/libomptarget/test/unified_shared_memory/close_modifier.c
@@ -1,6 +1,6 @@
 // RUN: %libomptarget-compile-run-and-check-generic
-// XFAIL: nvptx64-nvidia-cuda
 
+// REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
 // amdgcn does not have printf definition

diff  --git a/openmp/libomptarget/test/unified_shared_memory/shared_update.c b/openmp/libomptarget/test/unified_shared_memory/shared_update.c
index 3f844c230837b..ab9b3e86f0a27 100644
--- a/openmp/libomptarget/test/unified_shared_memory/shared_update.c
+++ b/openmp/libomptarget/test/unified_shared_memory/shared_update.c
@@ -1,5 +1,6 @@
 // RUN: %libomptarget-compile-run-and-check-generic
-// XFAIL: nvptx64-nvidia-cuda
+
+// REQUIRES: unified_shared_memory
 
 // amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa


        


More information about the Openmp-commits mailing list