public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/95270] New: OpenACC 'enter data attach(data_p)' fails for 'int *data_p'
@ 2020-05-22 13:22 tschwinge at gcc dot gnu.org
2020-06-08 18:53 ` [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size tschwinge at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2020-05-22 13:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95270
Bug ID: 95270
Summary: OpenACC 'enter data attach(data_p)' fails for 'int
*data_p'
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: openacc
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: tschwinge at gcc dot gnu.org
CC: jakub at gcc dot gnu.org, jules at gcc dot gnu.org
Target Milestone: ---
Created attachment 48581
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48581&action=edit
'mdc-2b_.c'
See test case attached: 'acc_attach(&data_p)' works, '#pragma enter data
attach(data_p)' doesn't.
In such a case, I suppose we either need to explicitly set 'OMP_CLAUSE_SIZE' in
all front ends, or otherwise make sure to skip/invalidate the
'gcc/gimplify.c:gimplify_scan_omp_clauses' handling:
if (OMP_CLAUSE_SIZE (c) == NULL_TREE)
OMP_CLAUSE_SIZE (c) = DECL_P (decl) ? DECL_SIZE_UNIT (decl)
: TYPE_SIZE_UNIT (TREE_TYPE (decl));
..., or elsewhere?
Given that for 'GOMP_MAP_ATTACH' etc. this is a *bias*, not a *size*, I'd like
to see this explicitly mentioned/handled in the code, under the assumption that
for 'GOMP_MAP_STRUCT'-related 'GOMP_MAP_ATTACH', we do need this set non-zero.
Also need to update the comments in 'include/gomp-constants.h:enum
gomp_map_kind' to explain that (see 'GOMP_MAP_POINTER' example?).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size
2020-05-22 13:22 [Bug middle-end/95270] New: OpenACC 'enter data attach(data_p)' fails for 'int *data_p' tschwinge at gcc dot gnu.org
@ 2020-06-08 18:53 ` tschwinge at gcc dot gnu.org
2020-06-08 19:25 ` jules at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2020-06-08 18:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95270
Thomas Schwinge <tschwinge at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jules at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Target Milestone|--- |10.0
Summary|OpenACC 'enter data |OpenACC 'enter data attach'
|attach(data_p)' fails for |looks up target memory
|'int *data_p' |object displaced by pointer
| |size
Last reconfirmed| |2020-06-08
Ever confirmed|0 |1
--- Comment #1 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
I just hit this one again, started to debug it once again (until I finally
remembered this existing issue...), and cried a little bit. ;'-|
Julian, this is a bug, right? During gimplification, or in the front end(s)?
Please have a look.
This issue is also visible in the (current) 'omplower' tree dump scans in
'c-c++-common/goacc/mdc-1.c': expecting 'bias: 8'. (Pointer size, by the way;
cross-checked with '-m32' where we get 'bias: 4'.)
I'd thought I remember that I may work around this by wrapping pointers as
'struct' members, which would then 'attach' correctly, without size/bias
confusion, but apparently that's not true; the attached 'mdc-2b_.c' fails in
the same way even if altered as follows:
- int *data_p = &data;
+#if 0
+ int *data_p;
+#else
+ struct s {
+ int *data_p;
+ } s;
+# define data_p s.data_p
+#endif
+ data_p = &data;
What you instead have to do is to make sure that your target memory object
(here: 'data') is bigger than the bias (pointer size):
- int data;
+ struct { char d[sizeof (void *) + 1]; } data;
Then it works, in all variants I've now posted.
Execution test cases that would ("might") exercise/notice this behavior:
- 'libgomp.oacc-c-c++-common/deep-copy-2.c' -- works despite the bug, because
the '#pragma acc data copy(s.a[0:10])' already synthesizes an implicit
'map(attach:s.a [bias: 0])' (correct) and thus the incorrect 'map(attach:s.a
[bias: 8])' synthesized for the inner '#pragma acc parallel loop attach(s.a)'
doesn't cause a problem, as 'bias' is only used in the first call of the
respective 'gomp_attach_pointer'.
- 'libgomp.oacc-c-c++-common/deep-copy-4.c' -- works despite the bug, because
for a struct bigger than the bias ('struct node' here), a 'splay_tree_lookup'
with start offset by bias will then still look up the expected object,
apparently. With the 'val'/'sum' business removed, this test case quickly
fails: 'libgomp: pointer target not mapped for attach'.
- 'libgomp.oacc-fortran/deep-copy-6.f90' -- correctly synthesizes
'map(attach:var.a [bias: 0])' for '!$acc enter data attach(var%a)'. However,
for the earlier '!$acc enter data copyin(var%a(5:n - 5), var%b(5:n - 5))'
synthesizes the two 'gomp_attach_pointer' calls both with 'bias = 16' -- seems
to work, but is that correct?
- 'libgomp.oacc-fortran/deep-copy-8.f90' -- correctly synthesizes
'map(attach:var.a [bias: 0])' for '!$acc enter data attach(var%a)'.
That's all with an explicit 'attach' clause, folks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size
2020-05-22 13:22 [Bug middle-end/95270] New: OpenACC 'enter data attach(data_p)' fails for 'int *data_p' tschwinge at gcc dot gnu.org
2020-06-08 18:53 ` [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size tschwinge at gcc dot gnu.org
@ 2020-06-08 19:25 ` jules at gcc dot gnu.org
2020-07-09 22:44 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jules at gcc dot gnu.org @ 2020-06-08 19:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95270
--- Comment #2 from jules at gcc dot gnu.org ---
TBH I've suspected problems with misuse of the bias for attach/detach before,
but I've not come up with a test case. I'll have a look.
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size
2020-05-22 13:22 [Bug middle-end/95270] New: OpenACC 'enter data attach(data_p)' fails for 'int *data_p' tschwinge at gcc dot gnu.org
2020-06-08 18:53 ` [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size tschwinge at gcc dot gnu.org
2020-06-08 19:25 ` jules at gcc dot gnu.org
@ 2020-07-09 22:44 ` cvs-commit at gcc dot gnu.org
2020-07-13 17:14 ` cvs-commit at gcc dot gnu.org
2022-01-09 0:33 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-09 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95270
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Julian Brown <jules@gcc.gnu.org>:
https://gcc.gnu.org/g:0d00fe404c162ad0cf922ca8455aa23a74042b63
commit r11-1976-g0d00fe404c162ad0cf922ca8455aa23a74042b63
Author: Julian Brown <julian@codesourcery.com>
Date: Tue Jun 9 06:21:34 2020 -0700
openacc: Set bias to zero for explicit attach/detach clauses in C and C++
This is a fix for the pointer (or array) size inadvertently being used
for the bias with attach and detach mapping kinds, for both C and C++.
2020-07-09 Julian Brown <julian@codesourcery.com>
Thomas Schwinge <thomas@codesourcery.com>
gcc/c/
PR middle-end/95270
* c-typeck.c (c_finish_omp_clauses): Set OMP_CLAUSE_SIZE (bias) to
zero
for standalone attach/detach clauses.
gcc/cp/
PR middle-end/95270
* semantics.c (finish_omp_clauses): Likewise.
include/
PR middle-end/95270
* gomp-constants.h (gomp_map_kind): Expand comment for
attach/detach
mapping kinds.
gcc/testsuite/
PR middle-end/95270
* c-c++-common/goacc/mdc-1.c: Update expected dump output for zero
bias.
libgomp/
PR middle-end/95270
* testsuite/libgomp.oacc-c-c++-common/pr95270-1.c: New test.
* testsuite/libgomp.oacc-c-c++-common/pr95270-2.c: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size
2020-05-22 13:22 [Bug middle-end/95270] New: OpenACC 'enter data attach(data_p)' fails for 'int *data_p' tschwinge at gcc dot gnu.org
` (2 preceding siblings ...)
2020-07-09 22:44 ` cvs-commit at gcc dot gnu.org
@ 2020-07-13 17:14 ` cvs-commit at gcc dot gnu.org
2022-01-09 0:33 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-13 17:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95270
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Julian Brown
<jules@gcc.gnu.org>:
https://gcc.gnu.org/g:2974e1eee053496e1d43f7f2e62f5feac2aa0315
commit r10-8475-g2974e1eee053496e1d43f7f2e62f5feac2aa0315
Author: Julian Brown <julian@codesourcery.com>
Date: Tue Jun 9 06:21:34 2020 -0700
openacc: Set bias to zero for explicit attach/detach clauses in C and C++
This is a fix for the pointer (or array) size inadvertently being used
for the bias with attach and detach mapping kinds, for both C and C++.
2020-07-09 Julian Brown <julian@codesourcery.com>
Thomas Schwinge <thomas@codesourcery.com>
gcc/c/
PR middle-end/95270
* c-typeck.c (c_finish_omp_clauses): Set OMP_CLAUSE_SIZE (bias) to
zero
for standalone attach/detach clauses.
gcc/cp/
PR middle-end/95270
* semantics.c (finish_omp_clauses): Likewise.
include/
PR middle-end/95270
* gomp-constants.h (gomp_map_kind): Expand comment for
attach/detach
mapping kinds.
gcc/testsuite/
PR middle-end/95270
* c-c++-common/goacc/mdc-1.c: Update expected dump output for zero
bias.
libgomp/
PR middle-end/95270
* testsuite/libgomp.oacc-c-c++-common/pr95270-1.c: New test.
* testsuite/libgomp.oacc-c-c++-common/pr95270-2.c: New test.
(cherry picked from commit 0d00fe404c162ad0cf922ca8455aa23a74042b63)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size
2020-05-22 13:22 [Bug middle-end/95270] New: OpenACC 'enter data attach(data_p)' fails for 'int *data_p' tschwinge at gcc dot gnu.org
` (3 preceding siblings ...)
2020-07-13 17:14 ` cvs-commit at gcc dot gnu.org
@ 2022-01-09 0:33 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-09 0:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95270
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|10.0 |10.2
Status|ASSIGNED |RESOLVED
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-09 0:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 13:22 [Bug middle-end/95270] New: OpenACC 'enter data attach(data_p)' fails for 'int *data_p' tschwinge at gcc dot gnu.org
2020-06-08 18:53 ` [Bug middle-end/95270] OpenACC 'enter data attach' looks up target memory object displaced by pointer size tschwinge at gcc dot gnu.org
2020-06-08 19:25 ` jules at gcc dot gnu.org
2020-07-09 22:44 ` cvs-commit at gcc dot gnu.org
2020-07-13 17:14 ` cvs-commit at gcc dot gnu.org
2022-01-09 0:33 ` pinskia 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).