This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/80304] Warn about variable redefinition in do-concurrent
- From: "chinoune.mehdi at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 04 Apr 2017 19:02:12 +0000
- Subject: [Bug fortran/80304] Warn about variable redefinition in do-concurrent
- Auto-submitted: auto-generated
- References: <bug-80304-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80304
Chinoune <chinoune.mehdi at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #41117|0 |1
is obsolete| |
--- Comment #10 from Chinoune <chinoune.mehdi at hotmail dot com> ---
Created attachment 41129
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41129&action=edit
modified test-program
(In reply to Thomas Koenig from comment #9)
> What you are doing is
>
> DO CONCURRENT( i=0:1 ,j=0:1)
> a = a + add(i,j,abs(i-j))
> b = b + add2(i,j,abs(i-j))
> END DO
>
> This causes the variables a and b to be defined multiple
> times in the loop.
>
> In the standard, this is given in 8.1.6.7 of J3/10-007:
>
> 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.
>
> Conceptually, when parallelizing, you cannot depend on a having
> any specific value during the loop execution, so the program
> might read a in one thread, have it changed by another thread,
> then add the value to it and store it back, losing what
> was done by the other thread.
>
> You cannot do a sum like this with DO CONCURRENT. In OpenMP terms,
> what you are attempting a reduction.
>
> It would be nice to warn about this, though.
1- Why 'b' has been calculated correctly while 'a' hasn't ?! .the only
difference between the two functions is ( +1. )
2- I attached a new modified test and it fails.
3- The test-program works well with gfortran-5 gfortran-6 and Intel Fortran
2017.