Boost logo

Ublas :

From: Manuel González Castro (iinmgc00_at_[hidden])
Date: 2008-01-11 13:02:17


Hi,

> Can anybody tell me the reason, why Matlab get faster, the bigger the
> program gets?

In the Win32 binary distribution of Matlab you can find the shared
libraries for ATLAS (atlas_P4.dll, atlas_Athlon.dll ...), an optimized
implementation of BLAS. That may be why Matlab beats your code for big
matrix/vectors. For small sizes, the slow flow control and function
calls of Matlab make them slower.

> Is there some general comparison between C++/Boost and Matlab.

You cannot make a "general" comparison between Matlab and C++/ublas
since it will highly depend on the type of computations. A benefit of
ublas is that you can tune or optimize a particular routine if it is a
bottleneck for your code (if have done that for some sparse matrix
routines). In Matlab you cannot do that.

As others members of this list have suggested, you can use the BLAS
bindings of ublas to link an optimized version of BLAS like ATLAS,
gotoblas, Intel MKL, AMD ACML, etc.

Another solution is to use sparse storage, if your matrix sparse.
According to my experience with ublas and linear solvers, sparse storage
may be faster than dense storage even for small sizes (n=20) and low
percentage of non-zeros (60%). In my simulation software based on ublas,
sparse computations run 10-100 times faster than Matlab sparse
computations.

Best regards,
Manuel