mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 03:39:01 +08:00
Add perf monitoring for gemv
This commit is contained in:
parent
d2718d662c
commit
4c0d5f3c01
@ -59,3 +59,6 @@ before-evaluators
|
||||
9174:d228bc282ac9 # merge
|
||||
9212:c90098affa7b # Fix performance regression introduced in changeset 8aad8f35c955
|
||||
9213:9f1c14e4694b # Fix performance regression in dgemm introduced by changeset 81d53c711775
|
||||
3.3-beta2
|
||||
3.3-rc1
|
||||
3.3.0
|
||||
|
68
bench/perf_monitoring/gemm/gemv.cpp
Normal file
68
bench/perf_monitoring/gemm/gemv.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <Eigen/Core>
|
||||
#include "../../BenchTimer.h"
|
||||
using namespace Eigen;
|
||||
|
||||
#ifndef SCALAR
|
||||
#error SCALAR must be defined
|
||||
#endif
|
||||
|
||||
typedef SCALAR Scalar;
|
||||
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> Mat;
|
||||
typedef Matrix<Scalar,Dynamic,1> Vec;
|
||||
|
||||
EIGEN_DONT_INLINE
|
||||
void gemv(const Mat &A, const Vec &B, Vec &C)
|
||||
{
|
||||
C.noalias() += A * B;
|
||||
}
|
||||
|
||||
EIGEN_DONT_INLINE
|
||||
double bench(long m, long n)
|
||||
{
|
||||
Mat A(m,n);
|
||||
Vec B(n);
|
||||
Vec C(m);
|
||||
A.setRandom();
|
||||
B.setRandom();
|
||||
C.setZero();
|
||||
|
||||
BenchTimer t;
|
||||
|
||||
double up = 1e9*4/sizeof(Scalar);
|
||||
double tm0 = 4, tm1 = 10;
|
||||
if(NumTraits<Scalar>::IsComplex)
|
||||
{
|
||||
up /= 4;
|
||||
tm0 = 2;
|
||||
tm1 = 4;
|
||||
}
|
||||
|
||||
double flops = 2. * m * n;
|
||||
long rep = std::max(1., std::min(100., up/flops) );
|
||||
long tries = std::max(tm0, std::min(tm1, up/flops) );
|
||||
|
||||
BENCH(t, tries, rep, gemv(A,B,C));
|
||||
|
||||
return 1e-9 * rep * flops / t.best();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::vector<double> results;
|
||||
|
||||
std::ifstream settings("gemv_settings.txt");
|
||||
long m, n;
|
||||
while(settings >> m >> n)
|
||||
{
|
||||
//std::cerr << " Testing " << m << " " << n << " " << k << std::endl;
|
||||
results.push_back( bench(m, n) );
|
||||
}
|
||||
|
||||
std::cout << RowVectorXd::Map(results.data(), results.size());
|
||||
|
||||
return 0;
|
||||
}
|
11
bench/perf_monitoring/gemm/gemv_settings.txt
Normal file
11
bench/perf_monitoring/gemm/gemv_settings.txt
Normal file
@ -0,0 +1,11 @@
|
||||
8 8
|
||||
9 9
|
||||
24 24
|
||||
239 239
|
||||
240 240
|
||||
2400 24
|
||||
24 2400
|
||||
24 240
|
||||
2400 2400
|
||||
4800 23
|
||||
23 4800
|
Loading…
x
Reference in New Issue
Block a user