public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40205] New: OpenMP do loop with MAXINT gives wrong trip count
@ 2009-05-20 11:13 pkeir at dcs dot gla dot ac dot uk
2009-05-20 11:28 ` [Bug middle-end/40205] " rguenth at gcc dot gnu dot org
2009-09-26 10:16 ` steven at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: pkeir at dcs dot gla dot ac dot uk @ 2009-05-20 11:13 UTC (permalink / raw)
To: gcc-bugs
When the largest integer is used as the upper bound of a for loop which is
parallelised using OpenMP, thread n-1 will execute at most one iteration. The
code below demonstrates this by printing at most one message.
This is shown most clearly by first setting the OMP_NUM_THREADS environment
variable to 1. We would then expect ten "I get printed once or less." messages,
but we get only one. (With OMP_NUM_THREADS set to 2, we would again expect ten,
but only get six messages).
The OpenMP runtime library is used in this example only to make explicit that
the error relates to the last thread of the team. ( i.e. "use omp_lib" allows
us to call omp_get_thread_num() and omp_get_num_threads() )
I tried using the -fdump-tree-original switch, and it occurs to me that the use
of <= in the generated loops may play a part in this. ( OpenMP "for loop" tests
are permitted only to use <,<=,> or >= )
The example code follows, and is compiled with
gfortran -Wall -save-temps -fopenmp ompbug3.f95
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12) x86_64-linux-gnu Ubuntu 8.10
----------------------------------------------------
program main
use omp_lib
integer(kind=4) :: i, lower, upper
upper = huge(maxint)
lower = upper - 9 ! The 9 can of course be changed
!$omp parallel do
do i = lower, upper
if (omp_get_thread_num() == (omp_get_num_threads() - 1)) then
print *, "I get printed once or less."
end if
end do
!$end omp parallel do
end program
----------------------------------------------------
--
Summary: OpenMP do loop with MAXINT gives wrong trip count
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pkeir at dcs dot gla dot ac dot uk
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40205
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/40205] OpenMP do loop with MAXINT gives wrong trip count
2009-05-20 11:13 [Bug fortran/40205] New: OpenMP do loop with MAXINT gives wrong trip count pkeir at dcs dot gla dot ac dot uk
@ 2009-05-20 11:28 ` rguenth at gcc dot gnu dot org
2009-09-26 10:16 ` steven at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-05-20 11:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2009-05-20 11:28 -------
Confirmed. extract_omp_for_data "canonicalizes" <= and >= to < and > by
adding/subtracting one to/from the bound.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Component|fortran |middle-end
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2009-05-20 11:28:36
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40205
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/40205] OpenMP do loop with MAXINT gives wrong trip count
2009-05-20 11:13 [Bug fortran/40205] New: OpenMP do loop with MAXINT gives wrong trip count pkeir at dcs dot gla dot ac dot uk
2009-05-20 11:28 ` [Bug middle-end/40205] " rguenth at gcc dot gnu dot org
@ 2009-09-26 10:16 ` steven at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-09-26 10:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from steven at gcc dot gnu dot org 2009-09-26 10:15 -------
Jakub, OpenMP bug, is this something you have time for?
--
steven at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40205
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-09-26 10:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-20 11:13 [Bug fortran/40205] New: OpenMP do loop with MAXINT gives wrong trip count pkeir at dcs dot gla dot ac dot uk
2009-05-20 11:28 ` [Bug middle-end/40205] " rguenth at gcc dot gnu dot org
2009-09-26 10:16 ` steven at gcc dot gnu dot 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).