4 integer, save :: u(64), v
5 integer :: min_iters
, max_iters
, ntasks
, cnt
6 procedure(grainsize
), pointer :: fn
10 ! If grainsize is present, # of task loop iters is
11 ! >= grainsize && < 2 * grainsize,
12 ! unless # of loop iterations is smaller than grainsize.
13 call test (0, 79, 1, 17, fn
, ntasks
, min_iters
, max_iters
, cnt
)
14 if (cnt
.ne
. 79) STOP 1
15 if (min_iters
.lt
. 17 .or
. max_iters
.ge
. 17 * 2) STOP 2
16 call test (-49, 2541, 7, 28, fn
, ntasks
, min_iters
, max_iters
, cnt
)
17 if (cnt
.ne
. 370) STOP 3
18 if (min_iters
.lt
. 28 .or
. max_iters
.ge
. 28 * 2) STOP 4
19 call test (7, 21, 2, 15, fn
, ntasks
, min_iters
, max_iters
, cnt
)
20 if (cnt
.ne
. 7) STOP 5
21 if (min_iters
.ne
. 7 .or
. max_iters
.ne
. 7) STOP 6
22 if (ntasks
.ne
. 1) STOP 7
24 ! If num_tasks is present, # of task loop iters is
25 ! min (# of loop iters, num_tasks).
26 call test (-51, 2500, 48, 9, fn
, ntasks
, min_iters
, max_iters
, cnt
)
27 if (cnt
.ne
. 54 .or
. ntasks
.ne
. 9) STOP 8
28 call test (0, 25, 2, 17, fn
, ntasks
, min_iters
, max_iters
, cnt
)
29 if (cnt
.ne
. 13 .or
. ntasks
.ne
. 13) STOP 9
33 subroutine grainsize (a
, b
, c
, d
)
34 integer, intent (in
) :: a
, b
, c
, d
38 !$omp taskloop firstprivate (j, k) grainsize (d)
45 if (k
.ge
. 64) STOP 10
50 end subroutine grainsize
51 subroutine num_tasks (a
, b
, c
, d
)
52 integer, intent (in
) :: a
, b
, c
, d
56 !$omp taskloop firstprivate (j, k) num_tasks (d)
63 if (k
.ge
. 64) STOP 11
68 end subroutine num_tasks
69 subroutine test (a
, b
, c
, d
, fn
, num_tasks
, min_iters
, max_iters
, cnt
)
70 integer, intent (in
) :: a
, b
, c
, d
71 procedure(grainsize
), pointer :: fn
72 integer, intent (out
) :: num_tasks
, min_iters
, max_iters
, cnt
82 min_iters
= minval (u(1:v
))
83 max_iters
= maxval (u(1:v
))