[Numpy-discussion] parallel loop annotations

Stéfan van der Walt stefan@sun.ac...
Wed Jun 18 17:54:46 CDT 2008


2008/6/18 Rahul Garg <garg1@ualberta.ca>:
> I want to add a similar annotation to Python
> example usage :
>
> "pragma parallel for"
> for i in xrange(m): a[i] = b[i]*c[i]
>
> The interpreter ignores such strings and the code will of course
> execute serially but such strings can potentially be used by compilers.
> Any thoughts on this? What form of annotations would you like to see?
> Is it pythonic?

Is the idea to have the annotations completely separated from the
executed source?  Otherwise, I'd just as well make it implicit:

with parallel(i):
    for i in range(m):
        a[i] = b[i] * c[i]

That is also roughly the form that Fernando implemented for IPython1,
and is very intuitive.

What have you been using for other annotations so far?  Python itself
supports at least one other annotation:

# encoding: utf-8

so maybe

# pragma: parallel for

could work.

Regards
Stéfan


More information about the Numpy-discussion mailing list