00001
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 #include "converse.h"
00005 #include "charmProjections.h"
00006 #include "traceCoreCommon.h"
00007 #include "charmEvents.h"
00008 #include "ck.h"
00009 #include "trace-common.h"
00010
00011 #if CMK_TRACE_ENABLED
00012 CtvStaticDeclare(int,curThreadEvent);
00013
00014 static int curEvent;
00015 static int execEvent;
00016 static int execEp;
00017 static int execPe;
00018 static int curevent=0;
00019 #endif
00020
00021 void initCharmProjections()
00022 {
00023 #if CMK_TRACE_ENABLED
00024 CtvInitialize(int,curThreadEvent);
00025 CtvAccess(curThreadEvent) = 0;
00026 curEvent = 0;
00027 #endif
00028 }
00029
00030
00031
00032
00033
00034 void charm_creation(envelope *e, int ep, int num)
00035 {
00036 #if CMK_TRACE_ENABLED
00037 if(e==0) {
00038 CtvAccess(curThreadEvent)=curEvent;
00039 int iData[4];
00040 iData[0] = ForChareMsg;
00041 iData[1] = ep;
00042 iData[2] = curEvent++;
00043 iData[3] = CkMyPe();
00044 LogEvent1(_CHARM_LANG_ID, _E_CREATION, 4, iData);
00045 } else {
00046 e->setEvent(curEvent);
00047 for(int i=0; i<num; i++) {
00048 int iData[5];
00049 iData[0] = e->getMsgtype();
00050 iData[1] = ep;
00051 iData[2] = curEvent+i;
00052 iData[3] = CkMyPe();
00053 iData[4] = e->getTotalsize();
00054 LogEvent1(_CHARM_LANG_ID, _E_CREATION, 5, iData);
00055 }
00056 curEvent += num;
00057 }
00058 #endif
00059 }
00060
00061 void charm_beginExecute(envelope *e)
00062 {
00063 #if CMK_TRACE_ENABLED
00064 if(e==0) {
00065 execEvent = CtvAccess(curThreadEvent);
00066 execEp = (-1);
00067 int iData[4];
00068 iData[0] = ForChareMsg;
00069 iData[1] = _threadEP;
00070 iData[2] = execEvent;
00071 iData[3] = CkMyPe();
00072 LogEvent1(_CHARM_LANG_ID, _E_BEGIN_PROCESSING, 4, iData);
00073 } else {
00074 charm_beginExecuteDetailed(e->getEvent(),e->getMsgtype(),e->getEpIdx(),e->getSrcPe(),e->getTotalsize());
00075 }
00076 #endif
00077 }
00078
00079 void charm_beginExecuteDetailed(int event,int msgType,int ep,int srcPe,int ml)
00080 {
00081 #if CMK_TRACE_ENABLED
00082 execEvent=event;
00083 execEp=ep;
00084 execPe=srcPe;
00085 int iData[5];
00086 iData[0] = msgType;
00087 iData[1] = ep;
00088 iData[2] = event;
00089 iData[3] = srcPe;
00090 iData[4] = ml;
00091
00092 LogEvent1(_CHARM_LANG_ID, _E_BEGIN_PROCESSING, 5, iData);
00093 #endif
00094 }
00095
00096 void charm_endExecute(void)
00097 {
00098 #if CMK_TRACE_ENABLED
00099 if(execEp == (-1)) {
00100 int iData[4];
00101 iData[0] = 0;
00102 iData[1] = _threadEP;
00103 iData[2] = execEvent;
00104 iData[3] = CkMyPe();
00105 LogEvent1(_CHARM_LANG_ID, _E_END_PROCESSING, 4, iData);
00106 } else {
00107 int iData[4];
00108 iData[0] = 0;
00109 iData[1] = execEp;
00110 iData[2] = execEvent;
00111 iData[3] = execPe;
00112 LogEvent1(_CHARM_LANG_ID, _E_END_PROCESSING, 4, iData);
00113 }
00114 #endif
00115 }
00116
00117
00118
00119
00120 void charm_enqueueMsg(envelope *e) {
00121 #if CMK_TRACE_ENABLED
00122 int iData[3];
00123 iData[0] = e->getMsgtype();
00124 iData[1] = e->getEvent();
00125 iData[2] = e->getSrcPe();
00126 LogEvent1(_CHARM_LANG_ID,_E_ENQUEUE,3,iData);
00127 #endif
00128 }
00129
00130 void charm_dequeueMsg(envelope *e) {
00131 #if CMK_TRACE_ENABLED
00132 int iData[3];
00133 iData[0] = e->getMsgtype();
00134 iData[1] = e->getEvent();
00135 iData[2] = e->getSrcPe();
00136 LogEvent1(_CHARM_LANG_ID,_E_DEQUEUE,3,iData);
00137 #endif
00138 }
00139
00140 void charm_beginComputation(void)
00141 {
00142 #if CMK_TRACE_ENABLED
00143 LogEvent1(_CHARM_LANG_ID, _E_BEGIN_COMPUTATION, 0, NULL);
00144 #endif
00145 }
00146
00147 void charm_endComputation(void)
00148 {
00149 #if CMK_TRACE_ENABLED
00150 LogEvent1(_CHARM_LANG_ID, _E_END_COMPUTATION, 0, NULL);
00151 #endif
00152 }
00153
00154 void charm_messageRecv(char *env, int pe) {}
00155
00156 void charm_userEvent(int e) {
00157 #if CMK_TRACE_ENABLED
00158 int iData[3];
00159 iData[0] = e;
00160 iData[1] = curevent;
00161 iData[2] = CkMyPe();
00162 curevent++;
00163 LogEvent1(_CHARM_LANG_ID, _E_USER_EVENT_CHARM,3,iData);
00164 #endif
00165 }
00166
00167
00168 void charm_userPairEvent(int e,double bt,double et){
00169 #if CMK_TRACE_ENABLED
00170 int iData1[3];
00171 int iData2[3];
00172 iData1[0] = iData2[0] = e;
00173 iData1[1] = iData2[1] = curevent;
00174 iData1[2] = iData2[2] = CkMyPe();
00175 curevent++;
00176 LogEvent4(_CHARM_LANG_ID, _E_USER_EVENT_PAIR,3,iData1,bt);
00177 LogEvent4(_CHARM_LANG_ID, _E_USER_EVENT_PAIR,3,iData2,et);
00178
00179 #endif
00180 }
00181
00182 void charm_beginPack(void)
00183 {
00184 #if CMK_TRACE_ENABLED
00185 int iData[1];
00186 iData[0] = CkMyPe();
00187 LogEvent1(_CHARM_LANG_ID, _E_BEGIN_PACK, 1, iData);
00188 #endif
00189 }
00190
00191 void charm_endPack(void)
00192 {
00193 #if CMK_TRACE_ENABLED
00194 int iData[1];
00195 iData[0] = CkMyPe();
00196 LogEvent1(_CHARM_LANG_ID, _E_END_PACK, 1, iData);
00197 #endif
00198 }
00199
00200 void charm_beginUnpack(void)
00201 {
00202 #if CMK_TRACE_ENABLED
00203 int iData[1];
00204 iData[0] = CkMyPe();
00205 LogEvent1(_CHARM_LANG_ID, _E_BEGIN_UNPACK, 1, iData);
00206 #endif
00207 }
00208
00209 void charm_endUnpack(void)
00210 {
00211 #if CMK_TRACE_ENABLED
00212 int iData[1];
00213 iData[0] = CkMyPe();
00214 LogEvent1(_CHARM_LANG_ID, _E_END_UNPACK, 1, iData);
00215 #endif
00216 }
00217
00218