Skip to content

Commit 2bb39a8

Browse files
[L0] Added wait function to prevent race condition with urEventWait
Signed-off-by: Winston Zhang <[email protected]>
1 parent 63546cc commit 2bb39a8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/adapters/level_zero/event.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
//===----------------------------------------------------------------------===//
1010

1111
#include <algorithm>
12+
#include <chrono>
1213
#include <climits>
1314
#include <mutex>
1415
#include <optional>
1516
#include <string.h>
17+
#include <thread>
1618

1719
#include "command_buffer.hpp"
1820
#include "common.hpp"
@@ -823,6 +825,9 @@ urEventWait(uint32_t NumEvents, ///< [in] number of events in the event list
823825
Queues.insert(Q);
824826
}
825827
}
828+
// Added to prevent race condition when using counter-based events.
829+
if (Event->CounterBasedEventsEnabled)
830+
std::this_thread::sleep_for(std::chrono::nanoseconds(1));
826831
}
827832
}
828833

0 commit comments

Comments
 (0)