GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Macros | Typedefs | Enumerations | Functions
task.h File Reference

Types and functions for the tasks. More...

#include <pthread.h>
#include <semaphore.h>
#include <hwloc.h>
#include "error.h"
Include dependency graph for task.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ghost_task
 This structure represents a GHOST task. More...
 

Macros

#define GHOST_TASK_LD_UNDEFINED   -2
 
#define GHOST_TASK_FILL_LD   -1
 Use all processing units in the given NUMA domain. More...
 
#define GHOST_TASK_FILL_ALL   -2
 Use all available processing units. More...
 

Typedefs

typedef struct ghost_task ghost_task
 This structure represents a GHOST task. More...
 

Enumerations

enum  ghost_task_flags {
  GHOST_TASK_DEFAULT = 0, GHOST_TASK_PRIO_HIGH = 1, GHOST_TASK_LD_STRICT = 2, GHOST_TASK_NOT_ALLOW_CHILD = 4,
  GHOST_TASK_NOT_PIN = 8, GHOST_TASK_ONLY_HYPERTHREADS = 16, GHOST_TASK_NO_HYPERTHREADS = 32
}
 
enum  ghost_task_state {
  GHOST_TASK_INVALID, GHOST_TASK_CREATED, GHOST_TASK_ENQUEUED, GHOST_TASK_RUNNING,
  GHOST_TASK_FINISHED
}
 

Functions

ghost_error ghost_task_create (ghost_task **task, int nThreads, int LD, void *(*func)(void *), void *arg, ghost_task_flags flags, ghost_task **depends, int ndepends)
 Create a task. More...
 
ghost_error ghost_task_enqueue (ghost_task *t)
 Enqueue a task. More...
 
ghost_error ghost_task_wait (ghost_task *t)
 Wait for a task to finish. More...
 
ghost_task_state ghost_taskest (ghost_task *t)
 Test the task's current state. More...
 
void ghost_task_destroy (ghost_task *t)
 Destroy a task. More...
 
ghost_error ghost_task_unpin (ghost_task *task)
 Unpin a task's threads. More...
 
const char * ghost_task_state_string (ghost_task_state state)
 Return a string representing the task's state. More...
 
ghost_error ghost_task_string (char **str, ghost_task *t)
 Stringify a task. More...
 
ghost_error ghost_task_cur (ghost_task **task)
 
bool ghost_tasking_enabled ()
 Check whether tasking is globally enabled. More...
 

Detailed Description

Types and functions for the tasks.

@{

Author
Moritz Kreutzer morit.nosp@m.z.kr.nosp@m.eutze.nosp@m.r@fa.nosp@m.u.de

Macro Definition Documentation

#define GHOST_TASK_FILL_ALL   -2

Use all available processing units.

#define GHOST_TASK_FILL_LD   -1

Use all processing units in the given NUMA domain.

#define GHOST_TASK_LD_UNDEFINED   -2

Typedef Documentation

typedef struct ghost_task ghost_task

This structure represents a GHOST task.

This data structure holds all necessary information for a task. The members ghost_task::nThreads, ghost_task::LD, ghost_task::flags, ghost_task::func, ghost_task::arg, ghost_task::depends, and ghost_task::ndepends have to be set by the user in ghost_task_init(). All other members are set by the library at some point.

Enumeration Type Documentation

Enumerator
GHOST_TASK_DEFAULT 

The default task.

GHOST_TASK_PRIO_HIGH 

The task will be treated as high-priority.

GHOST_TASK_LD_STRICT 

The task must be executed in the given NUMA node.

GHOST_TASK_NOT_ALLOW_CHILD 

A child task must not use this task's resources.

GHOST_TASK_NOT_PIN 
GHOST_TASK_ONLY_HYPERTHREADS 
GHOST_TASK_NO_HYPERTHREADS 
Enumerator
GHOST_TASK_INVALID 

Task is invalid (e.g., not yet created).

GHOST_TASK_CREATED 

Task has been created.

GHOST_TASK_ENQUEUED 

Task has been enqueued.

GHOST_TASK_RUNNING 

Task is running.

GHOST_TASK_FINISHED 

Task has finished.

Function Documentation

ghost_error ghost_task_create ( ghost_task **  task,
int  nThreads,
int  LD,
void *(*)(void *)  func,
void *  arg,
ghost_task_flags  flags,
ghost_task **  depends,
int  ndepends 
)

Create a task.

Parameters
taskWhere to store the task
nThreadsThe number of threads which are reserved for the task
LDThe index of the task queue this task should be added to
funcThe function the task should execute
argThe arguments to the task's function
flagsThe task's flags
dependsList of ghost_task * on which this task depends
ndependsLength of the depends argument
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

ghost_error ghost_task_cur ( ghost_task **  task)

Here is the call graph for this function:

void ghost_task_destroy ( ghost_task t)

Destroy a task.

Parameters
[in,out]tThe task to be destroyed
ghost_error ghost_task_enqueue ( ghost_task t)

Enqueue a task.

Parameters
tThe task.
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

ghost_error ghost_task_unpin ( ghost_task task)

Unpin a task's threads.

Parameters
[in,out]taskThe task.
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

ghost_error ghost_task_wait ( ghost_task t)

Wait for a task to finish.

Parameters
tThe task to wait for
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

ghost_task_state ghost_taskest ( ghost_task t)

Test the task's current state.

Parameters
tThe task to test
Returns
The state of the task
bool ghost_tasking_enabled ( )

Check whether tasking is globally enabled.

Returns
false if the GHOST_TASK environment variable is set to "disable", true otherwise.