File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 7171 if : matrix.backend == 'dnnl'
7272 run : |
7373 tests/ctranslate2_test tests/data
74+
75+ build-and-test-cpp-x86_64-sanitizer :
76+ runs-on : ubuntu-22.04
77+ env :
78+ CT2_VERBOSE : 1
7479
80+ steps :
81+ - uses : actions/checkout@v4
82+ with :
83+ submodules : recursive
84+
85+ - name : Install Intel oneAPI
86+ run : |
87+ wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
88+ sudo apt-key add *.PUB
89+ sudo sh -c 'echo "deb https://apt.repos.intel.com/oneapi all main" > /etc/apt/sources.list.d/oneAPI.list'
90+ sudo apt-get update
7591
92+ - name : Configure with MKL
93+ env :
94+ CT2_USE_MKL : 1
95+ MKL_VERSION : 2023.0.0
96+ run : |
97+ sudo apt-get install -y intel-oneapi-mkl-devel-$MKL_VERSION
98+ cmake -DCMAKE_INSTALL_PREFIX=$PWD/install -DBUILD_TESTS=ON -DENABLE_ADDRESS_SANITIZER=ON -DCMAKE_BUILD_TYPE=Debug .
99+
100+ - name : Build
101+ run : |
102+ make install
103+
104+ - name : Download test data
105+ working-directory : tests/data/models
106+ run : |
107+ wget https://opennmt-models.s3.amazonaws.com/pi_lm_step_5000.pt
108+ wget https://opennmt-models.s3.amazonaws.com/transliteration-aren-all.tar.gz
109+ tar xf transliteration-aren-all.tar.gz
110+
111+ - name : Test AddressSanitizer
112+ env :
113+ CT2_USE_MKL : 1
114+ run : |
115+ ASAN_OPTIONS=detect_leaks=1:print_stats=1 tests/ctranslate2_test tests/data
116+
76117 build-and-test-cpp-arm64 :
77118 runs-on : ${{ matrix.os }}
78119 env :
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ option(BUILD_TESTS "Compile the tests" OFF)
2222option (BUILD_SHARED_LIBS "Build shared libraries" ON )
2323option (WITH_TENSOR_PARALLEL "Compile with NCCL and MPI backend" OFF )
2424option (WITH_FLASH_ATTN "Compile with Flash Attention 2" OFF )
25+ option (ENABLE_ADDRESS_SANITIZER "ASAN" OFF )
26+
27+ MESSAGE (STATUS "Compiler Id: ${CMAKE_CXX_COMPILER_ID} " )
28+ MESSAGE (STATUS "Compiler Version: ${CMAKE_CXX_COMPILER_VERSION} " )
2529
2630if (ENABLE_PROFILING)
2731 message (STATUS "Enable profiling support" )
@@ -476,6 +480,16 @@ if (WITH_RUY)
476480 list (APPEND LIBRARIES ruy)
477481endif ()
478482
483+ IF (ENABLE_ADDRESS_SANITIZER AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG" ))
484+ MESSAGE (STATUS "ENABLE_ADDRESS_SANITIZER: ENABLED" )
485+ set (ASAN_FLAGS " -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-common" )
486+ string (APPEND CMAKE_C_FLAGS ${ASAN_FLAGS} )
487+ string (APPEND CMAKE_CXX_FLAGS ${ASAN_FLAGS} )
488+ add_link_options (-fsanitize=address)
489+ ELSEIF (ENABLE_ADDRESS_SANITIZER)
490+ MESSAGE (FATAL_ERROR "SANITIZER requires Debug build type" )
491+ ENDIF ()
492+
479493if (WITH_CUDA)
480494 find_package (CUDA 11.0 REQUIRED)
481495 list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake)
You can’t perform that action at this time.
0 commit comments