7272 run : |
7373 tests/ctranslate2_test tests/data
7474
75- build-and-test-cpp-x86_64-address_sanitizer :
75+
76+
77+ build-and-test-cpp-x86_64-thread_sanitizer :
7678 runs-on : ubuntu-22.04
7779 env :
7880 CT2_VERBOSE : 1
@@ -87,24 +89,33 @@ jobs:
8789 wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
8890 sudo apt-key add *.PUB
8991 sudo sh -c 'echo "deb https://apt.repos.intel.com/oneapi all main" > /etc/apt/sources.list.d/oneAPI.list'
90- sudo apt update
92+ sudo apt-get update
9193
9294 - name : Install MKL
9395 env :
94- CT2_USE_MKL : 1
9596 MKL_VERSION : 2023.0.0
9697 run : |
9798 sudo apt install -y intel-oneapi-mkl-devel-$MKL_VERSION
9899
99- - name : Install Clang
100- run : |
101- sudo apt install -y clang
100+
101+
102+ - name : Install Clang2
103+ run : |
104+ NPROC=$(nproc)
105+ git clone --depth 1 --branch llvmorg-7.0.1 --recurse-submodules -j$NPROC https://github.com/llvm/llvm-project
106+ cd llvm-project
107+ mkdir build
108+ cd build
109+ cmake -DLIBOMP_TSAN_SUPPORT=1 ../openmp
110+ sudo cmake --build . --target install --parallel $NPROC
111+
112+ # sudo and --target install is optional if you adjust the path to libomp.so below
102113
103- - name : Configure with MKL and Clang
114+ - name : Configure with MKL
104115 env :
105116 CT2_USE_MKL : 1
106117 run : |
107- cmake -DCMAKE_INSTALL_PREFIX=$PWD/install -DBUILD_TESTS=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DENABLE_ADDRESS_SANITIZER =ON -DCMAKE_BUILD_TYPE=Debug .
118+ cmake -DCMAKE_INSTALL_PREFIX=$PWD/install -DBUILD_TESTS=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DENABLE_THREAD_SANITIZER =ON -DCMAKE_BUILD_TYPE=Debug .
108119
109120 - name : Build
110121 run : |
@@ -117,306 +128,60 @@ jobs:
117128 wget https://opennmt-models.s3.amazonaws.com/transliteration-aren-all.tar.gz
118129 tar xf transliteration-aren-all.tar.gz
119130
120- - name : Test AddressSanitizer
131+ - name : Test ThreadSanitizer
121132 env :
122133 CT2_USE_MKL : 1
123134 run : |
124- ASAN_OPTIONS=detect_leaks=1:print_stats=1 tests/ctranslate2_test tests/data
125-
126- build-and-test-cpp-arm64 :
127- runs-on : ${{ matrix.os }}
135+ ldd /usr/local/lib/libomp.so
136+ LD_PRELOAD=/usr/local/lib/libomp.so TSAN_OPTIONS=halt_on_error=1 tests/ctranslate2_test tests/data
137+
138+ build-and-test-cpp-x86_64-thread_sanitizer_NOLLVMOPENMP :
139+ runs-on : ubuntu-22.04
128140 env :
129141 CT2_VERBOSE : 1
130- strategy :
131- matrix :
132142
133- include :
134- - os : ubuntu-22.04-arm
135- backend : openblas
136- - os : macos-15
137- backend : ruy
138143 steps :
139144 - uses : actions/checkout@v4
140145 with :
141146 submodules : recursive
142147
143- - name : Build with OpenBLAS and Ruy
144- if : matrix.backend == 'openblas'
145- run : |
146- wget https://github.com/xianyi/OpenBLAS/archive/v0.3.13.tar.gz
147- tar xzvf v0.3.13.tar.gz
148- cd OpenBLAS-0.3.13
149- make TARGET=ARMV8 NO_LAPACK=1 -j $(nproc)
150- sudo make PREFIX=/usr/local install -j $(nproc)
151- cd ..
152- export OpenBLAS_HOME=/usr/local
153- cmake \
154- -DOPENMP_RUNTIME=COMP \
155- -DCMAKE_INSTALL_PREFIX=$PWD/install \
156- -DWITH_MKL=OFF \
157- -DWITH_OPENBLAS=ON \
158- -DWITH_RUY=ON \
159- -DBUILD_TESTS=ON \
160- .
161- make -j $(nproc) install
162-
163- - name : Build Ruy
164- if : matrix.backend == 'ruy'
165- run : |
166- CMAKE_EXTRA_OPTIONS='-DCMAKE_OSX_ARCHITECTURES=arm64 -DWITH_ACCELERATE=ON -DWITH_MKL=OFF -DOPENMP_RUNTIME=NONE -DWITH_RUY=ON'
167- cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
168- -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
169- -DCMAKE_INSTALL_PREFIX=$PWD/install \
170- -DBUILD_TESTS=ON \
171- $CMAKE_EXTRA_OPTIONS \
172- .
173- make -j $(nproc) install
174-
175- - name : Download test data
176- run : |
177- wget https://opennmt-models.s3.amazonaws.com/transliteration-aren-all.tar.gz
178- tar xf transliteration-aren-all.tar.gz -C tests/data/models/
179-
180- - name : Test
148+ - name : Install Intel oneAPI
181149 run : |
182- tests/ctranslate2_test tests/data
183-
184- build-python-wheels :
185- runs-on : ${{ matrix.os }}
186- strategy :
187- matrix :
188- os : [ubuntu-22.04, windows-2022]
189- arch : [auto64]
190- include :
191- - os : ubuntu-22.04
192- arch : aarch64
193- - os : macos-15
194- arch : arm64
195- - os : macos-15-intel
196- arch : x86_64
197-
198- steps :
199- - uses : actions/checkout@v4
200- with :
201- submodules : recursive
202-
203- - uses : docker/setup-qemu-action@v2
204- if : ${{ matrix.arch == 'aarch64' }}
205- name : Set up QEMU
150+ wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
151+ sudo apt-key add *.PUB
152+ sudo sh -c 'echo "deb https://apt.repos.intel.com/oneapi all main" > /etc/apt/sources.list.d/oneAPI.list'
153+ sudo apt-get update
206154
207- - name : Build wheels
208- uses : pypa/cibuildwheel@v3.2.1
209- with :
210- package-dir : python
211- output-dir : python/wheelhouse
155+ - name : Install MKL
212156 env :
213- CIBW_ENVIRONMENT_PASS_LINUX : CIBW_ARCHS
214- CIBW_ENVIRONMENT_WINDOWS : CTRANSLATE2_ROOT='${{ github.workspace }}\install'
215- CIBW_ENVIRONMENT_MACOS : " CTRANSLATE2_ROOT='/usr/local' MACOSX_DEPLOYMENT_TARGET=11.00"
216- CIBW_BEFORE_ALL_LINUX : python/tools/prepare_build_environment_linux.sh
217- CIBW_BEFORE_ALL_MACOS : python/tools/prepare_build_environment_macos.sh
218- CIBW_BEFORE_ALL_WINDOWS : bash python/tools/prepare_build_environment_windows.sh
219- CIBW_BEFORE_BUILD : pip install -r python/install_requirements.txt
220- CIBW_MANYLINUX_X86_64_IMAGE : manylinux_2_28
221- CIBW_MANYLINUX_AARCH64_IMAGE : manylinux_2_28
222- CIBW_ARCHS : ${{ matrix.arch }}
223- CIBW_SKIP : " *-musllinux_*"
224-
225- - name : Upload Python wheels
226- uses : actions/upload-artifact@v4
227- with :
228- name : python-wheels-${{ runner.os }}-${{ matrix.arch }}
229- path : python/wheelhouse
230-
231-
232- # We could test the Python wheels using cibuildwheel but we prefer to run the tests outside
233- # the build environment to ensure wheels correctly embed all dependencies.
234- test-python-wheels :
235- needs : [build-python-wheels]
236- runs-on : ${{ matrix.os }}
237- strategy :
238- matrix :
239- include :
240- - os : ubuntu-22.04
241- artifact_pattern : python-wheels-Linux-auto64
242- wheel_pattern : " *cp310*manylinux*x86_64.whl"
243-
244- - os : ubuntu-22.04-arm
245- artifact_pattern : python-wheels-Linux-aarch64
246- wheel_pattern : " *cp310*manylinux*_aarch64.whl"
247-
248- - os : macos-15
249- artifact_pattern : python-wheels-macOS-arm64
250- wheel_pattern : " *cp310*macosx*arm64.whl"
251-
252- steps :
253- - name : Set up Python 3.10.11
254- uses : actions/setup-python@v5
255- with :
256- python-version : " 3.10.11"
257-
258- - uses : actions/checkout@v4
259-
260- - name : Prepare test environment
261- shell : bash
262- run : |
263- ./python/tools/prepare_test_environment.sh
264-
265- - name : Download Python wheels
266- uses : actions/download-artifact@v4
267- with :
268- pattern : ${{ matrix.artifact_pattern }}
269- merge-multiple : true
270- path : .
271-
272- - name : Install wheel
273- shell : bash
274- run : |
275- pip install ${{ matrix.wheel_pattern }}
276-
277- - name : Test Python wheel
278- run : |
279- pytest -v python/tests/ --ignore=python/tests/test_opennmt_tf.py
280-
281-
282- check-python-style :
283- runs-on : ubuntu-latest
284-
285- steps :
286- - uses : actions/checkout@v4
287-
288- - name : Set up Python 3.10.11
289- uses : actions/setup-python@v5
290- with :
291- python-version : " 3.10.11"
292-
293- - name : Install dependencies
294- run : |
295- python -m pip install black==22.* flake8==3.8.* isort==5.*
296-
297- - name : Check code format with Black
298- working-directory : python
299- run : |
300- black --check .
301-
302- - name : Check imports order with isort
303- working-directory : python
304- run : |
305- isort --check-only .
306-
307- - name : Check code style with Flake8
308- working-directory : python
309- if : ${{ always() }}
310- run : |
311- flake8 .
312-
313-
314- publish-python-wheels-on-pypi :
315- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
316- needs : [build-and-test-cpp-x86_64, build-and-test-cpp-arm64, build-python-wheels, test-python-wheels, check-python-style]
317- runs-on : ubuntu-22.04
318-
319- steps :
320- - name : Download Python wheels
321- uses : actions/download-artifact@v4
322- with :
323- pattern : python-wheels-*
324- merge-multiple : true
325- path : .
326-
327- - name : Publish Python wheels to PyPI
328- uses : pypa/gh-action-pypi-publish@release/v1
329- with :
330- user : __token__
331- password : ${{ secrets.PYPI_API_TOKEN }}
332- packages-dir : .
333-
334-
335- build-and-push-docker-images :
336- runs-on : ubuntu-22.04
337- steps :
338- - uses : actions/checkout@v4
339- with :
340- submodules : recursive
341-
342- - name : Show disk and docker usage (before cleanup)
343- run : |
344- df -h
345- echo " -= Docker System =-"
346- docker system df || true
347-
348- - name : Free disk space (cleanup heavy preinstalled directories + docker prune)
349- run : |
350- echo " -= Removing big preinstalled directories (shouldn't remove the needed tools) =-"
351- sudo rm -rf /opt/hostedtoolcache || true
352- sudo rm -rf /usr/share/dotnet || true
353- sudo rm -rf /usr/lib/jvm || true
354- sudo rm -rf /usr/local/lib/android || true
355- echo " -= Running docker prune =-"
356- docker system prune -af --volumes || true
357- docker builder prune -af || true
358-
359- - name : Show disk and docker usage (after cleanup)
157+ MKL_VERSION : 2023.0.0
360158 run : |
361- df -h
362- echo " -= Docker System =-"
363- docker system df || true
159+ sudo apt install -y intel-oneapi-mkl-devel-$MKL_VERSION
364160
365- - name : Build Docker images
161+ - name : Install Clang
366162 run : |
367- ./docker/build_all.sh
368-
369- - name : Login to DockerHub
370- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
371- uses : docker/login-action@v2
372- with :
373- registry : ghcr.io
374- username : ${{ github.actor }}
375- password : ${{ secrets.GITHUB_TOKEN }}
163+ sudo apt install -y clang
376164
377- - name : Push Docker images
378- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
165+ - name : Configure with MKL
166+ env :
167+ CT2_USE_MKL : 1
379168 run : |
380- ./docker/build_all.sh ${GITHUB_REF##*/v} 1
381-
382-
383- build-and-deploy-docs :
384- runs-on : ubuntu-latest
385- needs : [check-python-style, build-python-wheels]
386-
387- steps :
388- - uses : actions/checkout@v4
389-
390- - name : Set up Python 3.10.11
391- uses : actions/setup-python@v5
392- with :
393- python-version : " 3.10.11"
169+ cmake -DCMAKE_INSTALL_PREFIX=$PWD/install -DBUILD_TESTS=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DENABLE_THREAD_SANITIZER=ON -DCMAKE_BUILD_TYPE=Debug .
394170
395- - name : Download CTranslate2 wheels
396- uses : actions/download-artifact@v4
397- with :
398- pattern : python-wheels-${{ runner.os }}-*
399- merge-multiple : true
400- path : .
401-
402- - name : Install CTranslate2 wheel
171+ - name : Build
403172 run : |
404- pip install *cp310*manylinux*x86_64.whl
173+ make -j $(nproc) install
405174
406- - name : Install dependencies to build docs
407- working-directory : docs
175+ - name : Download test data
176+ working-directory : tests/data/models
408177 run : |
409- python -m pip install -r requirements.txt
178+ wget https://opennmt-models.s3.amazonaws.com/pi_lm_step_5000.pt
179+ wget https://opennmt-models.s3.amazonaws.com/transliteration-aren-all.tar.gz
180+ tar xf transliteration-aren-all.tar.gz
410181
411- - name : Build docs
412- working-directory : docs
182+ - name : Test ThreadSanitizer
183+ env :
184+ CT2_USE_MKL : 1
413185 run : |
414- python generate.py python
415- sphinx-build . build
186+ TSAN_OPTIONS=halt_on_error=1 tests/ctranslate2_test tests/data
416187
417- - name : Deploy docs
418- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
419- uses : JamesIves/github-pages-deploy-action@v4
420- with :
421- folder : docs/build
422- clean : true
0 commit comments