This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgomp/38935] New: Openmp reduction with - (minus) does not produce correct result
- From: "sebastian dot schlingmann at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jan 2009 13:56:36 -0000
- Subject: [Bug libgomp/38935] New: Openmp reduction with - (minus) does not produce correct result
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
When using openmp reduction with minus the results are added instead of
substracted.
Small test programm to verify:
#include <omp.h>
int main(int argc, char* argv[]) {
int result = 15;
#pragma omp parallel reduction(-:result) num_threads(4)
{
result += 2;
// (1)
}
// (2)
}
At position (1) the variable result is 2 for each thread.
After the parallel block at position (2) it should be 7 (15-2-2-2-2) but the
value of result is 23 instead.
When I use + instead of - for the reduction clause the result is also 23.
I used the gcc version shipped with Ubuntu (gcc (Ubuntu 4.3.2-1ubuntu11)
4.3.2).
--
Summary: Openmp reduction with - (minus) does not produce correct
result
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgomp
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebastian dot schlingmann at web dot de
GCC host triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38935