34 #include "qrm_common.h" 135 integer(kind=omp_lock_kind) :: lock
143 integer,
allocatable :: proxy_list(:,:)
144 integer :: stolen=0, ntsk=0, ncores, nnodes, cnode
161 #if defined (_OPENMP) 209 integer :: i, j, ii, jj, cnt, id, c, n
210 integer,
allocatable :: topo(:,:), core_to_node(:)
215 allocate(topo(0:h%cnode-1,0:h%nnodes-1))
222 allocate(topo(0:h%cnode-1,0:h%nnodes-1))
233 allocate(core_to_node(0:h%nnodes*h%cnode-1))
236 core_to_node(topo(i,j)) = j
246 h%proxy_list(id,cnt) = c*h%ncores+id
253 n = core_to_node(mod(id,h%ncores))
254 n = mod(n+j,h%nnodes)
259 if(c*h%ncores +topo(i,n) .eq. id)
exit 260 h%proxy_list(id,cnt) = c*h%ncores+topo(i,n)
269 deallocate(topo, core_to_node)
293 integer,
optional :: q
294 logical :: qrm_sched_task
306 qrm_sched_task = .true.
310 if(h%queues(iq)%n .eq. 0)
then 315 if(pol .eq.
't')
then 316 i = mod(h%queues(iq)%h+h%queues(iq)%n-1,
max_tasks)+1
317 else if(pol .eq.
'h')
then 318 h%queues(iq)%h = h%queues(iq)%h-1
319 if (h%queues(iq)%h .le. 0) h%queues(iq)%h=
max_tasks 322 h%queues(iq)%n = h%queues(iq)%n+1
324 h%queues(iq)%q(i) = tsk
326 qrm_sched_task = .false.
346 logical :: qrm_get_task
351 qrm_get_task = .false.
357 if(omp_test_lock(h%queues(queue)%lock))
then 359 if(h%queues(queue)%n .gt. 0)
then 360 tsk = h%queues(queue)%q(h%queues(queue)%h)
361 if(tsk%bind .and. i .ne. 0)
goto 10
362 qrm_get_task = .true.
363 h%queues(queue)%q(h%queues(queue)%h) =
qrm_task_type(0, 0, 0, 0, .false.)
364 h%queues(queue)%h = mod(h%queues(queue)%h,
max_tasks)+1
365 h%queues(queue)%n = h%queues(queue)%n-1
366 if (h%queues(queue)%n .eq. 0) h%queues(queue)%h = 0
368 h%stolen = h%stolen+1
374 qrm_get_task = .false.
378 call omp_unset_lock(h%queues(queue)%lock)
394 integer :: qrm_task_queue_card
397 qrm_task_queue_card = sum(h%queues(:)%n)
412 integer,
optional :: who
413 logical :: qrm_task_queue_empty
417 if(
present(who))
then 419 qrm_task_queue_empty = h%queues(who)%n .eq. 0
422 qrm_task_queue_empty = .true.
426 qrm_task_queue_empty = qrm_task_queue_empty .and. (maxval(h%queues(0:
qrm_task_nth-1)%n) .eq. 0)
450 __qrm_prnt_dbg(
'("Queues cleaned -- ntsk:",i6," stolen:",i6)')h%ntsk,h%stolen
453 deallocate(h%queues, h%proxy_list)
484 allocate(h%queues(0:0))
516 integer,
optional :: q
517 logical :: qrm_sched_task
523 qrm_sched_task = .true.
525 if(h%queues(0)%n .eq. 0)
then 530 if(pol .eq.
't')
then 531 i = mod(h%queues(0)%h+h%queues(0)%n-1,
max_tasks)+1
532 else if(pol .eq.
'h')
then 533 h%queues(0)%h = h%queues(0)%h-1
534 if (h%queues(0)%h .le. 0) h%queues(0)%h=
max_tasks 537 h%queues(0)%n = h%queues(0)%n+1
539 h%queues(0)%q(i) = tsk
541 qrm_sched_task = .false.
561 logical :: qrm_get_task
564 qrm_get_task = .false.
568 call omp_set_lock(h%queues(0)%lock)
570 if(h%queues(0)%n .gt. 0)
then 571 tsk = h%queues(0)%q(h%queues(0)%h)
572 qrm_get_task = .true.
573 h%queues(0)%q(h%queues(0)%h) =
qrm_task_type(0, 0, 0, 0, .false.)
574 h%queues(0)%h = mod(h%queues(0)%h,
max_tasks)+1
575 h%queues(0)%n = h%queues(0)%n-1
576 if (h%queues(0)%n .eq. 0) h%queues(0)%h = 0
580 qrm_get_task = .false.
584 call omp_unset_lock(h%queues(0)%lock)
598 integer :: qrm_task_queue_card
600 qrm_task_queue_card = h%queues(0)%n
615 integer,
optional :: who
616 logical :: qrm_task_queue_empty
618 qrm_task_queue_empty = h%queues(0)%n .eq. 0
634 __qrm_prnt_dbg(
'("Queues cleaned -- ntsk:",i6," stolen:",i6)')h%ntsk,h%stolen
subroutine qrm_clean_task_queue(h)
Destroyes a set of queues.
Generic interface for the ::qrm_hwloc_topo routine.
This type defines the handle for the queues attached to a family of threads.
integer, private qrm_task_thn
This module contains the interfaces of all non-typed routines.
integer, parameter qrm_task_asm_
integer, parameter qrm_task_pnl_
integer, parameter qrm_task_free_
This module contains the definition of a task type that is used for scheduling tasks during the facto...
logical function qrm_sched_task(h, tsk, pol, q)
Pushes a task on a queue.
This module contains all the error management routines and data.
logical function qrm_task_queue_empty(h, who)
Tells whether one, or all, queues are empty.
integer, parameter qrm_task_exit_
subroutine qrm_init_task_queue(h)
Inititalizes a set of queues attached to a family of threads referenced through the handle h...
logical function qrm_get_task(h, tsk)
Pops a task from a queue. Tasks are always popped from the head of the queue. The return value is ...
This type defines a computational task.
integer, parameter qrm_task_act_
Generic interface for the ::qrm_hwloc_info routine.
integer function qrm_task_queue_card(h)
Returns the number of tasks present on a set of queues referenced by a handle.
integer, parameter qrm_task_upd_
subroutine qrm_task_proximity(h)
Defines the order in which queues have to be visited by each thread.
integer, parameter max_tasks
The max size of a task queue attached to a thread.
integer, parameter qrm_task_app_
integer, parameter qrm_task_sol_
integer, parameter qrm_task_cln_
integer, private qrm_task_nth
This type defines the task queue attached to a thread.