Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
py: [ 3.7, 3.8, 3.9 ]
py: [ 3.12, 3.13 ]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.py }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}

- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.py }}-pip-${{ hashFiles('requirements.txt') }}
Expand Down
14 changes: 10 additions & 4 deletions mockmpi/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

import numpy as np

# This constant seems to have the same value in MPICH and OpenMPI
# so we reproduce it here since it can be quite important.
IN_PLACE = 1
# This constant used to be 1 in both MPICH and OpenMPI,
# but starting with mpi4py version 4, they switched it to -1.
# Use -1 here, but when we check for it allow 1 as well.
# And if we happen to have mpi4py installed, include whatever it actually has as well.
try:
from mpi4py.MPI import IN_PLACE
except ImportError:
IN_PLACE = -1
ALLOWED_IN_PLACE = [IN_PLACE, 1, -1]


class MockComm(object):
Expand Down Expand Up @@ -113,7 +119,7 @@ def allreduce(self, sendobj, op=None):
return d

def Reduce(self, sendbuf, recvbuf, op=None, root=0):
if isinstance(sendbuf, int) and (sendbuf == IN_PLACE):
if isinstance(sendbuf, int) and (sendbuf in ALLOWED_IN_PLACE):
sendbuf = recvbuf.copy()

if not isinstance(sendbuf, np.ndarray):
Expand Down
Loading