| 1 |
/* { dg-additional-options "-fdump-tree-gimple" } */ |
| 2 |
|
| 3 |
#if __cplusplus >= 201103L |
| 4 |
# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__ |
| 5 |
#else |
| 6 |
# define __GOMP_UINTPTR_T_ENUM |
| 7 |
#endif |
| 8 |
|
| 9 |
typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM |
| 10 |
{ |
| 11 |
omp_interop_none = 0, |
| 12 |
__omp_interop_t_max__ = __UINTPTR_MAX__ |
| 13 |
} omp_interop_t; |
| 14 |
|
| 15 |
void f1(omp_interop_t) { } |
| 16 |
#pragma omp declare variant(f1) match(construct={dispatch}) \ |
| 17 |
append_args(interop(target, prefer_type({attr("ompx_fun")}))) |
| 18 |
void g1(void); |
| 19 |
|
| 20 |
|
| 21 |
int f2(omp_interop_t, omp_interop_t); |
| 22 |
#pragma omp declare variant(f2) \ |
| 23 |
append_args(interop(target, prefer_type("cuda")), \ |
| 24 |
interop(prefer_type({fr("hsa")}),target)) \ |
| 25 |
match(construct={dispatch}) |
| 26 |
int g2(void) { return 5; } |
| 27 |
|
| 28 |
int foo (omp_interop_t obj1) |
| 29 |
{ |
| 30 |
omp_interop_t obj2 = omp_interop_none; |
| 31 |
int res; |
| 32 |
|
| 33 |
#pragma omp dispatch interop(obj1) device(11) |
| 34 |
g1(); |
| 35 |
|
| 36 |
#pragma omp dispatch interop(obj1, obj2) device(22) |
| 37 |
g2(); |
| 38 |
|
| 39 |
#pragma omp dispatch interop(obj2, obj1) device(33) |
| 40 |
res = g2(); |
| 41 |
|
| 42 |
return res; |
| 43 |
} |
| 44 |
|
| 45 |
/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 3 "gimple" } } */ |
| 46 |
|
| 47 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(11\\);" 1 "gimple" } } */ |
| 48 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(22\\);" 1 "gimple" } } */ |
| 49 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(33\\);" 1 "gimple" } } */ |
| 50 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\.\[0-9\]+\\);" 3 "gimple" } } */ |
| 51 |
|
| 52 |
/* { dg-final { scan-tree-dump-times " f1 \\(obj1\\);" 1 "gimple" } } */ |
| 53 |
/* { dg-final { scan-tree-dump-times " f2 \\(obj1, obj2\\);" 1 "gimple" } } */ |
| 54 |
/* { dg-final { scan-tree-dump-times " res = f2 \\(obj2, obj1\\);" 1 "gimple" } } */ |