* [Bug c/96810] This is a case that gcc shoud not compile successfully, but gcc acts opposite.
2020-08-27 8:11 [Bug c/96810] New: This is a case that gcc shoud not compile successfully, but gcc acts opposite weiwt.fnst at cn dot fujitsu.com
@ 2020-08-27 8:49 ` jakub at gcc dot gnu.org
2020-08-28 5:12 ` weiwt.fnst at cn dot fujitsu.com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-27 8:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96810
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The standard says this is unspecified behavior, but the unspecified behavior
happens at runtime, so if the compiler could detect it at compile time, it
would need to be at most a warning (if the code is never called, there is no
unspecified behavior). Generally this isn't something that can be detected at
compile time, e.g. the target data can be in a different function from target,
or there could be target exit data that unmaps it in between and makes it
valid, or the fact that the pointer must alias the array could be not known to
the compiler, etc.
And the testcase is rejected at runtime:
libgomp: Trying to map into device [0x7ffc13463cbc..0x7ffc13463d0c) object when
[0x7ffc13463cb0..0x7ffc13463cc0) is already mapped
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/96810] This is a case that gcc shoud not compile successfully, but gcc acts opposite.
2020-08-27 8:11 [Bug c/96810] New: This is a case that gcc shoud not compile successfully, but gcc acts opposite weiwt.fnst at cn dot fujitsu.com
2020-08-27 8:49 ` [Bug c/96810] " jakub at gcc dot gnu.org
@ 2020-08-28 5:12 ` weiwt.fnst at cn dot fujitsu.com
2020-08-28 14:39 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: weiwt.fnst at cn dot fujitsu.com @ 2020-08-28 5:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96810
--- Comment #2 from Wei Wentao <weiwt.fnst at cn dot fujitsu.com> ---
> --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> >The standard says this is unspecified behavior, but the unspecified behavior
> >happens at runtime, so if the compiler could detect it at compile time, it
> >would need to be at most a warning (if the code is never called, there is no
> >unspecified behavior). Generally this isn't something that can be detected at
> >compile time, e.g. the target data can be in a different function from target,
> >or there could be target exit data that unmaps it in between and makes it
> >valid, or the fact that the pointer must alias the array could be not known to
> >the compiler, etc.
> >And the testcase is rejected at runtime:
> >libgomp: Trying to map into device [0x7ffc13463cbc..0x7ffc13463d0c) object when
> > [0x7ffc13463cb0..0x7ffc13463cc0) is already mapped
When I use clang to compile the same case, the compilation fails which is in
line with expectations and is opposite to the result of gcc. The details show
as below:
clang version 11.0.0
clang /.../llvm/build/bin/clang -fopenmp-version=50 -fopenmp
-I/.../common.deb.ompt.optional/include/ Example array_sections.2.c
Example_array_sections.2.c:19:7: error: original storage of expression in data
environment is shared but data environment do not fully contain mapped
expression storage
A[2] = 0;
^
Example_array_sections.2.c:11:30: note: used here
#pragma omp target data map( A[0:4] )
^~~~~~
1 error generated.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/96810] This is a case that gcc shoud not compile successfully, but gcc acts opposite.
2020-08-27 8:11 [Bug c/96810] New: This is a case that gcc shoud not compile successfully, but gcc acts opposite weiwt.fnst at cn dot fujitsu.com
2020-08-27 8:49 ` [Bug c/96810] " jakub at gcc dot gnu.org
2020-08-28 5:12 ` weiwt.fnst at cn dot fujitsu.com
@ 2020-08-28 14:39 ` jakub at gcc dot gnu.org
2020-08-31 8:28 ` weiwt.fnst at cn dot fujitsu.com
2020-09-03 5:14 ` weiwt.fnst at cn dot fujitsu.com
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-28 14:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96810
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Last reconfirmed| |2020-08-28
Resolution|INVALID |---
Ever confirmed|0 |1
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually sorry, the diagnostics clang emits is not about the bug mentioned in
the testcase, but about something different.
And while the bug described in the comment is really hard to diagnose at
compile time and in most cases impossible, what clang diagnoses is the fact
that
the target construct has implicit map(tofrom:A) clause and because the target
data maps only a small part of it, it mapping in target construct will fail.
Still, clang implements it incorrectly, it e.g. rejects:
int A[30];
void
foo (void)
{
#pragma omp target data map (A[0:4])
#pragma omp target
A[2] = 0;
}
int
main ()
{
#pragma omp target data map (A)
foo ();
return 0;
}
or
void bar (int *, int);
void
foo (void)
{
int A[30];
bar (A, 0);
#pragma omp target data map (A[0:4])
#pragma omp target
A[2] = 0;
bar (A, 1);
}
Both are completely valid and e.g. the latter could work just fine at runtime
if bar performs #pragma omp target enter data (arg1[:30]) for arg2 0 and exit
data for arg2 non-zero.
Perhaps a warning might be ok, but it still can have many false positives
(unless the compiler can prove that the array can't be mapped before the outer
target data).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/96810] This is a case that gcc shoud not compile successfully, but gcc acts opposite.
2020-08-27 8:11 [Bug c/96810] New: This is a case that gcc shoud not compile successfully, but gcc acts opposite weiwt.fnst at cn dot fujitsu.com
` (2 preceding siblings ...)
2020-08-28 14:39 ` jakub at gcc dot gnu.org
@ 2020-08-31 8:28 ` weiwt.fnst at cn dot fujitsu.com
2020-09-03 5:14 ` weiwt.fnst at cn dot fujitsu.com
4 siblings, 0 replies; 6+ messages in thread
From: weiwt.fnst at cn dot fujitsu.com @ 2020-08-31 8:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96810
--- Comment #4 from Wei Wentao <weiwt.fnst at cn dot fujitsu.com> ---
>>--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
>>Actually sorry, the diagnostics clang emits is not about the bug mentioned in
>>the testcase, but about something different.
>>And while the bug described in the comment is really hard to diagnose at
>>compile time and in most cases impossible, what clang diagnoses is the fact
>>that
>>the target construct has implicit map(tofrom:A) clause and because the target
>>data maps only a small part of it, it mapping in target construct will fail.
>>Still, clang implements it incorrectly, it e.g. rejects:
>>int A[30];
>>void
>>foo (void)
>>{
>> #pragma omp target data map (A[0:4])
>> #pragma omp target
>> A[2] = 0;
>>}
>>int
>>main ()
>>{
>> #pragma omp target data map (A)
>> foo ();
>> return 0;
>>}
>>or
>>void bar (int *, int);
>>void
>>foo (void)
>>{
>> int A[30];
>> bar (A, 0);
>> #pragma omp target data map (A[0:4])
>> #pragma omp target
>> A[2] = 0;
>> bar (A, 1);
>>}
>>Both are completely valid and e.g. the latter could work just fine at runtime
>>if bar performs #pragma omp target enter data (arg1[:30]) for arg2 0 and exit
>>data for arg2 non-zero.
>>Perhaps a warning might be ok, but it still can have many false positives
>>(unless the compiler can prove that the array can't be mapped before the outer
>>target data).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/96810] This is a case that gcc shoud not compile successfully, but gcc acts opposite.
2020-08-27 8:11 [Bug c/96810] New: This is a case that gcc shoud not compile successfully, but gcc acts opposite weiwt.fnst at cn dot fujitsu.com
` (3 preceding siblings ...)
2020-08-31 8:28 ` weiwt.fnst at cn dot fujitsu.com
@ 2020-09-03 5:14 ` weiwt.fnst at cn dot fujitsu.com
4 siblings, 0 replies; 6+ messages in thread
From: weiwt.fnst at cn dot fujitsu.com @ 2020-09-03 5:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96810
--- Comment #5 from Wei Wentao <weiwt.fnst at cn dot fujitsu.com> ---
Sorry for the last comment.I don't know how this happened.
Let's get to the point.
>>And while the bug described in the comment is really hard to diagnose at
>>compile time and in most cases impossible, what clang diagnoses is the fact
>>that
>>the target construct has implicit map(tofrom:A) clause and because the target
>>data maps only a small part of it, it mapping in target construct will fail.
>>Still, clang implements it incorrectly,
>>Both are completely valid and e.g. the latter could work just fine at runtime
>>if bar performs #pragma omp target enter data (arg1[:30]) for arg2 0 and exit
>>data for arg2 non-zero.
Thank you for your explanation. I agree with that. May I think that clang can
at least emit a diagnostic while gcc did nothing?
Since clang can find the problem in implicit the map, why can't it and gcc find
the problem in the explicit map?
Does it mean that there are some areas in gcc need to be improved? That is what
I am wondering about.
^ permalink raw reply [flat|nested] 6+ messages in thread