50 Commits

Author SHA1 Message Date
Egor Mayorov
940d2d7f17 swap operators in AST 2025-05-28 16:20:10 +03:00
Egor Mayorov
bf3521da97 Use more complex algorythm for building new order of statements 2025-05-28 16:20:10 +03:00
Egor Mayorov
37f8064427 update in new order 2025-05-28 16:20:10 +03:00
Egor Mayorov
3d7c18773d biulding new order 2025-05-28 16:20:10 +03:00
Egor Mayorov
4c3981be62 some loop analysis done 2025-05-28 16:20:10 +03:00
Egor Mayorov
4e68fd9548 Add _bin to gitignore 2025-05-28 16:20:10 +03:00
Egor Mayorov
4944dd516d Some actions simplify analyzing IR 2025-05-28 16:20:10 +03:00
Egor Mayorov
d3e3996349 Pass with output file added 2025-05-28 16:20:10 +03:00
Egor Mayorov
c1f164a029 change pass deps 2025-05-28 16:20:10 +03:00
Egor Mayorov
62cade5a7e New pass 2025-05-28 16:20:10 +03:00
ALEXks
8f55c13a0c added dumping messages to json 2025-05-27 18:10:24 +03:00
ALEXks
7ee9d839a1 moved messages from Parser to SPF_message 2025-05-26 21:06:51 +03:00
ALEXks
78e9b63331 moved messages to Json 2025-05-23 17:36:12 +03:00
ALEXks
879094a6b7 moved messages to Json, some refactoring 2025-05-23 15:56:37 +03:00
ALEXks
6c16cc5432 added json for SPF_ParseFilesWithOrder pass 2025-05-20 16:37:21 +03:00
ALEXks
b1eeac0b10 added json for SPF_CreateParallelVariant pass 2025-05-20 16:20:27 +03:00
ALEXks
4bcf83f551 fixed 2025-05-19 14:07:33 +03:00
ALEXks
c548f4ab4c added json to SPF_GetArrayLinks 2025-05-18 20:15:50 +03:00
2338156a28 Merge pull request 'arrayJson' (#56) from arrayJson into master 2025-05-18 15:32:12 +00:00
ALEXks
718b1738a1 fixed typo 2025-05-18 16:42:38 +03:00
ALEXks
0fe97ceb24 fixed AlignRuleBase::toJson() 2025-05-18 16:41:14 +03:00
ALEXks
81725651b1 fixed Array::toJson() 2025-05-18 16:41:14 +03:00
ALEXks
4614e166b4 version updated 2025-05-18 16:41:10 +03:00
ALEXks
bcecd5460b added json for SPF_GetArrayDistribution pass 2025-05-18 16:40:31 +03:00
ALEXks
719e3723ae added json for SPF_GetAllDeclaratedArrays pass 2025-05-18 16:40:31 +03:00
ALEXks
12d3c2c8e5 fixed NULL error in matchParallelAndDist function 2025-05-18 15:42:38 +03:00
ALEXks
a719dea05f fixed BUILD_INCLUDE_DEPENDENCIES pass 2025-05-18 15:38:26 +03:00
ALEXks
5f98eaf872 updated submodule 2025-05-18 14:53:46 +03:00
ALEXks
e3d77f51f1 fixed getNameInLocation 2025-05-11 09:17:16 +03:00
ALEXks
0a4b795900 fixed module utils 2025-05-07 15:00:01 +03:00
ALEXks
8efd632325 fixed gcov 2025-05-02 21:38:13 +03:00
ALEXks
5a7d7269cd added json for SPF_GetGCovInfo pass 2025-05-02 17:52:28 +03:00
ALEXks
4b7c3d89b0 fixed getInterfaceBlock 2025-04-30 16:52:37 +03:00
ALEXks
e7990bda0a fixed SPF_InsertIncludesPass unpacking 2025-04-30 09:14:22 +03:00
ALEXks
a49f10cb5b added predictor library to Sapfor 2025-04-25 14:30:43 +03:00
636f2b0af1 added predictor library to submodule 2025-04-23 18:02:18 +03:00
ALEXks
640e34816f Merge branch 'master' of http://192.168.0.176:30008/Alexander_KS/SAPFOR 2025-04-23 14:25:05 +03:00
ALEXks
b88eccaad4 added json for line info 2025-04-23 14:25:01 +03:00
ALEXks
7b0cb828a7 fixed predictor 2025-04-22 18:08:28 +03:00
ALEXks
06980ee344 fixed dumping statistics 2025-04-20 21:34:31 +03:00
ALEXks
cde49042ae added pass dependency for RENAME_INLCUDES 2025-04-16 16:18:32 +03:00
ALEXks
dae0afef45 moved SPF_GetIncludeDependencies to json 2025-04-16 14:58:46 +03:00
ALEXks
41b4649d83 added json for call graph positions, removed SPF_GetGraphVizOfFunctions 2025-04-13 21:30:41 +03:00
ALEXks
b068a49b0b added json for call graph 2025-04-13 17:24:49 +03:00
ALEXks
5acbd10a26 removed checking from predictor 2025-04-12 21:52:41 +03:00
ALEXks
da6685df43 fixed 2025-04-01 18:53:49 +03:00
ALEXks
9c4993feeb version 2025-04-01 16:36:31 +03:00
ALEXks
7666a6c804 declare for module in progess 2025-04-01 16:36:09 +03:00
ALEXks
79302bf7b7 moved LoopGraph to json 2025-04-01 15:31:43 +03:00
ALEXks
a7f199ad4c moved LoopGraph to json 2025-04-01 15:28:53 +03:00
9 changed files with 188 additions and 124 deletions

View File

@@ -2,6 +2,7 @@
#include <vector> #include <vector>
#include "dvm.h" #include "dvm.h"
#include "../GraphCall/graph_calls.h" #include "../GraphCall/graph_calls.h"
#include "../Utils/json.hpp"
class ParallelStats class ParallelStats
{ {
@@ -11,10 +12,10 @@ public:
RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0; RemoteCount = ShadowCount = ReductionCount = AcrossCount = 0;
} }
int RemoteCount; int RemoteCount = 0;
int ShadowCount; int ShadowCount = 0;
int ReductionCount; int ReductionCount = 0;
int AcrossCount; int AcrossCount = 0;
}; };
class PredictorStats class PredictorStats
@@ -27,28 +28,32 @@ public:
} }
ParallelStats ParallelStat; ParallelStats ParallelStat;
int ParallelCount; int ParallelCount = 0;
int RemoteCount; int RemoteCount = 0;
int RedistributeCount; int RedistributeCount = 0;
int IntervalCount; int IntervalCount = 0;
int TotalScoreComm; int TotalScoreComm = 0;
int TotalScorePar; int TotalScorePar = 0;
int TotalScoreDist; int TotalScoreDist = 0;
std::string to_string() nlohmann::json toJson()
{ {
std::string res = ""; nlohmann::json stat;
res += std::to_string(ParallelCount) + "|";
res += std::to_string(RemoteCount) + "|";
res += std::to_string(RedistributeCount) + "|";
res += std::to_string(IntervalCount) + "|";
res += std::to_string(ParallelStat.RemoteCount) + "|"; stat["ParallelCount"] = ParallelCount;
res += std::to_string(ParallelStat.ShadowCount) + "|"; stat["RemoteCount"] = RemoteCount;
res += std::to_string(ParallelStat.ReductionCount) + "|"; stat["RedistributeCount"] = RedistributeCount;
res += std::to_string(ParallelStat.AcrossCount); 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;
} }
}; };

View File

@@ -387,7 +387,50 @@ static string shiftLines(const string &in, const map<string, const FileInfo*> &m
return newStr; return newStr;
} }
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors) static void addMessage(const string& in, const map<string, const FileInfo*>& mapOfFiles,
const FileInfo* currF, map<string, vector<Messages>>& messages, typeMessage type)
{
int byNum = 0;
auto it = in.find("on line ");
if (it != string::npos)
it += strlen("on line ");
int line = 0;
sscanf(in.c_str() + it, "%d", &line);
auto it1 = in.find("of", it + 1);
if (it1 == string::npos)
return;
it1 += 3;
string fileN = in.substr(it1, in.find(':', it1) - it1);
auto itF = mapOfFiles.find(fileN);
if (itF != mapOfFiles.end() && itF->second != currF)
{
byNum = itF->second->includesAdded;
if (byNum != 0)
{
if (line - byNum <= 0)
{
//return in;
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
}
else
line -= byNum;
}
}
const string newStr = in.substr(0, it) + std::to_string(line) + in.substr(in.find(' ', it + 1));
wstring messageE, messageR;
__spf_printToLongBuf(messageE, L"%s", to_wstring(newStr).c_str());
__spf_printToLongBuf(messageR, L"%s", to_wstring(newStr).c_str());
messages[fileN].push_back(Messages(type, line, messageR, messageE, 6000));
}
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors, map<string, vector<Messages>>& messages)
{ {
int errorsCount = 0; int errorsCount = 0;
map<string, const FileInfo*> mapOfFiles; map<string, const FileInfo*> mapOfFiles;
@@ -420,9 +463,13 @@ static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string
for (auto& elem : splited) for (auto& elem : splited)
{ {
if (elem.find("Warning 308") != string::npos) if (elem.find("Warning 308") != string::npos)
{
addMessage(elem, mapOfFiles, &file, messages, WARR);
outS += shiftLines(elem, mapOfFiles, &file) + "\n"; outS += shiftLines(elem, mapOfFiles, &file) + "\n";
}
else if (elem.find("Error") != string::npos) else if (elem.find("Error") != string::npos)
{ {
addMessage(elem, mapOfFiles, &file, messages, ERROR);
errS += shiftLines(elem, mapOfFiles, &file) + "\n"; errS += shiftLines(elem, mapOfFiles, &file) + "\n";
errorsCount++; errorsCount++;
} }
@@ -652,7 +699,7 @@ static int parseFiles(vector<string>& errors, vector<FileInfo>& listOfProject, v
return rethrow; return rethrow;
} }
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining) int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining, map<string, vector<Messages>>& messages)
{ {
FILE* list = fopen(proj, "r"); FILE* list = fopen(proj, "r");
if (!list) if (!list)
@@ -723,7 +770,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
vector<string> errors; vector<string> errors;
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining); int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining);
int errCount = dumpErrors(listOfProject, errors); int errCount = dumpErrors(listOfProject, errors, messages);
if (rethrow != 0) if (rethrow != 0)
throw rethrow; throw rethrow;
@@ -732,6 +779,8 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
void parseFiles(int argc, char** argv) void parseFiles(int argc, char** argv)
{ {
map<string, vector<Messages>> messages;
bool isInline = false; bool isInline = false;
auto result = splitCommandLineForParse(argv, argc, isInline); auto result = splitCommandLineForParse(argv, argc, isInline);
if (result.second.size() == 0) if (result.second.size() == 0)

View File

@@ -3,5 +3,5 @@
#include <vector> #include <vector>
#include <string> #include <string>
int parseFiles(const char* proj, std::vector<std::string>& filesCompilationOrder, int parseForInlining); int parseFiles(const char* proj, std::vector<std::string>& filesCompilationOrder, int parseForInlining, std::map<std::string, std::vector<Messages>>& messages);
void parseFiles(int argc, char** argv); void parseFiles(int argc, char** argv);

View File

@@ -64,6 +64,7 @@
#include "DvmhRegions/LoopChecker.h" #include "DvmhRegions/LoopChecker.h"
#include "DvmhRegions/ReadWriteAnalyzer.h" #include "DvmhRegions/ReadWriteAnalyzer.h"
#include "Utils/utils.h" #include "Utils/utils.h"
#include "Utils/json.hpp"
#include "Distribution/Array.h" #include "Distribution/Array.h"
#include "VisualizerCalls/get_information.h" #include "VisualizerCalls/get_information.h"
@@ -109,6 +110,7 @@ using namespace std;
using std::chrono::high_resolution_clock; using std::chrono::high_resolution_clock;
using std::chrono::duration_cast; using std::chrono::duration_cast;
using std::chrono::milliseconds; using std::chrono::milliseconds;
using json = nlohmann::json;
int PASSES_DONE[EMPTY_PASS]; int PASSES_DONE[EMPTY_PASS];
bool PASSES_DONE_INIT = false; bool PASSES_DONE_INIT = false;
@@ -2053,7 +2055,7 @@ static void findFunctionsToInclude(bool needToAddErrors)
SPF_messages[byFile.first].push_back(message); SPF_messages[byFile.first].push_back(message);
else else
{ {
if (message.type != ERROR) if (message.getType() != ERROR)
SPF_messages[byFile.first].push_back(message); SPF_messages[byFile.first].push_back(message);
else else
lastErrors[byFile.first].push_back(message); lastErrors[byFile.first].push_back(message);
@@ -2228,8 +2230,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
runPass(GROUP_ACTUAL_AND_REMOTE, proj_name, folderName); runPass(GROUP_ACTUAL_AND_REMOTE, proj_name, folderName);
runAnalysis(*project, CALCULATE_STATS_SCHEME, false); 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 //TODO: need to rewrite this to new algo
/*if (!folderName && !consoleMode || predictOn) /*if (!folderName && !consoleMode || predictOn)
runAnalysis(*project, PREDICT_SCHEME, false); */ runAnalysis(*project, PREDICT_SCHEME, false); */
@@ -2398,7 +2399,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
break; break;
case PARSE_FILES: case PARSE_FILES:
{ {
int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining); int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining, SPF_messages);
if (err != 0) if (err != 0)
throw err; throw err;
} }
@@ -2667,26 +2668,28 @@ int main(int argc, char **argv)
{ {
printStackTrace(); printStackTrace();
printf("exception occurred\n"); printf("exception occurred\n");
json byFileArray = json::array();
for (auto& byFile : SPF_messages) for (auto& byFile : SPF_messages)
{ {
json inFile;
inFile["file"] = byFile.first;
json messages = json::array();
for (auto& message : byFile.second) for (auto& message : byFile.second)
{ {
string toPrint = ""; message.print(byFile.first);
for (int z = 0; z < message.engMessage.size(); ++z) messages.push_back(message.toJson());
toPrint += message.engMessage[z];
string type;
if (message.type == WARR)
type = "WARR";
else if (message.type == ERROR)
type = "ERROR";
else if (message.type == NOTE)
type = "NOTE";
else
type = "UNKN";
printf("%s - [#%d: %s: line %d]: %s\n", type.c_str(), message.group, byFile.first.c_str(), message.line, toPrint.c_str());
} }
inFile["messages"] = messages;
byFileArray.push_back(inFile);
} }
json allMessages;
allMessages["allMessage"] = byFileArray;
FILE* outF = fopen("dump_messages.json", "w");
fprintf(outF, "%s", allMessages.dump().c_str());
fclose(outF);
} }
deleteAllAllocatedData(withDel); deleteAllAllocatedData(withDel);

View File

@@ -1,5 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include "json.hpp"
#ifdef __SPF #ifdef __SPF
#include "dvm.h" #include "dvm.h"
#endif #endif
@@ -143,6 +145,9 @@ enum typeMessage { WARR, ERROR, NOTE };
// 06 "%s clause can be used only once." // 06 "%s clause can be used only once."
// 07 "Variable '%s' can't be used in FILES and EXCEPT clauses at the same time." // 07 "Variable '%s' can't be used in FILES and EXCEPT clauses at the same time."
// 6000 PARSER GROUP
//
extern int langOfMessages; extern int langOfMessages;
struct Messages struct Messages
{ {
@@ -164,18 +169,41 @@ public:
engMessage.erase(engMessage.begin() + engMessage.size() - 1); engMessage.erase(engMessage.begin() + engMessage.size() - 1);
} }
std::wstring toString() const nlohmann::json toJson() const
{ {
std::wstring retVal = L"|"; nlohmann::json resVal;
retVal += std::to_wstring((int)type) + L" ";
retVal += std::to_wstring(line) + L" "; resVal["line"] = line;
retVal += std::to_wstring(group); resVal["group"] = group;
retVal += L"|" + value; resVal["value"] = std::string(value.begin(), value.end());
return retVal; resVal["type"] = (int)type;
return resVal;
} }
std::string getString() const { return std::string(engMessage.begin(), engMessage.end()); } typeMessage getType() const { return type; }
public: int getLine() const { return line; }
void print(const std::string& file) const
{
std::string toPrint = "";
for (int z = 0; z < engMessage.size(); ++z)
toPrint += engMessage[z];
std::string typeStr;
if (type == WARR)
typeStr = "WARR";
else if (type == ERROR)
typeStr = "ERROR";
else if (type == NOTE)
typeStr = "NOTE";
else
typeStr = "UNKN";
printf("%s - [#%d: %s: line %d]: %s\n", typeStr.c_str(), group, file.c_str(), line, toPrint.c_str());
}
auto getUniqKey() const { return std::make_tuple(type, group, line, value); }
private:
typeMessage type; typeMessage type;
int group; int group;
int line; int line;

View File

@@ -30,6 +30,7 @@
#include "../Distribution/Arrays.h" #include "../Distribution/Arrays.h"
#include "../DynamicAnalysis/gcov_info.h" #include "../DynamicAnalysis/gcov_info.h"
#include "../ParallelizationRegions/ParRegions.h" #include "../ParallelizationRegions/ParRegions.h"
#include "json.hpp"
#if __SPF #if __SPF
#include "acc_analyzer.h" #include "acc_analyzer.h"
@@ -42,6 +43,7 @@ using std::set;
using std::vector; using std::vector;
using std::string; using std::string;
using std::wstring; using std::wstring;
using json = nlohmann::json;
#if __cplusplus >= 201703L #if __cplusplus >= 201703L
#include <filesystem> #include <filesystem>
@@ -427,7 +429,7 @@ static map<string, vector<Messages>> removeCopies(map<string, vector<Messages>>
map<tuple<typeMessage, int, int, wstring>, const Messages*> uniq; map<tuple<typeMessage, int, int, wstring>, const Messages*> uniq;
for (auto& message : byFile.second) for (auto& message : byFile.second)
{ {
auto key = make_tuple(message.type, message.group, message.line, message.value); auto key = message.getUniqKey();
/*string tmp = ""; /*string tmp = "";
for (auto& s : message.toString()) for (auto& s : message.toString())
tmp += (char)s; tmp += (char)s;
@@ -460,7 +462,7 @@ static void convertGlobalMessagesBuffer(short *&result, int *&resultSize)
bool waschanged = false; bool waschanged = false;
for (auto &message : byFile.second) for (auto &message : byFile.second)
{ {
if (message.line > 0) if (message.getLine() > 0)
newVal.push_back(message); newVal.push_back(message);
else else
waschanged = true; waschanged = true;
@@ -470,22 +472,30 @@ static void convertGlobalMessagesBuffer(short *&result, int *&resultSize)
byFile.second = newVal; byFile.second = newVal;
} }
wstring val = L""; json allMessages = json::array();
val += std::to_wstring(copySPF_messages.size()); for (auto& byFile : copySPF_messages)
for (auto it = copySPF_messages.begin(); it != copySPF_messages.end(); ++it)
{ {
val += L"|" + to_wstring(it->first.c_str()) + L"|" + std::to_wstring(it->second.size()); json inFile;
for (int k = 0; k < it->second.size(); ++k) inFile["file"] = byFile.first;
val += it->second[k].toString();
json array = json::array();
for (auto& message : byFile.second)
{
json msg = message.toJson();
array.push_back(msg);
}
inFile["messages"] = array;
allMessages.push_back(inFile);
} }
const unsigned len = (unsigned)val.size(); json all;
result = new short[len + 1]; all["allMessages"] = allMessages;
allocated.insert(result);
result[len] = '\0'; const string str = all.dump();
for (unsigned i = 0; i < len; ++i) const unsigned len = (unsigned)str.size();
result[i] = val[i];
copyStringToShort(result, str);
allocated.insert(result);
resultSize = new int[1]; resultSize = new int[1];
resultSize[0] = (int)len; resultSize[0] = (int)len;
@@ -1686,4 +1696,16 @@ set<string> fillDistributedArrays(const DataDirective& dataDirectives,
for (auto& elem : ret) for (auto& elem : ret)
distrArrays.insert(shortName ? elem->GetShortName() : elem->GetName()); distrArrays.insert(shortName ? elem->GetShortName() : elem->GetName());
return distrArrays; return distrArrays;
}
void copyStringToShort(short*& result, const string& resVal, bool withEnd)
{
result = new short[resVal.size() + 1];
allocated.insert(result);
for (int i = 0; i < resVal.size(); ++i)
result[i] = resVal[i];
if (withEnd)
result[resVal.size()] = (short)'\0';
} }

View File

@@ -96,3 +96,5 @@ std::vector<std::string> splitAndArgvCreate(const std::string& options);
std::set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false); std::set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false);
std::set<std::string> fillDistributedArrays(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false, bool shortName = false); std::set<std::string> fillDistributedArrays(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false, bool shortName = false);
void copyStringToShort(short*& result, const std::string& resVal, bool withEnd = true);

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2421" #define VERSION_SPF "2422"

View File

@@ -218,18 +218,6 @@ static bool tryOpenProjectFile(const char *project)
return ret; return ret;
} }
static void copyStringToShort(short *&result, const string &resVal, bool withEnd = true)
{
result = new short[resVal.size() + 1];
allocated.insert(result);
for (int i = 0; i < resVal.size(); ++i)
result[i] = resVal[i];
if (withEnd)
result[resVal.size()] = (short)'\0';
}
volatile int passDone = 0; volatile int passDone = 0;
static volatile int rethrow = 0; static volatile int rethrow = 0;
static void runPassesLoop(const vector<passes> &passesToRun, const char *prName, const char *folderNameChar) static void runPassesLoop(const vector<passes> &passesToRun, const char *prName, const char *folderNameChar)
@@ -465,14 +453,15 @@ int SPF_ParseFilesWithOrder(void*& context, int winHandler, short* options, shor
{ {
runPassesForVisualizer(projName, { PARSE_FILES }); runPassesForVisualizer(projName, { PARSE_FILES });
string resVal = ""; json filesArray = json::array();
for (auto& elem : filesCompilationOrder)
{ for (auto& file : filesCompilationOrder)
if (resVal == "") filesArray.push_back(file);
resVal += elem;
else json filesOrder;
resVal += "|" + elem; filesOrder["allFiles"] = filesArray;
}
string resVal = filesOrder.dump();
copyStringToShort(result, resVal); copyStringToShort(result, resVal);
retSize = 0; retSize = 0;
} }
@@ -1065,7 +1054,6 @@ int SPF_CreateParallelVariant(void*& context, int winHandler, short *options, sh
printf("SAPFOR: set all info done\n"); printf("SAPFOR: set all info done\n");
runPassesForVisualizer(projName, { INSERT_PARALLEL_DIRS }, folderName); runPassesForVisualizer(projName, { INSERT_PARALLEL_DIRS }, folderName);
string predictRes = "";
PredictorStats summed; PredictorStats summed;
for (auto &predFile : allPredictorStats) for (auto &predFile : allPredictorStats)
{ {
@@ -1081,44 +1069,11 @@ int SPF_CreateParallelVariant(void*& context, int winHandler, short *options, sh
summed.TotalScoreComm += predFile.second.TotalScoreComm; summed.TotalScoreComm += predFile.second.TotalScoreComm;
summed.TotalScoreDist += predFile.second.TotalScoreDist; summed.TotalScoreDist += predFile.second.TotalScoreDist;
summed.TotalScorePar += predFile.second.TotalScorePar; 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); copyStringToShort(predictorStats, predictRes);
__spf_print(1, " statistic to send: %s\n", predictRes.c_str()); __spf_print(1, " statistic to send: %s\n", predictRes.c_str());
retSize = (int)predictRes.size(); retSize = (int)predictRes.size();
} }