mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Fix race in events scenarios.
- It could happen that 2 threads try to update the same event within tree - First thread starts to submit command, it releases cmdToSubmit - Second thread doesn't see the command and follows - Second thread thinks that it submitted the command so it follows to subsequent steps which are child events notification - We end up with corrupted enqueue sequence as child may submit prior to parent. - With this change each submit step is synchronized basing on task count - When second thread enters submit command without task count being set it wait for first thread to properly set it. Change-Id: Ic2ddaea17f9af8cab6781320edae2c268dd0b189 Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
d724b9ab11
commit
6ffcd51847
@@ -120,6 +120,7 @@ TEST_F(EventTests, givenoneThreadUpdatingUserEventAnotherWaitingOnFinishWhenFini
|
||||
cl_event returnedEvent = nullptr;
|
||||
|
||||
std::atomic_bool go{false};
|
||||
std::atomic_bool updateEvent{true};
|
||||
|
||||
std::thread t([&]() {
|
||||
while (!go)
|
||||
@@ -132,7 +133,9 @@ TEST_F(EventTests, givenoneThreadUpdatingUserEventAnotherWaitingOnFinishWhenFini
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
std::thread t2([&]() {
|
||||
castToObject<Event>(returnedEvent)->updateExecutionStatus();
|
||||
while (updateEvent) {
|
||||
castToObject<Event>(returnedEvent)->updateExecutionStatus();
|
||||
}
|
||||
});
|
||||
|
||||
go = true;
|
||||
@@ -141,6 +144,7 @@ TEST_F(EventTests, givenoneThreadUpdatingUserEventAnotherWaitingOnFinishWhenFini
|
||||
EXPECT_EQ(pCmdQ->latestTaskCountWaited, i + 1);
|
||||
|
||||
t.join();
|
||||
updateEvent = false;
|
||||
t2.join();
|
||||
clReleaseEvent(returnedEvent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user