[memprof] Upgrade a unit test to MemProf Version 3 (#117063)
[llvm-project.git] / openmp / runtime / test / teams / teams-distr-on-host.c
blob7b77d05fa978f03f5e982a89329730e0f23053b5
1 // The test supposes no offload, pure host execution.
2 // It checks that the bug in implementation of distribute construct is fixed.
4 // RUN: %libomp-compile-and-run
6 // gcc/icc target offloading is incompatible with libomp
7 // UNSUPPORTED: icc, gcc
9 #include <stdio.h>
10 #include <omp.h>
12 int main()
14 const int size = 4;
15 int wrong_counts = 0;
16 omp_set_num_threads(2);
17 #pragma omp parallel reduction(+:wrong_counts)
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;
25 #pragma omp target teams distribute map(tofrom: A[:size]) private(i)
26 for(i = 0; i < size; i++)
28 A[i] = i;
29 printf("th %d, team %d, i %d\n", th, omp_get_team_num(), i);
31 #pragma omp critical
33 printf("tid = %d\n", th);
34 for(i = 0; i < size; i++)
36 if (A[i] != i) wrong_counts++;
37 printf(" %d", A[i]);
39 printf("\n");
42 if (wrong_counts) {
43 printf("failed\n");
44 } else {
45 printf("passed\n");
47 return wrong_counts;