public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/103384] New: [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works
@ 2021-11-23 14:27 burnus at gcc dot gnu.org
2021-11-23 14:59 ` [Bug middle-end/103384] " jakub at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-11-23 14:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103384
Bug ID: 103384
Summary: [OpenMP] declare variant with device={kind(nohost)}
does not use GPU, kind(gpu) works
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: openmp, wrong-code
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: jakub at gcc dot gnu.org
Target Milestone: ---
Created attachment 51861
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51861&action=edit
Testcase, fails as is (if omp_get_num_devices() > 0) and '{kind(nohost)}' -
works when later is changed to "match(device={kind(gpu)})"
Observed with
https://github.com/SOLLVE/sollve_vv/blob/master/tests/5.0/declare_target/test_declare_target_device_type_nohost.c
For that testcase with nvptx offloading, with
#pragma omp declare variant(target_function) match(device={kind(gpu)})
target_function() is called and the code is executed on the GPU
(value a[0] = 5 (host function 'update') + 1 (device function
'target_function') == 6).
However, using kind(nohost), i.e.
#pragma omp declare variant(target_function) match(device={kind(nohost)})
will *not* execute 'target_function' (thus: a[0] == 10 = 2*5 (host function
'update').
Expected: both {kind(nohost)} and {kind(gpu)} are executed on the GPU.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/103384] [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works
2021-11-23 14:27 [Bug middle-end/103384] New: [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works burnus at gcc dot gnu.org
@ 2021-11-23 14:59 ` jakub at gcc dot gnu.org
2021-11-24 9:35 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-23 14:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103384
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Would
--- gcc/omp-general.c.jj 2021-10-15 11:59:16.135683948 +0200
+++ gcc/omp-general.c 2021-11-23 15:45:32.761468592 +0100
@@ -1487,16 +1487,22 @@ omp_context_selector_matches (tree ctx)
continue;
if (!strcmp (prop, "host"))
{
+#ifdef ACCEL_COMPILER
+ return 0;
+#else
if (omp_maybe_offloaded ())
ret = -1;
continue;
+#endif
}
if (!strcmp (prop, "nohost"))
{
+#ifndef ACCEL_COMPILER
if (omp_maybe_offloaded ())
ret = -1;
else
return 0;
+#endif
continue;
}
int r = 0;
fix this? In ACCEL_COMPILER we know that it is nohost, so for host we should
return 0 even if we earlier on the host side said it might be offloaded and so
defer, and for host we know it is ok.
I don't really like the test, in the SOLLVE test it just relies on no host
fallback without ensuring it, in your attached test omp_get_num_devices ()
doesn't guarantee no host fallback either. Check omp_is_initial_device () in
the target region instead?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/103384] [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works
2021-11-23 14:27 [Bug middle-end/103384] New: [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works burnus at gcc dot gnu.org
2021-11-23 14:59 ` [Bug middle-end/103384] " jakub at gcc dot gnu.org
@ 2021-11-24 9:35 ` cvs-commit at gcc dot gnu.org
2021-11-24 10:00 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-24 9:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103384
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:5bca26742cf3357bf4e20ec97eee4c7f7de17ce0
commit r12-5494-g5bca26742cf3357bf4e20ec97eee4c7f7de17ce0
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Nov 24 10:30:32 2021 +0100
openmp: Fix up handling of kind(host) and kind(nohost) in ACCEL_COMPILERs
[PR103384]
As the testcase shows, we weren't handling kind(host) and kind(nohost)
properly
in the ACCEL_COMPILERs, the code written in there is valid for the host
compiler only, where if we are maybe offloaded, we defer resolution after
IPA,
otherwise return 0 for kind(nohost) and accept it for kind(host). Note,
omp_maybe_offloaded is false after IPA. If ACCEL_COMPILER is defined, it
is
the other way around, but also we know we are after IPA.
2021-11-24 Jakub Jelinek <jakub@redhat.com>
PR middle-end/103384
gcc/
* omp-general.c (omp_context_selector_matches): For ACCEL_COMPILER,
return 0 for kind(host) and continue for kind(nohost).
libgomp/
* testsuite/libgomp.c/declare-variant-2.c: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/103384] [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works
2021-11-23 14:27 [Bug middle-end/103384] New: [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works burnus at gcc dot gnu.org
2021-11-23 14:59 ` [Bug middle-end/103384] " jakub at gcc dot gnu.org
2021-11-24 9:35 ` cvs-commit at gcc dot gnu.org
@ 2021-11-24 10:00 ` jakub at gcc dot gnu.org
2021-11-29 8:50 ` cvs-commit at gcc dot gnu.org
2022-05-10 8:22 ` cvs-commit at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-24 10:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103384
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/103384] [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works
2021-11-23 14:27 [Bug middle-end/103384] New: [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2021-11-24 10:00 ` jakub at gcc dot gnu.org
@ 2021-11-29 8:50 ` cvs-commit at gcc dot gnu.org
2022-05-10 8:22 ` cvs-commit at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-29 8:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103384
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:333b0dc1792f48e822ebaaea6e104539918f47f2
commit r11-9338-g333b0dc1792f48e822ebaaea6e104539918f47f2
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Nov 24 10:30:32 2021 +0100
openmp: Fix up handling of kind(host) and kind(nohost) in ACCEL_COMPILERs
[PR103384]
As the testcase shows, we weren't handling kind(host) and kind(nohost)
properly
in the ACCEL_COMPILERs, the code written in there is valid for the host
compiler only, where if we are maybe offloaded, we defer resolution after
IPA,
otherwise return 0 for kind(nohost) and accept it for kind(host). Note,
omp_maybe_offloaded is false after IPA. If ACCEL_COMPILER is defined, it
is
the other way around, but also we know we are after IPA.
2021-11-24 Jakub Jelinek <jakub@redhat.com>
PR middle-end/103384
gcc/
* omp-general.c (omp_context_selector_matches): For ACCEL_COMPILER,
return 0 for kind(host) and continue for kind(nohost).
libgomp/
* testsuite/libgomp.c/declare-variant-2.c: New test.
(cherry picked from commit 5bca26742cf3357bf4e20ec97eee4c7f7de17ce0)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/103384] [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works
2021-11-23 14:27 [Bug middle-end/103384] New: [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2021-11-29 8:50 ` cvs-commit at gcc dot gnu.org
@ 2022-05-10 8:22 ` cvs-commit at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-10 8:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103384
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:279e48e9d8e8d99a73d5ca69f829b83638419c56
commit r10-10658-g279e48e9d8e8d99a73d5ca69f829b83638419c56
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Nov 24 10:30:32 2021 +0100
openmp: Fix up handling of kind(host) and kind(nohost) in ACCEL_COMPILERs
[PR103384]
As the testcase shows, we weren't handling kind(host) and kind(nohost)
properly
in the ACCEL_COMPILERs, the code written in there is valid for the host
compiler only, where if we are maybe offloaded, we defer resolution after
IPA,
otherwise return 0 for kind(nohost) and accept it for kind(host). Note,
omp_maybe_offloaded is false after IPA. If ACCEL_COMPILER is defined, it
is
the other way around, but also we know we are after IPA.
2021-11-24 Jakub Jelinek <jakub@redhat.com>
PR middle-end/103384
gcc/
* omp-general.c (omp_context_selector_matches): For ACCEL_COMPILER,
return 0 for kind(host) and continue for kind(nohost).
libgomp/
* testsuite/libgomp.c/declare-variant-2.c: New test.
(cherry picked from commit 5bca26742cf3357bf4e20ec97eee4c7f7de17ce0)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-10 8:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 14:27 [Bug middle-end/103384] New: [OpenMP] declare variant with device={kind(nohost)} does not use GPU, kind(gpu) works burnus at gcc dot gnu.org
2021-11-23 14:59 ` [Bug middle-end/103384] " jakub at gcc dot gnu.org
2021-11-24 9:35 ` cvs-commit at gcc dot gnu.org
2021-11-24 10:00 ` jakub at gcc dot gnu.org
2021-11-29 8:50 ` cvs-commit at gcc dot gnu.org
2022-05-10 8:22 ` cvs-commit 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).