[SciPy-user] Getting the right numerical libraries for scipy

David Cournapeau david@ar.media.kyoto-u.ac...
Fri Apr 3 10:03:46 CDT 2009


josef.pktd@gmail.com wrote:
> On Fri, Apr 3, 2009 at 10:12 AM, David Cournapeau
> <david@ar.media.kyoto-u.ac.jp> wrote:
>   
>> David Cournapeau wrote:
>>     
>>> I think it will depend on your dot implementation (does it uses atlas or
>>> other heavily optimized implementation). This is to be taken with a
>>> (big) grain of salt since I don't know much about sparse matrices, but
>>> if the distribution is purely random, then I can see how sparse matrices
>>> would be much slower than contiguous arrays. Memory access is often the
>>> bottleneck for simple FPU operations on big data, and random memory
>>> access just kills access performances  (can be order of magnitude slower
>>> - a cache miss on modern CPU costs ~ 250 cycles).
>>>       
>
> I think, csr and csc matrices are row and column contiguous in the
> non-zero elements, so the position of the elements might not matter so
> much for random memory access.
>   

Yes, they are contiguous - but the parts which are contiguous are not
"homogeneous". For example, if you want to compute the matrix product of
two matrices of size (n, m) and (m, k), knowing the shape is  enough to
split your computation to the best size for the fast kernels on a given
machine. For sparse matrices, not so much: you need to read the indexes
as well, and it becomes much more complex to optimize this.

cheers,

David


More information about the SciPy-user mailing list