This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/49897] New: nesting lastprivate gives incorrect result
- From: "markflorisson88 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 29 Jul 2011 08:22:49 +0000
- Subject: [Bug c/49897] New: nesting lastprivate gives incorrect result
- Auto-submitted: auto-generated
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