Debian Codegraph @

gcc/testsuite/g++.dg/gomp/append-args-1.C

raw
1 /* The following definitions are in omp_lib, which cannot be included
2 gcc/testsuite/g++.dg/gomp/append-args-1.C in gcc/testsuite/ */
3
4 #if __cplusplus >= 201103L
5 # define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
6 #else
7 # define __GOMP_UINTPTR_T_ENUM
8 #endif
9
10 typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
11 {
12 omp_interop_none = 0,
13 __omp_interop_t_max__ = __UINTPTR_MAX__
14 } omp_interop_t;
15
16 template<typename T, typename T2>
17 float repl1(T, T2, T2);
18 #pragma omp declare variant(repl1) match(construct={dispatch}) append_args(interop(target,prefer_type(1,5,4)), interop(targetsync))
19 template<typename T>
20 float base1(T);
21
22
23
24
25
26 template<typename T, typename T2, typename T3>
27 void repl3inval(T, T2, float);
28 #pragma omp declare variant(repl3inval) match(construct={dispatch}) adjust_args(nothing : y) \
29 append_args(interop(prefer_type({fr(3), attr("ompx_nop")},{fr(2)},{attr("ompx_all")}),target,targetsync))
30 template<typename T, typename T2>
31 void base2inval(T x, T2 y);
32
33 /* { dg-error "no matching function for call to 'repl3inval\\(int\\*, omp_interop_t, omp_interop_t\\)'" "" { target *-*-* } .-5 } */
34 /* { dg-note "there is 1 candidate" "" { target *-*-* } .-6 } */
35 /* { dg-note "candidate 1: 'template<class T, class T2, class T3> void repl3inval\\(T, T2, float\\)'" "" { target *-*-* } .-8 } */
36 /* { dg-note "template argument deduction/substitution failed:" "" { target *-*-* } .-9 } */
37 /* { dg-note "couldn't deduce template parameter 'T3'" "" { target *-*-* } .-9 } */
38
39
40 template<typename T>
41 void repl99(T);
42 #pragma omp declare variant(repl99) match(construct={dispatch}) \
43 append_args(interop(target, targetsync, prefer_type("cuda")))
44 void base99();
45
46
47
48 template<typename T, typename T2, typename T3>
49 void repl2(T, T2, T3, T3);
50 #pragma omp declare variant(repl2) match(construct={dispatch}) adjust_args(need_device_ptr : y) \
51 append_args(interop(target, targetsync, prefer_type(1)), \
52 interop(target, prefer_type({fr(3), attr("ompx_nop")},{fr(2)},{attr("ompx_all")})))
53 template<typename T, typename T2>
54 void base2(T x, T2 y);
55
56
57 template<typename T,typename T3>
58 void tooFewRepl(T, T, T3);
59 #pragma omp declare variant(tooFewRepl) match(construct={dispatch}) \
60 append_args(interop(target, targetsync, prefer_type(1)), \
61 interop(target, prefer_type({fr(3), attr("ompx_nop")},{fr(2)},{attr("ompx_all")})))
62 template<typename T, typename T2>
63 void tooFewBase(T x, T2 y);
64
65 /* { dg-error "no matching function for call to 'tooFewRepl\\(int\\*, int\\*, omp_interop_t, omp_interop_t\\)'" "" { target *-*-* } .-6 } */
66 /* { dg-note "there is 1 candidate" "" { target *-*-* } .-7 } */
67 /* { dg-note "candidate 1: 'template<class T, class T3> void tooFewRepl\\(T, T, T3\\)'" "" { target *-*-* } .-9 } */
68 /* { dg-note "candidate expects 3 arguments, 4 provided" "" { target *-*-* } .-10 } */
69
70
71
72 template<typename T, typename T2>
73 void repl3(T, T2, ...);
74 #pragma omp declare variant(repl3) match(construct={dispatch}) \
75 append_args(interop(target, prefer_type("cuda", "hsa")))
76 template<typename T>
77 void base3(T, ...);
78
79
80
81
82 float
83 test (int *a, int *b)
84 {
85 omp_interop_t obj1, obj2;
86 float x, y;
87
88 #pragma omp dispatch interop ( obj1, obj2 ) device(2) // OK
89 x = base1<short> (5);
90
91 #pragma omp dispatch interop ( obj1, obj2 ) // { dg-error "the 'device' clause must be present if the 'interop' clause has more than one list item" }
92 x = base1<short> (5);
93
94 #pragma omp dispatch
95 base2inval<int *, omp_interop_t> (a, omp_interop_none);
96
97 #pragma omp dispatch
98 base99 ();
99
100 #pragma omp dispatch interop ( obj1 )
101 base2<int *, omp_interop_t> (b, omp_interop_none);
102
103 #pragma omp dispatch interop ( obj1 )
104 base2<int *, int *> (b, a);
105
106 #pragma omp dispatch interop ( obj1 )
107 x = base1<omp_interop_t> (omp_interop_none);
108
109 #pragma omp dispatch interop ( obj1 )
110 x = base1<float> (1.0f);
111
112 #pragma omp dispatch
113 tooFewBase<int*,int*>(a,b);
114
115 #pragma omp dispatch nocontext(1)
116 base3<int*>(a, 1, 2, "abc");
117
118 #pragma omp dispatch
119 base3<int*>(a, 1, 2, "abc");
120
121 return x;
122 }