numba-mpi 0.40__tar.gz → 0.43__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {numba-mpi-0.40 → numba_mpi-0.43}/.github/workflows/readme_snippets.yml +14 -2
- {numba-mpi-0.40 → numba_mpi-0.43}/.github/workflows/tests+pypi.yml +5 -4
- numba_mpi-0.43/CODE_OF_CONDUCT.md +47 -0
- numba_mpi-0.43/PKG-INFO +179 -0
- numba_mpi-0.43/README.md +159 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/__init__.py +3 -1
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/requests.py +18 -0
- numba_mpi-0.43/numba_mpi.egg-info/PKG-INFO +179 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi.egg-info/SOURCES.txt +1 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/setup.py +1 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_isend_irecv.py +23 -5
- numba-mpi-0.40/PKG-INFO +0 -66
- numba-mpi-0.40/README.md +0 -47
- numba-mpi-0.40/numba_mpi.egg-info/PKG-INFO +0 -66
- {numba-mpi-0.40 → numba_mpi-0.43}/.github/numba_mpi_logo.svg +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/.github/workflows/stale.yml +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/.gitignore +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/.pre-commit-config.yaml +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/.vscode/settings.json +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/.zenodo.json +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/LICENSE +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/__init__.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/allreduce.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/barrier.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/bcast.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/initialized.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/irecv.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/isend.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/operator.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/rank.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/recv.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/scatter_gather.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/send.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/size.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/api/wtime.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/common.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi/utils.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi.egg-info/dependency_links.txt +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi.egg-info/requires.txt +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/numba_mpi.egg-info/top_level.txt +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/setup.cfg +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/__init__.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_allreduce.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_barrier.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_bcast.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_init.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_rank.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_scatter_gather.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_send_recv.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_size.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/api/test_wtime.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/common.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/test_version.py +0 -0
- {numba-mpi-0.40 → numba_mpi-0.43}/tests/utils.py +0 -0
@@ -22,7 +22,19 @@ jobs:
|
|
22
22
|
python-version: "3.10"
|
23
23
|
- uses: mpi4py/setup-mpi@v1
|
24
24
|
- run: pip install -e .
|
25
|
-
- run: pip install pytest-codeblocks pytest
|
25
|
+
- run: pip install pytest-codeblocks pytest matplotlib
|
26
|
+
- run: sudo apt-get install librsvg2-bin
|
26
27
|
- run: python -c "import pytest_codeblocks; code=pytest_codeblocks.extract_from_file('README.md'); f=open('readme.py', 'w'); f.writelines(block.code for block in code if block.syntax=='python'); f.close()"
|
27
28
|
- run: cat -n readme.py
|
28
|
-
- run: mpiexec -n
|
29
|
+
- run: mpiexec -n 4 python -We readme.py
|
30
|
+
- run: rsvg-convert readme_plot.svg > readme_plot.png
|
31
|
+
- uses: actions/upload-artifact@v3
|
32
|
+
with:
|
33
|
+
path: readme_plot.*
|
34
|
+
name: readme_plot
|
35
|
+
- if: github.ref == 'refs/heads/main'
|
36
|
+
uses: eine/tip@master
|
37
|
+
with:
|
38
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
39
|
+
files: |
|
40
|
+
readme_plot.png
|
@@ -88,13 +88,14 @@ jobs:
|
|
88
88
|
needs: [pylint, precommit, pdoc, zenodo_json]
|
89
89
|
strategy:
|
90
90
|
matrix:
|
91
|
-
|
91
|
+
mpi-np: [2, 3]
|
92
|
+
platform: [ubuntu-latest, macos-12, windows-latest]
|
92
93
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
93
94
|
mpi: [ 'mpich', 'openmpi', 'msmpi', 'intelmpi']
|
94
95
|
exclude:
|
95
|
-
- platform: macos-
|
96
|
+
- platform: macos-12
|
96
97
|
mpi: msmpi
|
97
|
-
- platform: macos-
|
98
|
+
- platform: macos-12
|
98
99
|
mpi: intelmpi
|
99
100
|
- platform: ubuntu-latest
|
100
101
|
mpi: msmpi
|
@@ -130,7 +131,7 @@ jobs:
|
|
130
131
|
- run: pip install -e .[tests]
|
131
132
|
- run: python -We -c "import mpi4py"
|
132
133
|
- run: python -We -c "import numba_mpi"
|
133
|
-
- run: mpiexec -n
|
134
|
+
- run: mpiexec -n ${{ matrix.mpi-np }} pytest --durations=10 -p no:unraisableexception -We
|
134
135
|
|
135
136
|
dist:
|
136
137
|
runs-on: ubuntu-latest
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Code of conduct for the numba-mpi open-source project
|
2
|
+
|
3
|
+
As [contributors and maintainers of this project](https://github.com/orgs/numba-mpi/people),
|
4
|
+
and in the interest of fostering an open and welcoming community, we pledge to respect all
|
5
|
+
people who contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free experience for
|
9
|
+
everyone, regardless of level of technical experience and regardless of any non-technical
|
10
|
+
personal characteristic or identity trait (gender, religion, physicality, age, ethnicity,
|
11
|
+
essentially **any**).
|
12
|
+
|
13
|
+
Nurturing open and unemotional code reviews and community discussions, we aim at ensuring
|
14
|
+
fruitful and enriching collaboration experience and maintaining quality engineering
|
15
|
+
standards. This Code of Conduct applies both within project spaces and in public spaces
|
16
|
+
when an individual is representing the project or its community.
|
17
|
+
|
18
|
+
Examples of unacceptable behavior by participants include:
|
19
|
+
|
20
|
+
* Breaching project security (e.g., granting GitHub access rights without ensuring
|
21
|
+
collaborators' consent);
|
22
|
+
* Breaching collaborators' privacy (e.g., publishing other's private information without
|
23
|
+
permission);
|
24
|
+
* Force developments (e.g., merging or releasing against expressed collaborators' comments
|
25
|
+
against doing it);
|
26
|
+
* Any form of harassing language of exclusion;
|
27
|
+
* Other unethical or unprofessional conduct (if in doubt, ask!).
|
28
|
+
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments,
|
30
|
+
commits, code, issues, and other contributions that are not aligned to this Code of Conduct,
|
31
|
+
or to ban temporarily or permanently any contributor for other behaviors that they deem
|
32
|
+
inappropriate, threatening, offensive, or harmful. By adopting this Code of Conduct, project
|
33
|
+
maintainers commit themselves to fairly, consistently and collaboratively applying these
|
34
|
+
principles to every aspect of managing this project.
|
35
|
+
|
36
|
+
Reporting actions that are violating the hereby Code of Conduct can be done publicly on the
|
37
|
+
project GitHub space, or if needed, can be reported directly to any of the
|
38
|
+
[project maintainers listed on GitHub](https://github.com/orgs/numba-mpi/people)
|
39
|
+
(as of the time of writing: Sylwester Arabas, David Zwicker, Kacper Derlatka, et al.).
|
40
|
+
Maintainers are obligated to maintain confidentiality with regard to the reporter of a
|
41
|
+
privately reported incident.
|
42
|
+
|
43
|
+
Please note that, as of time of writing, the entirety of the project team is engaged in the
|
44
|
+
development purely on voluntary basis.
|
45
|
+
|
46
|
+
--
|
47
|
+
This Code of Conduct was inspired by [Numba Code of Conduct](https://github.com/numba/numba-governance/blob/accepted/code-of-conduct.md).
|
numba_mpi-0.43/PKG-INFO
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: numba-mpi
|
3
|
+
Version: 0.43
|
4
|
+
Summary: Numba @njittable MPI wrappers tested on Linux, macOS and Windows
|
5
|
+
Home-page: https://github.com/numba-mpi/numba-mpi
|
6
|
+
Author: https://github.com/numba-mpi/numba-mpi/graphs/contributors
|
7
|
+
License: GPL v3
|
8
|
+
Project-URL: Tracker, https://github.com/numba-mpi/numba-mpi/issues
|
9
|
+
Project-URL: Documentation, https://numba-mpi.github.io/numba-mpi
|
10
|
+
Project-URL: Source, https://github.com/numba-mpi/numba-mpi
|
11
|
+
Requires-Python: >=3.8
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENSE
|
14
|
+
Requires-Dist: numba
|
15
|
+
Requires-Dist: numpy
|
16
|
+
Requires-Dist: mpi4py
|
17
|
+
Requires-Dist: psutil
|
18
|
+
Provides-Extra: tests
|
19
|
+
Requires-Dist: pytest<8.0.0; extra == "tests"
|
20
|
+
|
21
|
+
# <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.svg" style="height:50pt" alt="numba-mpi logo"> numba-mpi
|
22
|
+
|
23
|
+
[](https://www.python.org/)
|
24
|
+
[](https://numba.pydata.org)
|
25
|
+
[](https://en.wikipedia.org/wiki/Linux)
|
26
|
+
[](https://en.wikipedia.org/wiki/macOS)
|
27
|
+
[](https://en.wikipedia.org/wiki/Windows)
|
28
|
+
[](https://github.com/numba-mpi/numba-mpi/actions/workflows/tests+pypi.yml)
|
29
|
+
[](https://GitHub.com/numba-mpi/numba-mpi/graphs/commit-activity)
|
30
|
+
[](https://www.gnu.org/licenses/gpl-3.0.html)
|
31
|
+
[](https://pypi.org/project/numba-mpi)
|
32
|
+
[](https://anaconda.org/conda-forge/numba-mpi)
|
33
|
+
[](https://aur.archlinux.org/packages/python-numba-mpi)
|
34
|
+
[](https://zenodo.org/badge/latestdoi/316911228)
|
35
|
+
|
36
|
+
### Overview
|
37
|
+
numba-mpi provides Python wrappers to the C MPI API callable from within [Numba JIT-compiled code](https://numba.readthedocs.io/en/stable/user/jit.html) (@njit mode).
|
38
|
+
|
39
|
+
Support is provided for a subset of MPI routines covering: `size`/`rank`, `send`/`recv`, `allreduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier`, `wtime`
|
40
|
+
and basic asynchronous communication with `isend`/`irecv` (only for contiguous arrays); for request handling including `wait`/`waitall`/`waitany` and `test`/`testall`/`testany`.
|
41
|
+
|
42
|
+
The API uses NumPy and supports both numeric and character datatypes (e.g., `broadcast`).
|
43
|
+
Auto-generated docstring-based API docs are published on the web: https://numba-mpi.github.io/numba-mpi
|
44
|
+
|
45
|
+
Packages can be obtained from
|
46
|
+
[PyPI](https://pypi.org/project/numba-mpi),
|
47
|
+
[Conda Forge](https://anaconda.org/conda-forge/numba-mpi),
|
48
|
+
[Arch Linux](https://aur.archlinux.org/packages/python-numba-mpi)
|
49
|
+
or by invoking `pip install git+https://github.com/numba-mpi/numba-mpi.git`.
|
50
|
+
|
51
|
+
numba-mpi is a pure-Python package.
|
52
|
+
The codebase includes a test suite used through the GitHub Actions workflows ([thanks to mpi4py's setup-mpi](https://github.com/mpi4py/setup-mpi)!)
|
53
|
+
for automated testing on: Linux ([MPICH](https://www.mpich.org/), [OpenMPI](https://www.open-mpi.org/doc/)
|
54
|
+
& [Intel MPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/mpi-library.html)),
|
55
|
+
macOS ([MPICH](https://www.mpich.org/) & [OpenMPI](https://www.open-mpi.org/doc/)) and
|
56
|
+
Windows ([MS MPI](https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi)).
|
57
|
+
|
58
|
+
Features that are not implemented yet include (help welcome!):
|
59
|
+
- support for non-default communicators
|
60
|
+
- support for `MPI_IN_PLACE` in `[all]gather`/`scatter` and `allreduce`
|
61
|
+
- support for `MPI_Type_create_struct` (Numpy structured arrays)
|
62
|
+
- ...
|
63
|
+
|
64
|
+
### Hello world send/recv example:
|
65
|
+
```python
|
66
|
+
import numba, numba_mpi, numpy
|
67
|
+
|
68
|
+
@numba.njit()
|
69
|
+
def hello():
|
70
|
+
src = numpy.array([1., 2., 3., 4., 5.])
|
71
|
+
dst_tst = numpy.empty_like(src)
|
72
|
+
|
73
|
+
if numba_mpi.rank() == 0:
|
74
|
+
numba_mpi.send(src, dest=1, tag=11)
|
75
|
+
elif numba_mpi.rank() == 1:
|
76
|
+
numba_mpi.recv(dst_tst, source=0, tag=11)
|
77
|
+
|
78
|
+
hello()
|
79
|
+
```
|
80
|
+
|
81
|
+
### Example comparing numba-mpi vs. mpi4py performance:
|
82
|
+
|
83
|
+
The example below compares `Numba`+`mpi4py` vs. `Numba`+`numba-mpi` performance.
|
84
|
+
The sample code estimates $\pi$ by numerical integration of $\int_0^1 (4/(1+x^2))dx=\pi$
|
85
|
+
dividing the workload into `n_intervals` handled by separate MPI processes
|
86
|
+
and then obtaining a sum using `allreduce` (see, e.g., analogous [Matlab docs example](https://www.mathworks.com/help/parallel-computing/numerical-estimation-of-pi-using-message-passing.html)).
|
87
|
+
The computation is carried out in a JIT-compiled function `get_pi_part()` and is repeated
|
88
|
+
`N_TIMES`. The repetitions and the MPI-handled reduction are done outside or
|
89
|
+
inside of the JIT-compiled block for `mpi4py` and `numba-mpi`, respectively.
|
90
|
+
Timing is repeated `N_REPEAT` times and the minimum time is reported.
|
91
|
+
The generated plot shown below depicts the speedup obtained by replacing `mpi4py`
|
92
|
+
with `numba_mpi`, plotted as a function of `N_TIMES / n_intervals` - the number of MPI calls per
|
93
|
+
interval. The speedup, which stems from avoiding roundtrips between JIT-compiled
|
94
|
+
and Python code is significant (150%-300%) in all cases. The more often communication
|
95
|
+
is needed (smaller `n_intervals`), the larger the measured speedup. Note that nothing
|
96
|
+
in the actual number crunching (within the `get_pi_part()` function) or in the employed communication logic
|
97
|
+
(handled by the same MPI library) differs between the `mpi4py` or `numba-mpi` solutions.
|
98
|
+
These are the overhead of `mpi4py` higher-level abstractions and the overhead of
|
99
|
+
repeatedly entering and leaving the JIT-compiled block if using `mpi4py`, which can be
|
100
|
+
eliminated by using `numba-mpi`, and which the measured differences in execution time
|
101
|
+
stem from.
|
102
|
+
```python
|
103
|
+
import timeit, mpi4py, numba, numpy as np, numba_mpi
|
104
|
+
|
105
|
+
N_TIMES = 10000
|
106
|
+
RTOL = 1e-3
|
107
|
+
|
108
|
+
@numba.jit
|
109
|
+
def get_pi_part(n_intervals=1000000, rank=0, size=1):
|
110
|
+
h = 1 / n_intervals
|
111
|
+
partial_sum = 0.0
|
112
|
+
for i in range(rank + 1, n_intervals, size):
|
113
|
+
x = h * (i - 0.5)
|
114
|
+
partial_sum += 4 / (1 + x**2)
|
115
|
+
return h * partial_sum
|
116
|
+
|
117
|
+
@numba.jit
|
118
|
+
def pi_numba_mpi(n_intervals):
|
119
|
+
pi = np.array([0.])
|
120
|
+
part = np.empty_like(pi)
|
121
|
+
for _ in range(N_TIMES):
|
122
|
+
part[0] = get_pi_part(n_intervals, numba_mpi.rank(), numba_mpi.size())
|
123
|
+
numba_mpi.allreduce(part, pi, numba_mpi.Operator.SUM)
|
124
|
+
assert abs(pi[0] - np.pi) / np.pi < RTOL
|
125
|
+
|
126
|
+
def pi_mpi4py(n_intervals):
|
127
|
+
pi = np.array([0.])
|
128
|
+
part = np.empty_like(pi)
|
129
|
+
for _ in range(N_TIMES):
|
130
|
+
part[0] = get_pi_part(n_intervals, mpi4py.MPI.COMM_WORLD.rank, mpi4py.MPI.COMM_WORLD.size)
|
131
|
+
mpi4py.MPI.COMM_WORLD.Allreduce(part, (pi, mpi4py.MPI.DOUBLE), op=mpi4py.MPI.SUM)
|
132
|
+
assert abs(pi[0] - np.pi) / np.pi < RTOL
|
133
|
+
|
134
|
+
plot_x = [x for x in range(1, 11)]
|
135
|
+
plot_y = {'numba_mpi': [], 'mpi4py': []}
|
136
|
+
for x in plot_x:
|
137
|
+
for impl in plot_y:
|
138
|
+
plot_y[impl].append(min(timeit.repeat(
|
139
|
+
f"pi_{impl}(n_intervals={N_TIMES // x})",
|
140
|
+
globals=locals(),
|
141
|
+
number=1,
|
142
|
+
repeat=10
|
143
|
+
)))
|
144
|
+
|
145
|
+
if numba_mpi.rank() == 0:
|
146
|
+
from matplotlib import pyplot
|
147
|
+
pyplot.figure(figsize=(8.3, 3.5), tight_layout=True)
|
148
|
+
pyplot.plot(plot_x, np.array(plot_y['mpi4py'])/np.array(plot_y['numba_mpi']), marker='o')
|
149
|
+
pyplot.xlabel('number of MPI calls per interval')
|
150
|
+
pyplot.ylabel('mpi4py/numba-mpi wall-time ratio')
|
151
|
+
pyplot.title(f'mpiexec -np {numba_mpi.size()}')
|
152
|
+
pyplot.grid()
|
153
|
+
pyplot.savefig('readme_plot.svg')
|
154
|
+
```
|
155
|
+
|
156
|
+

|
157
|
+
|
158
|
+
|
159
|
+
### MPI resources on the web:
|
160
|
+
|
161
|
+
- MPI standard and general information:
|
162
|
+
- https://www.mpi-forum.org/docs
|
163
|
+
- https://en.wikipedia.org/wiki/Message_Passing_Interface
|
164
|
+
- MPI implementations:
|
165
|
+
- OpenMPI: https://www.open-mpi.org
|
166
|
+
- MPICH: https://www.mpich.org
|
167
|
+
- MS MPI: https://learn.microsoft.com/en-us/message-passing-interface
|
168
|
+
- Intel MPI: https://intel.com/content/www/us/en/developer/tools/oneapi/mpi-library-documentation.html
|
169
|
+
- MPI bindings:
|
170
|
+
- Python: https://mpi4py.readthedocs.io
|
171
|
+
- Julia: https://juliaparallel.org/MPI.jl
|
172
|
+
- Rust: https://docs.rs/mpi
|
173
|
+
- C++: https://boost.org/doc/html/mpi.html
|
174
|
+
- R: https://cran.r-project.org/web/packages/Rmpi
|
175
|
+
|
176
|
+
### Acknowledgements:
|
177
|
+
|
178
|
+
Development of numba-mpi has been supported by the [Polish National Science Centre](https://ncn.gov.pl/en) (grant no. 2020/39/D/ST10/01220).
|
179
|
+
|
numba_mpi-0.43/README.md
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.svg" style="height:50pt" alt="numba-mpi logo"> numba-mpi
|
2
|
+
|
3
|
+
[](https://www.python.org/)
|
4
|
+
[](https://numba.pydata.org)
|
5
|
+
[](https://en.wikipedia.org/wiki/Linux)
|
6
|
+
[](https://en.wikipedia.org/wiki/macOS)
|
7
|
+
[](https://en.wikipedia.org/wiki/Windows)
|
8
|
+
[](https://github.com/numba-mpi/numba-mpi/actions/workflows/tests+pypi.yml)
|
9
|
+
[](https://GitHub.com/numba-mpi/numba-mpi/graphs/commit-activity)
|
10
|
+
[](https://www.gnu.org/licenses/gpl-3.0.html)
|
11
|
+
[](https://pypi.org/project/numba-mpi)
|
12
|
+
[](https://anaconda.org/conda-forge/numba-mpi)
|
13
|
+
[](https://aur.archlinux.org/packages/python-numba-mpi)
|
14
|
+
[](https://zenodo.org/badge/latestdoi/316911228)
|
15
|
+
|
16
|
+
### Overview
|
17
|
+
numba-mpi provides Python wrappers to the C MPI API callable from within [Numba JIT-compiled code](https://numba.readthedocs.io/en/stable/user/jit.html) (@njit mode).
|
18
|
+
|
19
|
+
Support is provided for a subset of MPI routines covering: `size`/`rank`, `send`/`recv`, `allreduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier`, `wtime`
|
20
|
+
and basic asynchronous communication with `isend`/`irecv` (only for contiguous arrays); for request handling including `wait`/`waitall`/`waitany` and `test`/`testall`/`testany`.
|
21
|
+
|
22
|
+
The API uses NumPy and supports both numeric and character datatypes (e.g., `broadcast`).
|
23
|
+
Auto-generated docstring-based API docs are published on the web: https://numba-mpi.github.io/numba-mpi
|
24
|
+
|
25
|
+
Packages can be obtained from
|
26
|
+
[PyPI](https://pypi.org/project/numba-mpi),
|
27
|
+
[Conda Forge](https://anaconda.org/conda-forge/numba-mpi),
|
28
|
+
[Arch Linux](https://aur.archlinux.org/packages/python-numba-mpi)
|
29
|
+
or by invoking `pip install git+https://github.com/numba-mpi/numba-mpi.git`.
|
30
|
+
|
31
|
+
numba-mpi is a pure-Python package.
|
32
|
+
The codebase includes a test suite used through the GitHub Actions workflows ([thanks to mpi4py's setup-mpi](https://github.com/mpi4py/setup-mpi)!)
|
33
|
+
for automated testing on: Linux ([MPICH](https://www.mpich.org/), [OpenMPI](https://www.open-mpi.org/doc/)
|
34
|
+
& [Intel MPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/mpi-library.html)),
|
35
|
+
macOS ([MPICH](https://www.mpich.org/) & [OpenMPI](https://www.open-mpi.org/doc/)) and
|
36
|
+
Windows ([MS MPI](https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi)).
|
37
|
+
|
38
|
+
Features that are not implemented yet include (help welcome!):
|
39
|
+
- support for non-default communicators
|
40
|
+
- support for `MPI_IN_PLACE` in `[all]gather`/`scatter` and `allreduce`
|
41
|
+
- support for `MPI_Type_create_struct` (Numpy structured arrays)
|
42
|
+
- ...
|
43
|
+
|
44
|
+
### Hello world send/recv example:
|
45
|
+
```python
|
46
|
+
import numba, numba_mpi, numpy
|
47
|
+
|
48
|
+
@numba.njit()
|
49
|
+
def hello():
|
50
|
+
src = numpy.array([1., 2., 3., 4., 5.])
|
51
|
+
dst_tst = numpy.empty_like(src)
|
52
|
+
|
53
|
+
if numba_mpi.rank() == 0:
|
54
|
+
numba_mpi.send(src, dest=1, tag=11)
|
55
|
+
elif numba_mpi.rank() == 1:
|
56
|
+
numba_mpi.recv(dst_tst, source=0, tag=11)
|
57
|
+
|
58
|
+
hello()
|
59
|
+
```
|
60
|
+
|
61
|
+
### Example comparing numba-mpi vs. mpi4py performance:
|
62
|
+
|
63
|
+
The example below compares `Numba`+`mpi4py` vs. `Numba`+`numba-mpi` performance.
|
64
|
+
The sample code estimates $\pi$ by numerical integration of $\int_0^1 (4/(1+x^2))dx=\pi$
|
65
|
+
dividing the workload into `n_intervals` handled by separate MPI processes
|
66
|
+
and then obtaining a sum using `allreduce` (see, e.g., analogous [Matlab docs example](https://www.mathworks.com/help/parallel-computing/numerical-estimation-of-pi-using-message-passing.html)).
|
67
|
+
The computation is carried out in a JIT-compiled function `get_pi_part()` and is repeated
|
68
|
+
`N_TIMES`. The repetitions and the MPI-handled reduction are done outside or
|
69
|
+
inside of the JIT-compiled block for `mpi4py` and `numba-mpi`, respectively.
|
70
|
+
Timing is repeated `N_REPEAT` times and the minimum time is reported.
|
71
|
+
The generated plot shown below depicts the speedup obtained by replacing `mpi4py`
|
72
|
+
with `numba_mpi`, plotted as a function of `N_TIMES / n_intervals` - the number of MPI calls per
|
73
|
+
interval. The speedup, which stems from avoiding roundtrips between JIT-compiled
|
74
|
+
and Python code is significant (150%-300%) in all cases. The more often communication
|
75
|
+
is needed (smaller `n_intervals`), the larger the measured speedup. Note that nothing
|
76
|
+
in the actual number crunching (within the `get_pi_part()` function) or in the employed communication logic
|
77
|
+
(handled by the same MPI library) differs between the `mpi4py` or `numba-mpi` solutions.
|
78
|
+
These are the overhead of `mpi4py` higher-level abstractions and the overhead of
|
79
|
+
repeatedly entering and leaving the JIT-compiled block if using `mpi4py`, which can be
|
80
|
+
eliminated by using `numba-mpi`, and which the measured differences in execution time
|
81
|
+
stem from.
|
82
|
+
```python
|
83
|
+
import timeit, mpi4py, numba, numpy as np, numba_mpi
|
84
|
+
|
85
|
+
N_TIMES = 10000
|
86
|
+
RTOL = 1e-3
|
87
|
+
|
88
|
+
@numba.jit
|
89
|
+
def get_pi_part(n_intervals=1000000, rank=0, size=1):
|
90
|
+
h = 1 / n_intervals
|
91
|
+
partial_sum = 0.0
|
92
|
+
for i in range(rank + 1, n_intervals, size):
|
93
|
+
x = h * (i - 0.5)
|
94
|
+
partial_sum += 4 / (1 + x**2)
|
95
|
+
return h * partial_sum
|
96
|
+
|
97
|
+
@numba.jit
|
98
|
+
def pi_numba_mpi(n_intervals):
|
99
|
+
pi = np.array([0.])
|
100
|
+
part = np.empty_like(pi)
|
101
|
+
for _ in range(N_TIMES):
|
102
|
+
part[0] = get_pi_part(n_intervals, numba_mpi.rank(), numba_mpi.size())
|
103
|
+
numba_mpi.allreduce(part, pi, numba_mpi.Operator.SUM)
|
104
|
+
assert abs(pi[0] - np.pi) / np.pi < RTOL
|
105
|
+
|
106
|
+
def pi_mpi4py(n_intervals):
|
107
|
+
pi = np.array([0.])
|
108
|
+
part = np.empty_like(pi)
|
109
|
+
for _ in range(N_TIMES):
|
110
|
+
part[0] = get_pi_part(n_intervals, mpi4py.MPI.COMM_WORLD.rank, mpi4py.MPI.COMM_WORLD.size)
|
111
|
+
mpi4py.MPI.COMM_WORLD.Allreduce(part, (pi, mpi4py.MPI.DOUBLE), op=mpi4py.MPI.SUM)
|
112
|
+
assert abs(pi[0] - np.pi) / np.pi < RTOL
|
113
|
+
|
114
|
+
plot_x = [x for x in range(1, 11)]
|
115
|
+
plot_y = {'numba_mpi': [], 'mpi4py': []}
|
116
|
+
for x in plot_x:
|
117
|
+
for impl in plot_y:
|
118
|
+
plot_y[impl].append(min(timeit.repeat(
|
119
|
+
f"pi_{impl}(n_intervals={N_TIMES // x})",
|
120
|
+
globals=locals(),
|
121
|
+
number=1,
|
122
|
+
repeat=10
|
123
|
+
)))
|
124
|
+
|
125
|
+
if numba_mpi.rank() == 0:
|
126
|
+
from matplotlib import pyplot
|
127
|
+
pyplot.figure(figsize=(8.3, 3.5), tight_layout=True)
|
128
|
+
pyplot.plot(plot_x, np.array(plot_y['mpi4py'])/np.array(plot_y['numba_mpi']), marker='o')
|
129
|
+
pyplot.xlabel('number of MPI calls per interval')
|
130
|
+
pyplot.ylabel('mpi4py/numba-mpi wall-time ratio')
|
131
|
+
pyplot.title(f'mpiexec -np {numba_mpi.size()}')
|
132
|
+
pyplot.grid()
|
133
|
+
pyplot.savefig('readme_plot.svg')
|
134
|
+
```
|
135
|
+
|
136
|
+

|
137
|
+
|
138
|
+
|
139
|
+
### MPI resources on the web:
|
140
|
+
|
141
|
+
- MPI standard and general information:
|
142
|
+
- https://www.mpi-forum.org/docs
|
143
|
+
- https://en.wikipedia.org/wiki/Message_Passing_Interface
|
144
|
+
- MPI implementations:
|
145
|
+
- OpenMPI: https://www.open-mpi.org
|
146
|
+
- MPICH: https://www.mpich.org
|
147
|
+
- MS MPI: https://learn.microsoft.com/en-us/message-passing-interface
|
148
|
+
- Intel MPI: https://intel.com/content/www/us/en/developer/tools/oneapi/mpi-library-documentation.html
|
149
|
+
- MPI bindings:
|
150
|
+
- Python: https://mpi4py.readthedocs.io
|
151
|
+
- Julia: https://juliaparallel.org/MPI.jl
|
152
|
+
- Rust: https://docs.rs/mpi
|
153
|
+
- C++: https://boost.org/doc/html/mpi.html
|
154
|
+
- R: https://cran.r-project.org/web/packages/Rmpi
|
155
|
+
|
156
|
+
### Acknowledgements:
|
157
|
+
|
158
|
+
Development of numba-mpi has been supported by the [Polish National Science Centre](https://ncn.gov.pl/en) (grant no. 2020/39/D/ST10/01220).
|
159
|
+
|
@@ -34,6 +34,9 @@ def wait(request):
|
|
34
34
|
"""Wrapper for MPI_Wait. Returns integer status code (0 == MPI_SUCCESS).
|
35
35
|
Status is currently not handled. Requires 'request' parameter to be a
|
36
36
|
c-style pointer to MPI_Request (such as returned by 'isend'/'irecv').
|
37
|
+
|
38
|
+
Uninitialized contents of 'request' (e.g., from numpy.empty()) may
|
39
|
+
cause invalid pointer dereference and segmentation faults.
|
37
40
|
"""
|
38
41
|
|
39
42
|
status_buffer = create_status_buffer()
|
@@ -64,6 +67,9 @@ def waitall(requests):
|
|
64
67
|
"""Wrapper for MPI_Waitall. Returns integer status code (0 == MPI_SUCCESS).
|
65
68
|
Status is currently not handled. Requires 'requests' parameter to be an
|
66
69
|
array or tuple of MPI_Request objects.
|
70
|
+
|
71
|
+
Uninitialized contents of 'requests' (e.g., from numpy.empty()) may
|
72
|
+
cause invalid pointer dereference and segmentation faults.
|
67
73
|
"""
|
68
74
|
if isinstance(requests, np.ndarray):
|
69
75
|
return _waitall_array_impl(requests)
|
@@ -123,6 +129,9 @@ def waitany(requests):
|
|
123
129
|
status; second - the index of request that was completed. Status is
|
124
130
|
currently not handled. Requires 'requests' parameter to be an array
|
125
131
|
or tuple of MPI_Request objects.
|
132
|
+
|
133
|
+
Uninitialized contents of 'requests' (e.g., from numpy.empty()) may
|
134
|
+
cause invalid pointer dereference and segmentation faults.
|
126
135
|
"""
|
127
136
|
|
128
137
|
if isinstance(requests, np.ndarray):
|
@@ -167,6 +176,9 @@ def test(request):
|
|
167
176
|
flag that indicates whether given request is completed. Status is currently
|
168
177
|
not handled. Requires 'request' parameter to be a c-style pointer to
|
169
178
|
MPI_Request (such as returned by 'isend'/'irecv').
|
179
|
+
|
180
|
+
Uninitialized contents of 'request' (e.g., from numpy.empty()) may
|
181
|
+
cause invalid pointer dereference and segmentation faults.
|
170
182
|
"""
|
171
183
|
|
172
184
|
status_buffer = create_status_buffer()
|
@@ -203,6 +215,9 @@ def testall(requests):
|
|
203
215
|
flag that indicates whether given request is completed. Status is currently
|
204
216
|
not handled. Requires 'requests' parameter to be an array or tuple of
|
205
217
|
MPI_Request objects.
|
218
|
+
|
219
|
+
Uninitialized contents of 'requests' (e.g., from numpy.empty()) may
|
220
|
+
cause invalid pointer dereference and segmentation faults.
|
206
221
|
"""
|
207
222
|
if isinstance(requests, np.ndarray):
|
208
223
|
return _testall_array_impl(requests)
|
@@ -269,6 +284,9 @@ def testany(requests):
|
|
269
284
|
that indicates whether any of requests is completed, and index of request
|
270
285
|
that is guaranteed to be completed. Requires 'requests' parameter to be an
|
271
286
|
array or tuple of MPI_Request objects.
|
287
|
+
|
288
|
+
Uninitialized contents of 'requests' (e.g., from numpy.empty()) may
|
289
|
+
cause invalid pointer dereference and segmentation faults.
|
272
290
|
"""
|
273
291
|
|
274
292
|
if isinstance(requests, np.ndarray):
|
@@ -0,0 +1,179 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: numba-mpi
|
3
|
+
Version: 0.43
|
4
|
+
Summary: Numba @njittable MPI wrappers tested on Linux, macOS and Windows
|
5
|
+
Home-page: https://github.com/numba-mpi/numba-mpi
|
6
|
+
Author: https://github.com/numba-mpi/numba-mpi/graphs/contributors
|
7
|
+
License: GPL v3
|
8
|
+
Project-URL: Tracker, https://github.com/numba-mpi/numba-mpi/issues
|
9
|
+
Project-URL: Documentation, https://numba-mpi.github.io/numba-mpi
|
10
|
+
Project-URL: Source, https://github.com/numba-mpi/numba-mpi
|
11
|
+
Requires-Python: >=3.8
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENSE
|
14
|
+
Requires-Dist: numba
|
15
|
+
Requires-Dist: numpy
|
16
|
+
Requires-Dist: mpi4py
|
17
|
+
Requires-Dist: psutil
|
18
|
+
Provides-Extra: tests
|
19
|
+
Requires-Dist: pytest<8.0.0; extra == "tests"
|
20
|
+
|
21
|
+
# <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.svg" style="height:50pt" alt="numba-mpi logo"> numba-mpi
|
22
|
+
|
23
|
+
[](https://www.python.org/)
|
24
|
+
[](https://numba.pydata.org)
|
25
|
+
[](https://en.wikipedia.org/wiki/Linux)
|
26
|
+
[](https://en.wikipedia.org/wiki/macOS)
|
27
|
+
[](https://en.wikipedia.org/wiki/Windows)
|
28
|
+
[](https://github.com/numba-mpi/numba-mpi/actions/workflows/tests+pypi.yml)
|
29
|
+
[](https://GitHub.com/numba-mpi/numba-mpi/graphs/commit-activity)
|
30
|
+
[](https://www.gnu.org/licenses/gpl-3.0.html)
|
31
|
+
[](https://pypi.org/project/numba-mpi)
|
32
|
+
[](https://anaconda.org/conda-forge/numba-mpi)
|
33
|
+
[](https://aur.archlinux.org/packages/python-numba-mpi)
|
34
|
+
[](https://zenodo.org/badge/latestdoi/316911228)
|
35
|
+
|
36
|
+
### Overview
|
37
|
+
numba-mpi provides Python wrappers to the C MPI API callable from within [Numba JIT-compiled code](https://numba.readthedocs.io/en/stable/user/jit.html) (@njit mode).
|
38
|
+
|
39
|
+
Support is provided for a subset of MPI routines covering: `size`/`rank`, `send`/`recv`, `allreduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier`, `wtime`
|
40
|
+
and basic asynchronous communication with `isend`/`irecv` (only for contiguous arrays); for request handling including `wait`/`waitall`/`waitany` and `test`/`testall`/`testany`.
|
41
|
+
|
42
|
+
The API uses NumPy and supports both numeric and character datatypes (e.g., `broadcast`).
|
43
|
+
Auto-generated docstring-based API docs are published on the web: https://numba-mpi.github.io/numba-mpi
|
44
|
+
|
45
|
+
Packages can be obtained from
|
46
|
+
[PyPI](https://pypi.org/project/numba-mpi),
|
47
|
+
[Conda Forge](https://anaconda.org/conda-forge/numba-mpi),
|
48
|
+
[Arch Linux](https://aur.archlinux.org/packages/python-numba-mpi)
|
49
|
+
or by invoking `pip install git+https://github.com/numba-mpi/numba-mpi.git`.
|
50
|
+
|
51
|
+
numba-mpi is a pure-Python package.
|
52
|
+
The codebase includes a test suite used through the GitHub Actions workflows ([thanks to mpi4py's setup-mpi](https://github.com/mpi4py/setup-mpi)!)
|
53
|
+
for automated testing on: Linux ([MPICH](https://www.mpich.org/), [OpenMPI](https://www.open-mpi.org/doc/)
|
54
|
+
& [Intel MPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/mpi-library.html)),
|
55
|
+
macOS ([MPICH](https://www.mpich.org/) & [OpenMPI](https://www.open-mpi.org/doc/)) and
|
56
|
+
Windows ([MS MPI](https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi)).
|
57
|
+
|
58
|
+
Features that are not implemented yet include (help welcome!):
|
59
|
+
- support for non-default communicators
|
60
|
+
- support for `MPI_IN_PLACE` in `[all]gather`/`scatter` and `allreduce`
|
61
|
+
- support for `MPI_Type_create_struct` (Numpy structured arrays)
|
62
|
+
- ...
|
63
|
+
|
64
|
+
### Hello world send/recv example:
|
65
|
+
```python
|
66
|
+
import numba, numba_mpi, numpy
|
67
|
+
|
68
|
+
@numba.njit()
|
69
|
+
def hello():
|
70
|
+
src = numpy.array([1., 2., 3., 4., 5.])
|
71
|
+
dst_tst = numpy.empty_like(src)
|
72
|
+
|
73
|
+
if numba_mpi.rank() == 0:
|
74
|
+
numba_mpi.send(src, dest=1, tag=11)
|
75
|
+
elif numba_mpi.rank() == 1:
|
76
|
+
numba_mpi.recv(dst_tst, source=0, tag=11)
|
77
|
+
|
78
|
+
hello()
|
79
|
+
```
|
80
|
+
|
81
|
+
### Example comparing numba-mpi vs. mpi4py performance:
|
82
|
+
|
83
|
+
The example below compares `Numba`+`mpi4py` vs. `Numba`+`numba-mpi` performance.
|
84
|
+
The sample code estimates $\pi$ by numerical integration of $\int_0^1 (4/(1+x^2))dx=\pi$
|
85
|
+
dividing the workload into `n_intervals` handled by separate MPI processes
|
86
|
+
and then obtaining a sum using `allreduce` (see, e.g., analogous [Matlab docs example](https://www.mathworks.com/help/parallel-computing/numerical-estimation-of-pi-using-message-passing.html)).
|
87
|
+
The computation is carried out in a JIT-compiled function `get_pi_part()` and is repeated
|
88
|
+
`N_TIMES`. The repetitions and the MPI-handled reduction are done outside or
|
89
|
+
inside of the JIT-compiled block for `mpi4py` and `numba-mpi`, respectively.
|
90
|
+
Timing is repeated `N_REPEAT` times and the minimum time is reported.
|
91
|
+
The generated plot shown below depicts the speedup obtained by replacing `mpi4py`
|
92
|
+
with `numba_mpi`, plotted as a function of `N_TIMES / n_intervals` - the number of MPI calls per
|
93
|
+
interval. The speedup, which stems from avoiding roundtrips between JIT-compiled
|
94
|
+
and Python code is significant (150%-300%) in all cases. The more often communication
|
95
|
+
is needed (smaller `n_intervals`), the larger the measured speedup. Note that nothing
|
96
|
+
in the actual number crunching (within the `get_pi_part()` function) or in the employed communication logic
|
97
|
+
(handled by the same MPI library) differs between the `mpi4py` or `numba-mpi` solutions.
|
98
|
+
These are the overhead of `mpi4py` higher-level abstractions and the overhead of
|
99
|
+
repeatedly entering and leaving the JIT-compiled block if using `mpi4py`, which can be
|
100
|
+
eliminated by using `numba-mpi`, and which the measured differences in execution time
|
101
|
+
stem from.
|
102
|
+
```python
|
103
|
+
import timeit, mpi4py, numba, numpy as np, numba_mpi
|
104
|
+
|
105
|
+
N_TIMES = 10000
|
106
|
+
RTOL = 1e-3
|
107
|
+
|
108
|
+
@numba.jit
|
109
|
+
def get_pi_part(n_intervals=1000000, rank=0, size=1):
|
110
|
+
h = 1 / n_intervals
|
111
|
+
partial_sum = 0.0
|
112
|
+
for i in range(rank + 1, n_intervals, size):
|
113
|
+
x = h * (i - 0.5)
|
114
|
+
partial_sum += 4 / (1 + x**2)
|
115
|
+
return h * partial_sum
|
116
|
+
|
117
|
+
@numba.jit
|
118
|
+
def pi_numba_mpi(n_intervals):
|
119
|
+
pi = np.array([0.])
|
120
|
+
part = np.empty_like(pi)
|
121
|
+
for _ in range(N_TIMES):
|
122
|
+
part[0] = get_pi_part(n_intervals, numba_mpi.rank(), numba_mpi.size())
|
123
|
+
numba_mpi.allreduce(part, pi, numba_mpi.Operator.SUM)
|
124
|
+
assert abs(pi[0] - np.pi) / np.pi < RTOL
|
125
|
+
|
126
|
+
def pi_mpi4py(n_intervals):
|
127
|
+
pi = np.array([0.])
|
128
|
+
part = np.empty_like(pi)
|
129
|
+
for _ in range(N_TIMES):
|
130
|
+
part[0] = get_pi_part(n_intervals, mpi4py.MPI.COMM_WORLD.rank, mpi4py.MPI.COMM_WORLD.size)
|
131
|
+
mpi4py.MPI.COMM_WORLD.Allreduce(part, (pi, mpi4py.MPI.DOUBLE), op=mpi4py.MPI.SUM)
|
132
|
+
assert abs(pi[0] - np.pi) / np.pi < RTOL
|
133
|
+
|
134
|
+
plot_x = [x for x in range(1, 11)]
|
135
|
+
plot_y = {'numba_mpi': [], 'mpi4py': []}
|
136
|
+
for x in plot_x:
|
137
|
+
for impl in plot_y:
|
138
|
+
plot_y[impl].append(min(timeit.repeat(
|
139
|
+
f"pi_{impl}(n_intervals={N_TIMES // x})",
|
140
|
+
globals=locals(),
|
141
|
+
number=1,
|
142
|
+
repeat=10
|
143
|
+
)))
|
144
|
+
|
145
|
+
if numba_mpi.rank() == 0:
|
146
|
+
from matplotlib import pyplot
|
147
|
+
pyplot.figure(figsize=(8.3, 3.5), tight_layout=True)
|
148
|
+
pyplot.plot(plot_x, np.array(plot_y['mpi4py'])/np.array(plot_y['numba_mpi']), marker='o')
|
149
|
+
pyplot.xlabel('number of MPI calls per interval')
|
150
|
+
pyplot.ylabel('mpi4py/numba-mpi wall-time ratio')
|
151
|
+
pyplot.title(f'mpiexec -np {numba_mpi.size()}')
|
152
|
+
pyplot.grid()
|
153
|
+
pyplot.savefig('readme_plot.svg')
|
154
|
+
```
|
155
|
+
|
156
|
+

|
157
|
+
|
158
|
+
|
159
|
+
### MPI resources on the web:
|
160
|
+
|
161
|
+
- MPI standard and general information:
|
162
|
+
- https://www.mpi-forum.org/docs
|
163
|
+
- https://en.wikipedia.org/wiki/Message_Passing_Interface
|
164
|
+
- MPI implementations:
|
165
|
+
- OpenMPI: https://www.open-mpi.org
|
166
|
+
- MPICH: https://www.mpich.org
|
167
|
+
- MS MPI: https://learn.microsoft.com/en-us/message-passing-interface
|
168
|
+
- Intel MPI: https://intel.com/content/www/us/en/developer/tools/oneapi/mpi-library-documentation.html
|
169
|
+
- MPI bindings:
|
170
|
+
- Python: https://mpi4py.readthedocs.io
|
171
|
+
- Julia: https://juliaparallel.org/MPI.jl
|
172
|
+
- Rust: https://docs.rs/mpi
|
173
|
+
- C++: https://boost.org/doc/html/mpi.html
|
174
|
+
- R: https://cran.r-project.org/web/packages/Rmpi
|
175
|
+
|
176
|
+
### Acknowledgements:
|
177
|
+
|
178
|
+
Development of numba-mpi has been supported by the [Polish National Science Centre](https://ncn.gov.pl/en) (grant no. 2020/39/D/ST10/01220).
|
179
|
+
|
@@ -176,7 +176,7 @@ def test_isend_irecv_waitall(isnd, ircv, wall, data_type):
|
|
176
176
|
dst1 = np.empty_like(src1)
|
177
177
|
dst2 = np.empty_like(src2)
|
178
178
|
|
179
|
-
reqs = np.
|
179
|
+
reqs = np.zeros((2,), dtype=mpi.RequestType)
|
180
180
|
if mpi.rank() == 0:
|
181
181
|
status, reqs[0:1] = isnd(src1, dest=1, tag=11)
|
182
182
|
assert status == MPI_SUCCESS
|
@@ -245,7 +245,7 @@ def test_isend_irecv_waitall_exchange(isnd, ircv, wall):
|
|
245
245
|
src = get_random_array((5,))
|
246
246
|
dst = np.empty_like(src)
|
247
247
|
|
248
|
-
reqs = np.
|
248
|
+
reqs = np.zeros((2,), dtype=mpi.RequestType)
|
249
249
|
if mpi.rank() == 0:
|
250
250
|
status, reqs[0:1] = isnd(src, dest=1, tag=11)
|
251
251
|
assert status == MPI_SUCCESS
|
@@ -263,6 +263,24 @@ def test_isend_irecv_waitall_exchange(isnd, ircv, wall):
|
|
263
263
|
np.testing.assert_equal(dst, src)
|
264
264
|
|
265
265
|
|
266
|
+
@pytest.mark.parametrize(
|
267
|
+
"fun",
|
268
|
+
(
|
269
|
+
jit_waitany.py_func,
|
270
|
+
jit_waitall.py_func,
|
271
|
+
jit_testany.py_func,
|
272
|
+
jit_testall.py_func,
|
273
|
+
jit_waitany,
|
274
|
+
jit_waitall,
|
275
|
+
jit_testany,
|
276
|
+
jit_testall,
|
277
|
+
),
|
278
|
+
)
|
279
|
+
def test_wall_segfault(fun):
|
280
|
+
reqs = np.zeros((2,), dtype=mpi.RequestType)
|
281
|
+
fun(reqs)
|
282
|
+
|
283
|
+
|
266
284
|
@pytest.mark.parametrize(
|
267
285
|
"isnd, ircv, wany, wall",
|
268
286
|
[
|
@@ -282,7 +300,7 @@ def test_isend_irecv_waitany(isnd, ircv, wany, wall, data_type):
|
|
282
300
|
dst1 = np.empty_like(src1)
|
283
301
|
dst2 = np.empty_like(src2)
|
284
302
|
|
285
|
-
reqs = np.
|
303
|
+
reqs = np.zeros((2,), dtype=mpi.RequestType)
|
286
304
|
if mpi.rank() == 0:
|
287
305
|
status, reqs[0:1] = isnd(src1, dest=1, tag=11)
|
288
306
|
assert status == MPI_SUCCESS
|
@@ -356,7 +374,7 @@ def test_isend_irecv_testall(isnd, ircv, tall, wall):
|
|
356
374
|
dst1 = np.empty_like(src1)
|
357
375
|
dst2 = np.empty_like(src2)
|
358
376
|
|
359
|
-
reqs = np.
|
377
|
+
reqs = np.zeros((2,), dtype=mpi.RequestType)
|
360
378
|
if mpi.rank() == 0:
|
361
379
|
time.sleep(TEST_WAIT_FULL_IN_SECONDS)
|
362
380
|
|
@@ -402,7 +420,7 @@ def test_isend_irecv_testany(isnd, ircv, tany, wall):
|
|
402
420
|
dst1 = np.empty_like(src1)
|
403
421
|
dst2 = np.empty_like(src2)
|
404
422
|
|
405
|
-
reqs = np.
|
423
|
+
reqs = np.zeros((2,), dtype=mpi.RequestType)
|
406
424
|
if mpi.rank() == 0:
|
407
425
|
time.sleep(TEST_WAIT_FULL_IN_SECONDS)
|
408
426
|
|
numba-mpi-0.40/PKG-INFO
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: numba-mpi
|
3
|
-
Version: 0.40
|
4
|
-
Summary: Numba @njittable MPI wrappers tested on Linux, macOS and Windows
|
5
|
-
Home-page: https://github.com/numba-mpi/numba-mpi
|
6
|
-
Author: https://github.com/numba-mpi/numba-mpi/graphs/contributors
|
7
|
-
License: GPL v3
|
8
|
-
Project-URL: Tracker, https://github.com/numba-mpi/numba-mpi/issues
|
9
|
-
Project-URL: Documentation, https://numba-mpi.github.io/numba-mpi
|
10
|
-
Project-URL: Source, https://github.com/numba-mpi/numba-mpi
|
11
|
-
Description-Content-Type: text/markdown
|
12
|
-
License-File: LICENSE
|
13
|
-
Requires-Dist: numba
|
14
|
-
Requires-Dist: numpy
|
15
|
-
Requires-Dist: mpi4py
|
16
|
-
Requires-Dist: psutil
|
17
|
-
Provides-Extra: tests
|
18
|
-
Requires-Dist: pytest<8.0.0; extra == "tests"
|
19
|
-
|
20
|
-
# <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.svg" style="height:50pt" alt="numba-mpi logo"> numba-mpi
|
21
|
-
|
22
|
-
[](https://www.python.org/)
|
23
|
-
[](https://numba.pydata.org)
|
24
|
-
[](https://en.wikipedia.org/wiki/Linux)
|
25
|
-
[](https://en.wikipedia.org/wiki/macOS)
|
26
|
-
[](https://en.wikipedia.org/wiki/Windows)
|
27
|
-
[](https://github.com/numba-mpi/numba-mpi/actions/workflows/tests+pypi.yml)
|
28
|
-
[](https://GitHub.com/numba-mpi/numba-mpi/graphs/commit-activity)
|
29
|
-
[](https://www.gnu.org/licenses/gpl-3.0.html)
|
30
|
-
[](https://pypi.org/project/numba-mpi)
|
31
|
-
[](https://anaconda.org/conda-forge/numba-mpi)
|
32
|
-
[](https://aur.archlinux.org/packages/python-numba-mpi)
|
33
|
-
[](https://zenodo.org/badge/latestdoi/316911228)
|
34
|
-
|
35
|
-
#### Numba @njittable MPI wrappers
|
36
|
-
- covering: `size`/`rank`, `send`/`recv`, `allreduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier` and `wtime`
|
37
|
-
- basic asynchronous communication with `isend`/`irecv` (only for contiguous arrays); for request handling including `wait`/`waitall`/`waitany` and `test`/`testall`/`testany`
|
38
|
-
- not yet implemented: support for non-default communicators, ...
|
39
|
-
- API based on NumPy and supporting numeric and character datatypes
|
40
|
-
- auto-generated docstring-based API docs on the web: https://numba-mpi.github.io/numba-mpi
|
41
|
-
- pure-Python implementation with packages available at [PyPI](https://pypi.org/project/numba-mpi), [Conda Forge](https://anaconda.org/conda-forge/numba-mpi) and for [Arch Linux](https://aur.archlinux.org/packages/python-numba-mpi)
|
42
|
-
- CI-tested on: Linux ([MPICH](https://www.mpich.org/), [OpenMPI](https://www.open-mpi.org/doc/) & [Intel MPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/mpi-library.html)), macOS ([MPICH](https://www.mpich.org/) & [OpenMPI](https://www.open-mpi.org/doc/)) and Windows ([MS MPI](https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi))
|
43
|
-
|
44
|
-
Hello world example:
|
45
|
-
```python
|
46
|
-
import numba, numba_mpi, numpy
|
47
|
-
|
48
|
-
@numba.njit()
|
49
|
-
def hello():
|
50
|
-
print(numba_mpi.rank())
|
51
|
-
print(numba_mpi.size())
|
52
|
-
|
53
|
-
src = numpy.array([1., 2., 3., 4., 5.])
|
54
|
-
dst_tst = numpy.empty_like(src)
|
55
|
-
|
56
|
-
if numba_mpi.rank() == 0:
|
57
|
-
numba_mpi.send(src, dest=1, tag=11)
|
58
|
-
elif numba_mpi.rank() == 1:
|
59
|
-
numba_mpi.recv(dst_tst, source=0, tag=11)
|
60
|
-
|
61
|
-
hello()
|
62
|
-
```
|
63
|
-
|
64
|
-
For information on MPI, see:
|
65
|
-
- https://www.mpi-forum.org/docs/
|
66
|
-
- https://mpi4py.readthedocs.io/en/stable/
|
numba-mpi-0.40/README.md
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.svg" style="height:50pt" alt="numba-mpi logo"> numba-mpi
|
2
|
-
|
3
|
-
[](https://www.python.org/)
|
4
|
-
[](https://numba.pydata.org)
|
5
|
-
[](https://en.wikipedia.org/wiki/Linux)
|
6
|
-
[](https://en.wikipedia.org/wiki/macOS)
|
7
|
-
[](https://en.wikipedia.org/wiki/Windows)
|
8
|
-
[](https://github.com/numba-mpi/numba-mpi/actions/workflows/tests+pypi.yml)
|
9
|
-
[](https://GitHub.com/numba-mpi/numba-mpi/graphs/commit-activity)
|
10
|
-
[](https://www.gnu.org/licenses/gpl-3.0.html)
|
11
|
-
[](https://pypi.org/project/numba-mpi)
|
12
|
-
[](https://anaconda.org/conda-forge/numba-mpi)
|
13
|
-
[](https://aur.archlinux.org/packages/python-numba-mpi)
|
14
|
-
[](https://zenodo.org/badge/latestdoi/316911228)
|
15
|
-
|
16
|
-
#### Numba @njittable MPI wrappers
|
17
|
-
- covering: `size`/`rank`, `send`/`recv`, `allreduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier` and `wtime`
|
18
|
-
- basic asynchronous communication with `isend`/`irecv` (only for contiguous arrays); for request handling including `wait`/`waitall`/`waitany` and `test`/`testall`/`testany`
|
19
|
-
- not yet implemented: support for non-default communicators, ...
|
20
|
-
- API based on NumPy and supporting numeric and character datatypes
|
21
|
-
- auto-generated docstring-based API docs on the web: https://numba-mpi.github.io/numba-mpi
|
22
|
-
- pure-Python implementation with packages available at [PyPI](https://pypi.org/project/numba-mpi), [Conda Forge](https://anaconda.org/conda-forge/numba-mpi) and for [Arch Linux](https://aur.archlinux.org/packages/python-numba-mpi)
|
23
|
-
- CI-tested on: Linux ([MPICH](https://www.mpich.org/), [OpenMPI](https://www.open-mpi.org/doc/) & [Intel MPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/mpi-library.html)), macOS ([MPICH](https://www.mpich.org/) & [OpenMPI](https://www.open-mpi.org/doc/)) and Windows ([MS MPI](https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi))
|
24
|
-
|
25
|
-
Hello world example:
|
26
|
-
```python
|
27
|
-
import numba, numba_mpi, numpy
|
28
|
-
|
29
|
-
@numba.njit()
|
30
|
-
def hello():
|
31
|
-
print(numba_mpi.rank())
|
32
|
-
print(numba_mpi.size())
|
33
|
-
|
34
|
-
src = numpy.array([1., 2., 3., 4., 5.])
|
35
|
-
dst_tst = numpy.empty_like(src)
|
36
|
-
|
37
|
-
if numba_mpi.rank() == 0:
|
38
|
-
numba_mpi.send(src, dest=1, tag=11)
|
39
|
-
elif numba_mpi.rank() == 1:
|
40
|
-
numba_mpi.recv(dst_tst, source=0, tag=11)
|
41
|
-
|
42
|
-
hello()
|
43
|
-
```
|
44
|
-
|
45
|
-
For information on MPI, see:
|
46
|
-
- https://www.mpi-forum.org/docs/
|
47
|
-
- https://mpi4py.readthedocs.io/en/stable/
|
@@ -1,66 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: numba-mpi
|
3
|
-
Version: 0.40
|
4
|
-
Summary: Numba @njittable MPI wrappers tested on Linux, macOS and Windows
|
5
|
-
Home-page: https://github.com/numba-mpi/numba-mpi
|
6
|
-
Author: https://github.com/numba-mpi/numba-mpi/graphs/contributors
|
7
|
-
License: GPL v3
|
8
|
-
Project-URL: Tracker, https://github.com/numba-mpi/numba-mpi/issues
|
9
|
-
Project-URL: Documentation, https://numba-mpi.github.io/numba-mpi
|
10
|
-
Project-URL: Source, https://github.com/numba-mpi/numba-mpi
|
11
|
-
Description-Content-Type: text/markdown
|
12
|
-
License-File: LICENSE
|
13
|
-
Requires-Dist: numba
|
14
|
-
Requires-Dist: numpy
|
15
|
-
Requires-Dist: mpi4py
|
16
|
-
Requires-Dist: psutil
|
17
|
-
Provides-Extra: tests
|
18
|
-
Requires-Dist: pytest<8.0.0; extra == "tests"
|
19
|
-
|
20
|
-
# <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.svg" style="height:50pt" alt="numba-mpi logo"> numba-mpi
|
21
|
-
|
22
|
-
[](https://www.python.org/)
|
23
|
-
[](https://numba.pydata.org)
|
24
|
-
[](https://en.wikipedia.org/wiki/Linux)
|
25
|
-
[](https://en.wikipedia.org/wiki/macOS)
|
26
|
-
[](https://en.wikipedia.org/wiki/Windows)
|
27
|
-
[](https://github.com/numba-mpi/numba-mpi/actions/workflows/tests+pypi.yml)
|
28
|
-
[](https://GitHub.com/numba-mpi/numba-mpi/graphs/commit-activity)
|
29
|
-
[](https://www.gnu.org/licenses/gpl-3.0.html)
|
30
|
-
[](https://pypi.org/project/numba-mpi)
|
31
|
-
[](https://anaconda.org/conda-forge/numba-mpi)
|
32
|
-
[](https://aur.archlinux.org/packages/python-numba-mpi)
|
33
|
-
[](https://zenodo.org/badge/latestdoi/316911228)
|
34
|
-
|
35
|
-
#### Numba @njittable MPI wrappers
|
36
|
-
- covering: `size`/`rank`, `send`/`recv`, `allreduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier` and `wtime`
|
37
|
-
- basic asynchronous communication with `isend`/`irecv` (only for contiguous arrays); for request handling including `wait`/`waitall`/`waitany` and `test`/`testall`/`testany`
|
38
|
-
- not yet implemented: support for non-default communicators, ...
|
39
|
-
- API based on NumPy and supporting numeric and character datatypes
|
40
|
-
- auto-generated docstring-based API docs on the web: https://numba-mpi.github.io/numba-mpi
|
41
|
-
- pure-Python implementation with packages available at [PyPI](https://pypi.org/project/numba-mpi), [Conda Forge](https://anaconda.org/conda-forge/numba-mpi) and for [Arch Linux](https://aur.archlinux.org/packages/python-numba-mpi)
|
42
|
-
- CI-tested on: Linux ([MPICH](https://www.mpich.org/), [OpenMPI](https://www.open-mpi.org/doc/) & [Intel MPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/mpi-library.html)), macOS ([MPICH](https://www.mpich.org/) & [OpenMPI](https://www.open-mpi.org/doc/)) and Windows ([MS MPI](https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi))
|
43
|
-
|
44
|
-
Hello world example:
|
45
|
-
```python
|
46
|
-
import numba, numba_mpi, numpy
|
47
|
-
|
48
|
-
@numba.njit()
|
49
|
-
def hello():
|
50
|
-
print(numba_mpi.rank())
|
51
|
-
print(numba_mpi.size())
|
52
|
-
|
53
|
-
src = numpy.array([1., 2., 3., 4., 5.])
|
54
|
-
dst_tst = numpy.empty_like(src)
|
55
|
-
|
56
|
-
if numba_mpi.rank() == 0:
|
57
|
-
numba_mpi.send(src, dest=1, tag=11)
|
58
|
-
elif numba_mpi.rank() == 1:
|
59
|
-
numba_mpi.recv(dst_tst, source=0, tag=11)
|
60
|
-
|
61
|
-
hello()
|
62
|
-
```
|
63
|
-
|
64
|
-
For information on MPI, see:
|
65
|
-
- https://www.mpi-forum.org/docs/
|
66
|
-
- https://mpi4py.readthedocs.io/en/stable/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|