[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / worksharing / single / omp_single_copyprivate.c
blob2fece5c100a8caf7ec4217931a9cd8539dd44504
1 // RUN: %libomp-compile-and-run
2 #include "omp_testsuite.h"
4 #define DEBUG_TEST 0
6 int j;
7 #pragma omp threadprivate(j)
9 int test_omp_single_copyprivate()
11 int result;
12 int nr_iterations;
14 result = 0;
15 nr_iterations = 0;
16 #pragma omp parallel num_threads(4)
18 int i;
19 for (i = 0; i < LOOPCOUNT; i++)
21 #if DEBUG_TEST
22 int thread;
23 thread = omp_get_thread_num ();
24 #endif
25 #pragma omp single copyprivate(j)
27 nr_iterations++;
28 j = i;
29 #if DEBUG_TEST
30 printf ("thread %d assigns, j = %d, i = %d\n", thread, j, i);
31 #endif
33 #if DEBUG_TEST
34 #pragma omp barrier
35 #endif
36 #pragma omp critical
38 #if DEBUG_TEST
39 printf ("thread = %d, j = %d, i = %d\n", thread, j, i);
40 #endif
41 result = result + j - i;
43 #pragma omp barrier
44 } /* end of for */
45 } /* end of parallel */
46 return ((result == 0) && (nr_iterations == LOOPCOUNT));
49 int main()
51 int i;
52 int num_failed=0;
54 for(i = 0; i < REPETITIONS; i++) {
55 if(!test_omp_single_copyprivate()) {
56 num_failed++;
59 return num_failed;