Skip to content

Commit b59fa78

Browse files
committed
[CI] Add thread sanitizer run
1 parent d0b5c39 commit b59fa78

File tree

3 files changed

+124
-1
lines changed

3 files changed

+124
-1
lines changed

.github/workflows/ubuntu.yml

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

cmake/configure.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ if( UNIX )
6464
-Wold-style-definition \
6565
-Wmissing-prototypes")
6666

67-
if ("${ENABLE_ADDRESS_SANITIZER}" OR "${ENABLE_UB_SANITIZER}" OR "${ENABLE_LEAK_SANITIZER}")
67+
if ("${ENABLE_ADDRESS_SANITIZER}"
68+
OR "${ENABLE_UB_SANITIZER}"
69+
OR "${ENABLE_LEAK_SANITIZER}"
70+
OR "${ENABLE_THREAD_SANITIZER}")
6871
set (COMMON_COMPILER_FLAGS "${COMMON_COMPILER_FLAGS} -Wno-cast-align")
6972
endif()
7073

cmake/sanitizers.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
1414
add_compile_options(-fsanitize=leak)
1515
add_link_options(-fsanitize=leak)
1616
message(STATUS "Enabled leak sanitizer")
17+
if (ENABLE_THREAD_SANITIZER)
18+
add_compile_options(-fsanitize=thread)
19+
add_link_options(-fsanitize=thread)
20+
message(STATUS "Enabled thread sanitizer")
1721
endif()
1822
else()
1923
message(WARNING "Sanitizers are supported on gcc and clang compilers only!")

0 commit comments

Comments
 (0)