• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

计算机工程与科学 ›› 2025, Vol. 47 ›› Issue (11): 1932-1944.

• 高性能计算 • 上一篇    下一篇

基于循环展开的高效RISC-V内存一致性测试方法

胡津涛,徐学政,杨德亨,黄安文,寇广,李琼


  

  1. (军事科学院国防科技创新研究院,北京 100071)

  • 收稿日期:2024-11-21 修回日期:2025-01-17 出版日期:2025-11-25 发布日期:2025-12-05
  • 基金资助:
    国家自然科学基金 (62402515)

An efficient method for RISC-V memory consistency testing based on loop unrolling

HU Jintao,XU Xuezheng,YANG Deheng,HUANG Anwen,KOU Guang,LI Qiong   

  1.  (Defense Innovation Institute,Academy of Military Sciences,Beijing 100071,China)
  • Received:2024-11-21 Revised:2025-01-17 Online:2025-11-25 Published:2025-12-05

摘要: 内存一致性模型,简称内存模型,规定了多核系统访存的观测规律,是软硬件共同遵守的架构规范,具有难设计、难描述、难实现和难测试的特点,一直是学术界和工业界的研究热点。由于并行程序执行顺序的不确定性,内存模型的测试通常需要大量重复地运行特定程序,通过最终的程序状态判断是否存在非法的访存顺序。这在硅前的仿真阶段尤其耗时,为芯片验证带来了极大的挑战。近年来,RISC-V因其开源、精简、模块化和高可定制性的特点广受欢迎。由于其开源的特点,RISC-V芯片的指令集扩展和微架构设计有着极高的灵活度,其内存模型也允许在兼容规范的基础上进行定制,这种高可定制性为芯片的验证带来了更多的挑战。为此,面向RISC-V架构提出了一种基于循环展开的高效内存一致性测试方法,通过分析已有测试方法的性能瓶颈,借鉴传统编译技术中的循环展开,将反复运行的测试程序合并,在大大降低线程同步开销的同时,提升了线程间访存交叉执行的概率,从而提高了测试效率。实验结果表明,所提方法在包括RISC-V板卡和模拟器在内的不同平台上相比已有的内存一致性测试方法,测试效率提升至1.5~184倍。

关键词: 内存一致性, RISC-V架构, 循环展开

Abstract: The memory consistency model, commonly referred to as the memory model, defines the observation rules for memory access in multi-core systems. As an architectural specification that both hardware and software must adhere to, it is characterized by difficulties of design, description, implementation, and testing, and has long been a research focus in both academic and industrial communities. Due to the uncertainty in the execution order of parallel programs, testing of memory models typically requires repeatedly running specific programs on a large scale. The presence of illegal memory access orders is determined based on the final program states. This process is particularly time-consuming during the pre-silicon simulation phase, posing significant challenges to chip verification. In recent years, RISC-V has gained widespread popularity due to its open-source nature, simplicity, modularity, and high customizability. Leveraging its open-source advantage, RISC-V chips offer an extremely high degree of flexibility in instruction set extension and micro-architecture design. Its memory model also allows customization on the basis of compliance with specifications, and this high customizability introduces additional challenges to chip verification. To address this issue, this paper proposes an efficient memory consistency testing method based on loop unrolling for the RISC-V architecture. By analyzing the performance bottlenecks of existing testing methods and drawing on the loop unrolling technique from traditional compilation, the method merges repeatedly executed test programs. This not only significantly reduces thread synchronization overhead but also increases the probability of inter-leaved memory access execution between threads, thereby improving testing efficiency. Experimental results show that, compared with existing memory consistency testing methods, the proposed method achieves a testing efficiency improvement ranging from 1.5 times to 184 times  across different platforms, including RISC-V boards and simulators.


Key words: memory consistency, RISC-V architecture, loop unrolling