summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/gomp/pr32468-1.c
blob: 43724135720e97c153e9995c4bd95f931c73aa5f (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* PR libgomp/32468 */
/* { dg-do compile } */
/* { dg-options "-O2 -fopenmp -fdump-tree-ompexp" } */

extern int printf (const char *, ...);
extern int omp_get_thread_num (void), omp_get_num_threads (void);
extern int bar (void);
extern int baz (const char *, ...);

void
f1 (void)
{
#pragma omp parallel
  {
    baz ("%d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
    #pragma omp sections
      {
	#pragma omp section
	printf ("section1 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
	#pragma omp section
	printf ("section2 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
      }
  }
}

void
f2 (void)
{
#pragma omp parallel
  {
    #pragma omp sections
      {
	#pragma omp section
	printf ("section1 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
	#pragma omp section
	printf ("section2 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
      }
    baz ("%d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
  }
}

void
f3 (void)
{
#pragma omp parallel
  {
    int bb = bar ();
    #pragma omp sections
      {
	#pragma omp section
	printf ("section1 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
	#pragma omp section
	printf ("section2 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
      }
  }
}

void
f4 (void)
{
  int i;
#pragma omp parallel
  {
    baz ("%d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
    #pragma omp for schedule (dynamic, 15)
    for (i = 0; i < 10000; i++)
      printf ("section1 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
  }
}

void
f5 (void)
{
  int i;
#pragma omp parallel
  {
    #pragma omp for schedule (dynamic, 15)
    for (i = 0; i < 10000; i++)
      printf ("section1 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
    baz ("%d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
  }
}

void
f6 (void)
{
  int i;
#pragma omp parallel
  {
    int bb = bar ();
    #pragma omp for schedule (runtime)
    for (i = 0; i < 10000; i++)
      printf ("section1 %d/%d\n", omp_get_thread_num (), omp_get_num_threads ());
  }
}

/* There should not be a GOMP_parallel_{loop,sections}* call.  */
/* { dg-final { scan-tree-dump-times "GOMP_parallel_loop" 0 "ompexp"} } */
/* { dg-final { scan-tree-dump-times "GOMP_parallel_sections" 0 "ompexp"} } */
/* { dg-final { cleanup-tree-dump "ompexp" } } */