Skip to content

Commit

Permalink
Merge pull request #460 from GavinHuttley/develop
Browse files Browse the repository at this point in the history
BUG: setting max_workers for MPI now uses UNIVERSE_SIZE
  • Loading branch information
GavinHuttley committed Dec 20, 2019
2 parents aa9a90a + 6a2f916 commit de5cbac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/cogent3/app/composable.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,4 +688,3 @@ def __str__(self):

def __repr__(self):
return str(self)

10 changes: 8 additions & 2 deletions src/cogent3/util/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ def imap(f, s, max_workers=None, use_mpi=False, if_serial="raise", chunksize=Non
elif COMM.Get_attr(MPI.UNIVERSE_SIZE) == 1 and if_serial == "warn":
warnings.warn(UserWarning, msg=err_msg)

if not max_workers:
max_workers = COMM.Get_attr(MPI.UNIVERSE_SIZE) - 1
max_workers = max_workers or 0

if max_workers > COMM.Get_attr(MPI.UNIVERSE_SIZE):
warnings.warn(
UserWarning, msg="max_workers too large, reducing to UNIVERSE_SIZE-1"
)

max_workers = min(max_workers, COMM.Get_attr(MPI.UNIVERSE_SIZE) - 1)

if not chunksize:
chunksize = set_default_chunksize(s, max_workers)
Expand Down

0 comments on commit de5cbac

Please sign in to comment.