public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/52348] New: [4.5/4.6] OpenMP incorrectly parallelizes loops (wrong iteration count)
@ 2012-02-23  9:22 ua_gcc_bugzilla@binary-island.eu
  2012-02-23  9:53 ` [Bug libgomp/52348] [4.5/4.6/4.7] " ua_gcc_bugzilla@binary-island.eu
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ua_gcc_bugzilla@binary-island.eu @ 2012-02-23  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52348
           Summary: [4.5/4.6] OpenMP incorrectly parallelizes loops (wrong
                    iteration count)
    Classification: Unclassified
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ua_gcc_bugzilla@binary-island.eu


Created attachment 26725
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26725
testcase with unsigned and signed integers (OpenMP >= 3.0 / < 3.0)

The attached testcase shows actually two possible bugs:

(1) Using the data type's maximum value range as the number of iterations, will
result in less iterations if and only if more than 1 thread is used. Gradually
increasing the number of threads and slowly decreasing the iteration count,
will produce the right result.

(2) Using a signed range for the loop counter (starting from the negative min
to the positive max), will not work at all. No loop iteration is done. As long
as the program is linked with openmp, this does not change. Recompiling without
openmp support, produces the right result.

This behavior has been reproduced with gcc 4.5.3, 4.6.2 and current 4.6 branch
(aka the upcoming 4.6.3). Current gcc 4.7 trunk does work partially: it
produces the right results for the unsigned range but still does not work for
the signed range. The selected target (64bit / 32bit) or optimizations (Os up
to O3) make no difference at all.

The expected output would be:

INT32_MAX: 65535 / 65535
UINT32_MAX: 65535 / 65535

The OpenMP < 3.0 part (signed integer range) works correctly with the path64
compiler and both parts also work correctly with the Intel C compiler.

All tests were performed on a x86_64 (Core i7 860) Gentoo system with glibc
2.14.1(-r2) and binutils-2.22(-r1).


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

* [Bug libgomp/52348] [4.5/4.6/4.7] OpenMP incorrectly parallelizes loops (wrong iteration count)
  2012-02-23  9:22 [Bug libgomp/52348] New: [4.5/4.6] OpenMP incorrectly parallelizes loops (wrong iteration count) ua_gcc_bugzilla@binary-island.eu
@ 2012-02-23  9:53 ` ua_gcc_bugzilla@binary-island.eu
  2012-02-23 10:08 ` [Bug libgomp/52348] " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ua_gcc_bugzilla@binary-island.eu @ 2012-02-23  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Matthias Dahl <ua_gcc_bugzilla@binary-island.eu> 2012-02-23 09:21:51 UTC ---
Before this causes any confusion: The path64 compiler does currently only
support OpenMP up to and including 2.5. That's why I stated only the OpenMP <
3.0 part works.


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

* [Bug libgomp/52348] OpenMP incorrectly parallelizes loops (wrong iteration count)
  2012-02-23  9:22 [Bug libgomp/52348] New: [4.5/4.6] OpenMP incorrectly parallelizes loops (wrong iteration count) ua_gcc_bugzilla@binary-island.eu
  2012-02-23  9:53 ` [Bug libgomp/52348] [4.5/4.6/4.7] " ua_gcc_bugzilla@binary-island.eu
@ 2012-02-23 10:08 ` rguenth at gcc dot gnu.org
  2012-02-23 10:29 ` ua_gcc_bugzilla@binary-island.eu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-02-23 10:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-23
            Summary|[4.5/4.6/4.7] OpenMP        |OpenMP incorrectly
                   |incorrectly parallelizes    |parallelizes loops (wrong
                   |loops (wrong iteration      |iteration count)
                   |count)                      |
     Ever Confirmed|0                           |1
      Known to fail|                            |4.3.6, 4.4.6, 4.5.3, 4.6.2,
                   |                            |4.7.0

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-23 09:58:24 UTC ---
With 4.3.x we warned

testcase.c: In function 'main':
testcase.c:26: warning: iteration variable 'x' is unsigned

and up to 4.6.2 we produce

INT32_MAX: 0 / 65535
UINT32_MAX: 32768 / 65535

but on trunk (4.7) we say

INT32_MAX: 0 / 65535
UINT32_MAX: 65535 / 65535

Confirmed that ICC produces

INT32_MAX: 65535 / 65535
UINT32_MAX: 65535 / 65535


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

* [Bug libgomp/52348] OpenMP incorrectly parallelizes loops (wrong iteration count)
  2012-02-23  9:22 [Bug libgomp/52348] New: [4.5/4.6] OpenMP incorrectly parallelizes loops (wrong iteration count) ua_gcc_bugzilla@binary-island.eu
  2012-02-23  9:53 ` [Bug libgomp/52348] [4.5/4.6/4.7] " ua_gcc_bugzilla@binary-island.eu
  2012-02-23 10:08 ` [Bug libgomp/52348] " rguenth at gcc dot gnu.org
@ 2012-02-23 10:29 ` ua_gcc_bugzilla@binary-island.eu
  2012-02-23 10:39 ` [Bug libgomp/52348] [4.5/4.6/4.7] " jakub at gcc dot gnu.org
  2012-02-23 10:47 ` ua_gcc_bugzilla@binary-island.eu
  4 siblings, 0 replies; 6+ messages in thread
From: ua_gcc_bugzilla@binary-island.eu @ 2012-02-23 10:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Matthias Dahl <ua_gcc_bugzilla@binary-island.eu> 2012-02-23 10:21:53 UTC ---
The warning with gcc 4.3.x is correct because of the lack of support for OpenMP
3.0. Starting with 4.4, gcc supports OpenMP 3.0 which allows unsigned iteration
variables.


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

* [Bug libgomp/52348] [4.5/4.6/4.7] OpenMP incorrectly parallelizes loops (wrong iteration count)
  2012-02-23  9:22 [Bug libgomp/52348] New: [4.5/4.6] OpenMP incorrectly parallelizes loops (wrong iteration count) ua_gcc_bugzilla@binary-island.eu
                   ` (2 preceding siblings ...)
  2012-02-23 10:29 ` ua_gcc_bugzilla@binary-island.eu
@ 2012-02-23 10:39 ` jakub at gcc dot gnu.org
  2012-02-23 10:47 ` ua_gcc_bugzilla@binary-island.eu
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-02-23 10:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Last reconfirmed|2012-02-23 00:00:00         |
                 CC|                            |jakub at gcc dot gnu.org
         Resolution|                            |INVALID
            Summary|OpenMP incorrectly          |[4.5/4.6/4.7] OpenMP
                   |parallelizes loops (wrong   |incorrectly parallelizes
                   |iteration count)            |loops (wrong iteration
                   |                            |count)
      Known to fail|4.3.6, 4.4.6, 4.5.3, 4.6.2, |
                   |4.7.0                       |

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-02-23 10:32:48 UTC ---
The first case is not valid OpenMP code.
See e.g. OpenMP 2.5, in section 2.5.1:
"Note that the canonical form allows the number of loop iterations to be
computed on entry to the loop. This computation is performed with values in the
type of var, after integral promotions. In particular, if the value of b - lb +
incr, or any intermediate result required to compute this value, cannot be
represented in that type, the behavior is unspecified."

The number of iterations here is (INT32_MAX - 1) - INT32_MIN + 1, but it and
any of its temporaries are supposed to be computed in the int type.  That is
unspecified behavior, you just can't have more than INT32_MAX iterations in a
valid OpenMP loop with int IV type.


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

* [Bug libgomp/52348] [4.5/4.6/4.7] OpenMP incorrectly parallelizes loops (wrong iteration count)
  2012-02-23  9:22 [Bug libgomp/52348] New: [4.5/4.6] OpenMP incorrectly parallelizes loops (wrong iteration count) ua_gcc_bugzilla@binary-island.eu
                   ` (3 preceding siblings ...)
  2012-02-23 10:39 ` [Bug libgomp/52348] [4.5/4.6/4.7] " jakub at gcc dot gnu.org
@ 2012-02-23 10:47 ` ua_gcc_bugzilla@binary-island.eu
  4 siblings, 0 replies; 6+ messages in thread
From: ua_gcc_bugzilla@binary-island.eu @ 2012-02-23 10:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Matthias Dahl <ua_gcc_bugzilla@binary-island.eu> 2012-02-23 10:38:51 UTC ---
I am a bit short on time, so I cannot check on the OpenMP 2.5 related matter
but closing this bug is a bit premature imho. There is still the issue with the
OpenMP 3.0 part which has been confirmed by Richard Guenther in Comment 2 btw.


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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-23  9:22 [Bug libgomp/52348] New: [4.5/4.6] OpenMP incorrectly parallelizes loops (wrong iteration count) ua_gcc_bugzilla@binary-island.eu
2012-02-23  9:53 ` [Bug libgomp/52348] [4.5/4.6/4.7] " ua_gcc_bugzilla@binary-island.eu
2012-02-23 10:08 ` [Bug libgomp/52348] " rguenth at gcc dot gnu.org
2012-02-23 10:29 ` ua_gcc_bugzilla@binary-island.eu
2012-02-23 10:39 ` [Bug libgomp/52348] [4.5/4.6/4.7] " jakub at gcc dot gnu.org
2012-02-23 10:47 ` ua_gcc_bugzilla@binary-island.eu

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).