[cig-commits] r13929 - in short/3D/PyLith/branches/pylith-swig: pylith/mpi unittests/pytests unittests/pytests/mpi
brad at geodynamics.org
brad at geodynamics.org
Thu Jan 22 21:09:02 PST 2009
Author: brad
Date: 2009-01-22 21:09:02 -0800 (Thu, 22 Jan 2009)
New Revision: 13929
Added:
short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/
short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/Makefile.am
short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/TestCommunicator.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/testmpi.py
Modified:
short/3D/PyLith/branches/pylith-swig/pylith/mpi/Communicator.py
short/3D/PyLith/branches/pylith-swig/unittests/pytests/Makefile.am
Log:
Finished Communicator.
Modified: short/3D/PyLith/branches/pylith-swig/pylith/mpi/Communicator.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/pylith/mpi/Communicator.py 2009-01-23 00:21:22 UTC (rev 13928)
+++ short/3D/PyLith/branches/pylith-swig/pylith/mpi/Communicator.py 2009-01-23 05:09:02 UTC (rev 13929)
@@ -45,7 +45,7 @@
# ----------------------------------------------------------------------
-def petsc_world():
+def petsc_comm_world():
"""
Python wrapper around PETSC_COMM_WORLD.
"""
@@ -56,7 +56,7 @@
# ----------------------------------------------------------------------
-def petsc_self():
+def petsc_comm_self():
"""
Python wrapper around PETSC_COMM_SELF.
"""
@@ -67,7 +67,7 @@
# ----------------------------------------------------------------------
-def mpi_world():
+def mpi_comm_world():
"""
Python wrapper around MPI_COMM_WORLD.
"""
@@ -78,13 +78,13 @@
# ----------------------------------------------------------------------
-def mpi_self():
+def mpi_comm_self():
"""
Python wrapper around MPI_COMM_SELF.
"""
global _mpi_self
if _mpi_self is None:
- _mpi_self = Communicator(mpimodule.MPI_COMM_SELF)
+ _mpi_self = Communicator(mpimodule.mpi_comm_self())
return _mpi_self
Modified: short/3D/PyLith/branches/pylith-swig/unittests/pytests/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/Makefile.am 2009-01-23 00:21:22 UTC (rev 13928)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/Makefile.am 2009-01-23 05:09:02 UTC (rev 13929)
@@ -16,6 +16,7 @@
feassemble \
materials \
meshio \
+ mpi \
problems \
topology \
utils
Added: short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/Makefile.am (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/Makefile.am 2009-01-23 05:09:02 UTC (rev 13929)
@@ -0,0 +1,25 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+subpackage = bc
+include $(top_srcdir)/subpackage.am
+
+TESTS = testmpi.py
+dist_check_SCRIPTS = testmpi.py
+
+TESTS_ENVIRONMENT = $(PYTHON)
+
+noinst_PYTHON = \
+ TestCommunicator.py
+
+
+# End of file
Added: short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/TestCommunicator.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/TestCommunicator.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/TestCommunicator.py 2009-01-23 05:09:02 UTC (rev 13929)
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/utils/TestCommunicator.py
+
+## @brief Unit testing of Communicator object.
+
+import unittest
+
+import pylith.mpi.Communicator as mpicomm
+
+# ----------------------------------------------------------------------
+class TestCommunicator(unittest.TestCase):
+ """
+ Unit testing of Communicator object.
+ """
+
+
+ def test_petsc_comm_world(self):
+ """
+ Test petsc_comm_world().
+ """
+ comm = mpicomm.petsc_comm_world()
+ return
+
+
+ def test_petsc_comm_self(self):
+ """
+ Test petsc_comm_self().
+ """
+ comm = mpicomm.petsc_comm_self()
+ return
+
+
+ def test_mpi_comm_world(self):
+ """
+ Test mpi_comm_world().
+ """
+ comm = mpicomm.mpi_comm_world()
+ return
+
+
+ def test_mpi_comm_self(self):
+ """
+ Test mpi_comm_self().
+ """
+ comm = mpicomm.mpi_comm_self()
+ return
+
+
+ def test_rank(self):
+ """
+ Test Communicator.rank().
+ """
+ comm = mpicomm.petsc_comm_world()
+ self.assertEqual(0, comm.rank)
+ return
+
+
+ def test_size(self):
+ """
+ Test Communicator.size().
+ """
+ comm = mpicomm.petsc_comm_world()
+ self.assertEqual(1, comm.size)
+ return
+
+
+ def test_barrier(self):
+ """
+ Test Communicator.barrier().
+ """
+ comm = mpicomm.petsc_comm_world()
+ comm.barrier()
+ return
+
+
+# End of file
Added: short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/testmpi.py
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/testmpi.py (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/testmpi.py 2009-01-23 05:09:02 UTC (rev 13929)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/bc/testmpi.py
+
+## @brief Python application for testing mpi code.
+
+from pyre.applications.Script import Script
+
+import unittest
+
+class TestApp(Script):
+ """
+ Test application.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="testapp"):
+ """
+ Constructor.
+ """
+ Script.__init__(self, name)
+ return
+
+
+ def main(self):
+ """
+ Run the application.
+ """
+ from pylith.utils.PetscManager import PetscManager
+ petsc = PetscManager()
+ petsc.initialize()
+
+ unittest.TextTestRunner(verbosity=2).run(self._suite())
+
+ petsc.finalize()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _suite(self):
+ """
+ Setup the test suite.
+ """
+
+ suite = unittest.TestSuite()
+
+ from TestCommunicator import TestCommunicator
+ suite.addTest(unittest.makeSuite(TestCommunicator))
+
+ return suite
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+ app = TestApp()
+ app.run()
+
+
+# End of file
Property changes on: short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi/testmpi.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the CIG-COMMITS
mailing list