fix: correct maxMemAllocSize

Resolves: NEO-11857

Signed-off-by: Damian Tomczak <damian.tomczak@intel.com>
This commit is contained in:
Damian Tomczak
2024-09-08 10:38:15 +00:00
committed by Compute-Runtime-Automation
parent 6e1b882e04
commit 41e24635e3
5 changed files with 64 additions and 50 deletions

View File

@@ -7,6 +7,7 @@
#include "shared/source/command_container/implicit_scaling.h" #include "shared/source/command_container/implicit_scaling.h"
#include "shared/source/command_stream/wait_status.h" #include "shared/source/command_stream/wait_status.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/bit_helpers.h" #include "shared/source/helpers/bit_helpers.h"
#include "shared/source/helpers/compiler_product_helper.h" #include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/gfx_core_helper.h"
@@ -1429,12 +1430,18 @@ TEST_F(DeviceTest, givenCallToDevicePropertiesThenMaximumMemoryToBeAllocatedIsCo
device->getProperties(&deviceProperties); device->getProperties(&deviceProperties);
EXPECT_EQ(deviceProperties.maxMemAllocSize, this->neoDevice->getDeviceInfo().maxMemAllocSize); EXPECT_EQ(deviceProperties.maxMemAllocSize, this->neoDevice->getDeviceInfo().maxMemAllocSize);
auto &gfxCoreHelper = neoDevice->getGfxCoreHelper();
auto expectedSize = this->neoDevice->getDeviceInfo().globalMemSize; auto expectedSize = this->neoDevice->getDeviceInfo().globalMemSize;
if (!this->neoDevice->areSharedSystemAllocationsAllowed()) {
expectedSize = std::min(expectedSize, gfxCoreHelper.getMaxMemAllocSize()); auto &rootDeviceEnvironment = this->neoDevice->getRootDeviceEnvironment();
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<NEO::GfxCoreHelper>();
if (compilerProductHelper.isForceToStatelessRequired()) {
EXPECT_EQ(deviceProperties.maxMemAllocSize, expectedSize);
} else {
EXPECT_EQ(deviceProperties.maxMemAllocSize,
std::min(ApiSpecificConfig::getReducedMaxAllocSize(expectedSize), gfxCoreHelper.getMaxMemAllocSize()));
} }
EXPECT_EQ(deviceProperties.maxMemAllocSize, expectedSize);
} }
TEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescOrdinalProperlySet) { TEST_F(DeviceTest, givenNodeOrdinalFlagWhenCallAdjustCommandQueueDescThenDescOrdinalProperlySet) {

View File

@@ -7,6 +7,7 @@
#include "shared/source/built_ins/sip.h" #include "shared/source/built_ins/sip.h"
#include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/helpers/file_io.h" #include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/string.h" #include "shared/source/helpers/string.h"
@@ -2615,9 +2616,12 @@ TEST_F(MemoryRelaxedSizeTests,
TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests,
givenCallToDeviceAllocWithLargerThanAllowedSizeAndRelaxedFlagThenAllocationIsMade) { givenCallToDeviceAllocWithLargerThanAllowedSizeAndRelaxedFlagThenAllocationIsMade) {
if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef();
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
if (compilerProductHelper.isForceToStatelessRequired()) {
GTEST_SKIP(); GTEST_SKIP();
} }
size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1;
size_t alignment = 1u; size_t alignment = 1u;
void *ptr = nullptr; void *ptr = nullptr;
@@ -2640,9 +2644,12 @@ TEST_F(MemoryRelaxedSizeTests,
TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests,
givenCallToDeviceAllocWithLargerThanAllowedSizeAndDebugFlagThenAllocationIsMade) { givenCallToDeviceAllocWithLargerThanAllowedSizeAndDebugFlagThenAllocationIsMade) {
if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef();
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
if (compilerProductHelper.isForceToStatelessRequired()) {
GTEST_SKIP(); GTEST_SKIP();
} }
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
debugManager.flags.AllowUnrestrictedSize.set(1); debugManager.flags.AllowUnrestrictedSize.set(1);
size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1;
@@ -2663,6 +2670,12 @@ TEST_F(MemoryRelaxedSizeTests,
TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests,
givenCallToDeviceAllocWithLargerThanGlobalMemSizeAndRelaxedFlagThenAllocationIsNotMade) { givenCallToDeviceAllocWithLargerThanGlobalMemSizeAndRelaxedFlagThenAllocationIsNotMade) {
auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef();
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
if (compilerProductHelper.isForceToStatelessRequired()) {
GTEST_SKIP();
}
size_t size = device->getNEODevice()->getDeviceInfo().globalMemSize + 1; size_t size = device->getNEODevice()->getDeviceInfo().globalMemSize + 1;
size_t alignment = 1u; size_t alignment = 1u;
void *ptr = nullptr; void *ptr = nullptr;
@@ -2854,9 +2867,12 @@ TEST_F(MemoryRelaxedSizeTests,
TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests,
givenCallToSharedAllocWithLargerThanAllowedSizeAndRelaxedFlagThenAllocationIsMade) { givenCallToSharedAllocWithLargerThanAllowedSizeAndRelaxedFlagThenAllocationIsMade) {
if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef();
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
if (compilerProductHelper.isForceToStatelessRequired()) {
GTEST_SKIP(); GTEST_SKIP();
} }
size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1;
size_t alignment = 1u; size_t alignment = 1u;
void *ptr = nullptr; void *ptr = nullptr;
@@ -2881,9 +2897,12 @@ TEST_F(MemoryRelaxedSizeTests,
TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests,
givenCallToSharedAllocWithLargerThanAllowedSizeAndDebugFlagThenAllocationIsMade) { givenCallToSharedAllocWithLargerThanAllowedSizeAndDebugFlagThenAllocationIsMade) {
if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef();
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
if (compilerProductHelper.isForceToStatelessRequired()) {
GTEST_SKIP(); GTEST_SKIP();
} }
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
debugManager.flags.AllowUnrestrictedSize.set(1); debugManager.flags.AllowUnrestrictedSize.set(1);
size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1;
@@ -6141,19 +6160,21 @@ HWTEST2_F(MultipleDevicePeerImageTest,
} }
TEST_F(MemoryRelaxedSizeTests, givenMultipleExtensionsPassedToCreateSharedMemThenAllExtensionsAreParsed) { TEST_F(MemoryRelaxedSizeTests, givenMultipleExtensionsPassedToCreateSharedMemThenAllExtensionsAreParsed) {
if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef();
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
if (compilerProductHelper.isForceToStatelessRequired()) {
GTEST_SKIP(); GTEST_SKIP();
} }
auto mockProductHelper = std::make_unique<MockProductHelper>(); auto mockProductHelper = std::make_unique<MockProductHelper>();
mockProductHelper->is48bResourceNeededForRayTracingResult = true; mockProductHelper->is48bResourceNeededForRayTracingResult = true;
std::unique_ptr<ProductHelper> productHelper = std::move(mockProductHelper); std::unique_ptr<ProductHelper> productHelper = std::move(mockProductHelper);
auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef();
currSvmAllocsManager->validateMemoryProperties = [](const SVMAllocsManager::UnifiedMemoryProperties &memoryProperties) -> void { currSvmAllocsManager->validateMemoryProperties = [](const SVMAllocsManager::UnifiedMemoryProperties &memoryProperties) -> void {
EXPECT_TRUE(memoryProperties.allocationFlags.flags.resource48Bit); EXPECT_TRUE(memoryProperties.allocationFlags.flags.resource48Bit);
}; };
std::swap(rootDeviceEnvironment.productHelper, productHelper); std::swap(rootDeviceEnvironment.productHelper, productHelper);
size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; size_t size = neoDevice->getDeviceInfo().maxMemAllocSize + 1;
size_t alignment = 1u; size_t alignment = 1u;
void *ptr = nullptr; void *ptr = nullptr;
ze_host_mem_alloc_desc_t hostDesc = {}; ze_host_mem_alloc_desc_t hostDesc = {};

View File

@@ -8,6 +8,7 @@
#include "shared/source/command_stream/command_stream_receiver.h" #include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/compiler_interface/oclc_extensions.h" #include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/aligned_memory.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/bit_helpers.h" #include "shared/source/helpers/bit_helpers.h"
#include "shared/source/helpers/compiler_product_helper.h" #include "shared/source/helpers/compiler_product_helper.h"
@@ -200,9 +201,12 @@ TEST_F(DeviceGetCapsTest, WhenCreatingDeviceThenCapsArePopulatedCorrectly) {
EXPECT_LE(sharedCaps.maxReadImageArgs * sizeof(cl_mem), sharedCaps.maxParameterSize); EXPECT_LE(sharedCaps.maxReadImageArgs * sizeof(cl_mem), sharedCaps.maxParameterSize);
EXPECT_LE(sharedCaps.maxWriteImageArgs * sizeof(cl_mem), sharedCaps.maxParameterSize); EXPECT_LE(sharedCaps.maxWriteImageArgs * sizeof(cl_mem), sharedCaps.maxParameterSize);
EXPECT_LE(128u * MemoryConstants::megaByte, sharedCaps.maxMemAllocSize); EXPECT_LE(128u * MemoryConstants::megaByte, sharedCaps.maxMemAllocSize);
if (!device->areSharedSystemAllocationsAllowed()) { const auto &compilerProductHelper = device->getRootDeviceEnvironment().getHelper<NEO::CompilerProductHelper>();
if (!compilerProductHelper.isForceToStatelessRequired()) {
EXPECT_GE((4 * MemoryConstants::gigaByte) - (8 * MemoryConstants::kiloByte), sharedCaps.maxMemAllocSize); EXPECT_GE((4 * MemoryConstants::gigaByte) - (8 * MemoryConstants::kiloByte), sharedCaps.maxMemAllocSize);
} }
EXPECT_LE(65536u, sharedCaps.imageMaxBufferSize); EXPECT_LE(65536u, sharedCaps.imageMaxBufferSize);
EXPECT_GT(sharedCaps.maxWorkGroupSize, 0u); EXPECT_GT(sharedCaps.maxWorkGroupSize, 0u);
@@ -463,27 +467,23 @@ TEST_F(DeviceGetCapsTest, givenDeviceCapsWhenLocalMemoryIsEnabledThenCalculateGl
EXPECT_EQ(sharedCaps.globalMemSize, expectedSize); EXPECT_EQ(sharedCaps.globalMemSize, expectedSize);
} }
HWTEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationsNotSupportedWhenCalculatingMaxAllocSizeThenAdjustToHWCap) { HWTEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndStatelessNotSupportedWhenCalculatingMaxAllocSizeThenAdjustToHWCap) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
debugManager.flags.EnableSharedSystemUsmSupport.set(0);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get())); auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getSharedDeviceInfo(); auto &rootDeviceEnvironment = device->getRootDeviceEnvironment();
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
if (compilerProductHelper.isForceToStatelessRequired()) {
GTEST_SKIP();
}
const auto &caps = device->getSharedDeviceInfo();
uint64_t expectedSize = std::max(caps.globalMemSize, static_cast<uint64_t>(128ULL * MemoryConstants::megaByte));
expectedSize = std::min(ApiSpecificConfig::getReducedMaxAllocSize(expectedSize), device->getGfxCoreHelper().getMaxMemAllocSize());
uint64_t expectedSize = std::max((caps.globalMemSize / 2), static_cast<uint64_t>(128ULL * MemoryConstants::megaByte));
auto &gfxCoreHelper = device->getGfxCoreHelper();
expectedSize = std::min(expectedSize, gfxCoreHelper.getMaxMemAllocSize());
EXPECT_EQ(caps.maxMemAllocSize, expectedSize); EXPECT_EQ(caps.maxMemAllocSize, expectedSize);
} }
TEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationsSupportedWhenCalculatingMaxAllocSizeThenEqualsToGlobalMemSize) {
DebugManagerStateRestore dbgRestorer;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getSharedDeviceInfo();
EXPECT_EQ(caps.maxMemAllocSize, caps.globalMemSize);
}
TEST_F(DeviceGetCapsTest, WhenDeviceIsCreatedThenExtensionsStringEndsWithSpace) { TEST_F(DeviceGetCapsTest, WhenDeviceIsCreatedThenExtensionsStringEndsWithSpace) {
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get())); auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();

View File

@@ -15,6 +15,7 @@
#include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/aligned_memory.h"
#include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/hw_info_helper.h" #include "shared/source/helpers/hw_info_helper.h"
@@ -83,14 +84,13 @@ void Device::initializeCaps() {
uint32_t subDeviceCount = gfxCoreHelper.getSubDevicesCount(&getHardwareInfo()); uint32_t subDeviceCount = gfxCoreHelper.getSubDevicesCount(&getHardwareInfo());
auto &rootDeviceEnvironment = this->getRootDeviceEnvironment(); auto &rootDeviceEnvironment = this->getRootDeviceEnvironment();
bool platformImplicitScaling = gfxCoreHelper.platformSupportsImplicitScaling(rootDeviceEnvironment); bool platformImplicitScaling = gfxCoreHelper.platformSupportsImplicitScaling(rootDeviceEnvironment);
const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<NEO::CompilerProductHelper>();
if (((NEO::ImplicitScalingHelper::isImplicitScalingEnabled( if ((NEO::ImplicitScalingHelper::isImplicitScalingEnabled(
getDeviceBitfield(), platformImplicitScaling))) && getDeviceBitfield(), platformImplicitScaling)) &&
(!isSubDevice()) && (subDeviceCount > 1)) { (!isSubDevice()) && (subDeviceCount > 1)) {
deviceInfo.maxMemAllocSize = deviceInfo.globalMemSize; deviceInfo.maxMemAllocSize = deviceInfo.globalMemSize;
} } else if (!compilerProductHelper.isForceToStatelessRequired()) {
if (!areSharedSystemAllocationsAllowed()) {
deviceInfo.maxMemAllocSize = ApiSpecificConfig::getReducedMaxAllocSize(deviceInfo.maxMemAllocSize); deviceInfo.maxMemAllocSize = ApiSpecificConfig::getReducedMaxAllocSize(deviceInfo.maxMemAllocSize);
deviceInfo.maxMemAllocSize = std::min(deviceInfo.maxMemAllocSize, gfxCoreHelper.getMaxMemAllocSize()); deviceInfo.maxMemAllocSize = std::min(deviceInfo.maxMemAllocSize, gfxCoreHelper.getMaxMemAllocSize());
} }

View File

@@ -353,24 +353,12 @@ TEST_F(DeviceGetCapsTest,
pDevice->deviceBitfield = 15; pDevice->deviceBitfield = 15;
debugManager.flags.EnableWalkerPartition.set(1); debugManager.flags.EnableWalkerPartition.set(1);
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
pDevice->initializeCaps(); pDevice->initializeCaps();
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize == pDevice->getDeviceInfo().globalMemSize); EXPECT_EQ(pDevice->getDeviceInfo().maxMemAllocSize, pDevice->getDeviceInfo().globalMemSize);
debugManager.flags.EnableWalkerPartition.set(0); debugManager.flags.EnableWalkerPartition.set(0);
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
pDevice->initializeCaps(); pDevice->initializeCaps();
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize <= pDevice->getDeviceInfo().globalMemSize); EXPECT_LE(pDevice->getDeviceInfo().maxMemAllocSize, pDevice->getDeviceInfo().globalMemSize);
debugManager.flags.EnableWalkerPartition.set(1);
debugManager.flags.EnableSharedSystemUsmSupport.set(0);
pDevice->initializeCaps();
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize < pDevice->getDeviceInfo().globalMemSize);
debugManager.flags.EnableWalkerPartition.set(0);
debugManager.flags.EnableSharedSystemUsmSupport.set(0);
pDevice->initializeCaps();
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize < pDevice->getDeviceInfo().globalMemSize);
} }
TEST_F(DeviceGetCapsTest, TEST_F(DeviceGetCapsTest,
@@ -382,9 +370,8 @@ TEST_F(DeviceGetCapsTest,
debugManager.flags.EnableImplicitScaling.set(1); debugManager.flags.EnableImplicitScaling.set(1);
debugManager.flags.EnableWalkerPartition.set(1); debugManager.flags.EnableWalkerPartition.set(1);
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
pDevice->initializeCaps(); pDevice->initializeCaps();
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize == pDevice->getDeviceInfo().globalMemSize); EXPECT_EQ(pDevice->getDeviceInfo().maxMemAllocSize, pDevice->getDeviceInfo().globalMemSize);
} }
TEST_F(DeviceGetCapsTest, TEST_F(DeviceGetCapsTest,
@@ -396,9 +383,8 @@ TEST_F(DeviceGetCapsTest,
debugManager.flags.EnableImplicitScaling.set(0); debugManager.flags.EnableImplicitScaling.set(0);
debugManager.flags.EnableWalkerPartition.set(1); debugManager.flags.EnableWalkerPartition.set(1);
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
pDevice->initializeCaps(); pDevice->initializeCaps();
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize <= pDevice->getDeviceInfo().globalMemSize); EXPECT_LE(pDevice->getDeviceInfo().maxMemAllocSize, pDevice->getDeviceInfo().globalMemSize);
} }
TEST_F(DeviceGetCapsTest, givenDontForcePreemptionModeDebugVariableWhenCreateDeviceThenSetDefaultHwPreemptionMode) { TEST_F(DeviceGetCapsTest, givenDontForcePreemptionModeDebugVariableWhenCreateDeviceThenSetDefaultHwPreemptionMode) {