blob: c721b908179ede86f57c56563b5dfb252aff4d2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// g++ -O3 -DNDEBUG -DMATSIZE=<x> benchmark.cpp -o benchmark && time ./benchmark
#include <iostream>
#include <Eigen/Core>
#ifndef MATSIZE
#define MATSIZE 3
#endif
using namespace std;
using namespace Eigen;
#ifndef REPEAT
#define REPEAT 40000000
#endif
#ifndef SCALAR
#define SCALAR double
#endif
int main(int argc, char *argv[])
{
Matrix<SCALAR,MATSIZE,MATSIZE> I = Matrix<SCALAR,MATSIZE,MATSIZE>::Ones();
Matrix<SCALAR,MATSIZE,MATSIZE> m;
for(int i = 0; i < MATSIZE; i++)
for(int j = 0; j < MATSIZE; j++)
{
m(i,j) = (i+MATSIZE*j);
}
asm("#begin");
for(int a = 0; a < REPEAT; a++)
{
m = Matrix<SCALAR,MATSIZE,MATSIZE>::Ones() + 0.00005 * (m + (m*m));
}
asm("#end");
cout << m << endl;
return 0;
}
|