Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to catch unit test failures more reliably #23

Merged
merged 4 commits into from
Mar 14, 2024
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
29 changes: 15 additions & 14 deletions pshmem/shmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,21 @@ def __init__(self, shape, dtype, comm, comm_node=None, comm_node_rank=None):
print(msg, flush=True)
raise

# Wait for other processes to attach
# Create a numpy array which acts as a view of the buffer.
self._flat = np.ndarray(
self._n,
dtype=self._dtype,
buffer=self._shmem,
)

# Initialize to zero.
if self._noderank == 0:
self._flat[:] = 0

# Wrap
self.data = self._flat.reshape(self._shape)

# Wait for other processes to attach and wrap
if self._nodecomm is not None:
self._nodecomm.barrier()

Expand All @@ -229,19 +243,6 @@ def __init__(self, shape, dtype, comm, comm_node=None, comm_node_rank=None):
print(msg, flush=True)
raise

# Create a numpy array which acts as a view of the buffer.
self._flat = np.ndarray(
self._n,
dtype=self._dtype,
buffer=self._shmem,
)
# Initialize to zero.
if self._noderank == 0:
self._flat[:] = 0

# Wrap
self.data = self._flat.reshape(self._shape)

def __del__(self):
self.close()

Expand Down
18 changes: 17 additions & 1 deletion pshmem/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,25 @@ def test_lock(self):


def run():
comm = None
if MPI is not None:
comm = MPI.COMM_WORLD

suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(LockTest))
suite.addTest(unittest.makeSuite(ShmemTest))
runner = unittest.TextTestRunner()
runner.run(suite)

ret = 0
_ret = runner.run(suite)
if not _ret.wasSuccessful():
ret += 1

if comm is not None:
ret = comm.allreduce(ret, op=MPI.SUM)

if ret > 0:
print(f"{ret} Processes had failures")
sys.exit(6)

return