Skip to content

Commit

Permalink
Hide mpi4py import
Browse files Browse the repository at this point in the history
  • Loading branch information
arahlin committed Oct 4, 2023
1 parent e83e07f commit 65e05be
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions mpi/MPIFileIO.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from mpi4py import MPI
from spt3g import core
import random

Expand Down Expand Up @@ -117,15 +116,20 @@ def __call__(self, frame):
return [] # Terminate processing on IO nodes

@core.pipesegment
def MPIIODistributor(pipe, mpicomm=MPI.COMM_WORLD, n_io=10, files=[]):
def MPIIODistributor(pipe, mpicomm=None, n_io=10, files=[]):
'''
Read files from disk using the first n_io processes in mpicomm, with
processing of frames in those files occurring on the other processes
in mpicomm. See documentation for MPIFileReader for the format of
the files argument and MPIFrameParallelizer for information on the
semantics of processing. Add this as the first module in your pipeline
in place of core.G3Reader.
Read files from disk using the first n_io processes in mpicomm (COMM_WORLD
by default), with processing of frames in those files occurring on the other
processes in mpicomm. See documentation for MPIFileReader for the format of
the files argument and MPIFrameParallelizer for information on the semantics
of processing. Add this as the first module in your pipeline in place of
core.G3Reader.
'''
if mpicomm is None:
from mpi4py import MPI

mpicomm = MPI.COMM_WORLD

subcomm = mpicomm.Split(mpicomm.rank < n_io, mpicomm.rank)
if mpicomm.rank < n_io:
pipe.Add(MPIFileReader, mpicomm=subcomm, files=files)
Expand Down

0 comments on commit 65e05be

Please sign in to comment.