StarPU Handbook

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Macros | Enumerations | Enumerator | Functions
Workers’ Properties

## Data Structures
struct | starpu_worker_collection
struct | starpu_sched_ctx_iterator

## Macros
#define | STARPU_NMAXWORKERS

## Enumerations
enum | starpu_node_kind { STARPU_UNUSED, STARPU_CPU_RAM, STARPU_CUDA_RAM, STARPU_OPENCL_RAM }
enum | starpu_worker_archtype { STARPU_ANY_WORKER, STARPU_CPU_WORKER, STARPU_CUDA_WORKER, STARPU_OPENCL_WORKER }
enum | starpu_worker_collection_type { STARPU_WORKER_LIST }

## Functions
unsigned | starpu_worker_get_count (void)
int | starpu_worker_get_count_by_type (enum starpu_worker_archtype type)
unsigned | starpu_cpu_worker_get_count (void)
unsigned | starpu_cuda_worker_get_count (void)
unsigned | starpu_opencl_worker_get_count (void)
int | starpu_worker_get_id (void)
int | starpu_worker_get_ids_by_type (enum starpu_worker_archtype type, int *workerids, int maxsize)
int | starpu_worker_get_by_type (enum starpu_worker_archtype type, int num)
int | starpu_worker_get_by_devid (enum starpu_worker_archtype type, int devid)
int | starpu_worker_get_devid (int id)
enum starpu_worker_archtype | starpu_worker_get_type (int id)
void | starpu_worker_get_name (int id, char *dst, size_t maxlen)
unsigned | starpu_worker_get_memory_node (unsigned workerid)
enum starpu_node_kind | starpu_node_get_kind (unsigned node)

## Detailed Description

## Data Structure Documentation

struct starpu_worker_collection

A scheduling context manages a collection of workers that can be memorized using different data structures. Thus, a generic structure is available in order to simplify the choice of its type. Only the list data structure is available but further data structures(like tree) implementations are foreseen.

### Data Fields
void * | workerids
unsigned | nworkers
enum starpu_worker_collection_type | type
unsigned(* | has_next )(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
int(* | get_next )(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
int(* | add )(struct starpu_worker_collection *workers, int worker)
int(* | remove )(struct starpu_worker_collection *workers, int worker)
void(* | init )(struct starpu_worker_collection *workers)
void(* | deinit )(struct starpu_worker_collection *workers)
void(* | init_iterator )(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)

#### Field Documentation

starpu_worker_collection::workerids

The workerids managed by the collection

starpu_worker_collection::nworkers

The number of workers in the collection

starpu_worker_collection::type

The type of structure (currently STARPU_WORKER_LIST is the only one available)

starpu_worker_collection::has_next

Checks if there is another element in collection

starpu_worker_collection::get_next

return the next element in the collection

starpu_worker_collection::add

add a new element in the collection

starpu_worker_collection::remove

remove an element from the collection

starpu_worker_collection::init

Initialize the collection

starpu_worker_collection::deinit

Deinitialize the colection

starpu_worker_collection::init_iterator

Initialize the cursor if there is one

struct starpu_sched_ctx_iterator

Structure needed to iterate on the collection

Data Fields
int | cursor | The index of the current worker in the collection, needed when iterating on the collection.

## Macro Definition Documentation

#define STARPU_NMAXWORKERS

Define the maximum number of workers managed by StarPU.

## Enumeration Type Documentation

enum starpu_node_kind

TODO

Enumerator
STARPU_UNUSED | TODO
STARPU_CPU_RAM | TODO
STARPU_CUDA_RAM | TODO
STARPU_OPENCL_RAM | TODO

enum starpu_worker_archtype

Worker Architecture Type

Enumerator
STARPU_ANY_WORKER | any worker, used in the hypervisor
STARPU_CPU_WORKER | CPU core
STARPU_CUDA_WORKER | NVIDIA CUDA device
STARPU_OPENCL_WORKER | OpenCL device

enum starpu_worker_collection_type

Types of structures the worker collection can implement

Enumerator
STARPU_WORKER_LIST | The collection is an array

## Function Documentation

unsigned starpu_worker_get_count | ( | void |  | ) |

This function returns the number of workers (i.e. processing units executing StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS.

int starpu_worker_get_count_by_type | ( | enum starpu_worker_archtype | type | ) |

Returns the number of workers of the given type. A positive (or NULL) value is returned in case of success, -EINVAL indicates that the type is not valid otherwise.

unsigned starpu_cpu_worker_get_count | ( | void |  | ) |

This function returns the number of CPUs controlled by StarPU. The returned value should be at most STARPU_MAXCPUS.

unsigned starpu_cuda_worker_get_count | ( | void |  | ) |

This function returns the number of CUDA devices controlled by StarPU. The returned value should be at most STARPU_MAXCUDADEVS.

unsigned starpu_opencl_worker_get_count | ( | void |  | ) |

This function returns the number of OpenCL devices controlled by StarPU. The returned value should be at most STARPU_MAXOPENCLDEVS.

int starpu_worker_get_id | ( | void |  | ) |

This function returns the identifier of the current worker, i.e the one associated to the calling thread. The returned value is either -1 if the current context is not a StarPU worker (i.e. when called from the application outside a task or a callback), or an integer between 0 and starpu_worker_get_count() - 1.

int starpu_worker_get_ids_by_type | ( | enum starpu_worker_archtype | type,
|  | int * | workerids,
|  | int | maxsize
| ) |  |

This function gets the list of identifiers of workers with the given type. It fills the array `workerids` with the identifiers of the workers that have the type indicated in the first argument. The argument `maxsize` indicates the size of the array `workerids`. The returned value gives the number of identifiers that were put in the array. -ERANGE is returned is `maxsize` is lower than the number of workers with the appropriate type: in that case, the array is filled with the `maxsize` first elements. To avoid such overflows, the value of maxsize can be chosen by the means of the function starpu_worker_get_count_by_type(), or by passing a value greater or equal to STARPU_NMAXWORKERS.

int starpu_worker_get_by_type | ( | enum starpu_worker_archtype | type,
|  | int | num
| ) |  |

This returns the identifier of the num-th worker that has the specified type type. If there are no such worker, -1 is returned.

int starpu_worker_get_by_devid | ( | enum starpu_worker_archtype | type,
|  | int | devid
| ) |  |

This returns the identifier of the worker that has the specified type `type` and device id `devid` (which may not be the n-th, if some devices are skipped for instance). If there are no such worker, -1 is returned.

int starpu_worker_get_devid | ( | int | id | ) |

This function returns the device id of the given worker. The worker should be identified with the value returned by the starpu_worker_get_id() function. In the case of a CUDA worker, this device identifier is the logical device identifier exposed by CUDA (used by the function cudaGetDevice() for instance). The device identifier of a CPU worker is the logical identifier of the core on which the worker was bound; this identifier is either provided by the OS or by the library `hwloc` in case it is available.

enum starpu_worker_archtype starpu_worker_get_type | ( | int | id | ) |

This function returns the type of processing unit associated to a worker. The worker identifier is a value returned by the function starpu_worker_get_id()). The returned value indicates the architecture of the worker: STARPU_CPU_WORKER for a CPU core, STARPU_CUDA_WORKER for a CUDA device, and STARPU_OPENCL_WORKER for a OpenCL device. The value returned for an invalid identifier is unspecified.

void starpu_worker_get_name | ( | int | id,
|  | char * | dst,
|  | size_t | maxlen
| ) |  |

This function allows to get the name of a given worker. StarPU associates a unique human readable string to each processing unit. This function copies at most the maxlen first bytes of the unique string associated to a worker identified by its identifier id into the dst buffer. The caller is responsible for ensuring that `dst` is a valid pointer to a buffer of `maxlen` bytes at least. Calling this function on an invalid identifier results in an unspecified behaviour.

unsigned starpu_worker_get_memory_node | ( | unsigned | workerid | ) |

This function returns the identifier of the memory node associated to the worker identified by `workerid`.

enum starpu_node_kind starpu_node_get_kind | ( | unsigned | node | ) |

Returns the type of the given node as defined by starpu_node_kind. For example, when defining a new data interface, this function should be used in the allocation function to determine on which device the memory needs to be allocated.