Hi,

rahul garg top-posted (just like Gary Furnish did before):
>> On Sat, Jun 21, 2008 at 11:51 AM, Dag Sverre Seljebotn wrote
>>> In dev1 days for SAGE a @parallel decorator for functions was
>>> demonstrated. So:
>>>
>>> P> @parallel
>>> P> def f(x): return 2*x
>>> ...
>>> P> f([1,2,3])
>>> [2, 4, 6]
>>>
>>> Where each of the multiplications would happen in parallel using
>>> PyProcessing. However, I don't think any Cython support is really needed
>>> for this (except for decorator support :-)).
>>>
>>> So: I like PyProcessing but there's no need to build anything into Cython
>>> for that. A parallel decorator could work for OpenMP though (at least if
>>> the function is also declared inline etc.)
>
> Well actually one usage scenario I had in mind was numpy and numerical code.
>
> Think about the following code :
> for i in xrange(m): x[i] = y[i] + z[i]
>
> Now in this case its a lot better to have parallel loops. First, if x,y,z
> have proper type declarations, lets say they are ndarray, then a parallel
> loop can easily be converted to C code with OpenMP.  Since we are accessing
> ndarray, and assuming compiler knows how to convert that to direct array
> access, then compiler can generate very efficient code. There will be no GIL
> acquire/release within the loop.
>
> This scenario is not handled easily using the decorator approach.

I updated the Wiki accordingly.

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to