|
| 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