Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

When are pure procedures not concurrency safe?

martin_upsdellagrese
539 Views
I receive a message from the guided autoparallizer that I should insert "!dir$ attributes concurrency_safe : profitable" to enable the autoparallizer to parallelize the loop. I have declared the subroutine as Pure which I understood to declare it as being safe to use in a parallel loop as it decalres that the only items changed within the subroutine are dummy variables declared with intent(out) or intent(inout).

Are there otherthings I should be looking out for?
0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
539 Views
Show us a code snip of your loop .and. the declarations of the variables used in the loop, plus the subroutine(s) that are giving you problems.

Many things can affect parallelization. When there is uncertainty, the compiler will remove vectorization. If your problematic subroutines are being passed scalars (and for functions returning scalar) it may be a candidate to flag as elemental as well as pure.

BTW

The Intel Developer's Forum (conference) is starting tomorrow. Many of the respondants to this forum message may be preparing to go and/or may not reply to your message(s) until next weekend. Be patient.

Jim Dempsey

0 Kudos
TimP
Honored Contributor III
539 Views
I receive a message from the guided autoparallizer that I should insert "!dir$ attributes concurrency_safe : profitable" to enable the autoparallizer to parallelize the loop. I have declared the subroutine as Pure which I understood to declare it as being safe to use in a parallel loop as it decalres that the only items changed within the subroutine are dummy variables declared with intent(out) or intent(inout).

Are there otherthings I should be looking out for?

This compiler message appears to be concerned more with performance than safety of threading. If the suggested directive does result in parallelization, you should test to see whether it produces desired performance.
You should be looking out for the usual questions; would there be good thread locality of data, are the loops sufficiently long, can parallelization be performed without removing vectorization, ...... ?
0 Kudos
Steven_L_Intel1
Employee
539 Views
Giving a procedure the PURE attribute specifies that it does not have side-effects, but this does not make it concurrency-safe. For example, a PURE procedure may still use static storage for local variables, though if you have enabled /Qparallel, it will use the stack instead. More to the point, PURE does not safeguard against unsynchronized reads of memory elsewhere in the program, which CONCURRENCY_SAFE specifies.
0 Kudos
Reply