diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-02 21:22:47 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-07-02 21:22:47 +0200 |
commit | 69f1837b81f57ff588ffd82a3db0a7b739b446de (patch) | |
tree | e8a300b94b510ed658c3b719e55917d2e3346017 /gcc/omp-low.c | |
parent | 15c723f39fb55da9ee0f288ecac2c178b68b2a3c (diff) | |
download | gcc-69f1837b81f57ff588ffd82a3db0a7b739b446de.zip gcc-69f1837b81f57ff588ffd82a3db0a7b739b446de.tar.gz gcc-69f1837b81f57ff588ffd82a3db0a7b739b446de.tar.bz2 |
re PR libgomp/32468 (number of threads in a parallel region depends on number of SECTIONs and MAX_THREADS)
PR libgomp/32468
* omp-low.c (check_combined_parallel): New function.
(lower_omp_parallel): Call it via walk_stmts, set
OMP_PARALLEL_COMBINED if appropriate.
(determine_parallel_type): If OMP_FOR resp. OMP_SECTIONS
isn't the only statement in WS_ENTRY_BB or OMP_RETURN
the only one in PAR_EXIT_BB and not OMP_PARALLEL_COMBINED,
don't consider it as combined parallel.
* gcc.dg/gomp/pr32468-1.c: New test.
From-SVN: r126226
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r-- | gcc/omp-low.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 700645f..fce9975 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -385,9 +385,12 @@ determine_parallel_type (struct omp_region *region) if (single_succ (par_entry_bb) == ws_entry_bb && single_succ (ws_exit_bb) == par_exit_bb - && workshare_safe_to_combine_p (par_entry_bb, ws_entry_bb)) + && workshare_safe_to_combine_p (par_entry_bb, ws_entry_bb) + && (OMP_PARALLEL_COMBINED (last_stmt (par_entry_bb)) + || (last_and_only_stmt (ws_entry_bb) + && last_and_only_stmt (par_exit_bb)))) { - tree ws_stmt = last_stmt (region->inner->entry); + tree ws_stmt = last_stmt (ws_entry_bb); if (region->inner->type == OMP_FOR) { @@ -4060,6 +4063,28 @@ lower_omp_for (tree *stmt_p, omp_context *ctx) *stmt_p = new_stmt; } +/* Callback for walk_stmts. Check if *TP only contains OMP_FOR + or OMP_PARALLEL. */ + +static tree +check_combined_parallel (tree *tp, int *walk_subtrees, void *data) +{ + struct walk_stmt_info *wi = data; + int *info = wi->info; + + *walk_subtrees = 0; + switch (TREE_CODE (*tp)) + { + case OMP_FOR: + case OMP_SECTIONS: + *info = *info == 0 ? 1 : -1; + break; + default: + *info = -1; + break; + } + return NULL; +} /* Lower the OpenMP parallel directive in *STMT_P. CTX holds context information for the directive. */ @@ -4077,6 +4102,19 @@ lower_omp_parallel (tree *stmt_p, omp_context *ctx) par_bind = OMP_PARALLEL_BODY (stmt); par_body = BIND_EXPR_BODY (par_bind); child_fn = ctx->cb.dst_fn; + if (!OMP_PARALLEL_COMBINED (stmt)) + { + struct walk_stmt_info wi; + int ws_num = 0; + + memset (&wi, 0, sizeof (wi)); + wi.callback = check_combined_parallel; + wi.info = &ws_num; + wi.val_only = true; + walk_stmts (&wi, &par_bind); + if (ws_num == 1) + OMP_PARALLEL_COMBINED (stmt) = 1; + } push_gimplify_context (); |