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 shows that both EMI and non-EMI |
12 | * callbacks cannot be registered for the same type. In the |
13 | * current implementation, the EMI callback overrides the non-EMI |
14 | * callback. |
15 | */ |
16 | |
17 | #include <omp.h> |
18 | #include <stdio.h> |
19 | |
20 | #include "callbacks.h" |
21 | #include "register_both.h" |
22 | |
23 | int main() { |
24 | int N = 100000; |
25 | |
26 | int a[N]; |
27 | int b[N]; |
28 | |
29 | int i; |
30 | |
31 | for (i = 0; i < N; i++) |
32 | a[i] = 0; |
33 | |
34 | for (i = 0; i < N; i++) |
35 | b[i] = i; |
36 | |
37 | #pragma omp target parallel for |
38 | { |
39 | for (int j = 0; j < N; j++) |
40 | a[j] = b[j]; |
41 | } |
42 | |
43 | #pragma omp target teams distribute parallel for |
44 | { |
45 | for (int j = 0; j < N; j++) |
46 | a[j] = b[j]; |
47 | } |
48 | |
49 | int rc = 0; |
50 | for (i = 0; i < N; i++) |
51 | if (a[i] != b[i]) { |
52 | rc++; |
53 | printf(format: "Wrong value: a[%d]=%d\n" , i, a[i]); |
54 | } |
55 | |
56 | if (!rc) |
57 | printf(format: "Success\n" ); |
58 | |
59 | return rc; |
60 | } |
61 | |
62 | /// CHECK: Callback Init: |
63 | /// CHECK: Callback Load: |
64 | /// CHECK: Callback Target EMI: kind=1 endpoint=1 |
65 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=1 |
66 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=1 |
67 | /// CHECK-NOT: dest=(nil) |
68 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=2 |
69 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=2 |
70 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=1 |
71 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=1 |
72 | /// CHECK-NOT: dest=(nil) |
73 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=2 |
74 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=2 |
75 | /// CHECK: Callback Submit: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] req_num_teams=1 |
76 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=3 |
77 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=3 |
78 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=3 |
79 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=3 |
80 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=4 |
81 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=4 |
82 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=4 |
83 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=4 |
84 | /// CHECK: Callback Target EMI: kind=1 endpoint=2 |
85 | /// CHECK: Callback Target EMI: kind=1 endpoint=1 |
86 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=1 |
87 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=1 |
88 | /// CHECK-NOT: dest=(nil) |
89 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=2 |
90 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=2 |
91 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=1 |
92 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=1 |
93 | /// CHECK-NOT: dest=(nil) |
94 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=2 |
95 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=2 |
96 | /// CHECK: Callback Submit: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] req_num_teams=0 |
97 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=3 |
98 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=3 |
99 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=3 |
100 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=3 |
101 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=4 |
102 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=4 |
103 | /// CHECK: Callback DataOp EMI: endpoint=1 optype=4 |
104 | /// CHECK: Callback DataOp EMI: endpoint=2 optype=4 |
105 | /// CHECK: Callback Target EMI: kind=1 endpoint=2 |
106 | /// CHECK: Callback Fini: |
107 | |