File: ci-abi.yml

package info (click to toggle)
mpi4py 4.1.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,564 kB
  • sloc: python: 35,306; ansic: 16,482; sh: 842; makefile: 618; cpp: 193; f90: 178
file content (435 lines) | stat: -rw-r--r-- 13,708 bytes parent folder | download | duplicates (4)
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
name: ci-abi

on:  # yamllint disable-line rule:truthy
  workflow_call:
    inputs:
      py-sabi:
        description: 'Python Stable ABI version'
        required: false
        default: ''
        type: string
      py-build:
        description: 'Python version (build)'
        required: false
        default: ''
        type: string
      py-test:
        description: 'Python version (test)'
        required: false
        default: ''
        type: string
      platform:
        description: 'Platform'
        required: false
        default: '*'
        type: string
  workflow_dispatch:
    inputs:
      py-sabi:
        description: 'Python Stable ABI version'
        required: false
        default: ''
        type: string
      py-build:
        description: 'Python version (build)'
        required: false
        default: ''
        type: string
      py-test:
        description: 'Python version (test)'
        required: false
        default: ''
        type: string
      platform:
        description: 'Platform'
        required: false
        default: '*'
        type: choice
        options:
          - '*'
          - Linux-aarch64
          - Linux-x86_64
          - macOS-arm64
          - macOS-x86_64
          - Windows-AMD64

permissions:
  contents: read

jobs:

  setup:
    name: setup
    runs-on: ubuntu-latest
    outputs:
      matrix-build: ${{ steps.matrix.outputs.matrix-build }}
      matrix-test:  ${{ steps.matrix.outputs.matrix-test  }}
    steps:
    - uses: step-security/harden-runner@v2
      with: {egress-policy: audit}
    - id: matrix
      name: setup build/test matrix
      shell: python
      run: |
        # setup build/test matrix #"
        MPI = {
            "mpiabi": [
            ],
            "mpich": [
                "3.4.3",
                "4.1.2",
                "4.3.1",
            ],
            "openmpi": [
                "4.1.6",
                "5.0.8",
            ],
            "impi": [
                "2021.7.1.15761",
                "2021.16.1.802",
            ],
            "msmpi": [
                "10.0.12498.5",
                "10.1.12498.52",
            ],
        }
        MPIABI_POSIX = ["mpiabi", "mpich", "openmpi"]
        MPIABI_WINNT = ["mpiabi", "impi", "msmpi"]
        MPIABI = {
            "Linux":   MPIABI_POSIX,
            "macOS":   MPIABI_POSIX,
            "Windows": MPIABI_WINNT,
        }
        RUNNER = {
            "Linux": {
                "aarch64": "ubuntu-24.04-arm",
                "x86_64":  "ubuntu-24.04",
            },
            "macOS": {
                "arm64": "macos-15",
                "x86_64": "macos-15-intel",
            },
            "Windows": {
                "AMD64": "windows-2025",
            },
        }
        PLATFORMS = (
            [(os, arch) for os in RUNNER for arch in RUNNER[os]]
            if "${{ inputs.platform }}" in ("*", "") else
            [tuple("${{ inputs.platform }}".split("-", 1))]
        )
        PYSABI = "${{ inputs.py-sabi || '3.10' }}"
        py_build = "${{ inputs.py-build }}"
        py_test = "${{ inputs.py-test }}"
        PY_BUILD = [py_build] if py_build else [PYSABI]
        PY_TEST = [py_test] if py_test else [PYSABI, "3"]
        # fill build/test matrix
        build = [
            {
                "py": py,
                "mpi": name,
                "platform": f"{os}-{arch}",
                "runner": RUNNER[os][arch],
            }
            for os, arch in PLATFORMS
            for py in PY_BUILD[:]
            for name in MPIABI[os]
        ]
        test = [
            {
                "py": py,
                "mpi": name,
                "mpi-version": version,
                "platform": f"{os}-{arch}",
                "runner": RUNNER[os][arch],
            }
            for os, arch in PLATFORMS
            for py in PY_TEST[:]
            for name in MPIABI[os]
            for version in MPI[name]
        ]
        # output build/test matrix
        import os, json
        with open(os.getenv("GITHUB_OUTPUT"), "w") as out:
            print(f"matrix-build={json.dumps(build)}", file=out)
            print(f"matrix-test={json.dumps(test)}", file=out)
        # "

  build:
    name: build (${{ matrix.platform }}, ${{ matrix.mpi }})
    runs-on: ${{ matrix.runner }}
    needs: setup
    strategy:
      fail-fast: false
      matrix:
        include: ${{ fromJSON(needs.setup.outputs.matrix-build) }}

    steps:

    - uses: step-security/harden-runner@v2
      with:
        egress-policy: audit

    - name: Checkout
      uses: actions/checkout@v5

    - if: matrix.mpi == 'mpiabi'
      name: Checkout MPI ABI stubs
      uses: actions/checkout@v5
      with:
        repository: mpi-forum/mpi-abi-stubs
        path: mpi-abi-stubs
        ref: main

    - if: matrix.mpi == 'mpiabi'
      name: Install MPI ABI stubs
      run: |
        bash build-cmake.sh
        echo "MPI_ABI_STUBS=$PREFIX" >> "$GITHUB_ENV"
      env:
        PREFIX: ${{ runner.temp }}/mpi-abi-stubs
      working-directory: mpi-abi-stubs
      shell: bash

    - if: runner.os != 'Windows' && matrix.mpi != 'mpiabi'
      id: micromamba
      name: Download MPI (${{ matrix.mpi }})
      uses: mamba-org/setup-micromamba@v2
      with:
        init-shell: none
        post-cleanup: none
        environment-name: ${{ matrix.mpi }}
        create-args: >-
          --relocate-prefix /opt/${{ matrix.mpi }}
          ${{ matrix.mpi }}
        condarc: |
          show_channel_urls: true
          channel_priority: strict
          channels:
            - conda-forge
            - conda-forge/label/python_rc
            - nodefaults

    - if: runner.os != 'Windows' && matrix.mpi != 'mpiabi'
      name: Install MPI (${{ matrix.mpi }})
      run: |
        # install MPI
        mpiname=${{ matrix.mpi }}
        prefix=/opt/${{ matrix.mpi }}
        envdir=${{ steps.micromamba.outputs.environment-path }}
        # tweak environment
        sudo mv "$envdir" "$prefix"
        echo "$prefix/bin" >> "$GITHUB_PATH"
        if [[ "$mpiname" == "mpich" ]]; then
        echo MPICH_CC=cc >> "$GITHUB_ENV"; fi
        if [[ "$mpiname" == "openmpi" ]]; then
        echo OMPI_CC=cc >> "$GITHUB_ENV"
        echo OMPI_MCA_pml=ob1 >> "$GITHUB_ENV"
        echo OMPI_MCA_btl=tcp,self >> "$GITHUB_ENV"; fi

    - if: runner.os == 'Windows' && matrix.mpi == 'impi'
      name: Install Intel MPI
      run: |
        # install Intel MPI
        mpiroot="$(pwd)/impi"
        mkdir -p "$mpiroot"
        # install build package
        mpi=intelmpi.devel.win-x64
        nuget install "$mpi"
        install=$(ls -d "$mpi".*/build/native)
        cp -a "$install/include" "$mpiroot"
        cp -a "$install/win-x64/lib" "$mpiroot"
        # tweak environment
        echo "$(cygpath -w "$mpiroot/bin")" >> "$GITHUB_PATH"
        echo "I_MPI_ROOT=$(cygpath -w "$mpiroot")" >> "$GITHUB_ENV"
      working-directory: ${{ runner.temp }}
      shell: bash

    - if: runner.os == 'Windows' && matrix.mpi == 'msmpi'
      name: Install Microsoft MPI
      run: |
        # install Intel MPI
        mpiroot="$(pwd)/msmpi"
        mkdir -p "$mpiroot"
        # install SDK package
        mpi=MSMPISDK
        nuget install "$mpi"
        install=$(ls -d "$mpi".*/)
        cp -a "$install/include" "$mpiroot"
        cp -a "$install/lib" "$mpiroot"
        # tweak environment
        msmpi_inc="$mpiroot/include"
        msmpi_lib32="$mpiroot/lib/x86"
        msmpi_lib64=$"$mpiroot/lib/x64"
        echo "MSMPI_INC=$(cygpath -w "$msmpi_inc")" >> "$GITHUB_ENV"
        echo "MSMPI_LIB32=$(cygpath -w "$msmpi_lib32")" >> "$GITHUB_ENV"
        echo "MSMPI_LIB64=$(cygpath -w "$msmpi_lib64")" >> "$GITHUB_ENV"
      working-directory: ${{ runner.temp }}
      shell: bash

    - name: Setup Python (${{ matrix.py }})
      uses: actions/setup-python@v6
      with:
        python-version: ${{ matrix.py }}
        allow-prereleases: true
        cache: pip
        cache-dependency-path: |
          conf/requirements-build-cython.txt

    - name: Upgrade pip
      run:  python -m pip install -U pip

    - name: Install build
      run:  python -m pip install -U build

    - name: Build mpi4py wheel
      run:  python -m build --verbose --wheel
      env:
        MPI4PY_BUILD_PYSABI: "${{ inputs.py-sabi || '1' }}"
        MPI4PY_BUILD_MPIABI: "1"
        CFLAGS: "-O0"

    - name: Upload mpi4py wheel
      uses: actions/upload-artifact@v4
      with:
        name: mpi4py-abi-${{ matrix.mpi }}-${{ matrix.platform }}
        path: dist/mpi4py-*.whl

  test:
    name: >-
      test (${{ format('{0}, {1}, {2}, {3}',
      matrix.platform, matrix.py, matrix.mpi, matrix.mpi-version) }})
    runs-on: ${{ matrix.runner }}
    needs: [setup, build]
    strategy:
      fail-fast: false
      matrix:
        include: ${{ fromJSON(needs.setup.outputs.matrix-test) }}

    steps:

    - uses: step-security/harden-runner@v2
      with:
        egress-policy: audit

    - if: runner.os != 'Windows'
      id: micromamba
      name: Download MPI (${{ matrix.mpi }}-${{ matrix.mpi-version }})
      uses: mamba-org/setup-micromamba@v2
      with:
        init-shell: none
        post-cleanup: none
        environment-name: ${{ matrix.mpi }}
        create-args: >-
          --relocate-prefix /opt/${{ matrix.mpi }}
          ${{ matrix.mpi }}=${{ matrix.mpi-version }}
        condarc: |
          show_channel_urls: true
          channel_priority: strict
          channels:
            - conda-forge
            - nodefaults

    - if: runner.os != 'Windows'
      name: Install MPI (${{ matrix.mpi }}-${{ matrix.mpi-version }})
      run: |
        mpiname=${{ matrix.mpi }} version=${{ matrix.mpi-version }}
        prefix=/opt/${{ matrix.mpi }}
        envdir=${{ steps.micromamba.outputs.environment-path }}
        sudo mv "$envdir" "$prefix"
        # tweak environment
        echo "$prefix/bin" >> $GITHUB_PATH
        if [[ "$mpiname" == "openmpi" ]]; then
        # Set OMPI/PRRTE MCA parameters
        mca_params="$HOME/.openmpi/mca-params.conf"
        mkdir -p "$(dirname "$mca_params")"
        echo pml=ob1 >> $mca_params
        echo btl=tcp,self >> $mca_params
        echo mpi_param_check = true >> "$mca_params"
        echo mpi_show_handle_leaks = true >> "$mca_params"
        echo rmaps_base_oversubscribe = true >> "$mca_params"
        mca_params="$HOME/.prte/mca-params.conf"
        mkdir -p "$(dirname "$mca_params")"
        echo rmaps_default_mapping_policy = :oversubscribe >> "$mca_params"
        if [[ "${version%%.*}" -lt 5 ]]; then
        # Use MPI_THREAD_LEVEL=MPI_THREAD_SERIALIZED with openmpi<5
        echo MPI4PY_RC_THREAD_LEVEL=serialized >> $GITHUB_ENV
        fi; fi;

    - if: runner.os == 'Windows' && matrix.mpi == 'impi'
      name: Install Intel MPI (${{ matrix.mpi-version }})
      run: |
        mpi=intelmpi.redist.win-x64 version=${{ matrix.mpi-version }}
        nuget install $mpi -Version $version
        mpiroot="$(pwd)/$mpi.$version/runtimes/win-x64/native"
        echo "$(cygpath -w "$mpiroot/bin")" >> "$GITHUB_PATH"
        echo "I_MPI_ROOT=$(cygpath -w "$mpiroot")" >> "$GITHUB_ENV"
        echo "I_MPI_SPAWN=1" >> "$GITHUB_ENV"
        echo "I_MPI_SPIN_COUNT=1" >> "$GITHUB_ENV"
        echo "I_MPI_THREAD_YIELD=2" >> "$GITHUB_ENV"
      working-directory: ${{ runner.temp }}
      shell: bash

    - if: runner.os == 'Windows' && matrix.mpi == 'msmpi'
      name: Install Microsoft MPI (${{ matrix.mpi-version }})
      run: |
        mpi=MSMpiSetup.exe version=${{ matrix.mpi-version }}
        url="https://download.microsoft.com/download/"
        case "$version" in
        10.0.*) hash="A/E/0/AE002626-9D9D-448D-8197-1EA510E297CE" ;;
        10.1.*) hash="7/2/7/72731ebb-b63c-4170-ade7-836966263a8f" ;;
        esac
        curl -sSLO "${url}${hash}"/$mpi
        ./MSMpiSetup.exe -unattend
        cmd='[Environment]::GetEnvironmentVariable("MSMPI_BIN","Machine")'
        echo "$(pwsh -c "$cmd")" >> "$GITHUB_PATH"
      working-directory: ${{ runner.temp }}
      shell: bash

    - name: Setup Python (${{ matrix.py }})
      uses: actions/setup-python@v6
      with:
        python-version: ${{ matrix.py }}
        allow-prereleases: true

    - name: Upgrade pip
      run:  python -m pip install -U pip

    - name: Download mpi4py wheel
      uses: actions/download-artifact@v5
      with:
        name: mpi4py-abi-${{ matrix.mpi }}-${{ matrix.platform }}
        path: dist

    - name: Install mpi4py wheel
      run:  python -m pip install mpi4py
              --verbose --no-index --find-links=dist

    - name: Checkout
      uses: actions/checkout@v5

    - name: Set hostname
      run:  sudo hostname localhost
      if:   runner.os == 'macOS'

    - name: Test mpi4py cmdline (mpi-library)
      run:  mpiexec -n 1 python -m mpi4py --mpi-library
    - name: Test mpi4py cmdline (mpi-std-version)
      run:  mpiexec -n 1 python -m mpi4py --mpi-std-version
    - name: Test mpi4py cmdline (mpi-lib-version)
      run:  mpiexec -n 1 python -m mpi4py --mpi-lib-version
    - name: Test mpi4py bench (helloworld)
      run:  mpiexec -n 4 python -m mpi4py.bench helloworld
    - name: Test mpi4py bench (ringtest)
      run:  mpiexec -n 4 python -m mpi4py.bench ringtest

    - name: Test mpi4py (np=1)
      run:  mpiexec -n 1 python test/main.py -v -e 'spawn|dynproc|pool'
    - name: Test mpi4py (np=2)
      run:  mpiexec -n 2 python test/main.py -v -f -i 'comm|p2p|cco|rma'
    - name: Test mpi4py (np=3)
      run:  mpiexec -n 3 python test/main.py -v -f -i 'comm|p2p|cco|rma'

    - name: Uninstall mpi4py
      run:  python -m pip uninstall mpi4py
              --verbose --yes