Skip to content

Commit 2e20165

Browse files
dalcinljeffhammond
authored andcommitted
CI: Add mpi4py build and checks
1 parent 29be950 commit 2e20165

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

.github/workflows/mpi4py.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: mpi4py
2+
3+
on: # yamllint disable-line rule:truthy
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
21+
mpi4py:
22+
runs-on: ubuntu-latest
23+
steps:
24+
25+
- name: Checkout mpi-stubs
26+
uses: actions/checkout@v4
27+
with:
28+
path: mpi-stubs
29+
30+
- name: Install mpi-stubs
31+
run: make -C mpi-stubs
32+
33+
- run: |
34+
mpi_stubs=${{ github.workspace }}/mpi-stubs
35+
echo $mpi_stubs/bin >> $GITHUB_PATH
36+
echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$mpi_stubs/lib >> $GITHUB_ENV
37+
38+
- name: Setup Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: 3
42+
43+
- name: Checkout mpi4py
44+
uses: actions/checkout@v4
45+
with:
46+
repository: mpi4py/mpi4py
47+
path: mpi4py
48+
49+
- name: Install mpi4py
50+
run: python -m pip install ./mpi4py
51+
env:
52+
CPPFLAGS: "-DMPI_ABI=1"
53+
CFLAGS: "-O0"
54+
55+
- name: Check mpi4py symbols
56+
run: |
57+
module=$(python -m mpi4py --prefix)/MPI.*.so
58+
nci=$(nm $module | awk '/ PyMPI_.*_c$/' | wc -l)
59+
ncx=$(nm $module | awk '/ MPI_.*_x$/' | wc -l)
60+
ncc=$(nm $module | awk '/ MPI_.*_c$/' | wc -l)
61+
test $nci -eq 0
62+
test $ncx -eq 0
63+
test $ncc -ge 159
64+
65+
- name: Test mpi4py module
66+
shell: python {0}
67+
run: |
68+
# load-python-module
69+
import importlib.util as imp
70+
spec = imp.find_spec("mpi4py.MPI")
71+
module = imp.module_from_spec(spec)
72+
print(module)
73+
74+
- name: Configure mpi4py (small-count)
75+
run: |
76+
config=mpi4py/src/lib-mpi/config.h
77+
echo "#undef MPI_VERSION" >> config.h
78+
echo "#undef MPI_SUBVERSION" >> config.h
79+
echo "#define MPI_VERSION 3" >> config.h
80+
echo "#define MPI_SUBVERSION 1" >> config.h
81+
cat mpi4py/src/lib-mpi/config.h >> config.h
82+
mv config.h mpi4py/src/lib-mpi/config.h
83+
84+
- name: Install mpi4py (small-count)
85+
run: python -m pip install ./mpi4py
86+
env:
87+
CPPFLAGS: "-DMPI_ABI=1"
88+
CFLAGS: "-O0"
89+
90+
- name: Check mpi4py symbols (small-count)
91+
run: |
92+
module=$(python -m mpi4py --prefix)/MPI.*.so
93+
nci=$(nm $module | awk '/ PyMPI_.*_c$/' | wc -l)
94+
ncx=$(nm $module | awk '/ MPI_.*_x$/' | wc -l)
95+
ncc=$(nm $module | awk '/ MPI_.*_c$/' | wc -l)
96+
test $nci -ge 149
97+
test $ncx -eq 5
98+
test $ncc -eq 0
99+
100+
- name: Test mpi4py module (small-count)
101+
shell: python {0}
102+
run: |
103+
# load-python-module
104+
import importlib.util as imp
105+
spec = imp.find_spec("mpi4py.MPI")
106+
module = imp.module_from_spec(spec)
107+
print(module)

0 commit comments

Comments
 (0)