From 025113211b0bc545296b1d811d6a1b9e81ce6773 Mon Sep 17 00:00:00 2001 From: AntonMilienkov Date: Thu, 2 May 2024 14:15:48 +0300 Subject: [PATCH] omp_getwetime added --- .../_src/Transformations/checkpoints.cpp | 70 ++++++------------- 1 file changed, 23 insertions(+), 47 deletions(-) diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp b/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp index 79f99c5..8f5b909 100644 --- a/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp @@ -805,12 +805,12 @@ static SgStatement* createLoadBlock(const vector& loadS, FuncInfo*& f const char* funcName = funcI->funcName.c_str(); vector 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& 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& vector local; map localParams; set addedToList; - //findLocalData(hedrFrom, firstExec, local, localParams, addedToList, allFuncInfo); if (!processedFrom.count(funcFrom)) { @@ -1194,7 +1193,6 @@ static void processFunctionCallChain(SgStatement* func, const vector& set addedModuleParams; set 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& 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& commonBloc //give max len, dont insert int maxFileLen = insertInitNamesOfFiles(numOfFiles, additional, files, journal, NULL); - //vector everyS; vector profS; - //vector 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& 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& 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& commonBloc if (funcI->isMain) insertInitNamesOfFiles(numOfFiles, additional, files, journal, lastDecl, false); - //TODO: - /*set 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& commonBloc } } - vector everyS; - vector initS; - vector> chainLocalVarNoParams; //localVarNoParams + vector> chainLocalVarNoParams; vector 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 everyS; + vector initS; if (type == typeEvery::TIME) { string everySs = "spf_cp_start" + additional; @@ -1578,15 +1552,17 @@ void createCheckpoints(SgFile* file, const map& 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()); }