OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

vt_unify_sync.h
1 /**
2 * VampirTrace
3 * http://www.tu-dresden.de/zih/vampirtrace
4 *
5 * Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
6 *
7 * Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
8 * Centre, Federal Republic of Germany
9 *
10 * See the file COPYING in the package base directory for details
11 **/
12
13 #ifndef _VT_UNIFY_SYNC_H_
14 #define _VT_UNIFY_SYNC_H_
15
16 #include "config.h"
17
18 #include "vt_unify.h"
19
20 #ifdef VT_ETIMESYNC
21 # include "vt_unify_esync.h"
22 #endif // VT_ETIMESYNC
23
24 #include "vt_inttypes.h"
25
26 #include <map>
27
28 //
29 // TimeSyncC class
30 //
31 class TimeSyncC
32 {
33 public:
34
35 // type for time synchronization methods
36 typedef enum { METHOD_OFFSET, METHOD_ENHANCED } MethodTypeT;
37
38 // type for time ranges
39 typedef std::pair<uint64_t, uint64_t> TimeRangeT;
40
41 // constructor
42 TimeSyncC();
43
44 // destructor
45 ~TimeSyncC();
46
47 // initialize time synchronization
48 bool initialize();
49
50 // set time sync. method
51 void setSyncMethod( const MethodTypeT & method )
52 {
53 #ifndef VT_ETIMESYNC
54 assert( method != METHOD_ENHANCED );
55 #endif // VT_ETIMESYNC
56
57 m_syncMethod = method;
58 }
59
60 // get time sync. method
61 MethodTypeT getSyncMethod() const
62 {
63 return m_syncMethod;
64 }
65
66 // set time range of certain process and update minimum start time
67 void setTimeRange( const uint32_t & proc, const uint64_t & minTime,
68 const uint64_t & maxTime )
69 {
70 assert( proc != 0 );
71
72 // set time range of certain process
73 m_proc2TimeRange[proc] = TimeRangeT( minTime, maxTime );
74 }
75
76 // get time range of certain process
77 // (if proc is 0, the global time range will be returned)
78 TimeRangeT getTimeRange( const uint32_t & proc = 0 ) const
79 {
80 // search for time range of given process
81 std::map<uint32_t, TimeRangeT>::const_iterator it =
82 m_proc2TimeRange.find( proc );
83 assert( it != m_proc2TimeRange.end() );
84
85 // return time range
86 return it->second;
87 }
88
89 // get minimum start time
90 uint64_t getMinStartTime() const
91 {
92 return m_minStartTime;
93 }
94
95 #ifdef VT_ETIMESYNC
96
97 // update timer parameters of certain process
98 void updateSyncParam( const uint32_t & proc )
99 {
100 assert( m_eTimeSync );
101 m_eTimeSync->updateSyncParam( proc );
102 }
103
104 // reset timer parameters of certain process
105 void resetSyncParam( const uint32_t & proc )
106 {
107 assert( m_eTimeSync );
108 m_eTimeSync->resetSyncParam( proc );
109 }
110
111 #endif // VT_ETIMESYNC
112
113 // translate local timestamp to global
114 // (defined here to become inlined)
115 uint64_t correctTime( const uint32_t & process, const uint64_t & time ) const
116 {
117 // get master process id
118 uint32_t mprocess = process & VT_TRACEID_BITMASK;
119
120 std::map<uint32_t, UnifyControlS*>::const_iterator it =
121 StreamId2UnifyCtl.find( mprocess );
122 assert( it != StreamId2UnifyCtl.end() );
123
124 #ifdef VT_ETIMESYNC
125 if( m_syncMethod == METHOD_ENHANCED )
126 {
127 const int64_t & offset = it->second->sync_offset;
128 const double & drift = it->second->sync_drift;
129
130 return (uint64_t)( offset + (uint64_t)( drift * (double)time ) );
131 }
132 else
133 #endif // VT_ETIMESYNC
134 {
135 const int64_t * ltime = it->second->ltime;
136 const int64_t * offset = it->second->offset;
137
138 return
139 (uint64_t)( ( (double)time +
140 ( ( ( (double)offset[1] - (double)offset[0] ) /
141 ( (double)ltime[1] - (double)ltime[0] ) )
142 * ( (double)time - (double)ltime[0]) )
143 + (double)offset[0] ) - m_minStartTime );
144 }
145 }
146
147 private:
148
149 // time sync. method to use
150 MethodTypeT m_syncMethod;
151
152 // map process id <-> time range
153 // (on rank 0 the first map entry (process id 0) holds the global time range)
154 std::map<uint32_t, TimeRangeT> m_proc2TimeRange;
155
156 // minimum start time
157 uint64_t m_minStartTime;
158
159 #ifdef VT_ETIMESYNC
160 // instance of class ETimeSyncC which cares about enhanced time sync.
161 ETimeSyncC * m_eTimeSync;
162 #endif // VT_ETIMESYNC
163
164 };
165
166 // instance of class TimeSyncC
167 extern TimeSyncC * theTimeSync;
168
169 #endif // _VT_UNIFY_SYNC_H_
ETimeSyncC
VampirTrace http://www.tu-dresden.de/zih/vampirtrace.
Definition: vt_unify_esync.h:28
TimeSyncC
VampirTrace http://www.tu-dresden.de/zih/vampirtrace.
Definition: vt_unify_sync.h:31