Synchronize before CPU memcpy after wait on events

Currently we track dependencies only in append
barrier call. This commit adds tracking for
append waitOnEvents so CPU memcpy correctly
waits for such dependency.

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2022-10-25 07:55:02 +00:00
committed by Compute-Runtime-Automation
parent 8980b2b817
commit f5355912ab
4 changed files with 28 additions and 10 deletions

View File

@@ -141,7 +141,7 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily<gfxCoreFami
bool waitForEventsFromHost();
protected:
std::atomic<bool> barrierCalled{false};
std::atomic<bool> dependenciesPresent{false};
};
template <PRODUCT_FAMILY gfxProductFamily>

View File

@@ -279,7 +279,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendBarrier(
}
ret = CommandListCoreFamily<gfxCoreFamily>::appendBarrier(hSignalEvent, numWaitEvents, phWaitEvents);
this->barrierCalled = true;
this->dependenciesPresent = true;
return flushImmediate(ret, true, hSignalEvent);
}
@@ -431,6 +431,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendWaitOnEvents(ui
checkAvailableSpace();
}
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendWaitOnEvents(numEvents, phWaitEvents);
this->dependenciesPresent = true;
return flushImmediate(ret, true, nullptr);
}
@@ -592,7 +593,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::performCpuMemcpy(void
this->appendBarrier(nullptr, numWaitEvents, phWaitEvents);
}
if (this->barrierCalled) {
if (this->dependenciesPresent) {
this->csr->flushTagUpdate();
}
@@ -611,13 +612,13 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::performCpuMemcpy(void
cpuMemcpyDstPtr = dstptr;
}
if (this->barrierCalled) {
if (this->dependenciesPresent) {
auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout;
const auto waitStatus = this->csr->waitForCompletionWithTimeout(NEO::WaitParams{false, false, timeoutMicroseconds}, this->csr->peekTaskCount());
if (waitStatus == NEO::WaitStatus::GpuHang) {
return ZE_RESULT_ERROR_DEVICE_LOST;
}
this->barrierCalled = false;
this->dependenciesPresent = false;
}
if (signalEvent) {