[Openmp-commits] [llvm] [openmp] [OpenMP][Offload][AMDGPU] Fix offload tests failure after the new triple (PR #208617)
via Openmp-commits
openmp-commits at lists.llvm.org
Thu Jul 9 21:18:04 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Kewen Meng (Kewen12)
<details>
<summary>Changes</summary>
Offload tests failed after introducing the new triple. This PR attempts to address that. It includes the changes in https://github.com/llvm/llvm-project/pull/208551. In addition, it also made following changes:
- Updated flang builder that our buildbot uses;
- Updated the CMakeLists for offload and AMDGPU device runtime (a little duplications to avoid breaking other buildbots);
- Added per target linker path and mapping for lit substitution/features in lit config;
- Updated hard-coded check lines in the tests.
This PR reduces the failed offload tests from 246 to 2 on my test runs locally. Test results and the two failed tests:
```
Failed Tests (2):
libomptarget :: amdgpu-amd-amdhsa :: offloading/fortran/declare-target-common-block-main.f90
libomptarget :: amdgpu-amd-amdhsa :: sanitizer/use_after_free_2.c
Total Discovered Tests: 3478
Skipped : 77 (2.21%)
Unsupported : 341 (9.80%)
Passed : 3053 (87.78%)
Expectedly Failed: 5 (0.14%)
Failed : 2 (0.06%)
```
I was not able to identify the commits for the two failed tests yet (didn't look like flakiness), will try again later.
---
Full diff: https://github.com/llvm/llvm-project/pull/208617.diff
8 Files Affected:
- (modified) offload/CMakeLists.txt (+1-1)
- (modified) offload/ci/openmp-offload-amdgpu-clang-flang.py (+3-2)
- (modified) offload/test/lit.cfg (+50-2)
- (modified) offload/test/offloading/fortran/basic_array.c (+1-1)
- (modified) offload/test/offloading/fortran/target-use-dev-ptr.f90 (+1-1)
- (modified) offload/test/offloading/fortran/usm_map_close.f90 (+1-1)
- (modified) openmp/CMakeLists.txt (+2-2)
- (modified) openmp/device/CMakeLists.txt (+2-2)
``````````diff
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index b218ed264707c..ce6ab9452d518 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -214,7 +214,7 @@ include_directories(${LIBOMPTARGET_LLVM_INCLUDE_DIRS})
# This is a list of all the targets that are supported/tested right now.
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu")
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu-LTO")
-set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} amdgcn-amd-amdhsa")
+set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} amdgpu-amd-amdhsa")
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64le-ibm-linux-gnu")
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64le-ibm-linux-gnu-LTO")
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64-ibm-linux-gnu")
diff --git a/offload/ci/openmp-offload-amdgpu-clang-flang.py b/offload/ci/openmp-offload-amdgpu-clang-flang.py
index ea31c5e87b1ff..609edf219103d 100755
--- a/offload/ci/openmp-offload-amdgpu-clang-flang.py
+++ b/offload/ci/openmp-offload-amdgpu-clang-flang.py
@@ -34,8 +34,9 @@
"-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath",
"-DCMAKE_CXX_STANDARD=17",
"-DLIBOMPTARGET_PLUGINS_TO_BUILD=amdgpu;host",
- "-DRUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES=compiler-rt;openmp",
- f"-DRUNTIMES_amdgcn-amd-amdhsa_CACHE_FILES={w.in_llvmsrc('compiler-rt')}/cmake/caches/AMDGPU.cmake\;{w.in_llvmsrc('libcxx')}/cmake/caches/AMDGPU.cmake CACHE STRING '')",
+ "-DLLVM_RUNTIME_TARGETS=default;amdgpu-amd-amdhsa",
+ "-DRUNTIMES_amdgpu-amd-amdhsa_LLVM_ENABLE_RUNTIMES=compiler-rt;openmp",
+ f"-DRUNTIMES_amdgpu-amd-amdhsa_CACHE_FILES={w.in_llvmsrc('compiler-rt')}/cmake/caches/AMDGPU.cmake\;{w.in_llvmsrc('libcxx')}/cmake/caches/AMDGPU.cmake CACHE STRING '')",
]
)
diff --git a/offload/test/lit.cfg b/offload/test/lit.cfg
index 03f3db08a2def..8c89b6481dc5f 100644
--- a/offload/test/lit.cfg
+++ b/offload/test/lit.cfg
@@ -137,6 +137,11 @@ if config.has_libomptarget_ompt:
config.available_features.add(config.libomptarget_current_target)
+amdgpu_target = 'amdgpu-amd-amdhsa'
+legacy_amdgpu_target = 'amdgcn-amd-amdhsa'
+if config.libomptarget_current_target == amdgpu_target:
+ config.available_features.add(legacy_amdgpu_target)
+
if config.libomptarget_has_libc:
config.available_features.add('libc')
@@ -144,7 +149,8 @@ profdata_path = os.path.join(config.bin_llvm_tools_dir, "llvm-profdata")
target = remove_suffix_if_present(config.libomptarget_current_target)
has_profile_rt = True
has_flang_rt = True
-if target.startswith('amdgcn') or target.startswith('nvptx'):
+if (target.startswith('amdgpu') or target.startswith('amdgcn') or
+ target.startswith('nvptx')):
has_profile_rt = bool(glob.glob(os.path.join(
config.llvm_lib_directory, 'clang', '*', 'lib', target,
'libclang_rt.profile.a')))
@@ -231,7 +237,8 @@ host_targets = [
if config.libomptarget_current_target.startswith('nvptx'):
config.available_features.add('gpu')
config.available_features.add('nvidiagpu')
-if config.libomptarget_current_target.startswith('amdgcn'):
+if (config.libomptarget_current_target.startswith('amdgpu') or
+ config.libomptarget_current_target.startswith('amdgcn')):
config.available_features.add('gpu')
config.available_features.add('amdgpu')
config.environment['HSA_DISABLE_COREDUMP_ON_EXCEPTION'] = '1'
@@ -241,6 +248,14 @@ if config.libomptarget_current_target.startswith('spirv64-intel'):
if config.libomptarget_current_target in host_targets:
config.available_features.add('host')
+def get_target_library_dir():
+ return os.path.join(
+ config.llvm_library_dir,
+ remove_suffix_if_present(config.libomptarget_current_target))
+
+if "gpu" in config.available_features and "intelgpu" not in config.available_features:
+ config.test_flags += " -Xoffload-linker -L" + get_target_library_dir()
+
def add_libraries(source):
if "gpu" not in config.available_features:
return source
@@ -259,6 +274,39 @@ def add_libraries(source):
# - for valid targets that do not exist in the system, return false, so that the
# same test can be used for different targets.
+def add_target_alias_substitutions(alias, target):
+ prefixes = [
+ "%libomptarget-compilexx-run-and-check-",
+ "%libomptarget-compile-run-and-check-",
+ "%libomptarget-compile-fortran-run-and-check-",
+ "%libomptarget-compilexx-and-run-",
+ "%libomptarget-compile-and-run-",
+ "%libomptarget-compile-fortran-and-run-",
+ "%libomptarget-compilexx-",
+ "%libomptarget-compilexxx-force-usm-",
+ "%libomptarget-compile-",
+ "%libomptarget-compile-fortran-",
+ "%libomptarget-compileoptxx-run-and-check-",
+ "%libomptarget-compileopt-run-and-check-",
+ "%libomptarget-compileoptxx-and-run-",
+ "%libomptarget-compileopt-and-run-",
+ "%libomptarget-compileoptxx-",
+ "%libomptarget-compileopt-",
+ "%libomptarget-run-",
+ "%libomptarget-run-fail-",
+ "%clangxxx-force-usm-",
+ "%clangxx-",
+ "%clang-",
+ "%flang-",
+ "%fcheck-",
+ ]
+
+ for prefix in prefixes:
+ config.substitutions.append((prefix + alias, prefix + target))
+
+if amdgpu_target in config.libomptarget_all_targets:
+ add_target_alias_substitutions(legacy_amdgpu_target, amdgpu_target)
+
# Scan all the valid targets.
for libomptarget_target in config.libomptarget_all_targets:
# Is this target in the current system? If so create a compile, run and test
diff --git a/offload/test/offloading/fortran/basic_array.c b/offload/test/offloading/fortran/basic_array.c
index 4daf1d4b0a998..b7b1abd4d889c 100644
--- a/offload/test/offloading/fortran/basic_array.c
+++ b/offload/test/offloading/fortran/basic_array.c
@@ -1,7 +1,7 @@
// Basic offloading test for function compiled with flang
// REQUIRES: flang, amdgcn-amd-amdhsa
-// RUN: %flang -c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+// RUN: %flang -c -fopenmp -fopenmp-targets=amdgpu-amd-amdhsa \
// RUN: %S/../../Inputs/basic_array.f90 -o basic_array.o
// RUN: %libomptarget-compile-generic basic_array.o
// RUN: %t | %fcheck-generic
diff --git a/offload/test/offloading/fortran/target-use-dev-ptr.f90 b/offload/test/offloading/fortran/target-use-dev-ptr.f90
index 069d4a717ff5e..2f4c7bd8b6fd2 100644
--- a/offload/test/offloading/fortran/target-use-dev-ptr.f90
+++ b/offload/test/offloading/fortran/target-use-dev-ptr.f90
@@ -2,7 +2,7 @@
! addresses are maintained across target boundaries
! REQUIRES: clang, flang, amdgcn-amd-amdhsa
-! RUN: %clang -c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+! RUN: %clang -c -fopenmp -fopenmp-targets=amdgpu-amd-amdhsa \
! RUN: %S/../../Inputs/target-use-dev-ptr.c -o target-use-dev-ptr_c.o
! RUN: %libomptarget-compile-fortran-generic target-use-dev-ptr_c.o
! RUN: %t | %fcheck-generic
diff --git a/offload/test/offloading/fortran/usm_map_close.f90 b/offload/test/offloading/fortran/usm_map_close.f90
index 61d096ef94f1b..448b22acffc7c 100644
--- a/offload/test/offloading/fortran/usm_map_close.f90
+++ b/offload/test/offloading/fortran/usm_map_close.f90
@@ -2,7 +2,7 @@
! near/on device when utilised in USM mode.
! REQUIRES: clang, flang, amdgpu
-! RUN: %clang -c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+! RUN: %clang -c -fopenmp -fopenmp-targets=amdgpu-amd-amdhsa \
! RUN: %S/../../Inputs/target-use-dev-ptr.c -o target-use-dev-ptr_c.o
! RUN: %libomptarget-compile-fortran-generic target-use-dev-ptr_c.o
! RUN: env HSA_XNACK=1 \
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 1f328785f6118..d0d0e2ba004e4 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -173,8 +173,8 @@ if(LIBOMP_FORTRAN_MODULES)
endif()
# Use the current compiler target to determine the appropriate runtime to build.
-if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn|^nvptx|^spirv64" OR
- "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^amdgcn|^nvptx|^spirv64")
+if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgpu|^amdgcn|^nvptx|^spirv64" OR
+ "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^amdgpu|^amdgcn|^nvptx|^spirv64")
add_subdirectory(device)
else()
# Build host runtime library, after LIBOMPTARGET variables are set since they
diff --git a/openmp/device/CMakeLists.txt b/openmp/device/CMakeLists.txt
index 32cd2d1dbb2fd..a41cc58669383 100644
--- a/openmp/device/CMakeLists.txt
+++ b/openmp/device/CMakeLists.txt
@@ -44,8 +44,8 @@ endif()
# propagation. That said, we will run the vectorizer again after the runtime
# has been linked into the user program.
list(APPEND compile_options "SHELL: -mllvm -vectorize-slp=false")
-if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn" OR
- "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^amdgcn")
+if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgpu|^amdgcn" OR
+ "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "^amdgpu|^amdgcn")
set(target_name "amdgpu")
list(APPEND compile_options "SHELL:-Xclang -mcode-object-version=none")
elseif("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^nvptx" OR
``````````
</details>
https://github.com/llvm/llvm-project/pull/208617
More information about the Openmp-commits
mailing list