Daily bump.
[gcc-git-mirror.git] / libgomp / testsuite / libgomp.c++ / target-has-device-addr-4.C
blob6468c6c8433bf020c5df8658e465fa3fd9db0122
1 #include <omp.h>
3 int
4 main ()
6   int *dp = (int*)omp_target_alloc (30*sizeof(int), 0);
8   #pragma omp target is_device_ptr(dp)
9     for (int i = 0; i < 30; i++)
10       dp[i] = i;
12   int (&x)[30] = *static_cast<int(*)[30]>(static_cast<void*>(dp));
14   #pragma omp target has_device_addr(x)
15     for (int i = 0; i < 30; i++)
16       x[i] = 2 * i;
18   #pragma omp target has_device_addr(x)
19     for (int i = 0; i < 30; i++)
20       if (x[i] != 2 * i)
21         __builtin_abort ();
23   #pragma omp target has_device_addr(x[1:5])
24     for (int i = 1; i < 6; i++)
25       x[i] = 3 * i;
27   #pragma omp target has_device_addr(x[1:5])
28     for (int i = 1; i < 6; i++)
29       if (x[i] != 3 * i)
30         __builtin_abort ();
32   omp_target_free (dp, 0);