diff --git a/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp index b7cd53bed2..652073bf25 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp @@ -7,6 +7,7 @@ #include "shared/source/command_container/implicit_scaling.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/compiler_product_helper.h" #include "shared/source/helpers/gfx_core_helper.h" @@ -1429,12 +1430,18 @@ TEST_F(DeviceTest, givenCallToDevicePropertiesThenMaximumMemoryToBeAllocatedIsCo device->getProperties(&deviceProperties); EXPECT_EQ(deviceProperties.maxMemAllocSize, this->neoDevice->getDeviceInfo().maxMemAllocSize); - auto &gfxCoreHelper = neoDevice->getGfxCoreHelper(); 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(); + auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); + + 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) { diff --git a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp index efe812998d..d85888854f 100644 --- a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp @@ -7,6 +7,7 @@ #include "shared/source/built_ins/sip.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/gfx_core_helper.h" #include "shared/source/helpers/string.h" @@ -2615,9 +2616,12 @@ TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests, givenCallToDeviceAllocWithLargerThanAllowedSizeAndRelaxedFlagThenAllocationIsMade) { - if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { + auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef(); + const auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + if (compilerProductHelper.isForceToStatelessRequired()) { GTEST_SKIP(); } + size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; size_t alignment = 1u; void *ptr = nullptr; @@ -2640,9 +2644,12 @@ TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests, givenCallToDeviceAllocWithLargerThanAllowedSizeAndDebugFlagThenAllocationIsMade) { - if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { + auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef(); + const auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + if (compilerProductHelper.isForceToStatelessRequired()) { GTEST_SKIP(); } + DebugManagerStateRestore restorer; debugManager.flags.AllowUnrestrictedSize.set(1); size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; @@ -2663,6 +2670,12 @@ TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests, givenCallToDeviceAllocWithLargerThanGlobalMemSizeAndRelaxedFlagThenAllocationIsNotMade) { + auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef(); + const auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + if (compilerProductHelper.isForceToStatelessRequired()) { + GTEST_SKIP(); + } + size_t size = device->getNEODevice()->getDeviceInfo().globalMemSize + 1; size_t alignment = 1u; void *ptr = nullptr; @@ -2854,9 +2867,12 @@ TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests, givenCallToSharedAllocWithLargerThanAllowedSizeAndRelaxedFlagThenAllocationIsMade) { - if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { + auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef(); + const auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + if (compilerProductHelper.isForceToStatelessRequired()) { GTEST_SKIP(); } + size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; size_t alignment = 1u; void *ptr = nullptr; @@ -2881,9 +2897,12 @@ TEST_F(MemoryRelaxedSizeTests, TEST_F(MemoryRelaxedSizeTests, givenCallToSharedAllocWithLargerThanAllowedSizeAndDebugFlagThenAllocationIsMade) { - if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { + auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef(); + const auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + if (compilerProductHelper.isForceToStatelessRequired()) { GTEST_SKIP(); } + DebugManagerStateRestore restorer; debugManager.flags.AllowUnrestrictedSize.set(1); size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; @@ -6141,19 +6160,21 @@ HWTEST2_F(MultipleDevicePeerImageTest, } TEST_F(MemoryRelaxedSizeTests, givenMultipleExtensionsPassedToCreateSharedMemThenAllExtensionsAreParsed) { - if (device->getNEODevice()->areSharedSystemAllocationsAllowed()) { + auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef(); + const auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + if (compilerProductHelper.isForceToStatelessRequired()) { GTEST_SKIP(); } + auto mockProductHelper = std::make_unique(); mockProductHelper->is48bResourceNeededForRayTracingResult = true; std::unique_ptr productHelper = std::move(mockProductHelper); - auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironmentRef(); currSvmAllocsManager->validateMemoryProperties = [](const SVMAllocsManager::UnifiedMemoryProperties &memoryProperties) -> void { EXPECT_TRUE(memoryProperties.allocationFlags.flags.resource48Bit); }; std::swap(rootDeviceEnvironment.productHelper, productHelper); - size_t size = device->getNEODevice()->getDeviceInfo().maxMemAllocSize + 1; + size_t size = neoDevice->getDeviceInfo().maxMemAllocSize + 1; size_t alignment = 1u; void *ptr = nullptr; ze_host_mem_alloc_desc_t hostDesc = {}; diff --git a/opencl/test/unit_test/device/device_caps_tests.cpp b/opencl/test/unit_test/device/device_caps_tests.cpp index 44299050cc..80edd2e046 100644 --- a/opencl/test/unit_test/device/device_caps_tests.cpp +++ b/opencl/test/unit_test/device/device_caps_tests.cpp @@ -8,6 +8,7 @@ #include "shared/source/command_stream/command_stream_receiver.h" #include "shared/source/compiler_interface/oclc_extensions.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/bit_helpers.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.maxWriteImageArgs * sizeof(cl_mem), sharedCaps.maxParameterSize); EXPECT_LE(128u * MemoryConstants::megaByte, sharedCaps.maxMemAllocSize); - if (!device->areSharedSystemAllocationsAllowed()) { + const auto &compilerProductHelper = device->getRootDeviceEnvironment().getHelper(); + + if (!compilerProductHelper.isForceToStatelessRequired()) { EXPECT_GE((4 * MemoryConstants::gigaByte) - (8 * MemoryConstants::kiloByte), sharedCaps.maxMemAllocSize); } + EXPECT_LE(65536u, sharedCaps.imageMaxBufferSize); EXPECT_GT(sharedCaps.maxWorkGroupSize, 0u); @@ -463,27 +467,23 @@ TEST_F(DeviceGetCapsTest, givenDeviceCapsWhenLocalMemoryIsEnabledThenCalculateGl EXPECT_EQ(sharedCaps.globalMemSize, expectedSize); } -HWTEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationsNotSupportedWhenCalculatingMaxAllocSizeThenAdjustToHWCap) { +HWTEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndStatelessNotSupportedWhenCalculatingMaxAllocSizeThenAdjustToHWCap) { DebugManagerStateRestore dbgRestorer; - debugManager.flags.EnableSharedSystemUsmSupport.set(0); auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); - const auto &caps = device->getSharedDeviceInfo(); + auto &rootDeviceEnvironment = device->getRootDeviceEnvironment(); + const auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + if (compilerProductHelper.isForceToStatelessRequired()) { + GTEST_SKIP(); + } + + const auto &caps = device->getSharedDeviceInfo(); + uint64_t expectedSize = std::max(caps.globalMemSize, static_cast(128ULL * MemoryConstants::megaByte)); + + expectedSize = std::min(ApiSpecificConfig::getReducedMaxAllocSize(expectedSize), device->getGfxCoreHelper().getMaxMemAllocSize()); - uint64_t expectedSize = std::max((caps.globalMemSize / 2), static_cast(128ULL * MemoryConstants::megaByte)); - auto &gfxCoreHelper = device->getGfxCoreHelper(); - expectedSize = std::min(expectedSize, gfxCoreHelper.getMaxMemAllocSize()); EXPECT_EQ(caps.maxMemAllocSize, expectedSize); } -TEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndSharedSystemAllocationsSupportedWhenCalculatingMaxAllocSizeThenEqualsToGlobalMemSize) { - DebugManagerStateRestore dbgRestorer; - debugManager.flags.EnableSharedSystemUsmSupport.set(1); - auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); - const auto &caps = device->getSharedDeviceInfo(); - - EXPECT_EQ(caps.maxMemAllocSize, caps.globalMemSize); -} - TEST_F(DeviceGetCapsTest, WhenDeviceIsCreatedThenExtensionsStringEndsWithSpace) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); const auto &caps = device->getDeviceInfo(); diff --git a/shared/source/device/device_caps.cpp b/shared/source/device/device_caps.cpp index 313dafa611..bc37fc7cc4 100644 --- a/shared/source/device/device_caps.cpp +++ b/shared/source/device/device_caps.cpp @@ -15,6 +15,7 @@ #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/compiler_product_helper.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/hw_info_helper.h" @@ -83,14 +84,13 @@ void Device::initializeCaps() { uint32_t subDeviceCount = gfxCoreHelper.getSubDevicesCount(&getHardwareInfo()); auto &rootDeviceEnvironment = this->getRootDeviceEnvironment(); bool platformImplicitScaling = gfxCoreHelper.platformSupportsImplicitScaling(rootDeviceEnvironment); + const auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); - if (((NEO::ImplicitScalingHelper::isImplicitScalingEnabled( - getDeviceBitfield(), platformImplicitScaling))) && + if ((NEO::ImplicitScalingHelper::isImplicitScalingEnabled( + getDeviceBitfield(), platformImplicitScaling)) && (!isSubDevice()) && (subDeviceCount > 1)) { deviceInfo.maxMemAllocSize = deviceInfo.globalMemSize; - } - - if (!areSharedSystemAllocationsAllowed()) { + } else if (!compilerProductHelper.isForceToStatelessRequired()) { deviceInfo.maxMemAllocSize = ApiSpecificConfig::getReducedMaxAllocSize(deviceInfo.maxMemAllocSize); deviceInfo.maxMemAllocSize = std::min(deviceInfo.maxMemAllocSize, gfxCoreHelper.getMaxMemAllocSize()); } diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index 1da9f70e54..f4bbba570e 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -353,24 +353,12 @@ TEST_F(DeviceGetCapsTest, pDevice->deviceBitfield = 15; debugManager.flags.EnableWalkerPartition.set(1); - debugManager.flags.EnableSharedSystemUsmSupport.set(1); 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.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); + EXPECT_LE(pDevice->getDeviceInfo().maxMemAllocSize, pDevice->getDeviceInfo().globalMemSize); } TEST_F(DeviceGetCapsTest, @@ -382,9 +370,8 @@ TEST_F(DeviceGetCapsTest, debugManager.flags.EnableImplicitScaling.set(1); debugManager.flags.EnableWalkerPartition.set(1); - debugManager.flags.EnableSharedSystemUsmSupport.set(1); pDevice->initializeCaps(); - EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize == pDevice->getDeviceInfo().globalMemSize); + EXPECT_EQ(pDevice->getDeviceInfo().maxMemAllocSize, pDevice->getDeviceInfo().globalMemSize); } TEST_F(DeviceGetCapsTest, @@ -396,9 +383,8 @@ TEST_F(DeviceGetCapsTest, debugManager.flags.EnableImplicitScaling.set(0); debugManager.flags.EnableWalkerPartition.set(1); - debugManager.flags.EnableSharedSystemUsmSupport.set(1); pDevice->initializeCaps(); - EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize <= pDevice->getDeviceInfo().globalMemSize); + EXPECT_LE(pDevice->getDeviceInfo().maxMemAllocSize, pDevice->getDeviceInfo().globalMemSize); } TEST_F(DeviceGetCapsTest, givenDontForcePreemptionModeDebugVariableWhenCreateDeviceThenSetDefaultHwPreemptionMode) {