Skip to content

Commit e9ca018

Browse files
committed
[L0] Updated Driver In order lists check and required version
- Cleaned up the checks for driver in order lists and migrated the check to platform. - Updated version needed to match version with fixes. - Fixed sync Immediate command List in order flag type. Signed-off-by: Neil R. Spruit <[email protected]>
1 parent 6cd6446 commit e9ca018

File tree

9 files changed

+45
-41
lines changed

9 files changed

+45
-41
lines changed

source/adapters/level_zero/command_buffer.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ bool checkCounterBasedEventsSupport(ur_device_handle_t Device) {
7575
return std::atoi(UrRet) != 0;
7676
}();
7777

78-
return Device->ImmCommandListUsed && Device->useDriverInOrderLists() &&
78+
return Device->ImmCommandListUsed &&
79+
Device->Platform->allowDriverInOrderLists() &&
7980
useDriverCounterBasedEvents &&
8081
Device->Platform->ZeDriverEventPoolCountingEventsExtensionFound;
8182
}
@@ -580,12 +581,8 @@ ur_result_t createMainCommandList(ur_context_handle_t Context,
580581
*/
581582
bool canBeInOrder(ur_context_handle_t Context,
582583
const ur_exp_command_buffer_desc_t *CommandBufferDesc) {
583-
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_INORDER_LISTS");
584-
// In-order command-lists are not available in old driver version.
585-
bool DriverInOrderRequested = UrRet ? std::atoi(UrRet) != 0 : false;
586-
bool CompatibleDriver = Context->getPlatform()->isDriverVersionNewerOrSimilar(
587-
1, 3, L0_DRIVER_INORDER_MIN_VERSION);
588-
bool CanUseDriverInOrderLists = CompatibleDriver && DriverInOrderRequested;
584+
bool CanUseDriverInOrderLists =
585+
Context->getPlatform()->allowDriverInOrderLists();
589586
return CanUseDriverInOrderLists
590587
? (CommandBufferDesc ? CommandBufferDesc->isInOrder : false)
591588
: false;

source/adapters/level_zero/common.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,6 @@ extern thread_local int32_t ErrorAdapterNativeCode;
536536
ur_result_t ErrorCode,
537537
int32_t AdapterErrorCode);
538538

539-
#define L0_DRIVER_INORDER_MIN_VERSION 29534
540-
541539
// Definitions for the External Semaphore Extension
542540

543541
#ifndef ZE_INTEL_EXTERNAL_SEMAPHORE_EXP_NAME

source/adapters/level_zero/context.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,11 @@ ur_result_t ur_context_handle_t_::initialize() {
329329

330330
ZeCommandQueueDesc.index = 0;
331331
ZeCommandQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
332-
if (Device->useDriverInOrderLists() &&
332+
if (Device->Platform->allowDriverInOrderLists() &&
333333
Device->useDriverCounterBasedEvents()) {
334334
logger::debug(
335335
"L0 Synchronous Immediate Command List needed with In Order property.");
336-
ZeCommandQueueDesc.flags |= ZE_COMMAND_LIST_FLAG_IN_ORDER;
336+
ZeCommandQueueDesc.flags |= ZE_COMMAND_QUEUE_FLAG_IN_ORDER;
337337
}
338338
ZE2UR_CALL(
339339
zeCommandListCreateImmediate,
@@ -786,8 +786,8 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
786786
for (auto ZeCommandListIt = ZeCommandListCache.begin();
787787
ZeCommandListIt != ZeCommandListCache.end(); ++ZeCommandListIt) {
788788
// If this is an InOrder Queue, then only allow lists which are in order.
789-
if (Queue->Device->useDriverInOrderLists() && Queue->isInOrderQueue() &&
790-
!(ZeCommandListIt->second.InOrderList)) {
789+
if (Queue->Device->Platform->allowDriverInOrderLists() &&
790+
Queue->isInOrderQueue() && !(ZeCommandListIt->second.InOrderList)) {
791791
continue;
792792
}
793793
// Only allow to reuse Regular Command Lists
@@ -853,8 +853,8 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
853853
continue;
854854

855855
// If this is an InOrder Queue, then only allow lists which are in order.
856-
if (Queue->Device->useDriverInOrderLists() && Queue->isInOrderQueue() &&
857-
!(it->second.IsInOrderList)) {
856+
if (Queue->Device->Platform->allowDriverInOrderLists() &&
857+
Queue->isInOrderQueue() && !(it->second.IsInOrderList)) {
858858
continue;
859859
}
860860

source/adapters/level_zero/device.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,22 +1539,6 @@ bool ur_device_handle_t_::useRelaxedAllocationLimits() {
15391539
return EnableRelaxedAllocationLimits;
15401540
}
15411541

1542-
bool ur_device_handle_t_::useDriverInOrderLists() {
1543-
// Use in-order lists implementation from L0 driver instead
1544-
// of adapter's implementation.
1545-
1546-
static const bool UseDriverInOrderLists = [&] {
1547-
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_INORDER_LISTS");
1548-
// bool CompatibleDriver = this->Platform->isDriverVersionNewerOrSimilar(
1549-
// 1, 3, L0_DRIVER_INORDER_MIN_VERSION);
1550-
if (!UrRet)
1551-
return false;
1552-
return std::atoi(UrRet) != 0;
1553-
}();
1554-
1555-
return UseDriverInOrderLists;
1556-
}
1557-
15581542
bool ur_device_handle_t_::useDriverCounterBasedEvents() {
15591543
// Use counter-based events implementation from L0 driver.
15601544

source/adapters/level_zero/device.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ struct ur_device_handle_t_ : _ur_object {
156156
// Read env settings to select immediate commandlist mode.
157157
ImmCmdlistMode useImmediateCommandLists();
158158

159-
// Whether Adapter uses driver's implementation of in-order lists or not
160-
bool useDriverInOrderLists();
161-
162159
// Whether Adapter uses driver's implementation of counter-based events or not
163160
bool useDriverCounterBasedEvents();
164161

source/adapters/level_zero/event.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,8 +1484,8 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList(
14841484
// the native driver implementation will already ensure in-order semantics.
14851485
// The only exception is when a different immediate command was last used on
14861486
// the same UR Queue.
1487-
if (CurQueue->Device->useDriverInOrderLists() && CurQueue->isInOrderQueue() &&
1488-
CurQueue->UsingImmCmdLists) {
1487+
if (CurQueue->Device->Platform->allowDriverInOrderLists() &&
1488+
CurQueue->isInOrderQueue() && CurQueue->UsingImmCmdLists) {
14891489
auto QueueGroup = CurQueue->getQueueGroup(UseCopyEngine);
14901490
uint32_t QueueGroupOrdinal, QueueIndex;
14911491
auto NextIndex = QueueGroup.getQueueIndex(&QueueGroupOrdinal, &QueueIndex,
@@ -1514,7 +1514,7 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList(
15141514

15151515
// For in-order queue and wait-list which is empty or has events only from
15161516
// the same queue then we don't need to wait on any other additional events
1517-
if (CurQueue->Device->useDriverInOrderLists() &&
1517+
if (CurQueue->Device->Platform->allowDriverInOrderLists() &&
15181518
CurQueue->isInOrderQueue() &&
15191519
WaitListEmptyOrAllEventsFromSameQueue(CurQueue, EventListLength,
15201520
EventList)) {

source/adapters/level_zero/platform.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,27 @@ ur_result_t ur_platform_handle_t_::initialize() {
460460
return UR_RESULT_SUCCESS;
461461
}
462462

463+
bool ur_platform_handle_t_::allowDriverInOrderLists() {
464+
// Use in-order lists implementation from L0 driver instead
465+
// of adapter's implementation.
466+
467+
// The following driver version is known to be passing and only this or newer
468+
// drivers should be allowed by default for in order lists.
469+
#define L0_DRIVER_INORDER_MINOR_VERSION 6
470+
#define L0_DRIVER_INORDER_PATCH_VERSION 32149
471+
472+
static const bool UseDriverInOrderLists = [&] {
473+
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_INORDER_LISTS");
474+
bool CompatibleDriver = this->isDriverVersionNewerOrSimilar(
475+
1, L0_DRIVER_INORDER_MINOR_VERSION, L0_DRIVER_INORDER_PATCH_VERSION);
476+
bool DriverInOrderRequested = UrRet ? std::atoi(UrRet) != 0 : false;
477+
bool CanUseDriverInOrderLists = CompatibleDriver || DriverInOrderRequested;
478+
return CanUseDriverInOrderLists;
479+
}();
480+
481+
return UseDriverInOrderLists;
482+
}
483+
463484
/// Checks the version of the level-zero driver.
464485
/// @param VersionMajor Major verion number to compare to.
465486
/// @param VersionMinor Minor verion number to compare to.

source/adapters/level_zero/platform.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ struct ur_platform_handle_t_ : public _ur_platform {
4848
// Zero.
4949
ZeDriverVersionStringExtension ZeDriverVersionString;
5050

51+
// Helper function to check if the driver supports Driver In Order Lists or
52+
// the User has Requested this support.
53+
bool allowDriverInOrderLists();
54+
5155
// Cache versions info from zeDriverGetProperties.
5256
std::string ZeDriverVersion;
5357
std::string ZeDriverApiVersion;

source/adapters/level_zero/queue.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,11 +1192,13 @@ ur_queue_handle_t_::ur_queue_handle_t_(
11921192
CopyCommandBatch.QueueBatchSize = ZeCommandListBatchCopyConfig.startSize();
11931193

11941194
this->CounterBasedEventsEnabled =
1195-
UsingImmCmdLists && isInOrderQueue() && Device->useDriverInOrderLists() &&
1195+
UsingImmCmdLists && isInOrderQueue() &&
1196+
Device->Platform->allowDriverInOrderLists() &&
11961197
Device->useDriverCounterBasedEvents() &&
11971198
Device->Platform->ZeDriverEventPoolCountingEventsExtensionFound;
11981199
this->InterruptBasedEventsEnabled =
1199-
isLowPowerEvents() && isInOrderQueue() && Device->useDriverInOrderLists();
1200+
isLowPowerEvents() && isInOrderQueue() &&
1201+
Device->Platform->allowDriverInOrderLists();
12001202
}
12011203

12021204
void ur_queue_handle_t_::adjustBatchSizeForFullBatch(bool IsCopy) {
@@ -2288,7 +2290,7 @@ ur_result_t ur_queue_handle_t_::createCommandList(
22882290
ZeCommandListDesc.commandQueueGroupOrdinal = QueueGroupOrdinal;
22892291

22902292
bool IsInOrderList = false;
2291-
if (Device->useDriverInOrderLists() && isInOrderQueue()) {
2293+
if (Device->Platform->allowDriverInOrderLists() && isInOrderQueue()) {
22922294
ZeCommandListDesc.flags = ZE_COMMAND_LIST_FLAG_IN_ORDER;
22932295
IsInOrderList = true;
22942296
}
@@ -2425,7 +2427,8 @@ ur_command_list_ptr_t &ur_queue_handle_t_::ur_queue_group_t::getImmCmdList() {
24252427
ZeCommandQueueDesc.flags |= ZE_COMMAND_QUEUE_FLAG_EXPLICIT_ONLY;
24262428
}
24272429

2428-
if (Queue->Device->useDriverInOrderLists() && Queue->isInOrderQueue()) {
2430+
if (Queue->Device->Platform->allowDriverInOrderLists() &&
2431+
Queue->isInOrderQueue()) {
24292432
isInOrderList = true;
24302433
ZeCommandQueueDesc.flags |= ZE_COMMAND_QUEUE_FLAG_IN_ORDER;
24312434
}

0 commit comments

Comments
 (0)