mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +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
@ -18,6 +18,8 @@ struct MockHwInfoConfigHw : NEO::HwInfoConfigHw<productFamily> {
|
||||
bool getUuid(Device *device, std::array<uint8_t, HwInfoConfig::uuidSize> &uuid) const override;
|
||||
uint32_t getSteppingFromHwRevId(const HardwareInfo &hwInfo) const override;
|
||||
int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) override;
|
||||
uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) override;
|
||||
uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) override;
|
||||
|
||||
bool use128MbEdram = false;
|
||||
bool enableMidThreadPreemption = false;
|
||||
|
@ -45,4 +45,14 @@ int MockHwInfoConfigHw<gfxProduct>::configureHardwareCustom(HardwareInfo *hwInfo
|
||||
featureTable->flags.ftrGpGpuMidBatchPreempt = 1;
|
||||
}
|
||||
return (failOnConfigureHardwareCustom) ? -1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
uint64_t MockHwInfoConfigHw<gfxProduct>::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) {
|
||||
return 1024u;
|
||||
}
|
||||
|
||||
template <>
|
||||
uint32_t MockHwInfoConfigHw<gfxProduct>::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) {
|
||||
return 800u;
|
||||
}
|
||||
|
@ -262,6 +262,33 @@ class DrmMock : public Drm {
|
||||
uint16_t flags;
|
||||
};
|
||||
StackVec<WaitUserFenceParams, 1> waitUserFenceParams;
|
||||
|
||||
bool storedGetDeviceMemoryMaxClockRateInMhzStatus = true;
|
||||
bool useBaseGetDeviceMemoryMaxClockRateInMhz = true;
|
||||
bool getDeviceMemoryMaxClockRateInMhz(uint32_t tileId, uint32_t &clkRate) override {
|
||||
|
||||
if (useBaseGetDeviceMemoryMaxClockRateInMhz == true) {
|
||||
return Drm::getDeviceMemoryMaxClockRateInMhz(tileId, clkRate);
|
||||
}
|
||||
|
||||
if (storedGetDeviceMemoryMaxClockRateInMhzStatus == true) {
|
||||
clkRate = 800;
|
||||
}
|
||||
return storedGetDeviceMemoryMaxClockRateInMhzStatus;
|
||||
}
|
||||
|
||||
bool storedGetDeviceMemoryPhysicalSizeInBytesStatus = true;
|
||||
bool useBaseGetDeviceMemoryPhysicalSizeInBytes = true;
|
||||
bool getDeviceMemoryPhysicalSizeInBytes(uint32_t tileId, uint64_t &physicalSize) override {
|
||||
if (useBaseGetDeviceMemoryPhysicalSizeInBytes == true) {
|
||||
return Drm::getDeviceMemoryPhysicalSizeInBytes(tileId, physicalSize);
|
||||
}
|
||||
|
||||
if (storedGetDeviceMemoryPhysicalSizeInBytesStatus == true) {
|
||||
physicalSize = 1024;
|
||||
}
|
||||
return storedGetDeviceMemoryPhysicalSizeInBytesStatus;
|
||||
}
|
||||
};
|
||||
|
||||
class DrmMockNonFailing : public DrmMock {
|
||||
|
@ -74,7 +74,17 @@ bool HwInfoConfigHw<IGFX_UNKNOWN>::overrideGfxPartitionLayoutForWsl() const {
|
||||
}
|
||||
|
||||
template <>
|
||||
uint32_t HwInfoConfigHw<IGFX_UNKNOWN>::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo) {
|
||||
uint32_t HwInfoConfigHw<IGFX_UNKNOWN>::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
uint64_t HwInfoConfigHw<IGFX_UNKNOWN>::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
uint64_t HwInfoConfigHw<IGFX_UNKNOWN>::getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,11 @@
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_os_context_linux.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@ -102,6 +104,180 @@ TEST(DrmTest, GivenInvalidPciPathWhenFrequencyIsQueriedThenReturnError) {
|
||||
EXPECT_EQ(0, maxFrequency);
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenValidSysfsNodeWhenGetDeviceMemoryMaxClockRateInMhzIsCalledThenReturnSuccess) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return 1;
|
||||
});
|
||||
|
||||
VariableBackup<decltype(SysCalls::sysCallsPread)> mockPread(&SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
const std::string testData("800");
|
||||
memcpy(buf, testData.data(), testData.length() + 1);
|
||||
return 4;
|
||||
});
|
||||
uint32_t clkRate = 0;
|
||||
EXPECT_TRUE(drm.getDeviceMemoryMaxClockRateInMhz(0, clkRate));
|
||||
EXPECT_EQ(clkRate, 800u);
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenValidSysfsNodeWhenGetDeviceMemoryPhysicalSizeInBytesIsCalledThenReturnSuccess) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return 1;
|
||||
});
|
||||
|
||||
VariableBackup<decltype(SysCalls::sysCallsPread)> mockPread(&SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
const std::string testData("800");
|
||||
memcpy(buf, testData.data(), testData.length() + 1);
|
||||
return 4;
|
||||
});
|
||||
uint64_t size = 0;
|
||||
EXPECT_TRUE(drm.getDeviceMemoryPhysicalSizeInBytes(0, size));
|
||||
EXPECT_EQ(2048u, size);
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenInValidSysfsNodeWhenGetDeviceMemoryMaxClockRateInMhzIsCalledThenReturnSuccess) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return -1;
|
||||
});
|
||||
|
||||
uint32_t clkRate = 0;
|
||||
EXPECT_FALSE(drm.getDeviceMemoryMaxClockRateInMhz(0, clkRate));
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenPciPathCouldNotBeRetrievedWhenGetDeviceMemoryPhysicalSizeInBytesIsCalledThenReturnZero) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("InvaliDdevice");
|
||||
uint64_t size = 0;
|
||||
EXPECT_FALSE(drm.getDeviceMemoryPhysicalSizeInBytes(0, size));
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenInValidSysfsNodeWhenGetDeviceMemoryPhysicalSizeInBytesIsCalledThenReturnSuccess) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return -1;
|
||||
});
|
||||
uint64_t size = 0;
|
||||
EXPECT_FALSE(drm.getDeviceMemoryPhysicalSizeInBytes(0, size));
|
||||
}
|
||||
|
||||
TEST(DrmTest, GivenSysfsNodeReadFailsWhenGetDeviceMemoryPhysicalSizeInBytesIsCalledThenReturnError) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return 1;
|
||||
});
|
||||
|
||||
VariableBackup<decltype(SysCalls::sysCallsPread)> mockPread(&SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
const std::string testData("800");
|
||||
memcpy(buf, testData.data(), testData.length() + 1);
|
||||
return 0;
|
||||
});
|
||||
uint64_t size = 0;
|
||||
EXPECT_FALSE(drm.getDeviceMemoryPhysicalSizeInBytes(0, size));
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenSysfsNodeReadFailsWithErrnoWhenGetDeviceMemoryPhysicalSizeInBytesIsCalledThenReturnError) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return 1;
|
||||
});
|
||||
|
||||
VariableBackup<decltype(SysCalls::sysCallsPread)> mockPread(&SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
const std::string testData("800");
|
||||
memcpy(buf, testData.data(), testData.length() + 1);
|
||||
errno = 1;
|
||||
return 4;
|
||||
});
|
||||
uint64_t size = 0;
|
||||
EXPECT_FALSE(drm.getDeviceMemoryPhysicalSizeInBytes(0, size));
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenSysfsNodeReadFailsWithImproperDataWhenGetDeviceMemoryPhysicalSizeInBytesIsCalledThenReturnError) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return 1;
|
||||
});
|
||||
|
||||
VariableBackup<decltype(SysCalls::sysCallsPread)> mockPread(&SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
const std::string testData("pqr");
|
||||
memcpy(buf, testData.data(), testData.length() + 1);
|
||||
return 4;
|
||||
});
|
||||
uint64_t size = 0;
|
||||
EXPECT_FALSE(drm.getDeviceMemoryPhysicalSizeInBytes(0, size));
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenSysfsNodeReadFailsWithErrnoWhenGetDeviceMemoryMaxClockRateInMhzIsCalledThenReturnError) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return 1;
|
||||
});
|
||||
|
||||
VariableBackup<decltype(SysCalls::sysCallsPread)> mockPread(&SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
const std::string testData("800");
|
||||
memcpy(buf, testData.data(), testData.length() + 1);
|
||||
errno = 1;
|
||||
return 4;
|
||||
});
|
||||
uint32_t clkRate = 0;
|
||||
EXPECT_FALSE(drm.getDeviceMemoryMaxClockRateInMhz(0, clkRate));
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenSysfsNodeReadFailsWithImproperDataWhenGetDeviceMemoryMaxClockRateInMhzIsCalledThenReturnError) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
drm.setPciPath("device");
|
||||
VariableBackup<decltype(SysCalls::sysCallsOpen)> mockOpen(&SysCalls::sysCallsOpen, [](const char *pathname, int flags) -> int {
|
||||
return 1;
|
||||
});
|
||||
|
||||
VariableBackup<decltype(SysCalls::sysCallsPread)> mockPread(&SysCalls::sysCallsPread, [](int fd, void *buf, size_t count, off_t offset) -> ssize_t {
|
||||
const std::string testData("abc");
|
||||
memcpy(buf, testData.data(), testData.length() + 1);
|
||||
return 4;
|
||||
});
|
||||
uint32_t clkRate = 0;
|
||||
EXPECT_FALSE(drm.getDeviceMemoryMaxClockRateInMhz(0, clkRate));
|
||||
}
|
||||
|
||||
TEST(DrmTest, WhenGettingRevisionIdThenCorrectIdIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
|
@ -9,7 +9,9 @@
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/test/common/fixtures/product_config_fixture.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/libult/linux/drm_mock.h"
|
||||
#include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h"
|
||||
#include "shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h"
|
||||
#include "shared/test/unit_test/helpers/gtest_helpers.h"
|
||||
#include "shared/test/unit_test/os_interface/linux/hw_info_config_linux_tests.h"
|
||||
@ -74,3 +76,32 @@ PVCTEST_F(ProductConfigTests, givenAotConfigWhenSetHwInfoRevisionIdForPvcThenCor
|
||||
EXPECT_EQ(hwInfo.platform.usRevId, aotConfig.ProductConfigID.Revision);
|
||||
}
|
||||
}
|
||||
|
||||
PVCTEST_F(HwInfoConfigTestLinuxPvc, givenOsInterfaceIsNullWhenGetDeviceMemoryPhysicalSizeInBytesIsCalledThenReturnZero) {
|
||||
auto hwInfoConfig = HwInfoConfig::get(productFamily);
|
||||
EXPECT_EQ(0u, hwInfoConfig->getDeviceMemoryPhysicalSizeInBytes(nullptr, 0));
|
||||
}
|
||||
|
||||
PVCTEST_F(HwInfoConfigTestLinuxPvc, givenOsInterfaceIsNullWhenGetDeviceMemoryMaxBandWidthInBytesPerSecondIsCalledThenReturnZero) {
|
||||
auto hwInfoConfig = HwInfoConfig::get(productFamily);
|
||||
auto testHwInfo = *defaultHwInfo;
|
||||
testHwInfo.platform.usRevId = 0x8;
|
||||
EXPECT_EQ(0u, hwInfoConfig->getDeviceMemoryMaxBandWidthInBytesPerSecond(testHwInfo, nullptr, 0));
|
||||
}
|
||||
|
||||
PVCTEST_F(HwInfoConfigTestLinuxPvc, WhenGetDeviceMemoryPhysicalSizeInBytesIsCalledThenReturnSuccess) {
|
||||
auto hwInfoConfig = HwInfoConfig::get(productFamily);
|
||||
drm->setPciPath("device");
|
||||
drm->storedGetDeviceMemoryPhysicalSizeInBytesStatus = true;
|
||||
drm->useBaseGetDeviceMemoryPhysicalSizeInBytes = false;
|
||||
EXPECT_EQ(1024u, hwInfoConfig->getDeviceMemoryPhysicalSizeInBytes(osInterface, 0));
|
||||
}
|
||||
|
||||
PVCTEST_F(HwInfoConfigTestLinuxPvc, WhenGetDeviceMemoryMaxBandWidthInBytesPerSecondIsCalledThenReturnSuccess) {
|
||||
auto hwInfoConfig = HwInfoConfig::get(productFamily);
|
||||
auto testHwInfo = *defaultHwInfo;
|
||||
testHwInfo.platform.usRevId = 0x8;
|
||||
drm->storedGetDeviceMemoryMaxClockRateInMhzStatus = true;
|
||||
drm->useBaseGetDeviceMemoryMaxClockRateInMhz = false;
|
||||
EXPECT_EQ(51200000000u, hwInfoConfig->getDeviceMemoryMaxBandWidthInBytesPerSecond(testHwInfo, osInterface, 0));
|
||||
}
|
||||
|
Reference in New Issue
Block a user