added statistics, fixed shadow, fixed inliner, and etc.
This commit is contained in:
@@ -1118,7 +1118,7 @@ void EnterDataRegionForLocalVariables(SgStatement *st, SgStatement *first_exec,
|
||||
{
|
||||
if (!el->lhs()) continue;
|
||||
SgSymbol *sym = el->lhs()->symbol();
|
||||
if (sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !(sym->attributes() & HEAP_BIT)) // //!(el->lhs()->symbol()->attributes() & PARAMETER_BIT) )
|
||||
if (sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT)) // //!(el->lhs()->symbol()->attributes() & PARAMETER_BIT) )
|
||||
{
|
||||
if ((HAS_SAVE_ATTR(sym) || IN_DATA(sym)) && IS_ARRAY(sym))
|
||||
newst = doIfThenForDataRegion(DataRegionVar(sym), st, DataEnter(new SgVarRefExp(sym),ConstRef(0)));
|
||||
@@ -1128,7 +1128,7 @@ void EnterDataRegionForLocalVariables(SgStatement *st, SgStatement *first_exec,
|
||||
}
|
||||
for (sl = acc_registered_list; sl; sl = sl->next)
|
||||
{
|
||||
if (sl->symb->variant() != CONST_NAME && IS_LOCAL_VAR(sl->symb) && !IS_ALLOCATABLE(sl->symb) && !HEADER(sl->symb)) //!(sl->symb->attributes() & PARAMETER_BIT))
|
||||
if (sl->symb->variant() != CONST_NAME && IS_LOCAL_VAR(sl->symb) && !IS_ALLOCATABLE(sl->symb) && !IS_POINTER_F90(sl->symb) && !HEADER(sl->symb)) //!(sl->symb->attributes() & PARAMETER_BIT))
|
||||
{
|
||||
if ((HAS_SAVE_ATTR(sl->symb) || IN_DATA(sl->symb)) && IS_ARRAY(sl->symb))
|
||||
newst = doIfThenForDataRegion(DataRegionVar(sl->symb), st, DataEnter(new SgVarRefExp(sl->symb),ConstRef(0)));
|
||||
@@ -1149,7 +1149,7 @@ void ExitDataRegionForLocalVariables(SgStatement *st, int is)
|
||||
{
|
||||
if (!el->lhs()) continue;
|
||||
SgSymbol *sym = el->lhs()->symbol();
|
||||
if (sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !(sym->attributes() & HEAP_BIT)) // //!(el->lhs()->symbol()->attributes() & PARAMETER_BIT) )
|
||||
if (sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT)) // //!(el->lhs()->symbol()->attributes() & PARAMETER_BIT) )
|
||||
{
|
||||
if ((HAS_SAVE_ATTR(sym) || IN_DATA(sym)) && IS_ARRAY(sym))
|
||||
continue;
|
||||
@@ -1160,7 +1160,7 @@ void ExitDataRegionForLocalVariables(SgStatement *st, int is)
|
||||
}
|
||||
for (sl = acc_registered_list; sl; sl = sl->next)
|
||||
{
|
||||
if (sl->symb->variant() != CONST_NAME && IS_LOCAL_VAR(sl->symb) && !IS_ALLOCATABLE(sl->symb) && !HEADER(sl->symb)) //!(sl->symb->attributes() & PARAMETER_BIT))
|
||||
if (sl->symb->variant() != CONST_NAME && IS_LOCAL_VAR(sl->symb) && !IS_ALLOCATABLE(sl->symb) && !IS_POINTER_F90(sl->symb) && !HEADER(sl->symb)) //!(sl->symb->attributes() & PARAMETER_BIT))
|
||||
{
|
||||
if ((HAS_SAVE_ATTR(sl->symb) || IN_DATA(sl->symb)) && IS_ARRAY(sl->symb))
|
||||
continue;
|
||||
|
||||
@@ -309,7 +309,7 @@ static void replaceShadowByRemote(SgExpression *specInDir, SgStatement *stat,
|
||||
|
||||
void devourShadowByRemote(void *file_, const map<string, FuncInfo*>& funcMap, const vector<LoopGraph*>& loops,
|
||||
const map<DIST::Array*, set<DIST::Array*>> &arrayLinksByFuncCalls)
|
||||
{
|
||||
{
|
||||
SgFile* file = static_cast<SgFile*>(file_);
|
||||
map<int, LoopGraph*> loopByLine;
|
||||
createMapLoopGraph(loops, loopByLine);
|
||||
|
||||
@@ -242,6 +242,44 @@ struct FuncInfo
|
||||
if (names.size() == 1)
|
||||
return *names.begin();
|
||||
|
||||
//try to find in next lvl calls
|
||||
for (auto& call : callsFromDetailed)
|
||||
{
|
||||
if (call.detailCallsFrom.second == line)
|
||||
{
|
||||
std::string name_next = call.detailCallsFrom.first;
|
||||
std::set<FuncInfo*> next, done;
|
||||
|
||||
for (auto& callFrom : callsFromV)
|
||||
if (callFrom->funcName == name_next)
|
||||
next.insert(callFrom);
|
||||
|
||||
done = next;
|
||||
while (next.size())
|
||||
{
|
||||
auto curr = next;
|
||||
next.clear();
|
||||
|
||||
for (auto& callFrom : curr)
|
||||
{
|
||||
for (auto& call : callFrom->callsFromDetailed)
|
||||
{
|
||||
if (call.detailCallsFrom.first == name)
|
||||
return call.detailCallsFrom.first;
|
||||
}
|
||||
|
||||
for (auto& callFromNext : callFrom->callsFromV)
|
||||
{
|
||||
if (done.find(callFromNext) == done.end())
|
||||
{
|
||||
next.insert(callFromNext);
|
||||
done.insert(callFromNext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1483,9 +1483,8 @@ static bool run_inliner(const map<string, FuncInfo*>& funcMap, set<SgStatement*>
|
||||
{
|
||||
wstring messageE, messageR;
|
||||
__spf_printToLongBuf(messageE, L"It is allowed to inline function only at execution code section.");
|
||||
#ifdef _WIN32
|
||||
__spf_printToLongBuf(messageR, R177);
|
||||
#endif
|
||||
|
||||
getObjectForFileFromMap(fileName.c_str(), SPF_messages).push_back(Messages(ERROR, insertPlace->lineNumber(), messageR, messageE, 2011));
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
@@ -1689,6 +1688,18 @@ static map<FuncInfo*, set<SgStatement*>> fillNextDeep(const set<SgStatement*>& i
|
||||
return nextInfo;
|
||||
}
|
||||
|
||||
static void addMessage(bool status, map<string, vector<Messages>>& SPF_messages, const string& fileName, const int line)
|
||||
{
|
||||
if (status == true)
|
||||
return;
|
||||
|
||||
wstring messageE, messageR;
|
||||
__spf_printToLongBuf(messageE, L"Function inlining failed with an error.");
|
||||
__spf_printToLongBuf(messageR, R193);
|
||||
|
||||
getObjectForFileFromMap(fileName.c_str(), SPF_messages).push_back(Messages(ERROR, line, messageR, messageE, 2020));
|
||||
}
|
||||
|
||||
static bool inliner(const string& fileName_in, const string& funcName, const int lineNumber,
|
||||
const map<string, vector<FuncInfo*>>& allFuncInfo, map<string, vector<Messages>>& SPF_messages,
|
||||
map<SgStatement*, set<SgSymbol*>>& newSymbsToDeclare, const map<string, CommonBlock*>& commonBlocks,
|
||||
@@ -1773,6 +1784,7 @@ static bool inliner(const string& fileName_in, const string& funcName, const int
|
||||
//1 level
|
||||
bool isInlined = run_inliner(funcMap, toInsert, SPF_messages, fileName, func, newSymbsToDeclare, point, commonBlocks);
|
||||
__spf_print(1, "%s\n", isInlined ? "done" : "fault");
|
||||
addMessage(isInlined, SPF_messages, fileName, lineNumber);
|
||||
|
||||
if (isInlined == false)
|
||||
{
|
||||
@@ -1807,6 +1819,8 @@ static bool inliner(const string& fileName_in, const string& funcName, const int
|
||||
__spf_print(1, " INLINE %s - ", next.first->funcName.c_str());
|
||||
bool isInlined = run_inliner(funcMap, next.second, SPF_messages, fileName, next.first, newSymbsToDeclare, point, commonBlocks);
|
||||
__spf_print(1, "%s\n", isInlined ? "done" : "fault");
|
||||
addMessage(isInlined, SPF_messages, fileName, lineNumber);
|
||||
|
||||
changed |= isInlined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,8 @@ static void calculate_for_parallel_loop(SgStatement* loop, const map<int, Gcov_i
|
||||
|
||||
void calculate_stats_for_predictor(const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
const map<string, map<int, Gcov_info>>& gCovInfo) {
|
||||
uint64_t paralle_exec_count = 0;
|
||||
uint64_t total_exec_count = 0;
|
||||
uint64_t parallel_exec_count = 0;
|
||||
uint64_t count_of_parallel_lines = 0;
|
||||
|
||||
for (auto& byFile : allFuncInfo) {
|
||||
@@ -170,7 +171,8 @@ void calculate_stats_for_predictor(const map<string, vector<FuncInfo*>>& allFunc
|
||||
for (auto& func : byFile.second) {
|
||||
SgStatement* stat = func->funcPointer->GetOriginal();
|
||||
|
||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext()) {
|
||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
||||
{
|
||||
uint64_t paralle_exec = 0;
|
||||
uint64_t lines_count = 0;
|
||||
|
||||
@@ -183,18 +185,44 @@ void calculate_stats_for_predictor(const map<string, vector<FuncInfo*>>& allFunc
|
||||
calculate_for_parallel_loop(loop, gcov, paralle_exec, lines_count);
|
||||
st = loop->lastNodeOfStmt();
|
||||
|
||||
paralle_exec_count += paralle_exec;
|
||||
parallel_exec_count += paralle_exec;
|
||||
count_of_parallel_lines += lines_count;
|
||||
|
||||
__spf_print(1, " PAR LOOP [%d %s] total exec %llu, total exec lines %llu, avg %.16e\n",
|
||||
loop->lineNumber(), byFile.first.c_str(), paralle_exec, lines_count, paralle_exec / (double)lines_count);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext())
|
||||
{
|
||||
if (!isSgExecutableStatement(st) || isDVM_stat(st) || isSPF_stat(st))
|
||||
continue;
|
||||
|
||||
int line = st->lineNumber();
|
||||
if (line <= 0)
|
||||
continue;
|
||||
|
||||
auto it = gcov.find(line);
|
||||
if (it == gcov.end())
|
||||
continue;
|
||||
|
||||
auto& info = it->second;
|
||||
|
||||
if (info.getNumLine() != line) {
|
||||
__spf_print(1, "bad gcov info\n");
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
|
||||
total_exec_count += info.getExecutedCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__spf_print(1, " coverage_average %.16e\n", paralle_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);
|
||||
|
||||
ofstream stats("stats.csv");
|
||||
stats << "coverage_average;" << paralle_exec_count / (double)count_of_parallel_lines << std::endl;
|
||||
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();
|
||||
}
|
||||
@@ -1908,7 +1908,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
}
|
||||
|
||||
static int countMaxValuesForParallelVariants(int &maxDims, int &maxDimsIdx, int &maxDimsIdxReg, vector<vector<int>> ¤tVariants)
|
||||
{
|
||||
{
|
||||
int lastI;
|
||||
if (consoleMode)
|
||||
{
|
||||
|
||||
@@ -92,8 +92,18 @@ void insertIntrinsicStat(const vector<FuncInfo*>& allFuncInfo)
|
||||
|
||||
SgStatement* intr = new SgStatement(INTRIN_STAT);
|
||||
intr->setExpression(0, makeExprList(list));
|
||||
intr->setlineNumber(st->lineNumber());
|
||||
|
||||
auto prev = (st->variant() == FOR_NODE) ? st->lexPrev() : st;
|
||||
int line = prev->lineNumber();
|
||||
while (line <= 0 && !isSgProgHedrStmt(prev)) {
|
||||
prev = prev->lexPrev();
|
||||
line = prev->lineNumber();
|
||||
}
|
||||
|
||||
if (line <= 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
intr->setlineNumber(line);
|
||||
st->insertStmtBefore(*intr, *func->funcPointer);
|
||||
}
|
||||
else
|
||||
@@ -449,6 +459,8 @@ static void insertIntents(set<string>& identificators, SgStatement* header, cons
|
||||
if (args.size())
|
||||
{
|
||||
SgIntentStmt* intent = new SgIntentStmt(*makeExprList(args), *attr);
|
||||
intent->setlineNumber(lastDecl->lineNumber());
|
||||
|
||||
lastDecl->insertStmtAfter(*intent, (header == lastDecl) ? *header : *lastDecl->controlParent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ enum typeMessage { WARR, ERROR, NOTE };
|
||||
// 07 "Internal error during unparsing process has occurred"
|
||||
// 08 "Can not do PRIVATE EXPANSION for this loop - privates not found"
|
||||
// 09 "Can not split this loop because of dependecy: %s"
|
||||
// 10 "This loop has indirect child loops and can not be splitted\n"
|
||||
// 11
|
||||
// 10 "This loop has indirect child loops and can not be splitted"
|
||||
// 11 "It is allowed to inline function only at execution code section"
|
||||
// 12 "for function duplication"
|
||||
// 13 "for function duplication"
|
||||
// 14 inlining errors - dims mismatch
|
||||
@@ -96,7 +96,7 @@ enum typeMessage { WARR, ERROR, NOTE };
|
||||
// 17 cannot remove private var '%s' - it has recursive dependency or it depends on non-invariant var '%s'
|
||||
// 18 "private variable '%s' was removed" or "private variable '%s' was partially removed"
|
||||
// 19 "Removing of private var '%s' was made with assumption that references '%s' and '%s' are different"
|
||||
// 20 --- FREE POSITION
|
||||
// 20 "Function inlining failed with an error"
|
||||
// 21 "cannot remove private var '%s' - cannot find reaching definition for the statement"
|
||||
// 22 "cannot transform ..."
|
||||
// 23 "cannot transform ..."
|
||||
@@ -276,7 +276,7 @@ static void printStackTrace() { };
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Свободный - R193 и далее R205
|
||||
// Свободный - R205
|
||||
// Гайд по русификации сообщений: При добавлении нового сообщения, меняется последний сводобный идентификатор.
|
||||
// В этом файле остаются только спецификаторы, для которых будет заполнен текст. Полный текст пишется в файле
|
||||
// russian_errors_text.txt. Спецификаторы там тоже сохраняются, по ним в визуализаторе будет восстановлен
|
||||
@@ -523,7 +523,7 @@ static const wchar_t *R201 = L"R201:%s";
|
||||
//2019
|
||||
static const wchar_t *R192 = L"R192:%s#%s#%s";
|
||||
//2020
|
||||
// static const wchar_t *R193 = L"R193:%s";
|
||||
static const wchar_t *R193 = L"R193:";
|
||||
//2021
|
||||
static const wchar_t *R194 = L"R194:%s";
|
||||
//2022
|
||||
|
||||
@@ -233,7 +233,7 @@ R201 = "Приватная переменная '%s' была частично
|
||||
//2019
|
||||
R192 = "Удаление приватной переменной '%s' было выполнено в предположении, что выражения '%s' и '%s' различны"
|
||||
//2020
|
||||
R193 = "--FREE POSITION"
|
||||
R193 = "Подстановка функций выполнилась с ошибкой"
|
||||
//2021
|
||||
R194 = "Нельзя удалить приватную переменную '%s' - не удалось найти достигающее определение для оператора"
|
||||
//2022
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2362"
|
||||
#define VERSION_SPF "2364"
|
||||
|
||||
@@ -555,6 +555,7 @@ bool OperatorChecker(SgFile* file, map<string, vector<Messages>>& currMessages)
|
||||
SgStatement* st = file->firstStatement();
|
||||
string currF = file->filename();
|
||||
|
||||
const set<int> cpOnSameLine = { ARITHIF_NODE, LOGIF_NODE, GOTO_NODE , IF_NODE, FORALL_STAT };
|
||||
while (st)
|
||||
{
|
||||
int line = st->lineNumber();
|
||||
@@ -562,9 +563,8 @@ bool OperatorChecker(SgFile* file, map<string, vector<Messages>>& currMessages)
|
||||
; // skip
|
||||
else if (line > 0 && st->fileName() == currF)
|
||||
{
|
||||
;
|
||||
int var = st->controlParent()->variant();
|
||||
bool cpWasAdded = (var == ARITHIF_NODE || var == LOGIF_NODE || var == GOTO_NODE || var == IF_NODE) && (usedLines.find(line) != usedLines.end());
|
||||
bool cpWasAdded = cpOnSameLine.find(var) != cpOnSameLine.end() && (usedLines.find(line) != usedLines.end());
|
||||
|
||||
if (usedLines.find(line) != usedLines.end() && !cpWasAdded)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user