This forum has been archived. All content is frozen. Please use KDE Discuss instead.

eigenproblem solver is super slow on Linux. Help !

Tags: None
(comma "," separated)
asilakov
Registered Member
Posts
2
Karma
0
Hi, I think I am missing something, can anybody help me?
Story: I have a (scientific) project that needs to do a ton of eigenproblem solving in a loop for a large rank matrices (>256) ("self-adjoint" and generally complex ).
Matlab just can not handle this due to memory issues. So, I have made a program using Eigen 3, having in mind running this with openMPI on our 64-processor cluster. On VS2012 Express on my laptop (i7, Win7) everything works jolly well, but when I tried to compile things on any of our Linux systems (also tried Virtual Machine Ubuntu on my laptop) instead of anticipated boost of performance I get 10x slower speed.
Here is a representative test code -- runs for about 4 ,729 s on Windows and 75,980s on Ubuntu (GCC) and a bit faster than Ubuntu on openSuse (Intel C++) ---

Code: Select all
// TestEigen.cpp
#include <time.h>
#include <Dense>
#include <iostream>

using namespace Eigen;

int main(void)
{
   const int nDim = 64;
   const int nSteps = 1000;
   clock_t tStart, tEnd;
   MatrixXcd Ham(64, 64);
   VectorXd Vval(64);
   MatrixXcd Vvec(64, 64);

        //make a dummy matrix
   for (int kk=0; kk<nDim; kk++)
      for (int bb=0; bb<nDim; bb++)
         Ham(kk, bb) = std::complex<double>(float(kk), 2.0);

        //make it self-adjoint
   Ham+=Ham.adjoint();

   SelfAdjointEigenSolver<MatrixXcd> ces;
   
        // TIC
   tStart=clock();
   for (int ii=0; ii<nSteps; ii++)
   {
      ces.compute(Ham);
      Vval=ces.eigenvalues();
      Vvec=ces.eigenvectors();
   }
       // TOC
   tEnd=clock()-tStart;

   std::cout<<" time " <<(float(tEnd))/CLOCKS_PER_SEC*1000 << " ms" << std::endl;
       return 1;
}

To compile I have used following code (GCC compiler is up to date, option "-o3" does not do much):
Code: Select all
g++ -I ../Eigen/ TestEigen.cpp -o3 -o TestEigen.exe



Then I have installed octave on the same Ubuntu machine and run similar code there. It took only 8.66 s !!!.
Code: Select all
clear all;
nDim = 64;
nSteps = 1000;

Ham = zeros(64, 64);

for ii=1:nDim
for jj=1:nDim
  Ham(ii, jj) = ii+2i;
  Ham(jj, ii) = ii-2i;
end
end
% only get time for diagonalisation procedure.
tic
for kk=1:nSteps
   [V, D]=eig(A+kk);
end
toc



can anybody help me understand where I loose the performance?
asilakov
Registered Member
Posts
2
Karma
0
OK, please forgive me, an old FartFortran user ... the optimization option should have been "-O3" (big O). Getting some other optimization options helped too. After looking at other threads on this forum, here is what gives me a whooping 1.8s speed:
Code: Select all
g++ -I ../Eigen/ -O3 -march=native -ffast-math -funroll-loops -ggdb3 TestEigen.cpp -o TestEigen.exe

Eat that, octave!!!


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]