Skip to content

Commit 05f0c61

Browse files
authored
Merge pull request #1768 from raiyanla/enable-in-order-default
[L0] Enable default support for L0 in-order lists
2 parents 2b77ca6 + cbd7691 commit 05f0c61

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

source/adapters/level_zero/command_buffer.cpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,6 @@ template <typename T> T *getPointerFromVector(std::vector<T> &V) {
2727
return V.size() == 0 ? nullptr : V.data();
2828
}
2929

30-
/**
31-
* Checks the version of the level-zero driver.
32-
* @param[in] Context Execution context
33-
* @param[in] VersionMajor Major version number to compare to.
34-
* @param[in] VersionMinor Minor version number to compare to.
35-
* @param[in] VersionBuild Build version number to compare to.
36-
* @return true if the version of the driver is higher than or equal to the
37-
* compared version.
38-
*/
39-
bool isDriverVersionNewerOrSimilar(ur_context_handle_t Context,
40-
uint32_t VersionMajor, uint32_t VersionMinor,
41-
uint32_t VersionBuild) {
42-
ZeStruct<ze_driver_properties_t> ZeDriverProperties;
43-
ZE2UR_CALL(zeDriverGetProperties,
44-
(Context->getPlatform()->ZeDriver, &ZeDriverProperties));
45-
uint32_t DriverVersion = ZeDriverProperties.driverVersion;
46-
auto DriverVersionMajor = (DriverVersion & 0xFF000000) >> 24;
47-
auto DriverVersionMinor = (DriverVersion & 0x00FF0000) >> 16;
48-
auto DriverVersionBuild = DriverVersion & 0x0000FFFF;
49-
50-
return ((DriverVersionMajor >= VersionMajor) &&
51-
(DriverVersionMinor >= VersionMinor) &&
52-
(DriverVersionBuild >= VersionBuild));
53-
}
54-
5530
/**
5631
* Default to using compute engine for fill operation, but allow to override
5732
* this with an environment variable. Disable the copy engine if the pattern
@@ -637,7 +612,8 @@ ur_result_t createMainCommandList(ur_context_handle_t Context,
637612
bool canBeInOrder(ur_context_handle_t Context,
638613
const ur_exp_command_buffer_desc_t *CommandBufferDesc) {
639614
// In-order command-lists are not available in old driver version.
640-
bool CompatibleDriver = isDriverVersionNewerOrSimilar(Context, 1, 3, 28454);
615+
bool CompatibleDriver = isDriverVersionNewerOrSimilar(
616+
Context->getPlatform()->ZeDriver, 1, 3, L0_DRIVER_INORDER_MIN_VERSION);
641617
return CompatibleDriver
642618
? (CommandBufferDesc ? CommandBufferDesc->isInOrder : false)
643619
: false;

source/adapters/level_zero/common.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,28 @@ ur_result_t ze2urResult(ze_result_t ZeResult) {
6767
}
6868
}
6969

70+
/// Checks the version of the level-zero driver.
71+
/// @param ZeDriver Level Zero Driver handle
72+
/// @param VersionMajor Major verion number to compare to.
73+
/// @param VersionMinor Minor verion number to compare to.
74+
/// @param VersionBuild Build verion number to compare to.
75+
/// @return true is the version of the driver is higher than or equal to the
76+
/// compared version
77+
bool isDriverVersionNewerOrSimilar(ze_driver_handle_t ZeDriver,
78+
uint32_t VersionMajor, uint32_t VersionMinor,
79+
uint32_t VersionBuild) {
80+
ZeStruct<ze_driver_properties_t> ZeDriverProperties;
81+
ZE2UR_CALL(zeDriverGetProperties, (ZeDriver, &ZeDriverProperties));
82+
uint32_t DriverVersion = ZeDriverProperties.driverVersion;
83+
auto DriverVersionMajor = (DriverVersion & 0xFF000000) >> 24;
84+
auto DriverVersionMinor = (DriverVersion & 0x00FF0000) >> 16;
85+
auto DriverVersionBuild = DriverVersion & 0x0000FFFF;
86+
87+
return ((DriverVersionMajor >= VersionMajor) &&
88+
(DriverVersionMinor >= VersionMinor) &&
89+
(DriverVersionBuild >= VersionBuild));
90+
}
91+
7092
// This function will ensure compatibility with both Linux and Windows for
7193
// setting environment variables.
7294
bool setEnvVar(const char *name, const char *value) {

source/adapters/level_zero/common.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ bool setEnvVar(const char *name, const char *value);
317317
// Map Level Zero runtime error code to UR error code.
318318
ur_result_t ze2urResult(ze_result_t ZeResult);
319319

320+
/// Checks the version of the level-zero driver.
321+
bool isDriverVersionNewerOrSimilar(ze_driver_handle_t ZeDriver,
322+
uint32_t VersionMajor, uint32_t VersionMinor,
323+
uint32_t VersionBuild);
324+
320325
// Trace a call to Level-Zero RT
321326
#define ZE2UR_CALL(ZeName, ZeArgs) \
322327
{ \
@@ -506,3 +511,5 @@ extern thread_local int32_t ErrorAdapterNativeCode;
506511
[[maybe_unused]] void setErrorMessage(const char *pMessage,
507512
ur_result_t ErrorCode,
508513
int32_t AdapterErrorCode);
514+
515+
#define L0_DRIVER_INORDER_MIN_VERSION 29534

source/adapters/level_zero/device.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,10 +1107,15 @@ bool ur_device_handle_t_::useRelaxedAllocationLimits() {
11071107
bool ur_device_handle_t_::useDriverInOrderLists() {
11081108
// Use in-order lists implementation from L0 driver instead
11091109
// of adapter's implementation.
1110-
static const bool UseDriverInOrderLists = [] {
1110+
1111+
ze_driver_handle_t ZeDriver = this->Platform->ZeDriver;
1112+
1113+
static const bool UseDriverInOrderLists = [&] {
11111114
const char *UrRet = std::getenv("UR_L0_USE_DRIVER_INORDER_LISTS");
1115+
bool CompatibleDriver = isDriverVersionNewerOrSimilar(
1116+
ZeDriver, 1, 3, L0_DRIVER_INORDER_MIN_VERSION);
11121117
if (!UrRet)
1113-
return false;
1118+
return CompatibleDriver;
11141119
return std::atoi(UrRet) != 0;
11151120
}();
11161121

0 commit comments

Comments
 (0)