DepSpawn 1.2
 
Loading...
Searching...
No Matches
Data Dependent Spawn (DepSpawn) library

DepSpawn is a C++ library that allows to easily parallelize applications in multicore systems. For this, the parallel tasks must be expressed as functions that convey their dependencies by means of their arguments. DepSpawn analyzes the arguments of each task when it is launched for parallel execution and it makes sure that tasks only run when all their dependencies are fulfilled.

All we need to do to spawn as a parallel task the execution of function f(a, b, ...) using DepSpawn is to rewrite it as ::spawn(f, a, b, ...).

The type of the formal parameters of a funtion indicates whether they are only inputs or they can be both inputs and outputs following C++ semantics:

  • Arguments by value (e.g. int a) are only inputs to the function because the function actually reveives a copy of the original argument, so it can only read, but never modify it.
  • Arguments by constant reference (e.g. const int& a) are also only inputs to the function because although the function accesses the original argument through the reference, the const modifier prohibits its modification.
  • Arguments by non-constant reference (e.g. int& a) are regarded as both inputs and outputs because the function accesses the original object provided by the caller, and it can both read and modify it.

As an example, in the code below the function foo receives its two arguments by value, which makes them read-only for this function. As a result, DepSpawn can run in parallel all the evaluations of this function, as there are no dependences among them according to their arguments.

#include "depspawn/depspawn.h"
using namespace depspawn;
int v[N];
void foo(int i, int j)
{
...
}
int main(int argc, char **argv)
{
for(int i = 0; i < N - 1; i++)
spawn(foo, v[i], v[i + 1]);
}
Public library API.
Definition: main.dox:1

However, in the code below foo can modify its second argument. This way, here DepSpawn executes sequentially all the evaluations of function foo, because each one of them takes as input a piece of data (v[i]) that is a potential output, i.e. can be written, by the evaluation of foo in the preceding iteration.

#include "depspawn/depspawn.h"
using namespace depspawn;
int v[N];
void foo(int i, int& j)
{
...
}
int main(int argc, char **argv)
{
for(int i = 0; i < N - 1; i++)
spawn(foo, v[i], v[i + 1]);
}

Please follow the list of topics covered this documentation to learn how to install and use DepSpawn step by step.