47 bool need_help =
false;
48 for (
int i = 1;
i < argc;
i++) {
49 if (argv[
i][0] ==
'r') {
50 rows = atoi(argv[
i] + 1);
51 }
else if (argv[
i][0] ==
'c') {
52 cols = atoi(argv[
i] + 1);
53 }
else if (argv[
i][0] ==
'n') {
54 nnzPerCol = atoi(argv[
i] + 1);
55 }
else if (argv[
i][0] ==
't') {
56 tries = atoi(argv[
i] + 1);
57 }
else if (argv[
i][0] ==
'p') {
58 repeats = atoi(argv[
i] + 1);
64 std::cout << argv[0] <<
" r<nb rows> c<nb columns> n<non zeros per column> t<nb tries> p<nb repeats>\n";
68 std::cout <<
"SpMV " <<
rows <<
" x " <<
cols <<
" with " << nnzPerCol <<
" non zeros per column. (" << repeats
69 <<
" repeats, and " << tries <<
" tries)\n\n";
76 while (nnzPerCol >= 4) {
77 std::cout <<
"nnz: " << nnzPerCol <<
"\n";
88 std::cout <<
"Dense " <<
t.value() / repeats <<
"\t";
91 std::cout <<
t.value() / repeats << endl;
98 std::cout <<
"Eigen " <<
t.value() / repeats <<
"\t";
101 std::cout <<
t.value() / repeats << endl;
107 std::cout <<
"CSparse \n";
109 eiToCSparse(sm, csm);
123 oski_vecview_t ov, ores;
125 om = oski_CreateMatCSC(sm._outerIndexPtr(), sm._innerIndexPtr(), sm._valuePtr(),
rows,
cols, SHARE_INPUTMAT, 1,
127 ov = oski_CreateVecView(dv.data(),
cols, STRIDE_UNIT);
128 ores = oski_CreateVecView(
res.data(),
rows, STRIDE_UNIT);
130 SPMV_BENCH(oski_MatMult(om, OP_NORMAL, 1, ov, 0, ores));
131 std::cout <<
"OSKI " <<
t.value() / repeats <<
"\t";
133 SPMV_BENCH(oski_MatMult(om, OP_TRANS, 1, ov, 0, ores));
134 std::cout <<
t.value() / repeats <<
"\n";
139 oski_SetHintMatMult(om, OP_NORMAL, 1.0, SYMBOLIC_VEC, 0.0, SYMBOLIC_VEC, ALWAYS_TUNE_AGGRESSIVELY);
142 double tuning =
t.value();
144 SPMV_BENCH(oski_MatMult(om, OP_NORMAL, 1, ov, 0, ores));
145 std::cout <<
"OSKI tuned " <<
t.value() / repeats <<
"\t";
147 SPMV_BENCH(oski_MatMult(om, OP_TRANS, 1, ov, 0, ores));
148 std::cout <<
t.value() / repeats <<
"\t(" << tuning <<
")\n";
151 oski_DestroyVecView(ov);
152 oski_DestroyVecView(ores);
159 using namespace boost::numeric;
163 boost::numeric::ublas::vector<Scalar> uv(
cols), ures(
rows);
167 SPMV_BENCH(ublas::axpy_prod(um, uv, ures,
true));
168 std::cout <<
"ublas " <<
t.value() / repeats <<
"\t";
171 std::cout <<
t.value() / repeats << endl;
181 std::vector<Scalar> gv(
cols), gres(
rows);
186 std::cout <<
"GMM++ " <<
t.value() / repeats <<
"\t";
188 SPMV_BENCH(gmm::mult(gmm::transposed(gm), gv, gres));
189 std::cout <<
t.value() / repeats << endl;
198 mtl::dense_vector<Scalar> mv(
cols, 1.0);
199 mtl::dense_vector<Scalar> mres(
rows, 1.0);
202 std::cout <<
"MTL4 " <<
t.value() / repeats <<
"\t";
205 std::cout <<
t.value() / repeats << endl;
211 if (nnzPerCol == 1)
break;
212 nnzPerCol -= nnzPerCol / 2;
void eiToGmm(const EigenSparseMatrix &src, GmmSparse &dst)
Definition: BenchSparseUtil.h:64
void eiToDense(const EigenSparseMatrix &src, DenseMatrix &dst)
Definition: BenchSparseUtil.h:54
mtl::compressed2D< Scalar, mtl::matrix::parameters< mtl::tag::col_major > > MtlSparse
Definition: BenchSparseUtil.h:74
void fillMatrix2(int nnzPerCol, int rows, int cols, EigenSparseMatrix &dst)
Definition: BenchSparseUtil.h:38
gmm::csc_matrix< Scalar > GmmSparse
Definition: BenchSparseUtil.h:62
void eiToMtl(const EigenSparseMatrix &src, MtlSparse &dst)
Definition: BenchSparseUtil.h:76
void eiToUblas(const EigenSparseMatrix &src, UBlasSparse &dst)
Definition: BenchSparseUtil.h:112
int i
Definition: BiCGSTAB_step_by_step.cpp:9
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Definition: BenchTimer.h:55
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
char * trans
Definition: level2_impl.h:240
t
Definition: plotPSD.py:36
#define SPMV_BENCH(CODE)
Definition: spmv.cpp:13