diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-11-24 10:30:32 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-11-24 10:30:32 +0100 |
commit | 5bca26742cf3357bf4e20ec97eee4c7f7de17ce0 (patch) | |
tree | c47407db15186348af5eb4ce842dd1d837c43fed /libgomp/testsuite/libgomp.c | |
parent | 709716b9f49f2fcf46f319000562cf6e61bd2f71 (diff) |
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.
Diffstat (limited to 'libgomp/testsuite/libgomp.c')
-rw-r--r-- | libgomp/testsuite/libgomp.c/declare-variant-2.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/declare-variant-2.c b/libgomp/testsuite/libgomp.c/declare-variant-2.c new file mode 100644 index 00000000000..666ab20ea5f --- /dev/null +++ b/libgomp/testsuite/libgomp.c/declare-variant-2.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ + +#include <omp.h> +#include <stdlib.h> + +void +foo_host (void) +{ + if (!omp_is_initial_device ()) + abort (); +} + +#pragma omp declare variant (foo_host) match (device={kind(host)}) +void +foo (void) +{ + if (omp_is_initial_device ()) + abort (); +} + +void +bar_nohost (void) +{ + if (omp_is_initial_device ()) + abort (); +} + +#pragma omp declare variant (bar_nohost) match (device={kind(nohost)}) +void +bar (void) +{ + if (!omp_is_initial_device ()) + abort (); +} + +int +main () +{ + #pragma omp target + { + foo (); + bar (); + } + return 0; +} |