brintos

brintos / llvm-project-archived public Read only

0
0
Text · 750 B · 47ea115 Raw
35 lines · c
1// RUN: %libomp-compile-and-run2 3// The test checks nonmonotonic scheduling works correctly when threads4// may execute different loops concurrently.5 6#include <stdio.h>7#include <omp.h>8 9#define N 20010#define C 2011int main()12{13  int i, l0 = 0, l1 = 0;14  #pragma omp parallel num_threads(8)15  {16    #pragma omp for schedule(nonmonotonic:dynamic,C) nowait17    for (i = 0; i < N; ++i) {18      #pragma omp atomic19        l0++;20    }21    #pragma omp for schedule(nonmonotonic:dynamic,C) nowait22    for (i = 0; i < N * N; ++i) {23      #pragma omp atomic24        l1++;25    }26  }27  if (l0 != N || l1 != N * N) {28    printf("failed l0 = %d, l1 = %d, should be %d %d\n", l0, l1, N, N * N);29    return 1;30  } else {31    printf("passed\n");32    return 0;33  }34}35