Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab_mpe.h
Go to the documentation of this file.
1 #ifndef MOAB_MPE_H
2 #define MOAB_MPE_H
3 
4 #include "moab/MOABConfig.h"
5 #ifdef MOAB_HAVE_LIBMPE
6 #include "moab_mpi.h"
7 #include "mpe.h"
8 #else
9 
10 /* Define dummy logging functions */
11 
12 /* mpe_misc.h */
13 
14 #define MPE_Seq_begin( A, B ) \
15  { \
16  if( ( A ) || ( B ) ) \
17  { \
18  } \
19  }
20 
21 #define MPE_Seq_end( A, B ) \
22  { \
23  if( ( A ) || ( B ) ) \
24  { \
25  } \
26  }
27 
28 #define MPE_DelTag( A, B, C, D ) \
29  ( \
30  { \
31  if( ( A ) || ( B ) || ( C ) || ( D ) ) \
32  { \
33  } \
34  }, \
35  MPI_SUCCESS )
36 #define MPE_GetTags( A, B, C, D ) ( ( A ) = *( C ), *( D ) = 0, if( B ){}, MPI_SUCCESS )
37 #define MPE_ReturnTags( A, B, C ) \
38  ( \
39  { \
40  if( ( A ) || ( B ) || ( C ) ) \
41  { \
42  } \
43  }, \
44  0 )
45 #define MPE_TagsEnd() ( MPI_SUCCESS )
46 
47 #define MPE_IO_Stdout_to_file( A, B ) \
48  { \
49  if( ( A ) || ( B ) ) \
50  { \
51  } \
52  }
53 
54 #define MPE_GetHostName( A, B ) \
55  { \
56  if( ( A ) || ( B ) ) \
57  { \
58  } \
59  }
60 
61 #define MPI_Start_debugger()
62 
63 /*
64 #if (defined(__STDC__) || defined(__cplusplus))
65 #define MPE_Errors_to_dbx ( MPI_Comm *, int *, ... );
66 #else
67 void MPE_Errors_to_dbx ( MPI_Comm *, int *, char *, char *, int * );
68 #endif
69 void MPE_Errors_call_debugger ( char *, char *, char ** );
70 void MPE_Errors_call_xdbx ( char *, char * );
71 void MPE_Errors_call_dbx_in_xterm ( char *, char * );
72 void MPE_Signals_call_debugger ( void );
73 
74 int MPE_Decomp1d ( int, int, int, int *, int * );
75 
76 void MPE_Comm_global_rank ( MPI_Comm, int, int * );
77 */
78 
79 /* mpe_log.h */
80 
81 #define MPE_LOG_OK 0
82 #define MPE_Log_OK MPE_LOG_OK
83 /* no problems */
84 #define MPE_LOG_LOCKED_OUT 1
85 #define MPE_Log_LOCKED_OUT MPE_LOG_LOCKED_OUT
86 /* logs are being worked on, cannot insert any new entries */
87 #define MPE_LOG_NO_MEMORY 2
88 #define MPE_Log_NO_MEMORY MPE_LOG_NO_MEMORY
89 /* could not allocate memory for logging data */
90 #define MPE_LOG_FILE_PROB 3
91 #define MPE_Log_FILE_PROB MPE_LOG_FILE_PROB
92 /* cound not open file for writing out the logged info */
93 #define MPE_LOG_NOT_INITIALIZED 4
94 #define MPE_Log_NOT_INITIALIZED MPE_LOG_NOT_INITIALIZED
95 /* logging not initialized */
96 #define MPE_LOG_PACK_FAIL 5
97 #define MPE_Log_PACK_FAIL MPE_LOG_PACK_FAIL
98 
99 #define MPE_Init_log() ( MPI_SUCCESS )
100 #define MPE_Initialized_logging() 1
101 
102 #define MPE_Describe_state( A, B, C, D ) \
103  { \
104  if( ( A ) || ( B ) || ( C ) || ( D ) ) \
105  { \
106  } \
107  }
108 #define MPE_Describe_event( A, B, C ) \
109  { \
110  if( ( A ) || ( B ) || ( C ) ) \
111  { \
112  } \
113  }
114 #define MPE_Log_get_event_number()
115 #define MPE_Log_send( A, B, C ) \
116  { \
117  if( ( A ) || ( B ) || ( C ) ) \
118  { \
119  } \
120  }
121 #define MPE_Log_receive( A, B, C ) \
122  { \
123  if( ( A ) || ( B ) || ( C ) ) \
124  { \
125  } \
126  }
127 #define MPE_Log_event( A, B, C ) \
128  { \
129  if( ( A ) || ( B ) || ( C ) ) \
130  { \
131  } \
132  }
133 #define MPE_Start_log()
134 #define MPE_Stop_log()
135 #define MPE_Finish_log( A ) \
136  { \
137  if( A ) \
138  { \
139  } \
140  }
141 
142 #endif
143 
144 #ifdef __cplusplus
145 
146 namespace moab
147 {
148 
149 class MPEState
150 {
151  private:
152  int sid, eid;
153  bool ok;
154 
155  public:
156  MPEState( const char* name, const char* color = 0 )
157  : sid( MPE_Log_get_event_number() ), eid( MPE_Log_get_event_number() ), ok( true )
158  {
159  MPE_Describe_state( sid, eid, name, color ? color : "yellow" );
160  }
161 
162  MPEState() : ok( false ) {}
163  bool valid() const
164  {
165  return ok;
166  }
167 
168  void start( int data = 0, const char* str = 0 )
169  {
170  MPE_Log_event( sid, data, str );
171  }
172  void start( const char* str, int data = 0 )
173  {
174  MPE_Log_event( sid, data, str );
175  }
176  void start( const char* str, const char* str2 )
177  {
178  MPE_Log_event( sid, 0, ( std::string( str ).append( str2 ) ).c_str() );
179  }
180  void end( int data = 0, const char* str = 0 )
181  {
182  MPE_Log_event( eid, data, str );
183  }
184  void end( const char* str, int data = 0 )
185  {
186  MPE_Log_event( eid, data, str );
187  }
188 };
189 
190 class MPEEvent
191 {
192  private:
193  int id;
194 
195  public:
196  MPEEvent( const char* name, const char* color = 0 ) : id( MPE_Log_get_event_number() )
197  {
198  MPE_Describe_event( id, name, color ? color : "red" );
199  }
200  void log( int data = 0, const char* str = 0 )
201  {
202  MPE_Log_event( id, data, str );
203  }
204  void log( const char* str, int data = 0 )
205  {
206  MPE_Log_event( id, data, str );
207  }
208 };
209 
210 } /* namespace moab */
211 
212 #endif /* __cplusplus */
213 
214 #endif /* MOAB_MPE_H */