diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index dc892c7c2e..1f810e14fe 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -1867,8 +1867,8 @@ HWTEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocati EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation->getUnderlyingBufferSize()); EXPECT_NE(0llu, graphicsAllocation->getGpuAddress()); EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer()); - auto &gfxCoreHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getHelper(); - EXPECT_EQ(gfxCoreHelper.isCachingOnCpuAvailable(), graphicsAllocation->getDefaultGmm()->resourceParams.Flags.Info.Cacheable); + auto &productHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getHelper(); + EXPECT_EQ(productHelper.isCachingOnCpuAvailable(), graphicsAllocation->getDefaultGmm()->resourceParams.Flags.Info.Cacheable); memoryManager.freeGraphicsMemory(graphicsAllocation); } diff --git a/shared/source/execution_environment/root_device_environment.cpp b/shared/source/execution_environment/root_device_environment.cpp index fd935d4025..f0177a7112 100644 --- a/shared/source/execution_environment/root_device_environment.cpp +++ b/shared/source/execution_environment/root_device_environment.cpp @@ -247,6 +247,10 @@ AssertHandler *RootDeviceEnvironment::getAssertHandler(Device *neoDevice) { return this->assertHandler.get(); } +bool RootDeviceEnvironment::isWddmOnLinux() const { + return isWddmOnLinuxEnable; +} + template HelperType &RootDeviceEnvironment::getHelper() const { if constexpr (std::is_same_v) { diff --git a/shared/source/execution_environment/root_device_environment.h b/shared/source/execution_environment/root_device_environment.h index 2a935f0761..ef475d906e 100644 --- a/shared/source/execution_environment/root_device_environment.h +++ b/shared/source/execution_environment/root_device_environment.h @@ -56,6 +56,7 @@ struct RootDeviceEnvironment { HardwareInfo *getMutableHardwareInfo() const; void setHwInfoAndInitHelpers(const HardwareInfo *hwInfo); bool isFullRangeSvm() const; + bool isWddmOnLinux() const; MOCKABLE_VIRTUAL void initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType); bool initOsInterface(std::unique_ptr &&hwDeviceId, uint32_t rootDeviceIndex); @@ -118,6 +119,7 @@ struct RootDeviceEnvironment { GraphicsAllocationUniquePtrType dummyAllocation = nullptr; bool limitedNumberOfCcs = false; + bool isWddmOnLinuxEnable = false; std::once_flag isDummyAllocationInitialized; std::unique_ptr dummyBlitProperties; diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp index 1bf5b501fc..a4a265beed 100644 --- a/shared/source/gmm_helper/cache_settings_helper.cpp +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -29,8 +29,8 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType } } -bool CacheSettingsHelper::isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const GfxCoreHelper &gfxCoreHelper) { - bool isCachingOnCpuAvailable = gfxCoreHelper.isCachingOnCpuAvailable(); +bool CacheSettingsHelper::isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const ProductHelper &productHelper, bool isWsl) { + bool isCachingOnCpuAvailable = isWsl ? true : productHelper.isCachingOnCpuAvailable(); if (DebugManager.flags.EnableCpuCacheForResources.get()) { isCachingOnCpuAvailable = true; } diff --git a/shared/source/gmm_helper/cache_settings_helper.h b/shared/source/gmm_helper/cache_settings_helper.h index bf0ae60d97..1d32e47c2c 100644 --- a/shared/source/gmm_helper/cache_settings_helper.h +++ b/shared/source/gmm_helper/cache_settings_helper.h @@ -16,7 +16,6 @@ namespace NEO { enum class AllocationType; struct HardwareInfo; class ProductHelper; -class GfxCoreHelper; struct CacheSettingsHelper { static GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached, const ProductHelper &productHelper); @@ -27,7 +26,7 @@ struct CacheSettingsHelper { (gmmResourceUsageType == GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED)); } - static bool isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const GfxCoreHelper &gfxCoreHelper); + static bool isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const ProductHelper &productHelper, bool isWsl); protected: static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper); diff --git a/shared/source/gmm_helper/gmm.cpp b/shared/source/gmm_helper/gmm.cpp index 6e051e504d..2103847326 100644 --- a/shared/source/gmm_helper/gmm.cpp +++ b/shared/source/gmm_helper/gmm.cpp @@ -39,8 +39,8 @@ Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_ resourceParams.Usage = gmmResourceUsage; resourceParams.Flags.Info.Linear = 1; - auto &gfxCoreHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); - resourceParams.Flags.Info.Cacheable = CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsage, gfxCoreHelper); + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); + resourceParams.Flags.Info.Cacheable = CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsage, productHelper, gmmHelper->getRootDeviceEnvironment().isWddmOnLinux()); resourceParams.Flags.Gpu.Texture = 1; if (alignedPtr) { diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 58b06c5662..5608a67c62 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -169,7 +169,6 @@ class GfxCoreHelper { virtual bool isTimestampShiftRequired() const = 0; virtual bool isRelaxedOrderingSupported() const = 0; static bool isWorkaroundRequired(uint32_t lowestSteppingWithBug, uint32_t steppingWithFix, const HardwareInfo &hwInfo, const ProductHelper &productHelper); - virtual bool isCachingOnCpuAvailable() const = 0; virtual ~GfxCoreHelper() = default; protected: @@ -381,7 +380,6 @@ class GfxCoreHelperHw : public GfxCoreHelper { bool isChipsetUniqueUUIDSupported() const override; bool isTimestampShiftRequired() const override; bool isRelaxedOrderingSupported() const override; - bool isCachingOnCpuAvailable() const override; ~GfxCoreHelperHw() override = default; diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index 922b5e7dc0..b57accf6ef 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -685,9 +685,4 @@ template uint32_t GfxCoreHelperHw::getMinimalGrfSize() const { return 128u; } - -template -bool GfxCoreHelperHw::isCachingOnCpuAvailable() const { - return true; -} } // namespace NEO diff --git a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl index cc622425df..d768963fab 100644 --- a/shared/source/helpers/gfx_core_helper_xehp_and_later.inl +++ b/shared/source/helpers/gfx_core_helper_xehp_and_later.inl @@ -232,9 +232,4 @@ bool GfxCoreHelperHw::isChipsetUniqueUUIDSupported() const { return true; } -template <> -bool GfxCoreHelperHw::isCachingOnCpuAvailable() const { - return false; -} - } // namespace NEO diff --git a/shared/source/os_interface/init_os_interface_drm_or_wddm.cpp b/shared/source/os_interface/init_os_interface_drm_or_wddm.cpp index e9a78a754b..ace46d94e1 100644 --- a/shared/source/os_interface/init_os_interface_drm_or_wddm.cpp +++ b/shared/source/os_interface/init_os_interface_drm_or_wddm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -16,6 +16,7 @@ bool RootDeviceEnvironment::initOsInterface(std::unique_ptr &&hwDevi if (hwDeviceId->getDriverModelType() == DriverModelType::DRM) { return initDrmOsInterface(std::move(hwDeviceId), rootDeviceIndex, this); } else { + this->isWddmOnLinuxEnable = true; return initWddmOsInterface(std::move(hwDeviceId), this); } } diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 07d84ddd56..6aba5faba4 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -207,6 +207,7 @@ class ProductHelper { virtual uint32_t getNumberOfPartsInTileForConcurrentKernel() const = 0; virtual bool is48bResourceNeededForRayTracing() const = 0; virtual bool disableL3CacheForDebug(const HardwareInfo &hwInfo) const = 0; + virtual bool isCachingOnCpuAvailable() const = 0; virtual ~ProductHelper() = default; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 594383056b..4b4275494b 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -791,4 +791,8 @@ bool ProductHelperHw::disableL3CacheForDebug(const HardwareInfo &) c return false; } +template +bool ProductHelperHw::isCachingOnCpuAvailable() const { + return true; +} } // namespace NEO diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 67aa1187b3..b1d3d86071 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -160,6 +160,7 @@ class ProductHelperHw : public ProductHelper { bool isCalculationForDisablingEuFusionWithDpasNeeded(const HardwareInfo &hwInfo) const override; bool is48bResourceNeededForRayTracing() const override; bool disableL3CacheForDebug(const HardwareInfo &hwInfo) const override; + bool isCachingOnCpuAvailable() const override; ~ProductHelperHw() override = default; diff --git a/shared/source/xe_hpg_core/mtl/os_agnostic_product_helper_mtl.inl b/shared/source/xe_hpg_core/mtl/os_agnostic_product_helper_mtl.inl index 5cc7069947..02dd7484bc 100644 --- a/shared/source/xe_hpg_core/mtl/os_agnostic_product_helper_mtl.inl +++ b/shared/source/xe_hpg_core/mtl/os_agnostic_product_helper_mtl.inl @@ -96,4 +96,9 @@ bool ProductHelperHw::isDummyBlitWaRequired() const { return true; } +template <> +bool ProductHelperHw::isCachingOnCpuAvailable() const { + return false; +} + } // namespace NEO diff --git a/shared/test/unit_test/gmm_helper/gmm_tests.cpp b/shared/test/unit_test/gmm_helper/gmm_tests.cpp index 234ee39aca..55c2d30d2e 100644 --- a/shared/test/unit_test/gmm_helper/gmm_tests.cpp +++ b/shared/test/unit_test/gmm_helper/gmm_tests.cpp @@ -5,14 +5,14 @@ * */ +#include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm_helper.h" -#include "shared/source/helpers/gfx_core_helper.h" #include "shared/test/common/fixtures/mock_execution_environment_gmm_fixture.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_gmm.h" -#include "shared/test/common/test_macros/test.h" +#include "shared/test/common/test_macros/hw_test.h" namespace NEO { using GmmTests = Test; @@ -33,13 +33,13 @@ TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenCreateGmmAndFlagEnableCpuCa DebugManagerStateRestore restore; DebugManager.flags.EnableCpuCacheForResources.set(0); StorageInfo storageInfo{}; - auto &gfxCoreHelper = getGmmHelper()->getRootDeviceEnvironment().getHelper(); + auto &productHelper = getGmmHelper()->getRootDeviceEnvironment().getHelper(); for (auto resourceUsageType : {GMM_RESOURCE_USAGE_OCL_IMAGE, GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER, GMM_RESOURCE_USAGE_OCL_BUFFER_CONST, GMM_RESOURCE_USAGE_OCL_BUFFER}) { auto gmm = std::make_unique(getGmmHelper(), nullptr, 0, 0, resourceUsageType, false, storageInfo, false); - EXPECT_EQ(gfxCoreHelper.isCachingOnCpuAvailable(), gmm->resourceParams.Flags.Info.Cacheable); + EXPECT_EQ(productHelper.isCachingOnCpuAvailable(), gmm->resourceParams.Flags.Info.Cacheable); } } @@ -52,4 +52,19 @@ TEST_F(GmmTests, givenResourceUsageTypesUnCachedWhenGreateGmmThenFlagCachcableIs EXPECT_FALSE(gmm->resourceParams.Flags.Info.Cacheable); } } + +HWTEST_F(GmmTests, givenIsResourceCacheableOnCpuWhenWslFlagThenReturnProperValue) { + DebugManagerStateRestore restore; + DebugManager.flags.EnableCpuCacheForResources.set(false); + auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getProductHelper(); + + GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType = GMM_RESOURCE_USAGE_OCL_BUFFER; + EXPECT_EQ(!CacheSettingsHelper::isUncachedType(gmmResourceUsageType), CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsageType, productHelper, true)); + EXPECT_EQ(productHelper.isCachingOnCpuAvailable(), CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsageType, productHelper, false)); + + gmmResourceUsageType = GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED; + EXPECT_EQ(!CacheSettingsHelper::isUncachedType(gmmResourceUsageType), CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsageType, productHelper, true)); + EXPECT_EQ(productHelper.isCachingOnCpuAvailable() && !CacheSettingsHelper::isUncachedType(gmmResourceUsageType), + CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsageType, productHelper, false)); +} } // namespace NEO diff --git a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp index 5630096ee8..130d3e9de9 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp @@ -1568,13 +1568,3 @@ HWTEST_F(GfxCoreHelperTest, givenNumGrfAndSimdSizeWhenAdjustingMaxWorkGroupSizeT numGrfRequired = GrfConfig::DefaultGrfNumber; EXPECT_EQ(defaultMaxGroupSize, gfxCoreHelper.adjustMaxWorkGroupSize(numGrfRequired, simdSize, defaultMaxGroupSize)); } - -HWTEST2_F(GfxCoreHelperTest, givenAtLeastXeHpWhenCheckIsCachingOnCpuAvailableThenAlwaysFalse, IsAtLeastXeHpCore) { - const auto &gfxCoreHelper = getHelper(); - EXPECT_FALSE(gfxCoreHelper.isCachingOnCpuAvailable()); -} - -HWTEST2_F(GfxCoreHelperTest, givenAtMostGen12lpWhenCheckIsCachingOnCpuAvailableThenAlwaysTrue, IsAtMostGen12lp) { - const auto &gfxCoreHelper = getHelper(); - EXPECT_TRUE(gfxCoreHelper.isCachingOnCpuAvailable()); -} diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index b351a122b7..e18921fcdf 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -760,3 +760,7 @@ HWTEST_F(ProductHelperTest, whenQueryingMaxNumSamplersThenReturnSixteen) { HWTEST_F(ProductHelperTest, whenDisableL3ForDebugCalledThenFalseIsReturned) { EXPECT_FALSE(productHelper->disableL3CacheForDebug(*defaultHwInfo)); } + +HWTEST_F(ProductHelperTest, whenCheckIsCachingOnCpuAvailableThenAlwaysTrue) { + EXPECT_TRUE(productHelper->isCachingOnCpuAvailable()); +} diff --git a/shared/test/unit_test/xe_hpg_core/mtl/excludes_xe_hpg_core_mtl.cpp b/shared/test/unit_test/xe_hpg_core/mtl/excludes_xe_hpg_core_mtl.cpp index 32746f77fa..6fb2f6223e 100644 --- a/shared/test/unit_test/xe_hpg_core/mtl/excludes_xe_hpg_core_mtl.cpp +++ b/shared/test/unit_test/xe_hpg_core/mtl/excludes_xe_hpg_core_mtl.cpp @@ -20,6 +20,7 @@ HWTEST_EXCLUDE_PRODUCT(ComputeModeRequirements, givenComputeModeProgrammingWhenR HWTEST_EXCLUDE_PRODUCT(ComputeModeRequirements, givenComputeModeProgrammingWhenRequiredGRFNumberIsGreaterThan128ThenLargeGRFModeIsProgrammed_ForceNonCoherentSupportedMatcher, IGFX_METEORLAKE); HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenAskedIfPatIndexProgrammingSupportedThenReturnFalse, IGFX_METEORLAKE); HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenIsAdjustWalkOrderAvailableCallThenFalseReturn, IGFX_METEORLAKE); +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, whenCheckIsCachingOnCpuAvailableThenAlwaysTrue, IGFX_METEORLAKE); HWTEST_EXCLUDE_PRODUCT(ProductHelperCommonTest, givenPatIndexAndAllocationTypeWhenCallOverridePatIndexThenSameIndexIsReturned, IGFX_METEORLAKE); HWTEST_EXCLUDE_PRODUCT(CompilerProductHelperFixture, GivenXeHpAndLaterThenBFloat16ConversionIsSupported_IsAtLeastXeHpCore, IGFX_METEORLAKE); HWTEST_EXCLUDE_PRODUCT(CompilerProductHelperFixture, GivenXeHpAndLaterThenMatrixMultiplyAccumulateIsSupported_IsAtLeastXeHpCore, IGFX_METEORLAKE); diff --git a/shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp b/shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp index 76e2f3e1ea..9253d3c4ab 100644 --- a/shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp +++ b/shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp @@ -311,3 +311,8 @@ MTLTEST_F(ProductHelperTestMtl, givenPatIndexAndAllocationTypeWhenCallOverridePa patIndex = 3u; EXPECT_EQ(patIndex, helper.overridePatIndex(allocationType, patIndex)); } + +MTLTEST_F(ProductHelperTestMtl, givenMtlWhenCheckIsCachingOnCpuAvailableThenAlwaysFalse) { + const auto &productHelper = getHelper(); + EXPECT_FALSE(productHelper.isCachingOnCpuAvailable()); +}