mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Improve waiting logic in HostPtrManager
Change-Id: Ib762a9604ad3d398044f289fa8a1aa4df2b4d37a Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
@@ -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]);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -165,6 +165,7 @@ class MemoryManager {
|
||||
|
||||
void waitForDeletions();
|
||||
void waitForEnginesCompletion(GraphicsAllocation &graphicsAllocation);
|
||||
void cleanTemporaryAllocationListOnAllEngines(bool waitForCompletion);
|
||||
|
||||
bool isAsyncDeleterEnabled() const;
|
||||
bool isLocalMemorySupported() const;
|
||||
|
||||
Reference in New Issue
Block a user