From 7bca33c5fb666e8aac9f5fc7f46059425812fb56 Mon Sep 17 00:00:00 2001 From: foreman Date: Wed, 8 Jan 2020 17:36:14 -0500 Subject: [PATCH] P4 to Git Change 2053967 by gandryey@gera-win10 on 2020/01/08 17:30:34 SWDEV-79445 - OCL generic changes and code clean-up - Propagate the error if flush() failed Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#159 edit --- rocclr/runtime/device/pal/palvirtual.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp index 1b16da57eb..a0a1e2a2a3 100644 --- a/rocclr/runtime/device/pal/palvirtual.cpp +++ b/rocclr/runtime/device/pal/palvirtual.cpp @@ -314,12 +314,6 @@ void VirtualGPU::Queue::addCmdDoppRef(Pal::IGpuMemory* iMem, bool lastDoppCmd, b } bool VirtualGPU::Queue::flush() { - // Stop commands building - if (Pal::Result::Success != iCmdBuffs_[cmdBufIdSlot_]->End()) { - LogError("PAL failed to finalize a command buffer!"); - return false; - } - if (palMemRefs_.size() != 0) { if (Pal::Result::Success != iDev_->AddGpuMemoryReferences(palMemRefs_.size(), &palMemRefs_[0], iQueue_, @@ -330,6 +324,12 @@ bool VirtualGPU::Queue::flush() { palMemRefs_.clear(); } + // Stop commands building + if (Pal::Result::Success != iCmdBuffs_[cmdBufIdSlot_]->End()) { + LogError("PAL failed to finalize a command buffer!"); + return false; + } + // Reset the fence. PAL will reset OS event if (Pal::Result::Success != iDev_->ResetFences(1, &iCmdFences_[cmdBufIdSlot_])) { LogError("PAL failed to reset a fence!"); @@ -430,6 +430,11 @@ bool VirtualGPU::Queue::waitForEvent(uint id) { return true; } + if (id == cmdBufIdCurrent_) { + // There is an error in the flush() and wait is bogus + return false; + } + uint slotId = id % max_command_buffers_; constexpr bool IbReuse = true; bool result = waifForFence(slotId); @@ -444,7 +449,10 @@ bool VirtualGPU::Queue::isDone(uint id) { if (id == cmdBufIdCurrent_) { // Flush the current command buffer - flush(); + if (!flush()) { + // If flush failed, then exit earlier... + return false; + } } if (Pal::Result::Success != iCmdFences_[id % max_command_buffers_]->GetStatus()) {