| 1 |
/* Testing 'has_device_addr' clause on the target construct with template. */ |
| 2 |
|
| 3 |
#include <omp.h> |
| 4 |
|
| 5 |
template <typename T> |
| 6 |
void |
| 7 |
foo (T (&x)) |
| 8 |
{ |
| 9 |
#pragma omp target has_device_addr(x) |
| 10 |
x = 24; |
| 11 |
} |
| 12 |
|
| 13 |
int |
| 14 |
main () |
| 15 |
{ |
| 16 |
int *dp = (int*)omp_target_alloc (sizeof(int), 0); |
| 17 |
int &x = *dp; |
| 18 |
|
| 19 |
foo <int> (x); |
| 20 |
|
| 21 |
int y = 42; |
| 22 |
int h = omp_get_initial_device (); |
| 23 |
int t = omp_get_default_device (); |
| 24 |
omp_target_memcpy (&y, dp, sizeof(int), 0, 0, h, t); |
| 25 |
if (y != 24) |
| 26 |
__builtin_abort (); |
| 27 |
|
| 28 |
omp_target_free (dp, 0); |
| 29 |
return 0; |
| 30 |
} |