00001 #include "envelope.h"
00002 #include "register.h"
00003 #include "trace-common.h"
00004 #include "ckcallback-ccs.h"
00005
00006 #include <set>
00007
00008 #ifndef PROJ_ANALYSIS
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 void _registerTraceProjections() {
00021
00022 }
00023 #else
00024 #include "TraceProjections.decl.h"
00025
00026 class KMeansStatsMessage : public CMessage_KMeansStatsMessage {
00027 public:
00028 int numMetrics;
00029 int numKPos;
00030 int numStats;
00031 bool *filter;
00032 double *kSeedsPos;
00033 double *stats;
00034 };
00035
00036 class KSeedsMessage : public CMessage_KSeedsMessage {
00037 public:
00038 int numKPos;
00039 double *kSeedsPos;
00040 };
00041
00042 class TraceProjectionsInit : public Chare {
00043 public:
00044 TraceProjectionsInit(CkArgMsg *msg);
00045 TraceProjectionsInit(CkMigrateMessage *m):Chare(m) {}
00046 };
00047
00048 class KSelectionMessage : public CMessage_KSelectionMessage {
00049 public:
00050 int numKMinIDs;
00051 int numKMaxIDs;
00052 int *minIDs;
00053 int *maxIDs;
00054 };
00055
00056 class KMeansBOC : public CBase_KMeansBOC {
00057 private:
00058
00059 bool autoCompute;
00060 bool usePhases;
00061 int numK;
00062 int peNumKeep;
00063 int numKReported;
00064 double entryThreshold;
00065
00066
00067 bool markedBegin;
00068 bool markedIdle;
00069 bool selected;
00070 int lastBeginEPIdx;
00071 double beginBlockTime;
00072 double beginIdleBlockTime;
00073 int numSelectionIter;
00074
00075 int currentPhase;
00076 double *currentExecTimes;
00077 int lastPhaseIdx;
00078
00079
00080 int numEntryMethods;
00081 int numMetrics;
00082 int phaseIter;
00083
00084 bool *keepMetric;
00085 double *incKSeeds;
00086 double minDistance;
00087 int lastMinK;
00088 int minK;
00089
00090
00091
00092
00093 double *kSeeds;
00094 int *kNumMembers;
00095
00096 int *exemplarChoicesLeft;
00097 int *outlierChoicesLeft;
00098
00099 public:
00100 KMeansBOC(bool outlierAutomatic, int numKSeeds, int _peNumKeep,
00101 double _entryThreshold, bool outlierUsePhases) :
00102 autoCompute(outlierAutomatic), usePhases(outlierUsePhases),
00103 numK(numKSeeds), peNumKeep(_peNumKeep), entryThreshold(_entryThreshold) {}
00104 KMeansBOC(CkMigrateMessage *m):CBase_KMeansBOC(m) {}
00105
00106 void startKMeansAnalysis();
00107 void flushCheck(bool someFlush);
00108 void flushCheckDone();
00109 void getNextPhaseMetrics();
00110 void collectKMeansData();
00111 void globalMetricRefinement(CkReductionMsg *msg);
00112 void initKSeeds();
00113 void findInitialClusters(KMeansStatsMessage *msg);
00114 void updateKSeeds(double *modVector, int n);
00115 double calculateDistance(int k);
00116 void updateSeedMembership(KSeedsMessage *msg);
00117 void findRepresentatives();
00118 void collectDistances(KSelectionMessage *msg);
00119 void findNextMinMax(CkReductionMsg *msg);
00120 void phaseDone();
00121
00122
00123
00124
00125
00126
00127 };
00128
00129 class TraceProjectionsBOC : public CBase_TraceProjectionsBOC {
00130 private:
00131 bool findOutliers;
00132 bool findStartTime;
00133
00134 int parModulesRemaining;
00135
00136 double dummy;
00137 double endTime;
00138 double analysisStartTime;
00139 int endPe;
00140 int flush_count;
00141 std::set<int> list;
00142 public:
00143 TraceProjectionsBOC(bool _findOutliers, bool _findStartTime) : findOutliers(_findOutliers), findStartTime(_findStartTime), parModulesRemaining(0), endPe(-1), flush_count(0) {};
00144 TraceProjectionsBOC(CkMigrateMessage *m):CBase_TraceProjectionsBOC(m), parModulesRemaining(0), endPe(-1), flush_count(0) {};
00145
00146 void traceProjectionsParallelShutdown(int);
00147 void startTimeAnalysis();
00148 void startTimeDone(double result);
00149 void startEndTimeAnalysis();
00150 void endTimeDone(double result);
00151 void kMeansDone(void);
00152 void kMeansDoneFlushed(void);
00153 void finalize(void);
00154 void shutdownAnalysis(void);
00155 void closingTraces(void);
00156 void closeParallelShutdown(void);
00157
00158 void ccsOutlierRequest(CkCcsRequestMsg *);
00159
00160 void flush_warning(int pe);
00161 void print_warning();
00162 };
00163 #endif