1 |
commit: 47bf3cba26079de61205acd26258739c78c30ac1 |
2 |
Author: spiros <andyspiros <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Aug 2 18:03:53 2011 +0000 |
4 |
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com> |
5 |
CommitDate: Tue Aug 2 18:03:53 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=47bf3cba |
7 |
|
8 |
Continue merging |
9 |
|
10 |
--- |
11 |
.../timers/distributed_perf_analyzer_root.hh | 2 +- |
12 |
btl/generic_bench/utils/LinearCongruential.hh | 66 ++++++++++++++++++++ |
13 |
2 files changed, 67 insertions(+), 1 deletions(-) |
14 |
|
15 |
diff --git a/btl/generic_bench/timers/distributed_perf_analyzer_root.hh b/btl/generic_bench/timers/distributed_perf_analyzer_root.hh |
16 |
index 807f20a..26a3257 100644 |
17 |
--- a/btl/generic_bench/timers/distributed_perf_analyzer_root.hh |
18 |
+++ b/btl/generic_bench/timers/distributed_perf_analyzer_root.hh |
19 |
@@ -52,7 +52,7 @@ public: |
20 |
double time_action = m_time_action / (double(_nb_calc)); |
21 |
|
22 |
/* Check */ |
23 |
- int do_check = (BtlConfig::Instance.checkResults && size<128) ? 1 : 0; |
24 |
+ int do_check = (BtlConfig::Instance.checkResults && size<128) ? 1 : 1; |
25 |
igebs2d_(&context, "A", " ", &iONE, &iONE, &do_check, &iONE); |
26 |
if (do_check > 0) { |
27 |
action.initialize(); |
28 |
|
29 |
diff --git a/btl/generic_bench/utils/LinearCongruential.hh b/btl/generic_bench/utils/LinearCongruential.hh |
30 |
new file mode 100644 |
31 |
index 0000000..49b9d12 |
32 |
--- /dev/null |
33 |
+++ b/btl/generic_bench/utils/LinearCongruential.hh |
34 |
@@ -0,0 +1,66 @@ |
35 |
+#ifndef LINEARCONGRUENTIAL_HH_ |
36 |
+#define LINEARCONGRUENTIAL_HH_ |
37 |
+ |
38 |
+#include <vector> |
39 |
+ |
40 |
+class LinearCongruential |
41 |
+{ |
42 |
+ typedef std::vector<unsigned> buffer_t; |
43 |
+ typedef unsigned int_t; |
44 |
+ |
45 |
+public: |
46 |
+ LinearCongruential(const int_t& seed) : |
47 |
+ a_(1664525u), c_(1013904223u), m_(getM()), i_(0) |
48 |
+ { |
49 |
+ buffer_.resize(100); |
50 |
+ fillBuffer(seed); |
51 |
+ } |
52 |
+ |
53 |
+ int_t a() const { return a_; } |
54 |
+ int_t c() const { return c_; } |
55 |
+ int_t m() const { return m_; } |
56 |
+ |
57 |
+ int_t get_int() { |
58 |
+ if (i_ >= buffer_.size()) { |
59 |
+ fillBuffer(); |
60 |
+ i_ = 0; |
61 |
+ } |
62 |
+ return buffer_.at(i_++); |
63 |
+ } |
64 |
+ |
65 |
+ double get_01() { |
66 |
+ return static_cast<double>(get_int())/static_cast<double>(m_); |
67 |
+ } |
68 |
+ |
69 |
+private: |
70 |
+ buffer_t buffer_; |
71 |
+ const int_t a_, c_, m_; |
72 |
+ std::size_t i_; |
73 |
+ |
74 |
+ void fillBuffer(const int_t& seed) |
75 |
+ { |
76 |
+ buffer_.front() = (seed*a_+c_) & m_; |
77 |
+ for ( |
78 |
+ typename buffer_t::iterator i = buffer_.begin()+1, end = buffer_.end(); |
79 |
+ i != end; ++i) |
80 |
+ *i = (*(i-1)*a_ + c_) & m_; |
81 |
+ } |
82 |
+ |
83 |
+ void fillBuffer() |
84 |
+ { |
85 |
+ const int_t seed = buffer_.back(); |
86 |
+ fillBuffer(seed); |
87 |
+ } |
88 |
+ |
89 |
+ static int_t getM() |
90 |
+ { |
91 |
+ int_t _m = 1; |
92 |
+ for (int i = 1; i < 32; ++i) { |
93 |
+ _m <<= 1; |
94 |
+ _m += 1; |
95 |
+ } |
96 |
+ return _m; |
97 |
+ } |
98 |
+}; |
99 |
+ |
100 |
+#endif /* LINEARCONGRUENTIAL_HH_ */ |