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"
|
||||||
@@ -34,11 +36,11 @@ static SgType* createArrayCharType(int len, int dim)
|
|||||||
auto lenght = new SgValueExp(len);
|
auto lenght = new SgValueExp(len);
|
||||||
arrayType->baseType()->thetype->entry.Template.kind_len = lenght->thellnd;
|
arrayType->baseType()->thetype->entry.Template.kind_len = lenght->thellnd;
|
||||||
return arrayType;
|
return arrayType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -57,7 +59,7 @@ static void findDecls(SgExpression* ex, vector<SgExpression*>& local, const map<
|
|||||||
|
|
||||||
if (ex->variant() == ARRAY_REF)
|
if (ex->variant() == ARRAY_REF)
|
||||||
{
|
{
|
||||||
if (ex->symbol()->variant() == VARIABLE_NAME &&
|
if (ex->symbol()->variant() == VARIABLE_NAME &&
|
||||||
added.find(ex->symbol()->identifier()) == added.end())
|
added.find(ex->symbol()->identifier()) == added.end())
|
||||||
{
|
{
|
||||||
added.insert(ex->symbol()->identifier());
|
added.insert(ex->symbol()->identifier());
|
||||||
@@ -70,8 +72,8 @@ 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())
|
||||||
{
|
{
|
||||||
@@ -84,16 +86,16 @@ static void findLocalData(SgStatement* start, SgStatement* end, vector<SgExpress
|
|||||||
|
|
||||||
if (st->variant() == EXTERN_STAT)
|
if (st->variant() == EXTERN_STAT)
|
||||||
for (SgExpression* ex = st->expr(0); ex; ex = ex->rhs())
|
for (SgExpression* ex = st->expr(0); ex; ex = ex->rhs())
|
||||||
added.insert(ex->lhs()->symbol()->identifier());
|
added.insert(ex->lhs()->symbol()->identifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (SgStatement* st = start; st != end; st = st->lexNext())
|
for (SgStatement* st = start; st != end; st = st->lexNext())
|
||||||
{
|
{
|
||||||
//printf("line %d %s Var %s\n", st->lineNumber(), st->fileName(), tag[st->variant()]);
|
//printf("line %d %s Var %s\n", st->lineNumber(), st->fileName(), tag[st->variant()]);
|
||||||
if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90)
|
if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90)
|
||||||
findDecls(st->expr(0), local, localParams, added);
|
findDecls(st->expr(0), local, localParams, added);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static vector<SgStatement*> findUseOfModules(SgStatement* start, SgStatement* end)
|
static vector<SgStatement*> findUseOfModules(SgStatement* start, SgStatement* end)
|
||||||
@@ -140,7 +142,7 @@ static SgExpression* getAttribute(SgExpression* spec, const string& type)
|
|||||||
if (val->value() == type)
|
if (val->value() == type)
|
||||||
return spec->lhs()->rhs();
|
return spec->lhs()->rhs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spec = spec->rhs();
|
spec = spec->rhs();
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -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;
|
||||||
@@ -190,7 +192,7 @@ static void insertToOpenClose(const map<int, UserFiles>& needToSave, const vecto
|
|||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
currClose->insertStmtAfter(*new SgAssignStmt(*new SgVarRefExp(makeVar(closedStatus[z])), *new SgValueExp(0)), *currClose->controlParent());
|
currClose->insertStmtAfter(*new SgAssignStmt(*new SgVarRefExp(makeVar(closedStatus[z])), *new SgValueExp(0)), *currClose->controlParent());
|
||||||
|
|
||||||
auto fStat = getFuncStat(currClose, { MODULE_STMT });
|
auto fStat = getFuncStat(currClose, { MODULE_STMT });
|
||||||
checkNull(fStat, convertFileName(__FILE__).c_str(), __LINE__);
|
checkNull(fStat, convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
useOnlyByFileAndFunc[currClose->fileName()][fStat].insert(closedStatus[z]);
|
useOnlyByFileAndFunc[currClose->fileName()][fStat].insert(closedStatus[z]);
|
||||||
@@ -286,7 +288,7 @@ static bool createForIOs(const map<int, UserFiles>& filesInfo, SgStatement* func
|
|||||||
close->insertStmtAfter(*ifstat, *close);
|
close->insertStmtAfter(*ifstat, *close);
|
||||||
++z;
|
++z;
|
||||||
}
|
}
|
||||||
|
|
||||||
z = 0;
|
z = 0;
|
||||||
|
|
||||||
auto sSTR = new SgSymbol(FUNCTION_NAME, "TO_STR", createArrayCharType(32, 0), moduleF);
|
auto sSTR = new SgSymbol(FUNCTION_NAME, "TO_STR", createArrayCharType(32, 0), moduleF);
|
||||||
@@ -296,7 +298,7 @@ static bool createForIOs(const map<int, UserFiles>& filesInfo, SgStatement* func
|
|||||||
vector<SgExpression*> listSpec;
|
vector<SgExpression*> listSpec;
|
||||||
/*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")));*/
|
||||||
|
|
||||||
auto fCall = new SgFunctionCallExp(*trim, *new SgVarRefExp(names[z]));
|
auto fCall = new SgFunctionCallExp(*trim, *new SgVarRefExp(names[z]));
|
||||||
auto fCall2 = new SgFunctionCallExp(*trim, *new SgFunctionCallExp(*sSTR, *new SgVarRefExp(counter)));
|
auto fCall2 = new SgFunctionCallExp(*trim, *new SgFunctionCallExp(*sSTR, *new SgVarRefExp(counter)));
|
||||||
|
|
||||||
@@ -307,7 +309,7 @@ static bool createForIOs(const map<int, UserFiles>& filesInfo, SgStatement* func
|
|||||||
ifstat->insertStmtAfter(*new SgAssignStmt(*new SgVarRefExp(closedStatus[z]), *new SgValueExp(1)), *ifstat);
|
ifstat->insertStmtAfter(*new SgAssignStmt(*new SgVarRefExp(closedStatus[z]), *new SgValueExp(1)), *ifstat);
|
||||||
open->insertStmtAfter(*ifstat, *open);
|
open->insertStmtAfter(*ifstat, *open);
|
||||||
++z;
|
++z;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto k_par = new SgSymbol(VARIABLE_NAME, "k");
|
auto k_par = new SgSymbol(VARIABLE_NAME, "k");
|
||||||
SgFuncHedrStmt* str_func = new SgFuncHedrStmt(*sSTR);
|
SgFuncHedrStmt* str_func = new SgFuncHedrStmt(*sSTR);
|
||||||
@@ -316,8 +318,8 @@ static bool createForIOs(const map<int, UserFiles>& filesInfo, SgStatement* func
|
|||||||
str_func->AddArg(*new SgVarRefExp(k_par));
|
str_func->AddArg(*new SgVarRefExp(k_par));
|
||||||
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);
|
||||||
|
|
||||||
@@ -408,10 +410,10 @@ static bool findSpfCpDir(SgFile* file, map<int, cpInfo>& info)
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fillToProcess(FuncInfo* funcI, set<pair<FuncInfo*, FuncInfo*>>& toProcess)
|
static void fillToProcess(FuncInfo* funcI, set<pair<FuncInfo*, FuncInfo*>>& toProcess)
|
||||||
{
|
{
|
||||||
int oldSize = toProcess.size();
|
int oldSize = toProcess.size();
|
||||||
for (int k = 0; k < funcI->callsTo.size(); k++)
|
for (int k = 0; k < funcI->callsTo.size(); k++)
|
||||||
{
|
{
|
||||||
pair<FuncInfo*, FuncInfo*> n(funcI, funcI->callsTo[k]);
|
pair<FuncInfo*, FuncInfo*> n(funcI, funcI->callsTo[k]);
|
||||||
toProcess.insert(n);
|
toProcess.insert(n);
|
||||||
@@ -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,9 +500,86 @@ 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());
|
||||||
@@ -583,26 +666,41 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
loadBlock->setLabel(*loadblockLab);
|
loadBlock->setLabel(*loadblockLab);
|
||||||
|
|
||||||
string filesS = "spf_cp_files" + additional;
|
string filesS = "spf_cp_files" + additional;
|
||||||
SgSymbol* files = new SgSymbol(VARIABLE_NAME, filesS.c_str(), createArrayCharType(32, numOfFiles + 1), func);
|
SgSymbol* files = new SgSymbol(VARIABLE_NAME, filesS.c_str(), createArrayCharType(32, numOfFiles + 1), func);
|
||||||
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,26 +961,51 @@ 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);
|
||||||
|
|
||||||
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;
|
||||||
@@ -915,7 +1079,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
|
|
||||||
FuncInfo* funcI = NULL;
|
FuncInfo* funcI = NULL;
|
||||||
for (auto& funcs : allFuncInfo)
|
for (auto& funcs : allFuncInfo)
|
||||||
if (funcs->funcName == func->symbol()->identifier())
|
if (funcs->funcName == func->symbol()->identifier())
|
||||||
funcI = funcs;
|
funcI = funcs;
|
||||||
|
|
||||||
if (funcI == NULL)
|
if (funcI == NULL)
|
||||||
@@ -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();
|
||||||
@@ -951,8 +1119,8 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
|
|
||||||
gotoBlock->addComment("!GOTO LOAD BLOCK \n");
|
gotoBlock->addComment("!GOTO LOAD BLOCK \n");
|
||||||
gotoBlock->setExpression(0, *new SgVarRefExp(loadS[0]) == *new SgValueExp(0));
|
gotoBlock->setExpression(0, *new SgVarRefExp(loadS[0]) == *new SgValueExp(0));
|
||||||
|
|
||||||
if (j->second->isMain)
|
if (j->second->isMain)
|
||||||
{
|
{
|
||||||
SgAssignStmt* loadOne = new SgAssignStmt(*new SgVarRefExp(loadS[0]), *new SgValueExp(1));
|
SgAssignStmt* loadOne = new SgAssignStmt(*new SgVarRefExp(loadS[0]), *new SgValueExp(1));
|
||||||
insertToGotoBlock.push_back(loadOne);
|
insertToGotoBlock.push_back(loadOne);
|
||||||
@@ -990,7 +1158,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
ifLoadOk1->insertStmtAfter(*loadZero, *ifLoadOk1);
|
ifLoadOk1->insertStmtAfter(*loadZero, *ifLoadOk1);
|
||||||
|
|
||||||
insertToifLoadOk.push_back(ifLoadOk1);
|
insertToifLoadOk.push_back(ifLoadOk1);
|
||||||
|
|
||||||
firstExec->insertStmtBefore(*gotoBlock, *hedrFrom);
|
firstExec->insertStmtBefore(*gotoBlock, *hedrFrom);
|
||||||
|
|
||||||
for (int z = insertToGotoBlock.size() - 1; z >= 0; --z)
|
for (int z = insertToGotoBlock.size() - 1; z >= 0; --z)
|
||||||
@@ -1000,32 +1168,37 @@ 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)
|
||||||
{
|
{
|
||||||
SgFunctionCallExp* callExp = (SgFunctionCallExp*)call.first;
|
SgFunctionCallExp* callExp = (SgFunctionCallExp*)call.first;
|
||||||
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++)
|
||||||
@@ -1041,15 +1214,15 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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++)
|
||||||
{
|
{
|
||||||
SgExpression* e;
|
SgExpression* e;
|
||||||
@@ -1058,7 +1231,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
st = bufAssign;
|
st = bufAssign;
|
||||||
callNum++;
|
callNum++;
|
||||||
@@ -1096,13 +1269,13 @@ 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");
|
||||||
|
|
||||||
storeBlock->setExpression(0, *new SgVarRefExp(everyS[0]) >= *new SgValueExp(every));
|
storeBlock->setExpression(0, *new SgVarRefExp(everyS[0]) >= *new SgValueExp(every));
|
||||||
|
|
||||||
vector<SgStatement*> insertToLoadS;
|
vector<SgStatement*> insertToLoadS;
|
||||||
|
|
||||||
loadBlock->setExpression(0, *new SgVarRefExp(loadS[0]) == *new SgValueExp(0));
|
loadBlock->setExpression(0, *new SgVarRefExp(loadS[0]) == *new SgValueExp(0));
|
||||||
loadBlock->addComment("! LOAD DATA FROM CHECKPOINT\n");
|
loadBlock->addComment("! LOAD DATA FROM CHECKPOINT\n");
|
||||||
@@ -1120,7 +1293,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//process modules
|
//process modules
|
||||||
vector<SgStatement*> modules;
|
vector<SgStatement*> modules;
|
||||||
findModulesInFile(file, modules);
|
findModulesInFile(file, modules);
|
||||||
@@ -1149,7 +1322,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
|
|
||||||
newF->AddArg("unit_f", *SgTypeInt());
|
newF->AddArg("unit_f", *SgTypeInt());
|
||||||
newF->AddArg("type_of_op", *SgTypeInt());
|
newF->AddArg("type_of_op", *SgTypeInt());
|
||||||
|
|
||||||
if (local.size())
|
if (local.size())
|
||||||
{
|
{
|
||||||
SgExpression& unit = SgAssignOp(*new SgKeywordValExp("unit"), *new SgVarRefExp(*newF->parameter(0)));
|
SgExpression& unit = SgAssignOp(*new SgKeywordValExp("unit"), *new SgVarRefExp(*newF->parameter(0)));
|
||||||
@@ -1161,7 +1334,7 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
|||||||
|
|
||||||
ifBlock->addComment(("!STORE OR LOAD " + to_string(local.size()) + " ITEMS\n").c_str());
|
ifBlock->addComment(("!STORE OR LOAD " + to_string(local.size()) + " ITEMS\n").c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static string cuttingType(const string& all_decl_with_init)
|
static string cuttingType(const string& all_decl_with_init)
|
||||||
@@ -1185,8 +1358,8 @@ 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_");
|
||||||
@@ -1201,7 +1374,7 @@ static SgExpression* moveSaveAssignToMod(SgExpression* ex, SgStatement*& saveMod
|
|||||||
if (ex->variant() != VAR_REF && ex->variant() != ARRAY_REF)
|
if (ex->variant() != VAR_REF && ex->variant() != ARRAY_REF)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
SgSymbol* copy = (withInit) ? &ex->lhs()->symbol()->copy() : &ex->symbol()->copy();
|
SgSymbol* copy = (withInit) ? &ex->lhs()->symbol()->copy() : &ex->symbol()->copy();
|
||||||
copy->changeName((string(copy->identifier()) + "_" + procName).c_str());
|
copy->changeName((string(copy->identifier()) + "_" + procName).c_str());
|
||||||
|
|
||||||
@@ -1213,8 +1386,8 @@ static SgExpression* moveSaveAssignToMod(SgExpression* ex, SgStatement*& saveMod
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
decl = makeDeclaration(NULL, { ex->symbol() }, NULL);
|
decl = makeDeclaration(NULL, { ex->symbol() }, NULL);
|
||||||
|
|
||||||
const string typeKey = cuttingType(decl->unparse());
|
const string typeKey = cuttingType(decl->unparse());
|
||||||
if (withInit)
|
if (withInit)
|
||||||
{
|
{
|
||||||
decl->expr(0)->lhs()->setLhs(withInit ? ex->lhs()->copyPtr() : ex->copyPtr());
|
decl->expr(0)->lhs()->setLhs(withInit ? ex->lhs()->copyPtr() : ex->copyPtr());
|
||||||
@@ -1246,7 +1419,7 @@ void convertSaveToModule(SgFile* file)
|
|||||||
vector<SgExpression*> renames;
|
vector<SgExpression*> renames;
|
||||||
|
|
||||||
SgStatement* func = file->functions(ff);
|
SgStatement* func = file->functions(ff);
|
||||||
|
|
||||||
string procName = file->functions(ff)->symbol()->identifier();
|
string procName = file->functions(ff)->symbol()->identifier();
|
||||||
set<SgStatement*> toRem;
|
set<SgStatement*> toRem;
|
||||||
vector<SgValueExp*> dataValues;
|
vector<SgValueExp*> dataValues;
|
||||||
@@ -1347,7 +1520,7 @@ void convertSaveToModule(SgFile* file)
|
|||||||
SgSymbol* modS = new SgSymbol(VARIABLE_NAME, saveModule->symbol()->identifier());
|
SgSymbol* modS = new SgSymbol(VARIABLE_NAME, saveModule->symbol()->identifier());
|
||||||
SgStatement* use = new SgStatement(USE_STMT, NULL, modS, makeExprList(renames), NULL, NULL);
|
SgStatement* use = new SgStatement(USE_STMT, NULL, modS, makeExprList(renames), NULL, NULL);
|
||||||
func->insertStmtAfter(*use, *func);
|
func->insertStmtAfter(*use, *func);
|
||||||
|
|
||||||
for (auto& dataV : dataValues)
|
for (auto& dataV : dataValues)
|
||||||
{
|
{
|
||||||
char* value = dataV->thellnd->entry.string_val;
|
char* value = dataV->thellnd->entry.string_val;
|
||||||
@@ -1358,7 +1531,7 @@ void convertSaveToModule(SgFile* file)
|
|||||||
for (auto& elem : dataRenames)
|
for (auto& elem : dataRenames)
|
||||||
{
|
{
|
||||||
auto it = dataS.find(elem.first);
|
auto it = dataS.find(elem.first);
|
||||||
if (it != string::npos &&
|
if (it != string::npos &&
|
||||||
(dataS[it + elem.first.size()] == ' ' || dataS[it + elem.first.size()] == '/') &&
|
(dataS[it + elem.first.size()] == ' ' || dataS[it + elem.first.size()] == '/') &&
|
||||||
(dataS[it - 1] == ',' || dataS[it - 1] == ' ' || dataS[it - 1] == '/'))
|
(dataS[it - 1] == ',' || dataS[it - 1] == ' ' || dataS[it - 1] == '/'))
|
||||||
{
|
{
|
||||||
@@ -1380,13 +1553,13 @@ void convertSaveToModule(SgFile* file)
|
|||||||
|
|
||||||
static int getUnit(SgExpression* spec)
|
static int getUnit(SgExpression* spec)
|
||||||
{
|
{
|
||||||
int unit = -1;
|
int unit = -1;
|
||||||
while (spec)
|
while (spec)
|
||||||
{
|
{
|
||||||
if (spec->lhs() && spec->lhs()->variant() == SPEC_PAIR)
|
if (spec->lhs() && spec->lhs()->variant() == SPEC_PAIR)
|
||||||
{
|
{
|
||||||
if (spec->lhs()->lhs()->variant() == KEYWORD_VAL)
|
if (spec->lhs()->lhs()->variant() == KEYWORD_VAL)
|
||||||
{
|
{
|
||||||
SgKeywordValExp* val = (SgKeywordValExp*)(spec->lhs()->lhs());
|
SgKeywordValExp* val = (SgKeywordValExp*)(spec->lhs()->lhs());
|
||||||
if (spec->lhs()->rhs()->variant() == INT_VAL)
|
if (spec->lhs()->rhs()->variant() == INT_VAL)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user