numba-mpi 1.0.0__py3-none-any.whl → 1.1.1__py3-none-any.whl
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/__init__.py +1 -0
- numba_mpi/api/reduce.py +112 -0
- {numba_mpi-1.0.0.dist-info → numba_mpi-1.1.1.dist-info}/METADATA +6 -6
- {numba_mpi-1.0.0.dist-info → numba_mpi-1.1.1.dist-info}/RECORD +7 -6
- {numba_mpi-1.0.0.dist-info → numba_mpi-1.1.1.dist-info}/WHEEL +1 -1
- {numba_mpi-1.0.0.dist-info → numba_mpi-1.1.1.dist-info}/LICENSE +0 -0
- {numba_mpi-1.0.0.dist-info → numba_mpi-1.1.1.dist-info}/top_level.txt +0 -0
numba_mpi/__init__.py
CHANGED
@@ -13,6 +13,7 @@ from .api.isend import isend
|
|
13
13
|
from .api.operator import Operator
|
14
14
|
from .api.rank import rank
|
15
15
|
from .api.recv import recv
|
16
|
+
from .api.reduce import reduce
|
16
17
|
from .api.requests import test, testall, testany, wait, waitall, waitany
|
17
18
|
from .api.scatter_gather import allgather, gather, scatter
|
18
19
|
from .api.send import send
|
numba_mpi/api/reduce.py
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
"""file contains MPI_Reduce() implementations"""
|
2
|
+
|
3
|
+
import ctypes
|
4
|
+
from numbers import Number
|
5
|
+
|
6
|
+
import numpy as np
|
7
|
+
from numba.core import types
|
8
|
+
from numba.extending import overload
|
9
|
+
|
10
|
+
from numba_mpi.common import _MPI_Comm_World_ptr, _MpiComm, _MpiDatatype, _MpiOp, libmpi
|
11
|
+
from numba_mpi.utils import _mpi_addr, _mpi_dtype
|
12
|
+
|
13
|
+
_MPI_Reduce = libmpi.MPI_Reduce
|
14
|
+
_MPI_Reduce.restype = ctypes.c_int
|
15
|
+
_MPI_Reduce.argtypes = [
|
16
|
+
ctypes.c_void_p,
|
17
|
+
ctypes.c_void_p,
|
18
|
+
ctypes.c_int,
|
19
|
+
_MpiDatatype,
|
20
|
+
_MpiOp,
|
21
|
+
ctypes.c_int,
|
22
|
+
_MpiComm,
|
23
|
+
]
|
24
|
+
|
25
|
+
|
26
|
+
def reduce(sendobj, recvobj, operator, root): # pylint: disable=unused-argument
|
27
|
+
"""wrapper for MPI_Reduce
|
28
|
+
Note that complex datatypes and user-defined functions are not properly supported.
|
29
|
+
Returns integer status code (0 == MPI_SUCCESS)
|
30
|
+
"""
|
31
|
+
if isinstance(sendobj, Number):
|
32
|
+
# reduce a single number
|
33
|
+
sendobj = np.array([sendobj])
|
34
|
+
status = _MPI_Reduce(
|
35
|
+
sendobj.ctypes.data,
|
36
|
+
recvobj.ctypes.data,
|
37
|
+
sendobj.size,
|
38
|
+
_mpi_dtype(sendobj),
|
39
|
+
_mpi_addr(operator),
|
40
|
+
root,
|
41
|
+
_mpi_addr(_MPI_Comm_World_ptr),
|
42
|
+
)
|
43
|
+
|
44
|
+
elif isinstance(sendobj, np.ndarray):
|
45
|
+
# reduce an array
|
46
|
+
sendobj = np.ascontiguousarray(sendobj)
|
47
|
+
status = _MPI_Reduce(
|
48
|
+
sendobj.ctypes.data,
|
49
|
+
recvobj.ctypes.data,
|
50
|
+
sendobj.size,
|
51
|
+
_mpi_dtype(sendobj),
|
52
|
+
_mpi_addr(operator),
|
53
|
+
root,
|
54
|
+
_mpi_addr(_MPI_Comm_World_ptr),
|
55
|
+
)
|
56
|
+
|
57
|
+
else:
|
58
|
+
raise TypeError(f"Unsupported type {sendobj.__class__.__name__}")
|
59
|
+
|
60
|
+
return status
|
61
|
+
|
62
|
+
|
63
|
+
@overload(reduce)
|
64
|
+
def ol_reduce(sendobj, recvobj, operator, root): # pylint: disable=unused-argument
|
65
|
+
"""wrapper for MPI_Reduce
|
66
|
+
Note that complex datatypes and user-defined functions are not properly supported.
|
67
|
+
Returns integer status code (0 == MPI_SUCCESS)
|
68
|
+
"""
|
69
|
+
if isinstance(sendobj, types.Number):
|
70
|
+
# reduce a single number
|
71
|
+
|
72
|
+
def impl(sendobj, recvobj, operator, root):
|
73
|
+
sendobj = np.array([sendobj])
|
74
|
+
|
75
|
+
status = _MPI_Reduce(
|
76
|
+
sendobj.ctypes.data,
|
77
|
+
recvobj.ctypes.data,
|
78
|
+
sendobj.size,
|
79
|
+
_mpi_dtype(sendobj),
|
80
|
+
_mpi_addr(operator),
|
81
|
+
root,
|
82
|
+
_mpi_addr(_MPI_Comm_World_ptr),
|
83
|
+
)
|
84
|
+
|
85
|
+
# The following no-op prevents numba from too aggressive optimizations
|
86
|
+
# This looks like a bug in numba (tested for version 0.55)
|
87
|
+
sendobj[0] # pylint: disable=pointless-statement
|
88
|
+
|
89
|
+
return status
|
90
|
+
|
91
|
+
elif isinstance(sendobj, types.Array):
|
92
|
+
# reduce an array
|
93
|
+
|
94
|
+
def impl(sendobj, recvobj, operator, root):
|
95
|
+
sendobj = np.ascontiguousarray(sendobj)
|
96
|
+
|
97
|
+
status = _MPI_Reduce(
|
98
|
+
sendobj.ctypes.data,
|
99
|
+
recvobj.ctypes.data,
|
100
|
+
sendobj.size,
|
101
|
+
_mpi_dtype(sendobj),
|
102
|
+
_mpi_addr(operator),
|
103
|
+
root,
|
104
|
+
_mpi_addr(_MPI_Comm_World_ptr),
|
105
|
+
)
|
106
|
+
|
107
|
+
return status
|
108
|
+
|
109
|
+
else:
|
110
|
+
raise TypeError(f"Unsupported type {sendobj.__class__.__name__}")
|
111
|
+
|
112
|
+
return impl
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: numba-mpi
|
3
|
-
Version: 1.
|
4
|
-
Summary: Numba @
|
3
|
+
Version: 1.1.1
|
4
|
+
Summary: Numba @jittable MPI wrappers tested on Linux, macOS and Windows
|
5
5
|
Home-page: https://github.com/numba-mpi/numba-mpi
|
6
6
|
Author: https://github.com/numba-mpi/numba-mpi/graphs/contributors
|
7
7
|
License: GPL v3
|
@@ -19,7 +19,7 @@ Provides-Extra: tests
|
|
19
19
|
Requires-Dist: pytest <8.0.0 ; extra == 'tests'
|
20
20
|
Requires-Dist: py-pde ; extra == 'tests'
|
21
21
|
|
22
|
-
# <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.
|
22
|
+
# <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.png" width=128 height=142 alt="numba-mpi logo"> numba-mpi
|
23
23
|
|
24
24
|
[](https://www.python.org/)
|
25
25
|
[](https://numba.pydata.org)
|
@@ -35,9 +35,9 @@ Requires-Dist: py-pde ; extra == 'tests'
|
|
35
35
|
[](https://zenodo.org/badge/latestdoi/316911228)
|
36
36
|
|
37
37
|
### Overview
|
38
|
-
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) (@
|
38
|
+
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) (@jit mode). For an outline of the project, rationale, architecture, and features, refer to: [numba-mpi arXiv e-print](https://doi.org/10.48550/arXiv.2407.13712) (please cite if numba-mpi is used in your research).
|
39
39
|
|
40
|
-
Support is provided for a subset of MPI routines covering: `size`/`rank`, `send`/`recv`, `allreduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier`, `wtime`
|
40
|
+
Support is provided for a subset of MPI routines covering: `size`/`rank`, `send`/`recv`, `allreduce`, `reduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier`, `wtime`
|
41
41
|
and basic asynchronous communication with `isend`/`irecv` (only for contiguous arrays); for request handling including `wait`/`waitall`/`waitany` and `test`/`testall`/`testany`.
|
42
42
|
|
43
43
|
The API uses NumPy and supports both numeric and character datatypes (e.g., `broadcast`).
|
@@ -66,7 +66,7 @@ Features that are not implemented yet include (help welcome!):
|
|
66
66
|
```python
|
67
67
|
import numba, numba_mpi, numpy
|
68
68
|
|
69
|
-
@numba.
|
69
|
+
@numba.jit()
|
70
70
|
def hello():
|
71
71
|
src = numpy.array([1., 2., 3., 4., 5.])
|
72
72
|
dst_tst = numpy.empty_like(src)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
numba_mpi/__init__.py,sha256=
|
1
|
+
numba_mpi/__init__.py,sha256=EsiszqT6I7-Vrbgdk36_mGp5kHpAS5AYCkhjRya-5rg,785
|
2
2
|
numba_mpi/common.py,sha256=2JJoUrd3Qa6GIFk6Zlt2NudS7ZurPxpVwBLRGSkCg5E,2266
|
3
3
|
numba_mpi/utils.py,sha256=gfGFuzmGgs4FnBqzPI91ftAq4UHgXb_HFkvxrVWkcIo,1866
|
4
4
|
numba_mpi/api/__init__.py,sha256=Zj5df4lWeGpxAXV8jKGFnmtLBQ50HwNU8dPf-os06X8,51
|
@@ -11,13 +11,14 @@ numba_mpi/api/isend.py,sha256=2mpP4FhMk0GrikjDluKwRnpVywdLj9RD4HVVEMSj9A8,1080
|
|
11
11
|
numba_mpi/api/operator.py,sha256=3VTPZAdOP05bxdqt3lA0hRDICM-iaBMa4m-krEdO91s,342
|
12
12
|
numba_mpi/api/rank.py,sha256=1xZvHUclsK20aMtK07JzXYxW5F4Er8HZgOmcf495sjo,597
|
13
13
|
numba_mpi/api/recv.py,sha256=YsYK-q7PNfi3zt0ftVddM363VsnJ4XFfmgMq8aeCr-o,1260
|
14
|
+
numba_mpi/api/reduce.py,sha256=ug8WctzXRuxD3IrvrXN4sAfWdjJ1vvMhwykTgF8nn1s,3233
|
14
15
|
numba_mpi/api/requests.py,sha256=5EhgFyeQCGP8YclSPwxP95c2AhBo19CLlShK0TxCR2U,9114
|
15
16
|
numba_mpi/api/scatter_gather.py,sha256=goZn4BxMKakWQHjfXIOdjzK3DJ-lTeaiQQwgnyQeZ_s,2410
|
16
17
|
numba_mpi/api/send.py,sha256=jn1hPw0YHBHOaeJop_ZbjaBChaqgfw3nM1xGhW9sabI,909
|
17
18
|
numba_mpi/api/size.py,sha256=-RX-FtcIH4qDxCoGOhZjjgEWXpytt79vsH0YX9dtZuY,597
|
18
19
|
numba_mpi/api/wtime.py,sha256=qrTqlefW7K7hqnAQKkGYm8kgdiRGuSAGiHmPcTrhLzE,279
|
19
|
-
numba_mpi-1.
|
20
|
-
numba_mpi-1.
|
21
|
-
numba_mpi-1.
|
22
|
-
numba_mpi-1.
|
23
|
-
numba_mpi-1.
|
20
|
+
numba_mpi-1.1.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
21
|
+
numba_mpi-1.1.1.dist-info/METADATA,sha256=a9ZEpxFg6RO9FMIz7vUdn52cQYcK6hiuLMVf-2sYIA0,9897
|
22
|
+
numba_mpi-1.1.1.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
23
|
+
numba_mpi-1.1.1.dist-info/top_level.txt,sha256=yb_ktLmrfuhOZS0rjS81FFNC-gK_4c19WbLG2ViP73g,10
|
24
|
+
numba_mpi-1.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|