Abstract
A memory consistency model specifies which writes to shared memory a given read may see. Ambiguities or errors in these specifications can lead to bugs in both compilers and applications. Yet architectures usually define their memory models with prose and litmus tests—small concurrent programs that demonstrate allowed and forbidden outcomes. Recent work has formalized the memory models of common architectures through substantial manual effort, but as new architectures emerge, there is a growing need for tools to aid these efforts.
This paper presents MemSynth, a synthesis-aided system for reasoning about axiomatic specifications of memory models. MemSynth takes as input a set of litmus tests and a framework sketch that defines a class of memory models. The sketch comprises a set of axioms with missing expressions (or holes). Given these inputs, MemSynth synthesizes a completion of the axioms—i.e., a memory model—that gives the desired outcome on all tests. The MemSynth engine employs a novel embedding of bounded relational logic in a solver-aided programming language, which enables it to tackle complex synthesis queries intractable to existing relational solvers. This design also enables it to solve new kinds of queries, such as checking if a set of litmus tests unambiguously defines a memory model within a framework sketch.
We show that MemSynth can synthesize specifications for x86 in under two seconds, and for PowerPC in 12 seconds from 768 litmus tests. Our ambiguity check identifies missing tests from both the Intel x86 documentation and the validation suite of a previous PowerPC formalization. We also used MemSynth to reproduce, debug, and automatically repair a paper on comparing memory models in just two days.
Supplemental Material
Available for Download
We have provided a VirtualBox image containing the implementation of MemSynth. The image contains implementations for the paper's experimental evaluation (Section 6).
- S. V. Adve and M. D. Hill. Weak ordering - a new definition. In ISCA, 1990. Google Scholar
Digital Library
- J. Alglave. A formal hierarchy of weak memory models. Form. Methods Syst. Des., 41(2), 2012. Google Scholar
Digital Library
- J. Alglave. Modeling of Architectures. In Advanced Lectures of the 15th International School on Formal Methods, 2015.Google Scholar
Cross Ref
- J. Alglave and L. Maranget. The Phat Experiment. http: //diy.inria.fr/phat/, 2010.Google Scholar
- J. Alglave, A. Fox, S. Ishtiaq, M. O. Myreen, S. Sarkar, P. Sewell, and F. Zappa Nardelli. The semantics of Power and ARM multiprocessor machine code. In DAMP, 2009. Google Scholar
Digital Library
- J. Alglave, L. Maranget, S. Sarkar, and P. Sewell. Fences in weak memory models. In CAV, 2010. Google Scholar
Digital Library
- J. Alglave, L. Maranget, S. Sarkar, and P. Sewell. Litmus: Running tests against hardware. In TACAS, 2011. Google Scholar
Digital Library
- J. Alglave, L. Maranget, and M. Tautschnig. Herding cats: Modelling, simulation, testing, and data mining for weak memory. ACM Trans. Program. Lang. Syst., 36(2), 2014. Google Scholar
Digital Library
- J. Alglave, M. Batty, A. F. Donaldson, G. Gopalakrishnan, J. Ketema, D. Poetzl, T. Sorensen, and J. Wickerson. GPU concurrency: Weak behaviors and programming assumptions. In ASPLOS, 2015. Google Scholar
Digital Library
- R. Alur and M. M. K. Martin. Personal communication, July 2016.Google Scholar
- M. Batty, S. Owens, S. Sarkar, P. Sewell, and W. Weber. Mathematizing C++ concurrency. In POPL, 2011. Google Scholar
Digital Library
- M. Batty, A. F. Donaldson, and J. Wickerson. Overhauling SC atomics in C11 and OpenCL. In POPL, 2016. Google Scholar
Digital Library
- J. Bornholt, E. Torlak, D. Grossman, and L. Ceze. Optimizing synthesis with metasketches. In POPL, 2016. Google Scholar
Digital Library
- S. Burckhardt and M. Musuvathi. Effective program verification for relaxed memory models. In CAV, 2008. Google Scholar
Digital Library
- J. Burnim, K. Sen, and C. Stergiou. Sound and complete monitoring of sequential consistency for relaxed memory models. In TACAS, 2011. Google Scholar
Digital Library
- Compaq. Alpha Architecture Reference Manual. 4th edition, 2002.Google Scholar
- J. Crawford, M. Ginsberg, E. Luks, and A. Roy. Symmetrybreaking predicates for search problems. In KR, 1996. Google Scholar
Digital Library
- A. Dan, Y. Meshman, M. Vechev, and E. Yahav. Effective abstractions for verification under relaxed memory models. In VMCAI, 2015. Google Scholar
Digital Library
- L. De Moura and N. Bjørner. Z3: An efficient SMT solver. In TACAS, 2008. Google Scholar
Digital Library
- B. Demsky and P. Lam. SATCheck: SAT-directed stateless model checking for SC and TSO. In OOPSLA, 2015. Google Scholar
Digital Library
- M. Flatt and PLT. Reference: Racket. Technical Report PLTTR-2010-1, PLT Design Inc., 2010.Google Scholar
- IBM. Power ISA Version 2.06 Revision B. IBM, 2010.Google Scholar
- Intel Corporation. Intel 64 and IA-32 Architectures Software Developer’s Manual. Intel Corporation, 2015. Revision 53.Google Scholar
- D. Jackson. Software Abstractions: logic, language, and analysis. MIT Press, 2nd edition, 2009. Google Scholar
Digital Library
- L. Lamport. Time, clocks, and the ordering of events in a distributed system. Commun. ACM, 21(7), 1978. Google Scholar
Digital Library
- D. Lustig, M. Pellauer, and M. Martonosi. PipeCheck: Specifying and verifying microarchitectural enforcement of memory consistency models. In MICRO, 2014. Google Scholar
Digital Library
- D. Lustig, A. Wright, A. Papakonstantinou, and O. Giroux. Automated synthesis of comprehensive memory model litmus test suites. In ASPLOS, 2017. Google Scholar
Digital Library
- S. Mador-Haim, R. Alur, and M. M. K. Martin. Generating litmus tests for contrasting memory consistency models. In CAV, 2010. Google Scholar
Digital Library
- S. Mador-Haim, R. Alur, and M. M. K. Martin. Litmus tests for comparing memory consistency models: How long do they need to be? In DAC, 2011. Google Scholar
Digital Library
- S. Mador-Haim, L. Maranget, S. Sarkar, K. Memarian, J. Alglave, S. Owens, R. Alur, M. M. K. Martin, P. Sewell, and D. Williams. An axiomatic memory model for POWER multiprocessors. In CAV, 2012. Google Scholar
Digital Library
- J. Manson, W. Pugh, and S. V. Adve. The Java memory model. In POPL, 2005. Google Scholar
Digital Library
- P. E. McKenney. A Formal Model of Linux-Kernel Memory Ordering. Linux Plumbers Conference, 2016.Google Scholar
- A. Milicevic, J. P. Near, E. Kang, and D. Jackson. Alloy ∗ : A general-purpose higher-order relational constraint solver. In ICSE, 2015. Google Scholar
Digital Library
- S. Owens, S. Sarkar, and P. Sewell. A better x86 memory model: x86-TSO (extended version). Technical Report UCAMCL-TR-745, University of Cambridge, 2009.Google Scholar
- S. Owens, S. Sarkar, and P. Sewell. A better x86 memory model: x86-TSO. In TPHOLs, 2009. Google Scholar
Digital Library
- S. Park and D. L. Dill. An executable specification, analyzer and verifier for RMO (Relaxed Memory Order). In SPAA, 1995. Google Scholar
Digital Library
- Racket. The Racket programming language. http://racketlang.org.Google Scholar
- S. Sarkar, P. Sewell, F. Zappa Nardelli, S. Owens, T. Ridge, T. Braibant, M. O. Myreen, and J. Alglave. The semantics of x86-CC multiprocessor machine code. In POPL, 2009. Google Scholar
Digital Library
- S. Sarkar, P. Sewell, J. Alglave, L. Maranget, and D. Williams. Understanding POWER multiprocessors. In PLDI, 2011. Google Scholar
Digital Library
- P. Sewell, S. Sarkar, S. Owens, F. Zappa Nardelli, and M. O. Myreen. x86-TSO: A rigorous and usable programmer’s model for x86 multiprocessors. Commun. ACM, 53(7):89–97, July 2010. Google Scholar
Digital Library
- A. Solar-Lezama, L. Tancau, R. Bodik, V. Saraswat, and S. Seshia. Combinatorial sketching for finite programs. In ASPLOS, 2006. Google Scholar
Digital Library
- E. Torlak and R. Bodik. Growing solver-aided languages with Rosette. In Onward!, 2013. Google Scholar
Digital Library
- E. Torlak and R. Bodik. A lightweight symbolic virtual machine for solver-aided host languages. In PLDI, 2014. Google Scholar
Digital Library
- E. Torlak and D. Jackson. Kodkod: A relational model finder. In TACAS, 2007. Google Scholar
Digital Library
- E. Torlak, M. Vaziri, and J. Dolby. MemSAT: Checking axiomatic specifications of memory models. In PLDI, 2010. Google Scholar
Digital Library
- D. L. Weaver and T. Germond. The SPARC architecture manual (version 9). SPARC International, 1994.Google Scholar
- J. Wickerson, M. Batty, T. Sorensen, and G. A. Constantinides. Automatically comparing memory consistency models. In POPL, 2017. Google Scholar
Digital Library
- Y. Yang, G. Gopalakrishnan, G. Lindstrom, and K. Slind. Nemos: A framework for axiomatic and executable specifications of memory consistency models. In IPDPS, 2004.Google Scholar
Cross Ref
- F. Zappa Nardelli, P. Sewell, J. ˘Sev˘cík, S. Sarkar, S. Owens, L. Maranget, M. Batty, and J. Alglave. Relaxed memory models must be rigorous. In EC 2, 2009.Google Scholar
Index Terms
Synthesizing memory models from framework sketches and Litmus tests
Recommendations
Synthesizing memory models from framework sketches and Litmus tests
PLDI 2017: Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and ImplementationA memory consistency model specifies which writes to shared memory a given read may see. Ambiguities or errors in these specifications can lead to bugs in both compilers and applications. Yet architectures usually define their memory models with prose ...
Automated Synthesis of Comprehensive Memory Model Litmus Test Suites
ASPLOS '17: Proceedings of the Twenty-Second International Conference on Architectural Support for Programming Languages and Operating SystemsThe memory consistency model is a fundamental part of any shared memory architecture or programming model. Modern weak memory models are notoriously difficult to define and to implement correctly. Most real-world programming languages, compilers, and (...
Generating litmus tests for contrasting memory consistency models
CAV'10: Proceedings of the 22nd international conference on Computer Aided VerificationWell-defined memory consistency models are necessary for writing correct parallel software Developing and understanding formal specifications of hardware memory models is a challenge due to the subtle differences in allowed reorderings and different ...






Comments