[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / worksharing / for / omp_doacross.c
blob364430675d647762f0ba63c2de3aff968243001e
1 // RUN: %libomp-compile-and-run
2 // XFAIL: gcc-4, gcc-5, clang-3.7, clang-3.8, icc-15, icc-16
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include "omp_testsuite.h"
7 #ifndef N
8 #define N 750
9 #endif
11 int test_doacross() {
12 int i, j;
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) {
17 m[i * N + j] = 0;
20 // Have first row and column be 0, 1, 2, 3, etc.
21 for (i = 0; i < N; ++i)
22 m[i * N] = i;
23 for (j = 0; j < N; ++j)
24 m[j] = j;
25 // Perform wavefront which results in matrix:
26 // 0 1 2 3 4
27 // 1 2 3 4 5
28 // 2 3 4 5 6
29 // 3 4 5 6 7
30 // 4 5 6 7 8
31 #pragma omp parallel shared(m)
33 int row, col;
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));
47 free(m);
48 return retval;
51 int main(int argc, char **argv) {
52 int i;
53 int num_failed = 0;
54 if (omp_get_max_threads() < 2)
55 omp_set_num_threads(4);
56 for (i = 0; i < REPETITIONS; i++) {
57 if (!test_doacross()) {
58 num_failed++;
61 return num_failed;