public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/63938] New: OpenMP atomic update does not protect access to automatic array
@ 2014-11-18 16:37 paul.k.romano at gmail dot com
  2014-11-24  7:10 ` [Bug fortran/63938] " Joost.VandeVondele at mat dot ethz.ch
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: paul.k.romano at gmail dot com @ 2014-11-18 16:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63938

            Bug ID: 63938
           Summary: OpenMP atomic update does not protect access to
                    automatic array
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: paul.k.romano at gmail dot com

It appears that performing !$omp atomic update on an automatic array does not
protect access to the array. As an example, consider the following program:

program atomic

  integer :: i, x(1)

  x(1) = 0

!$omp parallel do
  do i = 1, 1000
    !$omp atomic
    x(1) = x(1) + 1
  end do
!$omp end parallel do

  print *, x

end program atomic

Compiling and running this program should result in the value 1000. Instead, it
results in an unpredictable value for x, indicating there is a race condition.
If you change x to a scalar or an allocatable array, it works fine and reports
the value 1000. Equivalent code in C does not produce a race condition. The
code gives the correct value when compiled with the Intel fortran compiler.

Information on my build of gcc:
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --disable-multilib
Thread model: posix


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-11-28 17:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 16:37 [Bug fortran/63938] New: OpenMP atomic update does not protect access to automatic array paul.k.romano at gmail dot com
2014-11-24  7:10 ` [Bug fortran/63938] " Joost.VandeVondele at mat dot ethz.ch
2014-11-24 10:39 ` jakub at gcc dot gnu.org
2014-11-24 10:39 ` jakub at gcc dot gnu.org
2014-11-24 23:09 ` jakub at gcc dot gnu.org
2014-11-28 13:37 ` jakub at gcc dot gnu.org
2014-11-28 17:05 ` jakub at gcc dot gnu.org
2014-11-28 17:11 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).