Skip to content

Commit 9569817

Browse files
SWDEV-465366 : Deadlock during stream wait opeartion
Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> [rocm-systems] ROCm/rocm-systems#2652 (commit 71856ec)
1 parent f0fa080 commit 9569817

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

rocclr/device/pal/palvirtual.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,12 +3377,29 @@ bool VirtualGPU::waitAllEngines(CommandBatch* cb) {
33773377
}
33783378

33793379
void VirtualGPU::waitEventLock(CommandBatch* cb) {
3380-
bool earlyDone = false;
3380+
bool earlyDone = true;
3381+
GpuEvent eventsCopy[AllEngines];
3382+
33813383
{
3382-
// Make sure VirtualGPU has an exclusive access to the resources
33833384
amd::ScopedLock lock(execution());
3384-
earlyDone = waitAllEngines(cb);
3385+
3386+
GpuEvent* events = (cb == nullptr) ? events_ : cb->events_;
3387+
3388+
// The first loop is to flush all engines and/or check if
3389+
// engines are idle already
3390+
for (uint i = 0; i < AllEngines; ++i) {
3391+
eventsCopy[i] = events[i];
3392+
earlyDone &= isDone(&events[i]);
3393+
}
3394+
3395+
// Release all pinned memory
3396+
releasePinnedMem();
3397+
}
3398+
3399+
for (uint i = 0; i < AllEngines; ++i) {
3400+
waitForEvent(&eventsCopy[i]);
33853401
}
3402+
33863403
// Get timestamp, incase readjustTimeGPU_ needs to be updated
33873404
uint64_t endTimeStampCPU = amd::Os::timeNanos();
33883405

0 commit comments

Comments
 (0)