source: soft/giet_vm/giet_common/kernel_barriers.h @ 826

Last change on this file since 826 was 495, checked in by alain, 10 years ago

Introduce quad tree for distributed locks and barriers.

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : kernel_barrier.h
3// Date     : 19/01/2015
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The kernel_barrier.c and kernel_barrier.h files are part of the GIET-VM kernel.
8// They define both a simple barrier and a scalable, distributed barrier,
9// based on Synchronisation Quad Tree (SQT).
10///////////////////////////////////////////////////////////////////////////////////
11
12#ifndef GIET_KERNEL_BARRIERS_H
13#define GIET_KERNEL_BARRIERS_H
14
15#include "hard_config.h"
16
17#define SBT_MAX_LEVELS 5
18
19///////////////////////////////////////////////////////////////////////////////////
20//      Simple barrier structure and access functions
21///////////////////////////////////////////////////////////////////////////////////
22
23typedef struct simple_barrier_s
24{
25    unsigned int sense;          // barrier state (toggle)
26    unsigned int ntasks;         // total numer of expected tasks
27    unsigned int count;          // number of not arrived tasks
28    unsigned int padding[13];    // for 64 bytes alignment
29} simple_barrier_t;
30
31extern void _simple_barrier_init( simple_barrier_t*  barrier,
32                                  unsigned int       ntasks );
33
34extern void _simple_barrier_wait( simple_barrier_t*  barrier );
35
36//////////////////////////////////////////////////////////////////////////////////
37//      SQT barrier structures and access functions
38//////////////////////////////////////////////////////////////////////////////////
39
40typedef struct sqt_barrier_node_s
41{
42    unsigned int                arity;        // number of children (4 max)
43    unsigned int                count;        // number of not arrived children
44    unsigned int                sense;        // barrier state (toggle)     
45    unsigned int                level;        // hierarchical level (0 is bottom)
46    struct sqt_barrier_node_s*  parent;       // parent node (NULL for root)
47    struct sqt_barrier_node_s*  child[4];     // children node
48    unsigned int                padding[7];   // for 64 bytes alignment         
49} sqt_barrier_node_t;
50
51typedef struct sqt_barrier_s
52{
53    unsigned int          ntasks;
54    sqt_barrier_node_t*   node[X_SIZE][Y_SIZE][SBT_MAX_LEVELS];
55} sqt_barrier_t;
56
57extern void _sqt_barrier_init( sqt_barrier_t*  barrier );
58
59extern void _sqt_barrier_wait( sqt_barrier_t*  barrier );
60
61
62#endif
63
64// Local Variables:
65// tab-width: 4
66// c-basic-offset: 4
67// c-file-offsets:((innamespace . 0)(inline-open . 0))
68// indent-tabs-mode: nil
69// End:
70// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
71
Note: See TracBrowser for help on using the repository browser.