diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-10-22 09:33:17 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-10-22 09:36:18 +0200 |
commit | 17c5b7e1dc47bab6e6cedbf4b2d88cef3283533e (patch) | |
tree | a9ec38b74bb225359a0733bcef526bb4add9fa22 /libgomp | |
parent | 552ed3ea761324bdd42c1a40d4bbef91432da29a (diff) | |
download | gcc-17c5b7e1dc47bab6e6cedbf4b2d88cef3283533e.tar.gz |
openmp: Add test for OMP_TARGET_OFFLOAD=mandatory for cases where it must not fail
2020-10-22 Jakub Jelinek <jakub@redhat.com>
* testsuite/libgomp.c/target-41.c: New test.
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/testsuite/libgomp.c/target-41.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/target-41.c b/libgomp/testsuite/libgomp.c/target-41.c new file mode 100644 index 00000000000..d8d756f80e9 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/target-41.c @@ -0,0 +1,33 @@ +/* { dg-set-target-env-var OMP_TARGET_OFFLOAD "mandatory" } */ + +#include <omp.h> +#include <stdlib.h> + +int v; + +void +foo (void) +{ + v++; +} + +#pragma omp declare target to (v, foo) + +int +main () +{ + /* OMP_TARGET_OFFLOAD=mandatory shouldn't fail for host fallback + if it is because the program explicitly asked for the host + fallback through if(false) or omp_get_initial_device () as + the device. */ + #pragma omp target if (v) + foo (); + #pragma omp target device (omp_get_initial_device ()) + foo (); + omp_set_default_device (omp_get_initial_device ()); + #pragma omp target + foo (); + if (v != 3) + abort (); + return 0; +} |