Instrumenting ampi (only send and recv)
[charm.git] / src / conv-perf / traceCoreCommon.C
1
2 #include "traceCore.h"
3 #include "traceCoreCommon.h"
4 #include "charmProjections.h"
5 #include "ampiProjections.h"
6 #include "converse.h"
7
8
9 /* Trace Module Constants (Default Values) */
10 #define TRACE_CORE_BUFFER_SIZE 10
11
12 /* Trace Storage and associated Structure */
13 CpvDeclare(int, _traceCoreOn);
14 CpvDeclare(double, _traceCoreInitTime);
15 CpvDeclare(char*, _traceCoreRoot);
16 CpvDeclare(int, _traceCoreBufferSize);
17 CpvDeclare(TraceCore*, _traceCore);
18
19 /* Trace Timer */
20 #define  TRACE_CORE_TIMER   CmiWallTimer
21 inline double TraceCoreTimer() { return TRACE_CORE_TIMER() - CpvAccess(_traceCoreInitTime); }
22
23 /*****************************************************************/
24 /* Tracing API 
25  * Implementation of functions declared in traceCoreCommon.h 
26  *****************************************************************/
27 /* Initialize TraceCore Module */
28 //TODO decide parameters from command line
29 //TODO - trace-common.C
30 extern "C" void initTraceCore(char** argv)
31 {
32   /*CpvInitialize(int, _traceCoreOn);
33         CpvAccess(_traceCoreOn) = 0;*/
34
35   CpvInitialize(char*, _traceCoreRoot);
36         CpvAccess(_traceCoreRoot) = (char *) malloc(strlen(argv[0])+1);
37         _MEMCHECK(CpvAccess(_traceCoreRoot));
38         strcpy(CpvAccess(_traceCoreRoot), argv[0]);
39
40   CpvInitialize(int, _traceCoreBufferSize);
41         CpvAccess(_traceCoreBufferSize) = TRACE_CORE_BUFFER_SIZE;
42
43   CpvInitialize(double, _traceCoreInitTime);
44         CpvAccess(_traceCoreInitTime) = TRACE_CORE_TIMER();
45
46   CpvInitialize(TraceCore*, _traceCore);
47         CpvAccess(_traceCore) = new TraceCore(argv);
48   initCharmProjections();
49   initAmpiProjections();
50 }
51
52 /* End Core Trace Module */
53 //TODO - trace-common.C
54 extern "C" void closeTraceCore() {
55         closeAmpiProjections();
56         delete CpvAccess(_traceCore);
57 }
58
59 /* Resume Core Trace Module */
60 //TODO - trace-common.C
61 extern "C" void resumeTraceCore() {}
62
63 /* Suspend Core Trace Module */
64 //TODO - trace-common.C
65 extern "C" void suspendTraceCore() {}
66
67 /*Install the beginIdle/endIdle condition handlers.*/
68 //TODO - trace-common.C
69 extern "C" void beginTraceCore(void) {}
70
71 /*Cancel the beginIdle/endIdle condition handlers.*/
72 //TODO - trace-common.C
73 extern "C" void endTraceCore(void) {}
74
75 /*****************************************************************/
76 /* Tracing API 
77  * Implementation of functions declared in traceCoreAPI.h 
78  *****************************************************************/
79 extern "C" void RegisterLanguage(int lID, char* ln)
80 { CpvAccess(_traceCore)->RegisterLanguage(lID, ln); }
81
82 extern "C" void RegisterEvent(int lID, int eID)
83 { CpvAccess(_traceCore)->RegisterEvent(lID, eID); }
84
85 extern "C" void LogEvent(int lID, int eID)
86 { CpvAccess(_traceCore)->LogEvent(lID, eID); }
87
88 extern "C" void LogEvent1(int lID, int eID, int iLen, int* iData)
89 { CpvAccess(_traceCore)->LogEvent(lID, eID, iLen, iData); }
90
91 extern "C" void LogEvent2(int lID, int eID, int sLen, char* sData)
92 { CpvAccess(_traceCore)->LogEvent(lID, eID, sLen, sData); }
93
94 extern "C" void LogEvent3(int lID, int eID, int iLen, int* iData, int sLen, char* sData)
95 { CpvAccess(_traceCore)->LogEvent(lID, eID, iLen, iData, sLen, sData); }
96
97 extern "C" void LogEvent4(int lID, int eID, int iLen, int* iData, double t)
98 { CpvAccess(_traceCore)->LogEvent(lID, eID, iLen, iData,t); }
99