feature: use WaitUserFence on zeEventHostSynchronize

Disabled by default. Debug flag is required.

Related-To: NEO-7966

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2023-07-25 14:09:20 +00:00
committed by Compute-Runtime-Automation
parent 424784f7cf
commit a241099dff
9 changed files with 116 additions and 4 deletions

View File

@@ -67,6 +67,10 @@ struct EventImp : public Event {
const bool downloadAllocationRequired = false;
protected:
ze_result_t waitForUserFence(uint64_t timeout);
bool handlePreQueryStatusOperationsAndCheckCompletion();
ze_result_t calculateProfilingData();
ze_result_t queryStatusEventPackets();
ze_result_t queryInOrderEventStatus();

View File

@@ -227,7 +227,7 @@ ze_result_t EventImp<TagSizeT>::queryStatusEventPackets() {
}
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::queryStatus() {
bool EventImp<TagSizeT>::handlePreQueryStatusOperationsAndCheckCompletion() {
if (metricStreamer != nullptr) {
hostEventSetValue(metricStreamer->getNotificationState());
}
@@ -241,8 +241,19 @@ ze_result_t EventImp<TagSizeT>::queryStatus() {
}
if (!this->isFromIpcPool && isAlreadyCompleted()) {
return true;
}
return false;
}
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::queryStatus() {
if (handlePreQueryStatusOperationsAndCheckCompletion()) {
return ZE_RESULT_SUCCESS;
} else if (this->inOrderExecEvent) {
}
if (this->inOrderExecEvent) {
return queryInOrderEventStatus();
} else {
return queryStatusEventPackets();
@@ -353,6 +364,23 @@ ze_result_t EventImp<TagSizeT>::hostSignal() {
return status;
}
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::waitForUserFence(uint64_t timeout) {
if (handlePreQueryStatusOperationsAndCheckCompletion()) {
return ZE_RESULT_SUCCESS;
}
uint64_t waitAddress = castToUint64(ptrOffset(this->inOrderExecDataAllocation->getUnderlyingBuffer(), this->inOrderAllocationOffset));
if (!csrs[0]->waitUserFence(this->inOrderExecSignalValue, waitAddress, timeout)) {
return ZE_RESULT_NOT_READY;
}
handleSuccessfulHostSynchronization();
return ZE_RESULT_SUCCESS;
}
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::hostSynchronize(uint64_t timeout) {
std::chrono::microseconds elapsedTimeSinceGpuHangCheck{0};
@@ -372,7 +400,11 @@ ze_result_t EventImp<TagSizeT>::hostSynchronize(uint64_t timeout) {
waitStartTime = std::chrono::high_resolution_clock::now();
lastHangCheckTime = waitStartTime;
do {
ret = queryStatus();
if (NEO::DebugManager.flags.WaitForUserFenceOnEventHostSynchronize.get() == 1 && this->inOrderExecEvent) {
ret = waitForUserFence(timeout);
} else {
ret = queryStatus();
}
if (ret == ZE_RESULT_SUCCESS) {
if (this->getKernelForPrintf() != nullptr) {
static_cast<Kernel *>(this->getKernelForPrintf())->printPrintfOutput(true);