mardi 4 octobre 2016

armadillo linear sparse system solver using LAPACK and SuperLU

I tried to solve the sparse linear system using armadillo library.

 #include <iostream>
 #include<armadillo>
 using namespace std;
 using namespace arma;

int main(int argc, char** argv) {

int no_examples = 5000;
sp_mat A = sprandu<sp_mat>(no_examples,no_examples,0.7);
vec b = randu<vec>(no_examples);
wall_clock timer;
double t;
timer.tic();
vec x1 = spsolve(A, b,"superlu");
t= timer.toc();
cout<<"Elapsed time is:"<<t<<endl;
}

I compiled the program using g++ demo.cpp -O3 -I/usr/include/armadillo_bits -DARMA_DONT_USE_WRAPPER -lsuperlu -lopenblas -llapack. The run time obtained with superlu option is about 8.5 seconds. When the system system is solved with LAPACK option in spsolve see here, run time is 4.01 seconds. Can somebody explain why:

  1. Solving the same system of equations takes longer by SuperLu than LAPACK? my hunch is that they may be using different algorithms to solve the sparse linear system. Any other idea is welcomed!

Aucun commentaire:

Enregistrer un commentaire