[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / worksharing / for / kmp_doacross_check.c
blob59b61e32eb16a97cd9d3ed31f109aca933529384
1 // RUN: %libomp-compile-and-run
2 // UNSUPPORTED: gcc
3 // This test is incompatible with gcc because of the explicit call to
4 // __kmpc_doacross_fini(). gcc relies on an implicit call to this function
5 // when the last iteration is executed inside the GOMP_loop_*_next() functions.
6 // Hence, in gcc, having the explicit call leads to __kmpc_doacross_fini()
7 // being called twice.
8 #include <stdio.h>
10 #define N 1000
12 struct dim {
13 long long lo; // lower
14 long long up; // upper
15 long long st; // stride
17 extern void __kmpc_doacross_init(void*, int, int, struct dim *);
18 extern void __kmpc_doacross_wait(void*, int, long long*);
19 extern void __kmpc_doacross_post(void*, int, long long*);
20 extern void __kmpc_doacross_fini(void*, int);
21 extern int __kmpc_global_thread_num(void*);
23 int main()
25 int i;
26 int iter[N];
27 struct dim dims;
28 for( i = 0; i < N; ++i )
29 iter[i] = 1;
30 dims.lo = 1;
31 dims.up = N-1;
32 dims.st = 1;
33 #pragma omp parallel num_threads(4)
35 int i, gtid;
36 long long vec;
37 gtid = __kmpc_global_thread_num(NULL);
38 __kmpc_doacross_init(NULL,gtid,1,&dims); // thread starts the loop
39 #pragma omp for nowait schedule(dynamic)
40 for( i = 1; i < N; ++i )
42 // runtime call corresponding to #pragma omp ordered depend(sink:i-1)
43 vec=i-1;
44 __kmpc_doacross_wait(NULL,gtid,&vec);
45 // user's code
46 iter[i] = iter[i-1] + 1;
47 // runtime call corresponding to #pragma omp ordered depend(source)
48 vec=i;
49 __kmpc_doacross_post(NULL,gtid,&vec);
51 // thread finishes the loop (should be before the loop barrier)
52 __kmpc_doacross_fini(NULL,gtid);
54 if( iter[N-1] == N ) {
55 printf("passed\n");
56 } else {
57 printf("failed %d != %d\n", iter[N-1], N);
58 return 1;
60 return 0;