Instrumenting ampi (only send and recv)
authorSayantan Chakravorty <sayantan_chak@yahoo.com>
Mon, 6 Jan 2003 04:07:05 +0000 (04:07 +0000)
committerSayantan Chakravorty <sayantan_chak@yahoo.com>
Mon, 6 Jan 2003 04:07:05 +0000 (04:07 +0000)
src/conv-perf/allEvents.h
src/conv-perf/ampiEvents.h [new file with mode: 0644]
src/conv-perf/ampiProjections.C [new file with mode: 0644]
src/conv-perf/ampiProjections.h [new file with mode: 0644]
src/conv-perf/traceCore.C
src/conv-perf/traceCoreCommon.C

index e06d64c96c0eefc6d185640a86d760c351a62e20..a7fe68d62dc485b3498a67688f14c9e2f46704e2 100644 (file)
@@ -7,9 +7,11 @@
 #include "charmEvents.h"
 #include "converseEvents.h"
 #include "machineEvents.h"
+#include "ampiEvents.h"
 #include "charmProjections.h"
 #include "converseProjections.h"
 #include "machineProjections.h"
+#include "ampiProjections.h"
 #include "traceCoreAPI.h"     
 #include "traceCore.h"
 #include "charmEvents.h"
diff --git a/src/conv-perf/ampiEvents.h b/src/conv-perf/ampiEvents.h
new file mode 100644 (file)
index 0000000..a5533c9
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef __AMPI_EVENTS_H__
+#define __AMPI_EVENTS_H__
+
+#include "traceCoreAPI.h"
+#include "ampiProjections.h"
+
+#define _AMPI_LANG_ID  4 /*language id for ampi*/
+
+/* event IDs */
+#define _E_BEGIN_AMPI_PROCESSING 25
+#define _E_END_AMPI_PROCESSING  26
+#define _E_AMPI_MSG_SEND        27
+
+/* Registering Macro */
+#define REGISTER_AMPI \
+       { RegisterLanguage(_AMPI_LANG_ID, "ampi\0"); \
+         RegisterEvent(_AMPI_LANG_ID, _E_BEGIN_AMPI_PROCESSING); \
+         RegisterEvent(_AMPI_LANG_ID, _E_END_AMPI_PROCESSING); \
+         RegisterEvent(_AMPI_LANG_ID,_E_AMPI_MSG_SEND); \
+         \
+       }
+#define _LOG_E_BEGIN_AMPI_PROCESSING(tag,src,count) { ampi_beginProcessing(tag,src,count);}
+#define _LOG_E_END_AMPI_PROCESSING()               { ampi_endProcessing();}
+#define _LOG_E_AMPI_MSG_SEND(tag,dest,count,size)   { ampi_msgSend(tag,dest,count,size);}
+#endif
diff --git a/src/conv-perf/ampiProjections.C b/src/conv-perf/ampiProjections.C
new file mode 100644 (file)
index 0000000..0c3bccf
--- /dev/null
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "converse.h"
+#include "ampiProjections.h"
+#include "traceCoreCommon.h"
+#include "ampiEvents.h"
+#include "ck.h"
+
+static int current_tag  = -1;
+static int current_src = -1;
+static int current_count = -1;
+
+extern "C" void initAmpiProjections(){
+       ampi_beginProcessing(current_tag,current_src,current_count);
+}
+
+extern "C" void closeAmpiProjections(){        
+       ampi_endProcessing();
+}
+
+extern "C" void ampi_beginProcessing(int tag,int src,int count){
+       int *iData = (int *)malloc(sizeof(int)*3);
+       iData[0] = tag;
+       iData[1] = src;
+       iData[2] = count;
+       current_tag = tag;
+       current_src = src;
+       current_count = count;
+       LogEvent1(_AMPI_LANG_ID,_E_BEGIN_AMPI_PROCESSING,3,iData);
+}
+
+extern "C" void ampi_endProcessing(){
+       int *iData = (int *)malloc(sizeof(int)*3);
+       iData[0] = current_tag;
+       iData[1] = current_src;
+       iData[2] = current_count;
+       LogEvent1(_AMPI_LANG_ID,_E_END_AMPI_PROCESSING,3,iData);
+}
+
+extern "C" void ampi_msgSend(int tag,int dest,int count,int size){
+       int *iData = (int *)malloc(sizeof(int)*4);
+       iData[0] = tag;
+       iData[1] = dest;
+       iData[2] = count;
+       iData[3] = size;
+       //CmiPrintf("Size = %d\n",size);
+       LogEvent1(_AMPI_LANG_ID,_E_AMPI_MSG_SEND,4,iData);
+}
diff --git a/src/conv-perf/ampiProjections.h b/src/conv-perf/ampiProjections.h
new file mode 100644 (file)
index 0000000..a9e8480
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __AMPI_PROJECTIONS_H__
+#define __AMPI_PROJECTIONS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+void initAmpiProjections();
+void closeAmpiProjections();
+void ampi_beginProcessing(int tag,int src,int count);
+void ampi_endProcessing();
+void ampi_msgSend(int tag,int dest,int count,int size);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 4cd8cdfc48832ec661ccd5cebff7a2626b6e7bd1..5f06bdd8fa384ecf336b58a796091a3fb8ef263f 100644 (file)
@@ -12,6 +12,7 @@
 #include "converseEvents.h"    //TODO: remove this hack for REGISTER_CONVESE
 #include "charmEvents.h"       //TODO: remove this hack for REGISTER_CHARM
 #include "machineEvents.h"     // for machine events
+#include "ampiEvents.h"        /* for ampi events */
 
 CpvExtern(double, _traceCoreInitTime);
 CpvExtern(char*, _traceCoreRoot);
@@ -41,11 +42,14 @@ TraceCore::TraceCore(char** argv)
        REGISTER_CONVERSE
        REGISTER_CHARM
        REGISTER_MACHINE
+       REGISTER_AMPI
        closePtc();
 }
 
 TraceCore::~TraceCore()
-{ if(traceLogger) delete traceLogger; }
+{
+       if(traceLogger) delete traceLogger; 
+}
 
 void TraceCore::RegisterLanguage(int lID, char* ln)
 {
@@ -168,7 +172,7 @@ void TraceCore::LogEvent(int lID, int eID)
 
 void TraceCore::LogEvent(int lID, int eID, int iLen, int* iData)
 { 
-       if(traceCoreOn == 0){
+       if(traceCoreOn == 0){           
                return;
        }
        LogEvent(lID, eID, iLen, iData, 0, NULL); 
@@ -467,6 +471,7 @@ void TraceLogger::openLogFiles()
 
 void TraceLogger::closeLogFiles()
 {
+
   for(int i=1; i<numLangs; i++){
                if(fptrs[i])
                        fclose(fptrs[i]);
index a5f65ef4449d23c047f0ee2825ebd385d8764292..2042d2a8949ab1c694f686bc648ece678a43b48e 100644 (file)
@@ -2,6 +2,7 @@
 #include "traceCore.h"
 #include "traceCoreCommon.h"
 #include "charmProjections.h"
+#include "ampiProjections.h"
 #include "converse.h"
 
 
@@ -45,11 +46,15 @@ extern "C" void initTraceCore(char** argv)
   CpvInitialize(TraceCore*, _traceCore);
        CpvAccess(_traceCore) = new TraceCore(argv);
   initCharmProjections();
+  initAmpiProjections();
 }
 
 /* End Core Trace Module */
 //TODO - trace-common.C
-extern "C" void closeTraceCore() {}
+extern "C" void closeTraceCore() {
+       closeAmpiProjections();
+       delete CpvAccess(_traceCore);
+}
 
 /* Resume Core Trace Module */
 //TODO - trace-common.C