Files
compute-runtime/shared/test/unit_test/gmm_helper/gmm_tests.cpp
Katarzyna Cencelewska 004a3d875c 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>
2023-05-16 09:17:29 +02:00

54 lines
2.6 KiB
C++

/*
* Copyright (C) 2022-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#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, 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,
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_TRUE(gmm->resourceParams.Flags.Info.Cacheable);
}
}
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,
GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED,
GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED}) {
auto gmm = std::make_unique<Gmm>(getGmmHelper(), nullptr, 0, 0, resourceUsageType, false, storageInfo, false);
EXPECT_FALSE(gmm->resourceParams.Flags.Info.Cacheable);
}
}
} // namespace NEO