remove intent(in)
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include "../Utils/SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../Utils/utils.h"
|
#include "../Utils/utils.h"
|
||||||
@@ -38,7 +40,7 @@ static SgType* createArrayCharType(int len, int dim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void findDecls(SgExpression* ex, vector<SgExpression*>& local, const map<string, SgStatement*>& localParams,
|
static void findDecls(SgExpression* ex, vector<SgExpression*>& local, const map<string, SgStatement*>& localParams,
|
||||||
set<string>& added)
|
set<string>& added)
|
||||||
{
|
{
|
||||||
if (ex)
|
if (ex)
|
||||||
{
|
{
|
||||||
@@ -71,7 +73,7 @@ static void findDecls(SgExpression* ex, vector<SgExpression*>& local, const map<
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void findLocalData(SgStatement* start, SgStatement* end, vector<SgExpression*>& local,
|
static void findLocalData(SgStatement* start, SgStatement* end, vector<SgExpression*>& local,
|
||||||
map<string, SgStatement*>& localParams, set<string>& added)
|
map<string, SgStatement*>& localParams, set<string>& added)
|
||||||
{
|
{
|
||||||
for (SgStatement* st = start; st != end; st = st->lexNext())
|
for (SgStatement* st = start; st != end; st = st->lexNext())
|
||||||
{
|
{
|
||||||
@@ -149,7 +151,7 @@ static SgExpression* getAttribute(SgExpression* spec, const string& type)
|
|||||||
static SgSymbol* makeVar(const string& name) { return new SgSymbol(VARIABLE_NAME, name.c_str()); }
|
static SgSymbol* makeVar(const string& name) { return new SgSymbol(VARIABLE_NAME, name.c_str()); }
|
||||||
|
|
||||||
static void insertToOpenClose(const map<int, UserFiles>& needToSave, const vector<string>& names, const vector<string>& closedStatus,
|
static void insertToOpenClose(const map<int, UserFiles>& needToSave, const vector<string>& names, const vector<string>& closedStatus,
|
||||||
const string& iosModule)
|
const string& iosModule)
|
||||||
{
|
{
|
||||||
int z = 0;
|
int z = 0;
|
||||||
map<string, map<SgStatement*, set<string>>> useOnlyByFileAndFunc;
|
map<string, map<SgStatement*, set<string>>> useOnlyByFileAndFunc;
|
||||||
@@ -317,7 +319,7 @@ static bool createForIOs(const map<int, UserFiles>& filesInfo, SgStatement* func
|
|||||||
str_func->setExpression(0, NULL); //bad solution!
|
str_func->setExpression(0, NULL); //bad solution!
|
||||||
str_func->insertStmtAfter(*makeDeclaration(NULL, { sSTR }), *str_func);
|
str_func->insertStmtAfter(*makeDeclaration(NULL, { sSTR }), *str_func);
|
||||||
|
|
||||||
str_func->lastNodeOfStmt()->insertStmtBefore(*new SgInputOutputStmt(WRITE_STAT, *makeExprList({ new SgKeywordValExp("*"), new SgVarRefExp(sSTR)}, false), *new SgVarRefExp(k_par)), *str_func);
|
str_func->lastNodeOfStmt()->insertStmtBefore(*new SgInputOutputStmt(WRITE_STAT, *makeExprList({ new SgKeywordValExp("*"), new SgVarRefExp(sSTR) }, false), *new SgVarRefExp(k_par)), *str_func);
|
||||||
SgAssignStmt* adjustl = new SgAssignStmt(*new SgVarRefExp(sSTR), *new SgFunctionCallExp(*new SgSymbol(FUNCTION_NAME, "ADJUSTL"), *new SgVarRefExp(sSTR)));
|
SgAssignStmt* adjustl = new SgAssignStmt(*new SgVarRefExp(sSTR), *new SgFunctionCallExp(*new SgSymbol(FUNCTION_NAME, "ADJUSTL"), *new SgVarRefExp(sSTR)));
|
||||||
str_func->lastNodeOfStmt()->insertStmtBefore(*adjustl, *str_func);
|
str_func->lastNodeOfStmt()->insertStmtBefore(*adjustl, *str_func);
|
||||||
|
|
||||||
@@ -425,7 +427,7 @@ static void fillToProcess(FuncInfo* funcI, set<pair<FuncInfo*, FuncInfo*>>& toPr
|
|||||||
|
|
||||||
//TODO: reverse if 'before' == false
|
//TODO: reverse if 'before' == false
|
||||||
static int insertInitNamesOfFiles(const int numOfFiles, const string& additional, SgSymbol* files, SgArrayRefExp* journal,
|
static int insertInitNamesOfFiles(const int numOfFiles, const string& additional, SgSymbol* files, SgArrayRefExp* journal,
|
||||||
SgStatement* insert, bool before = true)
|
SgStatement* insert, bool before = true)
|
||||||
{
|
{
|
||||||
int maxFileLen = -1;
|
int maxFileLen = -1;
|
||||||
string tmp;
|
string tmp;
|
||||||
@@ -498,8 +500,85 @@ static void replaceExprByExprInSt(SgStatement* st, SgExpression* from, SgExpress
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBlocks, const map<int, UserFiles>& filesInfo,
|
void deleteIntentIn(SgStatement* start, SgStatement* end)
|
||||||
const vector<FuncInfo*>& allFuncInfo)
|
{
|
||||||
|
for (SgStatement* st = start; st != end; st = st->lexNext())
|
||||||
|
{
|
||||||
|
if (st->expr(2)) {
|
||||||
|
int var = st->expr(2)->lhs()->variant();
|
||||||
|
if (var == 468)
|
||||||
|
st->setExpression(2, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void replaceIntentInWithIntentinOut(SgStatement* start, SgStatement* end)
|
||||||
|
{
|
||||||
|
for (SgStatement* st = start; st != end; st = st->lexNext())
|
||||||
|
{
|
||||||
|
if (st->expr(2)) {
|
||||||
|
int var = st->expr(2)->lhs()->variant();
|
||||||
|
if (var == 468)
|
||||||
|
st->expr(2)->lhs()->setVariant(470);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void findLocalDataNoIntentIn(SgStatement* start, SgStatement* end, vector<SgExpression*>& local,
|
||||||
|
map<string, SgStatement*>& localParams, set<string>& added)
|
||||||
|
{
|
||||||
|
for (SgStatement* st = start; st != end; st = st->lexNext())
|
||||||
|
{
|
||||||
|
if (st->variant() == PARAM_DECL)
|
||||||
|
{
|
||||||
|
auto decl = (SgParameterStmt*)st;
|
||||||
|
for (int z = 0; z < decl->numberOfConstants(); ++z)
|
||||||
|
localParams[decl->constant(z)->identifier()] = st;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (st->variant() == EXTERN_STAT)
|
||||||
|
for (SgExpression* ex = st->expr(0); ex; ex = ex->rhs())
|
||||||
|
added.insert(ex->lhs()->symbol()->identifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SgStatement* st = start; st != end; st = st->lexNext())
|
||||||
|
if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90)
|
||||||
|
if (st->expr(2) && st->expr(2)->lhs()->variant() == 468) {
|
||||||
|
SgExpression* ex = st->expr(0);
|
||||||
|
while (ex)
|
||||||
|
{
|
||||||
|
if (ex->lhs())
|
||||||
|
if (ex->lhs()->variant() == VAR_REF)
|
||||||
|
added.insert(ex->lhs()->symbol()->identifier());
|
||||||
|
|
||||||
|
ex = ex->rhs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SgStatement* st = start; st != end; st = st->lexNext())
|
||||||
|
{
|
||||||
|
//printf("line %d %s Var %s\n", st->lineNumber(), st->fileName(), tag[st->variant()]);
|
||||||
|
if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90)
|
||||||
|
findDecls(st->expr(0), local, localParams, added);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SgStatement* st = start; st != end; st = st->lexNext())
|
||||||
|
if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90)
|
||||||
|
if (st->expr(2) && st->expr(2)->lhs()->variant() == 468) {
|
||||||
|
SgExpression* ex = st->expr(0);
|
||||||
|
while (ex)
|
||||||
|
{
|
||||||
|
if (ex->lhs())
|
||||||
|
if (ex->lhs()->variant() == VAR_REF)
|
||||||
|
added.erase(ex->lhs()->symbol()->identifier());
|
||||||
|
|
||||||
|
ex = ex->rhs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void createCheckpoints(SgFile* file, const map<string, CommonBlock*>& commonBlocks, const map<int, UserFiles>& filesInfo,
|
||||||
|
const vector<FuncInfo*>& allFuncInfo)
|
||||||
{
|
{
|
||||||
map<int, cpInfo> inFileCp;
|
map<int, cpInfo> inFileCp;
|
||||||
bool inFile = findSpfCpDir(file, inFileCp);
|
bool inFile = findSpfCpDir(file, inFileCp);
|
||||||
@@ -566,14 +645,18 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
checkNull(lastDecl, convertFileName(__FILE__).c_str(), __LINE__);
|
checkNull(lastDecl, convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
SgStatement* firstExec = lastDecl->lexNext();
|
SgStatement* firstExec = lastDecl->lexNext();
|
||||||
|
|
||||||
|
//deleteIntentIn(func->lexNext(), firstExec);
|
||||||
|
//replaceIntentInWithIntentinOut(func->lexNext(), firstExec);
|
||||||
|
|
||||||
vector<SgExpression*> local;
|
vector<SgExpression*> local;
|
||||||
map<string, SgStatement*> localParams;
|
map<string, SgStatement*> localParams;
|
||||||
set<string> addedToList;
|
set<string> addedToList;
|
||||||
findLocalData(func->lexNext(), lastDecl, local, localParams, addedToList);
|
findLocalDataNoIntentIn(func->lexNext(), firstExec, local, localParams, addedToList);
|
||||||
const vector<SgStatement*> useOfMods = findUseOfModules(func->lexNext(), lastDecl);
|
const vector<SgStatement*> useOfMods = findUseOfModules(func->lexNext(), firstExec);
|
||||||
|
|
||||||
SgStatement* loadBlock = new SgStatement(IF_NODE);
|
SgStatement* loadBlock = new SgStatement(IF_NODE);
|
||||||
SgStatement* storeBlock = new SgStatement(IF_NODE);
|
SgStatement* storeBlock = new SgStatement(IF_NODE);
|
||||||
|
//std::cout << "##############################################################################" << std::endl;
|
||||||
|
|
||||||
point->insertStmtBefore(*loadBlock, *point->controlParent());
|
point->insertStmtBefore(*loadBlock, *point->controlParent());
|
||||||
point->insertStmtBefore(*storeBlock, *point->controlParent());
|
point->insertStmtBefore(*storeBlock, *point->controlParent());
|
||||||
@@ -587,22 +670,37 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
SgArrayRefExp* journal = new SgArrayRefExp(*files, *new SgValueExp(numOfFiles + 1));
|
SgArrayRefExp* journal = new SgArrayRefExp(*files, *new SgValueExp(numOfFiles + 1));
|
||||||
|
|
||||||
//give max len, dont insert
|
//give max len, dont insert
|
||||||
|
/* after store-block in func with cp:
|
||||||
|
spf_cp_files_0_26(1) = 'spf_cp_file_1_0_26'
|
||||||
|
spf_cp_files_0_26(2) = 'spf_cp_file_2_0_26'
|
||||||
|
spf_cp_files_0_26(3) = 'spf_cp_journal_0_26'
|
||||||
|
*/
|
||||||
int maxFileLen = insertInitNamesOfFiles(numOfFiles, additional, files, journal, NULL);
|
int maxFileLen = insertInitNamesOfFiles(numOfFiles, additional, files, journal, NULL);
|
||||||
|
|
||||||
vector<SgSymbol*> everyS;
|
vector<SgSymbol*> everyS;
|
||||||
vector<SgSymbol*> profS;
|
vector<SgSymbol*> profS;
|
||||||
vector<SgExpression*> initS;
|
vector<SgExpression*> initS;
|
||||||
|
|
||||||
string profSs = "spf_cp_prof_s" + additional;
|
string
|
||||||
string profEs = "spf_cp_prof_e" + additional;
|
profSs = "spf_cp_prof_s" + additional,
|
||||||
|
profEs = "spf_cp_prof_e" + additional;
|
||||||
|
|
||||||
profS.push_back(new SgSymbol(VARIABLE_NAME, profSs.c_str(), SgTypeFloat(), func));
|
profS.push_back(new SgSymbol(VARIABLE_NAME, profSs.c_str(), SgTypeFloat(), func));
|
||||||
profS.push_back(new SgSymbol(VARIABLE_NAME, profEs.c_str(), SgTypeFloat(), func));
|
profS.push_back(new SgSymbol(VARIABLE_NAME, profEs.c_str(), SgTypeFloat(), func));
|
||||||
|
|
||||||
SgSymbol* timeF = new SgSymbol(FUNCTION_NAME, "omp_get_wtime", SgTypeDouble(),func); // OR dvtime
|
SgSymbol* timeF = new SgSymbol(FUNCTION_NAME, "omp_get_wtime", SgTypeDouble(), func); // OR dvtime
|
||||||
|
|
||||||
|
//spf_cp_prof_s(e)_0_26 = omp_get_wtime()
|
||||||
SgStatement* profCallS = new SgAssignStmt(*new SgVarRefExp(profS[0]), *new SgFunctionCallExp(*timeF));
|
SgStatement* profCallS = new SgAssignStmt(*new SgVarRefExp(profS[0]), *new SgFunctionCallExp(*timeF));
|
||||||
SgStatement* profCallE = new SgAssignStmt(*new SgVarRefExp(profS[1]), *new SgFunctionCallExp(*timeF));
|
SgStatement* profCallE = new SgAssignStmt(*new SgVarRefExp(profS[1]), *new SgFunctionCallExp(*timeF));
|
||||||
|
|
||||||
|
/* beginning of store block :
|
||||||
|
* ! STORE CHECKPOINT
|
||||||
|
spf_cp_interval_0_26 = spf_cp_interval_0_26 + 1
|
||||||
|
if (spf_cp_interval_0_26 .ge. 1) then
|
||||||
|
spf_cp_interval_0_26 = 0
|
||||||
|
endif
|
||||||
|
*/
|
||||||
if (type == typeEvery::TIME)
|
if (type == typeEvery::TIME)
|
||||||
{
|
{
|
||||||
string everySs = "spf_cp_start" + additional;
|
string everySs = "spf_cp_start" + additional;
|
||||||
@@ -633,14 +731,31 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
everyS.push_back(new SgSymbol(VARIABLE_NAME, everyIs.c_str(), SgTypeInt(), func));
|
everyS.push_back(new SgSymbol(VARIABLE_NAME, everyIs.c_str(), SgTypeInt(), func));
|
||||||
initS.push_back(new SgValueExp(0));
|
initS.push_back(new SgValueExp(0));
|
||||||
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(everyS[0]), *new SgValueExp(0));
|
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(everyS[0]), *new SgValueExp(0));
|
||||||
|
//std::cout << "INIT::" << std::endl;
|
||||||
|
//init->unparsestdout();
|
||||||
|
//std::cout << "storeBlock before::" << std::endl;
|
||||||
|
//storeBlock->unparsestdout();
|
||||||
storeBlock->insertStmtAfter(*init, *storeBlock);
|
storeBlock->insertStmtAfter(*init, *storeBlock);
|
||||||
|
//std::cout << "storeBlock after init::" << std::endl;
|
||||||
|
//storeBlock->unparsestdout();
|
||||||
|
|
||||||
SgAssignStmt* inc = new SgAssignStmt(*new SgVarRefExp(everyS[0]), *new SgVarRefExp(everyS[0]) + *new SgValueExp(1));
|
SgAssignStmt* inc = new SgAssignStmt(*new SgVarRefExp(everyS[0]), *new SgVarRefExp(everyS[0]) + *new SgValueExp(1));
|
||||||
|
//std::cout << "INC::" << std::endl;
|
||||||
|
//init->unparsestdout();
|
||||||
|
//std::cout << "storeBlock->controlParent()::" << std::endl;
|
||||||
|
//storeBlock->controlParent()->unparsestdout();
|
||||||
storeBlock->insertStmtBefore(*inc, *storeBlock->controlParent());
|
storeBlock->insertStmtBefore(*inc, *storeBlock->controlParent());
|
||||||
inc->addComment("! STORE CHECKPOINT\n");
|
inc->addComment("! STORE CHECKPOINT\n");
|
||||||
|
//std::cout << "storeBlock after inc::" << std::endl;
|
||||||
|
//storeBlock->unparsestdout();
|
||||||
|
|
||||||
storeBlock->setExpression(0, *new SgVarRefExp(everyS[0]) >= *new SgValueExp(every));
|
storeBlock->setExpression(0, *new SgVarRefExp(everyS[0]) >= *new SgValueExp(every));
|
||||||
|
//std::cout << "storeBlock after setexpr::" << std::endl;
|
||||||
|
//storeBlock->unparsestdout();
|
||||||
|
//std::cout << "storeBlock->controlParent()::" << std::endl;
|
||||||
|
//storeBlock->controlParent()->unparsestdout();
|
||||||
}
|
}
|
||||||
|
//std::cout << "##############################################################################" << std::endl;
|
||||||
|
|
||||||
vector<SgSymbol*> loadS;
|
vector<SgSymbol*> loadS;
|
||||||
vector<SgExpression*> initLoadS;
|
vector<SgExpression*> initLoadS;
|
||||||
@@ -658,9 +773,9 @@ 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;
|
/*string loadSaveS = "spf_cp_load_save" + additional;
|
||||||
loadS.push_back(new SgSymbol(VARIABLE_NAME, loadSaveS.c_str(), SgTypeInt(), func));
|
loadS.push_back(new SgSymbol(VARIABLE_NAME, loadSaveS.c_str(), SgTypeInt(), func));
|
||||||
initLoadS.push_back(new SgValueExp(0));*/
|
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));
|
||||||
@@ -670,10 +785,18 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
loadS.push_back(new SgSymbol(VARIABLE_NAME, saveFS.c_str(), SgTypeInt(), func));
|
loadS.push_back(new SgSymbol(VARIABLE_NAME, saveFS.c_str(), SgTypeInt(), func));
|
||||||
initLoadS.push_back(new SgValueExp(0));
|
initLoadS.push_back(new SgValueExp(0));
|
||||||
|
|
||||||
|
//std::cout << "loadBlock->controlParent()::" << std::endl;
|
||||||
|
//loadBlock->controlParent()->unparsestdout();
|
||||||
loadBlock->setExpression(0, *new SgVarRefExp(loadS[0]) == *new SgValueExp(0));
|
loadBlock->setExpression(0, *new SgVarRefExp(loadS[0]) == *new SgValueExp(0));
|
||||||
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[0]), *new SgValueExp(1));
|
SgAssignStmt* init = new SgAssignStmt(*new SgVarRefExp(loadS[0]), *new SgValueExp(1));
|
||||||
|
//std::cout << "INIT::" << std::endl;
|
||||||
|
//init->unparsestdout();
|
||||||
insertToLoadS.push_back(init);
|
insertToLoadS.push_back(init);
|
||||||
|
|
||||||
|
//std::cout << "loadBlock->controlParent()::" << std::endl;
|
||||||
|
//loadBlock->controlParent()->unparsestdout();
|
||||||
|
//std::cout << "##############################################################################" << std::endl;
|
||||||
|
|
||||||
vector<SgExpression*> listSpec;
|
vector<SgExpression*> listSpec;
|
||||||
|
|
||||||
SgExpression& unitNull = SgAssignOp(*new SgKeywordValExp("unit"), *new SgKeywordValExp("*"));
|
SgExpression& unitNull = SgAssignOp(*new SgKeywordValExp("unit"), *new SgKeywordValExp("*"));
|
||||||
@@ -684,6 +807,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
SgExpression* iostat = new SgVarRefExp(loadS[2]);
|
SgExpression* iostat = new SgVarRefExp(loadS[2]);
|
||||||
SgExpression* fileIdx = new SgVarRefExp(loadS[1]);
|
SgExpression* fileIdx = new SgVarRefExp(loadS[1]);
|
||||||
|
|
||||||
|
// for first open journal file in load block
|
||||||
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("iostat"), *iostat));
|
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("iostat"), *iostat));
|
||||||
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("status"), *new SgValueExp("old")));
|
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("status"), *new SgValueExp("old")));
|
||||||
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("file"), *journal));
|
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("file"), *journal));
|
||||||
@@ -711,9 +835,17 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
insertToifLoadOk.push_back(open);
|
insertToifLoadOk.push_back(open);
|
||||||
|
|
||||||
SgIfStmt* ifLoadOk1 = new SgIfStmt(*iostat == *new SgValueExp(0), *new SgIOControlStmt(CLOSE_STAT, unit));
|
SgIfStmt* ifLoadOk1 = new SgIfStmt(*iostat == *new SgValueExp(0), *new SgIOControlStmt(CLOSE_STAT, unit));
|
||||||
|
//std::cout << "ifLoadOk1::" << std::endl;
|
||||||
|
//ifLoadOk1->unparsestdout();
|
||||||
|
|
||||||
|
|
||||||
insertToifLoadOk.push_back(ifLoadOk1);
|
insertToifLoadOk.push_back(ifLoadOk1);
|
||||||
|
/* from "! LOAD DATA FROM CHECKPOINT"
|
||||||
|
spf_cp_file_n_0_26 = spf_cp_file_n_0_26 + 1
|
||||||
|
if (spf_cp_file_n_0_26 .eq. 3) then
|
||||||
|
spf_cp_file_n_0_26 = 1
|
||||||
|
endif
|
||||||
|
*/
|
||||||
ifLoadOk1->insertStmtAfter(*new SgIfStmt(*fileIdx == *new SgValueExp(numOfFiles + 1), *new SgAssignStmt(*fileIdx, *new SgValueExp(1))), *ifLoadOk1);
|
ifLoadOk1->insertStmtAfter(*new SgIfStmt(*fileIdx == *new SgValueExp(numOfFiles + 1), *new SgAssignStmt(*fileIdx, *new SgValueExp(1))), *ifLoadOk1);
|
||||||
ifLoadOk1->insertStmtAfter(*new SgAssignStmt(*fileIdx, *fileIdx + *new SgValueExp(1)), *ifLoadOk1);
|
ifLoadOk1->insertStmtAfter(*new SgAssignStmt(*fileIdx, *fileIdx + *new SgValueExp(1)), *ifLoadOk1);
|
||||||
ifLoadOk1->addComment("! LOAD DATA FROM CHECKPOINT\n");
|
ifLoadOk1->addComment("! LOAD DATA FROM CHECKPOINT\n");
|
||||||
@@ -730,6 +862,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
//open all files
|
//open all files
|
||||||
if (createdModuleForIO)
|
if (createdModuleForIO)
|
||||||
{
|
{
|
||||||
|
//std::cout << "createdModuleForIO" << std::endl;
|
||||||
SgCallStmt* call = new SgCallStmt(*new SgSymbol(FUNCTION_NAME, iosNames[1].c_str()));
|
SgCallStmt* call = new SgCallStmt(*new SgSymbol(FUNCTION_NAME, iosNames[1].c_str()));
|
||||||
ifLoadOk1->insertStmtAfter(*call, *ifLoadOk1);
|
ifLoadOk1->insertStmtAfter(*call, *ifLoadOk1);
|
||||||
}
|
}
|
||||||
@@ -737,6 +870,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
//READ from modules
|
//READ from modules
|
||||||
for (auto& mod : moduleNames)
|
for (auto& mod : moduleNames)
|
||||||
{
|
{
|
||||||
|
//std::cout << "READ from modules" << std::endl;
|
||||||
SgCallStmt* call = new SgCallStmt(*new SgSymbol(FUNCTION_NAME, ("SPF_CP_" + mod).c_str()));
|
SgCallStmt* call = new SgCallStmt(*new SgSymbol(FUNCTION_NAME, ("SPF_CP_" + mod).c_str()));
|
||||||
call->addArg(*new SgValueExp(unitNum));
|
call->addArg(*new SgValueExp(unitNum));
|
||||||
call->addArg(*new SgValueExp(0));
|
call->addArg(*new SgValueExp(0));
|
||||||
@@ -746,11 +880,16 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
//READ DATA
|
//READ DATA
|
||||||
if (local.size())
|
if (local.size())
|
||||||
{
|
{
|
||||||
|
//std::cout << "READ DATA" << std::endl;
|
||||||
auto dataRead = new SgInputOutputStmt(READ_STAT, unit, *makeExprList(local, false));
|
auto dataRead = new SgInputOutputStmt(READ_STAT, unit, *makeExprList(local, false));
|
||||||
ifLoadOk1->insertStmtAfter(*dataRead, *ifLoadOk1);
|
ifLoadOk1->insertStmtAfter(*dataRead, *ifLoadOk1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ifLoadOk1->insertStmtAfter(profCallS->copy(), *ifLoadOk1);
|
ifLoadOk1->insertStmtAfter(profCallS->copy(), *ifLoadOk1);
|
||||||
|
//std::cout << "loadBlock->controlParent()::" << std::endl;
|
||||||
|
//loadBlock->controlParent()->unparsestdout();
|
||||||
|
|
||||||
|
// loadblock done (need to upload)
|
||||||
|
|
||||||
listSpec.clear();
|
listSpec.clear();
|
||||||
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("form"), *new SgValueExp("unformatted")));
|
listSpec.push_back(&SgAssignOp(*new SgKeywordValExp("form"), *new SgValueExp("unformatted")));
|
||||||
@@ -822,19 +961,41 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
assign->insertStmtBefore(*new SgIOControlStmt(CLOSE_STAT, unit), *ifStoreOk);
|
assign->insertStmtBefore(*new SgIOControlStmt(CLOSE_STAT, unit), *ifStoreOk);
|
||||||
|
|
||||||
ifStoreOk->insertStmtAfter(profCallS->copy(), *ifStoreOk);
|
ifStoreOk->insertStmtAfter(profCallS->copy(), *ifStoreOk);
|
||||||
|
// store-block done
|
||||||
|
|
||||||
|
// block after name of files and before first executable operator
|
||||||
SgStatement* copyForGoto = loadBlock->copyPtr();
|
SgStatement* copyForGoto = loadBlock->copyPtr();
|
||||||
|
//std::cout << "copyForGoto::" << std::endl;
|
||||||
|
//copyForGoto->unparsestdout();
|
||||||
copyForGoto->deleteLabel();
|
copyForGoto->deleteLabel();
|
||||||
|
//std::cout << "copyForGoto after delete label::" << std::endl;
|
||||||
|
//copyForGoto->unparsestdout();
|
||||||
|
//std::cout << "firstExec::" << std::endl;
|
||||||
|
//firstExec->unparsestdout();
|
||||||
firstExec->insertStmtBefore(*copyForGoto, *func);
|
firstExec->insertStmtBefore(*copyForGoto, *func);
|
||||||
|
//std::cout << "firstExec parent after insert::" << std::endl;
|
||||||
|
//firstExec->controlParent()->unparsestdout();
|
||||||
|
//loadBlock->controlParent()->unparsestdout();
|
||||||
insertInitNamesOfFiles(numOfFiles, additional, files, journal, copyForGoto, true);
|
insertInitNamesOfFiles(numOfFiles, additional, files, journal, copyForGoto, true);
|
||||||
|
//std::cout << "insert names of files::" << std::endl;
|
||||||
|
|
||||||
copyForGoto->insertStmtAfter(insertToLoadS[insertToLoadS.size() - 1]->copy(), *copyForGoto);
|
copyForGoto->insertStmtAfter(insertToLoadS[insertToLoadS.size() - 1]->copy(), *copyForGoto);
|
||||||
|
//std::cout << "copyForGoto::" << std::endl;
|
||||||
|
//copyForGoto->controlParent()->unparsestdout();
|
||||||
copyForGoto->insertStmtAfter(insertToLoadS[insertToLoadS.size() - 2]->copy(), *copyForGoto);
|
copyForGoto->insertStmtAfter(insertToLoadS[insertToLoadS.size() - 2]->copy(), *copyForGoto);
|
||||||
|
//std::cout << "copyForGoto::" << std::endl;
|
||||||
|
//copyForGoto->controlParent()->unparsestdout();
|
||||||
|
|
||||||
copyForGoto = copyForGoto->lexNext()->lexNext();
|
copyForGoto = copyForGoto->lexNext()->lexNext();
|
||||||
|
//std::cout << "copyForGoto after double lexnext::" << std::endl;
|
||||||
|
//copyForGoto->unparsestdout();
|
||||||
|
|
||||||
copyForGoto->insertStmtAfter(*new SgGotoStmt(*loadblockLab), *copyForGoto);
|
copyForGoto->insertStmtAfter(*new SgGotoStmt(*loadblockLab), *copyForGoto);
|
||||||
|
//std::cout << "copyForGoto::" << std::endl;
|
||||||
|
//copyForGoto->controlParent()->unparsestdout();
|
||||||
copyForGoto->insertStmtAfter(*new SgIOControlStmt(CLOSE_STAT, unit), *copyForGoto);
|
copyForGoto->insertStmtAfter(*new SgIOControlStmt(CLOSE_STAT, unit), *copyForGoto);
|
||||||
|
//std::cout << "copyForGoto::" << std::endl;
|
||||||
|
//copyForGoto->controlParent()->unparsestdout();
|
||||||
|
|
||||||
for (int z = insertToLoadS.size() - 1; z >= 0; --z)
|
for (int z = insertToLoadS.size() - 1; z >= 0; --z)
|
||||||
loadBlock->insertStmtAfter(*insertToLoadS[z], *loadBlock);
|
loadBlock->insertStmtAfter(*insertToLoadS[z], *loadBlock);
|
||||||
@@ -842,6 +1003,9 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
for (int z = insertToifLoadOk.size() - 1; z >= 0; --z)
|
for (int z = insertToifLoadOk.size() - 1; z >= 0; --z)
|
||||||
ifLoadOk->insertStmtAfter(*insertToifLoadOk[z], *ifLoadOk);
|
ifLoadOk->insertStmtAfter(*insertToifLoadOk[z], *ifLoadOk);
|
||||||
|
|
||||||
|
// load block added
|
||||||
|
|
||||||
|
//std::cout << "##############################################################################" << std::endl;
|
||||||
|
|
||||||
//TODO:
|
//TODO:
|
||||||
/*set<string> elemNotDeclHere;
|
/*set<string> elemNotDeclHere;
|
||||||
@@ -927,6 +1091,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
map<FuncInfo*, SgStatement*> processedFrom;
|
map<FuncInfo*, SgStatement*> processedFrom;
|
||||||
for (auto j = toProcess.begin(); j != toProcess.end(); j++)
|
for (auto j = toProcess.begin(); j != toProcess.end(); j++)
|
||||||
{
|
{
|
||||||
|
std::cout << "( " << (j->first)->funcName << " , " << (j->second)->funcName << " ) " << std::endl;
|
||||||
int callNum = 1;
|
int callNum = 1;
|
||||||
SgStatement* hedrTo = (j->first)->funcPointer->GetOriginal();
|
SgStatement* hedrTo = (j->first)->funcPointer->GetOriginal();
|
||||||
SgStatement* hedrFrom = (j->second)->funcPointer->GetOriginal();
|
SgStatement* hedrFrom = (j->second)->funcPointer->GetOriginal();
|
||||||
@@ -935,10 +1100,13 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
lastDecl = lastDecl->lexNext();
|
lastDecl = lastDecl->lexNext();
|
||||||
|
|
||||||
SgStatement* firstExec = lastDecl->lexNext();
|
SgStatement* firstExec = lastDecl->lexNext();
|
||||||
|
|
||||||
|
deleteIntentIn(hedrFrom->lexNext(), firstExec);
|
||||||
|
|
||||||
vector<SgExpression*> local;
|
vector<SgExpression*> local;
|
||||||
map<string, SgStatement*> localParams;
|
map<string, SgStatement*> localParams;
|
||||||
set<string> addedToList;
|
set<string> addedToList;
|
||||||
findLocalData(hedrFrom->lexNext(), lastDecl, local, localParams, addedToList);
|
findLocalData(hedrFrom->lexNext(), firstExec, local, localParams, addedToList);
|
||||||
if (!processedFrom.count(j->second))
|
if (!processedFrom.count(j->second))
|
||||||
{
|
{
|
||||||
SgSymbol* modS = moduleF->symbol();
|
SgSymbol* modS = moduleF->symbol();
|
||||||
@@ -1000,20 +1168,25 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
ifLoadOk->insertStmtAfter(*insertToifLoadOk[z], *ifLoadOk);
|
ifLoadOk->insertStmtAfter(*insertToifLoadOk[z], *ifLoadOk);
|
||||||
|
|
||||||
processedFrom[j->second] = ifLoadOk1->lexNext();
|
processedFrom[j->second] = ifLoadOk1->lexNext();
|
||||||
processedFrom[j->second]->unparsestdout();
|
//processedFrom[j->second]->unparsestdout();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SgStatement * read = new SgInputOutputStmt(READ_STAT, *makeExprList({ &frmt, &unit }, false), *new SgVarRefExp(loadS[3]));
|
SgStatement* read = new SgInputOutputStmt(READ_STAT, *makeExprList({ &frmt, &unit }, false), *new SgVarRefExp(loadS[3]));
|
||||||
gotoBlock->insertStmtAfter(*read, *gotoBlock);
|
gotoBlock->insertStmtAfter(*read, *gotoBlock);
|
||||||
processedFrom[j->second] = gotoBlock->lexNext();
|
processedFrom[j->second] = gotoBlock->lexNext();
|
||||||
|
firstExec->insertStmtBefore(*gotoBlock, *hedrFrom);
|
||||||
}
|
}
|
||||||
|
processedFrom[j->second]->unparsestdout();
|
||||||
|
//std::cout << "gotoblock: " << std::endl;
|
||||||
|
//gotoBlock->unparsestdout();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& callInfo : j->second->callsFromDetailed)
|
for (auto& callInfo : j->second->callsFromDetailed)
|
||||||
{
|
{
|
||||||
|
//std::cout << "callinfo name: " << callInfo.detailCallsFrom.first << std::endl;
|
||||||
auto& call = callInfo.pointerDetailCallsFrom;
|
auto& call = callInfo.pointerDetailCallsFrom;
|
||||||
|
//std::cout << "callinfo var: " << call.second << std::endl;
|
||||||
SgStatement* st = NULL;
|
SgStatement* st = NULL;
|
||||||
|
|
||||||
if (isSgFuncHedrStmt(hedrTo) && call.second == FUNC_CALL)
|
if (isSgFuncHedrStmt(hedrTo) && call.second == FUNC_CALL)
|
||||||
@@ -1022,10 +1195,10 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
if (!strcmp(callExp->funName()->identifier(), (j->first)->funcName.c_str()))
|
if (!strcmp(callExp->funName()->identifier(), (j->first)->funcName.c_str()))
|
||||||
{
|
{
|
||||||
st = SgStatement::getStatmentByExpression(callExp);
|
st = SgStatement::getStatmentByExpression(callExp);
|
||||||
SgSymbol * buf = new SgSymbol(VARIABLE_NAME, ("SPF_CALL_"+ (j->first)->funcName + "_" + to_string(callNum)).c_str(), callExp->type(), (j->second)->funcPointer->GetOriginal());
|
SgSymbol* buf = new SgSymbol(VARIABLE_NAME, ("SPF_CALL_" + (j->first)->funcName + "_" + to_string(callNum)).c_str(), callExp->type(), (j->second)->funcPointer->GetOriginal());
|
||||||
SgExpression* bufRef = new SgVarRefExp(buf);
|
SgExpression* bufRef = new SgVarRefExp(buf);
|
||||||
SgStatement* bufAssign = new SgAssignStmt(*bufRef, *callExp);
|
SgStatement* bufAssign = new SgAssignStmt(*bufRef, *callExp);
|
||||||
st->insertStmtBefore(*bufAssign,* (st->controlParent()));
|
st->insertStmtBefore(*bufAssign, *(st->controlParent()));
|
||||||
replaceExprByExprInSt(st, callExp, bufRef);
|
replaceExprByExprInSt(st, callExp, bufRef);
|
||||||
makeDeclaration(hedrFrom, { buf });
|
makeDeclaration(hedrFrom, { buf });
|
||||||
for (int i = 0; i < callExp->numberOfArgs(); i++)
|
for (int i = 0; i < callExp->numberOfArgs(); i++)
|
||||||
@@ -1044,11 +1217,11 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SgSymbol* argBuf = new SgSymbol(VARIABLE_NAME, ("SPF_ARG_" + (j->first)->funcName+"_" + to_string(callNum) + "_" + to_string(i)).c_str(), s->type(), (j->second)->funcPointer->GetOriginal());
|
SgSymbol* argBuf = new SgSymbol(VARIABLE_NAME, ("SPF_ARG_" + (j->first)->funcName + "_" + to_string(callNum) + "_" + to_string(i)).c_str(), s->type(), (j->second)->funcPointer->GetOriginal());
|
||||||
SgExpression* argBufRef = new SgVarRefExp(argBuf);
|
SgExpression* argBufRef = new SgVarRefExp(argBuf);
|
||||||
SgStatement* argBufAssign = new SgAssignStmt(*argBufRef, *(callExp->arg(i)));
|
SgStatement* argBufAssign = new SgAssignStmt(*argBufRef, *(callExp->arg(i)));
|
||||||
bufAssign->insertStmtBefore(*argBufAssign, *(st->controlParent()));
|
bufAssign->insertStmtBefore(*argBufAssign, *(st->controlParent()));
|
||||||
SgStatement* decl = makeDeclaration(hedrFrom, {argBuf});
|
SgStatement* decl = makeDeclaration(hedrFrom, { argBuf });
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
@@ -1096,7 +1269,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
loadBlock->setLabel(*loadblockLab);
|
loadBlock->setLabel(*loadblockLab);
|
||||||
|
|
||||||
SgIfStmt* gotoIf = new SgIfStmt(*new SgVarRefExp(loadS[3]) == *new SgValueExp(labNum), *new SgGotoStmt(*loadblockLab));
|
SgIfStmt* gotoIf = new SgIfStmt(*new SgVarRefExp(loadS[3]) == *new SgValueExp(labNum), *new SgGotoStmt(*loadblockLab));
|
||||||
processedFrom[j->second]->insertStmtAfter(*gotoIf,*(processedFrom[j->second]->controlParent()));
|
processedFrom[j->second]->insertStmtAfter(*gotoIf, *(processedFrom[j->second]->controlParent()));
|
||||||
|
|
||||||
storeBlock->addComment("! STORE CHECKPOINT\n");
|
storeBlock->addComment("! STORE CHECKPOINT\n");
|
||||||
|
|
||||||
@@ -1186,7 +1359,7 @@ static void createModule(SgStatement*& module, const string& name, bool withFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SgExpression* moveSaveAssignToMod(SgExpression* ex, SgStatement*& saveModule,
|
static SgExpression* moveSaveAssignToMod(SgExpression* ex, SgStatement*& saveModule,
|
||||||
map<string, SgStatement*>& declLists, const string& procName, bool withInit)
|
map<string, SgStatement*>& declLists, const string& procName, bool withInit)
|
||||||
{
|
{
|
||||||
if (saveModule == NULL)
|
if (saveModule == NULL)
|
||||||
createModule(saveModule, "spf_module_save_");
|
createModule(saveModule, "spf_module_save_");
|
||||||
|
|||||||
Reference in New Issue
Block a user