aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/target-41.c
blob: a300de4d009ebd3323e6f9709a1bc3a927333f7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* { 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 enter (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 () or
     omp_initial_device as the device.  */
  #pragma omp target if (v)
  foo ();
  #pragma omp target device (omp_initial_device)
  foo ();
  #pragma omp target device (omp_get_initial_device ())
  foo ();
  omp_set_default_device (omp_get_initial_device ());
  #pragma omp target
  foo ();
  if (v != 4)
    abort ();
  return 0;
}