2 /* { dg-options "-O2 -fopenmp" } */
6 __attribute__((noinline
, noclone
)) int
7 test (int a
, int b
, int c
, int d
, void (*fn
) (int, int, int, int),
8 int *num_tasks
, int *min_iters
, int *max_iters
)
11 __builtin_memset (u
, 0, sizeof u
);
22 for (i
= 1; i
< v
; i
++)
24 if (*min_iters
> u
[i
])
26 if (*max_iters
< u
[i
])
35 grainsize (int a
, int b
, int c
, int d
)
38 #pragma omp taskloop firstprivate (j, k) grainsize(d)
39 for (i
= a
; i
< b
; i
+= c
)
43 #pragma omp atomic capture
53 num_tasks (int a
, int b
, int c
, int d
)
56 #pragma omp taskloop firstprivate (j, k) num_tasks(d)
57 for (i
= a
; i
< b
; i
+= c
)
61 #pragma omp atomic capture
76 int min_iters
, max_iters
, ntasks
;
77 /* If grainsize is present, # of task loop iters is >= grainsize && < 2 * grainsize,
78 unless # of loop iterations is smaller than grainsize. */
79 if (test (0, 79, 1, 17, grainsize
, &ntasks
, &min_iters
, &max_iters
) != 79
80 || min_iters
< 17 || max_iters
>= 17 * 2)
82 if (test (-49, 2541, 7, 28, grainsize
, &ntasks
, &min_iters
, &max_iters
) != 370
83 || min_iters
< 28 || max_iters
>= 28 * 2)
85 if (test (7, 21, 2, 15, grainsize
, &ntasks
, &min_iters
, &max_iters
) != 7
86 || ntasks
!= 1 || min_iters
!= 7 || max_iters
!= 7)
88 /* If num_tasks is present, # of task loop iters is min (# of loop iters, num_tasks). */
89 if (test (-51, 2500, 48, 9, num_tasks
, &ntasks
, &min_iters
, &max_iters
) != 54
92 if (test (0, 25, 2, 17, num_tasks
, &ntasks
, &min_iters
, &max_iters
) != 13