[cig-commits] r13312 - in short/3D/PyLith/trunk: doc playpen/memcheck
brad at geodynamics.org
brad at geodynamics.org
Fri Nov 14 13:54:04 PST 2008
Author: brad
Date: 2008-11-14 13:54:02 -0800 (Fri, 14 Nov 2008)
New Revision: 13312
Added:
short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_hex8_0500m.cfg
short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_hex8_1000m.cfg
short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_tet4_1000m.cfg
short/3D/PyLith/trunk/playpen/memcheck/memoryUsage.tex
short/3D/PyLith/trunk/playpen/memcheck/memory_usage.py
Removed:
short/3D/PyLith/trunk/doc/memoryUsage.tex
Log:
Added Python script to calculate memory usage by mesh.
Deleted: short/3D/PyLith/trunk/doc/memoryUsage.tex
===================================================================
--- short/3D/PyLith/trunk/doc/memoryUsage.tex 2008-11-14 21:53:13 UTC (rev 13311)
+++ short/3D/PyLith/trunk/doc/memoryUsage.tex 2008-11-14 21:54:02 UTC (rev 13312)
@@ -1,44 +0,0 @@
-\section{Mesh Memory}
-
- The \code{ISieve} maintains arrays for both cones and supports, and also for cone orientations.
-$$
- 2 (K C + V+C) + K C
-$$
-where $K$ is the number of vertices per cell, $C$ is the number of cells, and $V$ is the number of vertices. We also
-store coordinates, which takes
-$$
- D V
-$$
-
- Stratification uses a \code{Sieve} as a label to associate depths and heights with sieve points. There is an arrow
-for each mesh point for both height and depth. Thus we get
-$$
- 2 A (V + C)
-$$
-where $A$ is the size of an arrow in bytes. Materials are also stored this way, but in PyLith are mapped only to cells.
-
- For an IGeneralSection, the data take up only the minimum size. The atlas is an IUniformSection so that the data
-take up $2 max(V, C)$ integers, and its atlas is an IConstantSection. Thus, for a group we expect
-$$
- 2 max(V, C) + max(V, C)
-$$
-
-\subsection{Savings}
-
-\begin{itemize}
- \item We could eliminate the redundant classification of height since we can always use depth in its place.
-
- \item Groups could be IUniformSections since they have only 1 value per point.
-\end{itemize}
-
-\subsection{Strike-slip Benchmark}
- For the 1000m benchmark, we have
-\begin{itemize}
- \item $D = 3$
- \item $K = 4$
- \item $C = 13824$
- \item $V = 15625$
- \item $A = 40$
- \item $G = 6$
-\end{itemize}
-so we get 1,274,144 bytes for the mesh, 2,355,920 for stratification, 552,960 for materials, and 1,500,000 for groups.
\ No newline at end of file
Added: short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_hex8_0500m.cfg
===================================================================
--- short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_hex8_0500m.cfg (rev 0)
+++ short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_hex8_0500m.cfg 2008-11-14 21:54:02 UTC (rev 13312)
@@ -0,0 +1,33 @@
+[memoryusage]
+
+vertex_groups = [10,11,12,13,14,15]
+
+[memoryusage.mesh]
+
+cell_type = hex8
+ncells = 110592
+nvertices = 117649
+
+[memoryusage.vertex_groups.10]
+label = 10
+size = 1089
+
+[memoryusage.vertex_groups.11]
+label = 11
+size = 2401
+
+[memoryusage.vertex_groups.12]
+label = 12
+size = 2401
+
+[memoryusage.vertex_groups.13]
+label = 13
+size = 2303
+
+[memoryusage.vertex_groups.14]
+label = 14
+size = 2208
+
+[memoryusage.vertex_groups.15]
+label = 15
+size = 2224
Added: short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_hex8_1000m.cfg
===================================================================
--- short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_hex8_1000m.cfg (rev 0)
+++ short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_hex8_1000m.cfg 2008-11-14 21:54:02 UTC (rev 13312)
@@ -0,0 +1,33 @@
+[memoryusage]
+
+vertex_groups = [10,11,12,13,14,15]
+
+[memoryusage.mesh]
+
+cell_type = hex8
+ncells = 13824
+nvertices = 15625
+
+[memoryusage.vertex_groups.10]
+label = 10
+size = 289
+
+[memoryusage.vertex_groups.11]
+label = 11
+size = 625
+
+[memoryusage.vertex_groups.12]
+label = 12
+size = 625
+
+[memoryusage.vertex_groups.13]
+label = 13
+size = 575
+
+[memoryusage.vertex_groups.14]
+label = 14
+size = 528
+
+[memoryusage.vertex_groups.15]
+label = 15
+size = 536
Added: short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_tet4_1000m.cfg
===================================================================
--- short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_tet4_1000m.cfg (rev 0)
+++ short/3D/PyLith/trunk/playpen/memcheck/benchmark_strikeslip_tet4_1000m.cfg 2008-11-14 21:54:02 UTC (rev 13312)
@@ -0,0 +1,33 @@
+[memoryusage]
+
+vertex_groups = [fault,bc_xneg,bc_xpos,bc_yneg,bc_ypos,bc_zneg]
+
+[memoryusage.mesh]
+
+cell_type = tet4
+ncells = 79756
+nvertices = 15625
+
+[memoryusage.vertex_groups.fault]
+label = fault
+size = 289
+
+[memoryusage.vertex_groups.bc_xneg]
+label = boundary_xneg
+size = 625
+
+[memoryusage.vertex_groups.bc_xpos]
+label = boundary_xpos
+size = 625
+
+[memoryusage.vertex_groups.bc_yneg]
+label = boundary_yneg
+size = 536
+
+[memoryusage.vertex_groups.bc_ypos]
+label = boundary_ypos
+size = 575
+
+[memoryusage.vertex_groups.bc_zneg]
+label = boundary_zneg
+size = 528
Copied: short/3D/PyLith/trunk/playpen/memcheck/memoryUsage.tex (from rev 13310, short/3D/PyLith/trunk/doc/memoryUsage.tex)
===================================================================
--- short/3D/PyLith/trunk/playpen/memcheck/memoryUsage.tex (rev 0)
+++ short/3D/PyLith/trunk/playpen/memcheck/memoryUsage.tex 2008-11-14 21:54:02 UTC (rev 13312)
@@ -0,0 +1,44 @@
+\section{Mesh Memory}
+
+ The \code{ISieve} maintains arrays for both cones and supports, and also for cone orientations.
+$$
+ 2 (K C + V+C) + K C
+$$
+where $K$ is the number of vertices per cell, $C$ is the number of cells, and $V$ is the number of vertices. We also
+store coordinates, which takes
+$$
+ D V
+$$
+
+ Stratification uses a \code{Sieve} as a label to associate depths and heights with sieve points. There is an arrow
+for each mesh point for both height and depth. Thus we get
+$$
+ 2 A (V + C)
+$$
+where $A$ is the size of an arrow in bytes. Materials are also stored this way, but in PyLith are mapped only to cells.
+
+ For an IGeneralSection, the data take up only the minimum size. The atlas is an IUniformSection so that the data
+take up $2 max(V, C)$ integers, and its atlas is an IConstantSection. Thus, for a group we expect
+$$
+ 2 max(V, C) + max(V, C)
+$$
+
+\subsection{Savings}
+
+\begin{itemize}
+ \item We could eliminate the redundant classification of height since we can always use depth in its place.
+
+ \item Groups could be IUniformSections since they have only 1 value per point.
+\end{itemize}
+
+\subsection{Strike-slip Benchmark}
+ For the 1000m benchmark, we have
+\begin{itemize}
+ \item $D = 3$
+ \item $K = 4$
+ \item $C = 13824$
+ \item $V = 15625$
+ \item $A = 40$
+ \item $G = 6$
+\end{itemize}
+so we get 1,274,144 bytes for the mesh, 2,355,920 for stratification, 552,960 for materials, and 1,500,000 for groups.
\ No newline at end of file
Added: short/3D/PyLith/trunk/playpen/memcheck/memory_usage.py
===================================================================
--- short/3D/PyLith/trunk/playpen/memcheck/memory_usage.py (rev 0)
+++ short/3D/PyLith/trunk/playpen/memcheck/memory_usage.py 2008-11-14 21:54:02 UTC (rev 13312)
@@ -0,0 +1,435 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+from pyre.components.Component import Component
+from pyre.applications.Script import Script as Application
+
+sizeInt = 4
+sizeDouble = 8
+sizeArrow = 40
+
+# ITEM FACTORIES ///////////////////////////////////////////////////////
+
+def materialFactory(name):
+ """
+ Factory for material items.
+ """
+ from pyre.inventory import facility
+ return facility(name, factory=Material)
+
+
+def vertexGroupFactory(name):
+ """
+ Factory for vertex group items.
+ """
+ from pyre.inventory import facility
+ return facility(name, factory=VertexGroup)
+
+
+# ----------------------------------------------------------------------
+# Mesh class
+class Mesh(Component):
+ """
+ Mesh object for holding mesh size information.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """
+ Python object for managing Mesh facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing Mesh facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b cell_type Type of cell
+ ## @li \b ncells Number of cells
+ ## @li \b nvertices Number of vertices
+ ## @li \b ngroups Number of vertex groups
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+ cellType = pyre.inventory.str('cell_type', default="hex8",
+ validator=pyre.inventory.choice(['tri3', 'quad4', 'tet4', 'hex8']))
+ cellType.meta['tip'] = "Type of cell in mesh."
+
+ ncells = pyre.inventory.int('ncells', default=0)
+ ncells.meta['tip'] = "Number of cells in finite-element mesh."
+
+ nvertices = pyre.inventory.int('nvertices', default=0)
+ nvertices.meta['tip'] = "Number of vertices in finite-element mesh."
+
+ ngroups = pyre.inventory.int('ngroups', default=0)
+ ngroups.meta['tip'] = "Number of vertex groups in finite-element mesh."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="mesh"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name)
+ self.cellType = None
+ self.nvertices = 0
+ self.ncells = 0
+ self.coneSize = 0
+ return
+
+
+ def initialize(self):
+ """
+ Initialize application.
+ """
+ info = {'tri3': 3,
+ 'quad4': 4,
+ 'tet4': 4,
+ 'hex8': 8,
+ }
+
+ try:
+ self.coneSize = info[self.cellType]
+ except:
+ raise ValueError("Unknown cell type '%'." % self.cellType)
+ return
+
+
+ def tabulate(self):
+ """
+ Tabulate memory use.
+ """
+ memory = {'mesh': 0,
+ 'stratification': 0,
+ 'materials': 0}
+ ncells = self.ncells
+ nvertices = self.nvertices
+ coneSize = self.coneSize
+
+ # mesh
+ nbytes = sizeInt * ( 2 * (coneSize*ncells + nvertices + ncells) + \
+ coneSize*ncells )
+ memory['mesh'] = nbytes
+
+ # stratification
+ nbytes = 2 * sizeArrow * (nvertices + ncells)
+ memory['stratification'] = nbytes
+
+ # materials
+ nbytes = 2 * sizeArrow * ncells
+ memory['materials'] = nbytes
+ return memory
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Component._configure(self)
+ self.cellType = self.inventory.cellType
+ self.nvertices = self.inventory.nvertices
+ self.ncells = self.inventory.ncells
+
+ return
+
+
+# ----------------------------------------------------------------------
+# VertexGroup class
+class VertexGroup(Component):
+ """
+ Mesh object for holding vertex group size information.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """
+ Python object for managing VertexGroup facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing VertexGroup facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b label Name of group.
+ ## @li \b size Number of vertices in group.
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+ label = pyre.inventory.str('label', default="Vertex Group")
+ label.meta['tip'] = "Label for vertex group."
+
+ size = pyre.inventory.int('size', default=0)
+ size.meta['tip'] = "Number of vertices in group."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="vertexgroup"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name)
+ self.size = 0
+ return
+
+
+ def tabulate(self, mesh):
+ """
+ Tabulate memory use.
+ """
+ nvertices = mesh.nvertices
+ nbytes = sizeInt * ( 2 * nvertices + nvertices)
+ return nbytes
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Component._configure(self)
+ self.label = self.inventory.label
+ self.size = self.inventory.size
+ return
+
+
+# ----------------------------------------------------------------------
+# Material class
+class Material(Component):
+ """
+ Mesh object for holding material size information.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """
+ Python object for managing Material facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing Mesh facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b label Name of material.
+ ## @li \b size Number of cells in material.
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+ label = pyre.inventory.str('label', default="Material")
+ label.meta['tip'] = "Label for material."
+
+ size = pyre.inventory.int('size', default=0)
+ size.meta['tip'] = "Number of cells in material."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="material"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name)
+ self.size = 0
+ return
+
+
+ def tabulate(self, mesh):
+ """
+ Tabulate memory use.
+ """
+ nbytes = 2 * sizeArrow * self.size
+ return nbytes
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Component._configure(self)
+ self.label = self.inventory.label
+ self.size = self.inventory.size
+ return
+
+
+# ----------------------------------------------------------------------
+# MemoryUsageApp class
+class MemoryUsageApp(Application):
+ """
+ Python MemoryUsage application.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Application.Inventory):
+ """
+ Python object for managing MemoryUsageApp facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing MemoryUsageApp facilities and properties.
+ ##
+ ## \b Properties
+ ## @li None
+ ##
+ ## \b Facilities
+ ## @li mesh Finite-element mesh information.
+ ## @li groups Vertex groups information.
+ ## @li materials Materials information.
+
+ import pyre.inventory
+ from pylith.utils.EmptyBin import EmptyBin
+
+ mesh = pyre.inventory.facility("mesh", factory=Mesh)
+ mesh.meta['tip'] = "Finite-element mesh information."
+
+ groups = pyre.inventory.facilityArray("vertex_groups",
+ itemFactory=vertexGroupFactory,
+ factory=EmptyBin)
+ groups.meta['tip'] = "Vertex groups information."
+
+ materials = pyre.inventory.facilityArray("materials",
+ itemFactory=materialFactory,
+ factory=EmptyBin)
+ materials.meta['tip'] = "Materials information."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="memoryusage"):
+ """
+ Constructor.
+ """
+ Application.__init__(self, name)
+ self.memory = {'mesh': 0,
+ 'stratification': 0,
+ 'groups': 0}
+ self.mesh = None
+ self.groups = None
+ self.materials = None
+ return
+
+
+ def main(self, *args, **kwds):
+ """
+ Run the application.
+ """
+ self.mesh.initialize()
+ self._tabulate()
+ self.show()
+ return
+
+
+ def show(self):
+ """
+ Print memory usage.
+ """
+ megabyte = float(2**20)
+
+ print "MEMORY USAGE"
+ print " Finite-element mesh"
+ memory = self.memory['mesh']
+ print " Mesh: %d bytes (%.3f MB)" % \
+ (memory['mesh'],
+ memory['mesh'] / megabyte)
+ print " Stratification: %d bytes (%.3f MB)" % \
+ (memory['stratification'],
+ memory['stratification'] / megabyte)
+ print " Materials: %d bytes (%.3f MB)" % \
+ (memory['materials'],
+ memory['materials'] / megabyte)
+
+ print " Groups"
+ for (label, nbytes) in self.memory['groups'].items():
+ print " %s: %d bytes (%.3f MB)" % \
+ (label, nbytes, nbytes / megabyte)
+
+ print " Materials"
+ for (label, nbytes) in self.memory['materials'].items():
+ print " %s: %d bytes (%.3f MB)" % \
+ (label, nbytes, nbytes / megabyte)
+ print " TOTAL: %d bytes (%.3f MB)" % \
+ (self.memory['total'], self.memory['total'] / megabyte)
+
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Application._configure(self)
+ self.mesh = self.inventory.mesh
+ self.groups = self.inventory.groups
+ self.materials = self.inventory.materials
+ return
+
+
+ def _tabulate(self):
+ """
+ Tabulate expected memory usage.
+ """
+ total = 0
+ memory = {}
+
+ # mesh
+ info = self.mesh.tabulate()
+ memory['mesh'] = info
+ total += sum(info.values())
+
+ # groups
+ memory['groups'] = {}
+ for group in self.groups.components():
+ nbytes = group.tabulate(self.mesh)
+ total += nbytes
+ memory['groups'][group.label] = nbytes
+
+ # materials
+ memory['materials'] = {}
+ for material in self.materials.components():
+ nbytes = material.tabulate(self.mesh)
+ total += nbytes
+ memory['materials'][material.label] = nbytes
+
+ memory['total'] = total
+ self.memory = memory
+ return
+
+
+# ======================================================================
+__requires__ = ""
+
+if __name__ == "__main__":
+
+ app = MemoryUsageApp()
+ app.run()
+
+
+# End of file
Property changes on: short/3D/PyLith/trunk/playpen/memcheck/memory_usage.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the CIG-COMMITS
mailing list