[pypy-dev] Floating point computation

Ilya Osadchiy osadchiy.ilya at gmail.com
Sat Jul 9 11:19:26 CEST 2011


>>> The Translation and JIT backend for PyPy may be able to allow Python
>>> programmers to use SIMD instructions directly from Python.
>>
>> We kind of want to do that automatically for numpy operations.
>
> Can all basic SIMD instructions be mapped to numpy array operations?
> If so, why doesn't numpy already use them?  (Or does it?)
>

I think CPython's numpy may be compiled with auto-vectorization and
therefore use SIMD. It also has optional dependency for lapack, and
AFAIK most lapacks use SIMD.

>
> And if not, then is there some existing C extension module for CPython
> that exposes them somehow?  Of course CPython cannot hope for
> impressive speedups with such an extension module, but such a module
> in PyPy could be JITted and give massive speed benefits.
>

I think that JITting element-wise operations to SIMD assembly is
feasible. Logically you can see it like:
normal JIT => loop unroll => instruction reordering => substitute N
instructions of same type with 1 simd instruction
Of course there are problems (loads and stores need special treatment,
not every instruction has simd equivalent, register allocation
differs, etc)

But I think the bigger problem is JITting SIMD for things like matrix
multiply and fft, which are more than a single loop and the order of
calculations may seriously differ between scalar and simd versions.


More information about the pypy-dev mailing list