00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __HPCXX_PROFILE_H_
00036 #define __HPCXX_PROFILE_H_
00037
00038
00039 #define HPCXX_MAX_COUNTERS 256
00040 #define HPCXX_MAX_PROFILE_EVENTS HPCXX_MAX_COUNTERS
00041 #define HPCXX_MAX_COUNTER_STRING 8*HPCXX_MAX_COUNTERS
00042
00043
00044
00045
00046
00047
00048 #define HPCXX_PROFILE_Wait_HPCxx_Cond 0
00049 #define HPCXX_PROFILE_Signal_HPCxx_Cond 1
00050 #define HPCXX_PROFILE_Broadcast_HPCxx_Cond 2
00051
00052
00053 #define HPCXX_PROFILE_Read_HPCxx_GlobalPtr 3
00054 #define HPCXX_PROFILE_Write_HPCxx_GlobalPtr 4
00055
00056
00057 #define HPCXX_PROFILE_Write_HPCxx_SyncQ 5
00058 #define HPCXX_PROFILE_Read_HPCxx_SyncQ 6
00059 #define HPCXX_PROFILE_WaitAndCopy_HPCxx_SyncQ 7
00060
00061
00062 #define HPCXX_PROFILE_Create_HPCxx_Thread 8
00063 #define HPCXX_PROFILE_Suspend_HPCxx_Thread 9
00064 #define HPCXX_PROFILE_Resume_HPCxx_Thread 10
00065 #define HPCXX_PROFILE_Join_HPCxx_Thread 11
00066
00067
00068
00069
00070
00071 #define HPCXX_PROFILE_Increment_HPCxx_CSem 12
00072 #define HPCXX_PROFILE_Wait_HPCxx_CSem 13
00073
00074
00075 #define HPCXX_PROFILE_Write_HPCxx_Sync 14
00076 #define HPCXX_PROFILE_Read_HPCxx_Sync 15
00077
00078
00079 #define HPCXX_PROFILE_Lock_HPCxx_Mutex 16
00080 #define HPCXX_PROFILE_Unlock_HPCxx_Mutex 17
00081
00082 class HPCxx_Thread;
00083 class HPCxx_Runnable;
00084 class HPCxx_Group;
00085
00086 #ifdef PROFILING_ON
00087
00088 #ifndef PARSE_ONLY
00089 #include <map.h>
00090 #include <vector.h>
00091 #include <deque.h>
00092 #include <stack.h>
00093 #endif
00094
00095 #ifdef __cplusplus
00096 extern "C" {
00097 #endif
00098
00099
00100
00101
00102
00103
00104 void hpcxx_ProfileInit(HPCxx_Group *g);
00105 void hpcxx_ProfileThreadInit(HPCxx_Group *g);
00106 void hpcxx_ProfileExit();
00107 void hpcxx_ProfileExitThread();
00108 void hpcxx_ProfileDecrChildren();
00109 void hpcxx_ProfileWaitChildren();
00110 int tid();
00111
00112
00113
00114 int hpcxx_ProfileIsFunctionTopLevel(const int &, const int &);
00115 void hpcxx_ProfileSetNumberOfFunc( const int& );
00116
00117 void hpcxx_ProfileSetCurrentNodeId(const int& nid);
00118 void hpcxx_ProfileSetCurrentContextId(const int& cid);
00119 int hpcxx_ProfileThisNode();
00120 int hpcxx_ProfileThisContext();
00121
00122
00123 int hpcxx_ProfileGetEventCounter(void);
00124 int hpcxx_ProfileShowEventTable(void);
00125
00126 int hpcxx_ProfileObjectInit(void);
00127 int hpcxx_ProfileDumpObjectEventNames();
00128
00129
00130 int hpcxx_ProfileRegisterEvent(int eventid, char *event_name);
00131 void hpcxx_ProfileIncrementCounter(void *addr,int counter_id);
00132
00133
00134 void hpcxx_ProfileCollNames(char *coll, char *elem,
00135 char *var, void *var_addr);
00136 void hpcxx_ProfileCollAttr(void *var_addr, int no_of_elements,
00137 int dimension, int size_of_aggregate);
00138
00139
00140
00141
00142
00143
00144 inline char* strnew(const char* str) {
00145 char* newstr = 0;
00146 if (str) {
00147 newstr = new char[strlen(str) + 1];
00148 strcpy(newstr, str);
00149 }
00150 return newstr;
00151 }
00152
00153 struct lptr
00154 {
00155 bool operator()(void* s1, void* s2) const
00156 {
00157 return s1 < s2;
00158 }
00159 };
00160
00161 typedef struct hpcxx_ProfileFuncDescr {
00162 int numcalls;
00163 double usec;
00164 double cumusec;
00165 } hpcxx_ProfileFuncDescr;
00166
00167 typedef struct hpcxx_CurrentFuncInfo {
00168 int parentFunction;
00169 int myId;
00170 double start;
00171 } hpcxx_CurrentFuncInfo;
00172
00173 #ifdef __cplusplus
00174 }
00175 #endif
00176
00177
00178 class HPCxx_ProfileVarInfo
00179 {
00180 public:
00181 char *containerName;
00182 char *containerType;
00183 char *varName;
00184
00185 int numelems ;
00186 int dim ;
00187 int size ;
00188 long counters[HPCXX_MAX_COUNTERS];
00189 nexus_mutex_t counterLocks[HPCXX_MAX_COUNTERS];
00190
00191 HPCxx_ProfileVarInfo();
00192 HPCxx_ProfileVarInfo(const char *cname, const char *ctype, const char *vname);
00193 void incrementCounter(int counter_id);
00194 void registerAttributes(int no_of_elements, int dimension, int size_of_aggregate);
00195 const HPCxx_ProfileVarInfo& operator = ( const HPCxx_ProfileVarInfo& t) ;
00196 };
00197
00198
00199
00200
00201 class HPCxx_ThProfiler {
00202
00203
00204 #ifndef PARSE_ONLY
00205 map<void*, HPCxx_ProfileVarInfo, lptr>* contNameDb_;
00206 #endif
00207
00208 int parentTh_;
00209 int id_;
00210
00211 void checkFunctionList_();
00212 public:
00213 hpcxx_ProfileFuncDescr *pFuncList_;
00214 stack<hpcxx_CurrentFuncInfo, vector<hpcxx_CurrentFuncInfo> > funcStack;
00215 int currentFunc;
00216
00217 HPCxx_ThProfiler() {};
00218 HPCxx_ThProfiler( int );
00219 HPCxx_ThProfiler(const char* p);
00220 ~HPCxx_ThProfiler() {};
00221
00222 const HPCxx_ThProfiler& operator = ( const HPCxx_ThProfiler& );
00223
00224 int getThreadId();
00225 int getParentId();
00226
00227 void initFunctionList(const int&);
00228 void exitFunctionProfiling(const double&);
00229 void dumpInformationProfiling();
00230 void setFunctionTime(const int& , const double&);
00231 void incrFunctionCalls(const int&);
00232 void updateFunctions(const int& , const double&);
00233 void setStartTime(const int& , const double &);
00234
00235 int getNumberOfCollections();
00236 void collNames( char *, char *, char *, void *);
00237 void collAttr(void *, int, int, int);
00238 void incrementAggregateCounter(void *,int );
00239 };
00240
00241 class HPCxx_FuncProfiler {
00242 int ident_;
00243 int nf_;
00244 double start_;
00245
00246 public:
00247 HPCxx_FuncProfiler(int id);
00248 HPCxx_FuncProfiler(int id, int num);
00249 HPCxx_FuncProfiler(int id, char countonly);
00250 HPCxx_FuncProfiler(int id, int num , char countonly);
00251 ~HPCxx_FuncProfiler() ;
00252
00253 };
00254
00255
00256 #else
00257
00258 # define hpcxx_ProfileInit(g)
00259 # define hpcxx_ProfileThreadInit(g)
00260 # define hpcxx_ProfileExit()
00261 # define hpcxx_ProfileExitThread()
00262 # define hpcxx_ProfileDecrChildren()
00263 # define hpcxx_ProfileWaitChildren()
00264 # define tid()
00265 # define hpcxx_ProfileIsFunctionTopLevel(thread_id, function_id)
00266 # define hpcxx_ProfileSetNumberOfFunc(fn)
00267
00268
00269 # define hpcxx_ProfileSetCurrentNodeId(nid)
00270 # define hpcxx_ProfileSetCurrentContextId(cid)
00271 # define hpcxx_ProfileThisNode()
00272 # define hpcxx_ProfileThisContext()
00273 # define hpcxx_ProfileGetEventCounter()
00274 # define hpcxx_ProfileShowEventTable()
00275 # define hpcxx_ProfileObjectInit()
00276 # define hpcxx_ProfileInitNrOfSysEvents()
00277 # define hpcxx_ProfileDumpObjectEventNames()
00278 # define hpcxx_ProfileRegisterEvent(eventid,event_name)
00279 # define hpcxx_ProfileIncrementCounter(addr,counter_id)
00280 # define hpcxx_ProfileCollNames(coll,elem,var,var_addr)
00281 # define hpcxx_ProfileCollAttr(var_addr,no_of_elements,dimension,size_of_aggregate)
00282
00283
00284 class HPCxx_FuncProfiler {
00285 int ident_;
00286 int nf_;
00287 double start_;
00288
00289 public:
00290 HPCxx_FuncProfiler(int id) {};
00291 HPCxx_FuncProfiler(int id, int num) {};
00292 HPCxx_FuncProfiler(int id, char countonly) {};
00293 HPCxx_FuncProfiler(int id, int num , char countonly ) {};
00294 ~HPCxx_FuncProfiler() {};
00295 };
00296
00297 class HPCxx_ThProfiler {
00298 public:
00299 HPCxx_ThProfiler() {};
00300 HPCxx_ThProfiler( int ) {};
00301 HPCxx_ThProfiler(const char* p) {};
00302 ~HPCxx_ThProfiler() {};
00303 };
00304
00305
00306 #endif
00307
00308
00309 #endif
00310
00311
00312
00313
00314
00315
00316
00317