Skip to content

Commit f953fda

Browse files
authored
[SYCL] Set aux-target-cpu for SYCL offload device compilation (#1225)
This patch adds -aux_target_cpu that will set AVX and other necessary macros for the SYCL offload device compilation based on -aux-target-cpu target. Signed-off-by: Soumi Manna <[email protected]>
1 parent f41309b commit f953fda

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4742,6 +4742,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
47424742
// `--gpu-use-aux-triple-only` is specified.
47434743
if (!Args.getLastArg(options::OPT_gpu_use_aux_triple_only) &&
47444744
((IsCuda && JA.isDeviceOffloading(Action::OFK_Cuda)) ||
4745+
(IsSYCL && IsSYCLOffloadDevice) ||
47454746
(IsHIP && JA.isDeviceOffloading(Action::OFK_HIP)))) {
47464747
const ArgList &HostArgs =
47474748
C.getArgsForToolChain(nullptr, StringRef(), Action::OFK_None);

clang/test/Driver/sycl-offload.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// Check "-aux-target-cpu" and "target-cpu" are passed when compiling for SYCL offload device and host codes:
2+
// RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck -check-prefix=CHECK-OFFLOAD %s
3+
// CHECK-OFFLOAD: clang{{.*}} "-cc1" {{.*}} "-fsycl-is-device"
4+
// CHECK-OFFLOAD-SAME: "-aux-target-cpu" "x86-64"
5+
// CHECK-OFFLOAD-NEXT: clang{{.*}} "-cc1" {{.*}}
6+
// CHECK-OFFLOAD-NEXT-SAME: "-fsycl-is-host"
7+
// CHECK-OFFLOAD-NEXT-SAME: "-target-cpu" "x86-64"
8+
9+
/// Check "-aux-target-cpu" with "-aux-target-feature" and "-target-cpu" with "-target-feature" are passed
10+
/// when compiling for SYCL offload device and host codes:
11+
// RUN: %clang -fsycl -mavx -c %s -### -o %t.o 2>&1 | FileCheck -check-prefix=OFFLOAD-AVX %s
12+
// OFFLOAD-AVX: clang{{.*}} "-cc1" {{.*}} "-fsycl-is-device"
13+
// OFFLOAD-AVX-SAME: "-aux-target-cpu" "x86-64" "-aux-target-feature" "+avx"
14+
// OFFLOAD-AVX-NEXT: clang{{.*}} "-cc1" {{.*}}
15+
// OFFLOAD-AVX-NEXT-SAME: "-fsycl-is-host"
16+
// OFFLOAD-AVX-NEXT-SAME: "-target-cpu" "x86-64" "-target-feature" "+avx"

0 commit comments

Comments
 (0)