[Cython] OpenMP support

Sturla Molden sturla at molden.no
Tue Mar 8 16:10:35 CET 2011

Den 08.03.2011 11:34, skrev mark florisson:
> However, considering that OpenMP has quite a few constructs,

No, OpenMP has very few contructs, not quite a few. And most of them are 
not needed, nor wanted, because the functionality is covered by the 
Python language (such as scoping rules).

I.e. we do not need -- nor want -- things like private, shared, 
firstprivate or lastprivate in Cython, because the scope of variables 
inside closures are already covered by Python syntax. OpenMP is just 
making up for the lack of closures in C here.

We don't need to implement #pragma omp critical, because we have 

We don't need to implement #pragma omp atomic, because we have the GIL 
(as well as OS and compiler support for atomic operations).

#pragma omp barrier becomes a butterfly of threading.Event.


There is not really much left to implement. We need a decorator to 
launch closures as parallel blocks (trivial) and classes to do static, 
dynamic and guided load balancing (trivial as well).

It is hardly a page of code to write, just a handful of small classes, 
once Cython has closures working properly.


More information about the cython-devel mailing list