1 // RUN: %libomp-compile-and-run
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()
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*);
28 for( i
= 0; i
< N
; ++i
)
33 #pragma omp parallel num_threads(4)
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)
44 __kmpc_doacross_wait(NULL
,gtid
,&vec
);
46 iter
[i
] = iter
[i
-1] + 1;
47 // runtime call corresponding to #pragma omp ordered depend(source)
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
) {
57 printf("failed %d != %d\n", iter
[N
-1], N
);