Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04]
backend: [mkl, dnnl]
backend: [mkl, dnnl, asan]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be in an independent job instead of build-and-test-cpp-x86_64.


steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -50,6 +50,15 @@ jobs:
sudo apt-get install -y intel-oneapi-dnnl-devel=$DNNL_VERSION intel-oneapi-dnnl=$DNNL_VERSION
cmake -DCMAKE_INSTALL_PREFIX=$PWD/install -DBUILD_TESTS=ON -DWITH_MKL=OFF -DOPENMP_RUNTIME=COMP -DWITH_DNNL=ON .

- name: Configure with ASAN
if: startsWith(matrix.os, 'ubuntu') && matrix.backend == 'asan'
env:
DNNL_VERSION: 2023.0.0-25399
run: |
sudo apt-get install -y llvm libomp-dev intel-oneapi-dnnl-devel=$DNNL_VERSION intel-oneapi-dnnl=$DNNL_VERSION
cmake -DCMAKE_INSTALL_PREFIX=$PWD/install -DBUILD_TESTS=ON -DWITH_MKL=OFF -DOPENMP_RUNTIME=COMP -DWITH_DNNL=ON \
-DGOOGLE_ADDRESS_SANITIZER=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ .

- name: Build
run: |
make install
Expand All @@ -71,7 +80,10 @@ jobs:
if: matrix.backend == 'dnnl'
run: |
tests/ctranslate2_test tests/data

- name: Test ASAN
if: matrix.backend == 'asan'
run: |
ASAN_OPTIONS=detect_leaks=1:print_stats=1 tests/ctranslate2_test tests/data
Copy link
Author

@3manifold 3manifold Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force ASAN_OPTIONS=detect_leaks=1 in case os: [ubuntu-22.04] matrix expands in the future (leak detection is turned on by default on Linux).


build-and-test-cpp-aarch64:
runs-on: ubuntu-22.04
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ option(BUILD_TESTS "Compile the tests" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(WITH_TENSOR_PARALLEL "Compile with NCCL and MPI backend" OFF)
option(WITH_FLASH_ATTN "Compile with Flash Attention 2" OFF)
option(GOOGLE_ADDRESS_SANITIZER "ASAN" OFF)


if(ENABLE_PROFILING)
message(STATUS "Enable profiling support")
Expand Down Expand Up @@ -444,6 +446,16 @@ if (WITH_RUY)
list(APPEND LIBRARIES ruy)
endif()

IF (GOOGLE_ADDRESS_SANITIZER AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG"))
MESSAGE (STATUS "GOOGLE_ADDRESS_SANITIZER: ENABLED")
set(ASAN_FLAGS " -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-common")
string(APPEND CMAKE_C_FLAGS ${ASAN_FLAGS})
string(APPEND CMAKE_CXX_FLAGS ${ASAN_FLAGS})
add_link_options(-fsanitize=address)
ELSEIF (GOOGLE_ADDRESS_SANITIZER)
MESSAGE(FATAL_ERROR "SANITIZER requires Debug build type")
ENDIF ()

if (WITH_CUDA)
find_package(CUDA 11.0 REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
Expand Down
Loading