Dat3M icon indicating copy to clipboard operation
Dat3M copied to clipboard

Reads-from exactly one

Open hernanponcedeleon opened this issue 3 years ago • 3 comments

According to this (page 149, point 1), the fact that a load reads-from exactly one store is guaranteed by the totality of co and the definition of fr, so we can replace the exactly one (which could be hard for the solver) by an or.

hernanponcedeleon avatar Nov 03 '21 06:11 hernanponcedeleon

Note that Sc-per-Loc is enough to make this optimization possible for all memory models (not sure about C11 though). In full generality it may fail though. Unfortunately, this is the case for Refinement without any bias model so this option must be configurable.

ThomasHaas avatar Nov 03 '21 09:11 ThomasHaas

Consider the case where a load rf two stores, and without loss of generality we assume a particular co-order between them

Wx1 -rf-> Rx
Wx2 -rf-> Rx
Wx1 -co-> Wx2

This would form a cycle in Rx -rf^{-1}-> Wx1 -co-> Wx2 -rf-> Rx. I think the simpler assumption where this simplification is sound is if the WMM guarantees acyclic(fr U rf). However, to avoid a super specific flag and since most WMM will have Sc-per-Loc, we can enable this optimisation using the ASSUME_LOCAL_CONSISTENCY flag in GlobalSettings.

hernanponcedeleon avatar Nov 04 '21 10:11 hernanponcedeleon

Local consistency =/= SC-per-Loc though. Local consistency is even weaker and is basically Sc-per-thread (or Sc-per-thread-per-loc?). I think we should add a second flag for SC-Per-Loc or alternatively a flag Read_Relaxation. You cannot put it into Local consistency as Refinement works fine with local consistency but not with the read relaxation! I think all non-refinement tasks can enable this flag and refinement enables it only if Sc-per-Loc bias is used, otherwise it disables it. We could also make Refinement work with this, by splitting an execution with multiple reads into multiple executions with single reads and refine all of them! This needs some work, but it could actually leverage this optimization in a nice way

ThomasHaas avatar Nov 04 '21 11:11 ThomasHaas