Fix calculating maxMemAllocSize

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2021-07-13 16:01:30 +00:00
committed by Compute-Runtime-Automation
parent f293b409ff
commit 42c5f2235b
7 changed files with 55 additions and 15 deletions

View File

@@ -503,8 +503,8 @@ TEST_F(DeviceGetCapsTest, givenDeviceCapsWhenLocalMemoryIsEnabledThenCalculateGl
TEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationsNotSupportedWhenCalculatingMaxAllocSizeThenAdjustToHWCap) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableSharedSystemUsmSupport.set(0);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getDeviceInfo();
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getSharedDeviceInfo();
HardwareCapabilities hwCaps = {0};
auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
@@ -515,18 +515,13 @@ TEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationsNotSupport
EXPECT_EQ(caps.maxMemAllocSize, expectedSize);
}
TEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationsSupportedWhenCalculatingMaxAllocSizeThenAdjustToGlobalMemSize) {
TEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationsSupportedWhenCalculatingMaxAllocSizeThenEqualsToGlobalMemSize) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableSharedSystemUsmSupport.set(1);
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getDeviceInfo();
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getSharedDeviceInfo();
HardwareCapabilities hwCaps = {0};
auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
hwHelper.setupHardwareCapabilities(&hwCaps, *defaultHwInfo);
uint64_t expectedSize = std::max((caps.globalMemSize / 2), static_cast<uint64_t>(128ULL * MemoryConstants::megaByte));
EXPECT_EQ(caps.maxMemAllocSize, expectedSize);
EXPECT_EQ(caps.maxMemAllocSize, caps.globalMemSize);
}
TEST_F(DeviceGetCapsTest, whenDriverModelHasLimitationForMaxMemoryAllocationSizeThenTakeItIntoAccount) {
@@ -1732,3 +1727,23 @@ HWTEST_F(DeviceGetCapsTest, givenDSSCountEqualZeroWhenDeviceCreatedThenMaxEuPerD
EXPECT_EQ(device->sharedDeviceInfo.maxNumEUsPerSubSlice, device->sharedDeviceInfo.maxNumEUsPerDualSubSlice);
}
TEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationSupportWhenReduceMaxMemAllocSizeThenValidValueIsSet) {
HardwareCapabilities hwCaps = {0};
auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
hwHelper.setupHardwareCapabilities(&hwCaps, *defaultHwInfo);
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.EnableSharedSystemUsmSupport.set(0);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
auto globalMemSize = device->getSharedDeviceInfo().globalMemSize;
device->getDevice().reduceMaxMemAllocSize();
auto expectedSize = std::min(globalMemSize / 2, hwCaps.maxMemAllocSize);
expectedSize = std::max(expectedSize, static_cast<uint64_t>(128llu * MB));
EXPECT_EQ(device->getSharedDeviceInfo().maxMemAllocSize, expectedSize);
DebugManager.flags.EnableSharedSystemUsmSupport.set(1);
device.reset(new MockClDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get())));
device->getDevice().reduceMaxMemAllocSize();
EXPECT_EQ(device->getSharedDeviceInfo().maxMemAllocSize, globalMemSize);
}