Debian Codegraph @

gcc/testsuite/c-c++-common/gomp/append-args-6.c

raw
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 typedef enum omp_interop_fr_t
16 {
17 omp_ifr_cuda = 1,
18 omp_ifr_cuda_driver = 2,
19 omp_ifr_opencl = 3,
20 omp_ifr_sycl = 4,
21 omp_ifr_hip = 5,
22 omp_ifr_level_zero = 6,
23 omp_ifr_hsa = 7,
24 omp_ifr_last = omp_ifr_hsa
25 } omp_interop_fr_t;
26
27
28
29 void g(int, const char *, int *, int *, omp_interop_t, omp_interop_t) { }
30 #pragma omp declare variant(g) match(construct={dispatch}) \
31 append_args(interop(target,prefer_type( {fr("cuda") }, {fr(omp_ifr_hsa)} , {attr("ompx_a") } , {fr(omp_ifr_hip) }), targetsync), \
32 interop(targetsync, prefer_type("cuda", "hsa"))) adjust_args(need_device_ptr : y, k)
33 void f(int x, const char *y, int *, int *k) { }
34
35
36 void gvar(int, const char *, int *, int *, omp_interop_t, omp_interop_t, ...) { }
37 #pragma omp declare variant(gvar) match(construct={dispatch}) \
38 append_args(interop(target,prefer_type( {fr("cuda") }, {fr(omp_ifr_hsa)} , {attr("ompx_a") } , {fr(omp_ifr_hip) }), targetsync), \
39 interop(targetsync, prefer_type("cuda", "hsa"))) adjust_args(need_device_ptr : y, k)
40 void fvar(int x, const char *y, int *, int *k, ...) { }
41
42
43
44 void foo(const char *cp1, const char *cp2, int *a, int *b, int *c)
45 {
46 omp_interop_t obj1, obj2, obj3, obj4;
47 obj1 = obj2 = obj3 = obj4 = omp_interop_none;
48
49 #pragma omp dispatch device(5) interop(obj1,obj2) is_device_ptr(cp1)
50 f(3, cp1, a, b);
51
52 #pragma omp dispatch device(4) interop(obj3,obj4) is_device_ptr(a,b,c)
53 fvar(99, cp2, a, b, c, a, b, c, a, b, c);
54 }
55
56
57
58
59 int *fi();
60
61 struct t {
62 int *a, *b;
63 };
64
65 void fancy(int *x, int *y, omp_interop_t) { }
66
67 #pragma omp declare variant(fancy) match(construct={dispatch}) adjust_args(need_device_ptr: x,y) \
68 append_args( interop (prefer_type(omp_ifr_hip), target) )
69 void bar(int *x, int *y);
70
71 void sub(struct t *s, void *y, const omp_interop_t obj5, omp_interop_t obj6)
72 {
73 bar( fi(), s->b);
74
75 // This is a bit questionable as dereferencing 's' as device pointer might not work (unspecified behavior);
76 // but if for 's->b' it would still be need even if 's' was a device + host accessible pointer.
77 #pragma omp dispatch device(3) is_device_ptr(s) interop(obj5)
78 bar( fi(), s->b);
79
80 bar( (int *) y, s->b);
81 #pragma omp dispatch interop(obj6) is_device_ptr(y)
82 bar( (int *) y, s->b);
83 }
84
85
86 /* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 4 "gimple" } } */
87
88 /* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_interop_int \\(obj6, -5, 0B\\);" 1 "gimple" } } */
89
90 /* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(5\\);" 1 "gimple" } } */
91 /* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(4\\);" 1 "gimple" } } */
92 /* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(3\\);" 1 "gimple" } } */
93 /* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\.\[0-9\]+\\);" 5 "gimple" } } */
94
95 /* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(b, 5\\);" 1 "gimple" } } */
96 /* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(cp2, 4\\);" 1 "gimple" } } */
97 /* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(cp2, 4\\);" 1 "gimple" } } */
98 /* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(cp2, 4\\);" 1 "gimple" } } */
99 /* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(D\.\[0-9\]+, 3\\);" 2 "gimple" } } */
100 /* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(D\.\[0-9\]+, D\.\[0-9\]+\\);" 1 "gimple" } } */
101
102 /* { dg-final { scan-tree-dump-times "g \\(3, cp1, a, D\.\[0-9\]+, obj1, obj2\\);" 1 "gimple" } } */
103 /* { dg-final { scan-tree-dump-times "gvar \\(99, D\.\[0-9\]+, a, b, obj3, obj4, c, a, b, c, a, b, c\\);" 1 "gimple" } } */
104
105 /* { dg-final { scan-tree-dump-times "fancy \\(D\.\[0-9\]+, D\.\[0-9\]+, obj5\\);" 1 "gimple" } } */
106 /* { dg-final { scan-tree-dump-times "fancy \\(y, D\.\[0-9\]+, obj6\\);" 1 "gimple" } } */