38 asm(
"stmxcsr %[aux] \n\t"
39 "orl $32832, %[aux] \n\t"
46 int nbtries = 1, nbloops = 1,
M,
N,
K;
52 M =
N =
K = atoi(argv[1]);
53 }
else if ((argc == 3) && (
std::string(argv[1]) ==
"auto")) {
54 M =
N =
K = atoi(argv[2]);
55 nbloops = 1000000000 / (
M *
M *
M);
56 if (nbloops < 1) nbloops = 1;
58 }
else if (argc == 4) {
59 M =
N =
K = atoi(argv[1]);
60 nbloops = atoi(argv[2]);
61 nbtries = atoi(argv[3]);
62 }
else if (argc == 6) {
66 nbloops = atoi(argv[4]);
67 nbtries = atoi(argv[5]);
69 std::cout <<
"Usage: " << argv[0] <<
" size \n";
70 std::cout <<
"Usage: " << argv[0] <<
" auto size\n";
71 std::cout <<
"Usage: " << argv[0] <<
" size nbloops nbtries\n";
72 std::cout <<
"Usage: " << argv[0] <<
" M N K nbloops nbtries\n";
73 std::cout <<
"Usage: " << argv[0] <<
" check\n";
74 std::cout <<
"Options:\n";
75 std::cout <<
" size unique size of the 2 matrices (integer)\n";
76 std::cout <<
" auto automatically set the number of repetitions and tries\n";
77 std::cout <<
" nbloops number of times the GEMM routines is executed\n";
78 std::cout <<
" nbtries number of times the loop is benched (return the best try)\n";
79 std::cout <<
" M N K sizes of the matrices: MxN = MxK * KxN (integers)\n";
80 std::cout <<
" check check eigen product using cblas as a reference\n";
86 if (!(
std::string(argv[1]) ==
"auto")) std::cout <<
M <<
" x " <<
N <<
" x " <<
K <<
"\n";
90 ma = MyMatrix::Random(
M,
K);
91 mb = MyMatrix::Random(
K,
N);
92 mc = MyMatrix::Random(
M,
N);
104 for (uint
k = 0;
k < nbtries; ++
k) {
106 for (uint
j = 0;
j < nbloops; ++
j)
107 #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
108 CBLAS_GEMM(CblasRowMajor, CblasNoTrans, CblasNoTrans,
M,
N,
K,
alpha, ma.data(),
K, mb.data(),
N,
beta,
111 CBLAS_GEMM(CblasColMajor, CblasNoTrans, CblasNoTrans,
M,
N,
K,
alpha, ma.data(),
M, mb.
data(),
K,
beta,
117 std::cout <<
"cblas: " <<
timer.value() <<
" (" << 1
e-3 *
floor(1
e-6 * nbmad /
timer.value()) <<
" GFlops/s)\n";
119 std::cout <<
M <<
" : " <<
timer.value() <<
" ; " << 1
e-3 *
floor(1
e-6 * nbmad /
timer.value()) <<
"\n";
123 ma = MyMatrix::Random(
M,
K);
124 mb = MyMatrix::Random(
K,
N);
125 mc = MyMatrix::Random(
M,
N);
131 for (uint
k = 0;
k < nbtries; ++
k) {
137 std::cout <<
"eigen : " <<
timer.value() <<
" (" << 1
e-3 *
floor(1
e-6 * nbmad /
timer.value()) <<
" GFlops/s)\n";
139 std::cout <<
M <<
" : " <<
timer.value() <<
" ; " << 1
e-3 *
floor(1
e-6 * nbmad /
timer.value()) <<
"\n";
float Scalar
Definition: benchBlasGemm.cpp:21
void bench_eigengemm(MyMatrix &mc, const MyMatrix &ma, const MyMatrix &mb, int nbloops)
Definition: benchBlasGemm.cpp:150
Definition: BenchTimer.h:55
RealScalar alpha
Definition: level1_cplx_impl.h:151
Scalar beta
Definition: level2_cplx_impl.h:36
char char char int int * k
Definition: level2_impl.h:374
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 floor(const bfloat16 &a)
Definition: BFloat16.h:643
std::ptrdiff_t l1CacheSize()
Definition: products/GeneralBlockPanelKernel.h:3119
std::ptrdiff_t l2CacheSize()
Definition: products/GeneralBlockPanelKernel.h:3127
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
double timer
Definition: oomph_metis_from_parmetis_3.1.1/struct.h:210