Skip to content

Commit

Permalink
use MPI.Group.Compare for the comm tests in ManualEnsemble
Browse files Browse the repository at this point in the history
  • Loading branch information
JHopeCollins committed May 7, 2024
1 parent b5ccbfe commit 9113af8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions asQ/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ def __init__(self, global_comm, spatial_comm, ensemble_comm, **kwargs):
if MPI.Group.Intersection(spatial_group, ensemble_group).size != 1:
raise PyOP2CommError("spatial and ensemble comms must be cartesian product in global_comm")

spatial_intersection = MPI.Group.Intersection(global_group, spatial_group)
ensemble_intersection = MPI.Group.Intersection(global_group, ensemble_group)
is_subgroup = lambda sub, group: MPI.Group.Compare(sub, MPI.Group.Intersection(sub, group)) in {MPI.IDENT, MPI.CONGRUENT}

if MPI.Group.Compare(spatial_intersection, spatial_group) not in {MPI.IDENT, MPI.CONGRUENT}:
if not is_subgroup(spatial_group, global_group):
raise PyOP2CommError("spatial_comm must be subgroup of global_comm")
if MPI.Group.Compare(ensemble_intersection, ensemble_group) not in {MPI.IDENT, MPI.CONGRUENT}:
if not is_subgroup(ensemble_group, global_group):
raise PyOP2CommError("ensemble_comm must be subgroup of global_comm")

# create internal duplicates and name comms for debugging
Expand Down

0 comments on commit 9113af8

Please sign in to comment.