#include #include #include #include // Libra #include // C and C++ API // Util #include "../Util/LoadMtx.h" int main(int argc, char** argv) { std::cout << "*******************************************" << std::endl << std::endl; std::cout << "SpMV: Sparse Matrix * Vector multiplication" << std::endl << std::endl; std::cout << "*******************************************" << std::endl << std::endl; if (libra_Init(argc, argv) != 0) return 1; libra_SetDefaultDataType(GFLOAT64); // Load a matrix const std::string exeName(_getcwd(NULL, 0)); const size_t pos = exeName.rfind("Libra SDK"); const std::string dataPath = exeName.substr(0, pos+9) + std::string("\\data\\"); const std::string filename = dataPath + std::string("11948.mtx"); gVar A = LoadMatrix(filename.c_str()); const int iterCount = 1000; // Create a vector x with zeros. gVar x = zeros(A.rowCount(), 1); std::cout << "\nA * x = b" << std::endl; std::cout << "A = ["<< A.rowCount() << ","<< A.columnCount() << "], non-zero elements: " << A.elementCount() << std::endl; std::cout << "x = ["<< x.rowCount() << "]\n" << std::endl; gVar y; double startTime = libra_GetTime(); for (int i=0;i