![]() |
GHOST
1.1.2
General, Hybrid, and Optimized Sparse Toolkit
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <semaphore.h>
#include <errno.h>
#include <unistd.h>
#include "ghost/config.h"
#include "ghost/types.h"
#include "ghost/core.h"
#include "ghost/locality.h"
#include "ghost/task.h"
#include "ghost/taskq.h"
#include "ghost/thpool.h"
#include "ghost/pumap.h"
#include "ghost/util.h"
#include "ghost/machine.h"
#include "ghost/log.h"
#include "ghost/omp.h"
#include "ghost/bitmap.h"
Macros | |
#define | _XOPEN_SOURCE 500 |
Functions | |
static void * | thread_main (void *arg) |
The main routine of each thread in the thread pool. More... | |
ghost_error | ghost_taskq_create () |
Initializes a task queues. More... | |
static int | taskq_deleteTask (ghost_taskq *q, ghost_task *t) |
Deletes a given task from a given queue. More... | |
static ghost_task * | taskq_findDeleteAndPinTask (ghost_taskq *q, int nthreads) |
Try to find a task in the given queue. If there is a suited task, delete it from the queue, reserve enough cores in order to execute the task and pin the task's threads to the reserved cores. More... | |
ghost_error | ghost_taskq_startroutine (void *(**func)(void *)) |
ghost_error | ghost_taskq_add (ghost_task *t) |
Helper function to add a task to a queue. More... | |
ghost_error | ghost_taskq_destroy () |
Execute all outstanding threads and free the task queues' resources. More... | |
ghost_error | ghost_taskq_waitall () |
Wait for all tasks in all queues to be finished. More... | |
ghost_error | ghost_taskq_waitsome (ghost_task **tasks, int nt, int *index) |
Wait for some tasks out of a given list of tasks. More... | |
Variables | |
ghost_taskq * | taskq = NULL |
The task queue created by ghost_taskq_create(). More... | |
static int | killed = 0 |
This is set to 1 if the tasqs are about to be killed. The threads will exit their infinite loops in this case. More... | |
static pthread_mutex_t | globalMutex |
Protects access to global variables. More... | |
static pthread_cond_t | anyTaskFinishedCond |
This is waited for in ghost_task_waitsome() and broadcasted in ghost_task_wait() when the task has finished. More... | |
static pthread_mutex_t | anyTaskFinishedMutex |
The mutex to protect anyTaskFinishedCond. More... | |
static int | num_pending_tasks = 0 |
static int | nthreadcount = 0 |
Holds the number of valid thread counts for tasks. This is usually the number of PUs+1 (for zero-PU tasks) More... | |
static pthread_cond_t ** | newTaskCond_by_threadcount |
static pthread_mutex_t * | newTaskMutex_by_threadcount |
static int * | num_shep_by_threadcount |
static int * | waiting_shep_by_threadcount |
static int * | num_tasks_by_threadcount |
static pthread_key_t | threadcount_key |
static pthread_key_t | mutex_key |
#define _XOPEN_SOURCE 500 |
ghost_error ghost_taskq_add | ( | ghost_task * | t | ) |
Helper function to add a task to a queue.
t | The task |
ghost_error ghost_taskq_create | ( | ) |
Initializes a task queues.
ghost_error ghost_taskq_destroy | ( | ) |
Execute all outstanding threads and free the task queues' resources.
ghost_error ghost_taskq_startroutine | ( | void *(**)(void *) | func | ) |
ghost_error ghost_taskq_waitall | ( | ) |
Wait for all tasks in all queues to be finished.
ghost_error ghost_taskq_waitsome | ( | ghost_task ** | tasks, |
int | nt, | ||
int * | index | ||
) |
Wait for some tasks out of a given list of tasks.
tasks | The list of task pointers that should be waited for. |
nt | The length of the list. |
index | Indicating which tasks of the list are now finished. |
|
static |
Deletes a given task from a given queue.
q | |
t |
|
static |
Try to find a task in the given queue. If there is a suited task, delete it from the queue, reserve enough cores in order to execute the task and pin the task's threads to the reserved cores.
q |
|
static |
The main routine of each thread in the thread pool.
arg | The core at which the thread is running. |
|
static |
This is waited for in ghost_task_waitsome() and broadcasted in ghost_task_wait() when the task has finished.
|
static |
The mutex to protect anyTaskFinishedCond.
|
static |
Protects access to global variables.
|
static |
This is set to 1 if the tasqs are about to be killed. The threads will exit their infinite loops in this case.
|
static |
|
static |
|
static |
|
static |
Holds the number of valid thread counts for tasks. This is usually the number of PUs+1 (for zero-PU tasks)
|
static |
|
static |
|
static |
ghost_taskq* taskq = NULL |
The task queue created by ghost_taskq_create().
|
static |
|
static |