Debian Codegraph @

libgomp/testsuite/libgomp.c/target-48.c

raw
1 /* Check OMP_TARGET_OFFLOAD on systems with no available non-host devices;
2 omp_invalid_device == -4 with GCC. */
3
4 /* { dg-do run { target { ! offload_device } } } */
5 /* { dg-set-target-env-var OMP_TARGET_OFFLOAD "mandatory" } */
6
7 /* { dg-output ".*OMP_DEFAULT_DEVICE = '-4'.*OMP_TARGET_OFFLOAD = 'MANDATORY'.*" } */
8
9 #include <omp.h>
10
11 int
12 main ()
13 {
14 if (omp_get_default_device () != omp_invalid_device)
15 __builtin_abort ();
16
17 omp_set_default_device (omp_initial_device);
18
19 /* The spec is a bit unclear whether the line above sets the device number
20 (a) to -1 (= omp_initial_device) or
21 (b) to omp_get_initial_device() == omp_get_num_devices(). Therefore,
22 we accept either value. */
23
24 if (omp_get_default_device() != omp_get_initial_device()
25 && omp_get_default_device() != omp_initial_device)
26 __builtin_abort ();
27
28 omp_display_env (0);
29
30 return 0;
31 }