public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "paul.k.romano at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/63938] New: OpenMP atomic update does not protect access to automatic array Date: Tue, 18 Nov 2014 16:37:00 -0000 [thread overview] Message-ID: <bug-63938-4@http.gcc.gnu.org/bugzilla/> (raw) 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
next reply other threads:[~2014-11-18 16:37 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-11-18 16:37 paul.k.romano at gmail dot com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-63938-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).