在多线程程序中,当2个以上线程在没有顺序约束的条件下访问同一个存储单元时,且其中至少有一个为写访问,则可能会发生数据竞争。为此,提出一种针对X10并行程序的静态数据竞争检测算法,包括源访存对计算、可达访存对计算、时钟同步访存对计算和逃逸访存对计算4个阶段。通过在WALA框架中分析构建程序的调用图,计算源访存对集合,检测出内存访存中可能发生数据竞争的无序对。实验结果表明,该算法可以在不显著增加X10并行程序总体运行时间的情况下,达到比较理想的数据竞争检测效果。
A multi threaded program can contain a data race when two or more threads access the same memory location under no ordering constraints and at least one access is a write operation.The existence of data races can lead to many kinds of harmful program behaviors,including determinism violations,corrupted memory,and so on.It proposes a new algorithm for static detection of data races in X10 parallel programs,which contains four steps: pairs of sources accesses computation,pairs of reachable accesses computation,pairs of clockwise accesses computation,and escape analysis of accessing pairs computation.The essential idea of this approach is to construct the call graph of the program on the basis of the WALA,and then to compute pairs of sources accesses for detecting potential data races.Experimental results show that the algorithm performs well and can find and report potential data races in a cost effective manner.