From f156a74f549162167573581b274e5383e9ba592c Mon Sep 17 00:00:00 2001 From: John Falkowski Date: Mon, 16 Oct 2023 04:36:51 +0000 Subject: [PATCH] fix: split chunking prefetch flags Related-To: NEO-9120 Signed-off-by: John Falkowski --- level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl | 4 ++-- level_zero/core/source/cmdqueue/cmdqueue_hw.inl | 4 ++-- level_zero/core/source/helpers/api_specific_config_l0.cpp | 5 +++++ .../test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp | 1 + shared/source/debug_settings/debug_variables_base.inl | 3 ++- shared/source/helpers/api_specific_config.h | 1 + shared/source/memory_manager/unified_memory_manager.cpp | 2 +- shared/test/common/test_files/igdrcl.config | 1 + .../memory_manager/unified_memory_manager_tests.cpp | 2 +- 9 files changed, 16 insertions(+), 7 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index a65fe0a2d6..2da6ef8463 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -14,6 +14,7 @@ #include "shared/source/command_stream/wait_status.h" #include "shared/source/debugger/debugger_l0.h" #include "shared/source/direct_submission/relaxed_ordering_helper.h" +#include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/bindless_heaps_helper.h" #include "shared/source/helpers/completion_stamp.h" #include "shared/source/helpers/hw_info.h" @@ -332,8 +333,7 @@ inline ze_result_t CommandListCoreFamilyImmediate::executeCommand auto csr = static_cast(cmdQ)->getCsr(); auto lockCSR = csr->obtainUniqueOwnership(); - if (NEO::DebugManager.flags.ForceMemoryPrefetchForKmdMigratedSharedAllocations.get() || - NEO::DebugManager.flags.EnableBOChunkingPrefetch.get()) { + if (NEO::ApiSpecificConfig::isSharedAllocPrefetchEnabled()) { auto svmAllocMgr = this->device->getDriverHandle()->getSvmAllocsManager(); svmAllocMgr->prefetchSVMAllocs(*this->device->getNEODevice(), *csr); } diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl index 194000d890..929a63d2bd 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl @@ -19,6 +19,7 @@ #include "shared/source/debugger/debugger_l0.h" #include "shared/source/device/device.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/definitions/command_encoder_args.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/heap_base_address_model.h" @@ -63,8 +64,7 @@ ze_result_t CommandQueueHw::executeCommandLists( auto lockCSR = this->csr->obtainUniqueOwnership(); - if (NEO::DebugManager.flags.ForceMemoryPrefetchForKmdMigratedSharedAllocations.get() || - NEO::DebugManager.flags.EnableBOChunkingPrefetch.get() == 1) { + if (NEO::ApiSpecificConfig::isSharedAllocPrefetchEnabled()) { auto svmAllocMgr = device->getDriverHandle()->getSvmAllocsManager(); svmAllocMgr->prefetchSVMAllocs(*device->getNEODevice(), *csr); } diff --git a/level_zero/core/source/helpers/api_specific_config_l0.cpp b/level_zero/core/source/helpers/api_specific_config_l0.cpp index b4bb93bc86..b0e8aa9d24 100644 --- a/level_zero/core/source/helpers/api_specific_config_l0.cpp +++ b/level_zero/core/source/helpers/api_specific_config_l0.cpp @@ -68,4 +68,9 @@ const StackVec &ApiSpecificConfig::getPrefixStrings() { const StackVec &ApiSpecificConfig::getPrefixTypes() { return validL0PrefixTypes; } + +bool ApiSpecificConfig::isSharedAllocPrefetchEnabled() { + return (NEO::DebugManager.flags.ForceMemoryPrefetchForKmdMigratedSharedAllocations.get() || + (NEO::DebugManager.flags.EnableBOChunkingPrefetch.get() && ((NEO::DebugManager.flags.EnableBOChunking.get()) & 0x1))); +} } // namespace NEO diff --git a/level_zero/core/test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp b/level_zero/core/test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp index 85414ed0bf..718d1483ea 100644 --- a/level_zero/core/test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp +++ b/level_zero/core/test/unit_tests/xe_hpc_core/test_cmdlist_xe_hpc_core.cpp @@ -192,6 +192,7 @@ HWTEST2_F(CommandListStatePrefetchXeHpcCore, givenEnableBOChunkingPrefetchWhenEx DebugManagerStateRestore restore; DebugManager.flags.UseKmdMigration.set(true); DebugManager.flags.EnableBOChunkingPrefetch.set(true); + DebugManager.flags.EnableBOChunking.set(1); size_t size = 10; size_t alignment = 1u; diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index ffa85fbd7f..35711a53b5 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -520,7 +520,8 @@ DECLARE_DEBUG_VARIABLE(bool, EnableConcurrentSharedCrossP2PDeviceAccess, false, DECLARE_DEBUG_VARIABLE(bool, AllocateSharedAllocationsInHeapExtendedHost, true, "When enabled driver can allocate shared unified memory allocation in heap extended host. (0 - disable, 1 - enable)") DECLARE_DEBUG_VARIABLE(bool, AllocateHostAllocationsInHeapExtendedHost, true, "When enabled driver can allocate host unified memory allocation in heap extended host. (0 - disable, 1 - enable)") DECLARE_DEBUG_VARIABLE(bool, PrintBOChunkingLogs, false, "Print some logs on BO chunking") -DECLARE_DEBUG_VARIABLE(bool, EnableBOChunkingPrefetch, false, "Enables prefetching of chunks") +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, NumberOfBOChunks, 2, "Number of chunks to use. Must be a power of two)") diff --git a/shared/source/helpers/api_specific_config.h b/shared/source/helpers/api_specific_config.h index 4fb1465efc..6db374077f 100644 --- a/shared/source/helpers/api_specific_config.h +++ b/shared/source/helpers/api_specific_config.h @@ -33,5 +33,6 @@ struct ApiSpecificConfig { static std::string getAubPrefixForSpecificApi() { return (getName() + "_"); } + static bool isSharedAllocPrefetchEnabled(); }; } // namespace NEO diff --git a/shared/source/memory_manager/unified_memory_manager.cpp b/shared/source/memory_manager/unified_memory_manager.cpp index 36a632fe60..4e6e2c5a66 100644 --- a/shared/source/memory_manager/unified_memory_manager.cpp +++ b/shared/source/memory_manager/unified_memory_manager.cpp @@ -804,7 +804,7 @@ void SVMAllocsManager::prefetchMemory(Device &device, CommandStreamReceiver &com // and if KMD migration is set, as current target is to use // chunking only with KMD migration bool isChunkingNeededForDeviceAllocations = false; - if (NEO::DebugManager.flags.EnableBOChunkingPrefetch.get() && + if (NEO::DebugManager.flags.EnableBOChunkingDevMemPrefetch.get() && memoryManager->isKmdMigrationAvailable(device.getRootDeviceIndex()) && (svmData.memoryType == InternalMemoryType::DEVICE_UNIFIED_MEMORY)) { isChunkingNeededForDeviceAllocations = true; diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index d9fd6e5665..9c2f9a551c 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -519,6 +519,7 @@ AllocateSharedAllocationsInHeapExtendedHost = 1 AllocateHostAllocationsInHeapExtendedHost = 1 PrintBOChunkingLogs = 0 EnableBOChunkingPrefetch = 0 +EnableBOChunkingDevMemPrefetch = 0 EnableBOChunkingPreferredLocationHint = 0 NumberOfBOChunks = 2 EnableBOChunking = 0 diff --git a/shared/test/unit_test/memory_manager/unified_memory_manager_tests.cpp b/shared/test/unit_test/memory_manager/unified_memory_manager_tests.cpp index 8be4c97ee3..a0fb00ab37 100644 --- a/shared/test/unit_test/memory_manager/unified_memory_manager_tests.cpp +++ b/shared/test/unit_test/memory_manager/unified_memory_manager_tests.cpp @@ -244,7 +244,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, givenKmdMigratedSharedAllocationWhenPrefetch TEST_F(SVMLocalMemoryAllocatorTest, givenEnableBOChunkingPrefetchWhenPrefetchMemoryIsCalledThenSetMemPrefetchCalled) { DebugManagerStateRestore restore; DebugManager.flags.UseKmdMigration.set(1); - DebugManager.flags.EnableBOChunkingPrefetch.set(true); + DebugManager.flags.EnableBOChunkingDevMemPrefetch.set(true); std::unique_ptr deviceFactory(new UltDeviceFactory(1, 2)); auto device = deviceFactory->rootDevices[0];