[Numpy-discussion] libflatarray

Eelco Hoogendoorn hoogendoorn.eelco at gmail.com
Thu Feb 13 09:47:34 EST 2014


As usual, 'it depends', but a struct of arrays layout (which is a virtual
necessity on GPU's), can also be advantageous on the CPU. One rarely acts
on only a single object at a time; but quite often, you only work on a
subset of the objects attributes at a time. In an array of structs layout,
you are always pulling the whole objects from main memory into the cache,
even if you only use a single attribute. In a struct of arrays layout, we
can do efficient prefetching on a single attribute when looping over all
objects.


On Thu, Feb 13, 2014 at 3:37 PM, Sturla Molden <sturla.molden at gmail.com>wrote:

> Neal Becker <ndbecker2 at gmail.com> wrote:
> > I thought this was interesting:
> >
> > http://www.libgeodecomp.org/libflatarray.html
>
> This is mostly flawed thinking. Nowadays, CPUs are much faster than memory
> access, and the gap is just increasing. In addition, CPUs have hierarchical
> memory (several layers of cache). Most algorithms therefore benefit from
> doing as much computation on the data as possible, before reading more data
> from RAM. That means that an interleaved memory layout is usually the more
> effective.  This of course deepends on the algorithm, but an array of
> structs is usually better than a struct of arrays.
>
> Sturla
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140213/f7959d45/attachment.html>


More information about the NumPy-Discussion mailing list