public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/67986] New: OpenMP collapse - invalid code generated.
@ 2015-10-16 13:13 lbukata at gmail dot com
  2015-10-16 13:19 ` [Bug libgomp/67986] " jakub at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: lbukata at gmail dot com @ 2015-10-16 13:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67986

            Bug ID: 67986
           Summary: OpenMP collapse - invalid code generated.
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lbukata at gmail dot com
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Created attachment 36525
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36525&action=edit
Simple demonstration of the bug.

Invalid code for the following code:

#pragma omp parallel for collapse(2)
for (int32_t i = 0; i < N-1; ++i)       {
        for (int32_t j = i+1; j < N; ++j)       {
             #pragma omp critical
             cout<<"(i,j): ("<<i<<","<<j<<")"<<endl;
        }
}

Sequential code generates valid pairs of indices, however, the parallel code
neglects the dependency of inner loop range on outer loop variable. The full
source is attached.

Tested on both GCC 4.8.5 and GCC 4.9.3 with the same result. The distro is
Gentoo Linux 2015.


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

* [Bug libgomp/67986] OpenMP collapse - invalid code generated.
  2015-10-16 13:13 [Bug libgomp/67986] New: OpenMP collapse - invalid code generated lbukata at gmail dot com
@ 2015-10-16 13:19 ` jakub at gcc dot gnu.org
  2015-10-16 13:40 ` lbukata at gmail dot com
  2015-10-16 13:49 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-10-16 13:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67986

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This is not valid OpenMP code.
E.g. OpenMP 4.0, 2.7.1, p. 56, lines 1-3 says:
The iteration count for each associated loop is computed before entry to the
outermost loop. If execution of any associated loop changes any of the values
used to compute any of the iteration counts, then the behavior is unspecified.
Similar wording in other OpenMP standard versions.


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

* [Bug libgomp/67986] OpenMP collapse - invalid code generated.
  2015-10-16 13:13 [Bug libgomp/67986] New: OpenMP collapse - invalid code generated lbukata at gmail dot com
  2015-10-16 13:19 ` [Bug libgomp/67986] " jakub at gcc dot gnu.org
@ 2015-10-16 13:40 ` lbukata at gmail dot com
  2015-10-16 13:49 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: lbukata at gmail dot com @ 2015-10-16 13:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67986

--- Comment #2 from Libor Bukata <lbukata at gmail dot com> ---
In that case one would expect a compiler error (or at least warning) rather
than unspecified behaviour. Thanks you for your explanation.


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

* [Bug libgomp/67986] OpenMP collapse - invalid code generated.
  2015-10-16 13:13 [Bug libgomp/67986] New: OpenMP collapse - invalid code generated lbukata at gmail dot com
  2015-10-16 13:19 ` [Bug libgomp/67986] " jakub at gcc dot gnu.org
  2015-10-16 13:40 ` lbukata at gmail dot com
@ 2015-10-16 13:49 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-10-16 13:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67986

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The wording in the 4.0 and older versions is non-trivial to check at compile
time, sure, there are easy cases that can be detected, but otherwise whether a
value changes is hard to analyze at compile time.  In OpenMP 4.5, there is
additional restriction that the iterators of associated loops can't be even
mentioned in the b, lb and incr expressions, so even j = i * 0 will be invalid,
and then it is something that can be easily detected at compile time.
For OpenMP 5.0, there are vague plans to add support for certain triangular
collapsed loops, but what the exact wording will be is still undecided.


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

end of thread, other threads:[~2015-10-16 13:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-16 13:13 [Bug libgomp/67986] New: OpenMP collapse - invalid code generated lbukata at gmail dot com
2015-10-16 13:19 ` [Bug libgomp/67986] " jakub at gcc dot gnu.org
2015-10-16 13:40 ` lbukata at gmail dot com
2015-10-16 13:49 ` jakub 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).