fix: Don't program redundant paging fence semaphores

Related-To: NEO-12197

Don't program semaphore to wait for paging fence if it was
already programmed with the same value

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2024-10-04 15:52:28 +00:00
committed by Compute-Runtime-Automation
parent 490b474ce7
commit a915ef4b7b
6 changed files with 56 additions and 11 deletions

View File

@@ -44,8 +44,12 @@ class WddmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily>
protected:
void kmDafLockAllocations(ResidencyContainer &allocationsForResidency);
void addToEvictionContainer(GraphicsAllocation &gfxAllocation) override;
bool validForEnqueuePagingFence(uint64_t pagingFenceValue) const;
Wddm *wddm;
COMMAND_BUFFER_HEADER_REC *commandBufferHeader;
bool requiresBlockingResidencyHandling = true;
uint64_t lastEnqueuedPagingFenceValue = 0;
};
} // namespace NEO

View File

@@ -84,13 +84,16 @@ SubmissionStatus WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchB
}
batchBuffer.allocationsForResidency = &allocationsForResidency;
// Enqueue wait for paging fence only if it's valid and there's actual paging fence to wait for
auto mustWaitForResidency = this->requiresBlockingResidencyHandling;
mustWaitForResidency |= !this->executionEnvironment.directSubmissionController.get();
batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling = mustWaitForResidency;
auto pagingFenceValue = this->wddm->getCurrentPagingFenceValue();
if (!this->requiresBlockingResidencyHandling && pagingFenceValue > *this->wddm->getPagingFenceAddress()) {
if (this->validForEnqueuePagingFence(pagingFenceValue)) {
auto waitEnqueued = this->enqueueWaitForPagingFence(pagingFenceValue);
if (waitEnqueued) {
batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling = false;
batchBuffer.pagingFenceSemInfo.pagingFenceValue = pagingFenceValue;
this->lastEnqueuedPagingFenceValue = pagingFenceValue;
}
}
@@ -228,4 +231,11 @@ void WddmCommandStreamReceiver<GfxFamily>::addToEvictionContainer(GraphicsAlloca
this->getEvictionAllocations().push_back(&gfxAllocation);
}
template <typename GfxFamily>
bool WddmCommandStreamReceiver<GfxFamily>::validForEnqueuePagingFence(uint64_t pagingFenceValue) const {
return !this->requiresBlockingResidencyHandling &&
pagingFenceValue > *this->wddm->getPagingFenceAddress() &&
pagingFenceValue > this->lastEnqueuedPagingFenceValue;
}
} // namespace NEO