SST/macro
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
sstmac
backends
native
clock_cycle_parallel
thread_barrier.h
Go to the documentation of this file.
1
#ifndef THREAD_BARRIER_H
2
#define THREAD_BARRIER_H
3
4
#include <
pthread.h
>
5
#include <vector>
6
#include <stdint.h>
7
#include <
sstmac/common/sstmac_config.h
>
8
9
namespace
sstmac
{
10
namespace
native {
11
12
class
thread_barrier_functor
{
13
14
public
:
15
virtual
int64_t
16
execute
(int64_t) = 0;
17
18
};
19
20
class
thread_barrier
{
21
22
public
:
23
#ifdef SSTMAC_USE_SPINLOCK
24
typedef
pthread_spinlock_t
lock_t
;
25
#else
26
typedef
pthread_mutex_t
lock_t
;
27
#endif
28
29
thread_barrier
(
int
nthread);
30
31
thread_barrier
(){}
32
33
void
34
start(
int
me,
thread_barrier_functor
* functor = 0);
35
36
int64_t
37
vote(
int
me, int64_t vote,
thread_barrier_functor
* functor = 0);
38
39
void
init
(
int
nthread);
40
41
protected
:
42
int64_t
43
run
(
int
me,
int
level,
int
nthread, int64_t vote,
thread_barrier_functor
* functor);
44
45
void
lock(lock_t* l);
46
47
void
unlock(lock_t* l);
48
49
int
init_level(
int
level,
int
num,
int
offset);
50
51
52
53
protected
:
54
struct
barrier_state
{
55
lock_t*
in_lock
;
56
lock_t*
out_lock
;
57
int64_t
vote
;
58
};
59
60
int
nthread_
;
61
int
twoPowN_
;
62
lock_t*
out_locks_
;
63
lock_t*
in_locks_
;
64
std::vector<std::vector<barrier_state> >
levels_
;
65
};
66
67
class
multiuse_thread_barrier
68
{
69
public
:
70
thread_barrier
*
b0
;
71
thread_barrier
*
b1
;
72
73
private
:
74
int
next
;
75
76
public
:
77
multiuse_thread_barrier
() :
78
b0(0), b1(0),
79
next(0)
80
{
81
}
82
83
void
84
start
(
int
me){
85
if
(next==0){
86
b0->
start
(me);
87
}
else
{
88
b1->
start
(me);
89
}
90
next=(next+1)%2;
91
}
92
};
93
94
}
95
}
96
97
#endif // THREAD_BARRIER_H
sstmac::native::thread_barrier_functor
Definition:
thread_barrier.h:12
sstmac::native::multiuse_thread_barrier
Definition:
thread_barrier.h:67
sstmac::native::multiuse_thread_barrier::b0
thread_barrier * b0
Definition:
thread_barrier.h:70
sstmac::native::thread_barrier::barrier_state::vote
int64_t vote
Definition:
thread_barrier.h:57
sstmac::native::multiuse_thread_barrier::multiuse_thread_barrier
multiuse_thread_barrier()
Definition:
thread_barrier.h:77
pthread.h
sstmac::native::thread_barrier::out_locks_
lock_t * out_locks_
Definition:
thread_barrier.h:62
sstmac::native::thread_barrier::levels_
std::vector< std::vector< barrier_state > > levels_
Definition:
thread_barrier.h:64
sstmac::native::thread_barrier_functor::execute
virtual int64_t execute(int64_t)=0
sstmac::native::thread_barrier::nthread_
int nthread_
Definition:
thread_barrier.h:60
sstmac::native::thread_barrier::lock_t
pthread_mutex_t lock_t
Definition:
thread_barrier.h:26
sstmac::native::multiuse_thread_barrier::next
int next
Definition:
thread_barrier.h:74
pthread_mutex_t
#define pthread_mutex_t
Definition:
sstmac_pthread_macro.h:136
sstmac::init
parallel_runtime * init()
sstmac
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
Definition:
parallel_runtime.h:18
sstmac::native::thread_barrier::in_locks_
lock_t * in_locks_
Definition:
thread_barrier.h:63
sstmac::native::thread_barrier::twoPowN_
int twoPowN_
Definition:
thread_barrier.h:61
sstmac::native::thread_barrier::start
void start(int me, thread_barrier_functor *functor=0)
sstmac::native::thread_barrier::barrier_state::in_lock
lock_t * in_lock
Definition:
thread_barrier.h:55
sstmac::run
void run(opts &oo, sstmac::parallel_runtime *rt, sprockit::sim_parameters *params, sim_stats &stats)
sstmac::native::thread_barrier::thread_barrier
thread_barrier()
Definition:
thread_barrier.h:31
pthread_spinlock_t
#define pthread_spinlock_t
Definition:
sstmac_pthread_macro.h:137
sstmac::native::multiuse_thread_barrier::start
void start(int me)
Definition:
thread_barrier.h:84
sstmac::native::thread_barrier
Definition:
thread_barrier.h:20
sstmac::native::multiuse_thread_barrier::b1
thread_barrier * b1
Definition:
thread_barrier.h:71
sstmac::native::thread_barrier::barrier_state::out_lock
lock_t * out_lock
Definition:
thread_barrier.h:56
sstmac::native::thread_barrier::barrier_state
Definition:
thread_barrier.h:54
sstmac_config.h
Generated by
1.8.11