int main(int argc, char* argv[]) { if (argc == 1) { std::cerr << argv[0] << " <matrix> [Num threads]" << std::endl; exit(1); } init_paralution(); if (argc > 2) { set_omp_threads_paralution(atoi(argv[2])); } info_paralution(); LocalVector<double> x; LocalVector<double> rhs; LocalMatrix<double> mat; mat.ReadFileMTX(std::string(argv[1])); mat.info(); x.Allocate("x", mat.get_nrow()); rhs.Allocate("rhs", mat.get_nrow()); x.info(); rhs.info(); rhs.Ones(); mat.Apply(rhs, &x); std::cout << "dot=" << x.Dot(rhs) << std::endl; mat.ConvertToELL(); mat.info(); mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); mat.info(); rhs.Ones(); mat.Apply(rhs, &x); std::cout << "dot=" << x.Dot(rhs) << std::endl; stop_paralution(); return 0; }
int main(int argc, char* argv[]) { if (argc == 1) { std::cerr << argv[0] << " <matrix> [Num threads]" << std::endl; exit(1); } init_paralution(); if (argc > 2) { set_omp_threads_paralution(atoi(argv[2])); } info_paralution(); // int ii; LocalVector<double> x; LocalVector<double> rhs; LocalMatrix<double> mat; struct timeval ti1,ti2;//timer mat.ReadFileMTX(std::string(argv[1])); mat.info(); x.Allocate("x", mat.get_nrow()); rhs.Allocate("rhs", mat.get_nrow()); x.info(); rhs.info(); rhs.Ones(); gettimeofday(&ti1,NULL); /* read starttime in t1 */ mat.Apply(rhs, &x); gettimeofday(&ti2,NULL); /* read endtime in t2 */ fflush(stderr); fprintf(stderr, "\nTime cost host spmv code microseconds: %ld microseconds\n", ((ti2.tv_sec - ti1.tv_sec)*1000000L +ti2.tv_usec) - ti1.tv_usec ); std::cout << "\ndot=" << x.Dot(rhs) << std::endl; mat.ConvertToBCSR(); mat.info(); mat.MoveToAccelerator(); x.MoveToAccelerator(); rhs.MoveToAccelerator(); mat.info(); rhs.Ones(); // exit(1); gettimeofday(&ti1,NULL); /* read starttime in t1 */ mat.Apply(rhs, &x); gettimeofday(&ti2,NULL); /* read endtime in t2 */ fflush(stderr); fprintf(stderr, "\nTime cost for accelerator spmv microseconds: %ld microseconds\n", ((ti2.tv_sec - ti1.tv_sec)*1000000L +ti2.tv_usec) - ti1.tv_usec ); std::cout << "\ndot=" << x.Dot(rhs) << std::endl; stop_paralution(); return 0; }