[pypy-dev] Vectorizing numpy traces

Maciej Fijalkowski fijall at gmail.com
Tue Feb 24 19:36:07 CET 2015


before I answer, any clue why I get:

Google Chrome's connection attempt to postimg.org was rejected. The
website may be down, or your network may not be properly configured.

On Tue, Feb 24, 2015 at 8:18 PM, Richard Plangger <rich at pasra.at> wrote:
> hi,
>
> i'm currently trying to find a way to generate simd code for python
> loops that operate on numpy arrays.
> The IRC is quite busy so I think I'd rather post it as an email...
>
> I have familiarized myself with pypy and read most of the docs and read
> the code in the metainterp to understand how the traces are built.
>
> I translated pypy with --withmod-micronumpy enabled (installed numpy
> pypy fork in an virtual env) and gave the jitviewer a try.
> Here is a sample program that does not really make sense, but I think it
> would contain opportunity to generate SIMD instructions.
>
> ```
> import numpy
> def invoke():
>     a = numpy.zeros(1024)
>     b = numpy.zeros(1024)
>     c = numpy.zeros(1024)
>     # (2)
>     for i in range(0,1024):
>         c[i] = a[i] + b[i]
>     # (3)
>     c = a + b
>
> if __name__ == '__main__':
>     i = 0
>     # (1)
>     while i < 500:
>         invoke()
>         i += 1
> ```
>
> Here is the trace of invoke visible in jitviewer (uploaded to
> https://postimg.org/image/kbntluw55/full/).
>
> Here are some questions I have that would really help me to get going:
>
> (1) Is there a better way to get loops hot?
>
> (2) I cannot really figure out what all those trace/loop parameters are.
> obviously i can guess some but most of them do not really make sense to
> me. Am I missing some settings to be able to display more information
> for the trace?
>     In addition to that I do not really see any chance to generate a
> simd loop for (2). Every array access is (arguably) guarded by an array
> index overflow and I think to skip that check would be invalid.
>
> (3) There is no trace generated for this instruction? Does this
> internally call a c function?
>
> (4) What in our opinion makes sense to vectorize with simd instructions?
> Could you provide some sample loops/code (ranging from simple to complex
> loops)?
>
> I would really appreciate any help and/or push into the right direction.
>
> Best,
> Richard
>
>
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> https://mail.python.org/mailman/listinfo/pypy-dev
>


More information about the pypy-dev mailing list