[Numpy-discussion] Fast threading solution thoughts

Dag Sverre Seljebotn dagss@student.matnat.uio...
Thu Feb 12 05:34:42 CST 2009


Francesc Alted wrote:
> A Thursday 12 February 2009, Dag Sverre Seljebotn escrigué:
>   
>> A quick digression:
>>
>> It would be interesting to see how a spec would look for integrating
>> OpenMP natively into Cython for these kinds of purposes. Cython is
>> still flexible as a language after all.
>>     
>
> That would be really nice indeed.
>
>   
>> Avoiding language bloat is 
>> also important, but it is difficult to know what kind of balance can
>> be struck before some kind of spec is worked out. Has anyone managed
>> to use OpenMP with Cython code in a nice way already?
>>
>> I couldn't do any work on it right now but it could sit in the
>> pipeline for the year to come. Also I have a strong feeling that
>> making the spec and language design issues would take more time than
>> the actual implementation of it anyway.
>>     
>
> I tend to aggree with you.  As a matter of fact, doing (efficient) 
> parallelism is a very hairy thing and understanding all (or just most 
> of them) of its issues maybe the real problem for doing the port 
> (unless one can find some direct way to translate OpenMP directives 
> from Cython code to the C code, which would be wonderful).
>   
This is what I'm thinking. Example: This in Cython:

with cython.openmp.parallell(locals="a,b"): # implies nogil?
   for i in cython.openmp.range(0, 10):
      ...

could simply translate into emitting the right #pragmas in generated C 
at the right locations.

FYI, I am one of the core Cython developers and can make such 
modifications in Cython itself as long as there's consensus on how it 
should look on the Cython mailing list.  My problem is that I don't 
really know OpenMP and have little experience with it, so I'm not the 
best person for creating a draft for how such high-level OpenMP 
constructs should look like in Cython.

Dag Sverre


More information about the Numpy-discussion mailing list