[Openmp-commits] [openmp] [OpenMP] Fix two usm tests for amdgpus. (PR #77851)

via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 11 15:30:48 PST 2024


https://github.com/carlobertolli created https://github.com/llvm/llvm-project/pull/77851

Some are missing setting of HSA_XNACK=1 environment variable, used to enable unified memory support on amdgpu's when it's not been set at kernel boot time. Some others needed to be marked as supporting unified_shared_memory in the lit test harness.

>From 45b3a08c1dfb4de3b10dbab429c2637d91f6590e Mon Sep 17 00:00:00 2001
From: Carlo Bertolli <carlo.bertolli at amd.com>
Date: Tue, 2 Jan 2024 13:18:41 -0600
Subject: [PATCH] [OpenMP] Fix two usm tests for amdgpus. Some are missing
 setting of HSA_XNACK=1 environment variable, used to enable unified memory
 support on amdgpu's when it's not been set at kernel boot time. Some others
 needed to be marked as supporting unified_shared_memory in the lit test
 harness.

---
 openmp/libomptarget/test/lit.cfg                           | 5 ++++-
 openmp/libomptarget/test/lit.site.cfg.in                   | 1 +
 openmp/libomptarget/test/unified_shared_memory/api.c       | 7 +++----
 .../test/unified_shared_memory/close_enter_exit.c          | 7 +++----
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg
index 9078561e3198e6..b278c3a248fe47 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -117,7 +117,10 @@ if config.libomptarget_current_target.startswith('nvptx'):
     # If the architecture is invalid, assume it is supported.
     supports_unified_shared_memory = True
 if config.libomptarget_current_target.startswith('amdgcn'):
-    supports_unified_shared_memory = False
+    if not (config.amdgpu_test_arch == "gfx908" or
+            config.amdgpu_test_arch == "gfx90a" or
+            config.amdgpu_test_arch == "gfx942") :
+       supports_unified_shared_memory = False
 if supports_unified_shared_memory:
    config.available_features.add('unified_shared_memory')
 
diff --git a/openmp/libomptarget/test/lit.site.cfg.in b/openmp/libomptarget/test/lit.site.cfg.in
index 2d638118838727..7c75aaa18fa770 100644
--- a/openmp/libomptarget/test/lit.site.cfg.in
+++ b/openmp/libomptarget/test/lit.site.cfg.in
@@ -10,6 +10,7 @@ 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.amdgpu_test_arch = "@LIBOMPTARGET_AMDGPU_DETECTED_ARCH_LIST@"
 config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@/@CURRENT_TARGET@"
 config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
 config.llvm_library_dir = "@LIBOMPTARGET_LLVM_LIBRARY_DIR@"
diff --git a/openmp/libomptarget/test/unified_shared_memory/api.c b/openmp/libomptarget/test/unified_shared_memory/api.c
index 4f0f93b9bf5096..0c6a937dab7faa 100644
--- a/openmp/libomptarget/test/unified_shared_memory/api.c
+++ b/openmp/libomptarget/test/unified_shared_memory/api.c
@@ -1,10 +1,9 @@
-// RUN: %libomptarget-compile-run-and-check-generic
+// RUN: %libomptarget-compile-generic
+// RUN: env HSA_XNACK=1 \
+// RUN: %libomptarget-run-generic | %fcheck-generic
 // XFAIL: nvptx64-nvidia-cuda
 // XFAIL: nvptx64-nvidia-cuda-LTO
 
-// Fails on amdgpu with error: GPU Memory Error
-// UNSUPPORTED: amdgcn-amd-amdhsa
-
 #include <omp.h>
 #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 ec292c857f9c78..57a73787ef7ae9 100644
--- a/openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
+++ b/openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
@@ -1,11 +1,10 @@
-// RUN: %libomptarget-compile-run-and-check-generic
+// RUN: %libomptarget-compile-generic
+// RUN: env HSA_XNACK=1 \
+// RUN: %libomptarget-run-generic | %fcheck-generic
 
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// Fails on amdgpu with error: GPU Memory Error
-// XFAIL: amdgcn-amd-amdhsa
-
 #include <omp.h>
 #include <stdio.h>
 



More information about the Openmp-commits mailing list