1 // RUN: %libomptarget-compile-run-and-check-generic
3 // UNSUPPORTED: aarch64-unknown-linux-gnu
4 // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
7 * Example OpenMP program that registers EMI callbacks.
8 * Explicitly testing for an initialized device num and
9 * #pragma omp target [data enter / data exit / update]
10 * The latter with the addition of a nowait clause.
16 #include "callbacks.h"
17 #include "register_emi.h"
21 #pragma omp declare target
23 #pragma omp end declare target
31 for (i
= 0; i
< N
; i
++)
34 for (i
= 0; i
< N
; i
++)
37 for (i
= 0; i
< N
; i
++)
40 #pragma omp target enter data map(to : a)
41 #pragma omp target parallel for
43 for (int j
= 0; j
< N
; j
++)
46 #pragma omp target exit data map(from : a)
48 #pragma omp target parallel for map(alloc : c)
50 for (int j
= 0; j
< N
; j
++)
53 #pragma omp target update from(c) nowait
57 for (i
= 0; i
< N
; i
++) {
60 printf("Wrong value: a[%d]=%d\n", i
, a
[i
]);
64 for (i
= 0; i
< N
; i
++) {
65 if (c
[i
] != 2 * i
+ 1) {
67 printf("Wrong value: c[%d]=%d\n", i
, c
[i
]);
77 /// CHECK-NOT: Callback Target EMI:
78 /// CHECK-NOT: device_num=-1
79 /// CHECK: Callback Init:
80 /// CHECK: Callback Load:
81 /// CHECK: Callback Target EMI: kind=2 endpoint=1
82 /// CHECK-NOT: device_num=-1
83 /// CHECK: Callback DataOp EMI: endpoint=1 optype=1
84 /// CHECK: Callback DataOp EMI: endpoint=2 optype=1
85 /// CHECK-NOT: dest=(nil)
86 /// CHECK: Callback DataOp EMI: endpoint=1 optype=2
87 /// CHECK: Callback DataOp EMI: endpoint=2 optype=2
88 /// CHECK: Callback Target EMI: kind=2 endpoint=2
89 /// CHECK-NOT: device_num=-1
90 /// CHECK: Callback Target EMI: kind=1 endpoint=1
91 /// CHECK-NOT: device_num=-1
92 /// CHECK: Callback DataOp EMI: endpoint=1 optype=1
93 /// CHECK: Callback DataOp EMI: endpoint=2 optype=1
94 /// CHECK-NOT: dest=(nil)
95 /// CHECK: Callback DataOp EMI: endpoint=1 optype=2
96 /// CHECK: Callback DataOp EMI: endpoint=2 optype=2
97 /// CHECK: Callback Submit EMI: endpoint=1 req_num_teams=1
98 /// CHECK: Callback Submit EMI: endpoint=2 req_num_teams=1
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 Target EMI: kind=1 endpoint=2
104 /// CHECK-NOT: device_num=-1
105 /// CHECK: Callback Target EMI: kind=3 endpoint=1
106 /// CHECK-NOT: device_num=-1
107 /// CHECK: Callback DataOp EMI: endpoint=1 optype=3
108 /// CHECK: Callback DataOp EMI: endpoint=2 optype=3
109 /// CHECK: Callback DataOp EMI: endpoint=1 optype=4
110 /// CHECK: Callback DataOp EMI: endpoint=2 optype=4
111 /// CHECK: Callback Target EMI: kind=3 endpoint=2
112 /// CHECK-NOT: device_num=-1
113 /// CHECK: Callback Target EMI: kind=1 endpoint=1
114 /// CHECK-NOT: device_num=-1
115 /// CHECK: Callback Submit EMI: endpoint=1 req_num_teams=1
116 /// CHECK: Callback Submit EMI: endpoint=2 req_num_teams=1
117 /// CHECK: Callback Target EMI: kind=1 endpoint=2
118 /// CHECK-NOT: device_num=-1
119 /// CHECK: Callback Target EMI: kind=4 endpoint=1
120 /// CHECK-NOT: device_num=-1
121 /// CHECK: Callback DataOp EMI: endpoint=1 optype=3
122 /// CHECK: Callback DataOp EMI: endpoint=2 optype=3
123 /// CHECK: Callback Target EMI: kind=4 endpoint=2
124 /// CHECK-NOT: device_num=-1
125 /// CHECK: Callback Fini: