mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Add support for ze_device_memory_ext_properties_t
Related-To: LOCI-3099 Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
16047fa26b
commit
e8494abbe8
@@ -481,8 +481,10 @@ ze_result_t DeviceImp::getMemoryProperties(uint32_t *pCount, ze_device_memory_pr
|
||||
auto &hwInfo = this->getHwInfo();
|
||||
auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
|
||||
strcpy_s(pMemProperties->name, ZE_MAX_DEVICE_NAME, hwInfoConfig.getDeviceMemoryName().c_str());
|
||||
pMemProperties->maxClockRate = hwInfoConfig.getDeviceMemoryMaxClkRate(hwInfo);
|
||||
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
|
||||
pMemProperties->maxClockRate = hwInfoConfig.getDeviceMemoryMaxClkRate(hwInfo, osInterface, 0);
|
||||
pMemProperties->maxBusWidth = deviceInfo.addressBits;
|
||||
|
||||
if (this->isImplicitScalingCapable() ||
|
||||
this->getNEODevice()->getNumGenericSubDevices() == 0) {
|
||||
pMemProperties->totalSize = deviceInfo.globalMemSize;
|
||||
@@ -491,6 +493,38 @@ ze_result_t DeviceImp::getMemoryProperties(uint32_t *pCount, ze_device_memory_pr
|
||||
}
|
||||
|
||||
pMemProperties->flags = 0;
|
||||
|
||||
void *pNext = pMemProperties->pNext;
|
||||
while (pNext) {
|
||||
auto extendedProperties = reinterpret_cast<ze_device_memory_ext_properties_t *>(pMemProperties->pNext);
|
||||
if (extendedProperties->stype == ZE_STRUCTURE_TYPE_DEVICE_MEMORY_EXT_PROPERTIES) {
|
||||
|
||||
// GT_MEMORY_TYPES map to ze_device_memory_ext_type_t
|
||||
const std::array<ze_device_memory_ext_type_t, 5> sysInfoMemType = {
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR4,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR5,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR6,
|
||||
};
|
||||
|
||||
extendedProperties->type = sysInfoMemType[hwInfo.gtSystemInfo.MemoryType];
|
||||
|
||||
uint32_t enabledSubDeviceCount = 1;
|
||||
if (this->isImplicitScalingCapable()) {
|
||||
enabledSubDeviceCount = static_cast<uint32_t>(neoDevice->getDeviceBitfield().count());
|
||||
}
|
||||
extendedProperties->physicalSize = hwInfoConfig.getDeviceMemoryPhysicalSizeInBytes(osInterface, 0) * enabledSubDeviceCount;
|
||||
const uint64_t bandwidthInBytesPerSecond = hwInfoConfig.getDeviceMemoryMaxBandWidthInBytesPerSecond(hwInfo, osInterface, 0) * enabledSubDeviceCount;
|
||||
|
||||
// Convert to nano-seconds range
|
||||
extendedProperties->readBandwidth = static_cast<uint32_t>(bandwidthInBytesPerSecond * 1e-9);
|
||||
extendedProperties->writeBandwidth = extendedProperties->readBandwidth;
|
||||
extendedProperties->bandwidthUnit = ZE_BANDWIDTH_UNIT_BYTES_PER_NANOSEC;
|
||||
}
|
||||
pNext = const_cast<void *>(extendedProperties->pNext);
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/device/root_device.h"
|
||||
#include "shared/source/helpers/bindless_heaps_helper.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/preamble.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
@@ -1546,15 +1547,63 @@ TEST_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesWithNonNullPtrThenPro
|
||||
res = device->getMemoryProperties(&count, &memProperties);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(1u, count);
|
||||
|
||||
auto hwInfo = *NEO::defaultHwInfo;
|
||||
auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
|
||||
EXPECT_EQ(memProperties.maxClockRate, hwInfoConfig.getDeviceMemoryMaxClkRate(hwInfo));
|
||||
EXPECT_EQ(memProperties.maxClockRate, hwInfoConfig.getDeviceMemoryMaxClkRate(hwInfo, nullptr, 0));
|
||||
EXPECT_EQ(memProperties.maxBusWidth, this->neoDevice->getDeviceInfo().addressBits);
|
||||
EXPECT_EQ(memProperties.totalSize, this->neoDevice->getDeviceInfo().globalMemSize);
|
||||
EXPECT_EQ(0u, memProperties.flags);
|
||||
}
|
||||
|
||||
HWTEST2_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesForMemoryExtPropertiesThenPropertiesAreReturned, MatchAny) {
|
||||
uint32_t count = 0;
|
||||
ze_result_t res = device->getMemoryProperties(&count, nullptr);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(1u, count);
|
||||
|
||||
auto hwInfo = *NEO::defaultHwInfo;
|
||||
MockHwInfoConfigHw<productFamily> hwInfoConfig;
|
||||
VariableBackup<HwInfoConfig *> hwInfoConfigFactoryBackup{&NEO::hwInfoConfigFactory[static_cast<size_t>(hwInfo.platform.eProductFamily)]};
|
||||
hwInfoConfigFactoryBackup = &hwInfoConfig;
|
||||
|
||||
ze_device_memory_properties_t memProperties = {};
|
||||
ze_device_memory_ext_properties_t memExtProperties = {};
|
||||
memExtProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_MEMORY_EXT_PROPERTIES;
|
||||
memProperties.pNext = &memExtProperties;
|
||||
res = device->getMemoryProperties(&count, &memProperties);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(1u, count);
|
||||
const std::array<ze_device_memory_ext_type_t, 5> sysInfoMemType = {
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR4,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR5,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR6,
|
||||
};
|
||||
|
||||
auto bandwidthPerNanoSecond = hwInfoConfig.getDeviceMemoryMaxBandWidthInBytesPerSecond(hwInfo, nullptr, 0) / 1000000000;
|
||||
|
||||
EXPECT_EQ(memExtProperties.type, sysInfoMemType[hwInfo.gtSystemInfo.MemoryType]);
|
||||
EXPECT_EQ(memExtProperties.physicalSize, hwInfoConfig.getDeviceMemoryPhysicalSizeInBytes(nullptr, 0));
|
||||
EXPECT_EQ(memExtProperties.readBandwidth, bandwidthPerNanoSecond);
|
||||
EXPECT_EQ(memExtProperties.writeBandwidth, memExtProperties.readBandwidth);
|
||||
EXPECT_EQ(memExtProperties.bandwidthUnit, ZE_BANDWIDTH_UNIT_BYTES_PER_NANOSEC);
|
||||
}
|
||||
|
||||
TEST_F(DeviceGetMemoryTests, whenCallingGetMemoryPropertiesWhenPnextIsNonNullAndStypeIsUnSupportedThenNoErrorIsReturned) {
|
||||
uint32_t count = 0;
|
||||
ze_result_t res = device->getMemoryProperties(&count, nullptr);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(1u, count);
|
||||
|
||||
ze_device_memory_properties_t memProperties = {};
|
||||
ze_device_memory_ext_properties_t memExtProperties = {};
|
||||
memExtProperties.stype = ZE_STRUCTURE_TYPE_FORCE_UINT32;
|
||||
memProperties.pNext = &memExtProperties;
|
||||
res = device->getMemoryProperties(&count, &memProperties);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
struct DeviceHasNoDoubleFp64Test : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
@@ -1885,6 +1934,42 @@ TEST_F(MultipleDevicesEnabledImplicitScalingTest, GivenImplicitScalingEnabledWhe
|
||||
EXPECT_EQ((gtSysInfo.SliceCount * numSubDevices), deviceProperties.numSlices);
|
||||
}
|
||||
|
||||
HWTEST2_F(MultipleDevicesEnabledImplicitScalingTest, GivenImplicitScalingEnabledDeviceWhenCallingGetMemoryPropertiesForMemoryExtPropertiesThenPropertiesAreReturned, MatchAny) {
|
||||
uint32_t count = 0;
|
||||
L0::Device *device = driverHandle->devices[0];
|
||||
auto hwInfo = *NEO::defaultHwInfo;
|
||||
ze_result_t res = device->getMemoryProperties(&count, nullptr);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(1u, count);
|
||||
|
||||
MockHwInfoConfigHw<productFamily> hwInfoConfig;
|
||||
VariableBackup<HwInfoConfig *> hwInfoConfigFactoryBackup{&NEO::hwInfoConfigFactory[static_cast<size_t>(hwInfo.platform.eProductFamily)]};
|
||||
hwInfoConfigFactoryBackup = &hwInfoConfig;
|
||||
|
||||
ze_device_memory_properties_t memProperties = {};
|
||||
ze_device_memory_ext_properties_t memExtProperties = {};
|
||||
memExtProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_MEMORY_EXT_PROPERTIES;
|
||||
memProperties.pNext = &memExtProperties;
|
||||
res = device->getMemoryProperties(&count, &memProperties);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(1u, count);
|
||||
const std::array<ze_device_memory_ext_type_t, 5> sysInfoMemType = {
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR4,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_LPDDR5,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_HBM2,
|
||||
ZE_DEVICE_MEMORY_EXT_TYPE_GDDR6,
|
||||
};
|
||||
|
||||
auto bandwidthPerNanoSecond = hwInfoConfig.getDeviceMemoryMaxBandWidthInBytesPerSecond(hwInfo, nullptr, 0) / 1000000000;
|
||||
|
||||
EXPECT_EQ(memExtProperties.type, sysInfoMemType[hwInfo.gtSystemInfo.MemoryType]);
|
||||
EXPECT_EQ(memExtProperties.physicalSize, hwInfoConfig.getDeviceMemoryPhysicalSizeInBytes(nullptr, 0) * numSubDevices);
|
||||
EXPECT_EQ(memExtProperties.readBandwidth, bandwidthPerNanoSecond * numSubDevices);
|
||||
EXPECT_EQ(memExtProperties.writeBandwidth, memExtProperties.readBandwidth);
|
||||
EXPECT_EQ(memExtProperties.bandwidthUnit, ZE_BANDWIDTH_UNIT_BYTES_PER_NANOSEC);
|
||||
}
|
||||
|
||||
TEST_F(MultipleDevicesTest, whenRetrievingNumberOfSubdevicesThenCorrectNumberIsReturned) {
|
||||
L0::Device *device0 = driverHandle->devices[0];
|
||||
|
||||
@@ -3300,7 +3385,7 @@ TEST_F(DeviceSimpleTests, WhenGettingKernelPropertiesThenSuccessIsReturned) {
|
||||
}
|
||||
|
||||
TEST_F(DeviceSimpleTests, WhenGettingMemoryPropertiesThenSuccessIsReturned) {
|
||||
ze_device_memory_properties_t properties;
|
||||
ze_device_memory_properties_t properties = {};
|
||||
uint32_t count = 1;
|
||||
auto result = device->getMemoryProperties(&count, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
@@ -51,22 +51,6 @@ PVCTEST_F(DeviceTestPvc, givenPvcAStepWhenCreatingMultiTileDeviceThenExpectImpli
|
||||
delete device;
|
||||
}
|
||||
|
||||
PVCTEST_F(DeviceTestPvc, whenCallingGetMemoryPropertiesWithNonNullPtrThenPropertiesAreReturned) {
|
||||
uint32_t count = 0;
|
||||
ze_result_t res = device->getMemoryProperties(&count, nullptr);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(1u, count);
|
||||
|
||||
ze_device_memory_properties_t memProperties = {};
|
||||
res = device->getMemoryProperties(&count, &memProperties);
|
||||
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(1u, count);
|
||||
|
||||
EXPECT_EQ(memProperties.maxClockRate, 3200u);
|
||||
EXPECT_EQ(memProperties.maxBusWidth, this->neoDevice->getDeviceInfo().addressBits);
|
||||
EXPECT_EQ(memProperties.totalSize, this->neoDevice->getDeviceInfo().globalMemSize);
|
||||
}
|
||||
|
||||
PVCTEST_F(DeviceTestPvc, GivenPvcWhenGettingPhysicalEuSimdWidthThenReturn16) {
|
||||
ze_device_properties_t properties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
|
||||
device->getProperties(&properties);
|
||||
|
||||
Reference in New Issue
Block a user