1 | // The test supposes no offload, pure host execution. |
2 | // It checks that the bug in implementation of distribute construct is fixed. |
3 | |
4 | // RUN: %libomp-compile-and-run |
5 | |
6 | // gcc/icc target offloading is incompatible with libomp |
7 | // UNSUPPORTED: icc, gcc |
8 | |
9 | #include <stdio.h> |
10 | #include <omp.h> |
11 | |
12 | int main() |
13 | { |
14 | const int size = 4; |
15 | int wrong_counts = 0; |
16 | omp_set_num_threads(2); |
17 | #pragma omp parallel reduction(+:wrong_counts) |
18 | { |
19 | int i; |
20 | int A[size]; |
21 | int th = omp_get_thread_num(); |
22 | for(i = 0; i < size; i++) |
23 | A[i] = 0; |
24 | |
25 | #pragma omp target teams distribute map(tofrom: A[:size]) private(i) |
26 | for(i = 0; i < size; i++) |
27 | { |
28 | A[i] = i; |
29 | printf(format: "th %d, team %d, i %d\n" , th, omp_get_team_num(), i); |
30 | } |
31 | #pragma omp critical |
32 | { |
33 | printf(format: "tid = %d\n" , th); |
34 | for(i = 0; i < size; i++) |
35 | { |
36 | if (A[i] != i) wrong_counts++; |
37 | printf(format: " %d" , A[i]); |
38 | } |
39 | printf(format: "\n" ); |
40 | } |
41 | } |
42 | if (wrong_counts) { |
43 | printf(format: "failed\n" ); |
44 | } else { |
45 | printf(format: "passed\n" ); |
46 | } |
47 | return wrong_counts; |
48 | } |
49 | |