1 | // RUN: %libomptarget-compile-run-and-check-generic |
2 | // REQUIRES: ompt |
3 | // UNSUPPORTED: aarch64-unknown-linux-gnu |
4 | // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO |
5 | // UNSUPPORTED: x86_64-pc-linux-gnu |
6 | // UNSUPPORTED: x86_64-pc-linux-gnu-LTO |
7 | // UNSUPPORTED: s390x-ibm-linux-gnu |
8 | // UNSUPPORTED: s390x-ibm-linux-gnu-LTO |
9 | |
10 | /* |
11 | * Example OpenMP program that registers EMI callbacks |
12 | */ |
13 | |
14 | #include <assert.h> |
15 | #include <omp.h> |
16 | #include <stdio.h> |
17 | |
18 | #include "callbacks.h" |
19 | #include "register_emi.h" |
20 | |
21 | int main() { |
22 | int N = 100000; |
23 | |
24 | int a[N]; |
25 | int b[N]; |
26 | |
27 | int i; |
28 | |
29 | for (i = 0; i < N; i++) |
30 | a[i] = 0; |
31 | |
32 | for (i = 0; i < N; i++) |
33 | b[i] = i; |
34 | |
35 | #pragma omp target parallel for |
36 | { |
37 | for (int j = 0; j < N; j++) |
38 | a[j] = b[j]; |
39 | } |
40 | |
41 | #pragma omp target teams distribute parallel for |
42 | { |
43 | for (int j = 0; j < N; j++) |
44 | a[j] = b[j]; |
45 | } |
46 | |
47 | int rc = 0; |
48 | for (i = 0; i < N; i++) |
49 | if (a[i] != b[i]) { |
50 | rc++; |
51 | printf(format: "Wrong value: a[%d]=%d\n" , i, a[i]); |
52 | } |
53 | |
54 | if (!rc) |
55 | printf(format: "Success\n" ); |
56 | |
57 | return rc; |
58 | } |
59 | |
60 | /// CHECK: Callback Init: |
61 | /// CHECK: Callback Load: |
62 | /// CHECK: Callback Target EMI: kind=1 endpoint=1 |
63 | /// CHECK-NOT: code=(nil) |
64 | /// CHECK: code=[[CODE1:.*]] |
65 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=1 |
66 | /// CHECK: code=[[CODE1]] |
67 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=1 |
68 | /// CHECK-NOT: dest=(nil) |
69 | /// CHECK: code=[[CODE1]] |
70 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=2 |
71 | /// CHECK: code=[[CODE1]] |
72 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=2 |
73 | /// CHECK: code=[[CODE1]] |
74 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=1 |
75 | /// CHECK: code=[[CODE1]] |
76 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=1 |
77 | /// CHECK-NOT: dest=(nil) |
78 | /// CHECK: code=[[CODE1]] |
79 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=2 |
80 | /// CHECK: code=[[CODE1]] |
81 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=2 |
82 | /// CHECK: code=[[CODE1]] |
83 | /// CHECK: Callback Submit EMI: endpoint=1 req_num_teams=1 |
84 | /// CHECK: Callback Submit EMI: endpoint=2 req_num_teams=1 |
85 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=3 |
86 | /// CHECK: code=[[CODE1]] |
87 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=3 |
88 | /// CHECK: code=[[CODE1]] |
89 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=3 |
90 | /// CHECK: code=[[CODE1]] |
91 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=3 |
92 | /// CHECK: code=[[CODE1]] |
93 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=4 |
94 | /// CHECK: code=[[CODE1]] |
95 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=4 |
96 | /// CHECK: code=[[CODE1]] |
97 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=4 |
98 | /// CHECK: code=[[CODE1]] |
99 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=4 |
100 | /// CHECK: code=[[CODE1]] |
101 | /// CHECK: Callback Target EMI: kind=1 endpoint=2 |
102 | /// CHECK: code=[[CODE1]] |
103 | |
104 | /// CHECK: Callback Target EMI: kind=1 endpoint=1 |
105 | /// CHECK-NOT: code=(nil) |
106 | /// CHECK: code=[[CODE2:.*]] |
107 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=1 |
108 | /// CHECK: code=[[CODE2]] |
109 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=1 |
110 | /// CHECK-NOT: dest=(nil) |
111 | /// CHECK: code=[[CODE2]] |
112 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=2 |
113 | /// CHECK: code=[[CODE2]] |
114 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=2 |
115 | /// CHECK: code=[[CODE2]] |
116 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=1 |
117 | /// CHECK: code=[[CODE2]] |
118 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=1 |
119 | /// CHECK-NOT: dest=(nil) |
120 | /// CHECK: code=[[CODE2]] |
121 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=2 |
122 | /// CHECK: code=[[CODE2]] |
123 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=2 |
124 | /// CHECK: code=[[CODE2]] |
125 | /// CHECK: Callback Submit EMI: endpoint=1 req_num_teams=0 |
126 | /// CHECK: Callback Submit EMI: endpoint=2 req_num_teams=0 |
127 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=3 |
128 | /// CHECK: code=[[CODE2]] |
129 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=3 |
130 | /// CHECK: code=[[CODE2]] |
131 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=3 |
132 | /// CHECK: code=[[CODE2]] |
133 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=3 |
134 | /// CHECK: code=[[CODE2]] |
135 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=4 |
136 | /// CHECK: code=[[CODE2]] |
137 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=4 |
138 | /// CHECK: code=[[CODE2]] |
139 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=4 |
140 | /// CHECK: code=[[CODE2]] |
141 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=4 |
142 | /// CHECK: code=[[CODE2]] |
143 | /// CHECK: Callback Target EMI: kind=1 endpoint=2 |
144 | /// CHECK: code=[[CODE2]] |
145 | /// CHECK: Callback Fini: |
146 | |