PLASMA
2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
|
Functions | |
int | QUARK_Thread_Rank (Quark *quark) |
void * | QUARK_Args_List (Quark *quark) |
int | QUARK_Get_RankInTask (Quark *quark) |
void * | QUARK_Args_Pop (void *args_list, void **last_arg) |
Quark * | QUARK_Setup (int num_threads) |
Quark * | QUARK_New (int num_threads) |
void | QUARK_Barrier (Quark *quark) |
void | QUARK_Waitall (Quark *quark) |
void | QUARK_Free (Quark *quark) |
void | QUARK_Delete (Quark *quark) |
Task * | QUARK_Task_Init (Quark *quark, void(*function)(Quark *), Quark_Task_Flags *task_flags) |
void | QUARK_Task_Pack_Arg (Quark *quark, Task *task, int arg_size, void *arg_ptr, int arg_flags) |
unsigned long long | QUARK_Insert_Task_Packed (Quark *quark, Task *task) |
unsigned long long | QUARK_Insert_Task (Quark *quark, void(*function)(Quark *), Quark_Task_Flags *task_flags,...) |
int | QUARK_Cancel_Task (Quark *quark, unsigned long long taskid) |
void | QUARK_Worker_Loop (Quark *quark, int thread_rank) |
Quark_Sequence * | QUARK_Sequence_Create (Quark *quark) |
int | QUARK_Sequence_Cancel (Quark *quark, Quark_Sequence *sequence) |
Quark_Sequence * | QUARK_Sequence_Destroy (Quark *quark, Quark_Sequence *sequence) |
int | QUARK_Sequence_Wait (Quark *quark, Quark_Sequence *sequence) |
Quark_Sequence * | QUARK_Get_Sequence (Quark *quark) |
Quark_Task_Flags * | QUARK_Task_Flag_Set (Quark_Task_Flags *task_flags, int flag, intptr_t val) |
intptr_t | QUARK_Task_Flag_Get (Quark *quark, int flag) |
void | QUARK_DOT_DAG_Enable (Quark *quark, int enable) |
These functions are available from the QUARK library for the scheduling of kernel routines.
void* QUARK_Args_List | ( | Quark * | quark | ) |
Return a pointer to the argument list being processed by the current task and worker.
[in] | quark | The scheduler's main data structure. |
Definition at line 525 of file quark.c.
References quark_task_s::args_list, worker_s::current_task_ptr, QUARK_Thread_Rank(), and quark_s::worker.
void* QUARK_Args_Pop | ( | void * | args_list, |
void ** | last_arg | ||
) |
Return a pointer to the next argument. The variable last_arg should be NULL on the first call, then each subsequent call will use last_arg to get the the next argument. The argument list is not actually popped, it is preserved intact.
[in] | args_list | Pointer to the current arguments |
[in,out] | last_arg | Pointer to the last argument; should be NULL on the first call |
Definition at line 573 of file quark.c.
References icl_list_s::data, icl_list_first(), and icl_list_next().
void QUARK_Barrier | ( | Quark * | quark | ) |
Called by the master thread. Wait for all the tasks to be completed, then return. The worker tasks will NOT exit from their work loop.
[in,out] | quark | The scheduler's main data structure. |
Definition at line 908 of file quark.c.
References quark_s::address_set, quark_s::all_tasks_queued, quark_s::dot_dag_enable, FALSE, icl_hash_create(), icl_hash_destroy(), icl_hash_foreach, address_set_node_s::last_reader_or_writer_tasklevel, address_set_node_s::last_writer_tasklevel, quark_s::queue_before_computing, quark_s::tasklevel_width, tasklevel_width_max_level, TRUE, and quark_s::worker.
int QUARK_Cancel_Task | ( | Quark * | quark, |
unsigned long long | taskid | ||
) |
Called by any thread. Cancel a task that is in the scheduler. This works by simply making the task a NULL task. The scheduler still processes all the standard dependencies for this task, but when it is time to run the actual function, the scheduler does nothing.
[in,out] | quark | The scheduler's main data structure. |
[in] | taskid | The taskid returned by a QUARK_Insert_Task |
Definition at line 1373 of file quark.c.
References CANCELLED, DONE, quark_task_s::function, icl_hash_find(), RUNNING, quark_task_s::status, quark_task_s::task_mutex, quark_s::task_set, and quark_s::task_set_mutex.
void QUARK_Delete | ( | Quark * | quark | ) |
Called by the master thread. Wait for all tasks to complete, then join/end the worker threads, and clean up all the data structures.
[in,out] | quark | The scheduler's main data structure. |
Definition at line 1009 of file quark.c.
References quark_s::coresbind, quark_s::num_threads, pthread_attr_destroy(), pthread_join(), QUARK_Free(), quark_topology_finalize(), QUARK_Waitall(), quark_s::thread_attr, worker_s::thread_id, and quark_s::worker.
void QUARK_DOT_DAG_Enable | ( | Quark * | quark, |
int | enable | ||
) |
Enable and disable DAG generation in QUARK. Only to be called at the task insertion level by the master thread. Can be called multiple times to enable and disable DAG generation during the runtime. For the output to make sense, this MUST be preceeded by a sync operation such as QUARK_Barrier.
[in,out] | quark | Pointer to the scheduler data structure |
[in] | enable | Integer: 1 = enable DAG generation; otherwise disable |
Definition at line 2589 of file quark.c.
References quark_s::address_set, quark_s::dot_dag_enable, DOT_DAG_FILENAME, quark_s::dot_dag_mutex, quark_s::dot_dag_was_setup, fopen, quark_s::high_water_mark, icl_hash_foreach, address_set_node_s::last_reader_or_writer_taskid, address_set_node_s::last_reader_or_writer_tasklevel, address_set_node_s::last_writer_taskid, address_set_node_s::last_writer_tasklevel, quark_s::low_water_mark, pthread_mutex_destroy(), pthread_mutex_init(), quark_s::tasklevel_width, and tasklevel_width_max_level.
void QUARK_Free | ( | Quark * | quark | ) |
Called by the master thread. Free all QUARK data structures, this assumes that all usage of QUARK is completed. This interface does not manage, delete or close down the worker threads.
[in,out] | quark | The scheduler's main data structure. |
Definition at line 981 of file quark.c.
References quark_s::address_set, quark_s::address_set_mutex, quark_s::completed_tasks, icl_hash_destroy(), quark_s::num_threads, pthread_mutex_destroy(), QUARK_DOT_DAG_Enable(), quark_s::quark_mutex, QUARK_Waitall(), quark_s::task_set, and quark_s::worker.
int QUARK_Get_RankInTask | ( | Quark * | quark | ) |
Return the rank of a thread inside a parallel task.
[in] | quark | The scheduler's main data structure. |
Definition at line 544 of file quark.c.
References worker_s::current_task_ptr, QUARK_Thread_Rank(), quark_task_s::task_mutex, quark_task_s::threadid, and quark_s::worker.
Quark_Sequence* QUARK_Get_Sequence | ( | Quark * | quark | ) |
For the current thread, in the current task being executed, return the task's sequence value. This is the value provided when the task was Task_Inserted into a sequence.
[in,out] | quark | Pointer to the scheduler data structure |
Definition at line 2238 of file quark.c.
References worker_s::current_task_ptr, QUARK_Thread_Rank(), quark_task_s::sequence, and quark_s::worker.
unsigned long long QUARK_Insert_Task | ( | Quark * | quark, |
void(*)(Quark *) | function, | ||
Quark_Task_Flags * | task_flags, | ||
... | |||
) |
Called by the master thread. Add a new task to the scheduler, providing the data pointers, sizes, and dependency information. This function provides the main user interface for the user to write data-dependent algorithms.
[in,out] | quark | The scheduler's main data structure. |
[in] | function | The function (task) to be executed by the scheduler |
[in] | task_flags | Flags to specify task behavior |
[in] | ... | Triplets of the form, ending with 0 for arg_size. arg_size, arg_ptr, arg_flags where arg_size: int: Size of the argument in bytes (0 cannot be used here) arg_ptr: pointer: Pointer to data or argument arg_flags: int: Flags indicating argument usage and various decorators INPUT, OUTPUT, INOUT, VALUE, NODEP, SCRATCH LOCALITY, ACCUMULATOR, GATHERV TASK_COLOR, TASK_LABEL (special decorators for VALUE) e.g., arg_flags INPUT | LOCALITY | ACCUMULATOR e.g., arg_flags VALUE | TASK_COLOR |
Definition at line 1264 of file quark.c.
References QUARK_Insert_Task_Packed(), QUARK_Task_Init(), and QUARK_Task_Pack_Arg().
Called by the master thread. Add a new task to the scheduler, providing the data pointers, sizes, and dependency information. This function provides the main user interface for the user to write data-dependent algorithms.
[in,out] | quark | The scheduler's main data structure. |
[in,out] | task | The packed task structure that already has all the arguments associated with the function |
Definition at line 1181 of file quark.c.
References quark_s::all_tasks_queued, DBGPRINTF, FALSE, quark_task_s::function, quark_s::high_water_mark, icl_hash_insert(), LIST_INSERT_HEAD, NOTREADY, quark_s::num_tasks, quark_task_s::priority, quark_task_s::ptr_to_task_in_sequence, QUARK_ERR, QUARK_Thread_Rank(), quark_trace_addtask, worker_s::ready_list_size, quark_task_s::sequence, Quark_sequence_s::sequence_mutex, Quark_sequence_s::status, quark_task_s::status, quark_task_s::task_mutex, quark_s::task_set, quark_s::task_set_mutex, quark_task_s::task_thread_count, quark_task_s::task_thread_count_outstanding, quark_task_s::taskid, Quark_sequence_s::tasks_in_sequence, ll_list_node_s::val, and quark_s::worker.
Quark* QUARK_New | ( | int | num_threads | ) |
Called by the master thread. Allocate and initialize the scheduler data stuctures and spawn worker threads. Used when this scheduler is to do all the thread management.
[in] | num_threads | Number of threads to be used (1 master and rest compute workers). If num_threads < 1, first try environment variable QUARK_NUM_THREADS or use use num_threads = number of cores |
Definition at line 869 of file quark.c.
References quark_s::coresbind, pthread_attr_init(), pthread_attr_setscope(), pthread_create(), PTHREAD_SCOPE_SYSTEM, quark_get_affthreads(), quark_get_numthreads(), quark_setaffinity(), QUARK_Setup(), quark_topology_init(), quark_s::thread_attr, worker_s::thread_id, and quark_s::worker.
int QUARK_Sequence_Cancel | ( | Quark * | quark, |
Quark_Sequence * | sequence | ||
) |
Can be called by any thread. Cancels all the remaining tasks in a sequence using QUARK_Cancel_Task and changes the state so that future tasks belonging to that sequence are ignored.
[in,out] | quark | Pointer to the scheduler data structure |
[in,out] | sequence | Pointer to a sequence data structure |
Definition at line 2150 of file quark.c.
References LIST_FOREACH, QUARK_Cancel_Task(), QUARK_ERR, QUARK_SUCCESS, Quark_sequence_s::sequence_mutex, Quark_sequence_s::status, Quark_sequence_s::tasks_in_sequence, and ll_list_node_s::val.
Quark_Sequence* QUARK_Sequence_Create | ( | Quark * | quark | ) |
Called by the control program. Creates a new sequence data structure and returns it. This can be used to put a sequence of tasks into a group and cancel that group if an error condition occurs.
[in] | out | quark Pointer to the scheduler data structure |
Definition at line 2124 of file quark.c.
References DBGPRINTF, LIST_INIT, pthread_mutex_init(), QUARK_SUCCESS, QUARK_Thread_Rank(), worker_s::ready_list_size, Quark_sequence_s::sequence_mutex, Quark_sequence_s::status, Quark_sequence_s::tasks_in_sequence, and quark_s::worker.
Quark_Sequence* QUARK_Sequence_Destroy | ( | Quark * | quark, |
Quark_Sequence * | sequence | ||
) |
Called by the control program. Cancels all the remaining tasks in a sequence using QUARK_Cancel_Task and deletes the sequence data structure.
[in,out] | quark | Pointer to the scheduler data structure |
[in,out] | sequence | Pointer to a sequence data structure |
Definition at line 2187 of file quark.c.
References DBGPRINTF, LIST_EMPTY, pthread_mutex_destroy(), QUARK_Sequence_Cancel(), QUARK_Sequence_Wait(), QUARK_SUCCESS, QUARK_Thread_Rank(), worker_s::ready_list_size, Quark_sequence_s::sequence_mutex, Quark_sequence_s::tasks_in_sequence, and quark_s::worker.
int QUARK_Sequence_Wait | ( | Quark * | quark, |
Quark_Sequence * | sequence | ||
) |
Called by the control program. Returns when all the tasks in a sequence have completed.
[in,out] | quark | Pointer to the scheduler data structure |
[in,out] | sequence | Pointer to a sequence structure |
Definition at line 2216 of file quark.c.
References LIST_EMPTY, QUARK_ERR, QUARK_SUCCESS, QUARK_Thread_Rank(), Quark_sequence_s::tasks_in_sequence, and quark_s::worker.
Quark* QUARK_Setup | ( | int | num_threads | ) |
Called by the master thread. This routine does not do thread management, so it can be used with a larger libarary. Allocate and initialize the scheduler data stuctures for the master and num_threads worker threads.
[in] | num_threads | Number of threads to be used (1 master and rest compute workers). |
Definition at line 803 of file quark.c.
References quark_s::address_set, quark_s::address_set_mutex, quark_s::all_tasks_queued, quark_s::completed_tasks, quark_s::completed_tasks_mutex, quark_s::completed_tasks_size, quark_s::dot_dag_enable, quark_s::dot_dag_was_setup, FALSE, quark_s::high_water_mark, icl_hash_create(), quark_s::list_robin, quark_s::low_water_mark, quark_s::num_queued_tasks, quark_s::num_queued_tasks_cond, quark_s::num_queued_tasks_mutex, quark_s::num_tasks, quark_s::num_threads, pthread_cond_init(), pthread_mutex_init(), pthread_self(), QUARK_DOT_DAG_Enable(), quark_getenv_int(), quark_s::quark_mutex, quark_s::queue_before_computing, quark_s::start, TAILQ_INIT, quark_s::task_set, quark_s::task_set_mutex, worker_s::thread_id, TRUE, quark_s::war_dependencies_enable, and quark_s::worker.
intptr_t QUARK_Task_Flag_Get | ( | Quark * | quark, |
int | flag | ||
) |
Get the value of various task level flags. Each returned value can be either an integer or a pointer (intptr type).
Select from one of the flags: TASK_PRIORITY : an integer (0-MAX_INT) TASK_LOCK_TO_THREAD : an integer for the thread number TASK_LOCK_TO_THREAD_MASK : a pointer to a bitmask where task can run TASK_LABEL : a string pointer (NULL terminated) for the label TASK_COLOR : a string pointer (NULL terminated) for the color. TASK_SEQUENCE : pointer to a Quark_Sequence structure THREAD_SET_TO_MANUAL_SCHEDULING: boolean integer {0,1} setting thread to manual (1) or automatic (0) scheduling
[in] | flag | One of the flags shown above. |
Definition at line 2541 of file quark.c.
References worker_s::current_task_ptr, quark_task_s::lock_to_thread, quark_task_s::lock_to_thread_mask, quark_task_s::priority, QUARK_Thread_Rank(), quark_task_s::sequence, TASK_COLOR, quark_task_s::task_color, TASK_LABEL, quark_task_s::task_label, TASK_LOCK_TO_THREAD, TASK_LOCK_TO_THREAD_MASK, TASK_PRIORITY, TASK_SEQUENCE, TASK_THREAD_COUNT, quark_task_s::task_thread_count, THREAD_SET_TO_MANUAL_SCHEDULING, quark_task_s::thread_set_to_manual_scheduling, and quark_s::worker.
Quark_Task_Flags* QUARK_Task_Flag_Set | ( | Quark_Task_Flags * | task_flags, |
int | flag, | ||
intptr_t | val | ||
) |
Set various task level flags. This flag data structure is then provided when the task is created/inserted. Each flag can take a value which is either an integer or a pointer.
Select from one of the flags: TASK_PRIORITY : an integer (0-MAX_INT) TASK_LOCK_TO_THREAD : an integer for the thread number TASK_LOCK_TO_THREAD_MASK : a pointer to a bitmask where task can run TASK_LABEL : a string pointer (NULL terminated) for the label TASK_COLOR : a string pointer (NULL terminated) for the color. TASK_SEQUENCE : takes pointer to a Quark_Sequence structure THREAD_SET_TO_MANUAL_SCHEDULING: boolean integer {0,1} setting thread to manual (1) or automatic (0) scheduling
[in,out] | flags | Pointer to a Quark_Task_Flags structure |
[in] | flag | One of the flags listed above |
[in] | val | A integer or a pointer value for the flag ( uses the intptr_t ) |
Definition at line 2491 of file quark.c.
References TASK_COLOR, quark_task_flags_s::task_color, TASK_LABEL, quark_task_flags_s::task_label, TASK_LOCK_TO_THREAD, quark_task_flags_s::task_lock_to_thread, TASK_LOCK_TO_THREAD_MASK, quark_task_flags_s::task_lock_to_thread_mask, TASK_PRIORITY, quark_task_flags_s::task_priority, TASK_SEQUENCE, quark_task_flags_s::task_sequence, TASK_THREAD_COUNT, quark_task_flags_s::task_thread_count, THREAD_SET_TO_MANUAL_SCHEDULING, and quark_task_flags_s::thread_set_to_manual_scheduling.
Task* QUARK_Task_Init | ( | Quark * | quark, |
void(*)(Quark *) | function, | ||
Quark_Task_Flags * | task_flags | ||
) |
Called by the master thread. This is used in argument packing, to create an initial task data structure. Arguments can be packed into this structure, and it can be submitted later.
[in,out] | quark | The scheduler's main data structure. |
[in] | function | The function (task) to be executed by the scheduler |
[in] | task_flags | Flags to specify task behavior |
Definition at line 1060 of file quark.c.
References quark_task_s::function, and quark_set_task_flags_in_task_structure().
void QUARK_Task_Pack_Arg | ( | Quark * | quark, |
Task * | task, | ||
int | arg_size, | ||
void * | arg_ptr, | ||
int | arg_flags | ||
) |
Called by the master thread. This is used in argument packing, to pack/add arguments to a task data structure.
[in,out] | quark | The scheduler's main data structure. |
[in,out] | task | The task data struture to hold the arguments |
[in] | arg_size | Size of the argument in bytes (0 cannot be used here) |
[in] | arg_ptr | Pointer to data or argument |
[in] | arg_flags | Flags indicating argument usage and various decorators INPUT, OUTPUT, INOUT, VALUE, NODEP, SCRATCH LOCALITY, ACCUMULATOR, GATHERV TASK_COLOR, TASK_LABEL (special decorators for VALUE) e.g., arg_flags INPUT | LOCALITY | ACCUMULATOR e.g., arg_flags VALUE | TASK_COLOR |
Definition at line 1090 of file quark.c.
References ACCUMULATOR, dependency_s::address, quark_task_s::args_list, icl_list_s::data, quark_task_s::dependency_list, quark_s::dot_dag_enable, GATHERV, icl_list_append(), icl_list_insert(), icl_list_last(), icl_list_prev(), INOUT, INPUT, LOCALITY, quark_task_s::lock_to_thread, NODEP, quark_task_s::num_dependencies_remaining, OUTPUT, quark_task_s::priority, QUARK_DIRECTION_BITMASK, QUARK_REGION_ALL, QUARK_REGION_BITMASK, QUARK_VALUE_FLAGS_BITMASK, SCRATCH, quark_task_s::scratch_list, quark_task_s::sequence, TASK_COLOR, quark_task_s::task_color, dependency_s::task_dependency_list_node_ptr, TASK_LABEL, quark_task_s::task_label, TASK_LOCK_TO_THREAD, TASK_PRIORITY, TASK_SEQUENCE, TASK_THREAD_COUNT, quark_task_s::task_thread_count, THREAD_SET_TO_MANUAL_SCHEDULING, quark_task_s::thread_set_to_manual_scheduling, and VALUE.
int QUARK_Thread_Rank | ( | Quark * | quark | ) |
Return the rank of a thread.
[in] | quark | The scheduler's main data structure. |
Definition at line 504 of file quark.c.
References quark_s::num_threads, pthread_equal(), pthread_self(), worker_s::thread_id, and quark_s::worker.
void QUARK_Waitall | ( | Quark * | quark | ) |
Called by the master thread. Wait for all the tasks to be completed, then return. The worker tasks will also exit from their work loop at this time.
[in,out] | quark | The scheduler's main data structure. |
Definition at line 954 of file quark.c.
References DBGPRINTF, worker_s::finalize, quark_s::num_queued_tasks_mutex, quark_s::num_threads, quark_atomic_set, QUARK_Barrier(), worker_s::rank, worker_s::ready_list_size, TRUE, quark_s::worker, worker_s::worker_must_awake_cond, and worker_s::worker_mutex.
void QUARK_Worker_Loop | ( | Quark * | quark, |
int | thread_rank | ||
) |
This function is called by a thread when it wants to start working. This is used in a system that does its own thread management, so each worker thread in that system must call this routine to get the worker to participate in computation.
[in,out] | quark | The main data structure. |
[in] | thread_rank | The rank of the thread. |
Definition at line 1898 of file quark.c.
References pthread_self(), worker_s::thread_id, and quark_s::worker.