* [Bug middle-end/103416] [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit])
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
@ 2021-11-24 19:05 ` cltang at gcc dot gnu.org
2021-11-25 7:18 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cltang at gcc dot gnu.org @ 2021-11-24 19:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
--- Comment #1 from Chung-Lin Tang <cltang at gcc dot gnu.org> ---
Can you see if adding this patch:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583279.html
fixes this problem? If so, then it should be another occurrence of PR90030
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/103416] [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit])
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
2021-11-24 19:05 ` [Bug middle-end/103416] " cltang at gcc dot gnu.org
@ 2021-11-25 7:18 ` rguenth at gcc dot gnu.org
2021-11-25 10:07 ` burnus at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-25 7:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/103416] [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit])
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
2021-11-24 19:05 ` [Bug middle-end/103416] " cltang at gcc dot gnu.org
2021-11-25 7:18 ` rguenth at gcc dot gnu.org
@ 2021-11-25 10:07 ` burnus at gcc dot gnu.org
2021-11-25 10:52 ` burnus at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-11-25 10:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Chung-Lin Tang from comment #1)
> Can you see if adding this patch:
> https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583279.html
> fixes this problem? If so, then it should be another occurrence of PR90030
Yes and no.
That patch FIXES the issue
libgomp: cuCtxSynchronize error: misaligned address
libgomp: cuMemFree_v2 error: misaligned address
libgomp: device finalization failed
BUT I still see
#pragma omp target map(to:D.4246 [len: 4][implicit]) ...
and when adding an explicit firstprivate(n) I see
#pragma omp target firstprivate(n) map(to:D.4246 [len: 4][implicit]) ...
which looks wrong. I understand that implicit mapping tries to solve the
problem of explicitly mapping an array section via 'omp target (enter) data' -
and then implicitly mapping the whole array. — But I think it does not make
sense to add this implicit mapping if there is an implicit or explicit
'firstprivate' for that variable. – That's just generates pointless code,
obfuscates the dump, adds an overhead to libgomp, ...
Actually, it does not only apply to 'firstprivate' - the same also can be
caused for 'tofrom' vs. 'to' as in
#pragma omp target ... map(to:D.4217 [len: 4][implicit]) map(tofrom:n [len:
4][implicit])
for the following code:
PROGRAM target_parallel_do
implicit none
INTEGER :: i0, N
COMPLEX(8) :: scalar
N = 1
!$OMP TARGET PARALLEL do map(from: scalar) private(i0) defaultmap(tofrom)
DO i0 = 1, N
scalar%re = n
END DO
!$omp end target parallel do
END PROGRAM target_parallel_do
Admittedly, I have not yet managed to construct something which causes an
observable misbehavior.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/103416] [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit])
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2021-11-25 10:07 ` burnus at gcc dot gnu.org
@ 2021-11-25 10:52 ` burnus at gcc dot gnu.org
2021-11-25 11:21 ` burnus at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-11-25 10:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Okay, the
map(to:D.4217 [len: 4][implicit]) map(tofrom:n [len: 4][implicit])
issue is not new – only the '[implicit]' + the misaligned address one (fixed by
the patch from comment 1).
* * *
Thus regression → comment 1
***
And extra map(to:D.4217) – this occurs already with GCC 11 and is, thus, not a
regression.
(Only '[implicit]' is new.)
This seems to be due to a scope issue. In gimplify_omp_for
(gdb) p debug(for_stmt)
#pragma omp for nowait
for (i0 = 1; i0 <= D.4217; i0 = i0 + 1)
REALPART_EXPR <scalar> = (real(kind=8)) n;
which then calls at some point
omp_notice_variable (
debug_tree(decl) which ends up with
7698 nflags |= GOVD_MAP | GOVD_MAP_TO_ONLY;
The problem is that here
integer(kind=4) D.3933;
is generated in the parent scope of '#omp target' instead of in the parent
scope of '#omp parallel do'.
Thus, there are two questions:
* Why is 'map(to:' and not 'firstprivate' used?
* Why is the var generated in the parent scope of 'omp target' instead of
inside 'omp target'?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/103416] [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit])
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2021-11-25 10:52 ` burnus at gcc dot gnu.org
@ 2021-11-25 11:21 ` burnus at gcc dot gnu.org
2021-11-25 11:24 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-11-25 11:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Created attachment 51872
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51872&action=edit
RFC Patch to avoid the pointless evaluation, see comment 4
(In reply to Tobias Burnus from comment #3)
> * Why is the var generated in the parent scope of 'omp target' instead of
> inside 'omp target'?
The problem is a forced evaluation of the array bounds, which I regard as
pointless if the variable is just a plain variable - no array ref, not struct
ref no ...
Cf. attachment. (The question is when 'force=true' is needed and whether the
DECL_P check is the right one or whether more or less should be permitted.)
This is indeed the same as issue as PR80330 (8...)
* * *
The
libgomp: cuCtxSynchronize error: misaligned address
is a regression – see comment 1 for a patch which fixes it. This is PR90030
(9...)
* * *
> * Why is 'map(to:' and not 'firstprivate' used?
Because of:
gfc_omp_predetermined_mapping (tree decl)
{
if (DECL_ARTIFICIAL (decl)
&& ! GFC_DECL_RESULT (decl)
&& ! (DECL_LANG_SPECIFIC (decl)
&& GFC_DECL_SAVED_DESCRIPTOR (decl)))
return OMP_CLAUSE_DEFAULTMAP_TO;
I wonder whether OMP_DEFAULTMAP_FIRSTPRIVATE wouldn't make more sense in this
case – at least for gfc_omp_scalar_target_p ?
Which is also related to PR80330 (8...)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/103416] [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit])
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2021-11-25 11:21 ` burnus at gcc dot gnu.org
@ 2021-11-25 11:24 ` burnus at gcc dot gnu.org
2021-12-02 11:07 ` [Bug middle-end/103416] [OpenMP] Double mapping via " burnus at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-11-25 11:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #4)
> Created attachment 51872 [details]
> RFC Patch to avoid the pointless evaluation, see comment 4
The default was supposed to be 'false' - to be overridden where needed.
Otherwise, the 'false' has to added in gfc_trans_omp_do under
/* Evaluate all the expressions in the iterator. */
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/103416] [OpenMP] Double mapping via firstprivate(n) map(to:n [len: 4][implicit])
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2021-11-25 11:24 ` burnus at gcc dot gnu.org
@ 2021-12-02 11:07 ` burnus at gcc dot gnu.org
2022-05-06 8:32 ` [Bug fortran/103416] [OpenMP] Double mapping via firstprivate(n) map(to:n [len: 4][implicit]) of loop bounds jakub at gcc dot gnu.org
2023-05-08 12:23 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-12-02 11:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12 Regression][OpenMP] |[OpenMP] Double mapping via
|Bogus firstprivate(n) |firstprivate(n) map(to:n
|map(to:n [len: |[len: 4][implicit])
|4][implicit]) |
Keywords|wrong-code |missed-optimization
--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> ---
I changed the bug subject as the "12 Regression" issue has been fixed (cf.
below,
committed with reference to PR90030 not to this PR) – but the code-improvement
part still remains to be done.
* * *
(In reply to Chung-Lin Tang from comment #1)
> Can you see if adding this patch:
> https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583279.html
> fixes this problem? If so, then it should be another occurrence of PR90030
This patch is now committed:
commit r12-5706-g1ac7a8c9e4798d352eb8c64905dd38086af4e1cd
Author: Chung-Lin Tang <cltang@codesourcery.com>
Date: Thu Dec 2 18:24:03 2021 +0800
fortran: OpenMP/OpenACC array mapping alignment fix (PR90030)
* * *
TODO: LOOP VAR double mapping – cf. PR80330, i.e.
map(to:D.4217 [len: 4][implicit]) map(tofrom:n [len: 4][implicit])
where the loop variable is mapped twice.
See Comment 4 for what remains to be done and a draft patch.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/103416] [OpenMP] Double mapping via firstprivate(n) map(to:n [len: 4][implicit]) of loop bounds
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
` (6 preceding siblings ...)
2021-12-02 11:07 ` [Bug middle-end/103416] [OpenMP] Double mapping via " burnus at gcc dot gnu.org
@ 2022-05-06 8:32 ` jakub at gcc dot gnu.org
2023-05-08 12:23 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-06 8:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|12.0 |12.2
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 12.1 is being released, retargeting bugs to GCC 12.2.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/103416] [OpenMP] Double mapping via firstprivate(n) map(to:n [len: 4][implicit]) of loop bounds
2021-11-24 18:41 [Bug middle-end/103416] New: [12 Regression][OpenMP] Bogus firstprivate(n) map(to:n [len: 4][implicit]) burnus at gcc dot gnu.org
` (7 preceding siblings ...)
2022-05-06 8:32 ` [Bug fortran/103416] [OpenMP] Double mapping via firstprivate(n) map(to:n [len: 4][implicit]) of loop bounds jakub at gcc dot gnu.org
@ 2023-05-08 12:23 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-08 12:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103416
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|12.3 |12.4
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.3 is being released, retargeting bugs to GCC 12.4.
^ permalink raw reply [flat|nested] 10+ messages in thread