示例#1
0
    def test_allreduce_scalar_int(self):
        value = 3
        result = mpi.allreduce_scalar_int(value, mpi.mpi_sum(),
                                          mpi.petsc_comm_world())
        self.assertEqual(value, result)

        result = mpi.allreduce_scalar_int(value, mpi.mpi_min(),
                                          mpi.petsc_comm_self())
        self.assertEqual(value, result)

        result = mpi.allreduce_scalar_int(value, mpi.mpi_max(),
                                          mpi.petsc_comm_world())
        self.assertEqual(value, result)
        return
示例#2
0
文件: TestReduce.py 项目: jjle/pylith
  def test_allreduce_scalar_int(self):
    """
    Test allreduce_int().
    """
    value = 3
    result = mpi.allreduce_scalar_int(value, mpi.mpi_sum(), mpi.petsc_comm_world())
    self.assertEqual(value, result)

    result = mpi.allreduce_scalar_int(value, mpi.mpi_min(), mpi.petsc_comm_self())
    self.assertEqual(value, result)

    result = mpi.allreduce_scalar_int(value, mpi.mpi_max(), mpi.petsc_comm_world())
    self.assertEqual(value, result)
    return
示例#3
0
    def onComputeNodes(self, *args, **kwds):
        """Run the application in parallel on the compute nodes.
        """
        self.petsc.initialize()

        if self.inventory.includeCitations:
            self.petsc.setOption("-citations", "")

            from pylith.utils.petsc import citationsRegister
            for entry in self.citations():
                citationsRegister(entry)

        try:
            self.main(*args, **kwds)
        except Exception as err:
            import traceback
            import sys

            self.cleanup()  # Attempt to clean up memory.
            print(
                "Fatal error. Calling MPI_Abort() to abort PyLith application."
            )
            traceback.print_exc(file=sys.stdout)
            sys.stdout.flush()
            from pylith.mpi import mpi
            errorCode = -1
            mpi.mpi_abort(mpi.petsc_comm_world(), errorCode)

        self.cleanup()
        self.petsc.finalize()
        return
示例#4
0
def petsc_comm_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
示例#5
0
  def onComputeNodes(self, *args, **kwds):
    """
    Run the application in parallel on the compute nodes.
    """
    self.petsc.initialize()

    if self.inventory.includeCitations:
      self.petsc.setOption("-citations", "")

      from pylith.utils.petsc import citationsRegister
      for entry in self.citations():
        citationsRegister(entry)

    try:

      self.main(*args, **kwds)

    except Exception, err:
      self.cleanup() # Attempt to clean up memory.
      print "Fatal error. Calling MPI_Abort() to abort PyLith application."
      # Print stacktrace
      from traceback import print_exc
      print_exc()
      from pylith.mpi import mpi
      errorCode = -1
      mpi.mpi_abort(mpi.petsc_comm_world(), errorCode)
示例#6
0
def petsc_comm_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
示例#7
0
    def test_allreduce_scalar_double(self):
        """
    Test allreduce_double().
    """
        value = 2.0
        result = mpi.allreduce_scalar_double(value, mpi.mpi_sum(),
                                             mpi.petsc_comm_world())
        self.assertEqual(value, result)

        result = mpi.allreduce_scalar_double(value, mpi.mpi_min(),
                                             mpi.petsc_comm_self())
        self.assertEqual(value, result)

        result = mpi.allreduce_scalar_double(value, mpi.mpi_max(),
                                             mpi.petsc_comm_world())
        self.assertEqual(value, result)
        return
示例#8
0
  def onComputeNodes(self, *args, **kwds):
    """
    Run the application in parallel on the compute nodes.
    """
    self.petsc.initialize()

    try:

      self.main(*args, **kwds)

    except Exception, err:
      self.cleanup() # Attempt to clean up memory.
      print "Fatal error. Calling MPI_Abort() to abort PyLith application."
      # Print stacktrace
      from traceback import print_exc
      print_exc()
      from pylith.mpi import mpi
      errorCode = -1
      mpi.mpi_abort(mpi.petsc_comm_world(), errorCode)