summaryrefslogtreecommitdiff
path: root/.github/workflows/build_test.yml
blob: 70e11a4a44a538201096ab8a1da62f6c7aa7fc7d (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
name: Build_Test

on:
  push:
    branches:
      # coverage comparison in the "full" step needs to run on main after merges
      - main
  pull_request:
    branches:
      - main
      - maintenance/**

defaults:
  run:
    shell: bash

env:
  DOWNLOAD_OPENBLAS: 1
  PYTHON_VERSION: 3.9

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

permissions:
  contents: read # to fetch code (actions/checkout)

jobs:
  lint:
    if: github.repository == 'numpy/numpy' && github.event_name != 'push'
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - name: Install linter requirements
      run:
        python -m pip install -r linter_requirements.txt
    - name: Run linter on PR diff
      run:
        python tools/linter.py --branch origin/${{ github.base_ref }}

  smoke_test:
    if: "github.repository == 'numpy/numpy'"
    runs-on: ubuntu-latest
    env:
      WITHOUT_SIMD: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  basic:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    strategy:
      matrix:
        python-version: ["3.9", "3.10", "3.11", "pypy3.9-v7.3.11"]
    env:
      EXPECT_CPU_FEATURES: "SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL"
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ matrix.python-version }}
    - uses: ./.github/actions

  old_gcc:
    needs: [smoke_test]
    # provides GCC  7, 8
    runs-on: ubuntu-20.04
    if: github.event_name != 'push'
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    # comes with python3.6
    - name: Install Python3.9
      run: |
        sudo apt update
        # for add-apt-repository
        sudo apt install software-properties-common -y
        sudo add-apt-repository ppa:deadsnakes/ppa -y
        sudo apt install python3.9-dev -y
        sudo ln -s /usr/bin/python3.9 /usr/bin/pythonx
        pythonx -m pip install --upgrade pip setuptools wheel
        pythonx -m pip install -r test_requirements.txt
    - name: Install Compilers
      run: sudo apt install g++-7 g++-8 -y
    - name: Build gcc-7
      run: |
        export CC=/usr/bin/gcc-7
        export CXX=/usr/bin/g++-7
        rm -rf build && pythonx setup.py install --user
    - name: Runtests gcc-7
      run: pythonx runtests.py -n
    - name: Build gcc-8
      run: |
        export CC=/usr/bin/gcc-8
        export CXX=/usr/bin/g++-8
        rm -rf build && pythonx setup.py install --user
    - name: Runtests gcc-8
      run: pythonx runtests.py -n

  without_optimizations:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      WITHOUT_OPTIMIZATIONS: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  with_baseline_only:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      CPU_DISPATCH: "none"
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  without_avx512:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      CPU_DISPATCH: "max -xop -fma4 -avx512f -avx512cd -avx512_knl -avx512_knm -avx512_skx -avx512_clx -avx512_cnl -avx512_icl"
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  without_avx512_avx2_fma3:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      CPU_DISPATCH: "SSSE3 SSE41 POPCNT SSE42 AVX F16C"
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  debug:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      USE_DEBUG: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  blas64:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      NPY_USE_BLAS_ILP64: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  full:
    needs: [smoke_test]
    runs-on: ubuntu-22.04
    env:
      USE_WHEEL: 1
      RUN_FULL_TESTS: 1
      RUN_COVERAGE: 1
      INSTALL_PICKLE5: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  benchmark:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      PYTHONOPTIMIZE: 2
      BLAS: None
      LAPACK: None
      ATLAS: None
      NPY_BLAS_ORDER: mkl,blis,openblas,atlas,blas
      NPY_LAPACK_ORDER: MKL,OPENBLAS,ATLAS,LAPACK
      USE_ASV: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  relaxed_strides_debug:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      CHECK_BLAS: 1
      NPY_USE_BLAS_ILP64: 1
      NPY_RELAXED_STRIDES_DEBUG: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  use_wheel:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      USE_WHEEL: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  numpy2_flag:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      # Test for numpy-2.0 feature-flagged behavior.
      NPY_NUMPY_2_BEHAVIOR: 1
      # Using the future "weak" state doesn't pass tests
      # currently unfortunately
      NPY_PROMOTION_STATE: legacy
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  no_openblas:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      BLAS: None
      LAPACK: None
      ATLAS: None
      DOWNLOAD_OPENBLAS: ''
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  sdist:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    if: github.event_name != 'push'
    env:
      USE_SDIST: 1
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - uses: ./.github/actions

  armv7_simd_test:
    needs: [smoke_test]
    # make sure this matches the base docker image below
    runs-on: ubuntu-22.04
    if: github.event_name != 'push'
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - name: Initialize binfmt_misc for qemu-user-static
      run: |
        docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
    - name: Creates new container
      run: |
        # use x86_64 cross-compiler to speed up the build
        sudo apt update
        sudo apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gfortran-arm-linux-gnueabihf

        # Keep the `test_requirements.txt` dependency-subset synced
        docker run --name the_container --interactive -v /:/host arm32v7/ubuntu:22.04 /bin/bash -c "
          apt update &&
          apt install -y git python3 python3-dev python3-pip  &&
          python3 -m pip install cython==0.29.34 setuptools\<49.2.0 hypothesis==6.23.3 pytest==6.2.5 'typing_extensions>=4.2.0' &&
          ln -s /host/lib64 /lib64 &&
          ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
          ln -s /host/usr/arm-linux-gnueabihf /usr/arm-linux-gnueabihf &&
          rm -rf /usr/lib/gcc/arm-linux-gnueabihf && ln -s /host/usr/lib/gcc-cross/arm-linux-gnueabihf /usr/lib/gcc/arm-linux-gnueabihf &&
          rm -f /usr/bin/arm-linux-gnueabihf-gcc && ln -s /host/usr/bin/arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc &&
          rm -f /usr/bin/arm-linux-gnueabihf-g++ && ln -s /host/usr/bin/arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++ &&
          rm -f /usr/bin/arm-linux-gnueabihf-gfortran && ln -s /host/usr/bin/arm-linux-gnueabihf-gfortran /usr/bin/arm-linux-gnueabihf-gfortran &&
          rm -f /usr/bin/arm-linux-gnueabihf-ar && ln -s /host/usr/bin/arm-linux-gnueabihf-ar /usr/bin/arm-linux-gnueabihf-ar &&
          rm -f /usr/bin/arm-linux-gnueabihf-as && ln -s /host/usr/bin/arm-linux-gnueabihf-as /usr/bin/arm-linux-gnueabihf-as &&
          rm -f /usr/bin/arm-linux-gnueabihf-ld && ln -s /host/usr/bin/arm-linux-gnueabihf-ld /usr/bin/arm-linux-gnueabihf-ld &&
          rm -f /usr/bin/arm-linux-gnueabihf-ld.bfd && ln -s /host/usr/bin/arm-linux-gnueabihf-ld.bfd /usr/bin/arm-linux-gnueabihf-ld.bfd
        "
        docker commit the_container the_container
    - name: Build
      run: |
        sudo docker run --name the_build --interactive -v $(pwd):/numpy -v /:/host the_container /bin/bash -c "
          uname -a &&
          gcc --version &&
          g++ --version &&
          arm-linux-gnueabihf-gfortran --version &&
          python3 --version &&
          git config --global --add safe.directory /numpy
          cd /numpy &&
          python3 setup.py install
        "
        docker commit the_build the_build
    - name: Run SIMD Tests
      run: |
        docker run --rm --interactive -v $(pwd):/numpy the_build /bin/bash -c "
          cd /numpy && F90=arm-linux-gnueabihf-gfortran python3 runtests.py -n -v -- -k 'test_simd or test_kind'
        "

  sde_simd_avx512_test:
    # Intel Software Development Emulator (SDE) is used to run a given program
    # on a specific instruction set architecture and capture various performance details.
    # see https://www.intel.com/content/www/us/en/developer/articles/tool/software-development-emulator.html
    needs: [smoke_test]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - name: Install Intel SDE
      run: |
        curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/732268/sde-external-9.7.0-2022-05-09-lin.tar.xz
        mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/
        sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde
    - name: Install dependencies
      run: python -m pip install -r test_requirements.txt
    - name: Build
      run: python setup.py build
           --simd-test="\$werror AVX512F AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL"
           install
    # KNM implies KNL
    - name: Run SIMD tests (Xeon PHI)
      run: sde -knm -- python runtests.py -n -v -- -k test_simd
    # ICL implies SKX, CLX and CNL
    - name: Run SIMD tests (Ice Lake)
      run: sde -icl -- python runtests.py -n -v -- -k test_simd

  intel_spr_sde_test:
    needs: [smoke_test]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.4.0
      with:
        submodules: recursive
        fetch-depth: 0
    - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - name: Install Intel SDE
      run: |
        curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/751535/sde-external-9.14.0-2022-10-25-lin.tar.xz
        mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/
        sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde
    - name: Install dependencies
      run: |
        python -m pip install -r test_requirements.txt
        sudo apt install gcc-12 g++-12
    - name: Build and install NumPy
      run: |
        export CC=/usr/bin/gcc-12
        export CXX=/usr/bin/g++-12
        python -m pip install -e .
    - name: Show config
      run: |
        python -c "import numpy as np; np.show_config()"
    # Run only a few tests, running everything in an SDE takes a long time
    # Using pytest directly, unable to use python runtests.py -n -t ...
    # Disabled running in the SDE because of an SDE bug
    - name: Run linalg/ufunc/umath tests
      run: |
        python -m pytest numpy/core/tests/test_umath* numpy/core/tests/test_ufunc.py numpy/linalg/tests/test_*
        #sde -spr -- python -m pytest numpy/core/tests/test_umath* numpy/core/tests/test_ufunc.py numpy/linalg/tests/test_*