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] Enable SYCL AOT compilation using --offload-arch #15353

Draft
wants to merge 16 commits into
base: sycl
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 11 additions & 17 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,6 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
false) ||
C.getInputArgs().hasArg(options::OPT_fsycl_device_only);

bool IsSYCLOffloadArchEnabled =
HasValidSYCLRuntime &&
C.getInputArgs().hasArg(options::OPT_offload_arch_EQ);

Arg *SYCLfpga = C.getInputArgs().getLastArg(options::OPT_fintelfpga);

// Make -fintelfpga flag imply -fsycl.
Expand Down Expand Up @@ -1303,6 +1299,16 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
else if (HasValidSYCLRuntime &&
C.getInputArgs().hasArg(options::OPT_offload_arch_EQ) && !IsHIP &&
!IsCuda) {
// SYCL offloading to Intel CPUs and Intel GPUs with ``--offload-arch``
// is currently enabled only with ``--offload-new-driver`` option.
// Emit a diagnostic if ``--offload-arch`` is invoked without
// ``--offload-new driver`` option.
if (!C.getInputArgs().hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver,
false)) {
Diag(clang::diag::err_drv_sycl_offload_arch_new_driver);
return;
}
srividya-sundaram marked this conversation as resolved.
Show resolved Hide resolved
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
auto AMDTriple = getHIPOffloadTargetTriple(*this, C.getInputArgs());
auto NVPTXTriple = getNVIDIAOffloadTargetTriple(*this, C.getInputArgs(),
Expand Down Expand Up @@ -1365,19 +1371,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
llvm::Triple SYCLTargetTriple(MakeSYCLDeviceTriple(Val.getKey()));
std::string NormalizedName = SYCLTargetTriple.normalize();

// SYCL offloading to Intel CPUs and Intel GPUs with ``--offload-arch``
// is currently enabled only with ``--offload-new-driver`` option.
// Emit a diagnostic if ``--offload-arch`` is invoked without
// ``--offload-new driver`` option.
if (SYCLTargetTriple != NVPTXTriple && SYCLTargetTriple != AMDTriple) {
if (IsSYCLOffloadArchEnabled &&
!C.getInputArgs().hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver,
false)) {
Diag(clang::diag::err_drv_sycl_offload_arch_new_driver);
return;
}
}


// Make sure we don't have a duplicate triple.
auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
Expand Down
39 changes: 0 additions & 39 deletions clang/test/Driver/sycl-offload-arch-amd-gpu-cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx1013 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-GPU,CLANG-OFFLOAD-PACKAGER-AMD -DDEV_STR=gfx1013 -DMAC_STR=GFX1013

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx1013 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-GPU,CLANG-OFFLOAD-PACKAGER-AMD -DDEV_STR=gfx1013 -DMAC_STR=GFX1013

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx1030 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-GPU,CLANG-OFFLOAD-PACKAGER-AMD -DDEV_STR=gfx1030 -DMAC_STR=GFX1030

Expand Down Expand Up @@ -91,15 +88,6 @@

// AMD CPUs

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx600 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx600

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx601 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx601

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx602 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx602
srividya-sundaram marked this conversation as resolved.
Show resolved Hide resolved

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx700 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx700

Expand All @@ -109,18 +97,6 @@
// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx702 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx702

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx702 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx702

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx703 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx703

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx704 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx704

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx705 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx705

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx801 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx801

Expand All @@ -136,24 +112,12 @@
// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx810 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx810

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx9-generic -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx9-generic

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx1152 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx1152

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx1200 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx1200

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx1201 -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx1201

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=gfx12-generic -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-CPU,CLANG-OFFLOAD-PACKAGER-AMD-CPU -DDEV_STR=gfx12-generic

// RUN: %clangxx -### --offload-new-driver -fsycl --offload-arch=amdgcnspirv -nogpulib -fno-sycl-libspirv %s 2>&1 | \
// RUN: FileCheck %s --check-prefixes=TARGET-TRIPLE-AMD-SPIRV,CLANG-OFFLOAD-PACKAGER-AMD-SPIRV -DDEV_STR=amdgcnspirv

// TARGET-TRIPLE-AMD-GPU: clang{{.*}} "-triple" "amdgcn-amd-amdhsa"
// TARGET-TRIPLE-AMD-GPU: "-D__SYCL_TARGET_AMD_GPU_[[MAC_STR]]__"
// CLANG-OFFLOAD-PACKAGER-AMD: clang-offload-packager{{.*}} "--image={{.*}}triple=amdgcn-amd-amdhsa,arch=[[DEV_STR]],kind=sycl"
Expand All @@ -165,6 +129,3 @@
// TARGET-TRIPLE-AMD-SPIRV: clang{{.*}} "-triple" "spirv64-amd-amdhsa"
// CLANG-OFFLOAD-PACKAGER-AMD-SPIRV: clang-offload-packager{{.*}} "--image={{.*}}triple=spirv64-amd-amdhsa,arch=[[DEV_STR]],kind=sycl,{{.*}}"

// TARGET-TRIPLE-AMD-GENERIC: clang{{.*}} "-triple" "spirv64-amd-amdhsa"
// CLANG-OFFLOAD-PACKAGER-AMD-GENERIC: clang-offload-packager{{.*}} "--image={{.*}}triple=spirv64-amd-amdhsa,arch=[[DEV_STR]],kind=sycl,{{.*}}"

Loading