Den 11.03.2011 01:46, skrev Robert Bradshaw:
On a slightly higher level, are we just trying to use OpenMP from
Cython, or are we trying to build it into the language?

OpenMP is a specification, not a particular implementation. Implementation for Cython should either be compiler pragmas or a library.

I'd like it to be a library, as it should also be usable from Python. I have made some progress on the library route, depending on Cython's closures.

nogil makes things feel a bit awkward, though.

We could for example imagine code like this:

    with openmp.ordered(i):
<suite>

Context managers are forbidden in nogil AFAIK. So we end up with ugly hacks like this:

    with nogil:
       if openmp._ordered(i): # always returns 1, but will synchronize
<suite>

Would it be possible to:

- Make context managers that are allowed without the GIL? We don't need to worry about exceptions, but it should be possible to short-circuit from __enter__ to __exit__.

- Have cpdefs that are callable without the GIL?

This would certainly make OpenMP syntax look cleaner.


Sturla























_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to