fixed privates removing
This commit is contained in:
@@ -872,6 +872,13 @@ static void printToBuffer(const LoopGraph *currLoop, const int childSize, char b
|
|||||||
else
|
else
|
||||||
loopState = 1;
|
loopState = 1;
|
||||||
}
|
}
|
||||||
|
else if (PASSES_DONE[SELECT_ARRAY_DIM_CONF])
|
||||||
|
{
|
||||||
|
if (currLoop->hasLimitsToParallel())
|
||||||
|
loopState = 2;
|
||||||
|
else
|
||||||
|
loopState = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (currLoop->hasLimitsToParallel())
|
if (currLoop->hasLimitsToParallel())
|
||||||
|
|||||||
@@ -599,40 +599,6 @@ static bool isVarChangedBetween(string var, SgStatement* first, SgStatement* sec
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove if needless
|
|
||||||
// removeDeadCodeFromLoop removes assign statements to private scalar vars which are not read in loop
|
|
||||||
//static void removeDeadCodeFromLoop(LoopGraph* loop)
|
|
||||||
//{
|
|
||||||
// SgForStmt* loopStmt = (SgForStmt*) loop->loop->GetOriginal();
|
|
||||||
// set<Symbol*> privateVars;
|
|
||||||
// for (auto data : getAttributes<SgStatement*, SgStatement*>(loopStmt, set<int>{ SPF_ANALYSIS_DIR }))
|
|
||||||
// fillPrivatesFromComment(new Statement(data), privateVars);
|
|
||||||
//
|
|
||||||
// set<string> privates;
|
|
||||||
// for (Symbol* symbol : privateVars)
|
|
||||||
// privates.insert(OriginalSymbol((SgSymbol*)symbol)->identifier());
|
|
||||||
//
|
|
||||||
// vector<SgStatement*> stmtsToDelete;
|
|
||||||
// for (SgStatement* st = loopStmt->lexNext(); st != loopStmt->lastNodeOfStmt(); st = st->lexNext())
|
|
||||||
// {
|
|
||||||
// if (st->variant() != ASSIGN_STAT)
|
|
||||||
// continue;
|
|
||||||
//
|
|
||||||
// SgSymbol* var = st->expr(0)->symbol();
|
|
||||||
// if (var == nullptr || var->variant() != VARIABLE_NAME)
|
|
||||||
// continue;
|
|
||||||
//
|
|
||||||
// if (privates.find(var->identifier()) != privates.end() && !isVarReadInLoop(var, loopStmt))
|
|
||||||
// stmtsToDelete.push_back(st);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (auto stmt : stmtsToDelete)
|
|
||||||
// stmt->deleteStmt();
|
|
||||||
//
|
|
||||||
// for (auto childLoop : loop->children)
|
|
||||||
// removeDeadCodeFromLoop(childLoop);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// fillReadShortFixedSumscripts fills all short fixed subscripts vectors of array var,
|
// fillReadShortFixedSumscripts fills all short fixed subscripts vectors of array var,
|
||||||
// which are used for reading from array var in exp
|
// which are used for reading from array var in exp
|
||||||
static void fillReadShortFixedSubscripts(SgExpression* exp, const PrivateToRemove& var,
|
static void fillReadShortFixedSubscripts(SgExpression* exp, const PrivateToRemove& var,
|
||||||
@@ -698,32 +664,6 @@ static void removeExcessiveDefs(const PrivateToRemove& var)
|
|||||||
st->deleteStmt();
|
st->deleteStmt();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove is needless
|
|
||||||
// removeEmptyLoops removes loops with empty body and create messages
|
|
||||||
//static void removeEmptyLoops(LoopGraph* loop, vector<Messages>& messages)
|
|
||||||
//{
|
|
||||||
// vector<LoopGraph*> loopsToDelete;
|
|
||||||
// vector<LoopGraph*> newChildrenVector;
|
|
||||||
// for (auto childLoop : loop->children)
|
|
||||||
// {
|
|
||||||
// SgStatement* loopStmt = childLoop->loop->GetOriginal();
|
|
||||||
// if (loopStmt->lastNodeOfStmt() == loopStmt->lexNext())
|
|
||||||
// loopsToDelete.push_back(childLoop);
|
|
||||||
// else
|
|
||||||
// newChildrenVector.push_back(childLoop);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (auto loopToDelete : loopsToDelete)
|
|
||||||
// {
|
|
||||||
// addMessageRemoveLoop(messages, loopToDelete->lineNum);
|
|
||||||
// loopToDelete->loop->extractStmt();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// loop->children.swap(newChildrenVector);
|
|
||||||
// for (auto childLoop : loop->children)
|
|
||||||
// removeEmptyLoops(childLoop, messages);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// removeVarFromPrivateAttributes removes var from SPF ANALYSIS PRIVATE attributes of loop
|
// removeVarFromPrivateAttributes removes var from SPF ANALYSIS PRIVATE attributes of loop
|
||||||
static void removeVarFromPrivateAttributes(SgSymbol* var, LoopGraph* loop)
|
static void removeVarFromPrivateAttributes(SgSymbol* var, LoopGraph* loop)
|
||||||
{
|
{
|
||||||
@@ -833,7 +773,7 @@ void removePrivates(string filename, vector<Messages>& messages,
|
|||||||
const map<string, vector<FuncInfo*>>& allFuncInfo,
|
const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||||
int& countOfTransform)
|
int& countOfTransform)
|
||||||
{
|
{
|
||||||
set<LoopGraph*> removedDC;
|
set<LoopGraph*> removeDC;
|
||||||
for (auto& varToRemove : privatesToRemoveGlobal)
|
for (auto& varToRemove : privatesToRemoveGlobal)
|
||||||
{
|
{
|
||||||
if (filename != varToRemove.loop->fileName)
|
if (filename != varToRemove.loop->fileName)
|
||||||
@@ -842,23 +782,10 @@ void removePrivates(string filename, vector<Messages>& messages,
|
|||||||
auto removedDimensions = removeArray(filename, varToRemove);
|
auto removedDimensions = removeArray(filename, varToRemove);
|
||||||
countOfTransform++;
|
countOfTransform++;
|
||||||
|
|
||||||
//removeDeadCodeFromLoop(varToRemove.loop);
|
|
||||||
removeExcessiveDefs(varToRemove);
|
removeExcessiveDefs(varToRemove);
|
||||||
//removeEmptyLoops(varToRemove.loop, messages);
|
removeDC.insert(varToRemove.loop);
|
||||||
|
|
||||||
SgForStmt* loopStmt = (SgForStmt*)varToRemove.loop->loop->GetOriginal();
|
vector<SgArrayRefExp*> varRefs = getDirectArrayRefs(varToRemove.loop->loop, varToRemove.varSymbol);
|
||||||
FuncInfo* currFunc = getCurrectFunc(loopStmt, allFuncInfo);
|
|
||||||
if (currFunc == nullptr)
|
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
|
||||||
|
|
||||||
if (removedDC.find(varToRemove.loop) == removedDC.end())
|
|
||||||
{
|
|
||||||
removeDeadCode(currFunc->funcPointer, allFuncInfo, commonBlocks,
|
|
||||||
varToRemove.loop->loop, varToRemove.loop->loop->lastNodeOfStmt());
|
|
||||||
removedDC.insert(varToRemove.loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<SgArrayRefExp*> varRefs = getDirectArrayRefs(loopStmt, varToRemove.varSymbol);
|
|
||||||
int loopLineNum = varToRemove.loop->lineNum;
|
int loopLineNum = varToRemove.loop->lineNum;
|
||||||
string varName = varToRemove.varSymbol->identifier();
|
string varName = varToRemove.varSymbol->identifier();
|
||||||
auto& fixedDimensions = varToRemove.fixedDimensions;
|
auto& fixedDimensions = varToRemove.fixedDimensions;
|
||||||
@@ -892,6 +819,18 @@ void removePrivates(string filename, vector<Messages>& messages,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& dcLoopRem : removeDC)
|
||||||
|
{
|
||||||
|
auto loopStmt = dcLoopRem->loop->GetOriginal();
|
||||||
|
FuncInfo* currFunc = getCurrectFunc(loopStmt, allFuncInfo);
|
||||||
|
|
||||||
|
if (currFunc == nullptr)
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
|
removeDeadCode(currFunc->funcPointer, allFuncInfo, commonBlocks,
|
||||||
|
loopStmt, loopStmt->lastNodeOfStmt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************** *
|
/* ****************************************** *
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2298"
|
#define VERSION_SPF "2301"
|
||||||
|
|||||||
@@ -1674,10 +1674,11 @@ int SPF_SetDistributionFlagToArrays(void*& context, const char* keys, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int simpleTransformPass(const passes PASS_NAME, short *options, short *projName, short *folderName,
|
static int simpleTransformPass(const passes PASS_NAME, short *options, short *projName, short *folderName,
|
||||||
short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize)
|
short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize,
|
||||||
|
bool isBuildParallel = false)
|
||||||
{
|
{
|
||||||
clearGlobalMessagesBuffer();
|
clearGlobalMessagesBuffer();
|
||||||
setOptions(options);
|
setOptions(options, isBuildParallel);
|
||||||
|
|
||||||
int retCode = 0;
|
int retCode = 0;
|
||||||
try
|
try
|
||||||
@@ -1892,7 +1893,7 @@ int SPF_SharedMemoryParallelization(void*& context, int winHandler, short* optio
|
|||||||
MessageManager::setWinHandler(winHandler);
|
MessageManager::setWinHandler(winHandler);
|
||||||
ignoreArrayDistributeState = true;
|
ignoreArrayDistributeState = true;
|
||||||
mpiProgram = 1;
|
mpiProgram = 1;
|
||||||
return simpleTransformPass(INSERT_PARALLEL_DIRS_NODIST, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize);
|
return simpleTransformPass(INSERT_PARALLEL_DIRS_NODIST, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SPF_InsertPrivateFromGUI(void*& context, int winHandler, short* options, short* projName, short* folderName, short*& output,
|
int SPF_InsertPrivateFromGUI(void*& context, int winHandler, short* options, short* projName, short* folderName, short*& output,
|
||||||
|
|||||||
Reference in New Issue
Block a user