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

mpi: Add utility to get number of ranks on a single node #2265

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions devito/mpi/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ def nprocs(self):
else:
return 1

@property
def nprocs_local(self):
if self.comm is not MPI.COMM_NULL:
local_comm = MPI.Comm.Split_type(self.comm, MPI.COMM_TYPE_SHARED)
node_size = local_comm.Get_size()
local_comm.Free()
return node_size
else:
return 1

@property
def topology(self):
return self._topology
Expand Down
1 change: 1 addition & 0 deletions tests/test_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_partitioning(self):
}
assert f.shape == expected[distributor.nprocs][distributor.myrank]
assert f.size_global == 225
assert distributor.nprocs_local == distributor.nprocs

@pytest.mark.parallel(mode=[2, 4])
def test_partitioning_fewer_dims(self):
Expand Down
Loading