Skip to content

Commit 8b85b64

Browse files
authored
[SYCL][ESIMD][Driver] Pass -fsycl-esimd-force-stateless-mem to host (#9825)
Right now, the `-fsycl-esimd-force-stateless-mem` flag sets the `__ESIMD_FORCE_STATELESS_MEM` macro for the device compiler only. We have some APIs that have different arguments with `__ESIMD_FORCE_STATELESS_MEM` vs without it, so getting the host compiler to not error when calling one of those functions can be frustrating for the user. Make `-fsycl-esimd-force-stateless-mem` set `__ESIMD_FORCE_STATELESS_MEM` for the host compiler too. I also found we had some esimd_emulator tests that were testing stateless mode, but the emulator never uses the device code and always uses host code, so it wasn't even testing stateless mode. We discussed this internally and decided to disable the tests on the emulator. --------- Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 5069cc4 commit 8b85b64

13 files changed

+30
-21
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5129,10 +5129,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
51295129
CmdArgs.push_back("-fsycl-allow-func-ptr");
51305130
}
51315131

5132-
if (Args.hasFlag(options::OPT_fsycl_esimd_force_stateless_mem,
5133-
options::OPT_fno_sycl_esimd_force_stateless_mem, false))
5134-
CmdArgs.push_back("-fsycl-esimd-force-stateless-mem");
5135-
51365132
// Forward -fsycl-instrument-device-code option to cc1. This option will
51375133
// only be used for SPIR-V-based targets.
51385134
if (Triple.isSPIR())
@@ -5318,6 +5314,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
53185314
for (auto &Macro : D.getSYCLTargetMacroArgs())
53195315
CmdArgs.push_back(Args.MakeArgString(Macro));
53205316
}
5317+
if (Args.hasFlag(options::OPT_fsycl_esimd_force_stateless_mem,
5318+
options::OPT_fno_sycl_esimd_force_stateless_mem, false))
5319+
CmdArgs.push_back("-fsycl-esimd-force-stateless-mem");
53215320
}
53225321

53235322
if (IsOpenMPDevice) {

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,13 +1309,13 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
13091309
Builder.defineMacro("__ENABLE_USM_ADDR_SPACE__");
13101310
Builder.defineMacro("SYCL_DISABLE_FALLBACK_ASSERT");
13111311
}
1312-
1313-
if (LangOpts.SYCLESIMDForceStatelessMem)
1314-
Builder.defineMacro("__ESIMD_FORCE_STATELESS_MEM");
13151312
}
13161313
if (LangOpts.SYCLUnnamedLambda)
13171314
Builder.defineMacro("__SYCL_UNNAMED_LAMBDA__");
13181315

1316+
if (LangOpts.SYCLESIMDForceStatelessMem)
1317+
Builder.defineMacro("__ESIMD_FORCE_STATELESS_MEM");
1318+
13191319
// OpenCL definitions.
13201320
if (LangOpts.OpenCL) {
13211321
InitializeOpenCLFeatureTestMacros(TI, LangOpts, Builder);

clang/test/Driver/sycl-esimd-force-stateless-mem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
/// Verify that the driver option is translated to corresponding options
3-
/// to device compilation and sycl-post-link.
3+
/// to host/device compilation and sycl-post-link.
44
// RUN: %clang -### -fsycl -fsycl-esimd-force-stateless-mem \
55
// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-PASS-TO-COMPS %s
66
// CHECK-PASS-TO-COMPS: clang{{.*}} "-fsycl-esimd-force-stateless-mem"
77
// CHECK-PASS-TO-COMPS: sycl-post-link{{.*}} "-lower-esimd-force-stateless-mem"
8-
// CHECK-PASS-TO-COMPS-NOT: clang{{.*}} "-fsycl-is-host" {{.*}}"-fsycl-esimd-force-stateless-mem"
9-
// CHECK-PASS-TO-COMPS-NOT: clang{{.*}} "-fsycl-esimd-force-stateless-mem" {{.*}}"-fsycl-is-host"
8+
// CHECK-PASS-TO-COMPS: clang{{.*}} "-fsycl-is-host" {{.*}}"-fsycl-esimd-force-stateless-mem"
9+
"
1010
1111
/// Verify that stateless memory accesses mapping is not enforced by default
1212
// RUN: %clang -### -fsycl %s 2>&1 | FileCheck -check-prefix=CHECK-DEFAULT %s

sycl/test-e2e/ESIMD/acc_gather_scatter_rgba_stateless.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8+
// UNSUPPORTED: esimd_emulator
89
// Use -O2 to avoid huge stack usage under -O0.
910
// RUN: %{build} -O2 -fsycl-esimd-force-stateless-mem -o %t.out
1011
// RUN: %{run} %t.out

sycl/test-e2e/ESIMD/accessor_gather_scatter_stateless.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8+
// UNSUPPORTED: esimd_emulator
89
// Use -O2 to avoid huge stack usage under -O0.
910
// RUN: %{build} -O2 -fsycl-esimd-force-stateless-mem -o %t.out
1011
// RUN: %{run} %t.out

sycl/test-e2e/ESIMD/accessor_load_store_stateless.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// intrinsics when stateless memory accesses are enforced, i.e. accessor
1111
// based accesses are automatically converted to stateless accesses.
1212

13+
// UNSUPPORTED: esimd_emulator
1314
// RUN: %{build} -fsycl-esimd-force-stateless-mem -o %t.out
1415
// RUN: %{run} %t.out
1516

sycl/test-e2e/ESIMD/accessor_stateless.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8+
// UNSUPPORTED: esimd_emulator
89
// Use -O2 to avoid huge stack usage under -O0.
910
// RUN: %{build} -O2 -fsycl-esimd-force-stateless-mem -D_CRT_SECURE_NO_WARNINGS=1 -o %t.out
1011
// RUN: %{run} %t.out

sycl/test-e2e/ESIMD/lsc/lsc_predicate_stateless.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
// REQUIRES: gpu-intel-pvc || esimd_emulator
8+
// UNSUPPORTED: esimd_emulator
9+
// REQUIRES: gpu-intel-pvc
910
// RUN: %{build} -fsycl-esimd-force-stateless-mem -o %t.out
1011
// RUN: %{run} %t.out
1112

sycl/test-e2e/ESIMD/lsc/lsc_surf_load_u32_stateless.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
// REQUIRES: gpu-intel-pvc || esimd_emulator
8+
// UNSUPPORTED: esimd_emulator
9+
// REQUIRES: gpu-intel-pvc
910
// RUN: %{build} -fsycl-esimd-force-stateless-mem -o %t.out
1011
// RUN: %{run} %t.out
1112

12-
#include "lsc_surf_load_u32.cpp"
13+
#include "lsc_surf_load_u32.cpp"

sycl/test-e2e/ESIMD/lsc/lsc_surf_load_u64_stateless.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
// REQUIRES: gpu-intel-pvc || esimd_emulator
8+
// UNSUPPORTED: esimd_emulator
9+
// REQUIRES: gpu-intel-pvc
910
// RUN: %{build} -fsycl-esimd-force-stateless-mem -o %t.out
1011
// RUN: %{run} %t.out
1112

12-
#include "lsc_surf_load_u64.cpp"
13+
#include "lsc_surf_load_u64.cpp"

sycl/test-e2e/ESIMD/lsc/lsc_surf_load_u8_u16_stateless.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
// REQUIRES: gpu-intel-pvc || esimd_emulator
8+
// UNSUPPORTED: esimd_emulator
9+
// REQUIRES: gpu-intel-pvc
910
// RUN: %{build} -fsycl-esimd-force-stateless-mem -o %t.out
1011
// RUN: %{run} %t.out
1112

12-
#include "lsc_surf_load_u8_u16.cpp"
13+
#include "lsc_surf_load_u8_u16.cpp"

sycl/test-e2e/ESIMD/lsc/lsc_surf_store_u32_stateless.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
// REQUIRES: gpu-intel-pvc || esimd_emulator
8+
// UNSUPPORTED: esimd_emulator
9+
// REQUIRES: gpu-intel-pvc
910
// RUN: %{build} -fsycl-esimd-force-stateless-mem -o %t.out
1011
// RUN: %{run} %t.out
1112

12-
#include "lsc_surf_store_u32.cpp"
13+
#include "lsc_surf_store_u32.cpp"

sycl/test-e2e/ESIMD/lsc/lsc_surf_store_u64_stateless.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
// REQUIRES: gpu-intel-pvc || esimd_emulator
8+
// UNSUPPORTED: esimd_emulator
9+
// REQUIRES: gpu-intel-pvc
910
// RUN: %{build} -fsycl-esimd-force-stateless-mem -o %t.out
1011
// RUN: %{run} %t.out
1112

12-
#include "lsc_surf_store_u64.cpp"
13+
#include "lsc_surf_store_u64.cpp"

0 commit comments

Comments
 (0)