Skip to content

Commit 26db1a3

Browse files
committed
[CI] Add thread sanitizer run
1 parent e8c853a commit 26db1a3

3 files changed

Lines changed: 122 additions & 1 deletion

File tree

.github/workflows/ubuntu.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,122 @@ jobs:
473473
PPC_ASAN_RUN: 1
474474
ASAN_OPTIONS: abort_on_error=1
475475
UBSAN_OPTIONS: halt_on_error=1
476+
ubuntu-clang-thread-sanitizer-build:
477+
needs:
478+
- ubuntu-clang-build
479+
runs-on: ${{ matrix.os }}
480+
strategy:
481+
matrix:
482+
os: ["ubuntu-24.04"]
483+
steps:
484+
- uses: actions/checkout@v4
485+
with:
486+
submodules: recursive
487+
- name: Setup environment
488+
run: |
489+
sudo apt-get update
490+
sudo apt-get install --no-install-recommends -y ninja-build python3-pip \
491+
openmpi-bin openmpi-common libopenmpi-dev
492+
wget https://apt.llvm.org/llvm.sh
493+
chmod u+x llvm.sh
494+
sudo ./llvm.sh 20 all
495+
- name: ccache
496+
uses: hendrikmuhs/ccache-action@v1.2
497+
with:
498+
key: ${{ runner.os }}-clang
499+
create-symlink: true
500+
max-size: 1G
501+
- name: CMake configure
502+
run: >
503+
cmake -S . -B build -G Ninja
504+
-D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
505+
-D CMAKE_BUILD_TYPE=RELEASE -D ENABLE_THREAD_SANITIZER=ON
506+
-D CMAKE_INSTALL_PREFIX=install
507+
env:
508+
CC: clang-20
509+
CXX: clang++-20
510+
- name: Build project
511+
run: |
512+
cmake --build build --parallel
513+
env:
514+
CC: clang-20
515+
CXX: clang++-20
516+
- name: Install project
517+
run: |
518+
cmake --build build --target install
519+
- name: Archive installed package
520+
run: |
521+
tar -czvf ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz -C install .
522+
- name: Upload installed package
523+
uses: actions/upload-artifact@v4
524+
with:
525+
name: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}
526+
path: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz
527+
ubuntu-clang-thread-sanitizer-test:
528+
needs:
529+
- ubuntu-clang-thread-sanitizer-build
530+
runs-on: ${{ matrix.os }}
531+
strategy:
532+
matrix:
533+
os: ["ubuntu-24.04"]
534+
steps:
535+
- uses: actions/checkout@v4
536+
- name: Setup environment
537+
run: |
538+
sudo apt-get update
539+
sudo apt-get install --no-install-recommends -y ninja-build python3-pip valgrind \
540+
openmpi-bin openmpi-common libopenmpi-dev
541+
wget https://apt.llvm.org/llvm.sh
542+
chmod u+x llvm.sh
543+
sudo ./llvm.sh 20 all
544+
- name: Download installed package
545+
uses: actions/download-artifact@v4
546+
with:
547+
name: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}
548+
- name: Extract installed package
549+
run: |
550+
mkdir -p install
551+
tar -xzvf ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz -C install
552+
- name: Run tests (MPI)
553+
run: python3 scripts/run_tests.py --running-type="processes" --additional-mpi-args="--oversubscribe"
554+
env:
555+
PPC_NUM_PROC: 2
556+
PPC_NUM_THREADS: 2
557+
PPC_ASAN_RUN: 1
558+
ASAN_OPTIONS: abort_on_error=1
559+
UBSAN_OPTIONS: halt_on_error=1
560+
- name: Run tests (threads, num_threads=1)
561+
run: python3 scripts/run_tests.py --running-type="threads"
562+
env:
563+
PPC_NUM_PROC: 1
564+
PPC_NUM_THREADS: 1
565+
PPC_ASAN_RUN: 1
566+
ASAN_OPTIONS: abort_on_error=1
567+
UBSAN_OPTIONS: halt_on_error=1
568+
- name: Run tests (threads, num_threads=2)
569+
run: python3 scripts/run_tests.py --running-type="threads"
570+
env:
571+
PPC_NUM_PROC: 1
572+
PPC_NUM_THREADS: 2
573+
PPC_ASAN_RUN: 1
574+
ASAN_OPTIONS: abort_on_error=1
575+
UBSAN_OPTIONS: halt_on_error=1
576+
- name: Run tests (threads, num_threads=3)
577+
run: python3 scripts/run_tests.py --running-type="threads"
578+
env:
579+
PPC_NUM_PROC: 1
580+
PPC_NUM_THREADS: 3
581+
PPC_ASAN_RUN: 1
582+
ASAN_OPTIONS: abort_on_error=1
583+
UBSAN_OPTIONS: halt_on_error=1
584+
- name: Run tests (threads, num_threads=4)
585+
run: python3 scripts/run_tests.py --running-type="threads"
586+
env:
587+
PPC_NUM_PROC: 1
588+
PPC_NUM_THREADS: 4
589+
PPC_ASAN_RUN: 1
590+
ASAN_OPTIONS: abort_on_error=1
591+
UBSAN_OPTIONS: halt_on_error=1
476592
ubuntu-clang-sanitizer-test-extended:
477593
needs:
478594
- ubuntu-clang-sanitizer-test

cmake/configure.cmake

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

71-
if ("${ENABLE_ADDRESS_SANITIZER}" OR "${ENABLE_UB_SANITIZER}")
71+
if ("${ENABLE_ADDRESS_SANITIZER}" OR "${ENABLE_UB_SANITIZER}" OR "${ENABLE_THREAD_SANITIZER}")
7272
set (COMMON_COMPILER_FLAGS "${COMMON_COMPILER_FLAGS} -Wno-cast-align")
7373
endif()
7474

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)