added json for SPF_CreateParallelVariant pass
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <vector>
|
||||
#include "dvm.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
#include "../Utils/json.hpp"
|
||||
|
||||
class ParallelStats
|
||||
{
|
||||
@@ -11,10 +12,10 @@ public:
|
||||
RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0;
|
||||
}
|
||||
|
||||
int RemoteCount;
|
||||
int ShadowCount;
|
||||
int ReductionCount;
|
||||
int AcrossCount;
|
||||
int RemoteCount = 0;
|
||||
int ShadowCount = 0;
|
||||
int ReductionCount = 0;
|
||||
int AcrossCount = 0;
|
||||
};
|
||||
|
||||
class PredictorStats
|
||||
@@ -27,28 +28,32 @@ public:
|
||||
}
|
||||
|
||||
ParallelStats ParallelStat;
|
||||
int ParallelCount;
|
||||
int RemoteCount;
|
||||
int RedistributeCount;
|
||||
int IntervalCount;
|
||||
int TotalScoreComm;
|
||||
int TotalScorePar;
|
||||
int TotalScoreDist;
|
||||
int ParallelCount = 0;
|
||||
int RemoteCount = 0;
|
||||
int RedistributeCount = 0;
|
||||
int IntervalCount = 0;
|
||||
int TotalScoreComm = 0;
|
||||
int TotalScorePar = 0;
|
||||
int TotalScoreDist = 0;
|
||||
|
||||
std::string to_string()
|
||||
nlohmann::json toJson()
|
||||
{
|
||||
std::string res = "";
|
||||
res += std::to_string(ParallelCount) + "|";
|
||||
res += std::to_string(RemoteCount) + "|";
|
||||
res += std::to_string(RedistributeCount) + "|";
|
||||
res += std::to_string(IntervalCount) + "|";
|
||||
nlohmann::json stat;
|
||||
|
||||
res += std::to_string(ParallelStat.RemoteCount) + "|";
|
||||
res += std::to_string(ParallelStat.ShadowCount) + "|";
|
||||
res += std::to_string(ParallelStat.ReductionCount) + "|";
|
||||
res += std::to_string(ParallelStat.AcrossCount);
|
||||
stat["ParallelCount"] = ParallelCount;
|
||||
stat["RemoteCount"] = RemoteCount;
|
||||
stat["RedistributeCount"] = RedistributeCount;
|
||||
stat["IntervalCount"] = IntervalCount;
|
||||
|
||||
return res;
|
||||
stat["PS_RemoteCount"] = ParallelStat.RemoteCount;
|
||||
stat["PS_ShadowCount"] = ParallelStat.ShadowCount;
|
||||
stat["PS_ReductionCount"] = ParallelStat.ReductionCount;
|
||||
stat["PS_AcrossCount"] = ParallelStat.AcrossCount;
|
||||
|
||||
//TODO: need to improve
|
||||
// (summed.TotalScoreComm != 0 ? 1.0 / summed.TotalScoreComm : 0.0) + (double)summed.TotalScorePar * 1000 + (countOfDist == 0 ? -5000 : countOfDist);
|
||||
stat["TotalScore"] = -1 * (ParallelStat.RemoteCount + ParallelStat.ShadowCount + ParallelStat.ReductionCount + ParallelStat.AcrossCount);
|
||||
return stat;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2221,8 +2221,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
runPass(GROUP_ACTUAL_AND_REMOTE, proj_name, folderName);
|
||||
|
||||
runAnalysis(*project, CALCULATE_STATS_SCHEME, false);
|
||||
for (auto& elem : allPredictorStats)
|
||||
__spf_print(1, " stat for file %s: %s\n", elem.first.c_str(), elem.second.to_string().c_str());
|
||||
|
||||
//TODO: need to rewrite this to new algo
|
||||
/*if (!folderName && !consoleMode || predictOn)
|
||||
runAnalysis(*project, PREDICT_SCHEME, false); */
|
||||
|
||||
@@ -1065,7 +1065,6 @@ int SPF_CreateParallelVariant(void*& context, int winHandler, short *options, sh
|
||||
printf("SAPFOR: set all info done\n");
|
||||
runPassesForVisualizer(projName, { INSERT_PARALLEL_DIRS }, folderName);
|
||||
|
||||
string predictRes = "";
|
||||
PredictorStats summed;
|
||||
for (auto &predFile : allPredictorStats)
|
||||
{
|
||||
@@ -1082,43 +1081,10 @@ int SPF_CreateParallelVariant(void*& context, int winHandler, short *options, sh
|
||||
summed.TotalScoreDist += predFile.second.TotalScoreDist;
|
||||
summed.TotalScorePar += predFile.second.TotalScorePar;
|
||||
}
|
||||
predictRes += summed.to_string();
|
||||
//predictRes += "|" + to_string((summed.TotalScoreComm != 0 ? 1.0 / summed.TotalScoreComm : 0.0 )+ (double)summed.TotalScorePar * 1000 + (countOfDist == 0 ? -5000 : countOfDist));
|
||||
if (countOfDist == 0)
|
||||
predictRes += "|x";
|
||||
else
|
||||
predictRes += "|" + to_string(-1 * (summed.ParallelStat.AcrossCount + summed.ParallelStat.RemoteCount + summed.RedistributeCount + summed.RemoteCount));
|
||||
//predictRes += "|0";
|
||||
|
||||
//TODO: need to rewrite to new algo
|
||||
/*if (folderName == NULL)
|
||||
{
|
||||
SpfInterval *mainIterval = getMainInterval(project, intervals);
|
||||
const int idxBest = mainIterval->getBestTimeIdx();
|
||||
double speedUpBest = 1;
|
||||
int procCount = 1;
|
||||
string topo = "";
|
||||
if (idxBest != -1 && mainIterval->exec_time != 0)
|
||||
{
|
||||
speedUpBest = mainIterval->exec_time / mainIterval->predictedTimes[idxBest];
|
||||
topo += "[";
|
||||
for (int z = 0; z < topologies[idxBest].size(); ++z)
|
||||
{
|
||||
topo += to_string(topologies[idxBest][z]);
|
||||
procCount *= topologies[idxBest][z];
|
||||
if (z != topologies[idxBest].size() - 1)
|
||||
topo += "x";
|
||||
}
|
||||
topo += "]";
|
||||
}
|
||||
char buf[256];
|
||||
sprintf(buf, "%.2f", speedUpBest / procCount * 100.0);
|
||||
predictRes += "|" + string(buf) + topo;
|
||||
}
|
||||
else
|
||||
predictRes += "|0";*/
|
||||
|
||||
string predictRes = summed.toJson().dump();
|
||||
copyStringToShort(predictorStats, predictRes);
|
||||
|
||||
__spf_print(1, " statistic to send: %s\n", predictRes.c_str());
|
||||
retSize = (int)predictRes.size();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user