Pass compression and cachable params to CachePolicyGetPATIndex query

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz 2022-09-21 12:49:45 +00:00 committed by Compute-Runtime-Automation
parent 910bffb752
commit 34eabf2960
8 changed files with 69 additions and 21 deletions

View File

@ -7,7 +7,6 @@
set(NEO_CORE_GMM_HELPER
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}resource_info_${DRIVER_MODEL}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_context${BRANCH_DIR_SUFFIX}/gmm_client_context_extra.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.h
${CMAKE_CURRENT_SOURCE_DIR}/cache_settings_helper.cpp

View File

@ -79,4 +79,13 @@ void GmmClientContext::setGmmDeviceInfo(GMM_DEVICE_INFO *deviceInfo) {
clientContext->GmmSetDeviceInfo(deviceInfo);
}
uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cachable) {
bool outValue = compressed;
uint32_t patIndex = clientContext->CachePolicyGetPATIndex(gmmResourceInfo, usage, &outValue, cachable);
DEBUG_BREAK_IF(outValue != compressed);
return patIndex;
}
} // namespace NEO

View File

@ -22,7 +22,7 @@ class GmmClientContext {
MOCKABLE_VIRTUAL ~GmmClientContext();
MOCKABLE_VIRTUAL MEMORY_OBJECT_CONTROL_STATE cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage);
MOCKABLE_VIRTUAL uint32_t cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage);
MOCKABLE_VIRTUAL uint32_t cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cachable);
MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams);
MOCKABLE_VIRTUAL GMM_RESOURCE_INFO *copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes);

View File

@ -1,16 +0,0 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
namespace NEO {
uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage) {
return 0;
}
} // namespace NEO

View File

@ -1313,13 +1313,17 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c
GMM_RESOURCE_INFO *resourceInfo = nullptr;
GMM_RESOURCE_USAGE_TYPE usageType = CacheSettingsHelper::getGmmUsageType(allocationType, false, *hwInfo);
bool cachable = !CacheSettingsHelper::isUncachedType(usageType);
bool compressed = false;
if (gmm) {
resourceInfo = gmm->gmmResourceInfo->peekGmmResourceInfo();
usageType = gmm->resourceParams.Usage;
compressed = gmm->isCompressionEnabled;
cachable = gmm->gmmResourceInfo->getResourceFlags()->Info.Cacheable;
}
uint64_t patIndex = rootDeviceEnvironment.getGmmClientContext()->cachePolicyGetPATIndex(resourceInfo, usageType);
uint64_t patIndex = rootDeviceEnvironment.getGmmClientContext()->cachePolicyGetPATIndex(resourceInfo, usageType, compressed, cachable);
if (DebugManager.flags.ClosEnabled.get() != -1) {
closEnabled = !!DebugManager.flags.ClosEnabled.get();

View File

@ -37,7 +37,10 @@ MEMORY_OBJECT_CONTROL_STATE MockGmmClientContextBase::cachePolicyGetMemoryObject
return retVal;
}
uint32_t MockGmmClientContextBase::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage) {
uint32_t MockGmmClientContextBase::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cachable) {
passedCompressedSettingForGetPatIndexQuery = compressed;
passedCachableSettingForGetPatIndexQuery = cachable;
if (returnErrorOnPatIndexQuery) {
return MockPatIndex::error;
}

View File

@ -18,7 +18,7 @@ class MockGmmClientContextBase : public GmmClientContext {
};
MEMORY_OBJECT_CONTROL_STATE cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage) override;
uint32_t cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage) override;
uint32_t cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage, bool compressed, bool cachable) override;
GMM_RESOURCE_INFO *createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams) override;
GMM_RESOURCE_INFO *copyResInfoObject(GMM_RESOURCE_INFO *pSrcRes) override;
void destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo) override;
@ -32,6 +32,9 @@ class MockGmmClientContextBase : public GmmClientContext {
uint32_t getMediaSurfaceStateCompressionFormatCalled = 0u;
bool returnErrorOnPatIndexQuery = false;
bool passedCompressedSettingForGetPatIndexQuery = false;
bool passedCachableSettingForGetPatIndexQuery = false;
protected:
using GmmClientContext::GmmClientContext;
};

View File

@ -21,6 +21,7 @@
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_gfx_partition.h"
#include "shared/test/common/mocks/mock_gmm.h"
#include "shared/test/common/mocks/mock_gmm_client_context_base.h"
#include "shared/test/common/os_interface/linux/drm_memory_manager_fixture.h"
#include "shared/test/common/os_interface/linux/drm_mock_cache_info.h"
#include "shared/test/common/test_macros/hw_test.h"
@ -4841,6 +4842,51 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenPatIndex
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenCompressedAndCachableAllocationWhenQueryingPatIndexThenPassCorrectParams) {
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = 1;
allocData.flags.allocateMemory = true;
allocData.type = AllocationType::BUFFER;
allocData.rootDeviceIndex = rootDeviceIndex;
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_NE(nullptr, allocation);
auto drmAllocation = static_cast<DrmAllocation *>(allocation);
ASSERT_NE(nullptr, drmAllocation->getBO());
auto isVmBindPatIndexProgrammingSupported = HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported();
if (isVmBindPatIndexProgrammingSupported) {
auto mockClientContext = static_cast<MockGmmClientContextBase *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getGmmClientContext());
auto gmm = allocation->getDefaultGmm();
{
gmm->isCompressionEnabled = true;
gmm->gmmResourceInfo->getResourceFlags()->Info.Cacheable = 1;
mock->getPatIndex(allocation->getDefaultGmm(), allocation->getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false);
EXPECT_TRUE(mockClientContext->passedCachableSettingForGetPatIndexQuery);
EXPECT_TRUE(mockClientContext->passedCompressedSettingForGetPatIndexQuery);
}
{
gmm->isCompressionEnabled = false;
gmm->gmmResourceInfo->getResourceFlags()->Info.Cacheable = 0;
mock->getPatIndex(allocation->getDefaultGmm(), allocation->getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false);
EXPECT_FALSE(mockClientContext->passedCachableSettingForGetPatIndexQuery);
EXPECT_FALSE(mockClientContext->passedCompressedSettingForGetPatIndexQuery);
}
}
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedForImageThenLocalMemoryAllocationIsReturnedFromStandard64KbHeap) {
ImageDescriptor imgDesc = {};
imgDesc.imageType = ImageType::Image2D;