Once a cluster entry point has been entered by cluster controller core, all the following primitives can be used to do multi-core processing, in a fork-join manner (like OMP parallel primitive).
The execution can first be forked in order to activate more cores, and then synchronized together using barriers.
static int pi_cl_cluster_nb_cores |
( |
| ) |
|
|
inlinestatic |
This will return the number of slave cores present in the cluster, available to share/fork a task.
- Returns
- Number of cores.
This will block the execution of each calling core until all cores have reached the barrier. The set of cores participating in the barrier is the one created with the last fork. Each core of the team must execute the barrier exactly once for all cores to be able to go through the barrier.
This will block the execution of the calling core until it can execute the following section of code alone. This will also prevent all other cores of the team to execute the following code until pi_cl_team_critical_exit() is called.
- Note
- No runtime functions should be called from within the critical section, only application code is allowed.
This will exit the critical code and let other cores executing it.
void pi_cl_team_fork |
( |
int |
nb_cores, |
|
|
void(*)(void *) |
entry, |
|
|
void * |
arg |
|
) |
| |
Calling this function will create a team of workers and call the specified entry point on each core of the team to start multi-core processing. The team parameters (number of cores and stacks) are by default the ones configured when sending a task to cluster from the fabric controller. It is possible to use different parameters when doing a new fork. If this is done the new parameters will become the new default ones.
- Parameters
-
nb_cores | Number of cores to execute the task/entry point.. |
entry | Function entry point to be executed by team of workers. |
arg | Argument of the function entry point. |
- Note
- If nb_cores is zero, fork is done reusing the cores_mask of the previous fork or the default.
-
If the number of cores is not provided (i.e. is zero), the number of cores of the previous fork will be reused. Doing this has less runtime overhead.
void pi_cl_team_fork_task |
( |
struct pi_cl_team_task * |
fork_task | ) |
|
This function is similar to pi_cl_team_fork but takes a task as parameter, which allows setting more parameters. Calling this function will create a team of workers and call the specified entry point on each core of the team to start multi-core processing with the team parameters specified in the task.
- Parameters
-
fork_task | Task to be forked on slave cores. |
int pi_cl_team_nb_cores |
( |
| ) |
|
This will return the number of cores involved in the team created by the active fork operation.
- Returns
- The number of cores of the team.
void pi_cl_team_prepare_fork |
( |
int |
nb_cores | ) |
|
This function is called to set up a team of workers. This function has the same behaviour as pi_cl_team_fork(), but here the fork is not done, thus a call to pi_cl_team_preset_fork() is needed in order to dispatch the task to the team of workers.
- Parameters
-
nb_cores | Number of cores to execute the entry point |
void pi_cl_team_preset_fork |
( |
void(*)(void *) |
entry, |
|
|
void * |
arg |
|
) |
| |