[cig-commits] r13927 - in short/3D/PyLith/branches/pylith-swig/pylith: . mpi
brad at geodynamics.org
brad at geodynamics.org
Thu Jan 22 15:54:07 PST 2009
Author: brad
Date: 2009-01-22 15:54:07 -0800 (Thu, 22 Jan 2009)
New Revision: 13927
Added:
short/3D/PyLith/branches/pylith-swig/pylith/mpi/
short/3D/PyLith/branches/pylith-swig/pylith/mpi/Communicator.py
short/3D/PyLith/branches/pylith-swig/pylith/mpi/__init__.py
Log:
Created MPI Communicator for SWIG friendly interface.
Added: short/3D/PyLith/branches/pylith-swig/pylith/mpi/Communicator.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/mpi/Communicator.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/pylith/mpi/Communicator.py 2009-01-22 23:54:07 UTC (rev 13927)
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/mpi/Communicator.py
+##
+## @brief Python MPI communicator object.
+##
+## Provides SWIG friendly interface to MPI communicator object.
+
+import pylith.mpi.mpi as mpimodule
+
+# Communicator class
+class Communicator(object):
+ """
+ Python MPI communicator object.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, group):
+ """
+ Constructor.
+ """
+ self.handle = mpimodule.create_communicator(group)
+ self.rank = mpimodule.rank(self.handle)
+ self.size = mpimodule.size(self.handle)
+ return
+
+
+ def barrier(self):
+ """
+ MPI Barrier.
+ """
+ mpimodule.barrier(self.handle)
+ return
+
+
+# ----------------------------------------------------------------------
+def petsc_world():
+ """
+ Python wrapper around PETSC_COMM_WORLD.
+ """
+ global _petsc_world
+ if _petsc_world is None:
+ _petsc_world = Communicator(mpimodule.PETSC_COMM_WORLD)
+ return _petsc_world
+
+
+# ----------------------------------------------------------------------
+def petsc_self():
+ """
+ Python wrapper around PETSC_COMM_SELF.
+ """
+ global _petsc_self
+ if _petsc_self is None:
+ _petsc_self = Communicator(mpimodule.PETSC_COMM_SELF)
+ return _petsc_self
+
+
+# ----------------------------------------------------------------------
+def mpi_world():
+ """
+ Python wrapper around MPI_COMM_WORLD.
+ """
+ global _mpi_world
+ if _mpi_world is None:
+ _mpi_world = Communicator(mpimodule.MPI_COMM_WORLD)
+ return _mpi_world
+
+
+# ----------------------------------------------------------------------
+def mpi_self():
+ """
+ Python wrapper around MPI_COMM_SELF.
+ """
+ global _mpi_self
+ if _mpi_self is None:
+ _mpi_self = Communicator(mpimodule.MPI_COMM_SELF)
+ return _mpi_self
+
+
+# ----------------------------------------------------------------------
+# Singletons
+_petsc_world = None
+_petsc_self = None
+_mpi_world = None
+_mpi_self = None
+
+
+# End of file
Added: short/3D/PyLith/branches/pylith-swig/pylith/mpi/__init__.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/mpi/__init__.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/pylith/mpi/__init__.py 2009-01-22 23:54:07 UTC (rev 13927)
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/mpi/__init__.py
+##
+## @brief Python PyLith mpi module initialization
+
+__all__ = ['Communicator',
+ ]
+
+
+# End of file
More information about the CIG-COMMITS
mailing list