TSan-spd3 is a dynamic race detector for OpenMP programs. It is implemented on top of the ThreadSanitizer (TSan), reusing the majority of TSan's infrastructure, e.g., shadow memory and bug report. TSan-spd3 leverages the Scalable Precise Dynamic Datarace Detection (SPD3) algorithm, which was proposed by Raghavan Raman et al. in PLDI'12. Although initially designed for async-finish task parallelism, SPD3 can be applied to OpenMP programs. TSan-spd3 can precisely identify all potential data races under the given input if these programs only use the subset of supported OpenMP constructs; otherwise, TSan-spd3 may report false positives due to its incapability of encoding happens-before relations related to those unsupported constructs. In the following section, we list the details of OpenMP constructs handling by TSan-spd3.
Constructs | Supported? |
---|---|
parallel |
✔️ |
for |
✔️ |
single |
✔️ |
master/masked |
✔️ |
atomic |
✔️ |
task |
✔️ |
taskgroup |
✔️ |
taskwait |
✔️ |
taskloop |
✔️ |
barrier |
✔️ |
critical |
✖️ |
simd |
✖️ |
target |
✖️ |
Unsupported clauses for parallel for |
---|
ordered |
reduction |
schedule |
Unsupported clauses for task |
---|
depend |
-
Retrieve a
clang+llvm*
binary package from the official website according to your OS's architecture.- For x86_64 architecture, we have tested the installation using
clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
.
- For x86_64 architecture, we have tested the installation using
-
Unfold the package and set the following environment variables.
export PATH="<UNFOLDED_LLVM_DIR>/bin:$PATH"
export LD_LIBRARY_PATH="<UNFOLDED_LLVM_DIR>/lib:$LD_LIBRARY_PATH"
Replace <BUILD_DIR>
, <INSTALL_DIR>
, and <TSAN_SPD3_REPO_DIR>
with the desired paths on your platform. The CMake setting in the following command lines turns
off OpenMP device offloading support for Nvidia and AMD GPUs since TSan-spd3 cannot tackle memory accesses on non-host devices.
git clone https://github.com/lechenyu/TSan-spd3.git <TSAN_SPD3_REPO_DIR>
mkdir <BUILD_DIR> && cd <BUILD_DIR>
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> \
-DLLVM_ENABLE_LIBCXX=ON \
-DLLVM_LIT_ARGS="-sv -j12" \
-DCLANG_DEFAULT_CXX_STDLIB=libc++ \
-DLIBOMPTARGET_ENABLE_DEBUG=ON \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx;compiler-rt;openmp" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DLLVM_INSTALL_UTILS=ON \
-DLIBOMPTARGET_BUILD_CUDA_PLUGIN=False \
-DLIBOMPTARGET_BUILD_AMDGPU_PLUGIN=False \
-DLIBOMPTARGET_AMDGCN_GFXLIST="" \
<TSAN_SPD3_REPO_DIR>/llvm
cd <BUILD_DIR> && ninja -j 10 install
export PATH="<INSTALL_DIR>/bin:$PATH"
export LD_LIBRARY_PATH="<INSTALL_DIR>/lib:$LD_LIBRARY_PATH"
The usage of TSan-spd3 is similar to TSan/Archer.
To compile an OpenMP program with TSan-spd3 enabled, the extra flag-fsanitize=thread
should be set on the command line.
clang -O3 -g -fopenmp -fsanitize=thread app.c
clang++ -O3 -g -fopenmp -fsanitize=thread app.cpp
To avoid false alerts due to the OpenMP runtime implementation, set the TSan option ignore_noninstrumented_modules
to 1
.
export TSAN_OPTIONS="ignore_noninstrumented_modules=1"
Evaluation Results on DataRaceBench
This is the evaluation results of the latest TSan-spd3. These results may change in the future since we are actively updating TSan-spd3 to tackle more OpenMP constructs.
False Positive | 30 |
False Negative | 18 |
True Positive | 72 |
True Negative | 59 |
Timeout | 2 |
If you are referring to TSan-spd3 in a publication, please cite the following paper.
@inproceedings{yu2022leveraging,
title={Leveraging the Dynamic Program Structure Tree to Detect Data Races in OpenMP Programs},
author={Yu, Lechen and Jin, Feiyang and Protze, Joachim and Sarkar, Vivek},
booktitle={2022 IEEE/ACM Sixth International Workshop on Software Correctness for HPC Applications (Correctness)},
pages={54--62},
year={2022},
organization={IEEE}
}