public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/auto-numerical-bench:unstable commit in: btl/generic_bench/timers/, btl/generic_bench/utils/
@ 2011-08-02 18:45 Andrea Arteaga
  0 siblings, 0 replies; only message in thread
From: Andrea Arteaga @ 2011-08-02 18:45 UTC (permalink / raw
  To: gentoo-commits

commit:     47bf3cba26079de61205acd26258739c78c30ac1
Author:     spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Tue Aug  2 18:03:53 2011 +0000
Commit:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Tue Aug  2 18:03:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=47bf3cba

Continue merging

---
 .../timers/distributed_perf_analyzer_root.hh       |    2 +-
 btl/generic_bench/utils/LinearCongruential.hh      |   66 ++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/btl/generic_bench/timers/distributed_perf_analyzer_root.hh b/btl/generic_bench/timers/distributed_perf_analyzer_root.hh
index 807f20a..26a3257 100644
--- a/btl/generic_bench/timers/distributed_perf_analyzer_root.hh
+++ b/btl/generic_bench/timers/distributed_perf_analyzer_root.hh
@@ -52,7 +52,7 @@ public:
     double time_action = m_time_action / (double(_nb_calc));
 
     /* Check */
-    int do_check = (BtlConfig::Instance.checkResults && size<128) ? 1 : 0;
+    int do_check = (BtlConfig::Instance.checkResults && size<128) ? 1 : 1;
     igebs2d_(&context, "A", " ", &iONE, &iONE, &do_check, &iONE);
     if (do_check > 0) {
       action.initialize();

diff --git a/btl/generic_bench/utils/LinearCongruential.hh b/btl/generic_bench/utils/LinearCongruential.hh
new file mode 100644
index 0000000..49b9d12
--- /dev/null
+++ b/btl/generic_bench/utils/LinearCongruential.hh
@@ -0,0 +1,66 @@
+#ifndef LINEARCONGRUENTIAL_HH_
+#define LINEARCONGRUENTIAL_HH_
+
+#include <vector>
+
+class LinearCongruential
+{
+  typedef std::vector<unsigned> buffer_t;
+  typedef unsigned int_t;
+
+public:
+  LinearCongruential(const int_t& seed) :
+    a_(1664525u), c_(1013904223u), m_(getM()), i_(0)
+  {
+    buffer_.resize(100);
+    fillBuffer(seed);
+  }
+
+  int_t a() const { return a_; }
+  int_t c() const { return c_; }
+  int_t m() const { return m_; }
+
+  int_t get_int() {
+    if (i_ >= buffer_.size()) {
+        fillBuffer();
+        i_ = 0;
+    }
+    return buffer_.at(i_++);
+  }
+
+  double get_01() {
+    return static_cast<double>(get_int())/static_cast<double>(m_);
+  }
+
+private:
+  buffer_t buffer_;
+  const int_t a_, c_, m_;
+  std::size_t i_;
+
+  void fillBuffer(const int_t& seed)
+  {
+    buffer_.front() = (seed*a_+c_) & m_;
+    for (
+        typename buffer_t::iterator i = buffer_.begin()+1, end = buffer_.end();
+        i != end; ++i)
+      *i = (*(i-1)*a_ + c_) & m_;
+  }
+
+  void fillBuffer()
+  {
+    const int_t seed = buffer_.back();
+    fillBuffer(seed);
+  }
+
+  static int_t getM()
+  {
+    int_t _m = 1;
+    for (int i = 1; i < 32; ++i) {
+      _m <<= 1;
+      _m += 1;
+    }
+    return _m;
+  }
+};
+
+#endif /* LINEARCONGRUENTIAL_HH_ */



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-02 18:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-02 18:45 [gentoo-commits] proj/auto-numerical-bench:unstable commit in: btl/generic_bench/timers/, btl/generic_bench/utils/ Andrea Arteaga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox