Skip to content

Commit cf324f3

Browse files
sarnexKornevNikita
authored andcommitted
[CI] Automatically detect AMD architecture (#16071)
We can figure it out from the `sycl-ls` output. Confirmed working [here](https://github.com/intel/llvm/actions/runs/11841045635/job/32998817316?pr=16071) Closes: #16057 --------- Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 9f48e8a commit cf324f3

File tree

4 files changed

+44
-41
lines changed

4 files changed

+44
-41
lines changed

sycl/test-e2e/Matrix/joint_matrix_hip_gfx90a.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// RUN: %{build} -fsycl -fsycl-targets=amd_gpu_gfx90a %s -o %t.out
9+
// RUN: %clangxx -fsycl -fsycl-targets=amd_gpu_gfx90a %s -o %t.out
1010
// RUN: %{run} %t.out
1111

12-
// REQUIRES: gpu-amd-gfx90a
12+
// REQUIRES: arch-amd_gpu_gfx90a
1313

1414
#include "joint_matrix_hip_apply.hpp"
1515
#include "joint_matrix_hip_copy.hpp"

sycl/test-e2e/Matrix/joint_matrix_hip_half_gfx90a.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// RUN: %{build} -fsycl -fsycl-targets=amd_gpu_gfx90a %s -o %t.out
9+
// RUN: %clangxx -fsycl -fsycl-targets=amd_gpu_gfx90a %s -o %t.out
1010
// RUN: %{run} %t.out
1111

12-
// REQUIRES: gpu-amd-gfx90a
12+
// REQUIRES: arch-amd_gpu_gfx90a
1313
// REQUIRES: aspect-fp16
1414

1515
#include "joint_matrix_hip_apply.hpp"

sycl/test-e2e/Matrix/runtime_query_hip_gfx90a.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// REQUIRES: gpu-amd-gfx90a
10-
// RUN: %{build} -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx90a -o %t.out
9+
// REQUIRES: arch-amd_gpu_gfx90a
10+
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx90a %s -o %t.out
1111
// RUN: %{run} %t.out
1212

1313
#include <sycl/detail/core.hpp>

sycl/test-e2e/lit.cfg.py

+38-35
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,6 @@ def open_check_file(file_name):
442442
for line in sp.splitlines():
443443
if "Intel(R) Data Center GPU Max 1100" in line:
444444
config.available_features.add("gpu-intel-pvc-1T")
445-
if "gfx90a" in line:
446-
config.available_features.add("gpu-amd-gfx90a")
447445
if not line.startswith("["):
448446
continue
449447
(backend, device) = line[1:].split("]")[0].split(":")
@@ -540,39 +538,6 @@ def open_check_file(file_name):
540538
config.cuda_libs_dir = os.path.join(os.environ["CUDA_PATH"], r"lib64")
541539
config.cuda_include = os.path.join(os.environ["CUDA_PATH"], "include")
542540

543-
# FIXME: This needs to be made per-device as well, possibly with a helper.
544-
if "hip:gpu" in config.sycl_devices and config.hip_platform == "AMD":
545-
if not config.amd_arch:
546-
lit_config.error(
547-
"Cannot run tests for HIP without an offload-arch. Please "
548-
+ "specify one via the 'amd_arch' parameter or 'AMD_ARCH' CMake "
549-
+ "variable."
550-
)
551-
llvm_config.with_system_environment("ROCM_PATH")
552-
config.available_features.add("hip_amd")
553-
arch_flag = (
554-
"-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=" + config.amd_arch
555-
)
556-
elif "hip:gpu" in config.sycl_devices and config.hip_platform == "NVIDIA":
557-
config.available_features.add("hip_nvidia")
558-
arch_flag = ""
559-
else:
560-
arch_flag = ""
561-
562-
if lit_config.params.get("compatibility_testing", False):
563-
config.substitutions.append(("%clangxx", " true "))
564-
config.substitutions.append(("%clang", " true "))
565-
else:
566-
config.substitutions.append(
567-
(
568-
"%clangxx",
569-
" " + config.dpcpp_compiler + " " + config.cxx_flags + " " + arch_flag,
570-
)
571-
)
572-
config.substitutions.append(
573-
("%clang", " " + config.dpcpp_compiler + " " + config.c_flags)
574-
)
575-
576541
config.substitutions.append(("%threads_lib", config.sycl_threads_lib))
577542

578543
if lit_config.params.get("ze_debug"):
@@ -805,12 +770,50 @@ def open_check_file(file_name):
805770
# Use short names for LIT rules.
806771
features.add(be)
807772

773+
if be == "hip" and config.hip_platform == "AMD":
774+
if not config.amd_arch:
775+
# Guaranteed to be a single element in the set
776+
arch = [x for x in architecture_feature][0]
777+
amd_arch_prefix = "arch-amd_gpu_"
778+
if amd_arch_prefix not in arch or len(architecture_feature) != 1:
779+
lit_config.error(
780+
"Cannot detect architecture for AMD HIP device, specify it explicitly"
781+
)
782+
config.amd_arch = arch.replace(amd_arch_prefix, "")
783+
llvm_config.with_system_environment("ROCM_PATH")
784+
config.available_features.add("hip_amd")
785+
arch_flag = (
786+
"-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=" + config.amd_arch
787+
)
788+
config.substitutions.append(
789+
("%rocm_path", os.environ.get("ROCM_PATH", "/opt/rocm"))
790+
)
791+
elif be == "hip" and config.hip_platform == "NVIDIA":
792+
config.available_features.add("hip_nvidia")
793+
arch_flag = ""
794+
else:
795+
arch_flag = ""
796+
808797
config.sycl_dev_features[sycl_device] = features.union(config.available_features)
809798
if is_intel_driver:
810799
config.intel_driver_ver[sycl_device] = intel_driver_ver
811800
else:
812801
config.intel_driver_ver[sycl_device] = {}
813802

803+
if lit_config.params.get("compatibility_testing", False):
804+
config.substitutions.append(("%clangxx", " true "))
805+
config.substitutions.append(("%clang", " true "))
806+
else:
807+
config.substitutions.append(
808+
(
809+
"%clangxx",
810+
" " + config.dpcpp_compiler + " " + config.cxx_flags + " " + arch_flag,
811+
)
812+
)
813+
config.substitutions.append(
814+
("%clang", " " + config.dpcpp_compiler + " " + config.c_flags)
815+
)
816+
814817
# Set timeout for a single test
815818
try:
816819
import psutil

0 commit comments

Comments
 (0)