| 16 | |
| 17 | template <typename MatrixType> |
| 18 | __attribute__ ((noinline)) void bench_reverse(const MatrixType& m) |
| 19 | { |
| 20 | int rows = m.rows(); |
| 21 | int cols = m.cols(); |
| 22 | int size = m.size(); |
| 23 | |
| 24 | int repeats = (REPEAT*1000)/size; |
| 25 | MatrixType a = MatrixType::Random(rows,cols); |
| 26 | MatrixType b = MatrixType::Random(rows,cols); |
| 27 | |
| 28 | BenchTimer timerB, timerH, timerV; |
| 29 | |
| 30 | Scalar acc = 0; |
| 31 | int r = internal::random<int>(0,rows-1); |
| 32 | int c = internal::random<int>(0,cols-1); |
| 33 | for (int t=0; t<TRIES; ++t) |
| 34 | { |
| 35 | timerB.start(); |
| 36 | for (int k=0; k<repeats; ++k) |
| 37 | { |
| 38 | asm("#begin foo"); |
| 39 | b = a.reverse(); |
| 40 | asm("#end foo"); |
| 41 | acc += b.coeff(r,c); |
| 42 | } |
| 43 | timerB.stop(); |
| 44 | } |
| 45 | |
| 46 | if (MatrixType::RowsAtCompileTime==Dynamic) |
| 47 | std::cout << "dyn "; |
| 48 | else |
| 49 | std::cout << "fixed "; |
| 50 | std::cout << rows << " x " << cols << " \t" |
| 51 | << (timerB.value() * REPEAT) / repeats << "s " |
| 52 | << "(" << 1e-6 * size*repeats/timerB.value() << " MFLOPS)\t"; |
| 53 | |
| 54 | std::cout << "\n"; |
| 55 | // make sure the compiler does not optimize too much |
| 56 | if (acc==123) |
| 57 | std::cout << acc; |
| 58 | } |
| 59 | |
| 60 | int main(int argc, char* argv[]) |
| 61 | { |