1 #include <shark/LinAlg/BLAS/blas.h> 8 template<
class Triangular,
class AMat,
class CMat>
10 blas::matrix_expression<AMat, blas::cpu_tag>
const& A,
11 blas::matrix_expression<CMat, blas::cpu_tag> & C
13 double minTime = std::numeric_limits<double>::max();
14 for(std::size_t i = 0; i != 10; ++i){
16 shark::blas::kernels::syrk<Triangular::is_upper>(A,C,2.0);
17 minTime = min(minTime,time.
stop());
19 return (0.5*A().size1()*A().size2()*A().size1())/minTime/1024/1024;
22 int main(
int argc,
char **argv) {
23 std::size_t size = 100;
24 std::cout<<
"Mega Flops"<<std::endl;
25 for(std::size_t iter = 0; iter != 5; ++iter){
26 blas::matrix<double,blas::row_major> Arow(size,size);
27 for(std::size_t i = 0; i != size; ++i){
28 for(std::size_t k = 0; k != size; ++k){
29 Arow(i,k) = 0.1/size*i+0.1/size*k;
32 blas::matrix<double,blas::column_major> Acol = Arow;
34 blas::matrix<double,blas::row_major> Crow(size,size,0.0);
35 blas::matrix<double,blas::column_major> Ccol(size,size,0.0);
36 std::cout<<size<<
"\trow major result - lower\t"<<benchmark<blas::lower>(Arow,Crow)<<
"\t"<< benchmark<blas::lower>(Acol,Crow)<<std::endl;
37 std::cout<<size<<
"\trow major result - upper\t"<<benchmark<blas::upper>(Arow,Crow)<<
"\t"<< benchmark<blas::upper>(Acol,Crow)<<std::endl;
38 std::cout<<size<<
"\tcolumn major result - lower\t"<<benchmark<blas::lower>(Arow,Ccol)<<
"\t"<< benchmark<blas::lower>(Acol,Ccol)<<std::endl;
39 std::cout<<size<<
"\tcolumn major result - upper\t"<<benchmark<blas::upper>(Arow,Ccol)<<
"\t"<< benchmark<blas::upper>(Acol,Ccol)<<std::endl;