Error Message: "Jump out of OpenMP structured block not allowed"

Error Message: "Jump out of OpenMP structured block not allowed"

Hi everybody,

Is it possible to jump out of OpenMP structured block? Here is an example:

...
#pragma omp parallel for
for( int i = 0; i < 512; i++ )
{
...
if( i == 255 )
break;
...
}
...

Best regards,
Sergey

8 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

It is not allowed by OpenMP specification. Cancelation is not in specification yet.

I guees you can try tasks from OpenMP 3.0

--Vladimir

Quoting Michael Klemm (Intel)...
The only options is to have an empty if statement, when your abort condition becomes to true so that the loop does not do anything and executes as fast as possible to its natual end.
...
Until we have added user cancellation to the OpenMP specification (we are making progress here), there is no other option.
...

Thank you, Michael. A solution based on'If-Else' will work.

Best regards,
Sergey

I think you can set the loop control variable toa termination value.

for(int i=0; i < endVal; ++i)
{
...
if(bailOut)
{
i=endVal;
continue;
}
...
}

Although the running thread may have a different start val from 0 and/or may have a different endVal from endVal, no thread will (in this case) have an endVal larger than original endVal.

(This is valid for C/C++ and not valid for FORTRAN as it loops differently)

Jim Dempsey

www.quickthreadprogramming.com

Quoting jimdempseyatthecove...
(This is valid for C/C++ and not valid for FORTRAN as it loops differently)

Jim Dempsey

I'm researching thisfor a C/C++ application only. Thanks, Jim.

I suppose you make bailOut a shared variable (does it need to be set in a critical?), so each thread should receive the flag as it reaches that point. If your OpenMP doesn't complain about this, the compiler should avoid any optimizations based on i not being touched by your loop body. However, OpenMP implementations are notoriously poor at flagging violations which will produce unexpected results.

Hi all,

Modifying the loop counter is also prohibited by teh OpenMP specification. It works in most implementations, but it makes the program non-conforming and might break the code with different compiler releases.

Cheers,
-michael

Quoting Michael Klemm (Intel)...It works in most implementations, but it makes the program non-conforming and might break the code

[SergeyK] That's my primary concern...

with different compiler releases...

Cheers,
-michael

Thanks to everybody!

Best regards,
Sergey

Accedere per lasciare un commento.