| 1 |
/* { dg-do compile { target c++11 } } */ |
| 2 |
/* { dg-additional-options "-fdump-tree-gimple" } */ |
| 3 |
|
| 4 |
|
| 5 |
#if __cplusplus >= 201103L |
| 6 |
# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__ |
| 7 |
#else |
| 8 |
# define __GOMP_UINTPTR_T_ENUM |
| 9 |
#endif |
| 10 |
|
| 11 |
typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM |
| 12 |
{ |
| 13 |
omp_interop_none = 0, |
| 14 |
__omp_interop_t_max__ = __UINTPTR_MAX__ |
| 15 |
} omp_interop_t; |
| 16 |
|
| 17 |
typedef enum omp_interop_fr_t |
| 18 |
{ |
| 19 |
omp_ifr_cuda = 1, |
| 20 |
omp_ifr_cuda_driver = 2, |
| 21 |
omp_ifr_opencl = 3, |
| 22 |
omp_ifr_sycl = 4, |
| 23 |
omp_ifr_hip = 5, |
| 24 |
omp_ifr_level_zero = 6, |
| 25 |
omp_ifr_hsa = 7, |
| 26 |
omp_ifr_last = omp_ifr_hsa |
| 27 |
} omp_interop_fr_t; |
| 28 |
|
| 29 |
|
| 30 |
template<typename T2> |
| 31 |
float repl0(T2, T2); |
| 32 |
#pragma omp declare variant(repl0) match(construct={dispatch}) append_args(interop(target,prefer_type(1,5,4)), interop(targetsync)) |
| 33 |
float base0(); |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
template<typename T, typename T2> |
| 38 |
float repl1(T x, T2 y, T2 z) { return sizeof(x) + y == z; } |
| 39 |
#pragma omp declare variant(repl1) match(construct={dispatch}) append_args(interop(target,prefer_type(1,5,4,sizeof(T))), interop(targetsync)) |
| 40 |
template<typename T> |
| 41 |
float base1(T x) { return x + 42; } |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
template<typename T, typename T2, typename T3> |
| 46 |
void repl3inval(T, T2, T3); |
| 47 |
#pragma omp declare variant(repl3inval) match(construct={dispatch}) adjust_args(nothing : y) \ |
| 48 |
append_args(interop(prefer_type({fr(3), attr("ompx_nop")},{fr(2)},{attr("ompx_all")}),target,targetsync)) |
| 49 |
template<typename T, typename T2> |
| 50 |
void base2inval(T x, T2 y); |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
template<typename T> |
| 55 |
void repl99(T); |
| 56 |
#pragma omp declare variant(repl99) match(construct={dispatch}) \ |
| 57 |
append_args(interop(target, targetsync, prefer_type("cuda"))) |
| 58 |
template<typename T> |
| 59 |
void base99(); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
template<typename T, typename T2, typename T3> |
| 64 |
void repl2(T, T2, T3, T3); |
| 65 |
#pragma omp declare variant(repl2) match(construct={dispatch}) adjust_args(need_device_ptr : y) \ |
| 66 |
append_args(interop(target, targetsync, prefer_type(1)), \ |
| 67 |
interop(target, targetsync, prefer_type({fr(3), attr("ompx_nop")},{fr(2)},{attr("ompx_all")}))) |
| 68 |
template<typename T, typename T2> |
| 69 |
void base2(T x, T2 y); |
| 70 |
|
| 71 |
|
| 72 |
omp_interop_t obj2, obj3; |
| 73 |
|
| 74 |
void |
| 75 |
test_it (char *str, int i, int *ip, float *fp, omp_interop_t obj1) |
| 76 |
{ |
| 77 |
#pragma omp dispatch interop(obj2, obj1) device(99) |
| 78 |
base0 (); |
| 79 |
|
| 80 |
float f2; |
| 81 |
#pragma omp dispatch interop(obj1, obj2) device(14) |
| 82 |
f2 = base1 (*fp); |
| 83 |
fp[0] = f2; |
| 84 |
|
| 85 |
#pragma omp dispatch interop(obj1) |
| 86 |
base2inval (str, i); |
| 87 |
|
| 88 |
#pragma omp dispatch interop(obj2) device(21) |
| 89 |
base99<double>(); |
| 90 |
|
| 91 |
#pragma omp dispatch interop(obj3, obj1) device(31) |
| 92 |
base2(fp, ip); |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
/* { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 5 "gimple" } } */ |
| 98 |
|
| 99 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(99\\);" 1 "gimple" } } */ |
| 100 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(14\\);" 1 "gimple" } } */ |
| 101 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(21\\);" 1 "gimple" } } */ |
| 102 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(31\\);" 1 "gimple" } } */ |
| 103 |
|
| 104 |
/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\\.\[0-9\]+\\);" 6 "gimple" } } */ |
| 105 |
|
| 106 |
/* { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = __builtin_omp_get_interop_int \\(obj1, -5, 0B\\);" 1 "gimple" } } */ |
| 107 |
/* { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(ip, 31\\);" 1 "gimple" } } */ |
| 108 |
|
| 109 |
/* { dg-final { scan-tree-dump-times "repl0<omp_interop_t> \\(obj2\\.\[0-9\], obj1\\);" 1 "gimple" } } */ |
| 110 |
/* { dg-final { scan-tree-dump-times "f2 = repl1<float, omp_interop_t> \\(D\\.\[0-9\]+, obj1, obj2\\.\[0-9\]\\);" 1 "gimple" } } */ |
| 111 |
/* { dg-final { scan-tree-dump-times "repl3inval<char\\*, int, omp_interop_t> \\(str, i, obj1\\);" 1 "gimple" } } */ |
| 112 |
/* { dg-final { scan-tree-dump-times "repl99<omp_interop_t> \\(obj2\\.\[0-9\]\\);" 1 "gimple" } } */ |
| 113 |
/* { dg-final { scan-tree-dump-times "repl2<float\\*, int\\*, omp_interop_t> \\(fp, D\\.\[0-9\]+, obj3\\.\[0-9\], obj1\\);" 1 "gimple" } } */ |