[yt-svn] commit/yt: chummels: Merged in dfenn/yt (pull request #1340)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Dec 4 16:48:21 PST 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/0a5fada14287/
Changeset:   0a5fada14287
Branch:      yt
User:        chummels
Date:        2014-12-05 00:48:13+00:00
Summary:     Merged in dfenn/yt (pull request #1340)

Enables using an MPI subcommunicator
Affected #:  2 files

diff -r 6af7c5295ac43cbaab23054d2983bb70d54c9108 -r 0a5fada14287a12f9ea1061754ad386efadc30bd yt/__init__.py
--- a/yt/__init__.py
+++ b/yt/__init__.py
@@ -152,7 +152,7 @@
 
 from yt.visualization.volume_rendering.api import \
     off_axis_projection, ColorTransferFunction, \
-    TransferFunctionHelper
+    TransferFunctionHelper, TransferFunction, MultiVariateTransferFunction
 
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
     parallel_objects, enable_parallelism, communication_system

diff -r 6af7c5295ac43cbaab23054d2983bb70d54c9108 -r 0a5fada14287a12f9ea1061754ad386efadc30bd yt/utilities/parallel_tools/parallel_analysis_interface.py
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py
@@ -63,7 +63,7 @@
 
 # Set up translation table and import things
 
-def enable_parallelism(suppress_logging=False):
+def enable_parallelism(suppress_logging=False, communicator=None):
     """
     This method is used inside a script to turn on MPI parallelism, via 
     mpi4py.  More information about running yt in parallel can be found
@@ -74,6 +74,10 @@
     suppress_logging : bool
        If set to True, only rank 0 will log information after the initial
        setup of MPI.
+
+    communicator : mpi4py.MPI.Comm
+        The MPI communicator to use. This controls which processes yt can see.
+        If not specified, will be set to COMM_WORLD.
     """
     global parallel_capable, MPI
     try:
@@ -84,30 +88,35 @@
         return
     MPI = _MPI
     exe_name = os.path.basename(sys.executable)
-    parallel_capable = (MPI.COMM_WORLD.size > 1)
+    
+    # if no communicator specified, set to COMM_WORLD
+    if communicator is None:
+        communicator = MPI.COMM_WORLD
+
+    parallel_capable = (communicator.size > 1)
     if not parallel_capable: return False
     mylog.info("Global parallel computation enabled: %s / %s",
-               MPI.COMM_WORLD.rank, MPI.COMM_WORLD.size)
-    communication_system.push(MPI.COMM_WORLD)
-    ytcfg["yt","__global_parallel_rank"] = str(MPI.COMM_WORLD.rank)
-    ytcfg["yt","__global_parallel_size"] = str(MPI.COMM_WORLD.size)
+               communicator.rank, communicator.size)
+    communication_system.push(communicator)
+    ytcfg["yt","__global_parallel_rank"] = str(communicator.rank)
+    ytcfg["yt","__global_parallel_size"] = str(communicator.size)
     ytcfg["yt","__parallel"] = "True"
     if exe_name == "embed_enzo" or \
         ("_parallel" in dir(sys) and sys._parallel == True):
         ytcfg["yt","inline"] = "True"
-    if MPI.COMM_WORLD.rank > 0:
+    if communicator.rank > 0:
         if ytcfg.getboolean("yt","LogFile"):
             ytcfg["yt","LogFile"] = "False"
             yt.utilities.logger.disable_file_logging()
     yt.utilities.logger.uncolorize_logging()
     # Even though the uncolorize function already resets the format string,
     # we reset it again so that it includes the processor.
-    f = logging.Formatter("P%03i %s" % (MPI.COMM_WORLD.rank,
+    f = logging.Formatter("P%03i %s" % (communicator.rank,
                                         yt.utilities.logger.ufstring))
     if len(yt.utilities.logger.rootLogger.handlers) > 0:
         yt.utilities.logger.rootLogger.handlers[0].setFormatter(f)
     if ytcfg.getboolean("yt", "parallel_traceback"):
-        sys.excepthook = traceback_writer_hook("_%03i" % MPI.COMM_WORLD.rank)
+        sys.excepthook = traceback_writer_hook("_%03i" % communicator.rank)
     if ytcfg.getint("yt","LogLevel") < 20:
         yt.utilities.logger.ytLogger.warning(
           "Log Level is set low -- this could affect parallel performance!")
@@ -125,7 +134,7 @@
     ))
     # Turn off logging on all but the root rank, if specified.
     if suppress_logging:
-        if MPI.COMM_WORLD.rank > 0:
+        if communicator.rank > 0:
             mylog.addFilter(FilterAllMessages())
     return True
 
@@ -217,7 +226,6 @@
         # attribute, which must be an instance of MPI.Intracomm, and call bcast
         # on that.
         retval = comm.comm.bcast(retval, root=self._owner)
-        #MPI.COMM_WORLD.Barrier()
         return retval
     return single_proc_results
 
@@ -621,7 +629,7 @@
         from yt.config import ytcfg
         ytcfg["yt","__topcomm_parallel_size"] = str(new_comm.size)
         ytcfg["yt","__topcomm_parallel_rank"] = str(new_comm.rank)
-        if MPI.COMM_WORLD.rank > 0 and ytcfg.getboolean("yt","serialize"):
+        if new_comm.rank > 0 and ytcfg.getboolean("yt","serialize"):
             ytcfg["yt","onlydeserialize"] = "True"
 
     def pop(self):

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list