Closed BradSwain closed 3 years ago
Yes, there is technically a data race here, but you can reason that it doesn't affect correctness.
Note that the logic inside the critical region can cause dtrec to decrease, but never to increase. So you could have a case where thread A passes the outer if-test, thread B decreases dtrec, and thread A later fails the inner if-test. That still gives correct behavior, since it's the inner test that matters. But the reverse can never happen: if thread A fails the outer if-test, dtchunk >= dtrec, and that continues to be true even if thread B decreases dtrec. So thread A could never have passed the inner if-test, regardless of what other threads did.
Does that make sense?
Sorry for the late reply, and thank you for the explanation. That does make sense to me. We figured we should report this race to be safe, but it does not appear to affect correctness.
We are developing a static race detection tool and it has detected a potential data race in PENNANT. The issue does not appear to be severe, but we thought it best to report anyway, just in case.
The data race occurs on the
dtrec
variable between the write atHydro.cc:601
and the read atHydro.cc:596
https://github.com/lanl/PENNANT/blob/d1fd8cae611e37c492b5c3bbd18f2885531060b7/src/Hydro.cc#L601-L596
Although the write is guarded by a critical section, the read at line 596 is not guarded, and so there is a data race between these two accesses.
I have pasted the full report from our tool below.