20 #define INDEXTYPE uint32_t
21 #define VALUETYPE double
31 int main(
int argc,
char* argv[])
34 int gl_nworkers = __cilkrts_get_nworkers();
38 bool syminput =
false;
41 INDEXTYPE m = 0, n = 0, nnz = 0, forcelogbeta = 0;
45 cout <<
"Normal usage: ./parspmvt inputmatrix.mtx sym/nosym binary/text triples/csc" << endl;
46 cout <<
"Assuming matrix.txt is the input, matrix is unsymmetric, and stored in text(ascii) file" << endl;
47 inputname =
"matrix.txt";
51 cout <<
"Normal usage: ./parspmvt inputmatrix.mtx sym/nosym binary/text triples/csc" << endl;
52 cout <<
"Assuming that the matrix is unsymmetric, and stored in text(ascii) file" << endl;
57 cout <<
"Normal usage: ./parspmvt inputmatrix.mtx sym/nosym binary/text triples/csc" << endl;
58 cout <<
"Assuming matrix is stored in text(ascii) file" << endl;
60 string issym(argv[2]);
63 else if(issym ==
"nosym")
66 cout <<
"unrecognized option, assuming nosym" << endl;
71 string issym(argv[2]);
74 else if(issym ==
"nosym")
77 cout <<
"unrecognized option, assuming unsymmetric" << endl;
79 string isbinary(argv[3]);
80 if(isbinary ==
"text")
82 else if(isbinary ==
"binary")
85 cout <<
"unrecognized option, assuming text file" << endl;
93 cout <<
"Processing CSC binary" << endl;
98 forcelogbeta = atoi(argv[4]);
104 FILE * f = fopen(inputname.c_str(),
"r");
107 cerr <<
"Problem reading binary input file\n";
122 if (m <= 0 || n <= 0 || nnz <= 0)
124 cerr <<
"Problem with matrix size in binary input file\n";
128 cout <<
"Reading matrix with dimensions: "<< m <<
"-by-" << n <<
" having "<< nnz <<
" nonzeros" << endl;
136 size_t cols = fread(colpointers,
sizeof(
INDEXTYPE), n+1, f);
139 cerr <<
"Problem with FREAD, aborting... " << endl;
146 size_t cols = fread(colindices,
sizeof(
INDEXTYPE), nnz, f);
149 cerr <<
"Problem with FREAD, aborting... " << endl;
153 size_t rows = fread(rowindices,
sizeof(
INDEXTYPE), nnz, f);
154 size_t nums = fread(vals,
sizeof(
VALUETYPE), nnz, f);
156 if(rows != nnz || nums != nnz)
158 cerr <<
"Problem with FREAD, aborting... " << endl;
162 cout<<
"Reading matrix in binary took " << ((
VALUETYPE) (tend-tstart)) /1000 <<
" seconds" <<endl;
167 csc->
SetPointers(colpointers, rowindices, vals , nnz, m, n,
true);
173 delete [] colindices;
174 delete [] rowindices;
182 cout <<
"# workers: "<< gl_nworkers << endl;
183 cout <<
"generating vectors... " << endl;
184 cout <<
"Starting SpMV_T..." << endl;
185 cout <<
"Col imbalance is: " <<
ColImbalance(bicsb) << endl;
195 bicsb_gespmvt<PTDD>(bicsb, xt.
getarr(), yt_bicsb.
getarr());
198 for(
int i=0; i <
REPEAT; ++i)
200 bicsb_gespmvt<PTDD>(bicsb, xt.
getarr(), yt_bicsb.
getarr());
204 long time = (t1-t0)/REPEAT;
205 cout<<
"BiCSB Trans" <<
" time: " << ((double) time) /1000 <<
" seconds" <<endl;
206 cout<<
"BiCSB Trans" <<
" mflop/sec: " <<
flops / (1000 * (double) time) <<endl;
210 for(
int i=0; i <
REPEAT; ++i)
215 time = (t1-t0)/REPEAT;
216 cout <<
"Transposed CSC time: " << ((double) time) / 1000 <<
" seconds" << endl;
217 cout <<
"Transposed CSC mflop/sec: " <<
flops/ (1000 * (double) time) << endl;
219 Verify(yt_csc, yt_bicsb,
"BiCSB", n);
221 ofstream stats(
"stats.txt");
222 bicsb.PrintStats(stats);
228 cout <<
"reading input matrix in text(ascii)... " << endl;
229 ifstream infile(inputname.c_str());
231 char c = infile.get();
234 infile.getline(line,256);
238 infile >> m >> n >> nnz;
244 if (infile.is_open())
247 while (! infile.eof() && cnz < nnz)
249 infile >> triples[cnz].
row >> triples[cnz].
col >> triples[cnz].
val;
257 cout<<
"Reading matrix in ascii took " << ((double) (tend-tstart)) /1000 <<
" seconds" <<endl;
259 cout <<
"converting to csc and bicsb... " << endl;
264 cout <<
"# workers: "<< gl_nworkers << endl;
265 cout <<
"generating vectors... " << endl;
266 cout <<
"starting matvecs... " << endl;
278 for(
int i=0; i <
REPEAT; ++i)
284 long time = (t1-t0)/REPEAT;
285 cout<<
"CSC Trans" <<
" time: " << ((double) time) /1000 <<
" seconds" <<endl;
286 cout<<
"CSC Trans" <<
" mflop/sec: " <<
flops / (1000 * (double) time) <<endl;
288 bicsb_gespmvt<PTDD>(bicsb, xt.
getarr(), yt_bicsb.
getarr());
291 for(
int i=0; i <
REPEAT; ++i)
293 bicsb_gespmvt<PTDD>(bicsb, xt.
getarr(), yt_bicsb.
getarr());
297 time = (t1-t0)/REPEAT;
298 cout<<
"BiCSB Trans" <<
" time: " << ((double) time) /1000 <<
" seconds" <<endl;
299 cout<<
"BiCSB Trans" <<
" mflop/sec: " <<
flops / (1000 * (double) time) <<endl;
301 Verify(yt_csc, yt_bicsb,
"BiCSB", n);
int main(int argc, char *argv[])
float ColImbalance(const BiCsb< NT, IT > &A)
void Verify(Spvec< NT, IT > &control, Spvec< NT, IT > &test, string name, IT m)
void SetPointers(ITYPE *colpointers, ITYPE *rowindices, T *vals, ITYPE size, ITYPE rows, ITYPE cols, bool fortran)
void csc_gaxpy_trans(const Csc< T, ITYPE > &A, T *x, T *y)