public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks
@ 2005-12-05 10:57 jakub at gcc dot gnu dot org
2006-01-29 20:19 ` [Bug middle-end/25261] " pinskia at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-12-05 10:57 UTC (permalink / raw)
To: gcc-bugs
As mentioned in my http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00035.html
mail, nested function calls in #pragma omp parallel blocks are still broken
(for all of C/C++/Fortran and at least in Fortran they are part of the
standards) and I'm even not sure what the exact semantics should be for them
if e.g. some of the variables the nested fns refer to are privatized in the
parallel and some are not.
Below is just a short testcase, we'll need several more testcases to cover
this when it is actually fixed.
/* { dg-do run } */
#include <omp.h>
extern void abort (void);
int
main (void)
{
int i = 5, j, l = 0;
int foo (void) { return i == 6; }
int bar (void) { return i - 3; }
omp_set_dynamic (0);
#pragma omp parallel for schedule (static, bar ()) num_threads (2) \
reduction (|:l)
for (j = 0; j < 4; j++)
if (omp_get_thread_num () != (j < 2))
l = 1;
i++;
#pragma omp parallel for schedule (static, bar ()) num_threads (2) \
reduction (|:l)
for (j = 0; j < 6; j++)
if (omp_get_thread_num () != (j < 3))
l = 1;
#pragma omp parallel num_threads (4) reduction (|:l)
if (! foo () || bar () != 3)
l = 1;
i++;
#pragma omp parallel num_threads (4) reduction (|:l)
if (foo () || bar () != 4)
l = 1;
if (l)
abort ();
return 0;
}
--
Summary: [gomp] Nested function calls in #pragma omp parallel
blocks
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: openmp
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
@ 2006-01-29 20:19 ` pinskia at gcc dot gnu dot org
2006-08-21 12:35 ` jakub at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-29 20:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-01-29 20:19 -------
Is this true any more or is it still broken.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
2006-01-29 20:19 ` [Bug middle-end/25261] " pinskia at gcc dot gnu dot org
@ 2006-08-21 12:35 ` jakub at gcc dot gnu dot org
2006-09-11 14:23 ` jakub at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-08-21 12:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jakub at gcc dot gnu dot org 2006-08-21 12:35 -------
It is not that hard to try the testcase. It is still broken.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-08-21 12:35:42
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
2006-01-29 20:19 ` [Bug middle-end/25261] " pinskia at gcc dot gnu dot org
2006-08-21 12:35 ` jakub at gcc dot gnu dot org
@ 2006-09-11 14:23 ` jakub at gcc dot gnu dot org
2006-09-11 15:47 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-09-11 14:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jakub at gcc dot gnu dot org 2006-09-11 14:22 -------
I believe OMP_PARALLEL handling in tree-nested.c isn't the only problem, see
e.g.:
extern void abort (void);
void
foo (int *j)
{
int i = 5;
int bar (void) { return i + 1; }
#pragma omp sections private (i)
{
#pragma omp section
{
i = 6;
if (bar () != 7)
#pragma omp atomic
++*j;
}
#pragma omp section
{
if (bar () != 6)
#pragma omp atomic
++*j;
}
}
}
int
main (void)
{
int j = 0;
#pragma omp parallel num_threads (2)
foo (&j);
if (j)
abort ();
return 0;
}
My understanding is that even the OMP_PRIVATE clause in the worksharing
construct
should result in a different FRAME. Another testcase:
extern void abort (void);
extern int omp_get_thread_num ();
extern void omp_set_dynamic (int);
int
main (void)
{
int j = 0, k = 6, l = 7, m = 8;
void
foo (void)
{
int i = 5;
int bar (void) { return i + 1 + (j > 100 ? 10000 : 0); }
#pragma omp sections private (i)
{
#pragma omp section
{
i = 6;
if (bar () != 7)
#pragma omp atomic
++j;
}
#pragma omp section
{
if (bar () != 6)
#pragma omp atomic
++j;
}
}
if (k != 6 + omp_get_thread_num () || l != 7 || m != 9)
#pragma omp atomic
++j;
}
omp_set_dynamic (0);
#pragma omp parallel num_threads (2) firstprivate (k) shared (l) private (m)
{
if (omp_get_thread_num () != 0)
k += omp_get_thread_num ();
m = 9;
foo ();
}
if (j)
abort ();
return 0;
}
I believe in many cases we will have to force use_pointer_in_frame when OpenMP
constructs are involved in the parent routines of nested functions. We don't
need it if either all the variables in FRAME structure are shared (then we can
pass around a pointer to the parent's FRAME), or if all are private (then we
could create a completely new copy of the FRAME and make the private vars live
in there), but as soon as things start to get mixed, we need to use pointers.
But not sure how easy would be to figure it out. As convert_nonlocal_reference
already needs to know if it should use pointer or a var directly, we'd need
another flag_openmp pass before walk_all_functions (convert_nonlocal_reference,
root); that would perhaps stick all vars mentioned in omp clauses in some hash
table in struct nesting_info and then use that as a guide to
use_pointer_in_frame.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rth at gcc dot gnu dot org,
| |dnovillo at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
` (2 preceding siblings ...)
2006-09-11 14:23 ` jakub at gcc dot gnu dot org
@ 2006-09-11 15:47 ` jakub at gcc dot gnu dot org
2006-09-22 16:35 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-09-11 15:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jakub at gcc dot gnu dot org 2006-09-11 15:46 -------
Furthermore, I have no idea what would:
extern void abort (void);
int
baz (int (*bar) (void))
{
return bar ();
}
void
foo (int *j)
{
int i = 5;
int (*fn) (void);
int bar (void) { return i + 1; }
fn = bar;
if (bar (fn) != 6)
#pragma omp atomic
++j;
#pragma omp sections private (i)
{
#pragma omp section
{
i = 6;
if (baz (fn) != 7)
#pragma omp atomic
++*j;
}
#pragma omp section
{
if (baz (fn) != 6)
#pragma omp atomic
++*j;
}
}
}
int
main (void)
{
int j = 0;
#pragma omp parallel num_threads (2)
foo (&j);
if (j)
abort ();
return 0;
}
be supposed to do. Do other openmp compilers support nested C functions? If
so,
what they are doing here? It would be easy to say that e.g. all non-local vars
in nested functions are implicitly shared (i.e. we always reference the
original
parent function's variables, not any remapped ones). But can we do the same in
Fortran where nested functions are part of the standard?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
` (3 preceding siblings ...)
2006-09-11 15:47 ` jakub at gcc dot gnu dot org
@ 2006-09-22 16:35 ` jakub at gcc dot gnu dot org
2006-09-26 18:11 ` jakub at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-09-22 16:35 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2006-
| |09/msg00988.html
Status|NEW |ASSIGNED
Keywords| |patch
Last reconfirmed|2006-08-21 12:35:42 |2006-09-22 16:35:21
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
` (4 preceding siblings ...)
2006-09-22 16:35 ` jakub at gcc dot gnu dot org
@ 2006-09-26 18:11 ` jakub at gcc dot gnu dot org
2006-09-27 2:52 ` pinskia at gcc dot gnu dot org
2007-01-10 19:23 ` pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-09-26 18:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2006-09-26 18:11 -------
Subject: Bug 25261
Author: jakub
Date: Tue Sep 26 18:10:58 2006
New Revision: 117235
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117235
Log:
PR middle-end/25261
PR middle-end/28790
* tree-nested.c (struct nesting_info): Added static_chain_added.
(convert_call_expr): Set static_chain_added when adding static
chain. Handle OMP_PARALLEL and OMP_SECTION.
* gcc.dg/gomp/nestedfn-1.c: New test.
* testsuite/libgomp.c/nestedfn-4.c: New test.
* testsuite/libgomp.c/nestedfn-5.c: New test.
* testsuite/libgomp.fortran/nestedfn3.f90: New test.
Added:
trunk/gcc/testsuite/gcc.dg/gomp/nestedfn-1.c
trunk/libgomp/testsuite/libgomp.c/nestedfn-4.c
trunk/libgomp/testsuite/libgomp.c/nestedfn-5.c
trunk/libgomp/testsuite/libgomp.fortran/nestedfn3.f90
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-nested.c
trunk/libgomp/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
` (5 preceding siblings ...)
2006-09-26 18:11 ` jakub at gcc dot gnu dot org
@ 2006-09-27 2:52 ` pinskia at gcc dot gnu dot org
2007-01-10 19:23 ` pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-27 2:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2006-09-27 02:51 -------
Fixed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/25261] [gomp] Nested function calls in #pragma omp parallel blocks
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
` (6 preceding siblings ...)
2006-09-27 2:52 ` pinskia at gcc dot gnu dot org
@ 2007-01-10 19:23 ` pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-10 19:23 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25261
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-01-10 19:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-05 10:57 [Bug middle-end/25261] New: [gomp] Nested function calls in #pragma omp parallel blocks jakub at gcc dot gnu dot org
2006-01-29 20:19 ` [Bug middle-end/25261] " pinskia at gcc dot gnu dot org
2006-08-21 12:35 ` jakub at gcc dot gnu dot org
2006-09-11 14:23 ` jakub at gcc dot gnu dot org
2006-09-11 15:47 ` jakub at gcc dot gnu dot org
2006-09-22 16:35 ` jakub at gcc dot gnu dot org
2006-09-26 18:11 ` jakub at gcc dot gnu dot org
2006-09-27 2:52 ` pinskia at gcc dot gnu dot org
2007-01-10 19:23 ` pinskia 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).