The memory model for RISC-V, a newly developed open source ISA, has not been finalized yet and thus, offers an opportunity to evaluate existing memory models. We believe RISC-V should not adopt the memory models of POWER or ARM, because their axiomatic and operational definitions are too complicated. We propose two new weak memory models: WMM and WMM-S, which balance definitional simplicity and implementation flexibility differently. Both allow all instruction reorderings except overtaking of loads by a store. We show that this restriction has little impact on performance and it considerably simplifies operational definitions. It also rules out the out-of-thin-air problem that plagues many definitions. WMM is simple (it is similar to the Alpha memory model), but it disallows behaviors arising due to shared store buffers and shared write-through caches (which are seen in POWER processors). WMM-S, on the other hand, is more complex and allows these behaviors. We give the operational definitions of both models using Instantaneous Instruction Execution (I 2 E), which has been used in the definitions of SC and TSO. We also show how both models can be implemented using conventional cache-coherent memory systems and out-of-order processors, and encompasses the behaviors of most known optimizations.
Keywords-weak memory model• Single-copy atomic: a store becomes visible to all processors at the same time, e.g., in SC. • Multi-copy atomic: a store becomes visible to the issuing processor before it is advertised simultaneously to all other processors, e.g., in TSO and Alpha [5]. • Non-atomic (or non-multi-copy-atomic): a store becomes visible to different processors at different times, e.g., in POWER and ARM.Multi-copy atomic stores are caused by the store buffer or write-through cache that is private to each processor. Non-atomic stores arise (mostly) because of the sharing of a store buffer or a write-through cache by multiple processors, and such stores considerably complicate the formal definitions [7], [8]. WMM is an Alpha-like memory model which permits only multi-copy atomic stores and thus, prohibits shared store buffers or shared write-through caches in implementations. WMM-S is an ARM/POWERlike memory model which admits non-atomic stores. We will present the implementations of both models using out-oforder (OOO) processors and cache-coherent memory systems.In particular, WMM and WMM-S allow the OOO processors in multicore settings to use all speculative techniques which are valid for uniprocessors, including even the load-value arXiv:1707.05923v2 [cs.PL] 18 Sep 2018 Atomic Memory … Processor Reg State … (a) SC Atomic Memory … Processor Reg State Store Buffer … (b) TSO/PSO Atomic Memory … Processor Reg State Store Buffer Inv Buffer …
TSO-Nm (non-memory execution)Predicate: The next instruction of a processor is a non-memory instruction. Action: Instruction is executed by local computation. TSO-Ld (load execution) Predicate: The next instruction of a processor is a load. Action: Assume the load address is a. The lo...