Over the years, several memory models have been proposed to capture the subtle concurrency semantics of C/C++.One of the most fundamental problems associated with a memory model M is consistency checking: given an execution X, is X consistent with M? This problem lies at the heart of numerous applications, including specification testing and litmus tests, stateless model checking, and dynamic analyses. As such, it has been explored extensively and its complexity is well-understood for traditional models like SC and TSO. However, less is known for the numerous model variants of C/C++, for which the problem becomes challenging due to the intricacies of their concurrency primitives. In this work we study the problem of consistency checking for popular variants of the C11 memory model, in particular, the RC20 model, its release-acquire (RA) fragment, the strong and weak variants of RA (SRA and WRA), as well as the Relaxed fragment of RC20. Motivated by applications in testing and model checking, we focus on reads-from consistency checking. The input is an execution X specifying a set of events, their program order and their reads-from relation, and the task is to decide the existence of a modification order on the writes of X that makes X consistent in a memory model. We draw a rich complexity landscape for this problem; our results include (i)~nearly-linear-time algorithms for certain variants, which improve over prior results, (ii)~fine-grained optimality results, as well as (iii)~matching upper and lower bounds (NP-hardness) for other variants. To our knowledge, this is the first work to characterize the complexity of consistency checking for C11 memory models. We have implemented our algorithms inside the TruSt model checker and the C11Tester testing tool. Experiments on standard benchmarks show that our new algorithms improve consistency checking, often by a significant margin.
翻译:多年来,已经提出了多个内存模型来捕捉 C/C++ 的微妙并发语义之一最基本的问题是一致性检查:给定执行 X,是否与模型 M 兼容?这个问题涉及许多应用程序,包括规范测试和范例测试、无状态模型检查和动态分析。因此,它已经得到了广泛的研究,而传统模型(如 SC 和 TSO)的复杂性已经得到了很好的理解。然而,对于 C/C++ 的许多模型变体,该问题的了解较少,因为由于它们并发原语的复杂性,该问题变得具有挑战性。在这项工作中,我们研究了 C11 内存模型的流行变体的一致性检查问题,特别是 RC20 模型,它的释放-获取碎片、RA 的强弱变体(SRA 和 WRA),以及 RC20 的松散碎片。受到测试和模型检查应用的启发,我们集中研究了读取-写入一致性检查。输入是一个指定事件集、它们的程序顺序和读取-写入关系的执行 X,任务是决定对 X 的写入进行修改的顺序是否使得 X 在内存模型中一致。我们为这个问题绘制了一个丰富的复杂性景观;我们的结果包括 (i) 某些变体的近线性时间算法,它们改进了先前的结果,(ii) 细粒度的优化结果,以及 (iii) 其他变体的匹配上界和下界(NP-难度)。据我们所知,这是第一个表征 C11 内存模型一致性检查复杂性的工作。我们已经在 TruSt 模型检查器和 C11Tester 测试工具中实现了我们的算法。对标准基准的实验表明,我们的新算法提高了一致性检查,通常有显着的改进。