= The Barrier Library = The [source:soft/giet_vm/giet_libs/barrier.c barrier.c] and [source:soft/giet_vm/giet_libs/barrier.h barrier.h] files define a synchronisation service between several tasks sharing the same address space in a parallel multi-tasks application. There is actually two types of barriers: == A) Simple Barrier == The ''giet_barrier_t'' is a simple sense-reversing barrier. It can be safely used several times (in a loop for example), but it does not scale, and should not be used when the number of expected tasks is larger than few tens. The available functions are: * '''barrier_init( giet_barrier_t * barrier, unsigned int ntasks )''' * '''barrier_wait( giet_barrier_t * barrier )''' The ''barrier'' argument is a pointer on a ''giet_barrier_t'' object. The ''ntasks'' argument is the number of expected tasks. Neither the barrier_init(), nor the barrier_wait() function contains a system call. == B) Distributed Barrier == The ''giet_sbt_barrier_t'' can be used in multi-clusters architectures, and is implemented as a physically distributed Sliced-Binary-Tree (SBT). To use this distributed barrier, some placement constraints must be respected: * The number of tasks must be a power of 2. * There is one task per processor in a given cluster. * The involved clusters form a mesh[X][Y] where (X = Y) or (x = 2*Y) * The lower left involved cluster is cluster(0,0) The available functions are: * '''sbt_barrier_init( giet_sbt_barrier_t * barrier, unsigned int ntasks )''' * '''sbt_barrier_wait( giet_sbt_barrier_t * barrier )''' The ''barrier'' argument is a pointer on a ''giet_barrier_t'' object. The ''ntasks'' argument is the number of expected tasks. The sbt_barrier_init() contains a system call, but the sbt_barrier_wait() does not. '''WARNING:''' For both types of barriers, the barrier initialisation should be done by one single task.