source: soft/giet_vm/giet_libs/barrier.h @ 496

Last change on this file since 496 was 487, checked in by alain, 9 years ago

1) Change the user sbt_barrier_init() prototype: the two (nclusters/ntasks) arguments
replace the single (ntasks) argument.
2) Introduce an explicit (channel) argument in all iuser access functions to the NIC component.
Previously, the channel registered in the task context was an implicit argument.
The channel is still registered in the task context for checking.

  • Property svn:executable set to *
File size: 4.8 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////
2// File     : barrier.h         
3// Date     : 01/04/2012
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The barrier.c and barrier.h files are part of the GIET-VM nano-kernel.
8// This user-level library provides a synchronisation service between several
9// tasks sharing the same address space in a parallel multi-tasks application.
10//
11// There is actually two types of barriers:
12// 1) The "giet_barrier_t" is a simple sense-reversing barrier.
13//    It can be safely used several times (in a loop for example),
14//    but it does not scale, and should not be used when the number
15//    of tasks is larger than few tens.
16//
17// 2) The giet_sbt_barrier_t" can be used in multi-clusters architectures,
18//    and is implemented as a physically distributed Sliced-Binary-Tree (SBT).
19//    WARNING: The following placement constraints must be respected:
20//    - The number of involved clusters must be a power of 2.
21//    - The number of involved tasks in a cluster is the same in all clusters.
22//    - The involved clusters form a mesh[N][N] or a mesh[N][N/2]
23//    - The lower left involved cluster is cluster(0,0) 
24//
25// Neither the barrier_init(), nor the barrier_wait() function require a syscall.
26// For both types of barriers, the barrier initialisation should be done by
27// one single task.
28///////////////////////////////////////////////////////////////////////////////////
29
30#ifndef _BARRIER_H_
31#define _BARRIER_H_
32
33#include "hard_config.h"
34
35///////////////////////////////////////////////////////////////////////////////////
36///////////////////////////////////////////////////////////////////////////////////
37//  simple barrier structure and access functions
38///////////////////////////////////////////////////////////////////////////////////
39///////////////////////////////////////////////////////////////////////////////////
40
41typedef struct giet_barrier_s
42{
43    char         name[32];   // barrier name
44    unsigned int sense;      // barrier state (toggle)
45    unsigned int ntasks;     // total number of expected tasks
46    unsigned int count;      // number of not arrived tasks
47} giet_barrier_t;
48
49///////////////////////////////////////////////////
50extern void barrier_init( giet_barrier_t* barrier,
51                          unsigned int    ntasks );   
52
53////////////////////////////////////////////////////
54extern void barrier_wait( giet_barrier_t* barrier );
55
56///////////////////////////////////////////////////////////////////////////////////
57//////////////////////////////////////////////////////////////////////////////////
58// SBT barrier structures and access functions
59//////////////////////////////////////////////////////////////////////////////////
60//////////////////////////////////////////////////////////////////////////////////
61
62typedef struct sbt_node_s
63{
64    unsigned int       arity;           // number of children (must be 2 or 4)
65    unsigned int       count;           // number of not arrived children
66    unsigned int       sense;           // barrier state (toggle)
67    unsigned int       level;           // hierarchical level (0 is bottom)
68    struct sbt_node_s* parent;          // pointer on parent node (NULL for root)
69    struct sbt_node_s* child0;          // pointer on children node
70    struct sbt_node_s* child1;          // pointer on children node
71    unsigned int       padding;         // for 32 bytes alignment
72} sbt_node_t;
73
74typedef struct giet_sbt_barrier_s
75{
76    char            name[32];                 // barrier name
77    unsigned int    ntasks;                   // total number of expected tasks
78    sbt_node_t*     node[X_SIZE][Y_SIZE][9];  // array of pointers on SBT nodes
79} giet_sbt_barrier_t;
80
81///////////////////////////////////////////////////////////
82extern void sbt_barrier_init( giet_sbt_barrier_t*  barrier,
83                              unsigned int         nclusters,
84                              unsigned int         ntasks );   
85
86/////////////////////////////////////////////////////////////
87extern void sbt_barrier_wait( giet_sbt_barrier_t*  barrier );
88
89/////////////////////////////////////////////
90void sbt_build( giet_sbt_barrier_t*  barrier,
91                unsigned int         x,
92                unsigned int         y,
93                unsigned int         level, 
94                sbt_node_t*          parent,
95                unsigned int         ntasks );
96
97///////////////////////////////////////
98void sbt_decrement( sbt_node_t* node );
99
100///////////////////////////////////
101void sbt_release( sbt_node_t* node,
102                  unsigned int expected );
103
104
105
106#endif
107
108// Local Variables:
109// tab-width: 4
110// c-basic-offset: 4
111// c-file-offsets:((innamespace . 0)(inline-open . 0))
112// indent-tabs-mode: nil
113// End:
114// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
115
Note: See TracBrowser for help on using the repository browser.