aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c-c++-common/nonmonotonic-1.c
blob: fc5e93fe53a0a20024ea02b992c42492034e5c58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* { dg-do run } */

#ifndef NONMONOTONIC_TYPE
#include <omp.h>
#include <stdlib.h>
#define NONMONOTONIC_TYPE int
#define NONMONOTONIC_END(n) n
#endif

int a[73];

int
main ()
{
  NONMONOTONIC_TYPE i;
  #pragma omp parallel for schedule(nonmonotonic: dynamic)
  for (i = 0; i < NONMONOTONIC_END (73); i++)
    a[i]++;
  #pragma omp parallel for schedule(nonmonotonic: dynamic, 5)
  for (i = 0; i < NONMONOTONIC_END (73); i++)
    a[i]++;
  #pragma omp parallel for schedule(nonmonotonic: guided)
  for (i = 0; i < NONMONOTONIC_END (73); i++)
    a[i]++;
  #pragma omp parallel for schedule(nonmonotonic: guided, 7)
  for (i = 0; i < NONMONOTONIC_END (73); i++)
    a[i]++;
  #pragma omp parallel
  {
    int cnt = omp_get_num_threads ();
    int thr = omp_get_thread_num ();
    if (thr < 73)
      a[thr]++;
    #pragma omp barrier
    #pragma omp for schedule(nonmonotonic: dynamic)
    for (i = 0; i < NONMONOTONIC_END (73); i++)
      a[i]++;
    #pragma omp for schedule(nonmonotonic: dynamic, 7)
    for (i = 0; i < NONMONOTONIC_END (73); i++)
      a[i]++;
    #pragma omp for schedule(nonmonotonic: guided)
    for (i = 0; i < NONMONOTONIC_END (73); i++)
      a[i]++;
    #pragma omp for schedule(nonmonotonic: guided, 5)
    for (i = 0; i < NONMONOTONIC_END (73); i++)
      a[i]++;
    #pragma omp single private (i)
    for (i = 0; i < 73; i++)
      if (a[i] != 8 + (i < cnt))
	abort ();
  }
  return 0;
}