(j3.2006) Fw: (j3-members.2015) Question about DO CONCURRENT

Malcolm Cohen malcolm
Thu Feb 5 19:35:14 EST 2015


Van writes:
>That was my first reaction too.  Then I realized that A is not changed
>during any iteration.  Therefore, either B is assigned in every
>iteration, or not assigned in any.

Ah of course, thanks.  (Very easy to misread that code!)

Yes I realised some time ago that we didn't get the DO CONCURRENT specs "right"
in the sense of being able to tell at compile time whether a variable was
localised or global.  In

  DO CONCURRENT(...)
      IF (condition) THEN
         X = something
      END IF
      code using X
   END DO

when the loop has more than one iteration, you can make X local to the loop,
since condition has to be loop-invariant for this to be legal, and after
execution, the "outer" X either has its original value (if the condition was
false) or is undefined (if the condition was true).

HOWEVER, in the similar but different

    DO CONCURRENT(...)
      IF (condition) THEN
           X = something
           code using X
      END IF
      code that doesn't use X
   END DO

you cannot localise X, because if "condition" is true exactly once, the
assignment affects the "outer" X.  OTOH, if condition is true more than once,
you cannot execute in parallel without localising X.  Rather UGH.

Cheers,
-- 
................................Malcolm Cohen, Nihon NAG, Tokyo. 




More information about the J3 mailing list