Skip to content

Commit 0d42fdf

Browse files
Fix setting flag Cacheable in gmm resource params base on resource usage
Signed-off-by: Katarzyna Cencelewska <[email protected]>
1 parent c6c9ed2 commit 0d42fdf

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

shared/source/gmm_helper/gmm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_
3737

3838
resourceParams.Usage = gmmResourceUsage;
3939
resourceParams.Flags.Info.Linear = 1;
40-
resourceParams.Flags.Info.Cacheable = 1;
40+
resourceParams.Flags.Info.Cacheable = !CacheSettingsHelper::isUncachedType(gmmResourceUsage);
4141
resourceParams.Flags.Gpu.Texture = 1;
4242

4343
if (alignedPtr) {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#
2-
# Copyright (C) 2021 Intel Corporation
2+
# Copyright (C) 2021-2022 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
66

77
target_sources(${TARGET_NAME} PRIVATE
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}/gmm_resource_info_tests.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}/gmm_tests.cpp
1011
)
1112

1213
add_subdirectories()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2022 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/gmm_helper/gmm.h"
9+
#include "shared/source/gmm_helper/gmm_helper.h"
10+
#include "shared/test/common/fixtures/mock_execution_environment_gmm_fixture.h"
11+
#include "shared/test/common/mocks/mock_execution_environment.h"
12+
#include "shared/test/common/mocks/mock_gmm.h"
13+
#include "shared/test/common/test_macros/test.h"
14+
15+
namespace NEO {
16+
using GmmTests = Test<MockExecutionEnvironmentGmmFixture>;
17+
TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenGreateGmmThenFlagCachcableIsTrue) {
18+
StorageInfo storageInfo{};
19+
for (auto resourceUsageType : {GMM_RESOURCE_USAGE_OCL_IMAGE,
20+
GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER,
21+
GMM_RESOURCE_USAGE_OCL_BUFFER_CONST,
22+
GMM_RESOURCE_USAGE_OCL_BUFFER}) {
23+
auto gmm = std::make_unique<Gmm>(getGmmHelper(), nullptr, 0, 0, resourceUsageType, false, storageInfo, false);
24+
EXPECT_TRUE(gmm->resourceParams.Flags.Info.Cacheable);
25+
}
26+
}
27+
28+
TEST_F(GmmTests, givenResourceUsageTypesUnCachedWhenGreateGmmThenFlagCachcableIsFalse) {
29+
StorageInfo storageInfo{};
30+
for (auto resourceUsageType : {GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC,
31+
GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED,
32+
GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED}) {
33+
auto gmm = std::make_unique<Gmm>(getGmmHelper(), nullptr, 0, 0, resourceUsageType, false, storageInfo, false);
34+
EXPECT_FALSE(gmm->resourceParams.Flags.Info.Cacheable);
35+
}
36+
}
37+
} // namespace NEO

0 commit comments

Comments
 (0)