[cig-commits] r13144 - in short/3D/PyLith/trunk: libsrc/utils modulesrc/utils pylith/utils
brad at geodynamics.org
brad at geodynamics.org
Tue Oct 28 21:05:05 PDT 2008
Author: brad
Date: 2008-10-28 21:05:05 -0700 (Tue, 28 Oct 2008)
New Revision: 13144
Modified:
short/3D/PyLith/trunk/libsrc/utils/EventLogger.cc
short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh
short/3D/PyLith/trunk/libsrc/utils/EventLogger.icc
short/3D/PyLith/trunk/modulesrc/utils/utils.pyxe.src
short/3D/PyLith/trunk/pylith/utils/EventLogger.py
Log:
Added stage methods to EventLogger.
Modified: short/3D/PyLith/trunk/libsrc/utils/EventLogger.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/EventLogger.cc 2008-10-29 03:54:13 UTC (rev 13143)
+++ short/3D/PyLith/trunk/libsrc/utils/EventLogger.cc 2008-10-29 04:05:05 UTC (rev 13144)
@@ -84,5 +84,37 @@
return id->second;
} // eventId
+// ----------------------------------------------------------------------
+// Register stage.
+int
+pylith::utils::EventLogger::registerStage(const char* name)
+{ // registerStage
+ assert(0 != _classId);
+ int id = 0;
+ PetscErrorCode err = PetscLogStageRegister(name, &id);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not register logging stage '" << name << "'.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _stages[name] = id;
+ return id;
+} // registerStage
+// ----------------------------------------------------------------------
+// Get stage identifier.
+int
+pylith::utils::EventLogger::stageId(const char* name)
+{ // stageId
+ map_event_type::iterator id = _stages.find(name);
+ if (id == _stages.end()) {
+ std::ostringstream msg;
+ msg << "Could not find logging stage '" << name << "'.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ return id->second;
+} // stagesId
+
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh 2008-10-29 03:54:13 UTC (rev 13143)
+++ short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh 2008-10-29 04:05:05 UTC (rev 13144)
@@ -89,6 +89,31 @@
*/
void eventEnd(const int id);
+ /** Register stage.
+ *
+ * @prerequisite Must call initialize() before registerStage().
+ *
+ * @param name Name of stage.
+ * @returns Stage identifier.
+ */
+ int registerStage(const char* name);
+
+ /** Get stage identifier.
+ *
+ * @param name Name of stage.
+ * @returns Stage identifier.
+ */
+ int stageId(const char* name);
+
+ /** Log stage begin.
+ *
+ * @param id Stage identifier.
+ */
+ void stagePush(const int id);
+
+ /// Log stage end.
+ void stagePop(void);
+
// PRIVATE METHODS //////////////////////////////////////////////////////
private :
@@ -106,6 +131,7 @@
std::string _className; ///< Name of logging class
int _classId; ///< PETSc logging identifier for class
map_event_type _events; ///< PETSc logging identifiers for events
+ map_event_type _stages; ///< PETSc logging identifiers for stages
}; // EventLogger
Modified: short/3D/PyLith/trunk/libsrc/utils/EventLogger.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/EventLogger.icc 2008-10-29 03:54:13 UTC (rev 13143)
+++ short/3D/PyLith/trunk/libsrc/utils/EventLogger.icc 2008-10-29 04:05:05 UTC (rev 13144)
@@ -39,10 +39,23 @@
// Log event end.
inline
void
-pylith::utils::EventLogger::eventEnd(const int id)
-{ // eventEnd
+pylith::utils::EventLogger::eventEnd(const int id) {
PetscLogEventEnd(id, 0, 0, 0, 0);
} // eventEnd
+// Log stage begin.
+inline
+void
+pylith::utils::EventLogger::stagePush(const int id) {
+ PetscLogStagePush(id);
+} // stagePush
+
+// Log stage end.
+inline
+void
+pylith::utils::EventLogger::stagePop(void) {
+ PetscLogStagePop();
+} // stagePop
+
// End of file
Modified: short/3D/PyLith/trunk/modulesrc/utils/utils.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/utils.pyxe.src 2008-10-29 03:54:13 UTC (rev 13143)
+++ short/3D/PyLith/trunk/modulesrc/utils/utils.pyxe.src 2008-10-29 04:05:05 UTC (rev 13144)
@@ -190,6 +190,96 @@
return
+ def registerStage(self, name):
+ """
+ Register stage.
+ """
+ # create shim for method 'registerStage'
+ #embed{ int EventLogger_registerStage(void* objVptr, char* name)
+ int result = 0;
+ try {
+ assert(0 != objVptr);
+ result = ((pylith::utils::EventLogger*) objVptr)->registerStage(name);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ return result;
+ #}embed
+
+ return EventLogger_registerStage(self.thisptr, name)
+
+
+ def stageId(self, name):
+ """
+ Get stage identifier.
+ """
+ # create shim for method 'stageId'
+ #embed{ int EventLogger_stageId(void* objVptr, char* name)
+ int result = 0;
+ try {
+ assert(0 != objVptr);
+ result = ((pylith::utils::EventLogger*) objVptr)->stageId(name);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ return result;
+ #}embed
+
+ return EventLogger_stageId(self.thisptr, name)
+
+
+ def stagePush(self, id):
+ """
+ Log stage begin.
+ """
+ # create shim for method 'stagePush'
+ #embed{ void EventLogger_stagePush(void* objVptr, int id)
+ try {
+ assert(0 != objVptr);
+ ((pylith::utils::EventLogger*) objVptr)->stagePush(id);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ #}embed
+
+ EventLogger_stagePush(self.thisptr, id)
+ return
+
+
+ def stagePop(self):
+ """
+ Log stage end.
+ """
+ # create shim for method 'stagePop'
+ #embed{ void EventLogger_stagePop(void* objVptr)
+ try {
+ assert(0 != objVptr);
+ ((pylith::utils::EventLogger*) objVptr)->stagePop();
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ #}embed
+
+ EventLogger_stagePop(self.thisptr)
+ return
+
+
def _createHandle(self):
"""
Wrap pointer to C++ object in PyCObject.
Modified: short/3D/PyLith/trunk/pylith/utils/EventLogger.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/EventLogger.py 2008-10-29 03:54:13 UTC (rev 13143)
+++ short/3D/PyLith/trunk/pylith/utils/EventLogger.py 2008-10-29 04:05:05 UTC (rev 13144)
@@ -103,6 +103,40 @@
return
+ def registerStage(self, name):
+ """
+ Register stage.
+ """
+ assert(None != self.cppHandle)
+ return self.cppHandle.registerStage(name)
+
+
+ def stageId(self, name):
+ """
+ Get stage identifier.
+ """
+ assert(None != self.cppHandle)
+ return self.cppHandle.stageId(name)
+
+
+ def stagePush(self, name):
+ """
+ Log stage begin.
+ """
+ assert(None != self.cppHandle)
+ self.cppHandle.stagePush(self.cppHandle.eventId(name))
+ return
+
+
+ def stagePop(self):
+ """
+ Log stage end.
+ """
+ assert(None != self.cppHandle)
+ self.cppHandle.stagePop()
+ return
+
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _createCppHandle(self):
More information about the CIG-COMMITS
mailing list