public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/111666] New: [OpenMP] Fortran FE creates too many temporaries for clauses / 'omp target'+'omp team' #teams/#threads optimize_target_teams optimization fails
@ 2023-10-02 18:08 burnus at gcc dot gnu.org
2023-10-04 9:43 ` [Bug fortran/111666] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: burnus at gcc dot gnu.org @ 2023-10-02 18:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111666
Bug ID: 111666
Summary: [OpenMP] Fortran FE creates too many temporaries for
clauses / 'omp target'+'omp team' #teams/#threads
optimize_target_teams optimization fails
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: missed-optimization, openmp
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: andrewjenner at gcc dot gnu.org, jakub at gcc dot gnu.org
Target Milestone: ---
I wonder whether trans-openmp.cc in general converts too much into temporaries.
Namely the following function. the 'gfc_evaluate_now' returns a constant as a
constant but otherwise creates a temporary:
static inline tree
gfc_convert_expr_to_tree (stmtblock_t *block, gfc_expr *expr)
{
gfc_se se;
tree result;
gfc_init_se (&se, NULL );
gfc_conv_expr (&se, expr);
gfc_add_block_to_block (block, &se.pre);
result = gfc_evaluate_now (se.expr, block);
gfc_add_block_to_block (block, &se.post);
return result;
}
* * *
This bites us for something similar to libgomp.fortran/examples-4/teams-2.f90
but modified:
function dotprod (..., num_teams, block_threads)
integer, VALUE :: num_teams, block_threads
!$omp target map(to: B, C, block_size) ...
!$omp teams num_teams(num_teams) thread_limit(block_threads) ...
The problem is that the gfc_evaluate_now produces code like:
D.4323 = num_teams;
D.4324 = block_threads;
#pragma omp teams ... num_teams(D.4323) thread_limit(D.4324)
And this is then too complex for gcc/gimplify.cc's optimize_target_teams
which no longer recognizes that num_teams and block_threads are (implicitly)
firstprivatize.
* * *
A similar issue shows up above without the VALUE attribute; this matches the
OpenMP Example document teams-2.f90 example - except that the values are passed
by reference.
(That's != libgomp.fortran/examples-4/teams-2.f90; the latter has 'map(tofrom:'
which prevents the optimize_target_teams optimization.)
In order to make that work, we would need to preserve 'num_teams(*num_teams)'
in the evaluation – and handle indirect-ref+DECL_P in optimize_target_teams.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug fortran/111666] [OpenMP] Fortran FE creates too many temporaries for clauses / 'omp target'+'omp team' #teams/#threads optimize_target_teams optimization fails
2023-10-02 18:08 [Bug fortran/111666] New: [OpenMP] Fortran FE creates too many temporaries for clauses / 'omp target'+'omp team' #teams/#threads optimize_target_teams optimization fails burnus at gcc dot gnu.org
@ 2023-10-04 9:43 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-04 9:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111666
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Why not delay this "evaluate now" to gimplification time?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-04 9:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-02 18:08 [Bug fortran/111666] New: [OpenMP] Fortran FE creates too many temporaries for clauses / 'omp target'+'omp team' #teams/#threads optimize_target_teams optimization fails burnus at gcc dot gnu.org
2023-10-04 9:43 ` [Bug fortran/111666] " rguenth 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).