| 1 |
/* { dg-additional-options "-fdump-tree-original" } */ |
| 2 |
|
| 3 |
/* The following definitions are in omp_lib, which cannot be included |
| 4 |
in gcc/testsuite/ */ |
| 5 |
|
| 6 |
#if __cplusplus >= 201103L |
| 7 |
# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__ |
| 8 |
#else |
| 9 |
# define __GOMP_UINTPTR_T_ENUM |
| 10 |
#endif |
| 11 |
|
| 12 |
typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM |
| 13 |
{ |
| 14 |
omp_interop_none = 0, |
| 15 |
__omp_interop_t_max__ = __UINTPTR_MAX__ |
| 16 |
} omp_interop_t; |
| 17 |
|
| 18 |
|
| 19 |
float repl1(); |
| 20 |
#pragma omp declare variant(repl1) match(construct={dispatch}) |
| 21 |
float base1(); |
| 22 |
|
| 23 |
void repl2(int *, int *); |
| 24 |
#pragma omp declare variant(repl2) match(construct={dispatch}) adjust_args(need_device_ptr : y) |
| 25 |
void base2(int *x, int *y); |
| 26 |
|
| 27 |
void repl3(int *, int *, omp_interop_t); |
| 28 |
#pragma omp declare variant(repl3) match(construct={dispatch}) adjust_args(need_device_ptr : y) append_args(interop(target)) |
| 29 |
void base3(int *x, int *y); |
| 30 |
|
| 31 |
|
| 32 |
float |
| 33 |
dupl (int *a, int *b) |
| 34 |
{ |
| 35 |
omp_interop_t obj1, obj2; |
| 36 |
float x; |
| 37 |
|
| 38 |
#pragma omp dispatch interop ( obj1 ) interop(obj2) device(2) /* { dg-error "too many 'interop' clauses" } */ |
| 39 |
x = base1 (); |
| 40 |
/* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */ |
| 41 |
/* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'float repl1\\(\\)'" "" { target c++ } .-3 } */ |
| 42 |
|
| 43 |
#pragma omp dispatch interop ( obj1) nocontext(1) interop (obj2 ) device(2)/* { dg-error "too many 'interop' clauses" } */ |
| 44 |
base2 (a, b); |
| 45 |
return x; |
| 46 |
} |
| 47 |
|
| 48 |
/* { dg-note "'declare variant' candidate 'repl1' declared here" "" { target c } 19 } */ |
| 49 |
/* { dg-note "'declare variant' candidate 'float repl1\\(\\)' declared here" "" { target c++ } 19 } */ |
| 50 |
|
| 51 |
|
| 52 |
/* { dg-note "'declare variant' candidate 'repl2' declared here" "" { target c } 23 } */ |
| 53 |
/* { dg-note "'declare variant' candidate 'void repl2\\(int\\*, int\\*\\)' declared here" "" { target c++ } 23 } */ |
| 54 |
|
| 55 |
|
| 56 |
/* { dg-note "'declare variant' candidate 'repl3' declared here" "" { target c } 28 } */ |
| 57 |
/* { dg-note "'declare variant' candidate 'void repl3\\(int\\*, int\\*, omp_interop_t\\)' declared here" "" { target c++ } 28 } */ |
| 58 |
|
| 59 |
float |
| 60 |
test (int *a, int *b) |
| 61 |
{ |
| 62 |
omp_interop_t obj1, obj2, obj3; |
| 63 |
float x, y; |
| 64 |
|
| 65 |
#pragma omp dispatch interop ( obj1 ) |
| 66 |
x = base1 (); |
| 67 |
/* { dg-error "number of list items in 'interop' clause \\(1\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */ |
| 68 |
/* { dg-error "number of list items in 'interop' clause \\(1\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'float repl1\\(\\)'" "" { target c++ } .-3 } */ |
| 69 |
|
| 70 |
#pragma omp dispatch interop ( obj1, obj1 ) device(42) /* Twice the same - should be fine. */ |
| 71 |
x = base1 (); |
| 72 |
/* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */ |
| 73 |
/* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'float repl1\\(\\)'" "" { target c++ } .-3 } */ |
| 74 |
|
| 75 |
#pragma omp dispatch novariants(1) interop(obj2, obj1) device(0) |
| 76 |
y = base1 (); |
| 77 |
|
| 78 |
#pragma omp dispatch interop(obj2, obj1) device(3) |
| 79 |
base2 (a, b); |
| 80 |
/* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'repl2'" "" { target c } .-2 } */ |
| 81 |
/* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'void repl2\\(int\\*, int\\*\\)'" "" { target c++ } .-3 } */ |
| 82 |
|
| 83 |
#pragma omp dispatch interop(obj2) nocontext(1) |
| 84 |
base2 (a, b); |
| 85 |
|
| 86 |
#pragma omp dispatch interop(obj3, obj2) device(2) |
| 87 |
base3 (a, b); |
| 88 |
/* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(1\\) for 'declare variant' candidate 'repl3'" "" { target c } .-2 } */ |
| 89 |
/* { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(1\\) for 'declare variant' candidate 'void repl3\\(int\\*, int\\*, omp_interop_t\\)'" "" { target c++ } .-3 } */ |
| 90 |
|
| 91 |
#pragma omp dispatch interop(obj3) |
| 92 |
base3 (a, b); |
| 93 |
return x + y; |
| 94 |
} |
| 95 |
|
| 96 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\)\[\\n\\r\]" 1 "original" } } */ |
| 97 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch device\\(42\\) interop\\(obj1\\) interop\\(obj1\\)\[\\n\\r\]" 1 "original" } } */ |
| 98 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch device\\(0\\) interop\\(obj1\\) interop\\(obj2\\) novariants\\(1\\)\[\\n\\r\]" 1 "original" } } */ |
| 99 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch device\\(3\\) interop\\(obj1\\) interop\\(obj2\\)\[\\n\\r\]" 1 "original" } } */ |
| 100 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch nocontext\\(1\\) interop\\(obj2\\)\[\\n\\r\]" 1 "original" } } */ |
| 101 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch device\\(2\\) interop\\(obj2\\) interop\\(obj3\\)\[\\n\\r\]" 1 "original" } } */ |
| 102 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj3\\)\[\\n\\r\]" 1 "original" } } */ |