[Haskell-cafe] matrix computations based on the GSL

Alberto Ruiz aruiz at um.es
Sat Mar 18 12:03:54 EST 2006


The Atlas library (Linux_P4SSE2) seems to be 9x faster (!) than gslcblas in 
matrix multiplication: 

ghc-6.4.1 --make examples/pca.hs GSL/debuggslaux.o \
 -L$(LIBATLAS) -lcblas  /usr/lib/libgsl.a -latlas

$ time ./a.out
GSL Wrapper gsl_matrix_fscanf: 2 s
GSL Wrapper submatrix: 0 s
GSL Wrapper constant: 0 s
GSL Wrapper constant: 0 s
GSL Wrapper multiplyR (gsl_blas_dgemm): 1 s
GSL Wrapper vector_scale: 0 s
GSL Wrapper multiplyR (gsl_blas_dgemm): 0 s
GSL Wrapper vector_scale: 0 s
GSL Wrapper gsl_vector_add: 0 s
GSL Wrapper trans: 0 s
GSL Wrapper multiplyR (gsl_blas_dgemm): 4 s  <---(the atlas version)
GSL Wrapper vector_scale: 0 s
GSL Wrapper trans: 0 s
GSL Wrapper vector_scale: 0 s
GSL Wrapper gsl_vector_add: 0 s
GSL Wrapper toScalar: 0 s
GSL Wrapper eigensystem: 11 s
[337829.6562539419,253504.78675022084,209790.38118221355, etc....
real    0m17.630s
user    0m17.255s
sys     0m0.179s

So gsl+atlas+haskell is not that bad... Also, the 5000x785 matrix can now be 
loaded just in 2 seconds, using a wrapper for gsl_matrix_fscanf. We could 
also try to include some lapack or atlas-lapack routines.

Precompiled atlas for different processors can be downloaded from 

https://sourceforge.net/project/showfiles.php?group_id=23725

However, I have not yet been able to link them in interactive mode.

The latest version of the library (extremely provisional, I am currently 
working actively in it) can be obtained from:

darcs get http://dis.um.es/~alberto/GSLHaskell

Of course, any contribution or suggestion will be greatly appreciated, 
including code samples that "should work" with this kind of library, to be 
used as examples or tests.

Best regards,

Alberto

On Friday 17 March 2006 13:30, Alberto Ruiz wrote:
> On Thursday 16 March 2006 18:13, Frederik Eaton wrote:
> > Also, in my experiments (with matrix inversion) it seems,
> > subjectively, that Octave is about 5 or so times faster for operations
> > on large matrices. Presumably you've tested this as well, do you have
> > any comparison results?
>
> Frederik, you are right, in my machine Octave is at least 3x faster than
> gsl (v1.5). Too much, specially in a simple matrix multiplication, and I
> don't know why. See below the times measured in the C side for the PCA
> example.
>
> I will look into this...
>
> Alberto


More information about the Haskell-Cafe mailing list