Skip to content

Commit 24c18be

Browse files
Jaime ArteagaCompute-Runtime-Automation
authored andcommitted
Add ze_eu_count_t to get total number of EUs
Related-To: LOCI-2667 Signed-off-by: Jaime Arteaga <[email protected]>
1 parent 2e9925c commit 24c18be

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

level_zero/core/source/device/device_imp.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,19 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
562562
std::string name = getNEODevice()->getDeviceInfo().name;
563563
memcpy_s(pDeviceProperties->name, name.length(), name.c_str(), name.length());
564564

565+
if (pDeviceProperties->pNext) {
566+
ze_base_desc_t *extendedDesc = reinterpret_cast<ze_base_desc_t *>(pDeviceProperties->pNext);
567+
if (extendedDesc->stype == ZE_STRUCTURE_TYPE_EU_COUNT_EXT) {
568+
ze_eu_count_ext_t *ze_eu_count_desc = reinterpret_cast<ze_eu_count_ext_t *>(extendedDesc);
569+
uint32_t numTotalEUs = hardwareInfo.gtSystemInfo.MaxEuPerSubSlice * hardwareInfo.gtSystemInfo.SubSliceCount * hardwareInfo.gtSystemInfo.SliceCount;
570+
571+
if (isImplicitScalingCapable()) {
572+
numTotalEUs *= neoDevice->getNumGenericSubDevices();
573+
}
574+
ze_eu_count_desc->numTotalEUs = numTotalEUs;
575+
}
576+
}
577+
565578
return ZE_RESULT_SUCCESS;
566579
}
567580

level_zero/core/test/black_box_tests/zello_world_gpu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int main(int argc, char *argv[]) {
149149

150150
SUCCESS_OR_TERMINATE(zeContextDestroy(context));
151151

152-
std::cout << "\nZello World Results validation " << (outputValidationSuccessful ? "PASSED" : "FAILED") << "\n";
152+
std::cout << "\nZello World GPU Results validation " << (outputValidationSuccessful ? "PASSED" : "FAILED") << "\n";
153153

154154
return 0;
155155
}

level_zero/core/test/unit_tests/sources/device/test_device.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,34 @@ TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDevicePropertiesCalledThenA
966966
EXPECT_NE(deviceProperties.maxMemAllocSize, devicePropertiesBefore.maxMemAllocSize);
967967
}
968968

969+
TEST_F(DeviceTest, WhenRequestingZeEuCountThenExpectedEUsAreReturned) {
970+
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
971+
ze_eu_count_ext_t ze_eu_count_desc = {ZE_STRUCTURE_TYPE_EU_COUNT_EXT};
972+
deviceProperties.pNext = &ze_eu_count_desc;
973+
974+
uint32_t maxEuPerSubSlice = 48;
975+
uint32_t subSliceCount = 8;
976+
uint32_t sliceCount = 1;
977+
978+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.MaxEuPerSubSlice = maxEuPerSubSlice;
979+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.SubSliceCount = subSliceCount;
980+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.SliceCount = sliceCount;
981+
982+
device->getProperties(&deviceProperties);
983+
984+
uint32_t expectedEUs = maxEuPerSubSlice * subSliceCount * sliceCount;
985+
986+
EXPECT_EQ(expectedEUs, ze_eu_count_desc.numTotalEUs);
987+
}
988+
989+
TEST_F(DeviceTest, WhenRequestingZeEuCountWithIncorrectStypeThenPNextIsIgnored) {
990+
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
991+
ze_eu_count_ext_t ze_eu_count_desc = {ZE_STRUCTURE_TYPE_SCHEDULING_HINT_EXP_PROPERTIES};
992+
deviceProperties.pNext = &ze_eu_count_desc;
993+
device->getProperties(&deviceProperties);
994+
EXPECT_EQ(0u, ze_eu_count_desc.numTotalEUs);
995+
}
996+
969997
TEST_F(DeviceTest, WhenGettingDevicePropertiesThenSubslicesPerSliceIsBasedOnSubslicesSupported) {
970998
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
971999
deviceProperties.type = ZE_DEVICE_TYPE_GPU;
@@ -1640,6 +1668,27 @@ TEST_F(MultipleDevicesDisabledImplicitScalingTest, whenCallingGetMemoryPropertie
16401668
EXPECT_EQ(memProperties.totalSize, device0->getNEODevice()->getDeviceInfo().globalMemSize / numSubDevices);
16411669
}
16421670

1671+
TEST_F(MultipleDevicesEnabledImplicitScalingTest, WhenRequestingZeEuCountThenExpectedEUsAreReturned) {
1672+
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
1673+
ze_eu_count_ext_t ze_eu_count_desc = {ZE_STRUCTURE_TYPE_EU_COUNT_EXT};
1674+
deviceProperties.pNext = &ze_eu_count_desc;
1675+
1676+
uint32_t maxEuPerSubSlice = 48;
1677+
uint32_t subSliceCount = 8;
1678+
uint32_t sliceCount = 1;
1679+
1680+
L0::Device *device = driverHandle->devices[0];
1681+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.MaxEuPerSubSlice = maxEuPerSubSlice;
1682+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.SubSliceCount = subSliceCount;
1683+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.SliceCount = sliceCount;
1684+
1685+
device->getProperties(&deviceProperties);
1686+
1687+
uint32_t expectedEUs = maxEuPerSubSlice * subSliceCount * sliceCount;
1688+
1689+
EXPECT_EQ(expectedEUs * numSubDevices, ze_eu_count_desc.numTotalEUs);
1690+
}
1691+
16431692
TEST_F(MultipleDevicesEnabledImplicitScalingTest, whenCallingGetMemoryPropertiesWithSubDevicesThenCorrectSizeReturned) {
16441693
L0::Device *device0 = driverHandle->devices[0];
16451694
uint32_t count = 1;

0 commit comments

Comments
 (0)