merge PAPI and fix the bug to run projections and autoPerf together
[charm.git] / src / ck-tune / trace-autoPerf.h
index d5b4f578314abdcc937dd0f7c1cd21fc7bcde717..44baad14d3c144a6b601dd224077865cbcba4705 100644 (file)
@@ -15,7 +15,6 @@
 #include <map>
 #include <list>
 
-
 using namespace std;
 
 extern CkGroupID traceAutoPerfGID;
@@ -176,6 +175,9 @@ public:
     double  commTime;
     double  objLoadMax;
 
+#if CMK_HAS_COUNTER_PAPI
+    LONG_LONG_PAPI papiValues[NUMPAPIEVENTS];
+#endif
     // functions
     perfData(){}
 };
@@ -248,6 +250,9 @@ class TraceAutoPerf : public Trace {
 
 public:
 
+#if CMK_HAS_COUNTER_PAPI
+    LONG_LONG_PAPI previous_papiValues[NUMPAPIEVENTS];
+#endif
     double  lastBeginExecuteTime;
     int     lastbeginMessageSize;
     int     lastEvent;
@@ -438,6 +443,15 @@ public:
       return totalEntryMethodInvocations;
   }
 
+#if CMK_HAS_COUNTER_PAPI
+  inline void readPAPI()
+  {
+      if (PAPI_read(CkpvAccess(papiEventSet), CkpvAccess(papiValues)) != PAPI_OK) {
+          CmiAbort("PAPI failed to read at begin execute!\n");
+      }
+  }
+#endif
+
   perfData* getSummary()
   {
       currentSummary->idleMin = currentSummary->idleMax= idleRatio(); 
@@ -449,6 +463,13 @@ public:
       currentSummary->grainsizeAvg = grainSize();
       currentSummary->grainsizeMax = maxGrainSize();
       currentSummary->numInvocations = totalEntryMethodInvocations;
+#if CMK_HAS_COUNTER_PAPI
+      readPAPI();
+      for(int i=0; i<NUMPAPIEVENTS; i++)
+      {
+          currentSummary->papiValues[i] = (CkpvAccess(papiValues)[i] - previous_papiValues[i]);
+      }
+#endif
       return currentSummary;
   }