mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +08:00
fix: Remove default setting of gmm flag Cacheable to true
- add debug flag EnableCpuCacheForResources to be able to allow coherency when resources could be cacheable Resolves: NEO-7194 Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
af2c61c54b
commit
004a3d875c
@@ -1866,7 +1866,7 @@ TEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocation
|
||||
EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE(0llu, graphicsAllocation->getGpuAddress());
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(1u, graphicsAllocation->getDefaultGmm()->resourceParams.Flags.Info.Cacheable);
|
||||
EXPECT_EQ(0u, graphicsAllocation->getDefaultGmm()->resourceParams.Flags.Info.Cacheable);
|
||||
|
||||
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
|
||||
@@ -490,6 +490,7 @@ DECLARE_DEBUG_VARIABLE(bool, SkipFlushingEventsOnGetStatusCalls, false, "When se
|
||||
DECLARE_DEBUG_VARIABLE(bool, AllowUnrestrictedSize, false, "Allow allocating memory with greater size than MAX_MEM_ALLOC_SIZE")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ForceDefaultThreadArbitrationPolicyIfNotSpecified, false, "When executing kernel without thread arbitration hint specified, ensure the default setting is used")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ForceAllResourcesUncached, false, "When set, all memory operations for all resources are forced to UC. This overrides all caching-related debug variables and globally disables all caches")
|
||||
DECLARE_DEBUG_VARIABLE(bool, EnableCpuCacheForResources, false, "When true, driver will set gmm flag cacheable related to caching on cpu, for resources where it is allowed")
|
||||
DECLARE_DEBUG_VARIABLE(bool, EnableDebuggerMmapMemoryAccess, false, "Mmap used to access memory by debug api, valid only on Linux OS")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ForceDefaultGrfCompilationMode, false, "Adds build option -cl-intel-128-GRF-per-thread to force kernel compilation in Default-GRF mode")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ForceLargeGrfCompilationMode, false, "Adds build option -cl-intel-256-GRF-per-thread to force kernel compilation in Large-GRF mode")
|
||||
|
||||
@@ -28,6 +28,13 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType
|
||||
}
|
||||
}
|
||||
|
||||
bool CacheSettingsHelper::isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType) {
|
||||
if (DebugManager.flags.EnableCpuCacheForResources.get()) {
|
||||
return !CacheSettingsHelper::isUncachedType(gmmResourceUsageType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper) {
|
||||
|
||||
switch (allocationType) {
|
||||
|
||||
@@ -26,6 +26,8 @@ struct CacheSettingsHelper {
|
||||
(gmmResourceUsageType == GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
|
||||
}
|
||||
|
||||
static bool isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType);
|
||||
|
||||
protected:
|
||||
static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper);
|
||||
static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingDisabled(AllocationType allocationType);
|
||||
|
||||
@@ -39,7 +39,7 @@ Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_
|
||||
|
||||
resourceParams.Usage = gmmResourceUsage;
|
||||
resourceParams.Flags.Info.Linear = 1;
|
||||
resourceParams.Flags.Info.Cacheable = !CacheSettingsHelper::isUncachedType(gmmResourceUsage);
|
||||
resourceParams.Flags.Info.Cacheable = CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsage);
|
||||
resourceParams.Flags.Gpu.Texture = 1;
|
||||
|
||||
if (alignedPtr) {
|
||||
|
||||
@@ -521,4 +521,5 @@ ExitOnSubmissionNumber = -1
|
||||
ExitOnSubmissionMode = 0
|
||||
ForceInOrderImmediateCmdListExecution = -1
|
||||
ForceTlbFlush = -1
|
||||
DebugSetMemoryDiagnosticsDelay = -1
|
||||
DebugSetMemoryDiagnosticsDelay = -1
|
||||
EnableCpuCacheForResources = 0
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -8,13 +8,16 @@
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/gmm_helper/gmm_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"
|
||||
|
||||
namespace NEO {
|
||||
using GmmTests = Test<MockExecutionEnvironmentGmmFixture>;
|
||||
TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenGreateGmmThenFlagCachcableIsTrue) {
|
||||
TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenCreateGmmAndFlagEnableCpuCacheForResourcesSetThenFlagCachcableIsTrue) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.EnableCpuCacheForResources.set(1);
|
||||
StorageInfo storageInfo{};
|
||||
for (auto resourceUsageType : {GMM_RESOURCE_USAGE_OCL_IMAGE,
|
||||
GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER,
|
||||
@@ -25,6 +28,19 @@ TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenGreateGmmThenFlagCachcableI
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenCreateGmmAndFlagEnableCpuCacheForResourcesNotSetThenFlagCachcableIsAlwaysFalse) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.EnableCpuCacheForResources.set(0);
|
||||
StorageInfo storageInfo{};
|
||||
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<Gmm>(getGmmHelper(), nullptr, 0, 0, resourceUsageType, false, storageInfo, false);
|
||||
EXPECT_FALSE(gmm->resourceParams.Flags.Info.Cacheable);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, givenResourceUsageTypesUnCachedWhenGreateGmmThenFlagCachcableIsFalse) {
|
||||
StorageInfo storageInfo{};
|
||||
for (auto resourceUsageType : {GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC,
|
||||
|
||||
Reference in New Issue
Block a user