QR_MUMPS
Data Types | Functions/Subroutines | Variables
qrm_task_mod Module Reference

This module contains the definition of a task type that is used for scheduling tasks during the factorization and solve, and the associated methods. More...

Data Types

type  qrm_task_queue
 This type defines the task queue attached to a thread. More...
 
type  qrm_task_queue_handle
 This type defines the handle for the queues attached to a family of threads. More...
 
type  qrm_task_type
 This type defines a computational task. More...
 

Functions/Subroutines

subroutine qrm_init_task_queue (h)
 Inititalizes a set of queues attached to a family of threads referenced through the handle h. More...
 
subroutine qrm_task_proximity (h)
 Defines the order in which queues have to be visited by each thread. More...
 
logical function qrm_sched_task (h, tsk, pol, q)
 Pushes a task on a queue. More...
 
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 .true. if something was found, .false. otherwise. More...
 
integer function qrm_task_queue_card (h)
 Returns the number of tasks present on a set of queues referenced by a handle. More...
 
logical function qrm_task_queue_empty (h, who)
 Tells whether one, or all, queues are empty. More...
 
subroutine qrm_clean_task_queue (h)
 Destroyes a set of queues. More...
 

Variables

integer, parameter qrm_task_exit_ = 0
 
integer, parameter qrm_task_pnl_ = 1
 
integer, parameter qrm_task_upd_ = 2
 
integer, parameter qrm_task_act_ = 3
 
integer, parameter qrm_task_asm_ = 4
 
integer, parameter qrm_task_free_ = 5
 
integer, parameter qrm_task_cln_ = 6
 
integer, parameter qrm_task_app_ = 7
 
integer, parameter qrm_task_sol_ = 8
 
integer, parameter max_tasks = 300
 The max size of a task queue attached to a thread. More...
 
integer, private qrm_task_thn
 
integer, private qrm_task_nth
 

Detailed Description

This module contains the definition of a task type that is used for scheduling tasks during the factorization and solve, and the associated methods.

The parallelism in qr_mumps is based on a dynamic execution of computational tasks. These computational tasks and their dependencies are defined by a set of rules that are handled in the factorization or solve routines. Once all the dependencies of a task are satisfied, the task is ready for being executed. The execution of all the ready tasks is managed by the methods in this module. Specifically, a task-queue handle is shared among all the threads in a family; each task queue groups a set of queues, one for each thread in the family. Each thread can access its queue through the handle of the family it belongs to and its rank.

Usage example:

type(qrm_task_queue_handle) :: h
type(qrm_task_type) :: task
integer :: iam
logical :: got
! The handle is always shared!!!
!$omp parallel shared(h)
! initialize the family queues
call qrm_init_task_queue(h)
iam = omp_get_thread_num()
! init the task using its constructor
task = qrm_task_type(qrm_act_, iam, 0, 0, .true.)
! push the task on my own queue
call qrm_sched_task(h, task, 't', iam)
! push the task on the queue
got = qrm_get_task(h, task)
if(got) then
! execute the task
end if
!$omp end parallel

In the small example above, each thread pushes on its own queue a task corresponding to the activation of the front whose ID is the same as the thread's rank. Note that the task is bound, i.e., it can only be executed by the thread associated to the queue where the task was pushed. Then each thread pops a task and executes it.

Function/Subroutine Documentation

subroutine qrm_task_mod::qrm_clean_task_queue ( type(qrm_task_queue_handle h)

Destroyes a set of queues.

Parameters
[in,out]hthe handle referencing the set of queues to be destroyed

Definition at line 440 of file qrm_task_mod.F90.

References max_tasks, and qrm_task_nth.

Referenced by _qrm_apply_q(), _qrm_apply_qt(), _qrm_factorization_core(), _qrm_solve_r(), _qrm_solve_rt(), dqrm_apply_q(), dqrm_apply_qt(), dqrm_factorization_core(), dqrm_solve_r(), and dqrm_solve_rt().

logical function qrm_task_mod::qrm_get_task ( type(qrm_task_queue_handle h,
type(qrm_task_type tsk 
)

Pops a task from a queue. Tasks are always popped from the head of the queue. The return value is .true. if something was found, .false. otherwise.

Parameters
[in,out]hThe handle to the set of queues
[out]tskthe returned task (if any)

Definition at line 343 of file qrm_task_mod.F90.

References max_tasks, qrm_task_nth, and qrm_task_thn.

Referenced by _qrm_apply_q(), _qrm_apply_qt(), _qrm_factorization_core(), _qrm_solve_r(), _qrm_solve_rt(), dqrm_apply_q(), dqrm_apply_qt(), dqrm_factorization_core(), dqrm_solve_r(), and dqrm_solve_rt().

subroutine qrm_task_mod::qrm_init_task_queue ( type(qrm_task_queue_handle h)

Inititalizes a set of queues attached to a family of threads referenced through the handle h.

Parameters
[in]hThe handle that references the queues

Definition at line 156 of file qrm_task_mod.F90.

References qrm_task_nth, qrm_task_proximity(), and qrm_task_thn.

Referenced by _qrm_apply_q(), _qrm_apply_qt(), _qrm_factorization_core(), _qrm_solve_r(), _qrm_solve_rt(), dqrm_apply_q(), dqrm_apply_qt(), dqrm_factorization_core(), dqrm_solve_r(), and dqrm_solve_rt().

logical function qrm_task_mod::qrm_sched_task ( type(qrm_task_queue_handle h,
type(qrm_task_type tsk,
character  pol,
integer, optional  q 
)

Pushes a task on a queue.

Parameters
[in,out]hthe handle to the set of queues
[in]tskthe task to be pushed
[in]polthe policy. It can be either 'h', in which case the task will be pushed on the head of the queue, or 't', in which case it will be pushed on the tail of the queue
[in]qthe queue in the set where to push the task. This can be used to improve data locality, e.g., a task can be pushed on the queue attached to the thread which owns the data to be accessed by the task itself

Definition at line 289 of file qrm_task_mod.F90.

References max_tasks, and qrm_task_thn.

Referenced by check_applyq_over(), check_applyqt_over(), check_facto_over(), check_solver_over(), check_solvert_over(), fill_queue_q(), fill_queue_qt(), fill_queue_r(), fill_queue_rt(), front_sched_act(), front_sched_ops(), panel(), and update().

subroutine qrm_task_mod::qrm_task_proximity ( type(qrm_task_queue_handle h)

Defines the order in which queues have to be visited by each thread.

Definition at line 205 of file qrm_task_mod.F90.

References qrm_task_nth.

Referenced by qrm_init_task_queue().

integer function qrm_task_mod::qrm_task_queue_card ( type(qrm_task_queue_handle h)

Returns the number of tasks present on a set of queues referenced by a handle.

Parameters
[in]hthe handle

Definition at line 393 of file qrm_task_mod.F90.

Referenced by _qrm_apply_q(), _qrm_apply_qt(), _qrm_factorization_core(), _qrm_solve_r(), _qrm_solve_rt(), dqrm_apply_q(), dqrm_apply_qt(), dqrm_factorization_core(), dqrm_solve_r(), and dqrm_solve_rt().

logical function qrm_task_mod::qrm_task_queue_empty ( type(qrm_task_queue_handle h,
integer, optional  who 
)

Tells whether one, or all, queues are empty.

Parameters
[in]hthe handle
[in]who(optional) if present, the function will only look at the queue attached to thread "who" otherwise it will look at all queues referenced by h

Definition at line 411 of file qrm_task_mod.F90.

References qrm_task_nth.

Variable Documentation

integer, parameter qrm_task_mod::max_tasks = 300

The max size of a task queue attached to a thread.

Definition at line 125 of file qrm_task_mod.F90.

Referenced by qrm_clean_task_queue(), qrm_get_task(), and qrm_sched_task().

integer, parameter qrm_task_mod::qrm_task_act_ = 3
integer, parameter qrm_task_mod::qrm_task_app_ = 7
integer, parameter qrm_task_mod::qrm_task_asm_ = 4
integer, parameter qrm_task_mod::qrm_task_cln_ = 6
integer, parameter qrm_task_mod::qrm_task_exit_ = 0
integer, parameter qrm_task_mod::qrm_task_free_ = 5

Definition at line 104 of file qrm_task_mod.F90.

integer, private qrm_task_mod::qrm_task_nth
private
integer, parameter qrm_task_mod::qrm_task_pnl_ = 1
integer, parameter qrm_task_mod::qrm_task_sol_ = 8
integer, private qrm_task_mod::qrm_task_thn
private

Definition at line 127 of file qrm_task_mod.F90.

Referenced by qrm_get_task(), qrm_init_task_queue(), and qrm_sched_task().

integer, parameter qrm_task_mod::qrm_task_upd_ = 2