Making sum detail tracing only get intialized once.
[charm.git] / src / ck-perf / trace-summaryBOC.h
1 #include "ckcallback-ccs.h"
2 #include "TraceSummary.decl.h"
3 #include <deque>
4
5 extern CkGroupID traceSummaryGID;
6 extern bool summaryCcsStreaming;
7
8 class TraceSummaryInit : public Chare {
9  public:
10   TraceSummaryInit(CkArgMsg *m) {
11     traceSummaryGID = CProxy_TraceSummaryBOC::ckNew();
12     CProxy_TraceSummaryBOC sumProxy(traceSummaryGID);
13
14     CkCallback *cb = new CkCallback(CkIndex_TraceSummaryBOC::sendSummaryBOC(NULL), 0, sumProxy);
15     CProxy_TraceSummaryBOC(traceSummaryGID).ckSetReductionClient(cb);
16
17     // No CCS Streaming support until user-code requires it.
18     summaryCcsStreaming = CmiFalse;
19   }
20   TraceSummaryInit(CkMigrateMessage *m):Chare(m) {}
21 };
22
23 class TraceSummaryBOC : public CBase_TraceSummaryBOC {
24 private:
25   int count;
26   BinEntry *bins;
27   int  nBins;
28   int nTracedPEs;
29
30   bool firstTime; // used to make sure traceEnableCCS only has an effect the first time.
31
32 public:
33   /* CCS support variables */
34   int lastRequestedIndexBlock;
35   int indicesPerBlock;
36   double collectionGranularity; /* time in seconds */
37   int nBufferedBins;
38   CkVec<double> *ccsBufferedData;
39   int nextBinIndexCcs;
40   std::deque<CkReductionMsg *> storedSumDetailResults;
41
42
43 public:
44   TraceSummaryBOC(void): count(0), bins(NULL), nBins(0), 
45     nTracedPEs(0), nextBinIndexCcs(0), firstTime(true) {};
46   TraceSummaryBOC(CkMigrateMessage *m):CBase_TraceSummaryBOC(m) {};
47   void startSumOnly();
48   void askSummary(int size);
49   void sendSummaryBOC(CkReductionMsg *);
50
51   /* CCS support methods/entry methods */
52   void initCCS();
53   void ccsRequestSummaryDouble(CkCcsRequestMsg *m);
54   void ccsRequestSummaryUnsignedChar(CkCcsRequestMsg *m);
55   void ccsRequestSumDetailUnsignedChar(CkCcsRequestMsg *m);
56   void ccsRequestSumDetailCompressed(CkCcsRequestMsg *m);
57   void ccsRequestSumDetailCompressedPE0(CkCcsRequestMsg *m);
58
59   void collectSummaryData(double startTime, double binSize, int numBins);
60   void summaryDataCollected(CkReductionMsg *);
61   void collectSumDetailData(double startTime, double binSize, int numBins);
62   void sumDetailDataCollected(CkReductionMsg *);
63
64 private:
65   void write();
66 };
67
68 void startCollectData(void *data, double currT);