From 39372d46b08d34fa4a5a4278884e951ace16e91f Mon Sep 17 00:00:00 2001 From: Mike Jarvis Date: Mon, 14 Jul 2025 13:51:39 -0400 Subject: [PATCH 1/4] Allow IN_PLACE=-1 as well --- mockmpi/comm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mockmpi/comm.py b/mockmpi/comm.py index 58c2713..f436900 100644 --- a/mockmpi/comm.py +++ b/mockmpi/comm.py @@ -3,9 +3,11 @@ 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. +IN_PLACE = -1 +ALLOWED_IN_PLACE = [1, -1] class MockComm(object): @@ -113,7 +115,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): From 8a15c24029ec19da7c93c146c048a5eafc4f936b Mon Sep 17 00:00:00 2001 From: Mike Jarvis Date: Mon, 14 Jul 2025 13:54:36 -0400 Subject: [PATCH 2/4] update ci versions --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 843a64a..ece462e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,12 +21,12 @@ jobs: - 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') }} From 24ab6f85a53de748bfa4b359909b316729d95d03 Mon Sep 17 00:00:00 2001 From: Mike Jarvis Date: Mon, 14 Jul 2025 13:55:44 -0400 Subject: [PATCH 3/4] Check against more recent python versions in ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ece462e..b1d0329 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ 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 From 6afdbcd0490d7874251c4df006158859df81c5a0 Mon Sep 17 00:00:00 2001 From: Mike Jarvis Date: Mon, 14 Jul 2025 17:59:19 -0400 Subject: [PATCH 4/4] Just in case it changes again, include the real mpi4py IN_PLACE if available --- mockmpi/comm.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mockmpi/comm.py b/mockmpi/comm.py index f436900..53011d6 100644 --- a/mockmpi/comm.py +++ b/mockmpi/comm.py @@ -6,8 +6,12 @@ # 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. -IN_PLACE = -1 -ALLOWED_IN_PLACE = [1, -1] +# 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):