add API to pass application annotation time to tracing framework
[charm.git] / src / conv-core / conv-trace.h
1 #ifndef _CONV_TRACE_H
2 #define _CONV_TRACE_H
3
4 #include "converse.h"
5
6 /* 
7  * These functions are called from Converse, and should be provided C binding
8  * by the tracing strategies.
9  */
10
11 void traceInit(char **argv);
12 void traceCharmInit(char **argv);       /* init trace module in ck */
13 void traceMessageRecv(char *msg, int pe);
14 void traceBeginIdle(void);
15 void traceEndIdle(void);
16 void traceResume(CmiObjId *);
17 void traceSuspend(void);
18 void traceAwaken(CthThread t);
19 void traceUserEvent(int);
20 void traceStartUsefulWork();
21 void traceStopUsefulWork();
22 void traceUserBracketEvent(int, double, double);
23 void traceUserSuppliedData(int);
24 void traceUserSuppliedBracketedNote(char *note, int eventID, double bt, double et);
25 void traceUserSuppliedNote(char*);
26 void traceMemoryUsage();
27 int  traceRegisterUserEvent(const char*, int e
28 #ifdef __cplusplus
29 =-1
30 #endif
31 );
32
33 #if CMK_SMP_TRACE_COMMTHREAD
34 int  traceBeginCommOp(char *msg);
35 void traceEndCommOp(char *msg);
36 void traceSendMsgComm(char *msg);
37 void traceCommSetMsgID(char *msg);
38 #endif
39 void traceChangeLastTimestamp(double ts);
40 void traceGetMsgID(char *msg, int *pe, int *event);
41 void traceSetMsgID(char *msg, int pe, int event);
42
43 /* Support for machine layers to register their user events to projections */
44 void registerMachineUserEventsFunction(void (*eventRegistrationFunc)());
45
46 int traceRegisterFunction(const char*, int idx
47 #ifdef __cplusplus
48 =-999
49 #endif
50 );
51 void traceBeginFuncIndexProj(int, char* file, int);
52 void traceEndFuncIndexProj(int);
53
54 void traceClose(void);
55 void traceCharmClose(void);          /* close trace in ck */
56 void traceBegin(void);
57 void traceEnd(void);
58 void traceWriteSts(void);
59 void traceFlushLog(void);
60
61 #if CMK_TRACE_ENABLED
62 CpvExtern(int, traceOn);
63 #define traceIsOn()  (CpvAccess(traceOn))
64 #else 
65 #define traceIsOn()  0
66 #endif
67
68 int  traceAvailable();
69
70 /* Comm thread tracing */
71 #if CMK_SMP_TRACE_COMMTHREAD
72 #define  TRACE_COMM_CREATION(time, msg)   \
73                     if (traceBeginCommOp(msg)) {   \
74                       traceChangeLastTimestamp(time);    \
75                       traceSendMsgComm(msg);   \
76                       traceEndCommOp(msg);    \
77                     }
78
79 #define  TRACE_COMM_CONTROL_CREATION(time0, time1, time2, msg)   \
80                     if (traceBeginCommOp(msg)) {   \
81                       traceChangeLastTimestamp(time0);    \
82                       traceSendMsgComm(msg);   \
83                       traceChangeLastTimestamp(time1);    \
84                       traceEndCommOp(msg);    \
85                       traceChangeLastTimestamp(time2);    \
86                     }
87
88 #define TRACE_COMM_SET_MSGID(msg, pe, event)  traceSetMsgID(msg, pe, event)
89 #define TRACE_COMM_GET_MSGID(msg, pe, event)  traceGetMsgID(msg, pe, event)
90 #define TRACE_COMM_SET_COMM_MSGID(msg)  traceCommSetMsgID(msg)
91 #else
92 #define TRACE_COMM_CREATION(time, msg)
93 #define TRACE_COMM_CONTROL_CREATION(time0, time1, time2, msg)
94 #define TRACE_COMM_SET_MSGID(msg, pe, event) 
95 #define TRACE_COMM_GET_MSGID(msg, pe, event) 
96 #define TRACE_COMM_SET_COMM_MSGID(msg)
97 #endif
98
99 #endif