Skip to content

Commit

Permalink
Merge pull request #2430 from nrspruit/fix_inorder_initList
Browse files Browse the repository at this point in the history
[UR] Fix correct usage of In Order sync list given counting events
  • Loading branch information
martygrant authored Dec 11, 2024
2 parents 8f33719 + 08acf05 commit 45f3d8a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
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

0 comments on commit 45f3d8a

Please sign in to comment.