Skip to content

[CI] Automatically detect AMD architecture #16071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is a bug fix, we shouldn't use %{build} if we're setting -fsycl-targets/choosing file and output

// RUN: %{run} %t.out

// REQUIRES: gpu-amd-gfx90a
// REQUIRES: arch-amd_gpu_gfx90a
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is just to remove a hack in the testing infra, should be exactly the same functionally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, just wondering if you were able to build and run these gfx90a tests. AFAIK we don't have these in our CI, so I don't think they ever ran.

Copy link
Contributor Author

@sarnex sarnex Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i actually tested on the one AMD machine i know not in our CI and it happens to be gfx90a (MI250)


#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
Loading