Skip to content

[UR] Fix correct usage of In Order sync list given counting events #2430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions source/adapters/level_zero/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,16 @@ ur_result_t ur_context_handle_t_::initialize() {

ZeCommandQueueDesc.index = 0;
ZeCommandQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
if (Device->useDriverInOrderLists() &&
Device->useDriverCounterBasedEvents()) {
logger::debug(
"L0 Synchronous Immediate Command List needed with In Order property.");
ZeCommandQueueDesc.flags |= ZE_COMMAND_LIST_FLAG_IN_ORDER;
}
ZE2UR_CALL(
zeCommandListCreateImmediate,
(ZeContext, Device->ZeDevice, &ZeCommandQueueDesc, &ZeCommandListInit));

return UR_RESULT_SUCCESS;
}

Expand Down
14 changes: 14 additions & 0 deletions source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,20 @@ bool ur_device_handle_t_::useDriverInOrderLists() {
return UseDriverInOrderLists;
}

bool ur_device_handle_t_::useDriverCounterBasedEvents() {
// Use counter-based events implementation from L0 driver.

static const bool DriverCounterBasedEventsEnabled = [] {
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_COUNTER_BASED_EVENTS");
if (!UrRet) {
return true;
}
return std::atoi(UrRet) != 0;
}();

return DriverCounterBasedEventsEnabled;
}

ur_result_t ur_device_handle_t_::initialize(int SubSubDeviceOrdinal,
int SubSubDeviceIndex) {
// Maintain various device properties cache.
Expand Down
3 changes: 3 additions & 0 deletions source/adapters/level_zero/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ struct ur_device_handle_t_ : _ur_object {
// Whether Adapter uses driver's implementation of in-order lists or not
bool useDriverInOrderLists();

// Whether Adapter uses driver's implementation of counter-based events or not
bool useDriverCounterBasedEvents();

// Returns whether immediate command lists are used on this device.
ImmCmdlistMode ImmCommandListUsed{};

Expand Down
9 changes: 1 addition & 8 deletions source/adapters/level_zero/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,16 +1186,9 @@ ur_queue_handle_t_::ur_queue_handle_t_(
ZeCommandListBatchComputeConfig.startSize();
CopyCommandBatch.QueueBatchSize = ZeCommandListBatchCopyConfig.startSize();

static const bool useDriverCounterBasedEvents = [] {
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_COUNTER_BASED_EVENTS");
if (!UrRet) {
return true;
}
return std::atoi(UrRet) != 0;
}();
this->CounterBasedEventsEnabled =
UsingImmCmdLists && isInOrderQueue() && Device->useDriverInOrderLists() &&
useDriverCounterBasedEvents &&
Device->useDriverCounterBasedEvents() &&
Device->Platform->ZeDriverEventPoolCountingEventsExtensionFound;
this->InterruptBasedEventsEnabled =
isLowPowerEvents() && isInOrderQueue() && Device->useDriverInOrderLists();
Expand Down
Loading