iai_callgrind::client_requests::helgrind

Function annotate_happens_before

source
pub fn annotate_happens_before(obj: *const ())
Available on crate feature client_requests_defs only.
Expand description

Create completely arbitrary happens-before edges between threads

If threads T1 … Tn all do annotate_happens_before and later (w.r.t. some notional global clock for the computation) thread Tm does annotate_happens_after, then Helgrind will regard all memory accesses done by T1 … Tn before the …BEFORE… call as happening-before all memory accesses done by Tm after the …AFTER… call. Hence, Helgrind won’t complain about races if Tm’s accesses afterward are to the same locations as accesses before by any of T1 … Tn.

obj is a machine word and completely arbitrary, and denotes the identity of some synchronisation object you’re modelling.

You must do the _BEFORE call just before the real sync event on the signaller’s side, and _AFTER just after the real sync event on the waiter’s side.

If none of the rest of these macros make sense to you, at least take the time to understand these two. They form the very essence of describing arbitrary inter-thread synchronisation events to Helgrind. You can get a long way just with them alone.