added new pass for statistics, updated dvm
This commit is contained in:
@@ -170,7 +170,7 @@ static char* getNestCond()
|
||||
|
||||
static char* getNewCycleVar(const char *oldVar)
|
||||
{
|
||||
char *str = new char[strlen(oldVar) + 2];
|
||||
char *str = new char[strlen(oldVar) + 3];
|
||||
str[0] = '\0';
|
||||
strcat(str, "__");
|
||||
strcat(str, oldVar);
|
||||
@@ -3468,7 +3468,7 @@ SgSymbol *hasSameNameAsSource(SgSymbol *symb)
|
||||
|
||||
int sameVariableName(SgSymbol *symb1, SgSymbol *symb2)
|
||||
{
|
||||
if (!symb1 || !symb2 || (symb1->variant() != VARIABLE_NAME && symb1->variant() != CONST_NAME) || symb2->variant() != VARIABLE_NAME && symb2->variant() != CONST_NAME)
|
||||
if (!symb1 || !symb2 || (symb1->variant() != VARIABLE_NAME && symb1->variant() != CONST_NAME && symb1->variant() != FUNCTION_NAME) || symb2->variant() != VARIABLE_NAME && symb2->variant() != CONST_NAME && symb2->variant() != FUNCTION_NAME)
|
||||
return 0;
|
||||
if (!strcmp (symb1->identifier(), symb2->identifier()))
|
||||
return 1;
|
||||
|
||||
@@ -661,7 +661,7 @@ void ReadWritePrint_Statement(SgStatement *stmt, int error_msg)
|
||||
//if(IN_COMPUTE_REGION && !in_checksection)
|
||||
// ChangeDistArrayRef(iol);
|
||||
}
|
||||
if(inparloop && (send || IN_COMPUTE_REGION) && error_msg)
|
||||
if(inparloop && (send || IN_COMPUTE_REGION || parloop_by_handler) && error_msg)
|
||||
err("Illegal I/O statement in the range of parallel loop/region", 184,stmt);
|
||||
|
||||
}
|
||||
|
||||
@@ -2297,8 +2297,10 @@ void Interface_2(SgStatement *stmt,SgExpression *clause[],SgExpression *init[],S
|
||||
}
|
||||
if (clause[CONSISTENT_]) //there is CONSISTENT clause
|
||||
for (SgExpression *el = clause[CONSISTENT_]->lhs(); el; el=el->rhs())
|
||||
InsertNewStatementAfter(Consistent_H(ilh, HeaderForArrayInParallelDir(el->lhs()->symbol(), stmt, 0), MappingList(stmt, el->lhs())), cur_st, cur_st->controlParent());
|
||||
|
||||
{
|
||||
SgExpression *head = HeaderForArrayInParallelDir(el->lhs()->symbol(), stmt, 0);
|
||||
InsertNewStatementAfter(Consistent_H(ilh, head, MappingList(stmt, el->lhs())), cur_st, cur_st->controlParent());
|
||||
}
|
||||
if (clause[REMOTE_ACCESS_]) //there is REMOTE_ACCESS clause
|
||||
{ int nbuf=1;
|
||||
//adding new element to remote_access directive/clause list
|
||||
@@ -2306,7 +2308,10 @@ void Interface_2(SgStatement *stmt,SgExpression *clause[],SgExpression *init[],S
|
||||
RemoteVariableList(clause[REMOTE_ACCESS_]->symbol(), clause[REMOTE_ACCESS_]->lhs(), stmt);
|
||||
|
||||
for (SgExpression *el=clause[REMOTE_ACCESS_]->lhs(); el; el=el->rhs(),nbuf++)
|
||||
InsertNewStatementAfter(LoopRemoteAccess_H(ilh, HeaderForArrayInParallelDir(el->lhs()->symbol(), stmt, 0), el->lhs()->symbol(), MappingList(stmt, ArrayRefAddition(el->lhs()))), cur_st, cur_st->controlParent());
|
||||
{
|
||||
SgExpression *head = HeaderForArrayInParallelDir(el->lhs()->symbol(), stmt, 0);
|
||||
InsertNewStatementAfter(LoopRemoteAccess_H(ilh, head, el->lhs()->symbol(), MappingList(stmt, ArrayRefAddition(el->lhs()))), cur_st, cur_st->controlParent());
|
||||
}
|
||||
}
|
||||
|
||||
if (clause[SHADOW_COMPUTE_]) //there is SHADOW_COMPUTE clause
|
||||
|
||||
@@ -45,4 +45,4 @@ int Perform::getPercent() { return percent; }
|
||||
void Perform::setNumber(int a) { number = a; }
|
||||
void Perform::setPercent(int a) { percent = a; }
|
||||
void Perform::gcov_print() { __spf_print(1, "%d - %d\n", number, percent); }
|
||||
ostream &operator<<(ostream &out, const Perform &a) { out << "number= " << a.number << "\npercent= " << a.percent << endl; return out; }
|
||||
ostream &operator<<(ostream &out, const Perform &a) { out << "number= " << a.number << ": percent= " << a.percent << endl; return out; }
|
||||
@@ -1019,6 +1019,10 @@ static void insert(SgStatement* callSt, SgStatement* tempHedr, SgStatement* begi
|
||||
st->setlineNumber(getNextNegativeLineNumber());
|
||||
}
|
||||
|
||||
next = prev->lexNext();
|
||||
next->setlineNumber(callSt->lineNumber());
|
||||
next->setFileName(callSt->fileName());
|
||||
|
||||
last->extractStmt();
|
||||
|
||||
if (callSt->variant() == PROC_STAT)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -12,9 +13,16 @@
|
||||
#include <queue>
|
||||
|
||||
#include "dvm.h"
|
||||
#include "../DynamicAnalysis/gcov_info.h"
|
||||
#include "PredictScheme.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
|
||||
using std::map;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::set;
|
||||
using std::ofstream;
|
||||
|
||||
static void fillParallel(SgExpression *exp, ParallelStats &parStats, int &totalScoreComm)
|
||||
{
|
||||
if (exp)
|
||||
@@ -116,3 +124,77 @@ void processFileToPredict(SgFile *file, PredictorStats &predictorCounts)
|
||||
|
||||
predictorCounts.TotalScorePar += predictorCounts.ParallelCount;
|
||||
}
|
||||
|
||||
static void calculate_for_parallel_loop(SgStatement* loop, const map<int, Gcov_info>& gcov,
|
||||
uint64_t& paralle_exec_count, uint64_t& count_of_parallel_lines) {
|
||||
for (auto st = loop; st != loop->lastNodeOfStmt(); st = st->lexNext()) {
|
||||
int line = st->lineNumber();
|
||||
if (line <= 0)
|
||||
continue;
|
||||
|
||||
auto it = gcov.find(line);
|
||||
if (it == gcov.end()) {
|
||||
__spf_print(1, "bad gcov info\n");
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
|
||||
auto& info = it->second;
|
||||
|
||||
if (info.getNumLine() != line) {
|
||||
__spf_print(1, "bad gcov info\n");
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
|
||||
count_of_parallel_lines++;
|
||||
paralle_exec_count += info.getExecutedCount();
|
||||
}
|
||||
}
|
||||
|
||||
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 count_of_parallel_lines = 0;
|
||||
|
||||
for (auto& byFile : allFuncInfo) {
|
||||
int ok = SgFile::switchToFile(byFile.first);
|
||||
if (ok == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
auto it = gCovInfo.find(byFile.first);
|
||||
if (it == gCovInfo.end()) {
|
||||
__spf_print(1, "bad gcov info\n");
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
|
||||
auto& gcov = it->second;
|
||||
for (auto& func : byFile.second) {
|
||||
SgStatement* stat = func->funcPointer->GetOriginal();
|
||||
|
||||
for (auto st = stat->lexNext(); st != stat->lastNodeOfStmt(); st = st->lexNext()) {
|
||||
uint64_t paralle_exec = 0;
|
||||
uint64_t lines_count = 0;
|
||||
|
||||
if (st->variant() == DVM_PARALLEL_ON_DIR) {
|
||||
auto loop = st->lexNext();
|
||||
checkNull(loop, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
if (loop->variant() != FOR_NODE)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
calculate_for_parallel_loop(loop, gcov, paralle_exec, lines_count);
|
||||
st = loop->lastNodeOfStmt();
|
||||
|
||||
paralle_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__spf_print(1, " coverage_average %.16e\n", paralle_exec_count / (double)count_of_parallel_lines);
|
||||
ofstream stats("stats.csv");
|
||||
stats << "coverage_average;" << paralle_exec_count / (double)count_of_parallel_lines << std::endl;
|
||||
stats.close();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "dvm.h"
|
||||
#include "../GraphCall/graph_calls.h"
|
||||
|
||||
class ParallelStats
|
||||
{
|
||||
@@ -52,3 +53,5 @@ public:
|
||||
};
|
||||
|
||||
void processFileToPredict(SgFile *file, PredictorStats &predictorCounts);
|
||||
|
||||
void calculate_stats_for_predictor(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, std::map<int, Gcov_info>>& gCovInfo);
|
||||
@@ -1892,9 +1892,9 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
else if (curr_regime == FIX_COMMON_BLOCKS)
|
||||
fixCommonBlocks(allFuncInfo, commonBlocks, &project);
|
||||
else if (curr_regime == GET_MIN_MAX_BLOCK_DIST)
|
||||
{
|
||||
__spf_print(1, "GET_MIN_MAX_BLOCK_DIST: %d %d\n", min_max_block.first, min_max_block.second);
|
||||
}
|
||||
else if (curr_regime == GET_STATS_FOR_PREDICTOR)
|
||||
calculate_stats_for_predictor(allFuncInfo, gCovInfo);
|
||||
|
||||
const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;
|
||||
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;
|
||||
|
||||
@@ -109,6 +109,7 @@ enum passes {
|
||||
FILL_COMMON_BLOCKS,
|
||||
PREDICT_SCHEME,
|
||||
CALCULATE_STATS_SCHEME,
|
||||
GET_STATS_FOR_PREDICTOR,
|
||||
|
||||
DEF_USE_STAGE1,
|
||||
DEF_USE_STAGE2,
|
||||
@@ -288,6 +289,7 @@ static void setPassValues()
|
||||
passNames[ARRAY_ACCESS_ANALYSIS_FOR_CORNER] = "ARRAY_ACCESS_ANALYSIS_FOR_CORNER";
|
||||
passNames[FILL_COMMON_BLOCKS] = "FILL_COMMON_BLOCKS";
|
||||
passNames[PREDICT_SCHEME] = "PREDICT_SCHEME";
|
||||
passNames[GET_STATS_FOR_PREDICTOR] = "GET_STATS_FOR_PREDICTOR";
|
||||
passNames[DEF_USE_STAGE1] = "DEF_USE_STAGE1";
|
||||
passNames[DEF_USE_STAGE2] = "DEF_USE_STAGE2";
|
||||
passNames[REMOVE_DVM_DIRS_TO_COMMENTS] = "REMOVE_DVM_DIRS_TO_COMMENTS";
|
||||
|
||||
@@ -265,7 +265,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
list({ LOOP_ANALYZER_COMP_DIST, REMOVE_OMP_DIRS }) <= list({ CREATE_DISTR_DIRS, CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS });
|
||||
|
||||
Pass(CALL_GRAPH2) <= list({ ONLY_ARRAY_GRAPH, CREATE_NESTED_LOOPS, FIND_FUNC_TO_INCLUDE, CHECK_FUNC_TO_INCLUDE, FIND_PARAMETERS });
|
||||
Pass(CALL_GRAPH2) <= list({ ONLY_ARRAY_GRAPH, CREATE_NESTED_LOOPS, FIND_FUNC_TO_INCLUDE, CHECK_FUNC_TO_INCLUDE, FIND_PARAMETERS, GET_STATS_FOR_PREDICTOR });
|
||||
|
||||
Pass(CALL_GRAPH2) <= list({ PURE_SAVE_TO_PARAMS, PURE_MODULE_TO_PARAMS, PURE_COMMON_TO_PARAMS, PURE_INTENT_INSERT });
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2359"
|
||||
#define VERSION_SPF "2362"
|
||||
|
||||
@@ -554,11 +554,15 @@ bool OperatorChecker(SgFile* file, map<string, vector<Messages>>& currMessages)
|
||||
|
||||
SgStatement* st = file->firstStatement();
|
||||
string currF = file->filename();
|
||||
|
||||
while (st)
|
||||
{
|
||||
int line = st->lineNumber();
|
||||
if (line > 0 && st->fileName() == currF)
|
||||
if (line > 0 && st->variant() == PROG_HEDR && st->symbol()->identifier() == string("_MAIN"))
|
||||
; // 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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user