Skip to content

Commit dcbb6b3

Browse files
committed
[CI] Add thread sanitizer run
1 parent 907ca22 commit dcbb6b3

File tree

3 files changed

+118
-1
lines changed

3 files changed

+118
-1
lines changed

.github/workflows/main.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,118 @@ jobs:
449449
PPC_ASAN_RUN: 1
450450
ASAN_OPTIONS: abort_on_error=1
451451
UBSAN_OPTIONS: halt_on_error=1
452+
ubuntu-clang-thread-sanitizer-build:
453+
needs:
454+
- ubuntu-clang-build
455+
runs-on: ${{ matrix.os }}
456+
strategy:
457+
matrix:
458+
os: ["ubuntu-24.04"]
459+
steps:
460+
- uses: actions/checkout@v4
461+
with:
462+
submodules: recursive
463+
- name: Setup environment
464+
run: |
465+
sudo apt-get update
466+
sudo apt-get install --no-install-recommends -y ninja-build python3-pip \
467+
openmpi-bin openmpi-common libopenmpi-dev
468+
wget https://apt.llvm.org/llvm.sh
469+
chmod u+x llvm.sh
470+
sudo ./llvm.sh 20 all
471+
- name: ccache
472+
uses: hendrikmuhs/[email protected]
473+
with:
474+
key: ${{ runner.os }}-clang
475+
create-symlink: true
476+
max-size: 1G
477+
- name: CMake configure
478+
run: >
479+
cmake -S . -B build
480+
-D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
481+
-G Ninja
482+
-D CMAKE_BUILD_TYPE=RELEASE -D ENABLE_THREAD_SANITIZER=ON
483+
-D CMAKE_INSTALL_PREFIX=install
484+
env:
485+
CC: clang-20
486+
CXX: clang++-20
487+
- name: Build project
488+
run: |
489+
cmake --build build --parallel
490+
env:
491+
CC: clang-20
492+
CXX: clang++-20
493+
- name: Install project
494+
run: |
495+
cmake --build build --target install
496+
- name: Archive installed package
497+
run: |
498+
tar -czvf ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz -C install .
499+
- name: Upload installed package
500+
uses: actions/upload-artifact@v4
501+
with:
502+
name: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}
503+
path: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz
504+
ubuntu-clang-thread-sanitizer-test:
505+
needs:
506+
- ubuntu-clang-thread-sanitizer-build
507+
runs-on: ${{ matrix.os }}
508+
strategy:
509+
matrix:
510+
os: ["ubuntu-24.04"]
511+
steps:
512+
- uses: actions/checkout@v4
513+
- name: Setup environment
514+
run: |
515+
sudo apt-get update
516+
sudo apt-get install --no-install-recommends -y ninja-build python3-pip valgrind \
517+
openmpi-bin openmpi-common libopenmpi-dev
518+
wget https://apt.llvm.org/llvm.sh
519+
chmod u+x llvm.sh
520+
sudo ./llvm.sh 20 all
521+
- name: Download installed package
522+
uses: actions/download-artifact@v4
523+
with:
524+
name: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}
525+
- name: Extract installed package
526+
run: |
527+
mkdir -p install
528+
tar -xzvf ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz -C install
529+
- name: Run tests (MPI)
530+
run: python3 scripts/run_tests.py --running-type="processes" --additional-mpi-args="--oversubscribe"
531+
env:
532+
PROC_COUNT: 2
533+
OMP_NUM_THREADS: 2
534+
ASAN_RUN: 1
535+
ASAN_OPTIONS: abort_on_error=1
536+
PPC_IGNORE_TEST_TIME_LIMIT: 1
537+
- name: Run tests (threads, num_threads=1)
538+
run: python3 scripts/run_tests.py --running-type="threads"
539+
env:
540+
OMP_NUM_THREADS: 1
541+
ASAN_RUN: 1
542+
ASAN_OPTIONS: abort_on_error=1
543+
PPC_IGNORE_TEST_TIME_LIMIT: 1
544+
- name: Run tests (threads, num_threads=2)
545+
run: python3 scripts/run_tests.py --running-type="threads"
546+
env:
547+
OMP_NUM_THREADS: 2
548+
ASAN_RUN: 1
549+
ASAN_OPTIONS: abort_on_error=1
550+
- name: Run tests (threads, num_threads=3)
551+
run: python3 scripts/run_tests.py --running-type="threads"
552+
env:
553+
OMP_NUM_THREADS: 3
554+
ASAN_RUN: 1
555+
ASAN_OPTIONS: abort_on_error=1
556+
PPC_IGNORE_TEST_TIME_LIMIT: 1
557+
- name: Run tests (threads, num_threads=4)
558+
run: python3 scripts/run_tests.py --running-type="threads"
559+
env:
560+
OMP_NUM_THREADS: 4
561+
ASAN_RUN: 1
562+
ASAN_OPTIONS: abort_on_error=1
563+
PPC_IGNORE_TEST_TIME_LIMIT: 1
452564
ubuntu-clang-sanitizer-test-extended:
453565
needs:
454566
- ubuntu-clang-sanitizer-test

cmake/configure.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if( UNIX )
6666
-Wold-style-definition \
6767
-Wmissing-prototypes")
6868

69-
if ("${ENABLE_ADDRESS_SANITIZER}" OR "${ENABLE_UB_SANITIZER}")
69+
if ("${ENABLE_ADDRESS_SANITIZER}" OR "${ENABLE_UB_SANITIZER}" OR "${ENABLE_THREAD_SANITIZER}")
7070
set (COMMON_COMPILER_FLAGS "${COMMON_COMPILER_FLAGS} -Wno-cast-align")
7171
endif()
7272

cmake/sanitizers.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
1010
add_link_options(-fsanitize=undefined -fno-sanitize=signed-integer-overflow)
1111
message(STATUS "Enabled UB sanitizer")
1212
endif()
13+
if (ENABLE_THREAD_SANITIZER)
14+
add_compile_options(-fsanitize=thread)
15+
add_link_options(-fsanitize=thread)
16+
message(STATUS "Enabled thread sanitizer")
17+
endif()
1318
else()
1419
message(WARNING "Sanitizers are supported on gcc and clang compilers only!")
1520
endif()

0 commit comments

Comments
 (0)