[mathicgb] 246/393: Added reset functionality to the logging system. All logs are now reset for each Groebner computation done through the library interface. Also, moved the new top/bottom F4 reducer log timing commands to be right next to the combined timer for that - without this, the time would be significantly different between the 2 kinds of logs because an expensive IO happened after starting one and before starting the other.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:12 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.
commit 204be2bdf7b3f30971287a7ee4cd089d8747c4c6
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Sun Apr 14 12:53:13 2013 -0400
Added reset functionality to the logging system. All logs are now reset for each Groebner computation done through the library interface. Also, moved the new top/bottom F4 reducer log timing commands to be right next to the combined timer for that - without this, the time would be significantly different between the 2 kinds of logs because an expensive IO happened after starting one and before starting the other.
---
src/mathicgb.cpp | 1 +
src/mathicgb/F4MatrixReducer.cpp | 7 +++----
src/mathicgb/LogDomain.cpp | 16 +++++++++++++++-
src/mathicgb/LogDomain.hpp | 9 ++++++++-
src/mathicgb/LogDomainSet.cpp | 9 +++++++++
src/mathicgb/LogDomainSet.hpp | 5 +++++
6 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/mathicgb.cpp b/src/mathicgb.cpp
index 1ab9ec2..c09c011 100755
--- a/src/mathicgb.cpp
+++ b/src/mathicgb.cpp
@@ -661,6 +661,7 @@ namespace mgbi {
mgb::tbb::task_scheduler_init scheduler(tbbMaxThreadCount);
// Set up logging
+ LogDomainSet::singleton().reset();
LogDomainSet::singleton().performLogCommands(conf.logging());
// Make reducer
diff --git a/src/mathicgb/F4MatrixReducer.cpp b/src/mathicgb/F4MatrixReducer.cpp
index cc59311..99b71d8 100755
--- a/src/mathicgb/F4MatrixReducer.cpp
+++ b/src/mathicgb/F4MatrixReducer.cpp
@@ -764,25 +764,24 @@ SparseMatrix reduceToEchelonFormShrawanDelayedModulus(
SparseMatrix F4MatrixReducer::reduceToBottomRight(const QuadMatrix& matrix) {
MATHICGB_ASSERT(matrix.debugAssertValid());
+ MATHICGB_LOG_TIME(F4MatReduceTop);
MATHICGB_LOG_TIME(F4MatrixReduce) <<
"\n***** Reducing QuadMatrix to bottom right matrix *****\n";
MATHICGB_IF_STREAM_LOG(F4MatrixReduce)
{matrix.printStatistics(log.stream());};
- MATHICGB_LOG_TIME(F4MatReduceTop);
return reduce(matrix, mModulus);
}
SparseMatrix F4MatrixReducer::reducedRowEchelonForm(
const SparseMatrix& matrix
) {
+ MATHICGB_LOG_TIME(F4RedBottomRight);
MATHICGB_LOG_TIME(F4MatrixReduce) <<
"\n***** Reducing SparseMatrix to reduced row echelon form *****\n";
MATHICGB_IF_STREAM_LOG(F4MatrixReduce)
{matrix.printStatistics(log.stream());};
- MATHICGB_LOG_TIME(F4RedBottomRight);
-
const bool useShrawan = false;
const bool useDelayedModulus = false;
if (useShrawan) {
@@ -794,7 +793,7 @@ SparseMatrix F4MatrixReducer::reducedRowEchelonForm(
// todo: actually do some work to determine a good way to determine
// when to use the sparse method, or alternatively make some some
// sort of hybrid.
- if ( matrix.computeDensity() < 0.02)
+ if (matrix.computeDensity() < 0.02)
return reduceToEchelonFormSparse(matrix, mModulus);
else
return reduceToEchelonForm(matrix, mModulus);
diff --git a/src/mathicgb/LogDomain.cpp b/src/mathicgb/LogDomain.cpp
index c3f0eaf..74e9012 100755
--- a/src/mathicgb/LogDomain.cpp
+++ b/src/mathicgb/LogDomain.cpp
@@ -14,14 +14,28 @@ LogDomain<true>::LogDomain(
const bool streamEnabled
):
mEnabled(enabled),
+ mOriginallyEnabled(enabled),
mStreamEnabled(streamEnabled),
+ mOriginallyStreamEnabled(streamEnabled),
mName(name),
mDescription(description),
- mInterval()
+ mInterval(),
+ mHasTime(false),
+ mCount(0),
+ mHasCount(false)
{
LogDomainSet::singleton().registerLogDomain(*this);
}
+void LogDomain<true>::reset() {
+ mEnabled = mOriginallyEnabled;
+ mStreamEnabled = mOriginallyStreamEnabled;
+ mInterval = TimeInterval();
+ mHasTime = false;
+ mCount = 0;
+ mHasCount = false;
+}
+
std::ostream& LogDomain<true>::stream() {
return std::cerr;
}
diff --git a/src/mathicgb/LogDomain.hpp b/src/mathicgb/LogDomain.hpp
index 7894db2..2146aed 100755
--- a/src/mathicgb/LogDomain.hpp
+++ b/src/mathicgb/LogDomain.hpp
@@ -76,6 +76,10 @@ public:
/// Returns true if setCount has been called.
bool hasCount() const {return mHasCount;}
+ /// Resets this object to the state it had when it was
+ /// constructed.
+ void reset();
+
private:
struct TimeInterval {
// todo: support user time too. clock() doesn't seem to sum the time
@@ -87,7 +91,9 @@ private:
void recordTime(TimeInterval interval);
bool mEnabled;
+ const bool mOriginallyEnabled;
bool mStreamEnabled;
+ const bool mOriginallyStreamEnabled;
const char* mName;
const char* mDescription;
@@ -95,7 +101,7 @@ private:
bool mHasTime; /// Whether any time has been registered (even if 0s).
Counter mCount;
- bool mHasCount; /// Whether the count has been set
+ bool mHasCount; /// Whether the count has been set (even if set to zero)
};
class LogDomain<true>::Timer {
@@ -163,6 +169,7 @@ public:
Counter count() const {return 0;}
void setCount(const Counter counter) {MATHICGB_ASSERT(false);}
bool hasCount() const {return false;}
+ void reset() {}
};
namespace LogDomainInternal {
diff --git a/src/mathicgb/LogDomainSet.cpp b/src/mathicgb/LogDomainSet.cpp
old mode 100644
new mode 100755
index 721f97e..7ced995
--- a/src/mathicgb/LogDomainSet.cpp
+++ b/src/mathicgb/LogDomainSet.cpp
@@ -195,6 +195,15 @@ void LogDomainSet::printTimeReport(std::ostream& out) const {
out.flags(oldFlags);
}
+void LogDomainSet::reset() {
+ mStartTime = mgb::tbb::tick_count::now();
+ const auto end = logDomains().cend();
+ for (auto it = logDomains().cbegin(); it != end; ++it) {
+ MATHICGB_ASSERT(*it != 0);
+ (*it)->reset();
+ }
+}
+
LogDomainSet& LogDomainSet::singleton() {
static LogDomainSet set;
return set;
diff --git a/src/mathicgb/LogDomainSet.hpp b/src/mathicgb/LogDomainSet.hpp
index efa84a7..f73481b 100755
--- a/src/mathicgb/LogDomainSet.hpp
+++ b/src/mathicgb/LogDomainSet.hpp
@@ -62,6 +62,11 @@ public:
void printTimeReport(std::ostream& out) const;
void printCountReport(std::ostream& out) const;
+ /// Resets the logging system as though the program had just started up.
+ /// This resets all counts, all recorded time and the enabledness of all logs.
+ /// You should not have a timer running for a log when you call this method.
+ void reset();
+
static LogDomainSet& singleton();
private:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git
More information about the debian-science-commits
mailing list