Browse code

added crude time estimate

Tom Sherman authored on 22/05/2018 15:05:30
Showing16 changed files

... ...
@@ -172,7 +172,6 @@ void AtomicDomain::cacheErase(uint64_t pos) const
172 172
     mEraseCache[ndx] = pos;
173 173
 }
174 174
 
175
-// TODO prevent re-allocations
176 175
 void AtomicDomain::resetCache(unsigned n)
177 176
 {
178 177
     mInsertCacheIndex = 0;
... ...
@@ -64,7 +64,6 @@ private:
64 64
     std::vector<Atom> mAtoms;
65 65
     std::map<uint64_t, uint64_t> mAtomPositions;
66 66
 
67
-    // TODO google_dense_set - first profile and benchmark
68 67
     boost::unordered_set<uint64_t> mUsedPositions;
69 68
 
70 69
     mutable std::vector<RawAtom> mInsertCache;
... ...
@@ -50,7 +50,8 @@ mStatistics(D.nrow(), D.ncol(), nFactor)
50 50
 Rcpp::List GapsRunner::run()
51 51
 {
52 52
     // reset the checkpoint timer
53
-    mLastCheckpoint = bpt_now();
53
+    mStartTime = bpt_now();
54
+    mLastCheckpoint = mStartTime;
54 55
 
55 56
     // cascade down the various phases of the algorithm
56 57
     // this allows for starting in the middle of the algorithm
... ...
@@ -162,6 +163,27 @@ void GapsRunner::displayStatus(const std::string &type, unsigned nIterTotal)
162 163
         Rprintf("%s %d of %d, Atoms:%lu(%lu) Chi2 = %.2f\n", type.c_str(),
163 164
             mCurrentIter + 1, nIterTotal, mASampler.nAtoms(),
164 165
             mPSampler.nAtoms(), mASampler.chi2());
166
+        bpt::time_duration diff = bpt_now() - mStartTime;
167
+        double elapsed = diff.total_milliseconds() / 1000.0;
168
+        Rprintf("Elapsed Time: %.3f seconds\n", elapsed);
169
+
170
+        double prop = 0.0;
171
+        switch (mPhase)
172
+        {
173
+            case GAPS_BURN:
174
+                prop = mCurrentIter;
175
+                break;
176
+            case GAPS_COOL:
177
+                prop = mEquilIter + mCurrentIter;
178
+                break;
179
+            case GAPS_SAMP:
180
+                prop = mEquilIter + mCoolIter + mCurrentIter;
181
+                break;
182
+        }   
183
+        prop = (double)(mEquilIter + mCoolIter + mSampleIter) / prop;
184
+        double est = diff.total_milliseconds() * prop / 1000.0;
185
+        Rprintf("Estimated Total Time: %.3f seconds\n", est);
186
+        Rprintf("Estimated Remaining Time: %.3f seconds\n", est - elapsed);        
165 187
     }
166 188
 }
167 189
 
... ...
@@ -2,7 +2,7 @@
2 2
 #define __COGAPS_GAPS_RUNNER_H__
3 3
 
4 4
 #include "Archive.h"
5
-#include "math/Matrix.h"
5
+#include "data_structures/Matrix.h"
6 6
 #include "GibbsSampler.h"
7 7
 #include "GapsStatistics.h"
8 8
 
... ...
@@ -65,6 +65,8 @@ public:
65 65
 
66 66
     unsigned mNumCores;
67 67
 
68
+    bpt::ptime mStartTime;
69
+
68 70
     void createCheckpoint();
69 71
     void makeCheckpointIfNeeded();
70 72
     void displayStatus(const std::string &type, unsigned nIterTotal);
... ...
@@ -2,7 +2,7 @@
2 2
 #define __COGAPS_GAPS_STATISTICS_H__
3 3
 
4 4
 #include "GibbsSampler.h"
5
-#include "math/Matrix.h"
5
+#include "data_structures/Matrix.h"
6 6
 
7 7
 class GapsStatistics
8 8
 {
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 #include "GapsAssert.h"
5 5
 #include "Archive.h"
6
-#include "math/Matrix.h"
6
+#include "data_structures/Matrix.h"
7 7
 #include "math/Random.h"
8 8
 #include "math/Algorithms.h"
9 9
 #include "ProposalQueue.h"
... ...
@@ -8,7 +8,7 @@ OBJECTS =   AtomicDomain.o \
8 8
             RcppExports.o \
9 9
             test-runner.o \
10 10
             math/Algorithms.o \
11
-            math/Matrix.o \
11
+            data_structures/Matrix.o \
12 12
             math/Random.o \
13 13
             cpp_tests/testAlgorithms.o \
14 14
             cpp_tests/testAtomicDomain.o \
... ...
@@ -2,8 +2,6 @@
2 2
 #include "ProposalQueue.h"
3 3
 #include "math/Random.h"
4 4
 
5
-// TODO invalidate 
6
-
7 5
 void ProposalQueue::setNumBins(unsigned nBins)
8 6
 {
9 7
     mNumBins = nBins;
... ...
@@ -3,7 +3,7 @@
3 3
 
4 4
 #include "Archive.h"
5 5
 #include "AtomicDomain.h"
6
-#include "data_structures/FixedHashSet.h"
6
+#include "data_structures/EfficientSets.h"
7 7
 
8 8
 #include <boost/unordered_set.hpp>
9 9
 #include <stdint.h>
... ...
@@ -1,5 +1,5 @@
1 1
 #include "catch.h"
2
-#include "../math/Matrix.h"
2
+#include "../data_structures/Matrix.h"
3 3
 #include "../math/Algorithms.h"
4 4
 
5 5
 #define MAT_SUM(nR, nC) ((nR + nC - 2) * nR * nC / 2.f)
... ...
@@ -1,5 +1,5 @@
1 1
 #include "catch.h"
2
-#include "../math/Matrix.h"
2
+#include "../data_structures/Matrix.h"
3 3
 
4 4
 TEST_CASE("Test Matrix.h")
5 5
 {
6 6
similarity index 83%
7 7
rename from src/data_structures/FixedHashSet.h
8 8
rename to src/data_structures/EfficientSets.h
... ...
@@ -1,5 +1,5 @@
1
-#ifndef __COGAPS_FIXED_HASH_SET__
2
-#define __COGAPS_FIXED_HASH_SET__
1
+#ifndef __COGAPS_EFFICIENT_SETS_H__
2
+#define __COGAPS_EFFICIENT_SETS_H__
3 3
 
4 4
 #include <stdint.h>
5 5
 
... ...
@@ -20,7 +20,7 @@ public:
20 20
     void insert(uint64_t n) {mSet[n] = mCurrentKey;}
21 21
 };
22 22
 
23
-// have vector with at least some % of holes
23
+// have sorted vector with at least some % of holes
24 24
 // even distribute entries along it
25 25
 // when shift happens, should be minimal
26 26
 
27 27
similarity index 100%
28 28
rename from src/math/Matrix.cpp
29 29
rename to src/data_structures/Matrix.cpp
30 30
similarity index 100%
31 31
rename from src/math/Matrix.h
32 32
rename to src/data_structures/Matrix.h
... ...
@@ -1,5 +1,5 @@
1 1
 #include "Algorithms.h"
2
-#include "Matrix.h"
2
+#include "../data_structures/Matrix.h"
3 3
 #include "SIMD.h"
4 4
 
5 5
 #include <algorithm>
... ...
@@ -1,7 +1,7 @@
1 1
 #ifndef __COGAPS_ALGORITHMS_H__
2 2
 #define __COGAPS_ALGORITHMS_H__
3 3
 
4
-#include "Matrix.h"
4
+#include "../data_structures/Matrix.h"
5 5
 
6 6
 #define GAPS_SQ(x) ((x) * (x))
7 7