Skip to content

Commit 0cc0ddb

Browse files
committed
[SYCL] Add temporary flag for PI link
The previous commit adds new logic to the Level Zero implementation of `piProgramLink`, but this logic is only used currently if the SYCL application explicitly calls `sycl::link`. When an application merely executes a kernel, the SYCL runtime generally calls `piProgramBuild` instead of `piProgramCompile` / `piProgramLink`. In order to enable wider testing of the new `piProgramLink` logic, this commit adds a temporary environment variable which forces the SYCL runtime to build all programs by calling `piProgramCompile` / `piProgramLink`. This is usually safe, though there are a few cases where it is unsafe and results in false errors. Therefore, use this environment variable with caution. Usage is like: ``` SYCL_FORCE_LINK=[0|1] ``` When running tests with `llvm-lit`, you can set this environment variable by passing `--param extra_environment=SYCL_FORCE_LINK=1`: ``` $ llvm-lit --param extra_environment=SYCL_FORCE_LINK=1 \ --param sycl_be=level_zero --param target_devices=gpu \ -j12 -v -s <test> ``` Here are the known cases when specifying `SYCL_FORCE_LINK=1` results in a false error: * Tests using AOT (ahead-of-time compilation) generally fail because a `pi_program` that is created from native code cannot be compiled with `piProgramCompile`. * Some tests enable tracing with `SYCL_PI_TRACE` and explicitly check for a call to `piProgramBuild`. These tests fail because the runtime calls `piProgramCompile` / `piProgramLink` instead of calling `piProgramBuild`.
1 parent ec5890b commit 0cc0ddb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,8 +963,11 @@ ProgramManager::ProgramPtr ProgramManager::build(
963963
DeviceLibReqMask);
964964
}
965965

966+
static const char *ForceLinkEnv = std::getenv("SYCL_FORCE_LINK");
967+
static bool ForceLink = ForceLinkEnv && (*ForceLinkEnv == '1');
968+
966969
const detail::plugin &Plugin = Context->getPlugin();
967-
if (LinkPrograms.empty()) {
970+
if (LinkPrograms.empty() && !ForceLink) {
968971
RT::PiResult Error = Plugin.call_nocheck<PiApiKind::piProgramBuild>(
969972
Program.get(), /*num devices =*/1, &Device, CompileOptions.c_str(),
970973
nullptr, nullptr);

0 commit comments

Comments
 (0)