Skip to content

Commit d13db51

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. Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent ef70004 commit d13db51

File tree

9 files changed

+40
-40
lines changed

9 files changed

+40
-40
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
}
@@ -592,12 +593,8 @@ ur_result_t createMainCommandList(ur_context_handle_t Context,
592593
*/
593594
bool canBeInOrder(ur_context_handle_t Context,
594595
const ur_exp_command_buffer_desc_t *CommandBufferDesc) {
595-
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_INORDER_LISTS");
596-
// In-order command-lists are not available in old driver version.
597-
bool DriverInOrderRequested = UrRet ? std::atoi(UrRet) != 0 : false;
598-
bool CompatibleDriver = Context->getPlatform()->isDriverVersionNewerOrSimilar(
599-
1, 3, L0_DRIVER_INORDER_MIN_VERSION);
600-
bool CanUseDriverInOrderLists = CompatibleDriver && DriverInOrderRequested;
596+
bool CanUseDriverInOrderLists =
597+
Context->getPlatform()->allowDriverInOrderLists();
601598
return CanUseDriverInOrderLists
602599
? (CommandBufferDesc ? CommandBufferDesc->isInOrder : false)
603600
: false;

source/adapters/level_zero/common.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,6 @@ extern thread_local int32_t ErrorAdapterNativeCode;
533533
ur_result_t ErrorCode,
534534
int32_t AdapterErrorCode);
535535

536-
#define L0_DRIVER_INORDER_MIN_VERSION 29534
537-
538536
// Definitions for the External Semaphore Extension
539537

540538
#ifndef ZE_INTEL_EXTERNAL_SEMAPHORE_EXP_NAME

source/adapters/level_zero/context.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ ur_result_t ur_context_handle_t_::initialize() {
327327

328328
ZeCommandQueueDesc.index = 0;
329329
ZeCommandQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
330-
if (Device->useDriverInOrderLists() &&
330+
if (Device->Platform->allowDriverInOrderLists() &&
331331
Device->useDriverCounterBasedEvents()) {
332332
logger::debug(
333333
"L0 Synchronous Immediate Command List needed with In Order property.");
@@ -784,8 +784,8 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
784784
for (auto ZeCommandListIt = ZeCommandListCache.begin();
785785
ZeCommandListIt != ZeCommandListCache.end(); ++ZeCommandListIt) {
786786
// If this is an InOrder Queue, then only allow lists which are in order.
787-
if (Queue->Device->useDriverInOrderLists() && Queue->isInOrderQueue() &&
788-
!(ZeCommandListIt->second.InOrderList)) {
787+
if (Queue->Device->Platform->allowDriverInOrderLists() &&
788+
Queue->isInOrderQueue() && !(ZeCommandListIt->second.InOrderList)) {
789789
continue;
790790
}
791791
// Only allow to reuse Regular Command Lists
@@ -851,8 +851,8 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
851851
continue;
852852

853853
// If this is an InOrder Queue, then only allow lists which are in order.
854-
if (Queue->Device->useDriverInOrderLists() && Queue->isInOrderQueue() &&
855-
!(it->second.IsInOrderList)) {
854+
if (Queue->Device->Platform->allowDriverInOrderLists() &&
855+
Queue->isInOrderQueue() && !(it->second.IsInOrderList)) {
856856
continue;
857857
}
858858

source/adapters/level_zero/device.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,22 +1519,6 @@ bool ur_device_handle_t_::useRelaxedAllocationLimits() {
15191519
return EnableRelaxedAllocationLimits;
15201520
}
15211521

1522-
bool ur_device_handle_t_::useDriverInOrderLists() {
1523-
// Use in-order lists implementation from L0 driver instead
1524-
// of adapter's implementation.
1525-
1526-
static const bool UseDriverInOrderLists = [&] {
1527-
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_INORDER_LISTS");
1528-
// bool CompatibleDriver = this->Platform->isDriverVersionNewerOrSimilar(
1529-
// 1, 3, L0_DRIVER_INORDER_MIN_VERSION);
1530-
if (!UrRet)
1531-
return false;
1532-
return std::atoi(UrRet) != 0;
1533-
}();
1534-
1535-
return UseDriverInOrderLists;
1536-
}
1537-
15381522
bool ur_device_handle_t_::useDriverCounterBasedEvents() {
15391523
// Use counter-based events implementation from L0 driver.
15401524

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
@@ -1468,8 +1468,8 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList(
14681468
// the native driver implementation will already ensure in-order semantics.
14691469
// The only exception is when a different immediate command was last used on
14701470
// the same UR Queue.
1471-
if (CurQueue->Device->useDriverInOrderLists() && CurQueue->isInOrderQueue() &&
1472-
CurQueue->UsingImmCmdLists) {
1471+
if (CurQueue->Device->Platform->allowDriverInOrderLists() &&
1472+
CurQueue->isInOrderQueue() && CurQueue->UsingImmCmdLists) {
14731473
auto QueueGroup = CurQueue->getQueueGroup(UseCopyEngine);
14741474
uint32_t QueueGroupOrdinal, QueueIndex;
14751475
auto NextIndex = QueueGroup.getQueueIndex(&QueueGroupOrdinal, &QueueIndex,
@@ -1498,7 +1498,7 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList(
14981498

14991499
// For in-order queue and wait-list which is empty or has events only from
15001500
// the same queue then we don't need to wait on any other additional events
1501-
if (CurQueue->Device->useDriverInOrderLists() &&
1501+
if (CurQueue->Device->Platform->allowDriverInOrderLists() &&
15021502
CurQueue->isInOrderQueue() &&
15031503
WaitListEmptyOrAllEventsFromSameQueue(CurQueue, EventListLength,
15041504
EventList)) {

source/adapters/level_zero/platform.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,23 @@ ur_result_t ur_platform_handle_t_::initialize() {
455455
return UR_RESULT_SUCCESS;
456456
}
457457

458+
bool ur_platform_handle_t_::allowDriverInOrderLists() {
459+
// Use in-order lists implementation from L0 driver instead
460+
// of adapter's implementation.
461+
462+
// The following driver version is known to be passing and only this or newer
463+
// drivers should be allowed by default for in order lists.
464+
#define L0_DRIVER_INORDER_MINOR_VERSION 6
465+
#define L0_DRIVER_INORDER_PATCH_VERSION 32149
466+
467+
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_INORDER_LISTS");
468+
bool CompatibleDriver = this->isDriverVersionNewerOrSimilar(
469+
1, L0_DRIVER_INORDER_MINOR_VERSION, L0_DRIVER_INORDER_PATCH_VERSION);
470+
bool DriverInOrderRequested = UrRet ? std::atoi(UrRet) != 0 : false;
471+
bool CanUseDriverInOrderLists = CompatibleDriver || DriverInOrderRequested;
472+
return CanUseDriverInOrderLists;
473+
}
474+
458475
/// Checks the version of the level-zero driver.
459476
/// @param VersionMajor Major verion number to compare to.
460477
/// @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
@@ -1187,11 +1187,13 @@ ur_queue_handle_t_::ur_queue_handle_t_(
11871187
CopyCommandBatch.QueueBatchSize = ZeCommandListBatchCopyConfig.startSize();
11881188

11891189
this->CounterBasedEventsEnabled =
1190-
UsingImmCmdLists && isInOrderQueue() && Device->useDriverInOrderLists() &&
1190+
UsingImmCmdLists && isInOrderQueue() &&
1191+
Device->Platform->allowDriverInOrderLists() &&
11911192
Device->useDriverCounterBasedEvents() &&
11921193
Device->Platform->ZeDriverEventPoolCountingEventsExtensionFound;
11931194
this->InterruptBasedEventsEnabled =
1194-
isLowPowerEvents() && isInOrderQueue() && Device->useDriverInOrderLists();
1195+
isLowPowerEvents() && isInOrderQueue() &&
1196+
Device->Platform->allowDriverInOrderLists();
11951197
}
11961198

11971199
void ur_queue_handle_t_::adjustBatchSizeForFullBatch(bool IsCopy) {
@@ -2283,7 +2285,7 @@ ur_result_t ur_queue_handle_t_::createCommandList(
22832285
ZeCommandListDesc.commandQueueGroupOrdinal = QueueGroupOrdinal;
22842286

22852287
bool IsInOrderList = false;
2286-
if (Device->useDriverInOrderLists() && isInOrderQueue()) {
2288+
if (Device->Platform->allowDriverInOrderLists() && isInOrderQueue()) {
22872289
ZeCommandListDesc.flags = ZE_COMMAND_LIST_FLAG_IN_ORDER;
22882290
IsInOrderList = true;
22892291
}
@@ -2416,7 +2418,8 @@ ur_command_list_ptr_t &ur_queue_handle_t_::ur_queue_group_t::getImmCmdList() {
24162418
ZeCommandQueueDesc.flags |= ZE_COMMAND_QUEUE_FLAG_EXPLICIT_ONLY;
24172419
}
24182420

2419-
if (Queue->Device->useDriverInOrderLists() && Queue->isInOrderQueue()) {
2421+
if (Queue->Device->Platform->allowDriverInOrderLists() &&
2422+
Queue->isInOrderQueue()) {
24202423
isInOrderList = true;
24212424
ZeCommandQueueDesc.flags |= ZE_COMMAND_QUEUE_FLAG_IN_ORDER;
24222425
}

0 commit comments

Comments
 (0)