Lazy sequentialization for TSO and PSO via shared memory abstractions