numba-mpi 1.0.0__tar.gz → 1.1.1__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.
Files changed (63) hide show
  1. numba_mpi-1.1.1/.github/numba_mpi_logo.png +0 -0
  2. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/.github/workflows/tests+pypi.yml +9 -6
  3. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/.zenodo.json +1 -1
  4. numba_mpi-1.1.1/CITATION.cff +20 -0
  5. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/PKG-INFO +6 -6
  6. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/README.md +4 -4
  7. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/__init__.py +1 -0
  8. numba_mpi-1.1.1/numba_mpi/api/reduce.py +112 -0
  9. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi.egg-info/PKG-INFO +6 -6
  10. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi.egg-info/SOURCES.txt +4 -0
  11. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/setup.py +4 -1
  12. numba_mpi-1.1.1/tests/api/test_reduce.py +54 -0
  13. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/.github/numba_mpi_logo.svg +0 -0
  14. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/.github/workflows/readme_snippets.yml +0 -0
  15. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/.github/workflows/stale.yml +0 -0
  16. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/.gitignore +0 -0
  17. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/.pre-commit-config.yaml +0 -0
  18. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/.vscode/settings.json +0 -0
  19. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/CODE_OF_CONDUCT.md +0 -0
  20. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/LICENSE +0 -0
  21. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/__init__.py +0 -0
  22. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/allreduce.py +0 -0
  23. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/barrier.py +0 -0
  24. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/bcast.py +0 -0
  25. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/initialized.py +0 -0
  26. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/irecv.py +0 -0
  27. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/isend.py +0 -0
  28. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/operator.py +0 -0
  29. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/rank.py +0 -0
  30. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/recv.py +0 -0
  31. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/requests.py +0 -0
  32. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/scatter_gather.py +0 -0
  33. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/send.py +0 -0
  34. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/size.py +0 -0
  35. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/api/wtime.py +0 -0
  36. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/common.py +0 -0
  37. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi/utils.py +0 -0
  38. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi.egg-info/dependency_links.txt +0 -0
  39. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi.egg-info/requires.txt +0 -0
  40. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/numba_mpi.egg-info/top_level.txt +0 -0
  41. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/setup.cfg +0 -0
  42. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/__init__.py +0 -0
  43. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_allreduce.py +0 -0
  44. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_barrier.py +0 -0
  45. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_bcast.py +0 -0
  46. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_init.py +0 -0
  47. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_isend_irecv.py +0 -0
  48. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_rank.py +0 -0
  49. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_scatter_gather.py +0 -0
  50. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_send_recv.py +0 -0
  51. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_size.py +0 -0
  52. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/api/test_wtime.py +0 -0
  53. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/common.py +0 -0
  54. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/paper_listings/exchange.py +0 -0
  55. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/paper_listings/hello.py +0 -0
  56. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/paper_listings/mpi4py_with_error.py +0 -0
  57. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/paper_listings/numba_mpi.py +0 -0
  58. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/paper_listings/py-pde.py +0 -0
  59. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/paper_listings/test.py +0 -0
  60. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/paper_listings/timing.py +0 -0
  61. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/test_paper_listings.py +0 -0
  62. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/test_version.py +0 -0
  63. {numba_mpi-1.0.0 → numba_mpi-1.1.1}/tests/utils.py +0 -0
@@ -33,7 +33,7 @@ jobs:
33
33
  pip install -r numba_mpi.egg-info/requires.txt
34
34
  - name: Analysing the code with pylint
35
35
  run: |
36
- pylint --unsafe-load-any-extension=y --disable=fixme $(git ls-files '*.py' | grep -v -e ^tests/paper_listings)
36
+ pylint --unsafe-load-any-extension=y --disable=fixme,duplicate-code $(git ls-files '*.py' | grep -v -e ^tests/paper_listings)
37
37
 
38
38
  precommit:
39
39
  runs-on: ubuntu-latest
@@ -64,15 +64,15 @@ jobs:
64
64
  - uses: mpi4py/setup-mpi@v1
65
65
  - name: Build
66
66
  run: |
67
- pip install pdoc3
67
+ pip install pdoc
68
68
  pip install -e .
69
- python -We -m pdoc --html numba_mpi
69
+ PDOC_ALLOW_EXEC=1 python -We -m pdoc -o html numba_mpi
70
70
  - name: Deploy
71
71
  if: github.ref == 'refs/heads/main'
72
72
  uses: JamesIves/github-pages-deploy-action@4.1.1
73
73
  with:
74
74
  BRANCH: pdoc
75
- FOLDER: html/numba_mpi
75
+ FOLDER: html
76
76
  CLEAN: true
77
77
 
78
78
  zenodo_json:
@@ -165,9 +165,12 @@ jobs:
165
165
  python -We -c "import numba_mpi"
166
166
 
167
167
  - if: github.event_name == 'push' && github.ref == 'refs/heads/main'
168
- uses: pypa/gh-action-pypi-publish@unstable/v1
168
+ uses: pypa/gh-action-pypi-publish@release/v1.12
169
169
  with:
170
+ attestations: false
170
171
  repository_url: https://test.pypi.org/legacy/
171
172
 
172
173
  - if: startsWith(github.ref, 'refs/tags')
173
- uses: pypa/gh-action-pypi-publish@unstable/v1
174
+ uses: pypa/gh-action-pypi-publish@release/v1.12
175
+ with:
176
+ attestations: false
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "title": "numba-mpi",
3
- "description": "Numba @njittable wrappers for MPI C API tested on Linux, macOS and Windows",
3
+ "description": "Numba @jittable wrappers for MPI C API tested on Linux, macOS and Windows",
4
4
  "creators": [
5
5
  {
6
6
  "affiliation": "Jagiellonian University, Kraków, Poland",
@@ -0,0 +1,20 @@
1
+ cff-version: 1.2.0
2
+ title: "numba-mpi"
3
+ url: "https://github.com/numba-mpi/numba-mpi"
4
+ preferred-citation:
5
+ type: article
6
+ authors:
7
+ - family-names: "Derlatka"
8
+ given-names: "Kacper"
9
+ - family-names: "Manna"
10
+ given-names: "Maciej"
11
+ - family-names: "Bulenok"
12
+ given-names: "Oleksii"
13
+ - family-names: "Zwicker"
14
+ given-names: "David"
15
+ - family-names: "Arabas"
16
+ given-names: "Sylwester"
17
+ doi: "10.1016/j.softx.2024.101897"
18
+ journal: "SoftwareX"
19
+ title: "Numba-MPI v1.0: Enabling MPI communication within Numba/LLVM JIT-compiled Python code"
20
+ year: 2024
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: numba-mpi
3
- Version: 1.0.0
4
- Summary: Numba @njittable MPI wrappers tested on Linux, macOS and Windows
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.svg" style="height:50pt" alt="numba-mpi logo"> numba-mpi
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
  [![Python 3](https://img.shields.io/static/v1?label=Python&logo=Python&color=3776AB&message=3)](https://www.python.org/)
25
25
  [![LLVM](https://img.shields.io/static/v1?label=LLVM&logo=LLVM&color=gold&message=Numba)](https://numba.pydata.org)
@@ -35,9 +35,9 @@ Requires-Dist: py-pde; extra == "tests"
35
35
  [![DOI](https://zenodo.org/badge/316911228.svg)](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) (@njit mode).
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.njit()
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
- # <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
1
+ # <img src="https://raw.githubusercontent.com/numba-mpi/numba-mpi/main/.github/numba_mpi_logo.svg" width=128 height=142 alt="numba-mpi logo"> numba-mpi
2
2
 
3
3
  [![Python 3](https://img.shields.io/static/v1?label=Python&logo=Python&color=3776AB&message=3)](https://www.python.org/)
4
4
  [![LLVM](https://img.shields.io/static/v1?label=LLVM&logo=LLVM&color=gold&message=Numba)](https://numba.pydata.org)
@@ -14,9 +14,9 @@
14
14
  [![DOI](https://zenodo.org/badge/316911228.svg)](https://zenodo.org/badge/latestdoi/316911228)
15
15
 
16
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).
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) (@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).
18
18
 
19
- Support is provided for a subset of MPI routines covering: `size`/`rank`, `send`/`recv`, `allreduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier`, `wtime`
19
+ Support is provided for a subset of MPI routines covering: `size`/`rank`, `send`/`recv`, `allreduce`, `reduce`, `bcast`, `scatter`/`gather` & `allgather`, `barrier`, `wtime`
20
20
  and basic asynchronous communication with `isend`/`irecv` (only for contiguous arrays); for request handling including `wait`/`waitall`/`waitany` and `test`/`testall`/`testany`.
21
21
 
22
22
  The API uses NumPy and supports both numeric and character datatypes (e.g., `broadcast`).
@@ -45,7 +45,7 @@ Features that are not implemented yet include (help welcome!):
45
45
  ```python
46
46
  import numba, numba_mpi, numpy
47
47
 
48
- @numba.njit()
48
+ @numba.jit()
49
49
  def hello():
50
50
  src = numpy.array([1., 2., 3., 4., 5.])
51
51
  dst_tst = numpy.empty_like(src)
@@ -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
@@ -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.0.0
4
- Summary: Numba @njittable MPI wrappers tested on Linux, macOS and Windows
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.svg" style="height:50pt" alt="numba-mpi logo"> numba-mpi
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
  [![Python 3](https://img.shields.io/static/v1?label=Python&logo=Python&color=3776AB&message=3)](https://www.python.org/)
25
25
  [![LLVM](https://img.shields.io/static/v1?label=LLVM&logo=LLVM&color=gold&message=Numba)](https://numba.pydata.org)
@@ -35,9 +35,9 @@ Requires-Dist: py-pde; extra == "tests"
35
35
  [![DOI](https://zenodo.org/badge/316911228.svg)](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) (@njit mode).
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.njit()
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,10 +1,12 @@
1
1
  .gitignore
2
2
  .pre-commit-config.yaml
3
3
  .zenodo.json
4
+ CITATION.cff
4
5
  CODE_OF_CONDUCT.md
5
6
  LICENSE
6
7
  README.md
7
8
  setup.py
9
+ .github/numba_mpi_logo.png
8
10
  .github/numba_mpi_logo.svg
9
11
  .github/workflows/readme_snippets.yml
10
12
  .github/workflows/stale.yml
@@ -28,6 +30,7 @@ numba_mpi/api/isend.py
28
30
  numba_mpi/api/operator.py
29
31
  numba_mpi/api/rank.py
30
32
  numba_mpi/api/recv.py
33
+ numba_mpi/api/reduce.py
31
34
  numba_mpi/api/requests.py
32
35
  numba_mpi/api/scatter_gather.py
33
36
  numba_mpi/api/send.py
@@ -44,6 +47,7 @@ tests/api/test_bcast.py
44
47
  tests/api/test_init.py
45
48
  tests/api/test_isend_irecv.py
46
49
  tests/api/test_rank.py
50
+ tests/api/test_reduce.py
47
51
  tests/api/test_scatter_gather.py
48
52
  tests/api/test_send_recv.py
49
53
  tests/api/test_size.py
@@ -7,6 +7,9 @@ def get_long_description():
7
7
  """returns contents of README.md file"""
8
8
  with open("README.md", "r", encoding="utf8") as file:
9
9
  long_description = file.read()
10
+ long_description = long_description.replace(
11
+ "numba_mpi_logo.svg", "numba_mpi_logo.png"
12
+ )
10
13
  return long_description
11
14
 
12
15
 
@@ -21,7 +24,7 @@ setup(
21
24
  python_requires=">=3.8",
22
25
  setup_requires=["setuptools_scm"],
23
26
  license="GPL v3",
24
- description="Numba @njittable MPI wrappers tested on Linux, macOS and Windows",
27
+ description="Numba @jittable MPI wrappers tested on Linux, macOS and Windows",
25
28
  install_requires=("numba", "numpy", "mpi4py", "psutil"),
26
29
  extras_require={"tests": ("pytest<8.0.0", "py-pde")}, # TODO #122
27
30
  long_description=get_long_description(),
@@ -0,0 +1,54 @@
1
+ # pylint: disable=missing-function-docstring,missing-class-docstring,missing-module-docstring
2
+ import numpy as np
3
+ import pytest
4
+ from numba import njit
5
+
6
+ import numba_mpi as mpi
7
+ from tests.common import data_types_real
8
+ from tests.utils import get_random_array
9
+
10
+
11
+ @njit
12
+ def jit_reduce(sendobj, recvobj, operator, root):
13
+ """helper function to produce a jitted version of `reduce`"""
14
+ return mpi.reduce(sendobj, recvobj, operator, root)
15
+
16
+
17
+ @pytest.mark.parametrize("reduce", (mpi.reduce, jit_reduce))
18
+ @pytest.mark.parametrize(
19
+ "op_mpi, op_np",
20
+ (
21
+ (mpi.Operator.SUM, np.sum),
22
+ (mpi.Operator.MIN, np.min),
23
+ (mpi.Operator.MAX, np.max),
24
+ ),
25
+ )
26
+ @pytest.mark.parametrize("data_type", data_types_real)
27
+ @pytest.mark.parametrize("root", range(mpi.size()))
28
+ def test_reduce(reduce, op_mpi, op_np, data_type, root):
29
+ # test arrays
30
+ src = get_random_array((3,), data_type)
31
+ rcv = np.empty_like(src)
32
+ status = reduce(src, rcv, operator=op_mpi, root=root)
33
+ assert status == mpi.SUCCESS
34
+ if mpi.rank() == root:
35
+ expect = op_np(np.tile(src, [mpi.size(), 1]), axis=0)
36
+ np.testing.assert_equal(rcv, expect)
37
+
38
+ # test scalars
39
+ src = src[0]
40
+ rcv = np.empty(1, dtype=src.dtype)
41
+ status = reduce(src, rcv, operator=op_mpi, root=root)
42
+ assert status == mpi.SUCCESS
43
+ if mpi.rank() == root:
44
+ expect = op_np(np.tile(src, [mpi.size(), 1]), axis=0)
45
+ np.testing.assert_equal(rcv, expect)
46
+
47
+ # test 0d arrays
48
+ src = get_random_array((), data_type)
49
+ rcv = np.empty_like(src)
50
+ status = reduce(src, rcv, operator=op_mpi, root=root)
51
+ assert status == mpi.SUCCESS
52
+ if mpi.rank() == root:
53
+ expect = op_np(np.tile(src, [mpi.size(), 1]), axis=0)
54
+ np.testing.assert_equal(rcv, expect)
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