mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
Bind buffer object before calling vm prefetch
Related-To: NEO-6740 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5a9292b3bc
commit
9f36b20423
@@ -238,6 +238,14 @@ bool DrmMemoryManager::setMemAdvise(GraphicsAllocation *gfxAllocation, MemAdvise
|
||||
|
||||
bool DrmMemoryManager::setMemPrefetch(GraphicsAllocation *gfxAllocation, uint32_t subDeviceId, uint32_t rootDeviceIndex) {
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(gfxAllocation);
|
||||
auto osContextLinux = static_cast<OsContextLinux *>(registeredEngines[defaultEngineIndex[rootDeviceIndex]].osContext);
|
||||
auto vmHandleId = subDeviceId;
|
||||
|
||||
auto retVal = drmAllocation->bindBOs(osContextLinux, vmHandleId, nullptr, true);
|
||||
if (retVal != 0) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return drmAllocation->setMemPrefetch(&this->getDrm(rootDeviceIndex), subDeviceId);
|
||||
}
|
||||
|
||||
@@ -54,8 +54,16 @@ class MockDrmAllocation : public DrmAllocation {
|
||||
DrmAllocation::markForCapture();
|
||||
}
|
||||
|
||||
int bindBOs(OsContext *osContext, uint32_t vmHandleId, std::vector<BufferObject *> *bufferObjects, bool bind) override {
|
||||
bindBOsCalled = true;
|
||||
DrmAllocation::bindBOs(osContext, vmHandleId, bufferObjects, bind);
|
||||
return bindBOsRetValue;
|
||||
}
|
||||
|
||||
bool registerBOBindExtHandleCalled = false;
|
||||
bool markedForCapture = false;
|
||||
bool bindBOsCalled = false;
|
||||
int bindBOsRetValue = 0;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -4041,10 +4041,36 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetMemPrefetchIsCalledThen
|
||||
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
|
||||
BufferObject bo(mock, 3, 1, 1024, 0);
|
||||
|
||||
DrmAllocation drmAllocation(0, AllocationType::UNIFIED_SHARED_MEMORY, &bo, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
||||
EXPECT_EQ(&bo, drmAllocation.getBO());
|
||||
MockDrmAllocation drmAllocation(AllocationType::UNIFIED_SHARED_MEMORY, MemoryPool::LocalMemory);
|
||||
drmAllocation.bufferObjects[0] = &bo;
|
||||
|
||||
memoryManager.registeredEngines = EngineControlContainer{this->device->allEngines};
|
||||
for (auto engine : memoryManager.registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
|
||||
EXPECT_TRUE(memoryManager.setMemPrefetch(&drmAllocation, 0, rootDeviceIndex));
|
||||
|
||||
EXPECT_TRUE(drmAllocation.bindBOsCalled);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetMemPrefetchFailsToBindBufferObjectThenReturnFalse) {
|
||||
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
|
||||
BufferObject bo(mock, 3, 1, 1024, 0);
|
||||
|
||||
MockDrmAllocation drmAllocation(AllocationType::UNIFIED_SHARED_MEMORY, MemoryPool::LocalMemory);
|
||||
drmAllocation.bufferObjects[0] = &bo;
|
||||
|
||||
memoryManager.registeredEngines = EngineControlContainer{this->device->allEngines};
|
||||
for (auto engine : memoryManager.registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
|
||||
drmAllocation.bindBOsRetValue = -1;
|
||||
|
||||
EXPECT_FALSE(memoryManager.setMemPrefetch(&drmAllocation, 0, rootDeviceIndex));
|
||||
|
||||
EXPECT_TRUE(drmAllocation.bindBOsCalled);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenPageFaultIsUnSupportedWhenCallingBindBoOnBufferAllocationThenAllocationShouldNotPageFaultAndExplicitResidencyIsNotRequired) {
|
||||
|
||||
Reference in New Issue
Block a user