= 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). The SBT topology is completely defined by the number of involved clusters, with the following constraints: * The number of involved clusters must be a power of 2. * The involved clusters form a mesh[X][Y] where (X = Y) or (X = 2*Y). * The lower left involved cluster is cluster(0,0). * All involved clusters must contain a heap[x][y] vseg declared in the mapping. * The number of involved tasks in a given cluster is the same for all clusters The available functions are: * '''sbt_barrier_init( giet_sbt_barrier_t * barrier, unsigned int nclusters, unsigned int ntasks )''' * '''sbt_barrier_wait( giet_sbt_barrier_t * barrier )''' The '''barrier''' argument is a pointer on a ''giet_barrier_t'' object. The '''nclusters''' argument is the number of involved clusters. The '''ntasks''' argument is the number of expected tasks in a single cluster. The sbt_barrier_init() contains a system call, but the sbt_barrier_wait() does not. == C) Barrier Initialization == For both types of barriers, the barrier initialization must be done by one single task.