public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49897] New: nesting lastprivate gives incorrect result
@ 2011-07-29  8:23 markflorisson88 at gmail dot com
  2011-07-29 15:38 ` [Bug middle-end/49897] " jakub at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: markflorisson88 at gmail dot com @ 2011-07-29  8:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

           Summary: nesting lastprivate gives incorrect result
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: markflorisson88@gmail.com


Nesting lastprivate doesn't work in gcc 4.5: the inner loop has a lastprivate
variable that is then also declared lastprivate on the outer loop (otherwise
there would be a race), but the result after the loop is always 0. It works
fine in gcc 4.2 to 4.4.

################################

SSH [1] [10:13] ~  ➤ gcc-4.5 -v
Using built-in specs.
COLLECT_GCC=gcc-4.5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.5.1/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.5.1-7ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.5 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-gold
--with-plugin-ld=ld.gold --enable-objc-gc --enable-targets=all --disable-werror
--with-arch-32=i686 --with-tune=generic --enable-checking=release
--build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.5.1 (Ubuntu/Linaro 4.5.1-7ubuntu2) 
SSH [0] [10:13] ~  ➤ gcc-4.5 -g -Wall -fopenmp -lgomp testomp.c
SSH [0] [10:14] ~  ➤ ./a.out
x=9, y=0, sum = 450
SSH [0] [10:14] ~  ➤ cat testomp.c
#include <stdio.h>

int main(void) {
    int i = 0, j = 0, x, y, sum = 0;
    x = 0;


    #pragma omp parallel reduction(+:sum)
    {
        #pragma omp for firstprivate(x) lastprivate(x, y)
        for (i = 0; i < 10; i++) {
            x = i;

            y = 0;
            #pragma omp parallel reduction(+:sum)
            {

                #pragma omp for firstprivate(y) lastprivate(y)
                for (j = 0; j < 10; j++) {
                    y = j;
                    sum += y;
                }
            }
        }
    }
    printf("x=%d, y=%d, sum = %d\n", x, y, sum);
    return 0;
}


SSH [0] [10:15] ~  ➤ gcc-4.4 -g -Wall -fopenmp -lgomp testomp.c
SSH [0] [10:15] ~  ➤ ./a.out
x=9, y=9, sum = 450


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

* [Bug middle-end/49897] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
@ 2011-07-29 15:38 ` jakub at gcc dot gnu.org
  2011-07-29 15:41 ` [Bug middle-end/49897] [4.5/4.6/4.7 Regression] " jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-29 15:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
      Known to work|                            |4.4.6
           Keywords|                            |openmp, wrong-code
   Last reconfirmed|                            |2011.07.29 15:38:18
          Component|c                           |middle-end
                 CC|                            |jakub at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1
   Target Milestone|---                         |4.5.4
      Known to fail|                            |4.5.3

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-29 15:38:18 UTC ---
Caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145338
I have a fix.


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

* [Bug middle-end/49897] [4.5/4.6/4.7 Regression] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
  2011-07-29 15:38 ` [Bug middle-end/49897] " jakub at gcc dot gnu.org
@ 2011-07-29 15:41 ` jakub at gcc dot gnu.org
  2011-07-29 15:42 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-29 15:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-29 15:40:20 UTC ---
*** Bug 49898 has been marked as a duplicate of this bug. ***


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

* [Bug middle-end/49897] [4.5/4.6/4.7 Regression] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
  2011-07-29 15:38 ` [Bug middle-end/49897] " jakub at gcc dot gnu.org
  2011-07-29 15:41 ` [Bug middle-end/49897] [4.5/4.6/4.7 Regression] " jakub at gcc dot gnu.org
@ 2011-07-29 15:42 ` jakub at gcc dot gnu.org
  2011-07-29 16:06 ` markflorisson88 at gmail dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-29 15:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-29 15:41:36 UTC ---
Created attachment 24865
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24865
gcc47-pr49897.patch

Fix.


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

* [Bug middle-end/49897] [4.5/4.6/4.7 Regression] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
                   ` (2 preceding siblings ...)
  2011-07-29 15:42 ` jakub at gcc dot gnu.org
@ 2011-07-29 16:06 ` markflorisson88 at gmail dot com
  2011-07-29 17:47 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: markflorisson88 at gmail dot com @ 2011-07-29 16:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

--- Comment #4 from markflorisson88 <markflorisson88 at gmail dot com> 2011-07-29 16:05:50 UTC ---
(In reply to comment #3)
> Created attachment 24865 [details]
> gcc47-pr49897.patch
> 
> Fix.

Wow, thanks a lot for the quick fix!


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

* [Bug middle-end/49897] [4.5/4.6/4.7 Regression] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
                   ` (3 preceding siblings ...)
  2011-07-29 16:06 ` markflorisson88 at gmail dot com
@ 2011-07-29 17:47 ` jakub at gcc dot gnu.org
  2011-07-29 17:49 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-29 17:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-29 17:45:46 UTC ---
Author: jakub
Date: Fri Jul 29 17:45:42 2011
New Revision: 176945

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176945
Log:
    PR middle-end/49897
    PR middle-end/49898
    * omp-low.c (use_pointer_for_field): If disallowing copy-in/out
    in nested parallel and outer is a gimple_reg, mark it as addressable
    and set its bit in task_shared_vars bitmap too.

    * testsuite/libgomp.c/pr49897-1.c: New test.
    * testsuite/libgomp.c/pr49897-2.c: New test.
    * testsuite/libgomp.c/pr49898-1.c: New test.
    * testsuite/libgomp.c/pr49898-2.c: New test.

Added:
    trunk/libgomp/testsuite/libgomp.c/pr49897-1.c
    trunk/libgomp/testsuite/libgomp.c/pr49897-2.c
    trunk/libgomp/testsuite/libgomp.c/pr49898-1.c
    trunk/libgomp/testsuite/libgomp.c/pr49898-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/libgomp/ChangeLog


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

* [Bug middle-end/49897] [4.5/4.6/4.7 Regression] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
                   ` (4 preceding siblings ...)
  2011-07-29 17:47 ` jakub at gcc dot gnu.org
@ 2011-07-29 17:49 ` jakub at gcc dot gnu.org
  2011-07-29 17:58 ` [Bug middle-end/49897] [4.5 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-29 17:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-29 17:48:45 UTC ---
Author: jakub
Date: Fri Jul 29 17:48:42 2011
New Revision: 176946

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176946
Log:
    PR middle-end/49897
    PR middle-end/49898
    * omp-low.c (use_pointer_for_field): If disallowing copy-in/out
    in nested parallel and outer is a gimple_reg, mark it as addressable
    and set its bit in task_shared_vars bitmap too.

    * testsuite/libgomp.c/pr49897-1.c: New test.
    * testsuite/libgomp.c/pr49897-2.c: New test.
    * testsuite/libgomp.c/pr49898-1.c: New test.
    * testsuite/libgomp.c/pr49898-2.c: New test.

Added:
    branches/gcc-4_6-branch/libgomp/testsuite/libgomp.c/pr49897-1.c
    branches/gcc-4_6-branch/libgomp/testsuite/libgomp.c/pr49897-2.c
    branches/gcc-4_6-branch/libgomp/testsuite/libgomp.c/pr49898-1.c
    branches/gcc-4_6-branch/libgomp/testsuite/libgomp.c/pr49898-2.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/omp-low.c
    branches/gcc-4_6-branch/libgomp/ChangeLog


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

* [Bug middle-end/49897] [4.5 Regression] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
                   ` (5 preceding siblings ...)
  2011-07-29 17:49 ` jakub at gcc dot gnu.org
@ 2011-07-29 17:58 ` jakub at gcc dot gnu.org
  2011-08-01 14:07 ` rguenth at gcc dot gnu.org
  2012-07-02 10:08 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-29 17:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.6.2, 4.7.0
            Summary|[4.5/4.6/4.7 Regression]    |[4.5 Regression] nesting
                   |nesting lastprivate gives   |lastprivate gives incorrect
                   |incorrect result            |result

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-29 17:57:48 UTC ---
Fixed for 4.6+ so far, 4.5 backport scheduled for later on.


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

* [Bug middle-end/49897] [4.5 Regression] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
                   ` (6 preceding siblings ...)
  2011-07-29 17:58 ` [Bug middle-end/49897] [4.5 " jakub at gcc dot gnu.org
@ 2011-08-01 14:07 ` rguenth at gcc dot gnu.org
  2012-07-02 10:08 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-01 14:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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

* [Bug middle-end/49897] [4.5 Regression] nesting lastprivate gives incorrect result
  2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
                   ` (7 preceding siblings ...)
  2011-08-01 14:07 ` rguenth at gcc dot gnu.org
@ 2012-07-02 10:08 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-02 10:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49897

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.5.4                       |4.6.2

--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-02 10:08:05 UTC ---
Fixed for 4.6.2.


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

end of thread, other threads:[~2012-07-02 10:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-29  8:23 [Bug c/49897] New: nesting lastprivate gives incorrect result markflorisson88 at gmail dot com
2011-07-29 15:38 ` [Bug middle-end/49897] " jakub at gcc dot gnu.org
2011-07-29 15:41 ` [Bug middle-end/49897] [4.5/4.6/4.7 Regression] " jakub at gcc dot gnu.org
2011-07-29 15:42 ` jakub at gcc dot gnu.org
2011-07-29 16:06 ` markflorisson88 at gmail dot com
2011-07-29 17:47 ` jakub at gcc dot gnu.org
2011-07-29 17:49 ` jakub at gcc dot gnu.org
2011-07-29 17:58 ` [Bug middle-end/49897] [4.5 " jakub at gcc dot gnu.org
2011-08-01 14:07 ` rguenth at gcc dot gnu.org
2012-07-02 10:08 ` rguenth 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).