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