Skip to content

Commit f07688d

Browse files
authored
Merge pull request oneapi-src#2618 from winstonzhang-intel/max_eu_count_calculation
[L0] MAX_COMPUTE_UNITS using ze_eu_count_ext_t
2 parents 7d864b6 + 3dbf8b2 commit f07688d

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

source/adapters/level_zero/device.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,18 @@ ur_result_t urDeviceGetInfo(
873873
return ReturnValue(int32_t(ZeDeviceNumIndices));
874874
} break;
875875
case UR_DEVICE_INFO_GPU_EU_COUNT: {
876+
if (Device->Platform->ZeDriverEuCountExtensionFound) {
877+
ze_device_properties_t DeviceProp = {};
878+
DeviceProp.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
879+
ze_eu_count_ext_t EuCountDesc = {};
880+
EuCountDesc.stype = ZE_STRUCTURE_TYPE_EU_COUNT_EXT;
881+
DeviceProp.pNext = (void *)&EuCountDesc;
882+
ZE2UR_CALL(zeDeviceGetProperties, (ZeDevice, &DeviceProp));
883+
if (EuCountDesc.numTotalEUs > 0) {
884+
return ReturnValue(uint32_t{EuCountDesc.numTotalEUs});
885+
}
886+
}
887+
876888
uint32_t count = Device->ZeDeviceProperties->numEUsPerSubslice *
877889
Device->ZeDeviceProperties->numSubslicesPerSlice *
878890
Device->ZeDeviceProperties->numSlices;

source/adapters/level_zero/platform.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ ur_result_t ur_platform_handle_t_::initialize() {
270270
ZeIntelExternalSemaphoreExtensionSupported = true;
271271
}
272272
}
273+
if (strncmp(extension.name, ZE_EU_COUNT_EXT_NAME,
274+
strlen(ZE_EU_COUNT_EXT_NAME) + 1) == 0) {
275+
if (extension.version == ZE_EU_COUNT_EXT_VERSION_1_0) {
276+
ZeDriverEuCountExtensionFound = true;
277+
}
278+
}
273279
zeDriverExtensionMap[extension.name] = extension.version;
274280
}
275281

source/adapters/level_zero/platform.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct ur_platform_handle_t_ : public _ur_platform {
6161
bool ZeDriverModuleProgramExtensionFound{false};
6262
bool ZeDriverEventPoolCountingEventsExtensionFound{false};
6363
bool zeDriverImmediateCommandListAppendFound{false};
64+
bool ZeDriverEuCountExtensionFound{false};
6465

6566
// Cache UR devices for reuse
6667
std::vector<std::unique_ptr<ur_device_handle_t_>> URDevicesCache;

0 commit comments

Comments
 (0)