added simple implementation for GET_STATS_FOR_PREDICTOR pass

This commit is contained in:
ALEXks
2024-11-14 12:37:38 +03:00
parent b163958711
commit c63c4dd46c
8 changed files with 473 additions and 59 deletions

View File

@@ -162,6 +162,35 @@ namespace SAPFOR
SgExpression* getExpression() const { return ex; } SgExpression* getExpression() const { return ex; }
int getLine() const { return st ? st->lineNumber() : -1; }
bool isAccess() const
{
std::set<CFG_OP> 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<CFG_OP> 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 int getNextInstrNum() { return lastNumInstr; }
static void shiftNextInstrNum(int byNum) { lastNumInstr += byNum; } static void shiftNextInstrNum(int byNum) { lastNumInstr += byNum; }
@@ -296,6 +325,8 @@ namespace SAPFOR
void setHeader() { header = true; } void setHeader() { header = true; }
bool isHeader() const { return header; } bool isHeader() const { return header; }
int getLine() const { return current->getLine(); }
~IR_Block() { delete current; } ~IR_Block() { delete current; }
}; };

View File

@@ -122,15 +122,20 @@ extern map<string, vector<Messages>> SPF_messages;
//for simple reduction //for simple reduction
template<typename fillType> template<typename fillType>
void fillReductionsFromComment(Statement *stIn, map<string, set<fillType>> &reduction, bool moduleNameAdd) void fillReductionsFromComment(Statement *stIn, map<string, set<fillType>> &reduction, bool moduleNameAdd, int type)
{ {
bool error = false; bool error = false;
if (stIn) if (stIn)
{ {
SgStatement *st = stIn->GetOriginal(); 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) while (exprList)
{ {
if (exprList->lhs()->variant() == REDUCTION_OP) if (exprList->lhs()->variant() == REDUCTION_OP)
@@ -188,19 +193,24 @@ void fillReductionsFromComment(Statement *stIn, map<string, set<fillType>> &redu
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
} }
template void fillReductionsFromComment(Statement *st, map<string, set<string>> &reduction, bool); template void fillReductionsFromComment(Statement *st, map<string, set<string>> &reduction, bool, int);
template void fillReductionsFromComment(Statement *st, map<string, set<Symbol*>> &reduction, bool); template void fillReductionsFromComment(Statement *st, map<string, set<Symbol*>> &reduction, bool, int);
//for min/max loc reduction //for min/max loc reduction
template<typename fillType> template<typename fillType>
void fillReductionsFromComment(Statement *stIn, map<string, set<tuple<fillType, fillType, int>>> &reduction, bool moduleNameAdd) void fillReductionsFromComment(Statement *stIn, map<string, set<tuple<fillType, fillType, int>>> &reduction, bool moduleNameAdd, int type)
{ {
if (stIn) if (stIn)
{ {
SgStatement *st = stIn->GetOriginal(); 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) while (exprList)
{ {
if (exprList->lhs()->variant() == REDUCTION_OP) if (exprList->lhs()->variant() == REDUCTION_OP)
@@ -241,8 +251,8 @@ void fillReductionsFromComment(Statement *stIn, map<string, set<tuple<fillType,
} }
} }
template void fillReductionsFromComment(Statement *st, map<string, set<tuple<string, string, int>>> &reduction, bool); template void fillReductionsFromComment(Statement *st, map<string, set<tuple<string, string, int>>> &reduction, bool, int);
template void fillReductionsFromComment(Statement *st, map<string, set<tuple<Symbol*, Symbol*, int>>> &reduction, bool); template void fillReductionsFromComment(Statement *st, map<string, set<tuple<Symbol*, Symbol*, int>>> &reduction, bool, int);
void fillParameterFromComment(Statement *stIn, vector<pair<Expression*, Expression*>> &assigns) void fillParameterFromComment(Statement *stIn, vector<pair<Expression*, Expression*>> &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<pair<Symbol*, string>, 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) int getCoverPropertyFromComment(Statement* stIn)
{ {
if (stIn) if (stIn)

View File

@@ -8,16 +8,26 @@
#include "../GraphLoop/graph_loops.h" #include "../GraphLoop/graph_loops.h"
#include "../Distribution/DvmhDirective.h" #include "../Distribution/DvmhDirective.h"
struct DvmDirective
{
std::set<Symbol*> corners;
std::vector<std::pair<std::pair<Symbol*, std::string>, std::vector<std::pair<int, int>>>> shadowRenew, across;
std::map<std::pair<std::pair<std::string, std::string>, std::string>, Expression*> remoteAccess;
std::map<std::string, std::set<Symbol*>> reduction;
std::map<std::string, std::set<std::tuple<Symbol*, Symbol*, int>>> reductionLoc;
};
bool isSPF_NoInline(Statement *stPrev); bool isSPF_NoInline(Statement *stPrev);
template<typename fillType> template<typename fillType>
void fillPrivatesFromComment(Statement *st, std::set<fillType> &privates, int type = -1); void fillPrivatesFromComment(Statement *st, std::set<fillType> &privates, int type = -1);
template<typename fillType> template<typename fillType>
void fillReductionsFromComment(Statement *st, std::map<std::string, std::set<fillType>> &reduction, bool moduleNameAdd = false); void fillReductionsFromComment(Statement *st, std::map<std::string, std::set<fillType>> &reduction, bool moduleNameAdd = false, int type = SPF_ANALYSIS_DIR);
template<typename fillType> template<typename fillType>
void fillReductionsFromComment(Statement *st, std::map<std::string, std::set<std::tuple<fillType, fillType, int>>> &reduction, bool moduleNameAdd = false); void fillReductionsFromComment(Statement *st, std::map<std::string, std::set<std::tuple<fillType, fillType, int>>> &reduction, bool moduleNameAdd = false, int type = SPF_ANALYSIS_DIR);
void fillParameterFromComment(Statement *st, std::vector<std::pair<Expression*, Expression*>> &assigns); void fillParameterFromComment(Statement *st, std::vector<std::pair<Expression*, Expression*>> &assigns);
@@ -32,6 +42,7 @@ void fillRemoteFromComment(Statement *st, std::map<std::pair<fillType, std::stri
void fillAcrossInfoFromDirectives(const LoopGraph *loopInfo, std::vector<std::pair<std::pair<std::string, std::string>, std::vector<std::pair<int, int>>>> &acrossInfo); void fillAcrossInfoFromDirectives(const LoopGraph *loopInfo, std::vector<std::pair<std::pair<std::string, std::string>, std::vector<std::pair<int, int>>>> &acrossInfo);
void fillInfoFromDirectives(const LoopGraph *loopInfo, ParallelDirective *directive); void fillInfoFromDirectives(const LoopGraph *loopInfo, ParallelDirective *directive);
void fillInfoFromDirective(Statement* parallel_on, DvmDirective& directive);
void fillFissionPrivatesExpansionFromComment(Statement *stIn, std::vector<std::string> &vars); void fillFissionPrivatesExpansionFromComment(Statement *stIn, std::vector<std::string> &vars);

View File

@@ -18,12 +18,23 @@
#include "../Utils/SgUtils.h" #include "../Utils/SgUtils.h"
#include "../DirectiveProcessing/directive_parser.h" #include "../DirectiveProcessing/directive_parser.h"
#include "../Distribution/DvmhDirective.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::map;
using std::string; using std::string;
using std::vector; using std::vector;
using std::set; using std::set;
using std::ofstream; using std::ofstream;
using std::pair;
using std::tuple;
using json = nlohmann::json;
static void fillParallel(SgExpression *exp, ParallelStats &parStats, int &totalScoreComm) static void fillParallel(SgExpression *exp, ParallelStats &parStats, int &totalScoreComm)
{ {
@@ -152,8 +163,25 @@ static void calculateForParallelLoop(SgStatement* loop, const map<int, Gcov_info
} }
} }
static json info;
void calculateStatsForPredictor(const map<string, vector<FuncInfo*>>& allFuncInfo, void calculateStatsForPredictor(const map<string, vector<FuncInfo*>>& allFuncInfo,
const map<string, map<int, Gcov_info>>& gCovInfo) { const map<string, map<int, Gcov_info>>& 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 total_exec_count = 0;
uint64_t parallel_exec_count = 0; uint64_t parallel_exec_count = 0;
uint64_t count_of_parallel_lines = 0; uint64_t count_of_parallel_lines = 0;
@@ -226,17 +254,321 @@ void calculateStatsForPredictor(const map<string, vector<FuncInfo*>>& allFuncInf
__spf_print(1, " average_parallel_exec %.16e\n", parallel_exec_count / (double)count_of_parallel_lines); __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); __spf_print(1, " parallel_rate %.16e\n", parallel_exec_count / (double)total_exec_count);
ofstream stats("stats.csv"); program["program_info"]["average_parallel_line_executions"] = parallel_exec_count / (double)count_of_parallel_lines;
stats << "average_parallel_exec;" << parallel_exec_count / (double)count_of_parallel_lines << std::endl; program["program_info"]["parallel_execution_fraction"] = parallel_exec_count / (double)total_exec_count;
stats << "parallel_rate;" << parallel_exec_count / (double)total_exec_count << std::endl;
stats.close(); info = { cluster, program };
} }
void parseDvmDirForPredictor(const map<string, vector<FuncInfo*>>& allFuncInfo, static const Gcov_info& getInfo(SgStatement* st, const map<int, Gcov_info> &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<DIST::Array*, int>& 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<DIST::Array*, int>& 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<pair<string, SgSymbol*>> srcSymbs;
auto list = listSrc;
while (list)
{
srcSymbs.push_back({ list->lhs()->unparse(), list->lhs()->symbol() });
list = list->rhs();
}
vector<pair<int, int>> 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<pair<pair<Symbol*, string>, vector<pair<int, int>>>>& dirs, SgStatement *st,
const map<DIST::Array*, int>& 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<DIST::Array*, int>& byPos, SgExpression* spec, SgSymbol* arr, SgExpression* arrSpec,
SgStatement* st, SgExpression* clauses, const map<int, Gcov_info>& gcov, json& directives,
const map<string, CommonBlock*>& commonBlocks, const map<string, vector<FuncInfo*>>& allFuncInfo)
{
json parallel;
json& shadow_renew = directives["shadow_renew"];
json& reduction = directives["reduction"];
json& remote_access = directives["remote_access"];
json& across = directives["across"];
vector<pair<string, SgSymbol*>> 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<int64_t> 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<int> 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<tuple<int, string, string>, pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays,
const map<string, CommonBlock*>& commonBlocks,
const map<string, vector<FuncInfo*>>& allFuncInfo,
const map<string, map<int, Gcov_info>>& gCovInfo) const map<string, map<int, Gcov_info>>& gCovInfo)
{ {
ofstream dirs("dirs.csv"); auto& program = info[1]["program_info"];
map<DIST::Array*, int> 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) for (auto& byFile : allFuncInfo)
{ {
int ok = SgFile::switchToFile(byFile.first); int ok = SgFile::switchToFile(byFile.first);
@@ -260,48 +592,43 @@ void parseDvmDirForPredictor(const map<string, vector<FuncInfo*>>& allFuncInfo,
SgExpression* list; SgExpression* list;
SgExpression* dup; SgExpression* dup;
auto line = 0; auto line = 0;
switch (st->variant()) switch (st->variant())
{ {
case DVM_PARALLEL_ON_DIR: case DVM_PARALLEL_ON_DIR:
{ parallelDir(byPos, st->expr(2), st->expr(0)->symbol(), st->expr(0)->lhs(), st, st->expr(1), gcov, directives, commonBlocks, allFuncInfo);
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;
}
break; break;
case DVM_VAR_DECL: // TODO case DVM_VAR_DECL: // TODO
dup = st->expr(2)->lhs()->copyPtr(); {
dup->setLhs(NULL); auto type = st->expr(2)->lhs();
dirs << "1;" << dup->unparse() << ";" << st->expr(2)->lhs()->lhs()->unparse() << ";" << st->expr(0)->unparse() << ";\n"; 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; break;
case DVM_DISTRIBUTE_DIR: case DVM_DISTRIBUTE_DIR:
dirs << "1;" << "DISTRIBUTE;" << st->expr(1)->unparse() << ";" << st->expr(0)->unparse() << ";\n"; directives["distribute"].push_back(parseDistribution(byPos, st->expr(0)->lhs()->symbol(), st->expr(1), st->lineNumber()));
break; break;
case DVM_ALIGN_DIR: 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; break;
case DVM_SHADOW_DIR: 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; break;
case DVM_REMOTE_ACCESS_DIR: case DVM_REMOTE_ACCESS_DIR:
{ {
@@ -314,14 +641,14 @@ void parseDvmDirForPredictor(const map<string, vector<FuncInfo*>>& allFuncInfo,
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
} }
dirs << info.getExecutedCount() << ";" << "REMOTE_ACCESS;"; //dirs << info.getExecutedCount() << ";" << "REMOTE_ACCESS;";
list = st->expr(0); list = st->expr(0);
while (list) while (list)
{ {
dirs << list->lhs()->unparse() << ";"; //dirs << list->lhs()->unparse() << ";";
list = list->rhs(); list = list->rhs();
} }
dirs << "\n"; //dirs << "\n";
break; break;
} }
default: default:
@@ -332,5 +659,10 @@ void parseDvmDirForPredictor(const map<string, vector<FuncInfo*>>& 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();
} }

View File

@@ -55,4 +55,4 @@ public:
void processFileToPredict(SgFile *file, PredictorStats &predictorCounts); void processFileToPredict(SgFile *file, PredictorStats &predictorCounts);
void calculateStatsForPredictor(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo); void calculateStatsForPredictor(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo);
void parseDvmDirForPredictor(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo); void parseDvmDirForPredictor(const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays, const std::map<std::string, CommonBlock*>& commonBlocks, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo);

View File

@@ -1570,9 +1570,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
internalExit = 1; internalExit = 1;
} }
else if (curr_regime == REMOVE_DIST_ARRAYS_FROM_IO) else if (curr_regime == REMOVE_DIST_ARRAYS_FROM_IO)
{
replaceDistributedArraysInIO(parallelRegions, allFuncInfo, SPF_messages, newCopyDeclToIncl); replaceDistributedArraysInIO(parallelRegions, allFuncInfo, SPF_messages, newCopyDeclToIncl);
}
else if (curr_regime == LOOP_GRAPH) else if (curr_regime == LOOP_GRAPH)
{ {
if (keepFiles) 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) else if (curr_regime == GET_STATS_FOR_PREDICTOR)
{ {
calculateStatsForPredictor(allFuncInfo, gCovInfo); calculateStatsForPredictor(allFuncInfo, gCovInfo);
parseDvmDirForPredictor(allFuncInfo, gCovInfo); parseDvmDirForPredictor(declaredArrays, commonBlocks, allFuncInfo, gCovInfo);
} }
const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.; const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2366" #define VERSION_SPF "2367"

View File

@@ -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); 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 SPF_PrivateExpansion(void*& context, int winHandler, short *options, short *projName, short *folderName, short *&output,
int *&outputSize, short *&outputMessage, int *&outputMessageSize) 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); retCode = SPF_InsertIncludesPass(context, winHandler, optSh, projSh, fold, (char*)addOpt_c, output, outputSize, outputMessage, outputMessageSize);
else if (whichRun == "SPF_ResolveParallelRegionConflicts") else if (whichRun == "SPF_ResolveParallelRegionConflicts")
retCode = SPF_ResolveParallelRegionConflicts(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); 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") else if (whichRun == "SPF_LoopEndDoConverterPass")
retCode = SPF_LoopEndDoConverterPass(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); retCode = SPF_LoopEndDoConverterPass(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize);
else if (whichRun == "SPF_CreateParallelVariant") else if (whichRun == "SPF_CreateParallelVariant")