From f0175b391660cb0f5c76d426202f3e19e2dda1c5 Mon Sep 17 00:00:00 2001 From: John Falkowski Date: Fri, 3 Nov 2023 15:46:58 +0000 Subject: [PATCH] feature: set device allocation chunking as default Device allocation chunking only applies for multi-tile mode for implicit scaling Related-To: NEO-9051 Signed-off-by: John Falkowski --- .../debug_settings/debug_variables_base.inl | 2 +- .../os_interface/linux/drm_memory_manager.cpp | 2 +- shared/source/os_interface/linux/drm_neo.cpp | 10 +++++-- shared/source/os_interface/linux/drm_neo.h | 2 ++ shared/test/common/test_files/igdrcl.config | 2 +- .../drm_residency_handler_prelim_tests.cpp | 28 +++++++++++++++++-- 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index be7b38071a..2c4f269f09 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -529,7 +529,7 @@ DECLARE_DEBUG_VARIABLE(bool, PrintBOChunkingLogs, false, "Print some logs on BO DECLARE_DEBUG_VARIABLE(bool, EnableBOChunkingPrefetch, false, "Enables prefetching of Shared Memory chunks") DECLARE_DEBUG_VARIABLE(bool, EnableBOChunkingDevMemPrefetch, false, "Enables prefetching of Device Memory chunks") DECLARE_DEBUG_VARIABLE(bool, EnableBOChunkingPreferredLocationHint, false, "Enables preferred location advise on chunks") -DECLARE_DEBUG_VARIABLE(int32_t, EnableBOChunking, 0, "Enables use of chunking of BOs in the KMD, mask: 0 = no chunking, 1 = shared allocations only, 2 = device allocations only, 3 = shared and device allocations .") +DECLARE_DEBUG_VARIABLE(int32_t, EnableBOChunking, -1, "Enables use of chunking of BOs in the KMD, mask: -1 = default, 0 = no chunking, 1 = shared allocations only, 2 = multi-tile device allocations only, 3 = shared and multi-tile device allocations .") DECLARE_DEBUG_VARIABLE(int32_t, NumberOfBOChunks, 2, "Number of chunks to use. Must be a power of two)") DECLARE_DEBUG_VARIABLE(int32_t, MinimalAllocationSizeForChunking, -1, "2097152: default, >0: size in B. Minimal size an allocation should have to use chunking.") DECLARE_DEBUG_VARIABLE(int32_t, ForceAutoGrfCompilationMode, -1, "Adds build option -*-intel-enable-auto-large-GRF-mode to force kernel compilation") diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 704a0aa070..d5ccbb90b2 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -2288,7 +2288,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const // Dont chunk for sizes less than chunkThreshold or if debugging is enabled if (!executionEnvironment.isDebuggingEnabled() && - (drm.getChunkingMode() & 0x01) && + (drm.getChunkingMode() & chunkingModeShared) && !(chunkingSize & (MemoryConstants::chunkThreshold - 1)) && size >= drm.getMinimalSizeForChunking()) { numHandles = 1; diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index eed2388c0e..2ff306c1de 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -1157,7 +1157,11 @@ bool Drm::isChunkingAvailable() { int ret = ioctlHelper->isChunkingAvailable(); if (ret) { chunkingAvailable = true; - chunkingMode = DebugManager.flags.EnableBOChunking.get(); + if (DebugManager.flags.EnableBOChunking.get() == -1) { + chunkingMode = chunkingModeDevice; + } else { + chunkingMode = DebugManager.flags.EnableBOChunking.get(); + } } if (DebugManager.flags.MinimalAllocationSizeForChunking.get() != -1) { @@ -1167,8 +1171,8 @@ bool Drm::isChunkingAvailable() { printDebugString(DebugManager.flags.PrintBOChunkingLogs.get(), stdout, "Chunking available: %d; enabled for: shared allocations %d, device allocations %d; minimalChunkingSize: %zd\n", chunkingAvailable, - (chunkingMode & 0x01), - (chunkingMode & 0x02), + (chunkingMode & chunkingModeShared), + (chunkingMode & chunkingModeDevice), minimalChunkingSize); }); } diff --git a/shared/source/os_interface/linux/drm_neo.h b/shared/source/os_interface/linux/drm_neo.h index 375af26128..6e98b6f789 100644 --- a/shared/source/os_interface/linux/drm_neo.h +++ b/shared/source/os_interface/linux/drm_neo.h @@ -35,6 +35,8 @@ enum EngineType : uint32_t; namespace NEO { constexpr uint32_t contextPrivateParamBoost = 0x80000000; +constexpr uint32_t chunkingModeShared = 1; +constexpr uint32_t chunkingModeDevice = 2; enum class AllocationType; enum class CachePolicy : uint32_t; diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 426053b79a..8715238580 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -525,7 +525,7 @@ EnableBOChunkingPrefetch = 0 EnableBOChunkingDevMemPrefetch = 0 EnableBOChunkingPreferredLocationHint = 0 NumberOfBOChunks = 2 -EnableBOChunking = 0 +EnableBOChunking = -1 MinimalAllocationSizeForChunking = -1 DirectSubmissionControllerMaxTimeout = -1 ExitOnSubmissionNumber = -1 diff --git a/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp index 220b99b1bd..419a37b4c0 100644 --- a/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp @@ -1483,10 +1483,34 @@ TEST(DrmSetPairTests, whenQueryingForSetPairAvailableAndNoDebugKeyThenFalseIsRet EXPECT_EQ(0u, drm.context.setPairQueryCalled); } -TEST(DrmChunkingTests, whenQueryingForChunkingAvailableAndNoDebugKeyThenFalseIsReturned) { +TEST(DrmChunkingTests, whenQueryingForChunkingAvailableAndDefaultDebugVariableThenTrueIsReturned) { + DebugManagerStateRestore restorer; + DebugManager.flags.UseKmdMigration.set(1); + auto executionEnvironment = std::make_unique(); DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; - drm.context.chunkingQueryValue = 0; + + drm.context.chunkingQueryValue = 1; + drm.context.chunkingQueryReturn = 0; + EXPECT_FALSE(drm.chunkingAvailable); + + EXPECT_EQ(0u, drm.context.chunkingQueryCalled); + drm.callBaseIsChunkingAvailable = true; + EXPECT_TRUE(drm.isChunkingAvailable()); + EXPECT_TRUE(drm.getChunkingAvailable()); + EXPECT_EQ(1u, drm.context.chunkingQueryCalled); + EXPECT_EQ(2u, drm.getChunkingMode()); +} + +TEST(DrmChunkingTests, whenQueryingForChunkingAvailableAndDisableDebugVariableThenFalseIsReturned) { + DebugManagerStateRestore restorer; + DebugManager.flags.EnableBOChunking.set(0); + DebugManager.flags.UseKmdMigration.set(1); + + auto executionEnvironment = std::make_unique(); + DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]}; + + drm.context.chunkingQueryValue = 1; drm.context.chunkingQueryReturn = 0; EXPECT_FALSE(drm.chunkingAvailable);