diff --git a/shared/source/device/device_caps.cpp b/shared/source/device/device_caps.cpp index 9cd2bcc750..103aaafcd9 100644 --- a/shared/source/device/device_caps.cpp +++ b/shared/source/device/device_caps.cpp @@ -1,10 +1,11 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/command_container/implicit_scaling.h" #include "shared/source/compiler_interface/compiler_interface.h" #include "shared/source/debugger/debugger.h" #include "shared/source/device/device.h" @@ -77,6 +78,14 @@ void Device::initializeCaps() { deviceInfo.globalMemSize = alignDown(deviceInfo.globalMemSize, MemoryConstants::pageSize); deviceInfo.maxMemAllocSize = std::min(deviceInfo.globalMemSize, deviceInfo.maxMemAllocSize); // if globalMemSize was reduced for 32b + uint32_t subDeviceCount = HwHelper::getSubDevicesCount(&getHardwareInfo()); + + if (((NEO::ImplicitScalingHelper::isImplicitScalingEnabled( + getDeviceBitfield(), true))) && + (!isSubDevice()) && (subDeviceCount > 1)) { + deviceInfo.maxMemAllocSize = deviceInfo.globalMemSize; + } + if (!areSharedSystemAllocationsAllowed()) { deviceInfo.maxMemAllocSize = ApiSpecificConfig::getReducedMaxAllocSize(deviceInfo.maxMemAllocSize); deviceInfo.maxMemAllocSize = std::min(deviceInfo.maxMemAllocSize, hwHelper.getMaxMemAllocSize()); diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index 562474c535..4811b40061 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -102,6 +102,34 @@ TEST_F(DeviceGetCapsTest, givenMockCompilerInterfaceWhenInitializeCapsIsCalledTh EXPECT_EQ(1u, pDevice->getDeviceInfo().maxParameterSize); } +TEST_F(DeviceGetCapsTest, + givenImplicitScalingWhenInitializeCapsIsCalledThenMaxMemAllocSizeIsSetCorrectly) { + DebugManagerStateRestore dbgRestorer; + + DebugManager.flags.CreateMultipleSubDevices.set(4); + pDevice->deviceBitfield = 15; + + DebugManager.flags.EnableWalkerPartition.set(1); + DebugManager.flags.EnableSharedSystemUsmSupport.set(1); + pDevice->initializeCaps(); + EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize == pDevice->getDeviceInfo().globalMemSize); + + DebugManager.flags.EnableWalkerPartition.set(0); + DebugManager.flags.EnableSharedSystemUsmSupport.set(1); + pDevice->initializeCaps(); + EXPECT_TRUE(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, givenDontForcePreemptionModeDebugVariableWhenCreateDeviceThenSetDefaultHwPreemptionMode) { DebugManagerStateRestore dbgRestorer; {