On Dec 28, 2009, at 6:20 AM, Dag Sverre Seljebotn wrote:

> Stefan Behnel wrote:
>>
>> Michael G., 28.12.2009 03:31:
>>> Hrm, It seems that any sort of implemintation will be quite an  
>>> involved
>>> job.
>>>
>>> I have done some editing Nodes.py/toForFromStatNode by adding:
>>>    code.putln("#pragma omp parallel for")
>>>
>>> However on compilation openMP starts complaining about:
>>>    error: invalid exit from OpenMP structured block
>>> which occures at every "goto" statement inside the paralleled for.
>>>
>>> So basically, unless cython can be reworked to not utilize goto
>>> statements all over the place, openMP is not a feasible option.
>>
>> We could do it as for try-finally, where we basically pass through  
>> the
>> finally block in any case, and re-branch afterwards. I would expect  
>> that
>> gotos that stay inside of the OpenMP block should be fine.
>>
>> Is there a way to collectively exit from an OpenMP based loop in  
>> case of
>> an
>> error? (I guess that the semantics of that wouldn't be trivial to fix
>> anyway.)
>
> IIRC gotos only occur if you attempt to raise a Python exception,  
> which
> require the GIL.

There are a couple of other places gotos are used, for example for  
break, continue, and return statements (which have unclear semantics  
for OpenMP anyways). If statements use goto as well, but should stay  
within the block. However, by far the majority of gotos are exception  
handling (and it's hard to see how to do that another way...)

> A first implementation of Cython + OpenMP should target only nogil  
> mode,
> so one should require that OpenMP primitives are within a "with nogil"
> block, which should avoid the issue.
>
> There are ways of having OpenMP threads collectively exit on an  
> exception
> (like inserting a barrier) but I think its a waste of time to  
> discuss that
> until a no-gil, exception-less version is working.

I agree.

- Robert

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

Reply via email to