diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index b5b6ec0c0c..0f3f5b0c48 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -383,11 +383,11 @@ DECLARE_DEBUG_VARIABLE(bool, DisableStatelessToStatefulOptimization, false, "Dis DECLARE_DEBUG_VARIABLE(bool, DisableConcurrentBlockExecution, false, "disables concurrent block kernel execution") DECLARE_DEBUG_VARIABLE(bool, UseNoRingFlushesKmdMode, true, "Windows only, passes flag to KMD that informs KMD to not emit any ring buffer flushes.") DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForUseHostPtr, false, "When active all buffer allocations created with CL_MEM_USE_HOST_PTR flag will not share memory with CPU.") -DECLARE_DEBUG_VARIABLE(bool, ForceNonCoherentModeForTimestamps, false, "When active timestamp buffers are allocated in non coherent memory.") DECLARE_DEBUG_VARIABLE(bool, SetAssumeNotInUse, true, "Set AssumeNotInUse flag in d3d destroy allocation.") DECLARE_DEBUG_VARIABLE(bool, MitigateHostVisibleSignal, false, "Reset host visible signal in CB events, flush L3 when synchronize") DECLARE_DEBUG_VARIABLE(bool, ForceZeroCopyForUseHostPtr, false, "When active all buffer allocations created with CL_MEM_USE_HOST_PTR flag will use share memory with CPU.") DECLARE_DEBUG_VARIABLE(bool, DummyPageBackingEnabled, false, "When true, pass page backing flag to KMD to recover from page faults. Windows only."); +DECLARE_DEBUG_VARIABLE(int32_t, ForceNonCoherentModeForTimestamps, -1, "When active timestamp buffers are allocated in non coherent memory.") DECLARE_DEBUG_VARIABLE(int32_t, EnableReusingGpuTimestamps, -1, "Reuse GPU timestamp for next device time requests. -1: os-specific, 0: disable, 1: enable") DECLARE_DEBUG_VARIABLE(int32_t, AllowZeroCopyWithoutCoherency, -1, "Use cacheline flush instead of memory copy for map/unmap mem object") DECLARE_DEBUG_VARIABLE(int32_t, EnableHostPtrTracking, -1, "Enable host ptr tracking: -1 - default platform setting, 0 - disabled, 1 - enabled") diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp index f11f974608..162d485e8d 100644 --- a/shared/source/gmm_helper/cache_settings_helper.cpp +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -99,13 +99,10 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER; case AllocationType::gpuTimestampDeviceBuffer: case AllocationType::timestampPacketTagBuffer: - if (debugManager.flags.ForceNonCoherentModeForTimestamps.get()) { + if (productHelper.isNonCoherentTimestampsModeEnabled()) { return GMM_RESOURCE_USAGE_OCL_BUFFER; } - if (productHelper.isDcFlushAllowed()) { - return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper); - } - return GMM_RESOURCE_USAGE_OCL_BUFFER; + return getDefaultUsageTypeWithCachingDisabled(allocationType, productHelper); default: return GMM_RESOURCE_USAGE_OCL_BUFFER; } @@ -118,12 +115,6 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching case AllocationType::internalHeap: case AllocationType::linearStream: return GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED; - case AllocationType::timestampPacketTagBuffer: - case AllocationType::gpuTimestampDeviceBuffer: - if (debugManager.flags.ForceNonCoherentModeForTimestamps.get()) { - return GMM_RESOURCE_USAGE_OCL_BUFFER; - } - [[fallthrough]]; default: return productHelper.isNewCoherencyModelSupported() ? GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC : GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED; } diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 7c5f593613..7b7a71a7d7 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -269,6 +269,8 @@ class ProductHelper { virtual bool isCompressionForbidden(const HardwareInfo &hwInfo) const = 0; virtual bool isExposingSubdevicesAllowed() const = 0; virtual bool useAdditionalBlitProperties() const = 0; + virtual bool isNonCoherentTimestampsModeEnabled() const = 0; + virtual bool getStorageInfoLocalOnlyFlag(LocalMemAllocationMode usmDeviceAllocationMode, bool defaultValue) const = 0; virtual ~ProductHelper() = default; diff --git a/shared/source/os_interface/product_helper_before_xe2.inl b/shared/source/os_interface/product_helper_before_xe2.inl index 00efbfa626..9d7da0d887 100644 --- a/shared/source/os_interface/product_helper_before_xe2.inl +++ b/shared/source/os_interface/product_helper_before_xe2.inl @@ -50,4 +50,12 @@ bool ProductHelperHw::isResourceUncachedForCS(AllocationType allocat return false; } +template +bool ProductHelperHw::isNonCoherentTimestampsModeEnabled() const { + if (debugManager.flags.ForceNonCoherentModeForTimestamps.get() != -1) { + return debugManager.flags.ForceNonCoherentModeForTimestamps.get(); + } + return !this->isDcFlushAllowed(); +} + } // namespace NEO diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 9b7894305f..cc9e5ffe4e 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -206,6 +206,7 @@ class ProductHelperHw : public ProductHelper { bool isCompressionForbidden(const HardwareInfo &hwInfo) const override; bool isExposingSubdevicesAllowed() const override; bool useAdditionalBlitProperties() const override; + bool isNonCoherentTimestampsModeEnabled() const override; bool getStorageInfoLocalOnlyFlag(LocalMemAllocationMode usmDeviceAllocationMode, bool defaultValue) const override; ~ProductHelperHw() override = default; diff --git a/shared/source/os_interface/product_helper_xe2_and_later.inl b/shared/source/os_interface/product_helper_xe2_and_later.inl index e54b9cc1b1..c77ce85332 100644 --- a/shared/source/os_interface/product_helper_xe2_and_later.inl +++ b/shared/source/os_interface/product_helper_xe2_and_later.inl @@ -53,4 +53,12 @@ bool ProductHelperHw::isResourceUncachedForCS(AllocationType allocat return GraphicsAllocation::isAccessedFromCommandStreamer(allocationType); } +template +bool ProductHelperHw::isNonCoherentTimestampsModeEnabled() const { + if (debugManager.flags.ForceNonCoherentModeForTimestamps.get() != -1) { + return debugManager.flags.ForceNonCoherentModeForTimestamps.get(); + } + return true; +} + } // namespace NEO diff --git a/shared/test/common/mocks/mock_product_helper.cpp b/shared/test/common/mocks/mock_product_helper.cpp index 5ed5f61e3e..a6a6bfb085 100644 --- a/shared/test/common/mocks/mock_product_helper.cpp +++ b/shared/test/common/mocks/mock_product_helper.cpp @@ -483,6 +483,11 @@ bool ProductHelperHw::isResourceUncachedForCS(AllocationType alloc return false; } +template <> +bool ProductHelperHw::isNonCoherentTimestampsModeEnabled() const { + return false; +} + } // namespace NEO #include "shared/source/os_interface/product_helper.inl" diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index cc213f75a4..c9c890bc9e 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -621,7 +621,7 @@ ForceComputeWalkerPostSyncFlushWithWrite = -1 DeferStateInitSubmissionToFirstRegularUsage = -1 WaitForPagingFenceInController = -1 DirectSubmissionPrintSemaphoreUsage = -1 -ForceNonCoherentModeForTimestamps = 0 +ForceNonCoherentModeForTimestamps = -1 SetAssumeNotInUse = 1 ExperimentalUSMAllocationReuseVersion = -1 ForceNonWalkerSplitMemoryCopy = -1 diff --git a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp index 7da0c5a354..1487dc9c7a 100644 --- a/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -707,8 +707,8 @@ TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) { break; case AllocationType::gpuTimestampDeviceBuffer: case AllocationType::timestampPacketTagBuffer: - expectedUsage = (forceUncached || productHelper.isDcFlushAllowed()) ? uncachedGmmUsageType - : GMM_RESOURCE_USAGE_OCL_BUFFER; + expectedUsage = (forceUncached || !productHelper.isNonCoherentTimestampsModeEnabled()) ? uncachedGmmUsageType + : GMM_RESOURCE_USAGE_OCL_BUFFER; break; case AllocationType::bufferHostMemory: case AllocationType::externalHostPtr: @@ -754,8 +754,8 @@ TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) { break; case AllocationType::gpuTimestampDeviceBuffer: case AllocationType::timestampPacketTagBuffer: - expectedUsage = (forceUncached || productHelper.isDcFlushAllowed()) ? uncachedGmmUsageType - : GMM_RESOURCE_USAGE_OCL_BUFFER; + expectedUsage = (forceUncached || !productHelper.isNonCoherentTimestampsModeEnabled()) ? uncachedGmmUsageType + : GMM_RESOURCE_USAGE_OCL_BUFFER; break; case AllocationType::bufferHostMemory: case AllocationType::externalHostPtr: @@ -884,14 +884,25 @@ TEST(GmmTest, givenAllocationTypeAndMitigatedDcFlushWhenGettingUsageTypeThenRetu } } -TEST(GmmTest, givenDebugFlagWhenTimestampAllocationsAreQueriedThenBufferPolicyIsReturned) { +TEST(GmmTest, whenTimestampAllocationsAreQueriedThenCorrectBufferPolicyIsReturned) { DebugManagerStateRestore restorer; - debugManager.flags.ForceNonCoherentModeForTimestamps.set(1); MockExecutionEnvironment mockExecutionEnvironment{}; const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); - auto expectedUsage = GMM_RESOURCE_USAGE_OCL_BUFFER; + auto uncachedType = productHelper.isNewCoherencyModelSupported() ? GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC : GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED; + auto expectedUsage = uncachedType; + if (productHelper.isNonCoherentTimestampsModeEnabled()) { + expectedUsage = GMM_RESOURCE_USAGE_OCL_BUFFER; + } EXPECT_EQ(expectedUsage, CacheSettingsHelper::getGmmUsageType(AllocationType::gpuTimestampDeviceBuffer, false, productHelper, defaultHwInfo.get())); EXPECT_EQ(expectedUsage, CacheSettingsHelper::getGmmUsageType(AllocationType::timestampPacketTagBuffer, false, productHelper, defaultHwInfo.get())); + + debugManager.flags.ForceNonCoherentModeForTimestamps.set(0); + EXPECT_EQ(uncachedType, CacheSettingsHelper::getGmmUsageType(AllocationType::gpuTimestampDeviceBuffer, false, productHelper, defaultHwInfo.get())); + EXPECT_EQ(uncachedType, CacheSettingsHelper::getGmmUsageType(AllocationType::timestampPacketTagBuffer, false, productHelper, defaultHwInfo.get())); + + debugManager.flags.ForceNonCoherentModeForTimestamps.set(1); + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER, CacheSettingsHelper::getGmmUsageType(AllocationType::gpuTimestampDeviceBuffer, false, productHelper, defaultHwInfo.get())); + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER, CacheSettingsHelper::getGmmUsageType(AllocationType::timestampPacketTagBuffer, false, productHelper, defaultHwInfo.get())); } TEST(GmmTest, givenForceAllResourcesUncachedFlagSetWhenGettingUsageTypeThenReturnUncached) {