diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2008-04-11 08:18:47 +0000 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2008-04-11 08:18:47 +0000 |
commit | 7bee90a62a0e5fec52a4b8a6f0b1d88c175d63f8 (patch) | |
tree | 154639c70b74c592efb05ddc1033762eb7cc3851 /bench | |
parent | 187b1543ce2448e8be87211c833da5d83af6ec7d (diff) |
Merge Gael's experimental OpenMP parallelization support into Assign.h.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/benchmarkX.cpp | 24 | ||||
-rw-r--r-- | bench/benchmarkXL.cpp | 34 |
2 files changed, 52 insertions, 6 deletions
diff --git a/bench/benchmarkX.cpp b/bench/benchmarkX.cpp index 09173e1ed..590f2636b 100644 --- a/bench/benchmarkX.cpp +++ b/bench/benchmarkX.cpp @@ -5,18 +5,30 @@ using namespace std; USING_PART_OF_NAMESPACE_EIGEN +#ifndef MATTYPE +#define MATTYPE MatrixXd +#endif + +#ifndef MATSIZE +#define MATSIZE 20 +#endif + +#ifndef REPEAT +#define REPEAT 100000 +#endif + int main(int argc, char *argv[]) { - MatrixXd I = MatrixXd::identity(20,20); - MatrixXd m(20,20); - for(int i = 0; i < 20; i++) for(int j = 0; j < 20; j++) + MATTYPE I = MATTYPE::identity(MATSIZE,MATSIZE); + MATTYPE m(MATSIZE,MATSIZE); + for(int i = 0; i < MATSIZE; i++) for(int j = 0; j < MATSIZE; j++) { - m(i,j) = 0.1 * (i+20*j); + m(i,j) = 0.1 * (i+MATSIZE*j)/MATSIZE; } - for(int a = 0; a < 100000; a++) + for(int a = 0; a < REPEAT; a++) { m = I + 0.00005 * (m + m*m); } - cout << m << endl; + cout << m(0,0) << endl; return 0; } diff --git a/bench/benchmarkXL.cpp b/bench/benchmarkXL.cpp new file mode 100644 index 000000000..ff128da06 --- /dev/null +++ b/bench/benchmarkXL.cpp @@ -0,0 +1,34 @@ +// g++ -O3 -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX + +#include <Eigen/Core> + +using namespace std; +USING_PART_OF_NAMESPACE_EIGEN + +#ifndef MATTYPE +#define MATTYPE MatrixXLd +#endif + +#ifndef MATSIZE +#define MATSIZE 400 +#endif + +#ifndef REPEAT +#define REPEAT 10000 +#endif + +int main(int argc, char *argv[]) +{ + MATTYPE I = MATTYPE::identity(MATSIZE,MATSIZE); + MATTYPE m(MATSIZE,MATSIZE); + for(int i = 0; i < MATSIZE; i++) for(int j = 0; j < MATSIZE; j++) + { + m(i,j) = 0.1 * (i+MATSIZE*j)/MATSIZE; + } + for(int a = 0; a < REPEAT; a++) + { + m = I + 0.00005 * (m + m/4); + } + cout << m(0,0) << endl; + return 0; +} |