blob: 0c34cab56d2f4e1635c9c7158f75157b914d95b7 (
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
|
/* Testing 'has_device_addr' clause on the target construct with template. */
#include <omp.h>
template <typename T>
void
foo (T (&x))
{
#pragma omp target has_device_addr(x)
x = 24;
}
int
main ()
{
int *dp = (int*)omp_target_alloc (sizeof(int), 0);
int &x = *dp;
foo <int> (x);
int y = 42;
int h = omp_get_initial_device ();
int t = omp_get_default_device ();
omp_target_memcpy (&y, dp, sizeof(int), 0, 0, h, t);
if (y != 24)
__builtin_abort ();
omp_target_free (dp, 0);
return 0;
}
|