From 18d828421d57c624fca5da051896ebf4cf7a066c Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Mon, 21 Oct 2024 13:43:55 +0000 Subject: [PATCH] performance: add debug flag to control huge chunk size on wddm. Signed-off-by: Michal Mrozek --- shared/source/debug_settings/debug_variables_base.inl | 1 + .../os_interface/windows/max_chunk_size_drm_or_wddm.cpp | 5 ++++- shared/source/os_interface/windows/max_chunk_size_wddm.cpp | 5 ++++- shared/test/common/test_files/igdrcl.config | 1 + .../os_interface/windows/wddm_memory_manager_tests.cpp | 7 +++++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index f4913ceb4b..e38f364a03 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -403,6 +403,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableCopyWithStagingBuffers, -1, "Enable copy w DECLARE_DEBUG_VARIABLE(int32_t, StagingBufferSize, -1, "Size of single staging buffer. -1: default (2MB), >0: size in KB") DECLARE_DEBUG_VARIABLE(int32_t, ForcePostSyncL1Flush, -1, "-1: default (do nothing), 0: L1 flush disabled in post sync, 1: L1 flush enabled in post sync") DECLARE_DEBUG_VARIABLE(int32_t, AllowNotZeroForCompressedOnWddm, -1, "-1: default (do nothing), 0: do not set AllowNotZeroed for compressed resources, 1: set AllowNotZeroed for compressed resources"); +DECLARE_DEBUG_VARIABLE(int32_t, ForceWddmHugeChunkSizeMB, -1, "-1: default (do nothing), >0: set given huge chunk size in MegaBytes for WDDM"); DECLARE_DEBUG_VARIABLE(int64_t, ForceGmmSystemMemoryBufferForAllocations, 0, "0: default, >0: (bitmask) for given Allocation Types, force GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER gmm resource type"); /*DIRECT SUBMISSION FLAGS*/ diff --git a/shared/source/os_interface/windows/max_chunk_size_drm_or_wddm.cpp b/shared/source/os_interface/windows/max_chunk_size_drm_or_wddm.cpp index 078dd4abb7..15151db3cb 100644 --- a/shared/source/os_interface/windows/max_chunk_size_drm_or_wddm.cpp +++ b/shared/source/os_interface/windows/max_chunk_size_drm_or_wddm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,6 +12,9 @@ namespace NEO { const GfxMemoryAllocationMethod preferredAllocationMethod = GfxMemoryAllocationMethod::allocateByKmd; size_t WddmMemoryManager::getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod allocationMethod) const { + if (NEO::debugManager.flags.ForceWddmHugeChunkSizeMB.get() != -1) { + return NEO::debugManager.flags.ForceWddmHugeChunkSizeMB.get() * MemoryConstants::megaByte; + } if (GfxMemoryAllocationMethod::allocateByKmd == allocationMethod) { return 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k; } else { diff --git a/shared/source/os_interface/windows/max_chunk_size_wddm.cpp b/shared/source/os_interface/windows/max_chunk_size_wddm.cpp index e59d0693d1..99e6873789 100644 --- a/shared/source/os_interface/windows/max_chunk_size_wddm.cpp +++ b/shared/source/os_interface/windows/max_chunk_size_wddm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,6 +12,9 @@ namespace NEO { const GfxMemoryAllocationMethod preferredAllocationMethod = GfxMemoryAllocationMethod::useUmdSystemPtr; size_t WddmMemoryManager::getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod allocationMethod) const { + if (NEO::debugManager.flags.ForceWddmHugeChunkSizeMB.get() != -1) { + return NEO::debugManager.flags.ForceWddmHugeChunkSizeMB.get() * MemoryConstants::megaByte; + } return 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k; } diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 3e9b128a2d..79674bdffb 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -630,4 +630,5 @@ OverrideTimestampWidth = -1 IgnoreZebinUnknownAttributes = 0 FifoPollInterval = -1 MaxSubSlicesSupportedOverride = -1 +ForceWddmHugeChunkSizeMB = -1 # Please don't edit below this line diff --git a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index f936432979..97554d57d8 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -3640,6 +3640,13 @@ TEST_F(MockWddmMemoryManagerTest, givenDefaultMemoryManagerWhenItIsCreatedThenCo EXPECT_EQ(memoryManager.getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::useUmdSystemPtr), 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k); } +TEST_F(MockWddmMemoryManagerTest, givenDebugOverrideWhenQueryIsDoneThenProperSizeIsReturned) { + DebugManagerStateRestore dbgRestore; + NEO::debugManager.flags.ForceWddmHugeChunkSizeMB.set(256); + MockWddmMemoryManager memoryManager(executionEnvironment); + EXPECT_EQ(256 * MemoryConstants::megaByte, memoryManager.getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::allocateByKmd)); +} + TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForHostBufferAndRequestedSizeIsHugeThenResultAllocationIsSplitted) { DebugManagerStateRestore dbgRestore;