wiki:library_barrier

Version 7 (modified by alain, 10 years ago) (diff)

--

The barrier library

The barrier.c and 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 tasks, with the following constraints:

  • The number of tasks must be a power of 2.
  • There is one task per processor.
  • 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 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.