1 // RUN: %libomp-compile-and-run
2 // XFAIL: gcc-4, gcc-5, clang-3.7, clang-3.8, icc-15, icc-16
5 #include "omp_testsuite.h"
13 // Allocate and zero out the matrix
14 int *m
= (int *)malloc(sizeof(int) * N
* N
);
15 for (i
= 0; i
< N
; ++i
) {
16 for (j
= 0; j
< N
; ++j
) {
20 // Have first row and column be 0, 1, 2, 3, etc.
21 for (i
= 0; i
< N
; ++i
)
23 for (j
= 0; j
< N
; ++j
)
25 // Perform wavefront which results in matrix:
31 #pragma omp parallel shared(m)
34 #pragma omp for ordered(2)
35 for (row
= 1; row
< N
; ++row
) {
36 for (col
= 1; col
< N
; ++col
) {
37 #pragma omp ordered depend(sink : row - 1, col) depend(sink : row, col - 1)
38 m
[row
* N
+ col
] = m
[(row
- 1) * N
+ col
] + m
[row
* N
+ (col
- 1)] -
39 m
[(row
- 1) * N
+ (col
- 1)];
40 #pragma omp ordered depend(source)
45 // Check the bottom right element to see if iteration dependencies were held
46 int retval
= (m
[(N
- 1) * N
+ N
- 1] == 2 * (N
- 1));
51 int main(int argc
, char **argv
) {
54 if (omp_get_max_threads() < 2)
55 omp_set_num_threads(4);
56 for (i
= 0; i
< REPETITIONS
; i
++) {
57 if (!test_doacross()) {