Skip to content

Commit efdfdeb

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 <jaime.a.arteaga.molina@intel.com>
1 parent 0bd60e5 commit efdfdeb

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

level_zero/core/source/device/device_imp.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,20 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
552552
std::string name = getNEODevice()->getDeviceInfo().name;
553553
memcpy_s(pDeviceProperties->name, name.length(), name.c_str(), name.length());
554554

555+
if (pDeviceProperties->pNext) {
556+
ze_base_desc_t *extendedDesc = reinterpret_cast<ze_base_desc_t *>(pDeviceProperties->pNext);
557+
if (extendedDesc->stype == ZE_STRUCTURE_TYPE_EU_COUNT_EXT) {
558+
ze_eu_count_ext_t *ze_eu_count_desc = reinterpret_cast<ze_eu_count_ext_t *>(extendedDesc);
559+
uint32_t numTotalEUs = hardwareInfo.gtSystemInfo.MaxEuPerSubSlice * hardwareInfo.gtSystemInfo.SubSliceCount * hardwareInfo.gtSystemInfo.SliceCount;
560+
561+
if (isImplicitScalingCapable()) {
562+
numTotalEUs *= neoDevice->getNumGenericSubDevices();
563+
}
564+
565+
ze_eu_count_desc->numTotalEUs = numTotalEUs;
566+
}
567+
}
568+
555569
return ZE_RESULT_SUCCESS;
556570
}
557571

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
@@ -825,6 +825,34 @@ TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDevicePropertiesCalledThenA
825825
EXPECT_NE(deviceProperties.maxMemAllocSize, devicePropertiesBefore.maxMemAllocSize);
826826
}
827827

828+
TEST_F(DeviceTest, WhenRequestingZeEuCountThenExpectedEUsAreReturned) {
829+
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
830+
ze_eu_count_ext_t ze_eu_count_desc = {ZE_STRUCTURE_TYPE_EU_COUNT_EXT};
831+
deviceProperties.pNext = &ze_eu_count_desc;
832+
833+
uint32_t maxEuPerSubSlice = 48;
834+
uint32_t subSliceCount = 8;
835+
uint32_t sliceCount = 1;
836+
837+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.MaxEuPerSubSlice = maxEuPerSubSlice;
838+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.SubSliceCount = subSliceCount;
839+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.SliceCount = sliceCount;
840+
841+
device->getProperties(&deviceProperties);
842+
843+
uint32_t expectedEUs = maxEuPerSubSlice * subSliceCount * sliceCount;
844+
845+
EXPECT_EQ(expectedEUs, ze_eu_count_desc.numTotalEUs);
846+
}
847+
848+
TEST_F(DeviceTest, WhenRequestingZeEuCountWithIncorrectStypeThenPNextIsIgnored) {
849+
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
850+
ze_eu_count_ext_t ze_eu_count_desc = {ZE_STRUCTURE_TYPE_SCHEDULING_HINT_EXP_PROPERTIES};
851+
deviceProperties.pNext = &ze_eu_count_desc;
852+
device->getProperties(&deviceProperties);
853+
EXPECT_EQ(0u, ze_eu_count_desc.numTotalEUs);
854+
}
855+
828856
TEST_F(DeviceTest, WhenGettingDevicePropertiesThenSubslicesPerSliceIsBasedOnSubslicesSupported) {
829857
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
830858
deviceProperties.type = ZE_DEVICE_TYPE_GPU;
@@ -1499,6 +1527,27 @@ TEST_F(MultipleDevicesDisabledImplicitScalingTest, whenCallingGetMemoryPropertie
14991527
EXPECT_EQ(memProperties.totalSize, device0->getNEODevice()->getDeviceInfo().globalMemSize / numSubDevices);
15001528
}
15011529

1530+
TEST_F(MultipleDevicesEnabledImplicitScalingTest, WhenRequestingZeEuCountThenExpectedEUsAreReturned) {
1531+
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
1532+
ze_eu_count_ext_t ze_eu_count_desc = {ZE_STRUCTURE_TYPE_EU_COUNT_EXT};
1533+
deviceProperties.pNext = &ze_eu_count_desc;
1534+
1535+
uint32_t maxEuPerSubSlice = 48;
1536+
uint32_t subSliceCount = 8;
1537+
uint32_t sliceCount = 1;
1538+
1539+
L0::Device *device = driverHandle->devices[0];
1540+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.MaxEuPerSubSlice = maxEuPerSubSlice;
1541+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.SubSliceCount = subSliceCount;
1542+
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->gtSystemInfo.SliceCount = sliceCount;
1543+
1544+
device->getProperties(&deviceProperties);
1545+
1546+
uint32_t expectedEUs = maxEuPerSubSlice * subSliceCount * sliceCount;
1547+
1548+
EXPECT_EQ(expectedEUs * numSubDevices, ze_eu_count_desc.numTotalEUs);
1549+
}
1550+
15021551
TEST_F(MultipleDevicesEnabledImplicitScalingTest, whenCallingGetMemoryPropertiesWithSubDevicesThenCorrectSizeReturned) {
15031552
L0::Device *device0 = driverHandle->devices[0];
15041553
uint32_t count = 1;

0 commit comments

Comments
 (0)