[Numpy-discussion] Objected-oriented SIMD API for Numpy

David Cournapeau david at ar.media.kyoto-u.ac.jp
Wed Oct 21 02:56:52 EDT 2009


Hi Mathieu,

Mathieu Blondel wrote:
> Hello,
>
> About one year ago, a high-level, objected-oriented SIMD API was added
> to Mono. For example, there is a class Vector4f for vectors of 4
> floats and this class implements methods such as basic operators,
> bitwise operators, comparison operators, min, max, sqrt, shuffle
> directly using SIMD operations. You can have a look at the following
> pages for further details:
>
> http://tirania.org/blog/archive/2008/Nov-03.html (blog post)
>   

I am not sure how this could be applied to numpy case ? From what I can
understand, this cannot be directly applied to python: the described
changes are vm changes, and we cannot do anything at python vm level (I
would guess the python vm to be too primitive to implement this kind of
things anyway).

I don't see how the high level API at the assembly level (Mono.Simd)
would work either: the overhead of python and numpy to deal with 4 or 8
items in python would make this API useless from a speed POV.

Implementing some numpy internal code in SIMD, and having a 'object
oriented' C API for SIMD would indeed be nice - gcc provides SSE
intrinsics, as well as visual studio (although the later seems quite
buggy if I believe this link:
http://www.virtualdub.org/blog/pivot/entry.php?id=162), which would make
this in principle relatively easy.

This is only my opinion (read other numpy dev may disagree), but I think
that the numpy C code should be cleaned up before adding this kind of
features: there is still too much coupling between the pure C core and
the python machinery. Also, any use of SIMD code should be done at
runtime IMHO (so that one binary can be used on multiple architectures),
which has some issues on its own from a cross platform POV.

David



More information about the NumPy-Discussion mailing list