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

Daniel C Chen cdchen
Mon Feb 9 13:26:41 EST 2015


Malcolm said:
"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."

As for the solution, can we

1. Add syntax to DO CONCURRENT to allow users specify variables that need
to be localised, which is similar to OMP's PRIVATE/FIRSTPRIVATE clause. Or,

2. Change the following restriction (similar changes should apply to
Pointers, Allocatables)
"A variable that is referenced in an iteration shall either be previously
defined during that iteration, or shall not be defined or become undefined
during any other iteration. A variable that is defined or becomes undefined
by more than one iteration becomes undefined when the loop terminates. "
To
"A variable that is referenced in an iteration shall either be previously
defined during that iteration, or shall not be defined or become undefined
during any other iteration. A variable that is defined or becomes undefined
by one or more iterations becomes undefined when the loop terminates. "  --
This will allow compiler to localised x in the above example.

Thanks,

Daniel

XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran



From:	"Malcolm Cohen" <malcolm at nag-j.co.jp>
To:	"fortran standards email list for J3" <j3 at j3-fortran.org>
Date:	02/05/2015 19:35
Subject:	(j3.2006) Fw:  (j3-members.2015) Question about DO CONCURRENT
Sent by:	j3-bounces at mailman.j3-fortran.org



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.

_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20150209/10df4290/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.j3-fortran.org/pipermail/j3/attachments/20150209/10df4290/attachment.gif 



More information about the J3 mailing list