Skip to content

Commit 7d187c5

Browse files
committed
[CI] Add thread sanitizer run
1 parent 1870b8e commit 7d187c5

File tree

3 files changed

+126
-5
lines changed

3 files changed

+126
-5
lines changed

.github/workflows/ubuntu.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,122 @@ jobs:
301301
PPC_ASAN_RUN: 1
302302
ASAN_OPTIONS: abort_on_error=1
303303
UBSAN_OPTIONS: halt_on_error=1
304+
ubuntu-clang-thread-sanitizer-build:
305+
needs:
306+
- ubuntu-clang-build
307+
runs-on: ${{ matrix.os }}
308+
strategy:
309+
matrix:
310+
os: ["ubuntu-24.04"]
311+
steps:
312+
- uses: actions/checkout@v4
313+
with:
314+
submodules: recursive
315+
- name: Setup environment
316+
run: |
317+
sudo apt-get update
318+
sudo apt-get install --no-install-recommends -y ninja-build python3-pip \
319+
openmpi-bin openmpi-common libopenmpi-dev
320+
wget https://apt.llvm.org/llvm.sh
321+
chmod u+x llvm.sh
322+
sudo ./llvm.sh 20 all
323+
- name: ccache
324+
uses: hendrikmuhs/[email protected]
325+
with:
326+
key: ${{ runner.os }}-clang
327+
create-symlink: true
328+
max-size: 1G
329+
- name: CMake configure
330+
run: >
331+
cmake -S . -B build -G Ninja
332+
-D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
333+
-D CMAKE_BUILD_TYPE=RELEASE -D ENABLE_THREAD_SANITIZER=ON
334+
-D CMAKE_INSTALL_PREFIX=install
335+
env:
336+
CC: clang-20
337+
CXX: clang++-20
338+
- name: Build project
339+
run: |
340+
cmake --build build --parallel
341+
env:
342+
CC: clang-20
343+
CXX: clang++-20
344+
- name: Install project
345+
run: |
346+
cmake --build build --target install
347+
- name: Archive installed package
348+
run: |
349+
tar -czvf ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz -C install .
350+
- name: Upload installed package
351+
uses: actions/upload-artifact@v4
352+
with:
353+
name: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}
354+
path: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz
355+
ubuntu-clang-thread-sanitizer-test:
356+
needs:
357+
- ubuntu-clang-thread-sanitizer-build
358+
runs-on: ${{ matrix.os }}
359+
strategy:
360+
matrix:
361+
os: ["ubuntu-24.04"]
362+
steps:
363+
- uses: actions/checkout@v4
364+
- name: Setup environment
365+
run: |
366+
sudo apt-get update
367+
sudo apt-get install --no-install-recommends -y ninja-build python3-pip valgrind \
368+
openmpi-bin openmpi-common libopenmpi-dev
369+
wget https://apt.llvm.org/llvm.sh
370+
chmod u+x llvm.sh
371+
sudo ./llvm.sh 20 all
372+
- name: Download installed package
373+
uses: actions/download-artifact@v4
374+
with:
375+
name: ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}
376+
- name: Extract installed package
377+
run: |
378+
mkdir -p install
379+
tar -xzvf ubuntu-clang-thread-sanitizer-install-${{ matrix.os }}.tar.gz -C install
380+
- name: Run tests (MPI)
381+
run: python3 scripts/run_tests.py --running-type="processes" --additional-mpi-args="--oversubscribe"
382+
env:
383+
PPC_NUM_PROC: 2
384+
PPC_NUM_THREADS: 2
385+
PPC_ASAN_RUN: 1
386+
ASAN_OPTIONS: abort_on_error=1
387+
UBSAN_OPTIONS: halt_on_error=1
388+
- name: Run tests (threads, num_threads=1)
389+
run: python3 scripts/run_tests.py --running-type="threads"
390+
env:
391+
PPC_NUM_PROC: 1
392+
PPC_NUM_THREADS: 1
393+
PPC_ASAN_RUN: 1
394+
ASAN_OPTIONS: abort_on_error=1
395+
UBSAN_OPTIONS: halt_on_error=1
396+
- name: Run tests (threads, num_threads=2)
397+
run: python3 scripts/run_tests.py --running-type="threads"
398+
env:
399+
PPC_NUM_PROC: 1
400+
PPC_NUM_THREADS: 2
401+
PPC_ASAN_RUN: 1
402+
ASAN_OPTIONS: abort_on_error=1
403+
UBSAN_OPTIONS: halt_on_error=1
404+
- name: Run tests (threads, num_threads=3)
405+
run: python3 scripts/run_tests.py --running-type="threads"
406+
env:
407+
PPC_NUM_PROC: 1
408+
PPC_NUM_THREADS: 3
409+
PPC_ASAN_RUN: 1
410+
ASAN_OPTIONS: abort_on_error=1
411+
UBSAN_OPTIONS: halt_on_error=1
412+
- name: Run tests (threads, num_threads=4)
413+
run: python3 scripts/run_tests.py --running-type="threads"
414+
env:
415+
PPC_NUM_PROC: 1
416+
PPC_NUM_THREADS: 4
417+
PPC_ASAN_RUN: 1
418+
ASAN_OPTIONS: abort_on_error=1
419+
UBSAN_OPTIONS: halt_on_error=1
304420
ubuntu-clang-sanitizer-test-extended:
305421
needs:
306422
- ubuntu-clang-sanitizer-test

cmake/configure.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ if(UNIX)
6464
-Wold-style-definition \
6565
-Wmissing-prototypes")
6666

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

7374
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS}")
7475
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILER_FLAGS}")

cmake/sanitizers.cmake

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

0 commit comments

Comments
 (0)