doc: Add serial to list of ci file reserved words
[charm.git] / src / ck-perf / trace-summaryBOC.h
index 9b6051fffba6075714ca78b13517b4446e2fa847..9e8463fa2c3a9f063126811556a816233624a227 100644 (file)
@@ -1,68 +1,25 @@
 #include "ckcallback-ccs.h"
 #include "TraceSummary.decl.h"
+#include <deque>
 
 extern CkGroupID traceSummaryGID;
-extern CProxy_TraceSummaryInit initProxy;
 extern bool summaryCcsStreaming;
 
-void masterCollectData(void *data, double currT);
-
 class TraceSummaryInit : public Chare {
- public:
-  int lastRequestedIndexBlock;
-  int indicesPerBlock;
-  double collectionGranularity;
-  CkVec<double> *ccsBufferedData;
-  int nBufferedBins;
  public:
   TraceSummaryInit(CkArgMsg *m) {
-    lastRequestedIndexBlock = 0;
-    indicesPerBlock = 1000;
-    collectionGranularity = 0.001; // time in seconds
-    nBufferedBins = 0;
     traceSummaryGID = CProxy_TraceSummaryBOC::ckNew();
     CProxy_TraceSummaryBOC sumProxy(traceSummaryGID);
-    initProxy = thishandle;
+
     CkCallback *cb = new CkCallback(CkIndex_TraceSummaryBOC::sendSummaryBOC(NULL), 0, sumProxy);
     CProxy_TraceSummaryBOC(traceSummaryGID).ckSetReductionClient(cb);
-    if (CmiGetArgFlagDesc(m->argv,"+sumCCS",
-                         "CCS client connected to Trace Summary")) {
-      ccsBufferedData = new CkVec<double>();
-      CkPrintf("Trace Summary listening in for CCS Client\n");
-      CcsRegisterHandler("CkPerfSummaryCcsClientCB", 
-                        CkCallback(CkIndex_TraceSummaryInit::ccsClientRequest(NULL), thishandle));
-      CcdCallOnConditionKeep(CcdPERIODIC_1second, masterCollectData, 
-                            (void *)this);
-      summaryCcsStreaming = CmiTrue;
-    } else {
-      summaryCcsStreaming = CmiFalse;
-    }
+
+    // No CCS Streaming support until user-code requires it.
+    summaryCcsStreaming = CmiFalse;
   }
   TraceSummaryInit(CkMigrateMessage *m):Chare(m) {}
-  void dataCollected(CkReductionMsg *);  
-  void ccsClientRequest(CkCcsRequestMsg *m);
 };
 
-void masterCollectData(void *data, double currT) {
-  // CkPrintf("collectData called\n");
-  TraceSummaryInit *sumInitObj = (TraceSummaryInit *)data;
-
-  double startTime = sumInitObj->lastRequestedIndexBlock*
-    sumInitObj->collectionGranularity*sumInitObj->indicesPerBlock;
-  int numIndicesToGet = (int)floor((currT - startTime)/
-                                  sumInitObj->collectionGranularity);
-  int numBlocksToGet = numIndicesToGet/sumInitObj->indicesPerBlock;
-  // **TODO** consider limiting the total number of blocks each collection
-  //   request will pick up. This is to limit the amount of perturbation
-  //   if it proves to be a problem.
-  CProxy_TraceSummaryBOC sumProxy(traceSummaryGID);
-  sumProxy.collectData(startTime, 
-                      sumInitObj->collectionGranularity,
-                      numBlocksToGet*sumInitObj->indicesPerBlock);
-  // assume success
-  sumInitObj->lastRequestedIndexBlock += numBlocksToGet; 
-}
-
 class TraceSummaryBOC : public CBase_TraceSummaryBOC {
 private:
   int count;
@@ -70,18 +27,41 @@ private:
   int  nBins;
   int nTracedPEs;
 
+  bool firstTime; // used to make sure traceEnableCCS only has an effect the first time.
+  double _maxBinSize; //the max bin size collected from all processors
+public:
+  /* CCS support variables */
+  int lastRequestedIndexBlock;
+  int indicesPerBlock;
+  double collectionGranularity; /* time in seconds */
+  int nBufferedBins;
+  CkVec<double> *ccsBufferedData;
   int nextBinIndexCcs;
+
 public:
   TraceSummaryBOC(void): count(0), bins(NULL), nBins(0), 
-    nTracedPEs(0), nextBinIndexCcs(0) {};
+    nTracedPEs(0), nextBinIndexCcs(0), firstTime(true) {};
   TraceSummaryBOC(CkMigrateMessage *m):CBase_TraceSummaryBOC(m) {};
   void startSumOnly();
   void askSummary(int size);
   void sendSummaryBOC(CkReductionMsg *);
 
-  void collectData(double startTime, double binSize, int numBins);
+  /* CCS support methods/entry methods */
+  void initCCS();
+  void ccsRequestSummaryDouble(CkCcsRequestMsg *m);
+  void ccsRequestSummaryUnsignedChar(CkCcsRequestMsg *m);
+
+  void collectSummaryData(double startTime, double binSize, int numBins);
+  void summaryDataCollected(CkReductionMsg *);
+
+  void traceSummaryParallelShutdown(int pe);
+  void maxBinSize(CkReductionMsg *msg);
+  void shrink(double _maxBinSize);
+
+  void sumData(CkReductionMsg *msg);
+
 private:
   void write();
 };
 
-
+void startCollectData(void *data, double currT);