fix: Add missing checks in multi gpu scenario

- Check allocation root device index during eviction
- Wait for and marked allocation only from the current root device index

Related-To: NEO-7920
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala 2023-04-24 13:50:19 +00:00 committed by Compute-Runtime-Automation
parent d4de925711
commit 16db7cc890
3 changed files with 21 additions and 13 deletions

View File

@ -554,7 +554,7 @@ bool Context::BufferPoolAllocator::BufferPool::isPoolBuffer(const MemObj *buffer
void Context::BufferPoolAllocator::BufferPool::drain() {
for (auto allocation : mainStorage->getMultiGraphicsAllocation().getGraphicsAllocations()) {
if (memoryManager->allocInUse(*allocation)) {
if (allocation && memoryManager->allocInUse(*allocation)) {
return;
}
}

View File

@ -800,24 +800,28 @@ bool MemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllo
}
void MemoryManager::waitForEnginesCompletion(GraphicsAllocation &graphicsAllocation) {
for (auto &engine : getRegisteredEngines()) {
auto osContextId = engine.osContext->getContextId();
auto allocationTaskCount = graphicsAllocation.getTaskCount(osContextId);
if (graphicsAllocation.isUsedByOsContext(osContextId) &&
engine.commandStreamReceiver->getTagAllocation() != nullptr &&
allocationTaskCount > *engine.commandStreamReceiver->getTagAddress()) {
engine.commandStreamReceiver->waitForCompletionWithTimeout(WaitParams{false, false, TimeoutControls::maxTimeout}, allocationTaskCount);
if (graphicsAllocation.getRootDeviceIndex() == engine.osContext->getRootDeviceIndex()) {
auto osContextId = engine.osContext->getContextId();
auto allocationTaskCount = graphicsAllocation.getTaskCount(osContextId);
if (graphicsAllocation.isUsedByOsContext(osContextId) &&
engine.commandStreamReceiver->getTagAllocation() != nullptr &&
allocationTaskCount > *engine.commandStreamReceiver->getTagAddress()) {
engine.commandStreamReceiver->waitForCompletionWithTimeout(WaitParams{false, false, TimeoutControls::maxTimeout}, allocationTaskCount);
}
}
}
}
bool MemoryManager::allocInUse(GraphicsAllocation &graphicsAllocation) {
for (auto &engine : getRegisteredEngines()) {
auto osContextId = engine.osContext->getContextId();
auto allocationTaskCount = graphicsAllocation.getTaskCount(osContextId);
if (graphicsAllocation.isUsedByOsContext(osContextId) &&
engine.commandStreamReceiver->getTagAllocation() != nullptr &&
allocationTaskCount > *engine.commandStreamReceiver->getTagAddress()) {
return true;
if (graphicsAllocation.getRootDeviceIndex() == engine.osContext->getRootDeviceIndex()) {
auto osContextId = engine.osContext->getContextId();
auto allocationTaskCount = graphicsAllocation.getTaskCount(osContextId);
if (graphicsAllocation.isUsedByOsContext(osContextId) &&
engine.commandStreamReceiver->getTagAllocation() != nullptr &&
allocationTaskCount > *engine.commandStreamReceiver->getTagAddress()) {
return true;
}
}
}
return false;

View File

@ -167,6 +167,10 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::evictUnusedAllocationsImp
for (auto &allocation : allocationsForEviction) {
bool evict = true;
if (allocation->getRootDeviceIndex() != this->rootDeviceIndex) {
continue;
}
for (const auto &engine : engines) {
if (this->rootDeviceIndex == engine.commandStreamReceiver->getRootDeviceIndex() &&
engine.osContext->getDeviceBitfield().test(subdeviceIndex)) {