Skip to content

Commit 580bec9

Browse files
author
Fabio Mestre
committed
Add env var to enable / disable the immediate append path
1 parent 981786b commit 580bec9

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

source/adapters/level_zero/command_buffer.cpp

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,39 @@ bool checkImmediateAppendSupport(ur_context_handle_t Context,
3535
Context->getPlatform()->isDriverVersionNewerOrSimilar(1, 3,
3636
MinDriverVersion);
3737

38+
// If this environment variable is:
39+
// - Set to 1: the immediate append path will always be enabled as long the
40+
// pre-requisites are met.
41+
// - Set to 0: the immediate append path will always be disabled.
42+
// - Not Defined: The default behaviour will be used which enables the
43+
// immediate append path only for some devices when the pre-requisites are
44+
// met.
45+
const char *AppendEnvVarName = "UR_L0_CMD_BUFFER_USE_IMMEDIATE_APPEND_PATH";
46+
const char *UrRet = std::getenv(AppendEnvVarName);
47+
48+
if (UrRet) {
49+
const bool EnableAppendPath = std::atoi(UrRet) == 1;
50+
51+
if (EnableAppendPath && !Device->ImmCommandListUsed) {
52+
logger::error("{} is set but immediate command-lists are currently "
53+
"disabled. Immediate command-lists are "
54+
"required to use the immediate append path.",
55+
AppendEnvVarName);
56+
std::abort();
57+
}
58+
if (EnableAppendPath && !DriverSupportsImmediateAppend) {
59+
logger::error("{} is set but "
60+
"the current driver does not support the "
61+
"zeCommandListImmediateAppendCommandListsExp entrypoint. A "
62+
"driver version of at least {} is required to use the "
63+
"immediate append path.",
64+
AppendEnvVarName, MinDriverVersion);
65+
std::abort();
66+
}
67+
68+
return EnableAppendPath;
69+
}
70+
3871
return Device->isPVC() && Device->ImmCommandListUsed &&
3972
DriverSupportsImmediateAppend;
4073
}
@@ -1670,7 +1703,7 @@ ur_result_t validateCommandDesc(
16701703
logger::debug("Mutable features supported by device {}", SupportedFeatures);
16711704

16721705
// Kernel handle updates are not yet supported.
1673-
if (CommandDesc->hNewKernel != Command->Kernel) {
1706+
if (CommandDesc->hNewKernel && CommandDesc->hNewKernel != Command->Kernel) {
16741707
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
16751708
}
16761709

@@ -1959,11 +1992,7 @@ ur_result_t updateKernelCommand(
19591992
*/
19601993
ur_result_t
19611994
waitForOngoingExecution(ur_exp_command_buffer_handle_t CommandBuffer) {
1962-
1963-
bool UsingImmediateAppendPath = checkImmediateAppendSupport(
1964-
CommandBuffer->Context, CommandBuffer->Device);
1965-
1966-
if (UsingImmediateAppendPath) {
1995+
if (CommandBuffer->UseImmediateAppendPath) {
19671996
if (ur_event_handle_t &CurrentSubmissionEvent =
19681997
CommandBuffer->CurrentSubmissionEvent) {
19691998
ZE2UR_CALL(zeEventHostSynchronize,

0 commit comments

Comments
 (0)