Do not make resident something that is already resident.

Move checks to upper layers.
100ns gain in ZE_AFFINITY_MASK=0.0 PrintDebugSettings=1
./api_overhead_benchmark_l0 --test=ExecuteCommandListImmediate --api=l0
--UseProfiling=0 --CallsCount=1 --MeasureCompletionTime=0
--useBarrierSynchronization=0 --KernelExecutionTime=1 --iterations=1000

Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2022-09-20 15:18:18 +00:00
committed by Compute-Runtime-Automation
parent faf8d51f6d
commit bddf8c7dbc
3 changed files with 13 additions and 5 deletions

View File

@@ -141,6 +141,9 @@ class BufferObject {
static constexpr int gpuHangDetected{-7171};
uint32_t getOsContextId(OsContext *osContext);
std::vector<std::array<bool, EngineLimits::maxHandleCount>> bindInfo;
protected:
MOCKABLE_VIRTUAL MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded);
@@ -158,7 +161,6 @@ class BufferObject {
bool requiresImmediateBinding = false;
bool requiresExplicitResidency = false;
uint32_t getOsContextId(OsContext *osContext);
MOCKABLE_VIRTUAL void fillExecObject(ExecObject &execObject, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId);
void printBOBindingResult(OsContext *osContext, uint32_t vmHandleId, bool bind, int retVal);
@@ -170,7 +172,6 @@ class BufferObject {
CacheRegion cacheRegion = CacheRegion::Default;
CachePolicy cachePolicy = CachePolicy::WriteBack;
std::vector<std::array<bool, EngineLimits::maxHandleCount>> bindInfo;
StackVec<uint32_t, 2> bindExtHandles;
bool colourWithBind = false;

View File

@@ -47,16 +47,21 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsConte
for (auto gfxAllocation = gfxAllocations.begin(); gfxAllocation != gfxAllocations.end(); gfxAllocation++) {
auto drmAllocation = static_cast<DrmAllocation *>(*gfxAllocation);
auto bo = drmAllocation->storageInfo.getNumBanks() > 1 ? drmAllocation->getBOs()[drmIterator] : drmAllocation->getBO();
int result = drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, true);
if (result) {
return MemoryOperationsStatus::OUT_OF_MEMORY;
if (!bo->bindInfo[bo->getOsContextId(osContext)][drmIterator]) {
int result = drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, true);
if (result) {
return MemoryOperationsStatus::OUT_OF_MEMORY;
}
}
if (!evictable) {
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, osContext->getContextId());
}
}
}
return MemoryOperationsStatus::SUCCESS;
}

View File

@@ -402,6 +402,8 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenMakeBOsResidentFailsThenMakeResi
auto size = 1024u;
BufferObjects bos;
BufferObject mockBo(mock, 3, 1, 0, 1);
bos.push_back(&mockBo);
auto allocation = new MockDrmAllocationBOsResident(0, AllocationType::UNKNOWN, bos, nullptr, 0u, size, MemoryPool::LocalMemory);
auto graphicsAllocation = static_cast<GraphicsAllocation *>(allocation);