Skip to content

Commit 5afa292

Browse files
authored
[SYCL][RTC] Disable dead argument elimination (#16139)
Unused arguments need to remain in place for free-function kernels, in order not to perturb the argument indices used with `handler::set_arg`. Signed-off-by: Julian Oppermann <[email protected]>
1 parent 3c274a8 commit 5afa292

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ jit_compiler::compileDeviceCode(InMemoryFile SourceFile,
175175
DerivedArgList DAL{UserArgList};
176176
const auto &OptTable = getDriverOptTable();
177177
DAL.AddFlagArg(nullptr, OptTable.getOption(OPT_fsycl_device_only));
178+
DAL.AddFlagArg(nullptr,
179+
OptTable.getOption(OPT_fno_sycl_dead_args_optimization));
178180
DAL.AddJoinedArg(
179181
nullptr, OptTable.getOption(OPT_resource_dir_EQ),
180182
(DPCPPRoot + "/lib/clang/" + Twine(CLANG_VERSION_MAJOR)).str());
@@ -518,5 +520,11 @@ jit_compiler::parseUserArgs(View<const char *> UserArgs) {
518520
"Runtime compilation of ESIMD kernels is not yet supported");
519521
}
520522

523+
if (AL.hasFlag(OPT_fsycl_dead_args_optimization,
524+
OPT_fno_sycl_dead_args_optimization, false)) {
525+
return createStringError(
526+
"Dead argument optimization must be disabled for runtime compilation");
527+
}
528+
521529
return std::move(AL);
522530
}

sycl/test-e2e/KernelCompiler/kernel_compiler_sycl_jit.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ auto constexpr SYCLSource = R"===(
5656
5757
// use extern "C" to avoid name mangling
5858
extern "C" SYCL_EXTERNAL SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((sycl::ext::oneapi::experimental::nd_range_kernel<1>))
59-
void ff_cp(int *ptr) {
59+
void ff_cp(int *ptr, int *unused) {
6060
6161
// intentionally using deprecated routine, as opposed to this_work_item::get_nd_item<1>()
6262
sycl::nd_item<1> Item = sycl::ext::oneapi::experimental::this_nd_item<1>();
@@ -78,6 +78,7 @@ void test_1(sycl::queue &Queue, sycl::kernel &Kernel, int seed) {
7878
memset(usmPtr, 0, Range * sizeof(int));
7979
Queue.submit([&](sycl::handler &Handler) {
8080
Handler.set_arg(0, usmPtr);
81+
Handler.set_arg(1, usmPtr);
8182
Handler.parallel_for(R1, Kernel);
8283
});
8384
Queue.wait();
@@ -181,6 +182,7 @@ int test_unsupported_options() {
181182
CheckUnsupported({"-Xarch_device", "-fsanitize=address"});
182183
CheckUnsupported({"-fsycl-device-code-split=kernel"});
183184
CheckUnsupported({"-fsycl-device-code-split-esimd"});
185+
CheckUnsupported({"-fsycl-dead-args-optimization"});
184186

185187
return 0;
186188
}

0 commit comments

Comments
 (0)