[cig-commits] r15178 - in short/3D/PyLith/trunk: libsrc/feassemble libsrc/problems libsrc/topology pylith pylith/perf pylith/problems

knepley at geodynamics.org knepley at geodynamics.org
Wed Jun 10 13:40:01 PDT 2009


Author: knepley
Date: 2009-06-10 13:40:00 -0700 (Wed, 10 Jun 2009)
New Revision: 15178

Modified:
   short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc
   short/3D/PyLith/trunk/libsrc/problems/Formulation.cc
   short/3D/PyLith/trunk/libsrc/problems/Formulation.hh
   short/3D/PyLith/trunk/libsrc/problems/SolverLinear.cc
   short/3D/PyLith/trunk/libsrc/topology/Field.cc
   short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc
   short/3D/PyLith/trunk/pylith/Makefile.am
   short/3D/PyLith/trunk/pylith/perf/Memory.py
   short/3D/PyLith/trunk/pylith/perf/MemoryLogger.py
   short/3D/PyLith/trunk/pylith/perf/__init__.py
   short/3D/PyLith/trunk/pylith/problems/Formulation.py
   short/3D/PyLith/trunk/pylith/problems/Implicit.py
Log:
More logging progress


Modified: short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc	2009-06-10 20:40:00 UTC (rev 15178)
@@ -398,7 +398,7 @@
   
   if (!_outputFields->hasField("buffer (tensor)")) {
     ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
-    logger.stagePush("Problem");
+    logger.stagePush("Output");
     _outputFields->add("buffer (tensor)", "buffer");
     topology::Field<topology::Mesh>& buffer =
       _outputFields->get("buffer (tensor)");

Modified: short/3D/PyLith/trunk/libsrc/problems/Formulation.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/problems/Formulation.cc	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/libsrc/problems/Formulation.cc	2009-06-10 20:40:00 UTC (rev 15178)
@@ -43,6 +43,14 @@
 } // destructor
 
 // ----------------------------------------------------------------------
+// Return the fields
+const pylith::topology::SolutionFields&
+pylith::problems::Formulation::fields(void) const
+{ // fields
+  return *this->_fields;
+} // fields
+
+// ----------------------------------------------------------------------
 // Set integrators over the mesh.
 void
 pylith::problems::Formulation::meshIntegrators(IntegratorMesh** integrators,

Modified: short/3D/PyLith/trunk/libsrc/problems/Formulation.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/problems/Formulation.hh	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/libsrc/problems/Formulation.hh	2009-06-10 20:40:00 UTC (rev 15178)
@@ -94,6 +94,8 @@
    */
   void reformJacobian(const PetscVec* tmpSolveSolnVec =0);
 
+  const topology::SolutionFields& fields() const;
+
 // PRIVATE MEMBERS //////////////////////////////////////////////////////
 private :
 

Modified: short/3D/PyLith/trunk/libsrc/problems/SolverLinear.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/problems/SolverLinear.cc	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/libsrc/problems/SolverLinear.cc	2009-06-10 20:40:00 UTC (rev 15178)
@@ -16,6 +16,7 @@
 
 #include "pylith/topology/SolutionFields.hh" // USES SolutionFields
 #include "pylith/topology/Jacobian.hh" // USES Jacobian
+#include "pylith/problems/Formulation.hh" // USES Formulation
 
 #include <petscksp.h> // USES PetscKSP
 
@@ -77,13 +78,13 @@
 
   // Check for fibration
   if (residual.section()->getNumSpaces() > 0) {
+    const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = fields.mesh().sieveMesh();
     PC pc;
 
     err = KSPGetPC(_ksp, &pc); CHECK_PETSC_ERROR(err);
     err = PCSetType(pc, PCFIELDSPLIT); CHECK_PETSC_ERROR(err);
-
 #if defined(FIELD_SPLIT)
-    constructFieldSplit(residual.section(), pc);
+    constructFieldSplit(residual.section(), sieveMesh->getFactory()->getGlobalOrder(sieveMesh, "default", residual.section()), residual.vector(), pc);
 #endif
   }
 } // initialize

Modified: short/3D/PyLith/trunk/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.cc	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.cc	2009-06-10 20:40:00 UTC (rev 15178)
@@ -579,6 +579,8 @@
     err = VecDestroy(_vector); _vector = 0;
     CHECK_PETSC_ERROR(err);
   } // if
+  ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+  logger.stagePush("GlobalOrder");
 
   const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
   assert(!sieveMesh.isNull());
@@ -594,6 +596,7 @@
   CHECK_PETSC_ERROR(err);
 
   err = VecSetFromOptions(_vector); CHECK_PETSC_ERROR(err);  
+  logger.stagePop();
 } // createVector
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc	2009-06-10 20:40:00 UTC (rev 15178)
@@ -30,6 +30,8 @@
 { // constructor
   const ALE::Obj<Mesh::SieveMesh>& sieveMesh = fields.mesh().sieveMesh();
   const ALE::Obj<Mesh::RealSection>& solnSection = fields.solution().section();
+  ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+  logger.stagePush("Jacobian");
 
   // Set blockFlag to -1 if okay to set block size equal to fiber
   // dimension, otherwise use a block size of 1.
@@ -39,6 +41,7 @@
 					matrixType, &_matrix, blockFlag);
   CHECK_PETSC_ERROR_MSG(err, "Could not create PETSc sparse matrix "
 			"associated with system Jacobian.");
+  logger.stagePop();
 } // constructor
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/pylith/Makefile.am	2009-06-10 20:40:00 UTC (rev 15178)
@@ -93,6 +93,8 @@
 	perf/Material.py \
 	perf/VertexGroup.py \
 	perf/Field.py \
+	perf/GlobalOrder.py \
+	perf/Jacobian.py \
 	problems/__init__.py \
 	problems/Explicit.py \
 	problems/Formulation.py \

Modified: short/3D/PyLith/trunk/pylith/perf/Memory.py
===================================================================
--- short/3D/PyLith/trunk/pylith/perf/Memory.py	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/pylith/perf/Memory.py	2009-06-10 20:40:00 UTC (rev 15178)
@@ -4,11 +4,17 @@
   import distutils.sysconfig
   pointerSize = distutils.sysconfig.get_config_var('SIZEOF_VOID_P')
   if pointerSize == 4:
-    sizeArrow = 40 # 32 bit
+    sizeSetEntry = 12
+    sizeMapEntry = 16
+    sizeArrow    = 40 # 32 bit
   elif pointerSize == 8:
-    sizeArrow = 56 # 64 bit
+    sizeSetEntry = 24
+    sizeMapEntry = 32
+    sizeArrow    = 56 # 64 bit
   elif pointerSize is None:
-    sizeArrow = 0 # Use 0 if can't get estimate of pointer size.
+    sizeSetEntry = 0
+    sizeMapEntry = 0
+    sizeArrow    = 0 # Use 0 if can't get estimate of pointer size.
   else:
     raise RuntimeError('Could not determine the size of a pointer')
 

Modified: short/3D/PyLith/trunk/pylith/perf/MemoryLogger.py
===================================================================
--- short/3D/PyLith/trunk/pylith/perf/MemoryLogger.py	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/pylith/perf/MemoryLogger.py	2009-06-10 20:40:00 UTC (rev 15178)
@@ -41,8 +41,8 @@
 
     import pyre.inventory
 
-    dummy = pyre.inventory.bool("dummy", default=True)
-    dummy.meta['tip'] = "Nothing."
+    includeDealloc = pyre.inventory.bool("include_dealloc", default=True)
+    includeDealloc.meta['tip'] = "Subtract deallocated memory when reporting."
 
   # PUBLIC METHODS /////////////////////////////////////////////////////
 
@@ -67,7 +67,6 @@
     meshModel.tabulate(self.memory[stage])
     for group, nvertices in mesh.groupSizes():
       self.logVertexGroup('VertexGroups', group, nvertices, mesh.numVertices())
-    if self.verbose: self.show()
     return
 
   def logVertexGroup(self, stage, label, nvertices, nMeshVertices):
@@ -79,7 +78,6 @@
     if not stage in self.memory: self.memory[stage] = {}
     groupModel = pylith.perf.VertexGroup.VertexGroup(label, nvertices, nMeshVertices)
     groupModel.tabulate(self.memory[stage])
-    if self.verbose: self.show()
     return
 
   def logMaterial(self, stage, material):
@@ -93,7 +91,6 @@
     materialModel.tabulate(self.memory[stage])
     self.logField(stage, material.propertiesField())
     self.logField(stage, material.stateVarsField())
-    if self.verbose: self.show()
     return
 
   def logQuadrature(self, stage, quadrature):
@@ -106,7 +103,6 @@
     ##self.logField('Field', quadrature.jacobianPrecomp())
     ##self.logField('Field', quadrature.jacobianDetPrecomp())
     ##self.logField('Field', quadrature.basisDerivPrecomp())
-    if self.verbose: self.show()
     return
 
   def logField(self, stage, field):
@@ -118,9 +114,30 @@
     if not stage in self.memory: self.memory[stage] = {}
     fieldModel = pylith.perf.Field.Field(field.label(), field.sectionSize(), field.chartSize())
     fieldModel.tabulate(self.memory[stage])
-    if self.verbose: self.show()
     return
 
+  def logGlobalOrder(self, stage, label, field):
+    """
+    Read parameters to determine memory from our model.
+    """
+    import pylith.perf.GlobalOrder
+
+    if not stage in self.memory: self.memory[stage] = {}
+    orderModel = pylith.perf.GlobalOrder.GlobalOrder(label, field.chartSize())
+    orderModel.tabulate(self.memory[stage])
+    return
+
+  def logJacobian(self, stage, label):
+    """
+    Read parameters to determine memory from our model.
+    """
+    import pylith.perf.Jacobian
+
+    if not stage in self.memory: self.memory[stage] = {}
+    jacModel = pylith.perf.Jacobian.Jacobian(label)
+    jacModel.tabulate(self.memory[stage])
+    return
+
   def mergeMemDict(self, memDictTarget, memDictSource):
     for key in memDictSource:
       if not key in memDictTarget:
@@ -149,7 +166,7 @@
   def memLine(self, source, name, mem, indent = 0):
     return '%s%-30s %8d bytes (%.3f MB)' % (self.prefix(indent), name+' ('+source+'):', mem, mem / self.megabyte)
 
-  def processMemDict(self, memDict, indent = 0, namePrefix = ''):
+  def processMemDict(self, memDict, indent = 0, namePrefix = '', includeDealloc = True):
     from pylith.utils.petsc import MemoryLogger
     logger    =  MemoryLogger.singleton()
     output    = []
@@ -160,21 +177,27 @@
       fullname = namePrefix+name
       if isinstance(m, dict):
         output.append(self.prefix(indent)+name)
-        out,mem,codeMem = self.processMemDict(m, indent, fullname)
+        out,mem,codeMem = self.processMemDict(m, indent, fullname, includeDealloc)
         output.extend(out)
         total     += mem
         codeTotal += codeMem
       else:
-        mem = logger.getAllocationTotal(fullname) - logger.getDeallocationTotal(fullname)
+        mem = logger.getAllocationTotal(fullname)
+        if includeDealloc:
+          mem     -= logger.getDeallocationTotal(fullname)
         total     += m
         codeTotal += mem
         output.append(self.memLine('Model', name, m, indent))
         if logger.getAllocationTotal(fullname):
           output.append(self.memLine('Code',  name, mem, indent))
     if namePrefix:
-      mem = logger.getAllocationTotal(namePrefix) - logger.getDeallocationTotal(namePrefix)
+      mem = logger.getAllocationTotal(namePrefix)
+      if includeDealloc:
+        mem -= logger.getDeallocationTotal(namePrefix)
     else:
-      mem = logger.getAllocationTotal() - logger.getDeallocationTotal()
+      mem = logger.getAllocationTotal()
+      if includeDealloc:
+        mem -= logger.getDeallocationTotal()
     if mem == 0:
       mem = codeTotal
     output.append(self.memLine('Model', 'Total', total, indent))
@@ -190,7 +213,13 @@
     Print memory usage.
     """
     output = ["MEMORY USAGE"]
-    output.extend(self.processMemDict(self.memory)[0])
+    output.extend(self.processMemDict(self.memory, includeDealloc = self.includeDealloc)[0])
+
+    from pylith.utils.petsc import MemoryLogger
+    logger    =  MemoryLogger.singleton()
+    output.append(self.memLine('Code',  'Total Alloced', logger.getAllocationTotal('default'), 1))
+    output.append(self.memLine('Code',  'Total Dealloced', logger.getDeallocationTotal('default'), 1))
+
     print '\n'.join(output)
     return
 
@@ -201,7 +230,7 @@
     Set members based using inventory.
     """
     Logger._configure(self)
-    self.dummy = self.inventory.dummy
+    self.includeDealloc = self.inventory.includeDealloc
     return
 
 

Modified: short/3D/PyLith/trunk/pylith/perf/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/perf/__init__.py	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/pylith/perf/__init__.py	2009-06-10 20:40:00 UTC (rev 15178)
@@ -1 +1 @@
-__all__ = ['Memory', 'Logger', 'MemoryLogger', 'Mesh', 'Material']
+__all__ = ['Memory', 'Logger', 'MemoryLogger', 'Mesh', 'Material', 'Field', 'GlobalOrder']

Modified: short/3D/PyLith/trunk/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Formulation.py	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/pylith/problems/Formulation.py	2009-06-10 20:40:00 UTC (rev 15178)
@@ -218,7 +218,7 @@
     self._info.log("Creating solution field.")
     from pylith.utils.petsc import MemoryLogger
     logger = MemoryLogger.singleton()
-    #logger.setDebug(1)
+    logger.setDebug(0)
     logger.stagePush("Problem")
     self.fields.add("dispIncr(t->t+dt)", "displacement_increment")
     self.fields.add("disp(t)", "displacement")
@@ -239,9 +239,13 @@
     solution.allocate()
     for constraint in self.constraints:
       constraint.setConstraints(solution)
+    logger.stagePop()
+
+    # This creates a global order
     solution.createVector()
     solution.createScatter()
 
+    logger.stagePush("Problem")
     dispT = self.fields.get("disp(t)")
     dispT.vectorFieldType(dispT.VECTOR)
     dispT.scale(lengthScale.value)
@@ -339,9 +343,15 @@
     for name in self.fields.fieldNames():
       field = self.fields.get(name)
       self.perfLogger.logField('Problem', field)
+    self.perfLogger.logGlobalOrder('GlobalOrder', 'VectorOrder', self.fields.get('residual'))
     for integrator in self.integratorsMesh + self.integratorsSubMesh:
       self.perfLogger.logQuadrature('Quadrature', integrator.quadrature())
 
+    # Placeholders until we know we they go
+    self.perfLogger.memory['Fault'] = 0
+    self.perfLogger.memory['BoundaryConditions'] = 0
+    self.perfLogger.memory['Output'] = 0
+
     self._info.log("Formulation finalize.")
     self._debug.log(resourceUsageString())
     for integrator in self.integratorsMesh + self.integratorsSubMesh:

Modified: short/3D/PyLith/trunk/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Implicit.py	2009-06-10 19:52:34 UTC (rev 15177)
+++ short/3D/PyLith/trunk/pylith/problems/Implicit.py	2009-06-10 20:40:00 UTC (rev 15178)
@@ -93,7 +93,7 @@
     self._info.log("Creating solution field.")
     from pylith.utils.petsc import MemoryLogger
     logger = MemoryLogger.singleton()
-    #logger.setDebug(1)
+    logger.setDebug(0)
     logger.stagePush("Problem")
     self.fields.copyLayout("dispIncr(t->t+dt)")
 
@@ -104,13 +104,16 @@
     residual.zero()
     residual.createVector()
     self._debug.log(resourceUsageString())
+    logger.stagePop()
 
+    # Allocates memory for nonzero pattern and Jacobian
     self._info.log("Creating Jacobian matrix.")
     from pylith.topology.Jacobian import Jacobian
     self.jacobian = Jacobian(self.fields, self.matrixType)
     self.jacobian.zero() # TEMPORARY, to get correct memory usage
     self._debug.log(resourceUsageString())
 
+    logger.stagePush("Problem")
     self._info.log("Initializing solver.")
     self.solver.initialize(self.fields, self.jacobian, self)
     self._debug.log(resourceUsageString())
@@ -206,6 +209,15 @@
     return
 
 
+  def finalize(self):
+    """
+    Cleanup after time stepping.
+    """
+    Formulation.finalize(self)
+    self.perfLogger.logJacobian('Jacobian', 'dummy')
+    return
+
+
   # PRIVATE METHODS ////////////////////////////////////////////////////
 
   def _configure(self):



More information about the CIG-COMMITS mailing list