omp_getwetime added

This commit is contained in:
2024-05-02 14:15:48 +03:00
parent 19ddaa0523
commit 025113211b

View File

@@ -805,12 +805,12 @@ static SgStatement* createLoadBlock(const vector<SgSymbol*>& loadS, FuncInfo*& f
const char* funcName = funcI->funcName.c_str();
vector<SgStatement*> insertToLoadS;
SgStatement* loadBlock = new SgIfStmt(*new SgVarRefExp(loadS[4]) == *new SgValueExp(1)); //*new SgVarRefExp(loadS[0])
SgStatement* loadBlock = new SgIfStmt(*new SgVarRefExp(loadS[0]) == *new SgValueExp(1)); //*new SgVarRefExp(loadS[0])
loadBlock->addComment("! LOAD CHECKPOINT\n");
if (funcI->isMain)
{
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[4]), *new SgValueExp(0));
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[0]), *new SgValueExp(0));
insertToLoadS.push_back(init);
insertToLoadS.push_back(createOpenJ_old(iostat, journal, unit));
}
@@ -833,7 +833,7 @@ static SgStatement* createLoadBlock(const vector<SgSymbol*>& loadS, FuncInfo*& f
if (funcI->isMain)
{
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[4]), *new SgValueExp(1));
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[0]), *new SgValueExp(1));
ifLoadOk1->insertStmtAfter(*init, *ifLoadOk1);
}
@@ -1166,7 +1166,6 @@ static void processFunctionCallChain(SgStatement* func, const vector<FuncInfo*>&
vector<SgExpression*> local;
map<string, SgStatement*> localParams;
set<string> addedToList;
//findLocalData(hedrFrom, firstExec, local, localParams, addedToList, allFuncInfo);
if (!processedFrom.count(funcFrom))
{
@@ -1194,7 +1193,6 @@ static void processFunctionCallChain(SgStatement* func, const vector<FuncInfo*>&
set<string> addedModuleParams;
set<string> localVarNoParams;
insertStmtToModule(moduleStmts, moduleParamStmts, addedModuleParams, commonVariables, proc_moduleF, localVarNoParams, externVars);
//chainLocalVarNoParams.push_back(localVarNoParams);
const string namelabelSymb = funcFrom->funcName + "_label";
SgSymbol* procLabelSymb = createLabel(namelabelSymb, proc_moduleF);
@@ -1220,19 +1218,19 @@ static void processFunctionCallChain(SgStatement* func, const vector<FuncInfo*>&
localVarNoParams, moduleStmts, commonVariables, createdModuleForIO,
moduleNames, unitNum, funcI->funcName, chainLocalVarNoParams, false, procLabelSymb);
firstExec->insertStmtBefore(*loadBlock, *firstExec->controlParent());
if (funcFrom->isMain)
{
insertInitNamesOfFiles(numOfFiles, additional, files, journal, lastDecl, false);
}
SgStatement* gotoBlock = new SgStatement(IF_NODE);
gotoBlock->addComment("! goto next program unit\n");
gotoBlock->setExpression(0, *new SgVarRefExp(loadS[4]) == *new SgValueExp(1));
gotoBlock->setExpression(0, *new SgVarRefExp(loadS[0]) == *new SgValueExp(1));
firstExec->insertStmtBefore(*gotoBlock, *firstExec->controlParent());
// insert gotoBlock and save to module
processAllCalls(firstExec, funcTo->funcName, funcFrom->funcName, gotoBlock, localVarNoParams, procLabelSymb);
makeDeclaration(hedrFrom, { timeF });
}
}
@@ -1389,9 +1387,7 @@ void createCheckpoints(SgFile* file, const map<string, CommonBlock*>& commonBloc
//give max len, dont insert
int maxFileLen = insertInitNamesOfFiles(numOfFiles, additional, files, journal, NULL);
//vector<SgSymbol*> everyS;
vector<SgSymbol*> profS;
//vector<SgExpression*> initS;
string profSs = "spf_cp_prof_s" + additional;
string profEs = "spf_cp_prof_e" + additional;
@@ -1408,7 +1404,7 @@ void createCheckpoints(SgFile* file, const map<string, CommonBlock*>& commonBloc
string cpLoadS = "spf_cp_load" + additional;
loadS.push_back(new SgSymbol(VARIABLE_NAME, cpLoadS.c_str(), SgTypeInt(), func));
initLoadS.push_back(new SgValueExp(0));
initLoadS.push_back(new SgValueExp(1));
string fileNS = "spf_cp_file_n" + additional;
loadS.push_back(new SgSymbol(VARIABLE_NAME, fileNS.c_str(), SgTypeInt(), func));
@@ -1418,23 +1414,11 @@ void createCheckpoints(SgFile* file, const map<string, CommonBlock*>& commonBloc
loadS.push_back(new SgSymbol(VARIABLE_NAME, iostatS.c_str(), SgTypeInt(), func));
initLoadS.push_back(NULL);
/*string loadSaveS = "spf_cp_load_save" + additional;
loadS.push_back(new SgSymbol(VARIABLE_NAME, loadSaveS.c_str(), SgTypeInt(), func));
initLoadS.push_back(new SgValueExp(0));*/
string loadLabelS = "spf_cp_load_label" + additional;
loadS.push_back(new SgSymbol(VARIABLE_NAME, loadLabelS.c_str(), SgTypeInt(), func));
initLoadS.push_back(new SgValueExp(0));
string loadFS = "spf_cp_load_flag" + additional;
loadS.push_back(new SgSymbol(VARIABLE_NAME, loadFS.c_str(), SgTypeInt(), func));
initLoadS.push_back(new SgValueExp(1));
string saveFS = "spf_cp_save_flag" + additional;
loadS.push_back(new SgSymbol(VARIABLE_NAME, saveFS.c_str(), SgTypeInt(), func));
initLoadS.push_back(new SgValueExp(0));
SgExpression& unitNull = SgAssignOp(*new SgKeywordValExp("unit"), *new SgKeywordValExp("*"));
SgExpression& unit = SgAssignOp(*new SgKeywordValExp("unit"), *new SgValueExp(unitNum));
SgExpression& frmt = SgAssignOp(*new SgKeywordValExp("fmt"), *new SgKeywordValExp("*"));
@@ -1453,18 +1437,7 @@ void createCheckpoints(SgFile* file, const map<string, CommonBlock*>& commonBloc
if (funcI->isMain)
insertInitNamesOfFiles(numOfFiles, additional, files, journal, lastDecl, false);
//TODO:
/*set<string> elemNotDeclHere;
for (auto& elem : commonVars)
{
if (addedToList.find(elem) == addedToList.end())
elemNotDeclHere.insert(elem);
}
for (auto& elem : elemNotDeclHere)
printf("%s\n", elem.c_str());*/
// make all new declarations
//makeDeclaration(moduleF, everyS, &initS);
makeDeclaration(moduleF, loadS, &initLoadS);
makeDeclaration(moduleF, profS);
makeDeclaration(moduleF, { files });
@@ -1524,21 +1497,22 @@ void createCheckpoints(SgFile* file, const map<string, CommonBlock*>& commonBloc
}
}
vector<SgSymbol*> everyS;
vector<SgExpression*> initS;
vector<vector<string>> chainLocalVarNoParams; //localVarNoParams
vector<vector<string>> chainLocalVarNoParams;
vector<string> chainLabel;
//TODO: this function needs to be completely rewritten!!
processFunctionCallChain(func, allFuncInfo, moduleF, loadS, iostat, journal, frmt, unit, files, fileIdx, every, numOfFiles, additional,
profS, frmtProf, unitNull, unitNum, createdModuleForIO, moduleNames, chainLocalVarNoParams, chainLabel);
processFunctionCallChain(func, allFuncInfo, moduleF, loadS, iostat, journal, frmt, unit, files,
fileIdx, every, numOfFiles, additional, profS, frmtProf, unitNull,
unitNum, createdModuleForIO, moduleNames, chainLocalVarNoParams, chainLabel);
SgStatement* storeBlock = createSaveBlock(loadS, funcI, iostat, journal, frmt, unit, files, fileIdx,
numOfFiles, profS, frmtProf, unitNull, profCallS, profCallE, localVarNoParams, moduleStmts,
commonVariables, createdModuleForIO, moduleNames, unitNum, chainLocalVarNoParams, chainLabel);
numOfFiles, profS, frmtProf, unitNull, profCallS, profCallE,
localVarNoParams, moduleStmts, commonVariables, createdModuleForIO,
moduleNames, unitNum, chainLocalVarNoParams, chainLabel);
point->insertStmtBefore(*storeBlock, *point->controlParent());
vector<SgSymbol*> everyS;
vector<SgExpression*> initS;
if (type == typeEvery::TIME)
{
string everySs = "spf_cp_start" + additional;
@@ -1578,15 +1552,17 @@ void createCheckpoints(SgFile* file, const map<string, CommonBlock*>& commonBloc
storeBlock->setExpression(0, *new SgVarRefExp(everyS[0]) >= *new SgValueExp(every));
}
makeDeclaration(moduleF, everyS, &initS);
const int labNum = getNextFreeLabel();
auto nextStLab = new SgLabel(labNum);
point->setLabel(*nextStLab);
SgStatement* gotoBlock = new SgIfStmt(*new SgVarRefExp(loadS[4]) == *new SgValueExp(labNum));
gotoBlock->addComment("! goto CP\n");
SgStatement* gotoBlock = new SgIfStmt(*new SgVarRefExp(loadS[0]) == *new SgValueExp(labNum));
gotoBlock->addComment("! GOTO CP\n");
gotoBlock->insertStmtAfter(*new SgGotoStmt(*nextStLab), *gotoBlock);
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[4]), *new SgValueExp(0));
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[0]), *new SgValueExp(0));
gotoBlock->insertStmtAfter(*init, *gotoBlock);
loadBlock->insertStmtAfter(*gotoBlock, *loadBlock->controlParent());
}