diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 66ddc04c51bf0..144a53236f061 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -823,8 +823,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. + 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. diff --git a/clang/test/Driver/sycl-offload-new-driver.c b/clang/test/Driver/sycl-offload-new-driver.c index dd656192b80f3..e03709f97cb2a 100644 --- a/clang/test/Driver/sycl-offload-new-driver.c +++ b/clang/test/Driver/sycl-offload-new-driver.c @@ -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 \ diff --git a/clang/test/Driver/sycl-oneapi-gpu-amdgpu.cpp b/clang/test/Driver/sycl-oneapi-gpu-amdgpu.cpp index e6c8530c53130..4258f5b1f04cb 100644 --- a/clang/test/Driver/sycl-oneapi-gpu-amdgpu.cpp +++ b/clang/test/Driver/sycl-oneapi-gpu-amdgpu.cpp @@ -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 -nogpulib -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 -nogpulib -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 -nogpulib -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 \ diff --git a/sycl/doc/UsersManual.md b/sycl/doc/UsersManual.md index d8f48ee1b5205..4b22acba6af76 100644 --- a/sycl/doc/UsersManual.md +++ b/sycl/doc/UsersManual.md @@ -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.)