11 #define SPMV_BENCH(CODE) BENCH(t,tries,repeats,CODE); 37 int main(
int argc,
char *argv[])
46 bool need_help =
false;
47 for(
int i = 1;
i < argc;
i++)
51 rows = atoi(argv[
i]+1);
53 else if(argv[
i][0] ==
'c')
55 cols = atoi(argv[
i]+1);
57 else if(argv[
i][0] ==
'n')
59 nnzPerCol = atoi(argv[
i]+1);
61 else if(argv[
i][0] ==
't')
63 tries = atoi(argv[
i]+1);
65 else if(argv[
i][0] ==
'p')
67 repeats = atoi(argv[
i]+1);
76 std::cout << argv[0] <<
" r<nb rows> c<nb columns> n<non zeros per column> t<nb tries> p<nb repeats>\n";
80 std::cout <<
"SpMV " << rows <<
" x " << cols <<
" with " << nnzPerCol <<
" non zeros per column. (" << repeats <<
" repeats, and " << tries <<
" tries)\n\n";
89 std::cout <<
"nnz: " << nnzPerCol <<
"\n";
100 std::cout <<
"Dense " << t.
value()/repeats <<
"\t";
103 std::cout << t.
value()/repeats << endl;
110 std::cout <<
"Eigen " << t.
value()/repeats <<
"\t";
113 std::cout << t.
value()/repeats << endl;
119 std::cout <<
"CSparse \n";
121 eiToCSparse(sm, csm);
135 oski_vecview_t ov, ores;
137 om = oski_CreateMatCSC(sm._outerIndexPtr(), sm._innerIndexPtr(), sm._valuePtr(),
rows,
cols,
138 SHARE_INPUTMAT, 1, INDEX_ZERO_BASED);
139 ov = oski_CreateVecView(dv.data(),
cols, STRIDE_UNIT);
140 ores = oski_CreateVecView(res.data(),
rows, STRIDE_UNIT);
142 SPMV_BENCH( oski_MatMult(om, OP_NORMAL, 1, ov, 0, ores) );
143 std::cout <<
"OSKI " << t.
value()/repeats <<
"\t";
145 SPMV_BENCH( oski_MatMult(om, OP_TRANS, 1, ov, 0, ores) );
146 std::cout << t.
value()/repeats <<
"\n";
151 oski_SetHintMatMult(om, OP_NORMAL, 1.0, SYMBOLIC_VEC, 0.0, SYMBOLIC_VEC, ALWAYS_TUNE_AGGRESSIVELY);
154 double tuning = t.
value();
156 SPMV_BENCH( oski_MatMult(om, OP_NORMAL, 1, ov, 0, ores) );
157 std::cout <<
"OSKI tuned " << t.
value()/repeats <<
"\t";
159 SPMV_BENCH( oski_MatMult(om, OP_TRANS, 1, ov, 0, ores) );
160 std::cout << t.
value()/repeats <<
"\t(" << tuning <<
")\n";
164 oski_DestroyVecView(ov);
165 oski_DestroyVecView(ores);
173 UblasMatrix um(rows,cols);
176 boost::numeric::ublas::vector<Scalar> uv(cols), ures(rows);
180 SPMV_BENCH(ublas::axpy_prod(um, uv, ures,
true));
181 std::cout <<
"ublas " << t.
value()/repeats <<
"\t";
184 std::cout << t.
value()/repeats << endl;
194 std::vector<Scalar> gv(cols), gres(rows);
199 std::cout <<
"GMM++ " << t.
value()/repeats <<
"\t";
201 SPMV_BENCH(gmm::mult(gmm::transposed(gm), gv, gres));
202 std::cout << t.
value()/repeats << endl;
211 mtl::dense_vector<Scalar> mv(cols, 1.0);
212 mtl::dense_vector<Scalar> mres(rows, 1.0);
215 std::cout <<
"MTL4 " << t.
value()/repeats <<
"\t";
218 std::cout << t.
value()/repeats << endl;
226 nnzPerCol -= nnzPerCol/2;
Matrix< Scalar, Dynamic, Dynamic > DenseMatrix
void eiToMtl(const EigenSparseMatrix &src, MtlSparse &dst)
A matrix or vector expression mapping an existing array of data.
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
void fillMatrix2(int nnzPerCol, int rows, int cols, EigenSparseMatrix &dst)
Matrix< Scalar, Dynamic, 1 > DenseVector
void eiToDense(const EigenSparseMatrix &src, DenseMatrix &dst)
void eiToUblas(const EigenSparseMatrix &src, UBlasSparse &dst)
TransposeReturnType transpose()
mtl::compressed2D< Scalar, mtl::matrix::parameters< mtl::tag::col_major > > MtlSparse
gmm::csc_matrix< Scalar > GmmSparse
int main(int argc, char *argv[])
double value(int TIMER=CPU_TIMER) const
void eiToGmm(const EigenSparseMatrix &src, GmmSparse &dst)