From c63c4dd46ca8408375baed059470f750cd71ffe5 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Thu, 14 Nov 2024 12:37:38 +0300 Subject: [PATCH] added simple implementation for GET_STATS_FOR_PREDICTOR pass --- sapfor/experts/Sapfor_2017/_src/CFGraph/IR.h | 31 ++ .../DirectiveProcessing/directive_parser.cpp | 52 ++- .../DirectiveProcessing/directive_parser.h | 15 +- .../_src/Predictor/PredictScheme.cpp | 416 ++++++++++++++++-- .../_src/Predictor/PredictScheme.h | 2 +- sapfor/experts/Sapfor_2017/_src/Sapfor.cpp | 4 +- .../experts/Sapfor_2017/_src/Utils/version.h | 2 +- .../_src/VisualizerCalls/get_information.cpp | 10 + 8 files changed, 473 insertions(+), 59 deletions(-) diff --git a/sapfor/experts/Sapfor_2017/_src/CFGraph/IR.h b/sapfor/experts/Sapfor_2017/_src/CFGraph/IR.h index 505a428..a887a39 100644 --- a/sapfor/experts/Sapfor_2017/_src/CFGraph/IR.h +++ b/sapfor/experts/Sapfor_2017/_src/CFGraph/IR.h @@ -162,6 +162,35 @@ namespace SAPFOR SgExpression* getExpression() const { return ex; } + int getLine() const { return st ? st->lineNumber() : -1; } + + bool isAccess() const + { + std::set accessOps = { CFG_OP::LOAD , CFG_OP::STORE, CFG_OP::REC_REF_LOAD, CFG_OP::REC_REF_STORE }; + return accessOps.find(operation) != accessOps.end(); + } + + bool isArith() const + { + std::set arithOps = { CFG_OP::ADD, CFG_OP::MULT, CFG_OP::DIV, CFG_OP::SUBT, CFG_OP::UN_ADD, CFG_OP::UN_MINUS, CFG_OP::POW, CFG_OP::CONCAT }; + //CFG_OP::CAST, CFG_OP::GE, CFG_OP::LE, CFG_OP::GT, CFG_OP::LT, CFG_OP::EQ, CFG_OP::NEQV, CFG_OP::EQV, CFG_OP::OR, CFG_OP::AND, CFG_OP::NOT }; + + return (arithOps.find(operation) != arithOps.end()) || isIntirinsicCall(); + } + + bool isIntirinsicCall() const + { + if (operation == CFG_OP::F_CALL) + { + if (ex) + { + if (isIntrinsicFunctionName(ex->symbol()->identifier())) + return true; + } + } + return false; + } + static int getNextInstrNum() { return lastNumInstr; } static void shiftNextInstrNum(int byNum) { lastNumInstr += byNum; } @@ -296,6 +325,8 @@ namespace SAPFOR void setHeader() { header = true; } bool isHeader() const { return header; } + int getLine() const { return current->getLine(); } + ~IR_Block() { delete current; } }; diff --git a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_parser.cpp b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_parser.cpp index df9e069..ac11540 100644 --- a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_parser.cpp +++ b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_parser.cpp @@ -122,15 +122,20 @@ extern map> SPF_messages; //for simple reduction template -void fillReductionsFromComment(Statement *stIn, map> &reduction, bool moduleNameAdd) +void fillReductionsFromComment(Statement *stIn, map> &reduction, bool moduleNameAdd, int type) { bool error = false; if (stIn) { SgStatement *st = stIn->GetOriginal(); - if (st->variant() == SPF_ANALYSIS_DIR) + if (st->variant() == type) { - SgExpression *exprList = st->expr(0); + SgExpression* exprList = NULL; + if (type == SPF_ANALYSIS_DIR) + exprList = st->expr(0); + else if (type == DVM_PARALLEL_ON_DIR) + exprList = st->expr(1); + while (exprList) { if (exprList->lhs()->variant() == REDUCTION_OP) @@ -188,19 +193,24 @@ void fillReductionsFromComment(Statement *stIn, map> &redu printInternalError(convertFileName(__FILE__).c_str(), __LINE__); } -template void fillReductionsFromComment(Statement *st, map> &reduction, bool); -template void fillReductionsFromComment(Statement *st, map> &reduction, bool); +template void fillReductionsFromComment(Statement *st, map> &reduction, bool, int); +template void fillReductionsFromComment(Statement *st, map> &reduction, bool, int); //for min/max loc reduction template -void fillReductionsFromComment(Statement *stIn, map>> &reduction, bool moduleNameAdd) +void fillReductionsFromComment(Statement *stIn, map>> &reduction, bool moduleNameAdd, int type) { if (stIn) { SgStatement *st = stIn->GetOriginal(); - if (st->variant() == SPF_ANALYSIS_DIR) + if (st->variant() == type) { - SgExpression *exprList = st->expr(0); + SgExpression* exprList = NULL; + if (type == SPF_ANALYSIS_DIR) + exprList = st->expr(0); + else if (type == DVM_PARALLEL_ON_DIR) + exprList = st->expr(1); + while (exprList) { if (exprList->lhs()->variant() == REDUCTION_OP) @@ -241,8 +251,8 @@ void fillReductionsFromComment(Statement *stIn, map>> &reduction, bool); -template void fillReductionsFromComment(Statement *st, map>> &reduction, bool); +template void fillReductionsFromComment(Statement *st, map>> &reduction, bool, int); +template void fillReductionsFromComment(Statement *st, map>> &reduction, bool, int); void fillParameterFromComment(Statement *stIn, vector> &assigns) { @@ -598,6 +608,28 @@ void fillInfoFromDirectives(const LoopGraph *loopInfo, ParallelDirective *direct } } +void fillInfoFromDirective(Statement* parallel_on, DvmDirective& directive) +{ + Statement* sData = parallel_on; + + fillReductionsFromComment(sData, directive.reduction, true, DVM_PARALLEL_ON_DIR); + fillReductionsFromComment(sData, directive.reductionLoc, true, DVM_PARALLEL_ON_DIR); + + fillShadowAcrossFromParallel(SHADOW_RENEW_OP, sData, directive.shadowRenew, directive.corners); + fillShadowAcrossFromParallel(ACROSS_OP, sData, directive.across, directive.corners); + + //TODO: + /*map, Expression*> remotes; + fillRemoteFromComment(sData, remotes, false, DVM_PARALLEL_ON_DIR); + for (auto& elem : remotes) + { + SgSymbol* symb = OriginalSymbol(elem.first.first->GetOriginal()); + auto uniqKey = getFromUniqTable(symb); + + directive.remoteAccess[make_pair(make_pair(elem.first.first->GetOriginal()->identifier(), getShortName(uniqKey)), elem.first.second)] = new Expression(elem.second->GetOriginal()); + }*/ +} + int getCoverPropertyFromComment(Statement* stIn) { if (stIn) diff --git a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_parser.h b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_parser.h index d71c72a..4f6bd3c 100644 --- a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_parser.h +++ b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_parser.h @@ -8,16 +8,26 @@ #include "../GraphLoop/graph_loops.h" #include "../Distribution/DvmhDirective.h" +struct DvmDirective +{ + std::set corners; + std::vector, std::vector>>> shadowRenew, across; + std::map, std::string>, Expression*> remoteAccess; + + std::map> reduction; + std::map>> reductionLoc; +}; + bool isSPF_NoInline(Statement *stPrev); template void fillPrivatesFromComment(Statement *st, std::set &privates, int type = -1); template -void fillReductionsFromComment(Statement *st, std::map> &reduction, bool moduleNameAdd = false); +void fillReductionsFromComment(Statement *st, std::map> &reduction, bool moduleNameAdd = false, int type = SPF_ANALYSIS_DIR); template -void fillReductionsFromComment(Statement *st, std::map>> &reduction, bool moduleNameAdd = false); +void fillReductionsFromComment(Statement *st, std::map>> &reduction, bool moduleNameAdd = false, int type = SPF_ANALYSIS_DIR); void fillParameterFromComment(Statement *st, std::vector> &assigns); @@ -32,6 +42,7 @@ void fillRemoteFromComment(Statement *st, std::map, std::vector>>> &acrossInfo); void fillInfoFromDirectives(const LoopGraph *loopInfo, ParallelDirective *directive); +void fillInfoFromDirective(Statement* parallel_on, DvmDirective& directive); void fillFissionPrivatesExpansionFromComment(Statement *stIn, std::vector &vars); diff --git a/sapfor/experts/Sapfor_2017/_src/Predictor/PredictScheme.cpp b/sapfor/experts/Sapfor_2017/_src/Predictor/PredictScheme.cpp index 7679029..b3e9a6c 100644 --- a/sapfor/experts/Sapfor_2017/_src/Predictor/PredictScheme.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Predictor/PredictScheme.cpp @@ -18,12 +18,23 @@ #include "../Utils/SgUtils.h" #include "../DirectiveProcessing/directive_parser.h" #include "../Distribution/DvmhDirective.h" +#include "../GraphLoop/graph_loops_func.h" +#include "../ExpressionTransform/expr_transform.h" +#include "../DirectiveProcessing/directive_parser.h" +#include "../LoopAnalyzer/loop_analyzer.h" +#include "../CFGraph/CFGraph.h" + +#include "json.hpp" using std::map; using std::string; using std::vector; using std::set; using std::ofstream; +using std::pair; +using std::tuple; + +using json = nlohmann::json; static void fillParallel(SgExpression *exp, ParallelStats &parStats, int &totalScoreComm) { @@ -152,8 +163,25 @@ static void calculateForParallelLoop(SgStatement* loop, const map>& allFuncInfo, const map>& gCovInfo) { + + json cluster; + json program; + + cluster["cluster_info"] = { {"num_nodes", 0}, + {"cores_per_node", 0}, + {"threads_per_node", 0}, + {"memory_per_node_gb", 0}, + {"network_bandwidth_gbps", 0}, + {"network_latency_ms", 0} + }; + + program["program_info"]["sequential_execution_time_sec"] = 0.0; + program["program_info"]["launch_grid"] = { {"dimensions", {0, 0, 0} }, {"total_processes", 0} }; + uint64_t total_exec_count = 0; uint64_t parallel_exec_count = 0; uint64_t count_of_parallel_lines = 0; @@ -226,17 +254,321 @@ void calculateStatsForPredictor(const map>& allFuncInf __spf_print(1, " average_parallel_exec %.16e\n", parallel_exec_count / (double)count_of_parallel_lines); __spf_print(1, " parallel_rate %.16e\n", parallel_exec_count / (double)total_exec_count); - ofstream stats("stats.csv"); - stats << "average_parallel_exec;" << parallel_exec_count / (double)count_of_parallel_lines << std::endl; - stats << "parallel_rate;" << parallel_exec_count / (double)total_exec_count << std::endl; - stats.close(); + program["program_info"]["average_parallel_line_executions"] = parallel_exec_count / (double)count_of_parallel_lines; + program["program_info"]["parallel_execution_fraction"] = parallel_exec_count / (double)total_exec_count; + + info = { cluster, program }; } -void parseDvmDirForPredictor(const map>& allFuncInfo, +static const Gcov_info& getInfo(SgStatement* st, const map &gcov) +{ + auto stat = st; + while (isDVM_stat(stat)) + stat = stat->lexPrev(); + int line = stat->lineNumber(); // XXX + + auto list = st->expr(1); + auto it = gcov.find(line); + auto& info = it->second; + if (info.getNumLine() != line) + { + __spf_print(1, "bad gcov info\n"); + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + } + + return info; +} + +static json parseDistribution(const map& byPos, SgSymbol* arr, SgExpression* list, int line) +{ + json dist; + auto array = getArrayFromDeclarated(declaratedInStmt(arr), arr->identifier()); + if (array == NULL || byPos.find(array) == byPos.end()) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + + dist["line"] = line; + dist["array_id"] = byPos.at(array); + + while (list) + { + dist["distribution_spec"].push_back(list->lhs()->unparse()); + list = list->rhs(); + } + return dist; +} + +static json parseAlign(const map& byPos, SgSymbol* srcArr, SgSymbol* tgtArr, + SgExpression *listSrc, SgExpression* listTgt, int line) +{ + json align; + + auto arraySrc = getArrayFromDeclarated(declaratedInStmt(srcArr), srcArr->identifier()); + if (arraySrc == NULL || byPos.find(arraySrc) == byPos.end()) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + + auto arrayTgt = getArrayFromDeclarated(declaratedInStmt(tgtArr), tgtArr->identifier()); + if (arrayTgt == NULL || byPos.find(arrayTgt) == byPos.end()) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + + align["line"] = line; + align["source_array_id"] = byPos.at(arraySrc); + align["target_array_id"] = byPos.at(arrayTgt); + + vector> srcSymbs; + auto list = listSrc; + while (list) + { + srcSymbs.push_back({ list->lhs()->unparse(), list->lhs()->symbol() }); + list = list->rhs(); + } + + vector> coefs(srcSymbs.size()); + list = listTgt; + while (list) + { + auto exp = list->lhs(); + bool has = false; + for (int z = 0; z < srcSymbs.size(); ++z) + { + has = recSymbolFind(exp, srcSymbs[z].first, VAR_REF); + if (has) + { + getCoefsOfSubscript(coefs[z], exp, srcSymbs[z].second); + if (coefs[z].first == 0) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + break; + } + } + list = list->rhs(); + } + + for (int z = 0; z < coefs.size(); ++z) + { + if (coefs[z].first == 0) + continue; + if (coefs[z].second) + align["rules"].push_back({ z, coefs[z].first }); + else + align["rules"].push_back({ z, coefs[z].first, coefs[z].second }); + } + return align; +} + +static SgStatement* findBefore(SgStatement* st) +{ + while (st) + { + st = st->lexPrev(); + + if (isSgProgHedrStmt(st)) + break; + if (isDVM_stat(st) || isSPF_stat(st)) + continue; + if (isSgExecutableStatement(st)) + break; + } + return st; +} + +static void fillAcrossShadow(vector, vector>>>& dirs, SgStatement *st, + const map& byPos, const string& type, json& typed, json& parallel) +{ + for (auto& dir : dirs) + { + auto& symb = dir.first; + auto& access = dir.second; + + DIST::Array* arr = getArrayFromDeclarated(declaratedInStmt(symb.first), symb.first->identifier()); + if (arr == NULL || byPos.find(arr) == byPos.end()) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + + json item; + item["line"] = st->lineNumber(); + item["array_id"] = byPos.at(arr); + item["communication_pattern"] = "NEAREST_NEIGHBOR"; + + if (access.size()) + { + for (int z = 0; z < access.size(); ++z) + item["width"].push_back({ z, access[z].first, access[z].second }); + } + else + { + auto& spec = arr->GetShadowSpec(); + //TODO: analyze spec of array for shadow + for (int z = 0; z < spec.size(); ++z) + item["width"].push_back({ z, 1, 1 }); + } + + typed.push_back(item); + parallel["shadow_renews"].push_back(typed.size() - 1); + } +} + +static void parallelDir(const map& byPos, SgExpression* spec, SgSymbol* arr, SgExpression* arrSpec, + SgStatement* st, SgExpression* clauses, const map& gcov, json& directives, + const map& commonBlocks, const map>& allFuncInfo) +{ + json parallel; + + json& shadow_renew = directives["shadow_renew"]; + json& reduction = directives["reduction"]; + json& remote_access = directives["remote_access"]; + json& across = directives["across"]; + + vector> loopSymbs; + auto list = spec; + while (list) + { + loopSymbs.push_back({ list->lhs()->unparse(), list->lhs()->symbol() }); + list = list->rhs(); + } + + parallel["line"] = st->lineNumber(); + parallel["loops_count"] = loopSymbs.size(); + + SgStatement* loop = isSgForStmt(st->lexNext()); + if (loop == NULL) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + SgStatement* lastNode = loop->lastNodeOfStmt(); + + SgStatement* before = findBefore(loop); + if (before == NULL) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + + vector execs; + for (int z = 0; z < loopSymbs.size(); ++z) + { + auto& info = getInfo(loop, gcov); + execs.push_back(info.getExecutedCount()); + loop = loop->lexNext(); + } + + for (int z = execs.size() - 1; z > 0; --z) + execs[z] /= execs[z - 1]; + + auto& info = getInfo(before, gcov); + execs[0] /= info.getExecutedCount(); + + parallel["iterations_count"] = execs; + + DvmDirective directive; + fillInfoFromDirective(new Statement(st), directive); + + vector empty; + parallel["shadow_renews"] = empty; + parallel["reductions"] = empty; + parallel["remote_accesses"] = empty; + parallel["acrosses"] = empty; + + for (auto& op : directive.reduction) + { + for (auto& var : op.second) + { + json item; + item["line"] = st->lineNumber(); + item["operation"] = op.first; + if (!isSgArrayType(var->type())) + { + item["reduction_type"] = "SCALAR"; + item["size_bytes"] = getSizeOfType(var->type()); + item["elements_count"] = 1; + } + else + { + item["reduction_type"] = "ARRAY"; + auto type = isSgArrayType(var->type()); + item["size_bytes"] = getSizeOfType(type->baseType()); + item["elements_count"] = type->dimension(); + } + + reduction.push_back(item); + parallel["reductions"].push_back(reduction.size() - 1); + } + } + + fillAcrossShadow(directive.shadowRenew, st, byPos, "shadow_renews", shadow_renew, parallel); + fillAcrossShadow(directive.across, st, byPos, "acrosses", across, parallel); + + auto func = getFuncStat(st); + auto& funcInFile = allFuncInfo.at(st->fileName()); + FuncInfo* currF = NULL; + for (auto& elem : funcInFile) + if (elem->funcName == func->symbol()->identifier()) + currF = elem; + + if (currF == NULL) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + + auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, true, false, false, true), commonBlocks, allFuncInfo); + if (cfg.size() != 1) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + //TODO IP analysis + + unsigned countOfAccess = 0; + unsigned countOfOps = 0; + + if (cfg.find(currF) == cfg.end()) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + + //skip all parallel loops + loop = st->lexNext(); + for (int z = 0; z < loopSymbs.size(); ++z) + loop = loop->lexNext(); + + int lineStart = loop->lineNumber(); + int lineEnd = lastNode->lexNext()->lineNumber(); + + //dumpCFG(cfg, false); + //TODO: calculate access in bytes + for (auto& block : cfg[currF]) + { + for (auto& ir : block->getInstructions()) + { + auto line = ir->getLine(); + if (line < lineStart || line >= lineEnd) + continue; + + auto inst = ir->getInstruction(); + if (inst->isAccess()) + countOfAccess++; + if (inst->isArith()) + countOfOps++; + //printf("%s %d %d\n", inst->dump().c_str(), inst->isAccess(), inst->isArith()); + } + } + deleteCFG(cfg); + + parallel["computational_intensity"] = countOfOps > 0 ? ((double)countOfOps / (double)countOfAccess) : 0; + + directives["parallel"].push_back(parallel); +} + +void parseDvmDirForPredictor(const map, pair>& declaredArrays, + const map& commonBlocks, + const map>& allFuncInfo, const map>& gCovInfo) { - ofstream dirs("dirs.csv"); + auto& program = info[1]["program_info"]; + map byPos; + int pos = 0; + for (auto& arrayElem : declaredArrays) + { + json jArray; + auto& array = arrayElem.second.first; + auto sizes = array->GetSizes(); + for (int z = 0; z < array->GetDimSize(); ++z) + jArray["dimensions"].push_back(sizes[z].second - sizes[z].first + 1); + + jArray["name"] = array->GetName(); + jArray["element_size_bytes"] = array->GetTypeSize(); + + program["arrays_info"].push_back(jArray); + byPos[array] = pos++; + } + + auto& directives = program["directives"]; for (auto& byFile : allFuncInfo) { int ok = SgFile::switchToFile(byFile.first); @@ -260,48 +592,43 @@ void parseDvmDirForPredictor(const map>& allFuncInfo, SgExpression* list; SgExpression* dup; auto line = 0; - + switch (st->variant()) { case DVM_PARALLEL_ON_DIR: - { - auto stat = st; - while (isDVM_stat(stat)) - stat = stat->lexPrev(); - line = stat->lineNumber(); // XXX - - list = st->expr(1); - auto it = gcov.find(line); - auto& info = it->second; - if (info.getNumLine() != line) - { - __spf_print(1, "bad gcov info\n"); - printInternalError(convertFileName(__FILE__).c_str(), __LINE__); - } - - dirs << info.getExecutedCount() << ";" << "PARALLEL;" << st->expr(2)->unparse() << ";" << st->expr(0)->unparse() << ";"; - while (list) - { - dirs << list->lhs()->unparse() << ";"; - list = list->rhs(); - } - - dirs << std::endl; - } + parallelDir(byPos, st->expr(2), st->expr(0)->symbol(), st->expr(0)->lhs(), st, st->expr(1), gcov, directives, commonBlocks, allFuncInfo); break; case DVM_VAR_DECL: // TODO - dup = st->expr(2)->lhs()->copyPtr(); - dup->setLhs(NULL); - dirs << "1;" << dup->unparse() << ";" << st->expr(2)->lhs()->lhs()->unparse() << ";" << st->expr(0)->unparse() << ";\n"; + { + auto type = st->expr(2)->lhs(); + if (type->variant() == DISTRIBUTE_OP) + { + list = st->expr(0); + while (list) + { + directives["distribute"].push_back(parseDistribution(byPos, list->lhs()->symbol(), type->lhs(), st->lineNumber())); + list = list->rhs(); + } + } + else if (type->variant() == ALIGN_OP) + { + list = st->expr(0); + while (list) + { + directives["align"].push_back(parseAlign(byPos, list->lhs()->symbol(), type->rhs()->symbol(), type->lhs(), type->rhs()->lhs(), st->lineNumber())); + list = list->rhs(); + } + } + } break; case DVM_DISTRIBUTE_DIR: - dirs << "1;" << "DISTRIBUTE;" << st->expr(1)->unparse() << ";" << st->expr(0)->unparse() << ";\n"; - break; + directives["distribute"].push_back(parseDistribution(byPos, st->expr(0)->lhs()->symbol(), st->expr(1), st->lineNumber())); + break; case DVM_ALIGN_DIR: - dirs << "1;" << "ALIGN;" << st->expr(0)->unparse() << "(" << st->expr(1)->unparse() << ");" << st->expr(2)->unparse() << ";\n"; + directives["align"].push_back(parseAlign(byPos, st->expr(0)->lhs()->symbol(), st->expr(2)->symbol(), st->expr(1), st->expr(2)->lhs(), st->lineNumber())); break; case DVM_SHADOW_DIR: - dirs << "1;" << "SHADOW;" << st->expr(0)->unparse() << "(" << st->expr(1)->unparse() << ");\n"; + //dirs << "1;" << "SHADOW;" << st->expr(0)->unparse() << "(" << st->expr(1)->unparse() << ");\n"; break; case DVM_REMOTE_ACCESS_DIR: { @@ -314,14 +641,14 @@ void parseDvmDirForPredictor(const map>& allFuncInfo, printInternalError(convertFileName(__FILE__).c_str(), __LINE__); } - dirs << info.getExecutedCount() << ";" << "REMOTE_ACCESS;"; + //dirs << info.getExecutedCount() << ";" << "REMOTE_ACCESS;"; list = st->expr(0); while (list) { - dirs << list->lhs()->unparse() << ";"; + //dirs << list->lhs()->unparse() << ";"; list = list->rhs(); } - dirs << "\n"; + //dirs << "\n"; break; } default: @@ -332,5 +659,10 @@ void parseDvmDirForPredictor(const map>& allFuncInfo, } } - dirs.close(); + //printf("%s\n", info.dump(2).c_str()); + + ofstream dump("info.json"); + dump << info.dump(2) << std::endl; + dump.flush(); + dump.close(); } \ No newline at end of file diff --git a/sapfor/experts/Sapfor_2017/_src/Predictor/PredictScheme.h b/sapfor/experts/Sapfor_2017/_src/Predictor/PredictScheme.h index a29c73a..b444aa1 100644 --- a/sapfor/experts/Sapfor_2017/_src/Predictor/PredictScheme.h +++ b/sapfor/experts/Sapfor_2017/_src/Predictor/PredictScheme.h @@ -55,4 +55,4 @@ public: void processFileToPredict(SgFile *file, PredictorStats &predictorCounts); void calculateStatsForPredictor(const std::map>& allFuncInfo, const std::map>& gCovInfo); -void parseDvmDirForPredictor(const std::map>& allFuncInfo, const std::map>& gCovInfo); \ No newline at end of file +void parseDvmDirForPredictor(const std::map, std::pair>& declaredArrays, const std::map& commonBlocks, const std::map>& allFuncInfo, const std::map>& gCovInfo); \ No newline at end of file diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp index b9e4bbb..5addf9a 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp @@ -1570,9 +1570,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne internalExit = 1; } else if (curr_regime == REMOVE_DIST_ARRAYS_FROM_IO) - { replaceDistributedArraysInIO(parallelRegions, allFuncInfo, SPF_messages, newCopyDeclToIncl); - } else if (curr_regime == LOOP_GRAPH) { if (keepFiles) @@ -1902,7 +1900,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne else if (curr_regime == GET_STATS_FOR_PREDICTOR) { calculateStatsForPredictor(allFuncInfo, gCovInfo); - parseDvmDirForPredictor(allFuncInfo, gCovInfo); + parseDvmDirForPredictor(declaredArrays, commonBlocks, allFuncInfo, gCovInfo); } const float elapsed = duration_cast(high_resolution_clock::now() - timeForPass).count() / 1000.; diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/version.h b/sapfor/experts/Sapfor_2017/_src/Utils/version.h index ca75ac3..2ea0d82 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/version.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2366" +#define VERSION_SPF "2367" diff --git a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp index 1285cdf..7caba1e 100644 --- a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp +++ b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp @@ -1732,6 +1732,14 @@ int SPF_ResolveParallelRegionConflicts(void*& context, int winHandler, short *op return simpleTransformPass(RESOLVE_PAR_REGIONS, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize); } +int SPF_RemoveDistArraysFromIO(void*& context, int winHandler, short* options, short* projName, short* folderName, short*& output, + int*& outputSize, short*& outputMessage, int*& outputMessageSize) +{ + MessageManager::clearCache(); + MessageManager::setWinHandler(winHandler); + return simpleTransformPass(REMOVE_DIST_ARRAYS_FROM_IO, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize); + +} int SPF_PrivateExpansion(void*& context, int winHandler, short *options, short *projName, short *folderName, short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize) { @@ -2583,6 +2591,8 @@ const wstring Sapfor_RunTransformation(const char* transformName_c, const char* retCode = SPF_InsertIncludesPass(context, winHandler, optSh, projSh, fold, (char*)addOpt_c, output, outputSize, outputMessage, outputMessageSize); else if (whichRun == "SPF_ResolveParallelRegionConflicts") retCode = SPF_ResolveParallelRegionConflicts(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); + else if (whichRun == "SPF_RemoveDistArraysFromIO") + retCode = SPF_RemoveDistArraysFromIO(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); else if (whichRun == "SPF_LoopEndDoConverterPass") retCode = SPF_LoopEndDoConverterPass(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); else if (whichRun == "SPF_CreateParallelVariant")