Welcome to mirror list, hosted at ThFree Co, Russian Federation.

azure-pipelines.yml - github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0348ebb4295e509338f6a03bee9ad5906bfe6d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
# Azure pipelines for Marian NMT
#
# The pipeline need to be added manually to the repository, for example:
# 1. Go to Your repository > Pipelines, click "New pipeline"
# 2. Choose "Azure Repos Git" and a repository
# 3. Choose "Existing Azure Pipelines YAML file" and specify path to this file
# 4. "More actions" > "Save"

parameters:
# Allow skipping the entire 'Build' stage
- name: runBuilds
  displayName: Run builds? Uncheck to run regression tests only.
  type: boolean
  default: true

# The pipeline CI trigger is set on the branch master only and PR trigger on a
# (non-draft) pull request to any branch
trigger:
- master

pool:
  name: Azure Pipelines

variables:
  - group: marian-prod-tests
  - name: BOOST_ROOT_WINDOWS
    value: "C:/hostedtoolcache/windows/Boost/1.72.0/x86_64"
  - name: BOOST_URL
    value: "https://sourceforge.net/projects/boost/files/boost-binaries/1.72.0/boost_1_72_0-msvc-14.2-64.exe"
  - name: CUDA_PATH_WINDOWS
    value: "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA"
  - name: MKL_DIR
    value: "$(Build.SourcesDirectory)/mkl"
  - name: MKL_URL
    value: "https://romang.blob.core.windows.net/mariandev/ci/mkl-2020.1-windows-static.zip"
  - name: VCPKG_COMMIT
    value: c69096659f49e2b1aca532ea5c2f8c135182519b
  - name: VCPKG_DIR
    value: "$(Build.SourcesDirectory)/vcpkg"
  - name: VCPKG_PACKAGES
    value: "protobuf"
  # The Visual Studio installation directory can be found using:
  #   pushd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
  #   for /f "delims=" %%x in ('.\vswhere.exe -latest -property InstallationPath') do set VSPATH=%%x
  #   popd
  - name: VS_PATH
    value: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise"

stages:
- stage: Builds
  jobs:

  ######################################################################
  - job: BuildWindows
    condition: eq(${{ parameters.runBuilds }}, true)
    displayName: Windows

    strategy:
      matrix:
        # Windows CPU-only build
        "CPU":
          cuda: false
          cuda_version: ""
        # Windows CPU+GPU build
        "CUDA 10.2":
          cuda: true
          cuda_version: 10.2

    pool:
      vmImage: windows-latest

    steps:
    - checkout: self
      submodules: true

    - pwsh: .\scripts\ci\install_cuda_windows.ps1 "$(cuda_version)"
      displayName: Install CUDA
      condition: eq(variables.cuda, true)

    - pwsh: |
        C:\msys64\usr\bin\wget.exe -nv $(MKL_URL) -O mkl.zip
        Expand-Archive -Force mkl.zip $(MKL_DIR)
      displayName: Download MKL

    ## Cache for Boost
    #- task: Cache@2
    #  displayName: Cache Boost
    #  inputs:
    #    # Change the first value (v0) to another value to clear the cache
    #    key: '"v0" | "boost" | "$(BOOST_URL)" | "$(BOOST_ROOT_WINDOWS)" | "$(Agent.OS)"'
    #    path: $(BOOST_ROOT_WINDOWS)
    #    cacheHitVar: CACHE_BOOST_RESTORED

    # Boost is no longer pre-installed on Azure/GitHub-hosted Windows runners
    - pwsh: |
        Write-Host "Downloading Boost to $(BOOST_ROOT_WINDOWS)"
        C:\msys64\usr\bin\wget.exe -nv "$(BOOST_URL)" -O "$(Pipeline.Workspace)/boost.exe"
        Start-Process -Wait -FilePath "$(Pipeline.Workspace)/boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=$(BOOST_ROOT_WINDOWS)"
      displayName: Download Boost
      condition: ne(variables.CACHE_BOOST_RESTORED, 'true')

    ## Cache for vcpkg packages. It does not work yet properly due to linker errors after restoring it.
    #- task: Cache@2
    #  displayName: Cache vcpkg
    #  inputs:
    #    # Change the first value (v0) to another value to clear the cache
    #    key: '"v0" | "vcpkg" | "$(VCPKG_COMMIT)" | "$(VCPKG_PACKAGES)" | "$(Agent.OS)"'
    #    path: $(VCPKG_DIR)
    #    cacheHitVar: CACHE_VCPKG_RESTORED

    - pwsh: |
        git clone https://github.com/Microsoft/vcpkg.git $(VCPKG_DIR)
        cd $(VCPKG_DIR)
        git checkout $(VCPKG_COMMIT)
        pushd
        .\bootstrap-vcpkg.bat -disableMetrics
        popd
        # Install packages
        .\vcpkg.exe install --triplet x64-windows-static $(VCPKG_PACKAGES)
        # Clean to make the cache smaller
        Remove-Item $(VCPKG_DIR)\downloads  -Force -Recurse -ErrorAction SilentlyContinue
        Remove-Item $(VCPKG_DIR)\buildtrees -Force -Recurse -ErrorAction SilentlyContinue
      displayName: Prepare vcpkg
      condition: ne(variables.CACHE_VCPKG_RESTORED, 'true')

    - script: |
        :: Load VS environment
        call "$(VS_PATH)/VC/Auxiliary/Build/vcvarsall.bat" x64
        :: Create build directory
        mkdir build
        cd build
        :: Run CMake
        cmake .. -G Ninja ^
          -DCMAKE_BUILD_TYPE="Debug" ^
          -DCMAKE_C_COMPILER="cl.exe" ^
          -DCMAKE_CXX_COMPILER="cl.exe" ^
          -DCMAKE_MAKE_PROGRAM="ninja.exe" ^
          -DCMAKE_TOOLCHAIN_FILE="$(VCPKG_DIR)\scripts\buildsystems\vcpkg.cmake" ^
          -DVCPKG_TARGET_TRIPLET="x64-windows-static" ^
          ^
          -DBOOST_ROOT="$(BOOST_ROOT)" ^
          -DBOOST_INCLUDEDIR="$(BOOST_ROOT)/include" ^
          -DBOOST_LIBRARYDIR="$(BOOST_ROOT)/lib" ^
          -DOPENSSL_USE_STATIC_LIBS="TRUE" ^
          -DOPENSSL_MSVC_STATIC_RT="TRUE" ^
          ^
          -DCOMPILE_CPU="TRUE" ^
          -DCOMPILE_CUDA="$(cuda)" ^
          -DCOMPILE_EXAMPLES="FALSE" ^
          -DCOMPILE_SERVER="TRUE" ^
          -DCOMPILE_TESTS="TRUE" ^
          ^
          -DUSE_CUDNN="FALSE" ^
          -DUSE_FBGEMM="TRUE" ^
          -DUSE_MPI="FALSE" ^
          -DUSE_NCCL="FALSE" ^
          -DUSE_SENTENCEPIECE="TRUE" ^
          -DUSE_STATIC_LIBS="TRUE"
      displayName: Configure CMake
      env:
        # Set envvars so that CMake can find the installed packages
        MKLROOT: $(MKL_DIR)
        CUDA_PATH: $(CUDA_PATH_WINDOWS)/v$(cuda_version)
        BOOST_ROOT: $(BOOST_ROOT_WINDOWS)

    - script: |
        call "$(VS_PATH)/VC/Auxiliary/Build/vcvarsall.bat" x64
        ninja
      displayName: Compile
      workingDirectory: build

    - script: |
        call "$(VS_PATH)/VC/Auxiliary/Build/vcvarsall.bat" x64
        ctest
      displayName: Run unit tests
      workingDirectory: build
      condition: eq(variables.cuda, false)

    # Note that versions from Marian executables will not be printed for CUDA builds
    - script: |
        .\marian.exe --version
        .\marian-decoder.exe --version
        .\marian-scorer.exe --version
        .\marian-server.exe --version
        .\spm_encode.exe --version
      displayName: Print versions
      workingDirectory: build

  ######################################################################
  - job: BuildUbuntu
    condition: eq(${{ parameters.runBuilds }}, true)
    displayName: Ubuntu
    timeoutInMinutes: 90

    strategy:
      matrix:
        ################################################################
        # Ubuntu CPU-only build
        "CPU-only":
          image: ubuntu-18.04
          boost: true
          cpu: true
          gpu: false
          cuda: ""
          gcc: 7
          unit_tests: true
          examples: false
          static: true
        # Ubuntu GPU-only build
        "GPU-only":
          image: ubuntu-18.04
          boost: true
          cpu: false
          gpu: true
          cuda: 10.2
          gcc: 7
          unit_tests: false
          examples: false
          static: false
        ################################################################
        # Ubuntu 20.04 supports CUDA 11+
        #
        # CPU is disabled because FBGEMM + GCC 9+ do not compile on machines with
        # avx512_vnni, see https://github.com/marian-nmt/marian-dev/issues/709
        #
        "20.04 CUDA 11.1 gcc-9":
          image: ubuntu-20.04
          boost: false      # ubuntu-20.04 does not have Boost pre-installed yet
          cpu: false        # the used fbgemm does not compile with gcc 9+
          gpu: true
          cuda: 11.1
          gcc: 9
          unit_tests: false # disable unit tests to minimize compilation time
          examples: false   # disable examples to minimize compilation time
          static: false
        ################################################################
        # Ubuntu 18.04 supports CUDA 10.1+
        "18.04 CUDA 10.2 gcc-8":
          image: ubuntu-18.04
          boost: true
          cpu: true
          gpu: true
          cuda: 10.2
          gcc: 8
          unit_tests: true
          examples: true
          static: true
        ################################################################
        # Ubuntu 16.04 is no longer available on Azure-hosted machines

    pool:
      vmImage: $(image)

    steps:
    - checkout: self
      submodules: true

    # The following packages are already installed on Azure-hosted runners: build-essential openssl libssl-dev
    # No need to install libprotobuf{17,10,9v5} on Ubuntu {20,18,16}.04 because it is installed together with libprotobuf-dev
    # GCC 8 and lower are no longer pre-installed
    - bash: sudo apt-get install -y libgoogle-perftools-dev libprotobuf-dev protobuf-compiler gcc-$(gcc) g++-$(gcc)
      displayName: Install packages

    # Boost is no longer pre-installed on Azure/GitHub-hosted runners
    - bash: sudo apt-get install -y libboost-system-dev
      displayName: Install Boost
      condition: eq(variables.boost, true)

    # https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html
    - bash: |
        wget -qO- "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB" | sudo apt-key add -
        sudo sh -c "echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list"
        sudo apt-get update -o Dir::Etc::sourcelist="/etc/apt/sources.list.d/intel-mkl.list"
        sudo apt-get install -y --no-install-recommends intel-mkl-64bit-2020.0-088
      displayName: Install MKL
      condition: eq(variables.cpu, true)

    # The script simplifies installation of different versions of CUDA
    - bash: ./scripts/ci/install_cuda_ubuntu.sh $(cuda)
      displayName: Install CUDA
      condition: eq(variables.gpu, true)

    - bash: |
        mkdir -p build
        cd build
        CC=/usr/bin/gcc-$(gcc) CXX=/usr/bin/g++-$(gcc) CUDAHOSTCXX=/usr/bin/g++-$(gcc) \
        cmake .. \
          -DCOMPILE_CPU=$(cpu) \
          -DCOMPILE_CUDA=$(gpu) \
          -DCOMPILE_EXAMPLES=$(examples) \
          -DCOMPILE_SERVER=$(boost) \
          -DCOMPILE_TESTS=$(unit_tests) \
          -DUSE_FBGEMM=$(cpu) \
          -DUSE_SENTENCEPIECE=on \
          -DUSE_STATIC_LIBS=$(static) \
          -DBoost_ARCHITECTURE=-x64 \
          -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-$(cuda)
      displayName: Configure CMake

    # Clean build/src/ to safe disk space on Azure-hosted VMs and stay below the 10GB limit
    - bash: |
        make -j3
        rm -rf src/
      displayName: Compile
      workingDirectory: build

    # Unit tests are run only for CPU-only builds because Azure-hosted runners do not have GPUs
    # TODO: add an option to CMake to compile unit tests only for CPU
    - bash: make test
      displayName: Run unit tests
      workingDirectory: build
      condition: and(eq(variables.unit_tests, true), eq(variables.gpu, false))

    - bash: |
        ./marian --version
        ./marian-decoder --version
        ./marian-scorer --version
        ./spm_encode --version
      displayName: Print versions
      workingDirectory: build

  ######################################################################
  - job: BuildUbuntuMinimal
    condition: eq(${{ parameters.runBuilds }}, true)
    displayName: Ubuntu CPU+GPU gcc-7 cmake 3.5

    pool:
      vmImage: ubuntu-18.04

    steps:
    - checkout: self
      submodules: true

    # The script simplifies installation of different versions of CUDA.
    - bash: ./scripts/ci/install_cuda_ubuntu.sh "10.0"
      displayName: Install CUDA

    # CMake 3.5.1 is the minimum version supported
    - bash: |
        wget -nv https://cmake.org/files/v3.5/cmake-3.5.1-Linux-x86_64.tar.gz
        tar zxf cmake-3.5.1-Linux-x86_64.tar.gz
        ./cmake-3.5.1-Linux-x86_64/bin/cmake --version
      displayName: Download CMake

    # GCC 5 is the minimum version supported
    - bash: |
        /usr/bin/gcc-7 --version
        mkdir -p build
        cd build
        CC=/usr/bin/gcc-7 CXX=/usr/bin/g++-7 CUDAHOSTCXX=/usr/bin/g++-7 \
        ../cmake-3.5.1-Linux-x86_64/bin/cmake .. \
          -DCOMPILE_CPU=on \
          -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.0
      displayName: Configure CMake

    - bash: make -j3
      displayName: Compile
      workingDirectory: build

    - bash: |
        ./marian --version
        ./marian-decoder --version
        ./marian-scorer --version
      displayName: Print versions
      workingDirectory: build

  ######################################################################
  - job: BuildMacOS
    condition: eq(${{ parameters.runBuilds }}, true)
    displayName: macOS CPU clang

    pool:
      vmImage: macos-10.15

    steps:
    - checkout: self
      submodules: true

    - bash: brew install boost openblas openssl protobuf
      displayName: Install packages

    # Openblas location is exported explicitly because openblas is keg-only, which means it was not symlinked into /usr/local/.
    # CMake cannot find BLAS on Azure runners if Marian is being compiled statically, hence USE_STATIC_LIBS=off
    - bash: |
        export LDFLAGS="-L/usr/local/opt/openblas/lib"
        export CPPFLAGS="-I/usr/local/opt/openblas/include"
        mkdir -p build
        cd build
        cmake .. \
          -DCOMPILE_CPU=on \
          -DCOMPILE_CUDA=off \
          -DCOMPILE_EXAMPLES=on \
          -DCOMPILE_SERVER=on \
          -DCOMPILE_TESTS=on \
          -DUSE_FBGEMM=on \
          -DUSE_SENTENCEPIECE=on \
          -DUSE_STATIC_LIBS=off
      displayName: Configure CMake

    - bash: make -j2
      displayName: Compile
      workingDirectory: build

    - bash: make test
      displayName: Run unit tests
      workingDirectory: build

    - bash: |
        ./marian --version
        ./marian-decoder --version
        ./marian-scorer --version
        ./spm_encode --version
      displayName: Print versions
      workingDirectory: build

  ######################################################################
  - job: BuildInstall
    condition: eq(${{ parameters.runBuilds }}, true)
    displayName: Linux CPU library install

    pool:
      vmImage: ubuntu-18.04

    steps:
    - checkout: self
      submodules: true

    # The following packages are already installed on Azure-hosted runners: build-essential openssl libssl-dev
    # No need to install libprotobuf{17,10,9v5} on Ubuntu {20,18,16}.04 because it is installed together with libprotobuf-dev
    - bash: sudo apt-get install -y libgoogle-perftools-dev libprotobuf-dev protobuf-compiler
      displayName: Install packages

    # https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html
    - bash: |
        wget -qO- "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB" | sudo apt-key add -
        sudo sh -c "echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list"
        sudo apt-get update -o Dir::Etc::sourcelist="/etc/apt/sources.list.d/intel-mkl.list"
        sudo apt-get install -y --no-install-recommends intel-mkl-64bit-2020.0-088
      displayName: Install MKL

    - bash: /usr/bin/gcc-7 --version
      displayName: Print GCC version

    - bash: |
        mkdir -p install
        mkdir -p build
        cd build
        CC=/usr/bin/gcc-7 CXX=/usr/bin/g++-7 \
        cmake .. \
          -DCMAKE_INSTALL_PREFIX=../install \
          -DCMAKE_BUILD_TYPE=slim \
          -DCOMPILE_LIBRARY_ONLY=on \
          -DCOMPILE_CUDA=off \
          -DGENERATE_MARIAN_INSTALL_TARGETS=on \
          -DUSE_FBGEMM=on \
          -DUSE_SENTENCEPIECE=on
      displayName: Configure CMake

    - bash: make -j3 install
      displayName: Compile & install
      workingDirectory: build

    - bash: |
        test -e lib/libmarian.a
        test -e lib/libfbgemm.a
        test -e lib/libsentencepiece.a
        ls -lah *
      displayName: Check targets
      workingDirectory: install


# Marian is built in the same job where the regression tests are run to make sure that executables
# are compiled and run on a machine with the same CPU architecture, which is required for
# compilations with FBGEMM.
- stage: Tests
  jobs:

  ######################################################################
  - job: TestWindows
    displayName: Windows CPU+FBGEMM

    pool:
      vmImage: windows-latest

    steps:
    # Due to multiple checkouts this will be commonly cloned into D:\a\1\s\marian-dev
    - checkout: self
      submodules: true

    - pwsh: |
        C:\msys64\usr\bin\wget.exe -nv $(MKL_URL) -O mkl.zip
        Expand-Archive -Force mkl.zip $(MKL_DIR)
      displayName: Download MKL

    # Cache for vcpkg packages
    - task: Cache@2
      displayName: Cache vcpkg
      inputs:
        # Change the first value (v0) to another value to clear the cache
        key: '"v0" | "vcpkg" | "$(VCPKG_COMMIT)" | "$(VCPKG_PACKAGES)" | "$(Agent.OS)"'
        path: $(VCPKG_DIR)
        cacheHitVar: CACHE_VCPKG_RESTORED

    - pwsh: |
        git clone https://github.com/Microsoft/vcpkg.git $(VCPKG_DIR)
        cd $(VCPKG_DIR)
        git checkout $(VCPKG_COMMIT)
        pushd
        .\bootstrap-vcpkg.bat -disableMetrics
        popd
        # Install packages
        .\vcpkg.exe install --triplet x64-windows-static $(VCPKG_PACKAGES)
        # Clean to make the cache smaller
        Remove-Item $(VCPKG_DIR)\downloads  -Force -Recurse -ErrorAction SilentlyContinue
        Remove-Item $(VCPKG_DIR)\buildtrees -Force -Recurse -ErrorAction SilentlyContinue
      displayName: Prepare vcpkg
      condition: ne(variables.CACHE_VCPKG_RESTORED, 'true')

    - script: |
        :: Load VS environment
        call "$(VS_PATH)/VC/Auxiliary/Build/vcvarsall.bat" x64
        :: Create build directory
        mkdir build
        cd build
        :: Run CMake
        cmake .. -G Ninja ^
          -DCMAKE_BUILD_TYPE="Slim" ^
          -DCMAKE_C_COMPILER="cl.exe" ^
          -DCMAKE_CXX_COMPILER="cl.exe" ^
          -DCMAKE_MAKE_PROGRAM="ninja.exe" ^
          -DCMAKE_TOOLCHAIN_FILE="$(VCPKG_DIR)\scripts\buildsystems\vcpkg.cmake" ^
          -DVCPKG_TARGET_TRIPLET="x64-windows-static" ^
          -DDETERMINISTIC="TRUE" ^
          ^
          -DCOMPILE_CPU="TRUE" ^
          -DCOMPILE_CUDA="FALSE" ^
          ^
          -DUSE_FBGEMM="TRUE" ^
          -DUSE_SENTENCEPIECE="TRUE" ^
          -DUSE_STATIC_LIBS="TRUE"
      displayName: Configure CMake
      env:
        # Set envvars so that CMake can find the installed packages
        MKLROOT: $(MKL_DIR)
      workingDirectory: marian-dev

    - script: |
        pwd
        call "$(VS_PATH)/VC/Auxiliary/Build/vcvarsall.bat" x64
        ninja
      displayName: Compile
      workingDirectory: marian-dev/build

    ## Publish an artifact with Marian executables. Disabled because it is not portable due to
    ## fbgemm and not needed at the moment
    #- pwsh: Compress-Archive -Path marian*.exe spm_*.exe -DestinationPath $(Build.SourcesDirectory)/marian-dev-ci_windows-x64_cpu.zip
      #displayName: Prepare binaries
      #workingDirectory: marian-dev/build
    #- publish: marian-dev-ci_windows-x64_cpu.zip
      #artifact: marian-dev-ci_windows-x64_cpu
      #displayName: Publish binaries

    # Running regression tests
    # Due to multiple checkouts this will be commonly cloned into D:\a\1\s\marian-prod-tests
    - checkout: git://Marian/marian-prod-tests

    # Collect details about the CPU architecture, etc.
    # Because the outputs goes to *.log files, they will be also included in the artifact with test outputs.
    - script: bash -c "cat /proc/cpuinfo | tee cpuinfo.log"
      displayName: Machine statistics
      workingDirectory: marian-prod-tests

    - bash: |
        cd models
        bash download-models.sh
        ls
      displayName: Prepare tests
      env:
          AWS_SECRET_SAS_TOKEN: $(blob-sas-token)
      workingDirectory: marian-prod-tests

    # Avoid using $(Build.SourcesDirectory) in bash tasks because on Windows pools it uses '\'
    # instead of '/', which often breaks the job
    - bash: MARIAN=../marian-dev/build TIMEOUT=10m bash ./run_mrt.sh '#cpu' '#basics' '#devops'
      continueOnError: true
      displayName: Run tests
      workingDirectory: marian-prod-tests

    - bash: |
        # cut -c3- removes './' from paths making 7z to retain the directory structure
        find . -type f \( -name "*.log" -o -name "*.out" -o -name "*.diff" \) -print | cut -c3- > listing.txt
        echo "Creating an artifact with the following files:"
        cat listing.txt
        7z a -tzip ../regression-tests-ci_windows-x64_cpu.zip @listing.txt
      displayName: Collect outputs
      workingDirectory: marian-prod-tests

    - publish: regression-tests-ci_windows-x64_cpu.zip
      artifact: regression-tests-ci_windows-x64_cpu
      displayName: Publish outputs

  ######################################################################
  - job: TestLinux
    displayName: Linux CPU+FBGEMM

    pool:
      vmImage: ubuntu-latest

    steps:
    # Due to multiple checkouts this will be commonly cloned into D:\a\1\s\marian-dev
    - checkout: self
      submodules: true

    # The following packages are already installed on Azure-hosted runners: build-essential openssl libssl-dev
    # No need to install libprotobuf{17,10,9v5} on Ubuntu {20,18,16}.04 because it is installed together with libprotobuf-dev
    - bash: sudo apt-get install -y libgoogle-perftools-dev libprotobuf-dev protobuf-compiler gcc-8 g++-8
      displayName: Install packages

    # https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html
    - bash: |
        wget -qO- "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB" | sudo apt-key add -
        sudo sh -c "echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list"
        sudo apt-get update -o Dir::Etc::sourcelist="/etc/apt/sources.list.d/intel-mkl.list"
        sudo apt-get install -y --no-install-recommends intel-mkl-64bit-2020.0-088
      displayName: Install MKL

    # Note that COMPILE_CPU=on and USE_SENTENCEPUECE=on are set explicitly to make them detectable
    # by the regression tests framework (not sure if it is still required)
    - bash: |
        mkdir -p install
        mkdir -p build
        cd build
        CC=/usr/bin/gcc-8 CXX=/usr/bin/g++-8 \
        cmake .. \
          -DCMAKE_BUILD_TYPE=slim \
          -DCOMPILE_CPU=on \
          -DCOMPILE_CUDA=off \
          -DDETERMINISTIC=on \
          -DUSE_FBGEMM=on \
          -DUSE_SENTENCEPIECE=on \
          -DUSE_STATIC_LIBS=on
      displayName: Configure CMake
      workingDirectory: marian-dev

    - bash: make -j3
      displayName: Compile
      workingDirectory: marian-dev/build

    ## Publish an artifact with Marian executables. Disabled because it is not portable due to
    ## fbgemm and not needed at the moment
    #- bash: zip $(Build.SourcesDirectory)/marian-dev-ci_linux-x64-static_cpu.zip marian* spm_*
      #displayName: Prepare binaries
      #workingDirectory: marian-dev/build
    #- publish: marian-dev-ci_linux-x64-static_cpu.zip
      #artifact: marian-dev-ci_linux-x64-static_cpu
      #displayName: Publish binaries

    # Running regression tests
    # Due to multiple checkouts this will be commonly cloned into D:\a\1\s\marian-prod-tests
    - checkout: git://Marian/marian-prod-tests

    # Collect details about the CPU architecture, etc.
    # Because the outputs goes to *.log files, they will be also included in the artifact with test outputs.
    - bash: |
        echo ">>> lscpu"
        lscpu | tee lscpu.log
        echo ">>> cpuinfo"
        cat /proc/cpuinfo | tee cpuinfo.log
        /usr/bin/gcc-8 --version | tee gcc.log
      displayName: Machine statistics
      workingDirectory: marian-prod-tests

    - bash: |
        cd models
        bash download-models.sh
        ls
      displayName: Prepare tests
      env:
          AWS_SECRET_SAS_TOKEN: $(blob-sas-token)
      workingDirectory: marian-prod-tests

    - bash: MARIAN=../marian-dev/build bash ./run_mrt.sh '#cpu' '#basics' '#devops'
      continueOnError: true
      displayName: Run tests
      workingDirectory: marian-prod-tests

    - bash: |
        # cut -c3- removes './' from paths making 7z to retain the directory structure
        find . -type f \( -name "*.log" -o -name "*.out" -o -name "*.diff" \) -print | cut -c3- > listing.txt
        echo "Creating an artifact with the following files:"
        cat listing.txt
        7z a -tzip ../regression-tests-ci_linux-x64-static_cpu.zip @listing.txt
      displayName: Collect outputs
      workingDirectory: marian-prod-tests

    - publish: regression-tests-ci_linux-x64-static_cpu.zip
      artifact: regression-tests-ci_linux-x64-static_cpu
      displayName: Publish outputs