summaryrefslogtreecommitdiff
path: root/btl
diff options
context:
space:
mode:
authorspiros <andyspiros@gmail.com>2011-08-02 20:03:53 +0200
committerspiros <andyspiros@gmail.com>2011-08-02 20:03:53 +0200
commit47bf3cba26079de61205acd26258739c78c30ac1 (patch)
treead66793ea4bcf811ff829dd6a6d8cf249434f975 /btl
parentMerge last week's changes: (diff)
downloadauto-numerical-bench-47bf3cba26079de61205acd26258739c78c30ac1.tar.gz
auto-numerical-bench-47bf3cba26079de61205acd26258739c78c30ac1.tar.bz2
auto-numerical-bench-47bf3cba26079de61205acd26258739c78c30ac1.zip
Continue merging
Diffstat (limited to 'btl')
-rw-r--r--btl/generic_bench/timers/distributed_perf_analyzer_root.hh2
-rw-r--r--btl/generic_bench/utils/LinearCongruential.hh66
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_ */