>> With OpenMP one needs to list which function-local variables are >> thread-local and which are global, so at the very least Cython's >> variable >> name mangling must be coupled with OpenMP directives somehow. > > Good point. Given that the name mangling is deterministic, it would at > least provide a workable (if not very clean) possibility.
We must also take auxillary variables for the buffer protocol into account. Possibility of rebinding names makes this even more complex. When Cython supports closures, it will be easy to implement OpenMP constructs in using Python threads. OpenMP is not a big API. We can basically put a for-loop we want to run in parallel inside a closure, and apply a decorator to the closure. The decorator would be similar to an OpenMP pragma. I.e. the decorator function will run the closure in multiple threads, and schedule the work. So all we need to do is to write some appropriate decorator functions. What makes OpenMP so syntactically convinient is actually that it adds a form of "closures" to C and Fortran (i.e. the block on which the pragma is applied can be seen as a closure). Apple's GCD also works by adding "closures" (anonymous blocks) to Objective-C. So with closure-support already in Cython, the majority of the work involved in implementing something like OpenMP or GCD is already done. It will be easier to implement the rest of OpenMP in Cython than to make Cython use the OpenMP support in the C compiler. So basically let's just forget about OpenMP now. Spend the effort on completing closure support instead. Sturla Molden _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
