Skip to content

Commit 16ef26d

Browse files
authored
Merge pull request #11 from tskisner/win_fence
Add Fence calls on shared windows to fix RMA errors.
2 parents 8e9a210 + 4a47f9d commit 16ef26d

File tree

6 files changed

+48
-54
lines changed

6 files changed

+48
-54
lines changed

.github/workflows/deploy.yml

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,68 +23,39 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Cancel Previous Runs
26-
uses: styfle/cancel-workflow-action@0.4.0
26+
uses: styfle/cancel-workflow-action@0.9.1
2727
with:
2828
access_token: ${{ github.token }}
29+
2930
- name: Checkout
3031
uses: actions/checkout@v2
32+
3133
- name: Set up Python 3.7
3234
uses: actions/setup-python@v2
3335
with:
3436
python-version: 3.7
37+
3538
- name: Install Dependencies
3639
run: ./test_scripts/install_deps_github_ubuntu.sh && pip install twine
40+
3741
- name: Install Package
3842
run: pip install .
43+
3944
- name: Run Serial Test
4045
run: MPI_DISABLE=1 python3 -c 'import pshmem.test; pshmem.test.run()'
46+
4147
- name: Run MPI Test on 1 Process
4248
run: mpirun -np 1 python3 -c 'import pshmem.test; pshmem.test.run()'
49+
4350
- name: Run MPI Test on 2 Processes
4451
run: mpirun -np 2 python3 -c 'import pshmem.test; pshmem.test.run()'
52+
4553
- name: Build source package
4654
run: rm -rf dist && python setup.py sdist
55+
4756
- name: Build wheels
4857
run: mkdir -p wheelhouse && pip wheel -w wheelhouse .
58+
4959
- name: Upload to PyPI
5060
run: |
5161
python -m twine upload dist/*.tar.gz && python -m twine upload wheelhouse/pshmem*.whl
52-
53-
54-
# jobs:
55-
# wheels:
56-
# name: Python wheels on ${{ matrix.os }}
57-
# runs-on: ${{ matrix.os }}
58-
# strategy:
59-
# matrix:
60-
# os: [ubuntu-latest, macos-latest]
61-
# env:
62-
# CIBW_BUILD: cp36-macosx_x86_64 cp36-manylinux_x86_64 cp37-macosx_x86_64 cp37-manylinux_x86_64 cp38-macosx_x86_64 cp38-manylinux_x86_64
63-
# CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
64-
# CIBW_MANYLINUX_I686_IMAGE: manylinux2014
65-
# CIBW_BUILD_VERBOSITY: 3
66-
# CIBW_ENVIRONMENT_LINUX: "PATH=/usr/lib64/mpich-3.2/bin:${PATH}"
67-
# CIBW_BEFORE_BUILD_LINUX: ./test_scripts/install_deps_cibuildwheel_linux.sh
68-
# CIBW_BEFORE_BUILD_MACOS: ./test_scripts/install_deps_cibuildwheel_macos.sh
69-
# CIBW_BEFORE_TEST: pip3 install numpy && pip3 install mpi4py
70-
# CIBW_TEST_COMMAND: mpirun -np 2 python -c 'import pshmem; pshmem.test()'
71-
# steps:
72-
# - uses: actions/checkout@v2
73-
# - uses: actions/setup-python@v2
74-
# name: Install Python
75-
# with:
76-
# python-version: '3.7'
77-
# - name: Install cibuildwheel
78-
# run: |
79-
# python -m pip install twine cibuildwheel==1.4.2
80-
# - name: Build wheel
81-
# run: |
82-
# python -m cibuildwheel --output-dir wheelhouse
83-
# - name: Upload to PyPI
84-
# run: |
85-
# python -m twine upload wheelhouse/*.whl
86-
87-
# - uses: actions/upload-artifact@v2
88-
# with:
89-
# name: wheels
90-
# path: ./wheelhouse

.github/workflows/test.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,66 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [3.6, 3.7, 3.8]
16+
python-version: ["3.6", "3.7", "3.9", "3.10"]
1717
steps:
1818
- name: Cancel Previous Runs
19-
uses: styfle/cancel-workflow-action@0.4.0
19+
uses: styfle/cancel-workflow-action@0.9.1
2020
with:
2121
access_token: ${{ github.token }}
22+
2223
- name: Checkout
2324
uses: actions/checkout@v2
25+
2426
- name: Set up Python ${{ matrix.python-version }}
2527
uses: actions/setup-python@v2
2628
with:
2729
python-version: ${{ matrix.python-version }}
30+
2831
- name: Install Dependencies
2932
run: ./test_scripts/install_deps_github_ubuntu.sh
33+
3034
- name: Install Package
3135
run: pip3 install .
36+
3237
- name: Run Serial Test
3338
run: MPI_DISABLE=1 python3 -c 'import pshmem.test; pshmem.test.run()'
39+
3440
- name: Run MPI Test on 1 Process
3541
run: mpirun -np 1 python3 -c 'import pshmem.test; pshmem.test.run()'
42+
3643
- name: Run MPI Test on 2 Processes
3744
run: mpirun -np 2 python3 -c 'import pshmem.test; pshmem.test.run()'
45+
3846
macos:
3947
runs-on: macos-latest
4048
strategy:
4149
matrix:
42-
python-version: [3.6, 3.7, 3.8]
50+
python-version: ["3.6", "3.7", "3.9", "3.10"]
4351
steps:
4452
- name: Cancel Previous Runs
45-
uses: styfle/cancel-workflow-action@0.4.0
53+
uses: styfle/cancel-workflow-action@0.9.1
4654
with:
4755
access_token: ${{ github.token }}
56+
4857
- name: Checkout
4958
uses: actions/checkout@v2
59+
5060
- name: Set up Python ${{ matrix.python-version }}
5161
uses: actions/setup-python@v2
5262
with:
5363
python-version: ${{ matrix.python-version }}
64+
5465
- name: Install Dependencies
5566
run: ./test_scripts/install_deps_github_macos.sh
67+
5668
- name: Install Package
5769
run: pip3 install .
70+
5871
- name: Run Serial Test
5972
run: MPI_DISABLE=1 python3 -c 'import pshmem.test; pshmem.test.run()'
73+
6074
- name: Run MPI Test on 1 Process
6175
run: mpirun -np 1 python3 -c 'import pshmem.test; pshmem.test.run()'
76+
6277
- name: Run MPI Test on 2 Processes
6378
run: mpirun -np 2 python3 -c 'import pshmem.test; pshmem.test.run()'

pshmem/locking.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def __init__(self, comm, root=0, debug=False):
8484
print(msg, flush=True)
8585
raise
8686

87+
self._win.Fence()
88+
8789
if self._rank == self._root:
8890
# Root sets to zero
8991
self._win.Lock(self._root, MPI.LOCK_EXCLUSIVE)
@@ -95,6 +97,8 @@ def __init__(self, comm, root=0, debug=False):
9597
self._win.Flush(self._root)
9698
self._win.Unlock(self._root)
9799

100+
self._win.Fence()
101+
98102
return
99103

100104
def __del__(self):
@@ -110,6 +114,7 @@ def __exit__(self, type, value, tb):
110114
def close(self):
111115
# Explicitly free the shared window
112116
if hasattr(self, "_win") and (self._win is not None):
117+
self._win.Fence()
113118
self._win.Free()
114119
self._win = None
115120
return
@@ -143,6 +148,7 @@ def lock(self):
143148
),
144149
flush=True,
145150
)
151+
146152
self._win.Lock(self._root, MPI.LOCK_EXCLUSIVE)
147153

148154
# Get a local copy of the buffer

pshmem/shmem.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ def __init__(self, shape, dtype, comm, comm_node=None, comm_node_rank=None):
179179

180180
if self._n > 0:
181181
if self._comm is None:
182-
self._buffer = np.ndarray(shape=(nbytes,), dtype=np.dtype("B"), order="C")
182+
self._buffer = np.ndarray(
183+
shape=(nbytes,), dtype=np.dtype("B"), order="C"
184+
)
183185
else:
184186
import mpi4py.MPI as MPI
185187

@@ -205,6 +207,7 @@ def __init__(self, shape, dtype, comm, comm_node=None, comm_node_rank=None):
205207
# Every process looks up the memory address of rank zero's piece,
206208
# which is the start of the contiguous shared buffer.
207209
try:
210+
self._win.Fence()
208211
self._buffer, dsize = self._win.Shared_query(0)
209212
except:
210213
msg = "Process {} failed Win.Shared_query(0)".format(
@@ -340,6 +343,7 @@ def __repr__(self):
340343
def close(self):
341344
# Explicitly free the shared memory window.
342345
if hasattr(self, "_win") and (self._win is not None):
346+
self._win.Fence()
343347
self._win.Free()
344348
self._win = None
345349
# Free other communicators if needed
@@ -529,6 +533,8 @@ def set(self, data, offset=None, fromrank=0):
529533
# Delete the temporary copy
530534
del nodedata
531535

536+
self._win.Fence()
537+
532538
else:
533539
# We are just copying to a numpy array...
534540
dslice = []

pshmem/test.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,23 +309,17 @@ def test_zero(self):
309309
)
310310
self.assertTrue(False)
311311
except RuntimeError:
312-
print(
313-
"successful raise with no data during assignment", flush=True
314-
)
312+
print("successful raise with no data during assignment", flush=True)
315313
try:
316314
if self.rank == 0:
317315
shm.set(1.0, fromrank=0)
318316
else:
319317
shm.set(None, fromrank=0)
320318
if self.rank == 0:
321-
print(
322-
"unsuccessful raise with no data during set()", flush=True
323-
)
319+
print("unsuccessful raise with no data during set()", flush=True)
324320
self.assertTrue(False)
325321
except RuntimeError:
326-
print(
327-
"successful raise with no data during set()", flush=True
328-
)
322+
print("successful raise with no data during set()", flush=True)
329323

330324

331325
class LockTest(unittest.TestCase):

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def readme():
3737
"Programming Language :: Python :: 3.6",
3838
"Programming Language :: Python :: 3.7",
3939
"Programming Language :: Python :: 3.8",
40+
"Programming Language :: Python :: 3.9",
41+
"Programming Language :: Python :: 3.10",
4042
"Topic :: Utilities",
4143
],
4244
)

0 commit comments

Comments
 (0)