Debian Codegraph @

libgomp/testsuite/libgomp.c++/target-has-device-addr-4.C

raw
1 #include <omp.h>
2
3 int
4 main ()
5 {
6 int *dp = (int*)omp_target_alloc (30*sizeof(int), 0);
7
8 #pragma omp target is_device_ptr(dp)
9 for (int i = 0; i < 30; i++)
10 dp[i] = i;
11
12 int (&x)[30] = *static_cast<int(*)[30]>(static_cast<void*>(dp));
13
14 #pragma omp target has_device_addr(x)
15 for (int i = 0; i < 30; i++)
16 x[i] = 2 * i;
17
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 ();
22
23 #pragma omp target has_device_addr(x[1:5])
24 for (int i = 1; i < 6; i++)
25 x[i] = 3 * i;
26
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 ();
31
32 omp_target_free (dp, 0);
33 }