Skip to content
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

[DRIVER][SYCL] Update the SYCL triple parsing for AMD #15990

Merged
merged 8 commits into from
Dec 18, 2024
6 changes: 4 additions & 2 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,10 @@ static bool isValidSYCLTriple(llvm::Triple T) {
T.getOS() == llvm::Triple::CUDA && !T.hasEnvironment())
return true;

// AMDGCN is valid for SYCL
if (T.isAMDGCN())
// 'amdgcn-amd-amdhsa' is the valid SYCL triple for AMD GPUs.
jle-quel marked this conversation as resolved.
Show resolved Hide resolved
if (T.getArch() == llvm::Triple::amdgcn &&
T.getVendor() == llvm::Triple::AMD && T.getOS() == llvm::Triple::AMDHSA &&
!T.hasEnvironment())
return true;

// Check for invalid SYCL device triple values.
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Driver/sycl-offload-new-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@
// WRAPPER_OPTIONS_BACKEND_AOT-SAME: "--cpu-tool-arg=-backend-cpu-opt"

/// Verify arch settings for nvptx and amdgcn targets
// RUN: %clangxx -fsycl -### -fsycl-targets=amdgcn-amd-gpu -fno-sycl-libspirv \
// RUN: %clangxx -fsycl -### -fsycl-targets=amdgcn-amd-amdhsa -fno-sycl-libspirv \
// RUN: -nocudalib --offload-new-driver \
// RUN: -Xsycl-target-backend=amdgcn-amd-gpu --offload-arch=gfx600 \
// RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx600 \
// RUN: %s 2>&1 \
// RUN: | FileCheck -check-prefix AMD_ARCH %s
// AMD_ARCH: clang-offload-packager{{.*}} "--image=file={{.*}},triple=amdgcn-amd-gpu,arch=gfx600,kind=sycl,compile-opts=--offload-arch=gfx600"
// AMD_ARCH: clang-offload-packager{{.*}} "--image=file={{.*}},triple=amdgcn-amd-amdhsa,arch=gfx600,kind=sycl,compile-opts=--offload-arch=gfx600"

// RUN: %clangxx -fsycl -### -fsycl-targets=nvptx64-nvidia-cuda \
// RUN: -fno-sycl-libspirv -nocudalib --offload-new-driver %s 2>&1 \
Expand Down
21 changes: 21 additions & 0 deletions clang/test/Driver/sycl-oneapi-gpu-amdgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@
// RUN: FileCheck %s --check-prefix=BAD_AMD_INPUT
// BAD_AMD_INPUT: error: SYCL target is invalid: 'amd_gpu_bad'

// Check the SYCL triple for AMD GPUs.
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -### \
// RUN: -Xsycl-target-backend --offload-arch=gfx908 \
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/libspirv.bc %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=AMD-TRIPLE
// AMD-TRIPLE: clang{{.*}} "-triple" "amdgcn-amd-amdhsa"

// Check if SYCL triples with 'Environment' component are rejected for AMD GPUs.
// RUN: not %clangxx -c -fsycl -fsycl-targets=amdgcn-amd-amdhsa-sycl -### %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=BAD_TARGET_TRIPLE_ENV
// RUN: not %clang_cl -c -fsycl -fsycl-targets=amdgcn-amd-amdhsa-sycl -### %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=BAD_TARGET_TRIPLE_ENV
// BAD_TARGET_TRIPLE_ENV: error: SYCL target is invalid: 'amdgcn-amd-amdhsa-sycl'

// Check for invalid SYCL triple for AMD GPUs.
// RUN: not %clangxx -c -fsycl -fsycl-targets=amdgcn -### %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=BAD_TARGET_TRIPLE
// RUN: not %clang_cl -c -fsycl -fsycl-targets=amdgcn-amd -### %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=BAD_TARGET_TRIPLE
// BAD_TARGET_TRIPLE: error: SYCL target is invalid: 'amdgcn{{.*}}'

/// Test for proper creation of fat object
// RUN: %clangxx -fsycl -nogpulib -fsycl-targets=amd_gpu_gfx700 \
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/libspirv.bc \
Expand Down
1 change: 1 addition & 0 deletions sycl/doc/UsersManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ and not recommended to use in production environment.
spir64_fpga-unknown-unknown, spir64_gen-unknown-unknown
Available in special build configuration:
* nvptx64-nvidia-cuda - generate code ahead of time for CUDA target;
* amdgcn-amd-amdhsa - generate code ahead of time for HIP target;
* native_cpu - allows to run SYCL applications with no need of an
additional backend (note that this feature is WIP and experimental, and
currently overrides all the other specified SYCL targets when enabled.)
Expand Down
Loading