Skip to content

Commit

Permalink
[SYCL] Gracefully handle unknown device (#11254)
Browse files Browse the repository at this point in the history
Don't throw ICE when an unknown device is specified explicitly via
`-Xsycl-target-backend --offload-arch=`. We don't enable macros or other
niceties from sycl_ext_oneapi_device_architecture, but at least the code
compiles.

Fixes #8112, #11203, #12010
  • Loading branch information
al42and authored Nov 28, 2023
1 parent 4c9c455 commit 5a51c0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5482,7 +5482,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Triple.getSubArch() == llvm::Triple::SPIRSubArch_gen) ||
Triple.isNVPTX() || Triple.isAMDGCN()) {
StringRef Device = JA.getOffloadingArch();
if (!Device.empty()) {
if (!Device.empty() && !SYCL::gen::getGenDeviceMacro(Device).empty()) {
Macro = "-D";
Macro += SYCL::gen::getGenDeviceMacro(Device);
}
Expand Down
8 changes: 8 additions & 0 deletions clang/test/Driver/sycl-unsupported-arch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// Verify that compiler passes are correctly determined
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx600 -nogpulib -c -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=CHECK-PHASES
// CHECK-PHASES: offload, "device-sycl (amdgcn-amd-amdhsa:gfx600)"

/// Verify that preprocessor works (#8112)
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx600 -nogpulib -E %s 2>&1 | FileCheck %s --check-prefix=CHECK-PREPROCESSOR
// CHECK-PREPROCESSOR: // __CLANG_OFFLOAD_BUNDLE____START__ sycl-amdgcn-amd-amdhsa-gfx600

0 comments on commit 5a51c0a

Please sign in to comment.