[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / openmp / libomptarget / test / ompt / veccopy_data.c
blob3bac258fbc779987229ac8fe118a21c7216d3ee3
1 // RUN: %libomptarget-compile-run-and-check-generic
2 // REQUIRES: ompt
3 // UNSUPPORTED: aarch64-unknown-linux-gnu
4 // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
6 /*
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.
13 #include <omp.h>
14 #include <stdio.h>
16 #include "callbacks.h"
17 #include "register_emi.h"
19 #define N 100000
21 #pragma omp declare target
22 int c[N];
23 #pragma omp end declare target
25 int main() {
26 int a[N];
27 int b[N];
29 int i;
31 for (i = 0; i < N; i++)
32 a[i] = 0;
34 for (i = 0; i < N; i++)
35 b[i] = i;
37 for (i = 0; i < N; i++)
38 c[i] = 0;
40 #pragma omp target enter data map(to : a)
41 #pragma omp target parallel for
43 for (int j = 0; j < N; j++)
44 a[j] = b[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++)
51 c[j] = 2 * j + 1;
53 #pragma omp target update from(c) nowait
54 #pragma omp barrier
56 int rc = 0;
57 for (i = 0; i < N; i++) {
58 if (a[i] != i) {
59 rc++;
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) {
66 rc++;
67 printf("Wrong value: c[%d]=%d\n", i, c[i]);
71 if (!rc)
72 printf("Success\n");
74 return rc;
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: