OpenMPI  0.1.1
vt_unify.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_H_
14 #define _VT_UNIFY_H_
15 
16 #include "config.h"
17 
18 #ifdef VT_MPI
19 # include "vt_unify_mpi.h"
20 #endif // VT_MPI
21 
22 #ifdef VT_ETIMESYNC
23 # include "vt_unify_esync.h"
24 #endif // VT_ETIMESYNC
25 
26 #include "vt_defs.h"
27 #include "vt_inttypes.h"
28 
29 #include <map>
30 #include <set>
31 #include <string>
32 #include <vector>
33 
34 #if defined(HAVE_OMP) && HAVE_OMP
35 # ifdef VT_LIB
36 # undef HAVE_OMP
37  // disable OpenMP on NEC SX platforms to work around a compiler error
38 # elif defined(_SX)
39 # undef HAVE_OMP
40 # else // VT_LIB || _SX
41 # include <omp.h>
42 # endif // VT_LIB
43 #endif // HAVE_OMP
44 
45 #define STRBUFSIZE 1024
46 
47 // define to prefix each verbose message with a timestamp
48 //#define TIME_VERBOSE
49 
50 #ifdef VT_MPI
51 # define MASTER if( MyRank == 0 )
52 # define SLAVE if( MyRank != 0 )
53  // define to synchronize the error indicator between all ranks
54 //# define SYNC_ERROR
55 #else // VT_MPI
56 # define MASTER
57 #endif // VT_MPI
58 
59 //
60 // unify parameter structure (contains the program options)
61 //
62 struct ParamsS
63 {
64  ParamsS()
65  : verbose_level( 0 ), docompress( false ), doclean( true ),
66  showusage( false ), showversion( false ), showprogress( false ),
67  bequiet( false ), onlystats( false ), domsgmatch( false ),
68  droprecvs( false ), prof_sort_flags( 0x22 ), createthumb( false )
69  {
70 #if defined(HAVE_ZLIB) && HAVE_ZLIB
71  docompress = true;
72 #endif // HAVE_ZLIB
73 
74 #ifdef VT_UNIFY_HOOKS_MSGMATCH
75  domsgmatch = true;
76 #endif // VT_UNIFY_HOOKS_MSGMATCH
77 
78 #ifdef VT_UNIFY_HOOKS_THUMB
79  createthumb = true;
80 #endif // VT_UNIFY_HOOKS_THUMB
81  }
82 
83  std::string in_file_prefix; // input trace file prefix
84  std::string out_file_prefix; // output trace file prefix
85  uint8_t verbose_level; // verbose level
86  bool docompress; // flag: do compress output trace?
87  bool doclean; // flag: do remove local trace?
88  bool showusage; // flag: show usage text?
89  bool showversion; // flag: show VampirTrace version?
90  bool showprogress; // flag: show progress?
91  bool bequiet; // flag: print no messages?
92  bool onlystats; // flag: unify only summarized information?
93 
94  // HooksMsgMatchC's parameters
95  //
96  bool domsgmatch; // flag: do match messages?
97  bool droprecvs; // flag: drop receive messages, if matching?
98 
99  // HooksProfC's parameters
100  //
101  std::string prof_out_file; // profile output file
102  int prof_sort_flags; // profile sort flags
103 
104  // HooksThumbC's parameters
105  //
106  bool createthumb; // flag: create Vampir thumbnail?
107 
108 };
109 
110 //
111 // unify control structure for each input stream
112 //
114 {
115 #ifndef VT_ETIMESYNC
116  UnifyControlS()
117  : streamid( 0 ), pstreamid( 0 ), stream_avail( true )
118  {
119  ltime[0] = ltime[1] = offset[0] = offset[1] = 0;
120  }
121 
122  UnifyControlS( const uint32_t & _streamid, const uint32_t & _pstreamid,
123  const bool & _stream_avail, const int64_t * _ltime,
124  const int64_t * _offset )
125  : streamid( _streamid ), pstreamid( _pstreamid ),
126  stream_avail( _stream_avail )
127  {
128  ltime[0] = _ltime[0]; ltime[1] = _ltime[1];
129  offset[0] = _offset[0]; offset[1] = _offset[1];
130  }
131 #else // VT_ETIMESYNC
132  UnifyControlS()
133  : streamid( 0 ), pstreamid( 0 ), stream_avail( true ), sync_offset( 0 ),
134  sync_drift( 0.0 )
135  {
136  ltime[0] = ltime[1] = offset[0] = offset[1] = 0;
137  }
138 
139  UnifyControlS( const uint32_t & _streamid, const uint32_t & _pstreamid,
140  const bool & _stream_avail, const int64_t * _ltime,
141  const int64_t * _offset,
142  const std::vector<ETimeSyncC::SyncPhaseS> & _sync_phases,
143  const std::vector<ETimeSyncC::SyncTimeS> & _sync_times,
144  const std::vector<std::pair<uint32_t, uint32_t> > & _sync_pairs)
145  : streamid( _streamid ), pstreamid( _pstreamid ),
146  stream_avail( _stream_avail ), sync_offset( 0 ), sync_drift( 1.0 ),
147  sync_phases( _sync_phases ), sync_times( _sync_times ),
148  sync_pairs( _sync_pairs )
149  {
150  ltime[0] = _ltime[0]; ltime[1] = _ltime[1];
151  offset[0] = _offset[0]; offset[1] = _offset[1];
152  }
153 #endif // VT_ETIMESYNC
154 
155  uint32_t streamid; // id of input stream
156  uint32_t pstreamid; // id of parent input stream
157  bool stream_avail; // is stream available?
158 
159  // time sync. information
160  //
161  int64_t ltime[2]; // local times ...
162  int64_t offset[2]; // ... and chronological offsets to global time
163 #ifdef VT_ETIMESYNC
164  uint64_t sync_offset;
165  double sync_drift;
166  std::vector<ETimeSyncC::SyncPhaseS> sync_phases;
167  std::vector<ETimeSyncC::SyncTimeS> sync_times;
168  std::vector<std::pair<uint32_t, uint32_t> > sync_pairs;
169 #endif // VT_ETIMESYNC
170 
171 };
172 
173 // print verbose message
174 void VPrint( uint8_t level, const char * fmt, ... );
175 
176 // print verbose message in a parallel region
177 void PVPrint( uint8_t level, const char * fmt, ... );
178 
179 // synchronize error indicator between all ranks
180 bool SyncError( bool * error );
181 
182 // global variables
183 //
184 
185 // name of program's executable
186 extern const std::string ExeName;
187 
188 // temporary output file suffix
189 extern const std::string TmpFileSuffix;
190 
191 // output file prefix which used if local input files shall be kept
192 extern const std::string UniFilePrefix;
193 
194 // unify parameters
195 extern ParamsS Params;
196 
197 // vector of unify controls
198 extern std::vector<UnifyControlS*> UnifyCtls;
199 
200 // map stream id <-> unify control
201 extern std::map<uint32_t, UnifyControlS*> StreamId2UnifyCtl;
202 
203 // vector of stream ids to process by my rank
204 extern std::vector<uint32_t> MyStreamIds;
205 
206 #ifdef VT_MPI
207  // number of MPI-ranks
208  extern VT_MPI_INT NumRanks;
209 
210  // MPI-rank of calling process
211  extern VT_MPI_INT MyRank;
212 
213  // map stream id <-> processing MPI-rank
214  extern std::map<uint32_t, VT_MPI_INT> StreamId2Rank;
215 
216  // map MPI-rank <-> stream ids
217  extern std::map<VT_MPI_INT, std::set<uint32_t> > Rank2StreamIds;
218 #endif // VT_MPI
219 
220 #endif // _VT_UNIFY_H_
Definition: datastructs.h:41
Definition: vt_dyn.h:53
Definition: vt_unify.h:113