gemv_common.h File Reference
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <functional>
#include "eigen_src/Eigen/Core"
#include "../BenchTimer.h"

Go to the source code of this file.

Typedefs

typedef SCALAR Scalar
 
typedef Matrix< Scalar, Dynamic, Dynamic > Mat
 
typedef Matrix< Scalar, Dynamic, 1 > Vec
 

Functions

template<typename Func >
EIGEN_DONT_INLINE double bench (long m, long n, Func &f)
 
template<typename Func >
int main_gemv (int argc, char **argv, Func &f)
 

Typedef Documentation

◆ Mat

typedef Matrix<Scalar, Dynamic, Dynamic> Mat

◆ Scalar

typedef SCALAR Scalar

◆ Vec

typedef Matrix<Scalar, Dynamic, 1> Vec

Function Documentation

◆ bench()

template<typename Func >
EIGEN_DONT_INLINE double bench ( long  m,
long  n,
Func &  f 
)
20  {
21  Mat A(m, n);
22  Vec B(n);
23  Vec C(m);
24  A.setRandom();
25  B.setRandom();
26  C.setRandom();
27 
28  BenchTimer t;
29 
30  double up = 1e8 / sizeof(Scalar);
31  double tm0 = 4, tm1 = 10;
33  up /= 4;
34  tm0 = 2;
35  tm1 = 4;
36  }
37 
38  double flops = 2. * m * n;
39  long rep = std::max(1., std::min(100., up / flops));
40  long tries = std::max(tm0, std::min(tm1, up / flops));
41 
42  BENCH(t, tries, rep, f(A, B, C));
43 
44  return 1e-9 * rep * flops / t.best();
45 }
#define BENCH(TIMER, TRIES, REP, CODE)
Definition: BenchTimer.h:150
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:49
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:48
Definition: BenchTimer.h:55
Derived & setRandom(Index size)
Definition: Random.h:147
Definition: matrices.h:74
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
SCALAR Scalar
Definition: gemv_common.h:14
int * m
Definition: level2_cplx_impl.h:294
t
Definition: plotPSD.py:36
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217

References BENCH, e(), f(), m, max, min, n, Eigen::PlainObjectBase< Derived >::setRandom(), and plotPSD::t.

Referenced by main_gemv().

◆ main_gemv()

template<typename Func >
int main_gemv ( int  argc,
char **  argv,
Func &  f 
)
48  {
49  std::vector<double> results;
50 
51  std::string filename = std::string("gemv_settings.txt");
52  if (argc > 1) filename = std::string(argv[1]);
53  std::ifstream settings(filename);
54  long m, n;
55  while (settings >> m >> n) {
56  // std::cerr << " Testing " << m << " " << n << std::endl;
57  results.push_back(bench(m, n, f));
58  }
59 
60  std::cout << RowVectorXd::Map(results.data(), results.size());
61 
62  return 0;
63 }
std::map< std::string, Array< float, 1, 8, DontAlign|RowMajor > > results
Definition: dense_solvers.cpp:10
EIGEN_DONT_INLINE double bench(long m, long n, Func &f)
Definition: gemv_common.h:20
string filename
Definition: MergeRestartFiles.py:39
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References bench(), f(), MergeRestartFiles::filename, m, n, results, and oomph::Global_string_for_annotation::string().

Referenced by main().