Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
17 Views

BLOCK, END BLOCK statements not threadsafe

I have run accross random results using a BLOCK, END BLOCK contstruct. My application was multi-threaded. When I move the local declarations into the parent procedure and remove the BLOCK construct the results become repeatable.

I am using implied AUTOMATIC for the project via /Qopenmp.

The help file does not mention this limitation of your implementation. Is it a bug or intentional ?

Using Visual Fortran Compiler XE 15.0.5.280.

0 Kudos
7 Replies
Highlighted
17 Views

IVF document:

...
A BLOCK construct cannot appear inside a structured block of an OpenMP* directive.
...

I do not know why there is this restriction.

Jim Dempsey

0 Kudos
Highlighted
Employee
17 Views

It appears perhaps F2008 Standard related but I’m not finding supportive details so I’ll inquire w/Development. I expect it relates to this error that will be issued when the restriction is violated:

error #7936: This statement or directive is not permitted within the block of an OpenMP* WORKSHARE or OpenMP* PARALLEL WORKSHARE directive.

0 Kudos
Highlighted
Employee
17 Views

Here's some clarification. Correction, it is not F2008 Standard related rather it relates to a lack of meaning in terms of the OpenMP API.

The Developers indicate support could be implemented in the future. I’m told, when the OpenMP API documents what it means to have a BLOCK inside an OMP directive. It’s a question of variable scoping – a local inside the BLOCK inside an OMP block couldn’t appear on the SHARED etc lists of the OMP directive – they’re not visible in that scope.  If that just means all BLOCK locals inside OMP are PRIVATE, end of discussion, then that’s a simple definition.

0 Kudos
Highlighted
New Contributor II
17 Views

If all BLOCK locals were private inside an OMP construct then my application should have worked. I was not attempting to share any of them. So the BLOCK construct should work OK in a recursive routine provided the routine is not inside an openMP construct ?
0 Kudos
Highlighted
17 Views

Andrew,

You might have success in cutting the block out of the code and replacing it with:

   call MyBlock()

and make MyBlock a contains subroutine.

This will place the code out of line, but it may permit you to do what you want.

Jim Dempsey

0 Kudos
Highlighted
17 Views

>>So the BLOCK construct should work OK in a recursive routine provided the routine is not inside an openMP construct ?

Yes

Note, the contains subroutine will permit the subroutine to see the containing procedures variables without passing them as dummy's

Jim Dempsey

0 Kudos
Highlighted
Beginner
17 Views

I think there have been a number of bugs with block contructs, possibly including:

  1. final routines not called when variable goes out of scope (DPD200379085 fixed in 16 update 2)
  2. allocatable variables not deallocated when variable goes out of scope
  3. variables in block construct being saved (DPD200408259 not fixed: https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/616394 ). Using automatic attribute extension may be aworkaround.

Nick

0 Kudos