omp_getwetime added

This commit is contained in:
2024-05-02 14:15:48 +03:00
committed by ALEXks
parent a4ec840d3f
commit ce3df70fb4

View File

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