1 // RUN: %libomptarget-compileopt-run-and-check-generic
3 // UNSUPPORTED: x86_64-pc-linux-gnu
4 // UNSUPPORTED: x86_64-pc-linux-gnu-LTO
5 // UNSUPPORTED: aarch64-unknown-linux-gnu
6 // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
14 int main(int argc
, char **argv
) {
20 float *X
= (float *)malloc(sizeof(*X
) * N
);
21 float *Y
= (float *)malloc(sizeof(*X
) * N
);
23 for (int i
= 0; i
< N
; i
++) {
29 int NT
= (N
+ TL
- 1) / TL
;
31 #pragma omp target data map(to : X [0:N]) map(Y [0:N])
32 #pragma omp target teams num_teams(NT) thread_limit(TL)
36 int tid
= ompx_thread_id_x();
37 int bid
= ompx_block_id_x();
38 int tdim
= ompx_block_dim_x();
39 int gid
= tid
+ bid
* tdim
;
41 Y
[gid
] = a
* X
[gid
] + Y
[gid
];
45 float maxError
= 0.0f
;
46 for (int i
= 0; i
< N
; i
++) {
47 maxError
= fmax(maxError
, fabs(Y
[i
] - 4.0f
));
49 printf("%i %f %f\n", i
, maxError
, Y
[i
]);
53 // CHECK: Max error: 0.00
54 printf("Max error: %f\n", maxError
);