Improve pat index programming on linux

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2022-04-11 17:13:44 +00:00
committed by Compute-Runtime-Automation
parent 01a719cf33
commit 884d729e4e
23 changed files with 324 additions and 128 deletions

View File

@@ -38,7 +38,15 @@ MEMORY_OBJECT_CONTROL_STATE MockGmmClientContextBase::cachePolicyGetMemoryObject
}
uint32_t MockGmmClientContextBase::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResourceInfo, GMM_RESOURCE_USAGE_TYPE usage) {
return 1;
if (returnErrorOnPatIndexQuery) {
return MockPatIndex::error;
}
if (usage == GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) {
return MockPatIndex::uncached;
}
return MockPatIndex::cached;
}
} // namespace NEO

View File

@@ -11,6 +11,12 @@
namespace NEO {
class MockGmmClientContextBase : public GmmClientContext {
public:
struct MockPatIndex {
static constexpr uint32_t uncached = 1;
static constexpr uint32_t cached = 2;
static constexpr uint32_t error = GMM_PAT_ERROR;
};
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;
GMM_RESOURCE_INFO *createResInfoObject(GMM_RESCREATE_PARAMS *pCreateParams) override;
@@ -24,6 +30,7 @@ class MockGmmClientContextBase : public GmmClientContext {
uint8_t compressionFormatToReturn = 1;
uint32_t getSurfaceStateCompressionFormatCalled = 0u;
uint32_t getMediaSurfaceStateCompressionFormatCalled = 0u;
bool returnErrorOnPatIndexQuery = false;
protected:
using GmmClientContext::GmmClientContext;

View File

@@ -327,4 +327,9 @@ bool HwInfoConfigHw<IGFX_UNKNOWN>::isComputeDispatchAllWalkerEnableInCfeStateReq
return false;
}
template <>
bool HwInfoConfigHw<IGFX_UNKNOWN>::isVmBindPatIndexProgrammingSupported() const {
return false;
}
} //namespace NEO

View File

@@ -24,9 +24,8 @@ struct DrmDebugPrelimTest : public ::testing::Test {
executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
}
void TearDown() override {
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
}
protected:
@@ -240,10 +239,6 @@ TEST(DrmPrelimTest, givenContextDebugNotAvailableWhenCheckedForSupportThenTrueIs
}
TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinDefaultEngineContextThenExtensionsArePassedToVmBindIoctl) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
MockBufferObject bo(&drm, 0, 0, 1);
@@ -264,10 +259,6 @@ TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinDefaultE
}
TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinInternalContextThenExtensionsAreNotPassedToVmBindIoctl) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
MockBufferObject bo(&drm, 0, 0, 1);
@@ -282,10 +273,6 @@ TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinInternal
}
TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinCopyEngineContextThenExtensionsAreNotPassedToVmBindIoctl) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
MockBufferObject bo(&drm, 0, 0, 1);
@@ -302,10 +289,6 @@ TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinCopyEngi
}
HWTEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenUnbindingThenExtensionsAreNotSet) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
MockBufferObject bo(&drm, 0, 0, 1);
@@ -318,7 +301,7 @@ HWTEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenUnbindingThenExtens
EXPECT_NE(0u, drm.context.receivedVmBind.value().extensions);
bo.unbind(&osContext, 0);
if (HwHelperHw<FamilyType>::get().getNumCacheRegions() > 0) {
if (HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported()) {
EXPECT_NE(0u, drm.context.receivedVmUnbind.value().extensions);
} else {
EXPECT_EQ(0u, drm.context.receivedVmUnbind.value().extensions);

View File

@@ -278,6 +278,7 @@ TEST(DrmBufferObjectTestPrelim, givenBufferObjectSetToColourWithBindWhenBindingT
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
BufferObjectMock bo(&drm, 1, 0, 1);
@@ -334,6 +335,7 @@ TEST(DrmBufferObjectTestPrelim, givenBufferObjectMarkedForCaptureWhenBindingThen
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
BufferObjectMock bo(&drm, 1, 0, 1);
@@ -353,6 +355,7 @@ TEST(DrmBufferObjectTestPrelim, givenNoActiveDirectSubmissionAndForceUseImmediat
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
BufferObjectMock bo(&drm, 1, 0, 1);
@@ -369,6 +372,7 @@ TEST(DrmBufferObjectTestPrelim, whenBindingThenImmediateFlagIsSetAndExtensionLis
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.setDirectSubmissionActive(true);

View File

@@ -19,6 +19,7 @@ TEST(DrmVmBindTest, givenBoRequiringImmediateBindWhenBindingThenImmediateFlagIsP
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
@@ -36,6 +37,7 @@ TEST(DrmVmBindTest, givenBoRequiringExplicitResidencyWhenBindingThenMakeResident
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.pageFaultSupported = true;
@@ -64,6 +66,7 @@ TEST(DrmVmBindTest, givenBoNotRequiringExplicitResidencyWhenCallingWaitForBindTh
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
struct DrmQueryMockToTestWaitForBind : public DrmQueryMock {
@@ -105,6 +108,7 @@ TEST(DrmVmBindTest, givenUseKmdMigrationWhenCallingBindBoOnUnifiedSharedMemoryTh
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
executionEnvironment->initializeMemoryManager();
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);