MCPcopy Create free account
hub / github.com/PX4/eigen / main

Function main

bench/benchVecAdd.cpp:21–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19__attribute__ ((noinline)) void benchVec(VectorXf& a, VectorXf& b, VectorXf& c);
20
21int main(int argc, char* argv[])
22{
23 int size = SIZE * 8;
24 int size2 = size * size;
25 Scalar* a = internal::aligned_new<Scalar>(size2);
26 Scalar* b = internal::aligned_new<Scalar>(size2+4)+1;
27 Scalar* c = internal::aligned_new<Scalar>(size2);
28
29 for (int i=0; i<size; ++i)
30 {
31 a[i] = b[i] = c[i] = 0;
32 }
33
34 BenchTimer timer;
35
36 timer.reset();
37 for (int k=0; k<10; ++k)
38 {
39 timer.start();
40 benchVec(a, b, c, size2);
41 timer.stop();
42 }
43 std::cout << timer.value() << "s " << (double(size2*REPEAT)/timer.value())/(1024.*1024.*1024.) << " GFlops\n";
44 return 0;
45 for (int innersize = size; innersize>2 ; --innersize)
46 {
47 if (size2%innersize==0)
48 {
49 int outersize = size2/innersize;
50 MatrixXf ma = Map<MatrixXf>(a, innersize, outersize );
51 MatrixXf mb = Map<MatrixXf>(b, innersize, outersize );
52 MatrixXf mc = Map<MatrixXf>(c, innersize, outersize );
53 timer.reset();
54 for (int k=0; k<3; ++k)
55 {
56 timer.start();
57 benchVec(ma, mb, mc);
58 timer.stop();
59 }
60 std::cout << innersize << " x " << outersize << " " << timer.value() << "s " << (double(size2*REPEAT)/timer.value())/(1024.*1024.*1024.) << " GFlops\n";
61 }
62 }
63
64 VectorXf va = Map<VectorXf>(a, size2);
65 VectorXf vb = Map<VectorXf>(b, size2);
66 VectorXf vc = Map<VectorXf>(c, size2);
67 timer.reset();
68 for (int k=0; k<3; ++k)
69 {
70 timer.start();
71 benchVec(va, vb, vc);
72 timer.stop();
73 }
74 std::cout << timer.value() << "s " << (double(size2*REPEAT)/timer.value())/(1024.*1024.*1024.) << " GFlops\n";
75
76 return 0;
77}
78

Callers

nothing calls this directly

Calls 5

benchVecFunction · 0.85
resetMethod · 0.45
startMethod · 0.45
stopMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected