#include #include #include using namespace StormEigen; using namespace std; #define END 9 template struct map_size { enum { ret = S }; }; template<> struct map_size<10> { enum { ret = 20 }; }; template<> struct map_size<11> { enum { ret = 50 }; }; template<> struct map_size<12> { enum { ret = 100 }; }; template<> struct map_size<13> { enum { ret = 300 }; }; template struct alt_prod { enum { ret = M==1 && N==1 ? InnerProduct : K==1 ? OuterProduct : M==1 ? GemvProduct : N==1 ? GemvProduct : GemmProduct }; }; void print_mode(int mode) { if(mode==InnerProduct) std::cout << "i"; if(mode==OuterProduct) std::cout << "o"; if(mode==CoeffBasedProductMode) std::cout << "c"; if(mode==LazyCoeffBasedProductMode) std::cout << "l"; if(mode==GemvProduct) std::cout << "v"; if(mode==GemmProduct) std::cout << "m"; } template EIGEN_DONT_INLINE void prod(const Lhs& a, const Rhs& b, Res& c) { c.noalias() += typename ProductReturnType::Type(a,b); } template EIGEN_DONT_INLINE void bench_prod() { typedef Matrix Lhs; Lhs a; a.setRandom(); typedef Matrix Rhs; Rhs b; b.setRandom(); typedef Matrix Res; Res c; c.setRandom(); BenchTimer t; double n = 2.*double(M)*double(N)*double(K); int rep = 100000./n; rep /= 2; if(rep<1) rep = 1; do { rep *= 2; t.reset(); BENCH(t,1,rep,prod(a,b,c)); } while(t.best()<0.1); t.reset(); BENCH(t,5,rep,prod(a,b,c)); print_mode(Mode); std::cout << int(1e-6*n*rep/t.best()) << "\t"; } template struct print_n; template struct loop_on_m; template struct loop_on_n; template struct loop_on_k { static void run() { std::cout << "K=" << K << "\t"; print_n::run(); std::cout << "\n"; loop_on_m::run(); std::cout << "\n\n"; loop_on_k::run(); } }; template struct loop_on_k { static void run(){} }; template struct loop_on_m { static void run() { std::cout << M << "f\t"; loop_on_n::run(); std::cout << "\n"; std::cout << M << "f\t"; loop_on_n::run(); std::cout << "\n"; loop_on_m::run(); } }; template struct loop_on_m { static void run(){} }; template struct loop_on_n { static void run() { bench_prod::ret : Mode>(); loop_on_n::run(); } }; template struct loop_on_n { static void run(){} }; template struct print_n { static void run() { std::cout << map_size::ret << "\t"; print_n::run(); } }; template<> struct print_n { static void run(){} }; int main() { loop_on_k<1,1,1>::run(); return 0; }