Skip to content

Commit

Permalink
[CI] Automatically detect AMD architecture (#16071)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sarnex authored Nov 14, 2024
1 parent ee8e95b commit 73b0775
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 58 deletions.
1 change: 0 additions & 1 deletion .github/workflows/sycl-linux-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ jobs:
runner: '["Linux", "amdgpu"]'
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
image_extra_opts: --device=/dev/dri --device=/dev/kfd
extra_cmake_args: -DHIP_PLATFORM="AMD" -DAMD_ARCH="gfx1031"
- name: CUDA system
runner: '["Linux", "cuda"]'
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/sycl-linux-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ on:
type: string
required: True
extra_cmake_args:
description: |
If empty, then HIP_PLATFORM and AMD_ARCH would be automatically added
if inputs.target_devices contains 'ext_oneapi_hip'
type: string
required: False
tests_selector:
Expand Down Expand Up @@ -282,16 +279,6 @@ jobs:
run: |
if [ -n "$CMAKE_EXTRA_ARGS" ]; then
echo "opts=$CMAKE_EXTRA_ARGS" >> $GITHUB_OUTPUT
else
if [ "${{ contains(inputs.target_devices, 'ext_oneapi_hip') }}" == "true" ]; then
if [ "${{ runner.name }}" == "cp-amd-runner" ]; then
echo 'opts=-DHIP_PLATFORM="AMD" -DAMD_ARCH="gfx1030"' >> $GITHUB_OUTPUT
else
echo 'opts=-DHIP_PLATFORM="AMD" -DAMD_ARCH="gfx1031"' >> $GITHUB_OUTPUT
fi
else
echo 'opts=' >> $GITHUB_OUTPUT
fi
fi
- name: Configure E2E tests
if: inputs.tests_selector == 'e2e'
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Matrix/joint_matrix_hip_gfx90a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//

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

// REQUIRES: gpu-amd-gfx90a
// REQUIRES: arch-amd_gpu_gfx90a

#include "joint_matrix_hip_apply.hpp"
#include "joint_matrix_hip_copy.hpp"
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Matrix/joint_matrix_hip_half_gfx90a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//

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

// REQUIRES: gpu-amd-gfx90a
// REQUIRES: arch-amd_gpu_gfx90a
// REQUIRES: aspect-fp16

#include "joint_matrix_hip_apply.hpp"
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Matrix/runtime_query_hip_gfx90a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

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

#include <sycl/detail/core.hpp>
Expand Down
76 changes: 38 additions & 38 deletions sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,6 @@ def open_check_file(file_name):
)
sp = subprocess.check_output(cmd, text=True, shell=True)
for line in sp.splitlines():
if "gfx90a" in line:
config.available_features.add("gpu-amd-gfx90a")
if not line.startswith("["):
continue
(backend, device) = line[1:].split("]")[0].split(":")
Expand Down Expand Up @@ -540,42 +538,6 @@ def open_check_file(file_name):
config.cuda_libs_dir = os.path.join(os.environ["CUDA_PATH"], r"lib64")
config.cuda_include = os.path.join(os.environ["CUDA_PATH"], "include")

# FIXME: This needs to be made per-device as well, possibly with a helper.
if "hip:gpu" in config.sycl_devices and config.hip_platform == "AMD":
if not config.amd_arch:
lit_config.error(
"Cannot run tests for HIP without an offload-arch. Please "
+ "specify one via the 'amd_arch' parameter or 'AMD_ARCH' CMake "
+ "variable."
)
llvm_config.with_system_environment("ROCM_PATH")
config.available_features.add("hip_amd")
arch_flag = (
"-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=" + config.amd_arch
)
config.substitutions.append(
("%rocm_path", os.environ.get("ROCM_PATH", "/opt/rocm"))
)
elif "hip:gpu" in config.sycl_devices and config.hip_platform == "NVIDIA":
config.available_features.add("hip_nvidia")
arch_flag = ""
else:
arch_flag = ""

if lit_config.params.get("compatibility_testing", False):
config.substitutions.append(("%clangxx", " true "))
config.substitutions.append(("%clang", " true "))
else:
config.substitutions.append(
(
"%clangxx",
" " + config.dpcpp_compiler + " " + config.cxx_flags + " " + arch_flag,
)
)
config.substitutions.append(
("%clang", " " + config.dpcpp_compiler + " " + config.c_flags)
)

config.substitutions.append(("%threads_lib", config.sycl_threads_lib))

if lit_config.params.get("ze_debug"):
Expand Down Expand Up @@ -799,12 +761,50 @@ def open_check_file(file_name):
# Use short names for LIT rules.
features.add(be)

if be == "hip" and config.hip_platform == "AMD":
if not config.amd_arch:
# Guaranteed to be a single element in the set
arch = [x for x in architecture_feature][0]
amd_arch_prefix = "arch-amd_gpu_"
if amd_arch_prefix not in arch or len(architecture_feature) != 1:
lit_config.error(
"Cannot detect architecture for AMD HIP device, specify it explicitly"
)
config.amd_arch = arch.replace(amd_arch_prefix, "")
llvm_config.with_system_environment("ROCM_PATH")
config.available_features.add("hip_amd")
arch_flag = (
"-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=" + config.amd_arch
)
config.substitutions.append(
("%rocm_path", os.environ.get("ROCM_PATH", "/opt/rocm"))
)
elif be == "hip" and config.hip_platform == "NVIDIA":
config.available_features.add("hip_nvidia")
arch_flag = ""
else:
arch_flag = ""

config.sycl_dev_features[sycl_device] = features.union(config.available_features)
if is_intel_driver:
config.intel_driver_ver[sycl_device] = intel_driver_ver
else:
config.intel_driver_ver[sycl_device] = {}

if lit_config.params.get("compatibility_testing", False):
config.substitutions.append(("%clangxx", " true "))
config.substitutions.append(("%clang", " true "))
else:
config.substitutions.append(
(
"%clangxx",
" " + config.dpcpp_compiler + " " + config.cxx_flags + " " + arch_flag,
)
)
config.substitutions.append(
("%clang", " " + config.dpcpp_compiler + " " + config.c_flags)
)

# Set timeout for a single test
try:
import psutil
Expand Down

0 comments on commit 73b0775

Please sign in to comment.