2 /* { dg-options "-O2" } */
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
, int *sep
)
11 __builtin_memset (u
, 0, sizeof u
);
23 for (i
= 1; i
< v
; i
++)
25 if (*min_iters
> u
[i
])
27 if (*max_iters
< u
[i
])
31 if (*min_iters
!= *max_iters
)
33 for (i
= 0; i
< v
- 1; i
++)
36 for (j
= i
+ 1; j
< v
; j
++)
37 if (w
[min_idx
] > w
[j
])
49 if (u
[0] != *max_iters
)
51 for (i
= 1; i
< v
; i
++)
54 if (*sep
!= v
|| u
[i
] != *min_iters
)
64 grainsize (int a
, int b
, int c
, int d
)
67 #pragma omp taskloop firstprivate (j, k) grainsize(strict:d)
68 for (i
= a
; i
< b
; i
+= c
)
72 #pragma omp atomic capture
83 num_tasks (int a
, int b
, int c
, int d
)
86 #pragma omp taskloop firstprivate (j, k) num_tasks(strict:d)
87 for (i
= a
; i
< b
; i
+= c
)
91 #pragma omp atomic capture
107 int min_iters
, max_iters
, ntasks
, sep
;
108 /* If grainsize is present and has strict modifier, # of task loop iters is == grainsize,
109 except that it can be smaller on the last task. */
110 if (test (0, 79, 1, 17, grainsize
, &ntasks
, &min_iters
, &max_iters
, &sep
) != 79
111 || ntasks
!= 5 || min_iters
!= 11 || max_iters
!= 17 || sep
!= 4)
113 if (test (-49, 2541, 7, 28, grainsize
, &ntasks
, &min_iters
, &max_iters
, &sep
) != 370
114 || ntasks
!= 14 || min_iters
!= 6 || max_iters
!= 28 || sep
!= 13)
116 if (test (7, 21, 2, 15, grainsize
, &ntasks
, &min_iters
, &max_iters
, &sep
) != 7
117 || ntasks
!= 1 || min_iters
!= 7 || max_iters
!= 7 || sep
!= 1)
119 /* If num_tasks is present, # of tasks is min (# of loop iters, num_tasks)
120 and each task has at least one iteration. If strict modifier is present,
121 first set of tasks has ceil (# of loop iters / num_tasks) iterations,
122 followed by possibly empty set of tasks with floor (# of loop iters / num_tasks)
124 if (test (-51, 2500, 48, 9, num_tasks
, &ntasks
, &min_iters
, &max_iters
, &sep
) != 54
125 || ntasks
!= 9 || min_iters
!= 6 || max_iters
!= 6 || sep
!= 9)
127 if (test (0, 57, 1, 9, num_tasks
, &ntasks
, &min_iters
, &max_iters
, &sep
) != 57
128 || ntasks
!= 9 || min_iters
!= 6 || max_iters
!= 7 || sep
!= 3)
130 if (test (0, 25, 2, 17, num_tasks
, &ntasks
, &min_iters
, &max_iters
, &sep
) != 13
131 || ntasks
!= 13 || min_iters
!= 1 || max_iters
!= 1 || sep
!= 13)