Improve waiting logic in HostPtrManager

Change-Id: Ib762a9604ad3d398044f289fa8a1aa4df2b4d37a
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2019-03-23 12:52:57 +01:00
parent cefa3e3119
commit 2243fc950b
7 changed files with 79 additions and 13 deletions

View File

@@ -7,8 +7,6 @@
#include "runtime/memory_manager/host_ptr_manager.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/memory_manager/memory_manager.h"
using namespace NEO;
@@ -282,22 +280,14 @@ RequirementsStatus HostPtrManager::checkAllocationsForOverlapping(MemoryManager
checkedFragments->fragments[i] = getFragmentAndCheckForOverlaps(requirements->AllocationFragments[i].allocationPtr, requirements->AllocationFragments[i].allocationSize, checkedFragments->status[i]);
if (checkedFragments->status[i] == OverlapStatus::FRAGMENT_OVERLAPING_AND_BIGGER_THEN_STORED_FRAGMENT) {
// clean temporary allocations
auto commandStreamReceiver = memoryManager.getDefaultCommandStreamReceiver(0);
auto allocationStorage = commandStreamReceiver->getInternalAllocationStorage();
uint32_t taskCount = *commandStreamReceiver->getTagAddress();
allocationStorage->cleanAllocationList(taskCount, TEMPORARY_ALLOCATION);
memoryManager.cleanTemporaryAllocationListOnAllEngines(false);
// check overlapping again
checkedFragments->fragments[i] = getFragmentAndCheckForOverlaps(requirements->AllocationFragments[i].allocationPtr, requirements->AllocationFragments[i].allocationSize, checkedFragments->status[i]);
if (checkedFragments->status[i] == OverlapStatus::FRAGMENT_OVERLAPING_AND_BIGGER_THEN_STORED_FRAGMENT) {
// Wait for completion
while (*commandStreamReceiver->getTagAddress() < commandStreamReceiver->peekLatestSentTaskCount())
;
taskCount = *commandStreamReceiver->getTagAddress();
allocationStorage->cleanAllocationList(taskCount, TEMPORARY_ALLOCATION);
memoryManager.cleanTemporaryAllocationListOnAllEngines(true);
// check overlapping last time
checkedFragments->fragments[i] = getFragmentAndCheckForOverlaps(requirements->AllocationFragments[i].allocationPtr, requirements->AllocationFragments[i].allocationSize, checkedFragments->status[i]);

View File

@@ -439,4 +439,14 @@ void MemoryManager::waitForEnginesCompletion(GraphicsAllocation &graphicsAllocat
}
}
void MemoryManager::cleanTemporaryAllocationListOnAllEngines(bool waitForCompletion) {
for (auto &engine : getRegisteredEngines()) {
auto csr = engine.commandStreamReceiver;
if (waitForCompletion) {
csr->waitForCompletionWithTimeout(false, 0, csr->peekLatestSentTaskCount());
}
csr->getInternalAllocationStorage()->cleanAllocationList(*csr->getTagAddress(), AllocationUsage::TEMPORARY_ALLOCATION);
}
}
} // namespace NEO

View File

@@ -165,6 +165,7 @@ class MemoryManager {
void waitForDeletions();
void waitForEnginesCompletion(GraphicsAllocation &graphicsAllocation);
void cleanTemporaryAllocationListOnAllEngines(bool waitForCompletion);
bool isAsyncDeleterEnabled() const;
bool isLocalMemorySupported() const;