Memory Consistency Models using Constraints

Ruth Hoffmann,Özgür Akgün,Susmit Sarkar
DOI: https://doi.org/10.48550/arXiv.1808.09870
2018-08-29
Abstract:Memory consistency models (MCMs) are at the heart of concurrent programming. They represent the behaviour of concurrent programs at the chip level. To test these models small program snippets called litmus test are generated, which show allowed or forbidden behaviour of different MCMs. This paper is showcasing the use of constraint programming to automate the generation and testing of litmus tests for memory consistency models. We produce a few exemplary case studies for two MCMs, namely Sequential Consistency and Total Store Order. These studies demonstrate the flexibility of constrains programming in this context and lay foundation to the direct verification of MCMs against the software facing cache coherence protocols.
Programming Languages
What problem does this paper attempt to address?
The paper attempts to address the problem of automatically generating and testing memory consistency models (MCMs) test cases (referred to as litmus tests) through Constraint Programming. Specifically, the paper demonstrates how to use Constraint Programming to generate and verify litmus tests under different memory consistency models and explores the flexibility and effectiveness of this approach in generating test cases and verifying memory consistency models. ### Main Issues 1. **Generating litmus tests**: Automatically generating litmus tests that conform to specific memory consistency models. 2. **Verifying litmus tests**: Verifying whether the generated litmus tests conform to the expected behavior, i.e., checking whether these tests produce allowed final states under different memory consistency models. 3. **Comparing different memory consistency models**: Comparing the behavior differences of different memory consistency models (such as Sequential Consistency model SC and Total Store Order model TSO) through the generated litmus tests. ### Solution - **Constraint Programming**: Using Constraint Programming techniques to model memory consistency models and generate litmus tests that conform to these models. - **Case Study**: Demonstrating the application of Constraint Programming in generating and verifying litmus tests through specific case studies, including generating all possible final states and verifying whether these states meet expectations. - **Tool Comparison**: Comparing with existing tools (such as herd7 and TriCheck) to showcase the advantages of the Constraint Programming approach. ### Case Study - **Sequential Consistency model (SC)**: Defining the constraints of the SC model and generating litmus tests that conform to the SC model. - **Total Store Order model (TSO)**: Defining the constraints of the TSO model and generating litmus tests that conform to the TSO model. - **Generation and Verification**: Generating litmus tests through a constraint solver and verifying the behavior of these tests under different memory consistency models. ### Conclusion The paper demonstrates the effectiveness and flexibility of using Constraint Programming to model memory consistency models and generate litmus tests. Compared to traditional algorithms and tools, the Constraint Programming approach can generate smaller, more flexible models and effectively handle the state explosion problem. Future work will focus on implementing cache coherence protocols and directly verifying them with memory consistency models.