fixed omp clearing pass, refactored
This commit is contained in:
@@ -619,7 +619,7 @@ void removeOmpDir(void* stIn)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void addToAttribute(SgStatement* st, int var, const vector<SgExpression*>& list)
|
||||
static inline void addToAttribute(SgStatement* st, int var, vector<SgExpression*> list)
|
||||
{
|
||||
if (list.size())
|
||||
{
|
||||
@@ -629,6 +629,89 @@ static inline void addToAttribute(SgStatement* st, int var, const vector<SgExpre
|
||||
toAdd->setlineNumber(st->lineNumber());
|
||||
toAdd->setLocalLineNumber(888);
|
||||
|
||||
//filter
|
||||
if (var == ACC_PRIVATE_OP)
|
||||
{
|
||||
vector<SgExpression*> list_new;
|
||||
|
||||
auto attributes = getAttributes<SgStatement*, SgStatement*>(st, set<int>{SPF_ANALYSIS_DIR});
|
||||
set<string> privates;
|
||||
for (auto& attr : attributes)
|
||||
fillPrivatesFromComment(new Statement(attr), privates);
|
||||
|
||||
if (privates.size())
|
||||
{
|
||||
for (auto& elem : list)
|
||||
if (privates.find(elem->unparse()) == privates.end())
|
||||
list_new.push_back(elem);
|
||||
list = list_new;
|
||||
|
||||
if (!list.size())
|
||||
{
|
||||
__spf_print(1, "-- skip privates on line %d from OMP dir\n%s", st->lineNumber(), toAdd->unparse());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (var == REDUCTION_OP)
|
||||
{
|
||||
auto attributes = getAttributes<SgStatement*, SgStatement*>(st, set<int>{SPF_ANALYSIS_DIR});
|
||||
map<string, set<string>> reduction;
|
||||
for (auto& attr : attributes)
|
||||
fillReductionsFromComment(new Statement(attr), reduction);
|
||||
|
||||
map<string, set<string>> reductionToAdd;
|
||||
fillReductionsFromComment(new Statement(st), reductionToAdd);
|
||||
|
||||
vector<SgExpression*> list_new;
|
||||
if (reduction.size())
|
||||
{
|
||||
if (reduction == reductionToAdd)
|
||||
{
|
||||
__spf_print(1, "-- skip reduction on line %d from OMP dir\n%s", st->lineNumber(), toAdd->unparse());
|
||||
return;
|
||||
}
|
||||
|
||||
map<string, set<string>> reductionToAddNew;
|
||||
for (auto& redPair : reductionToAdd)
|
||||
{
|
||||
auto it = reduction.find(redPair.first);
|
||||
if (it == reduction.end())
|
||||
reductionToAddNew[redPair.first] = redPair.second;
|
||||
else
|
||||
{
|
||||
set<string> newVar;
|
||||
for (auto& var : redPair.second)
|
||||
{
|
||||
auto itVar = it->second.find(var);
|
||||
if (itVar == it->second.end())
|
||||
reductionToAddNew[redPair.first].insert(var);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!reductionToAddNew.size())
|
||||
{
|
||||
__spf_print(1, "-- skip reduction on line %d from OMP dir\n%s", st->lineNumber(), toAdd->unparse());
|
||||
return;
|
||||
}
|
||||
|
||||
if (reductionToAddNew != reductionToAdd)
|
||||
{
|
||||
list.clear();
|
||||
for (auto& redPair : reductionToAddNew)
|
||||
for (auto& var : redPair.second)
|
||||
list.push_back(new SgExpression(ARRAY_OP,
|
||||
new SgKeywordValExp(redPair.first.c_str()),
|
||||
new SgVarRefExp(findSymbolOrCreate(current_file, var, NULL, getFuncStat(st)))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ex = new SgExprListExp();
|
||||
ex->setLhs(new SgExpression(var, makeExprList(list), NULL));
|
||||
toAdd = new SgStatement(SPF_ANALYSIS_DIR, NULL, NULL, ex, NULL, NULL);
|
||||
|
||||
st->addAttribute(SPF_ANALYSIS_DIR, toAdd, sizeof(SgStatement));
|
||||
|
||||
if (var == ACC_PRIVATE_OP)
|
||||
|
||||
@@ -1691,7 +1691,6 @@ static inline bool processStat(SgStatement *st, const string &currFile,
|
||||
map<pair<string, int>, set<SgStatement*>>& usersDirectives)
|
||||
{
|
||||
bool retVal = true;
|
||||
|
||||
if (st->variant() == SPF_PARALLEL_REG_DIR || st->variant() == SPF_END_PARALLEL_REG_DIR)
|
||||
{
|
||||
bool result = checkParallelRegions(st, commonBlocks, messagesForFile);
|
||||
@@ -1954,7 +1953,6 @@ bool preprocess_spf_dirs(SgFile *file, const map<string, CommonBlock*> &commonBl
|
||||
{
|
||||
int funcNum = file->numberOfFunctions();
|
||||
const string currFile = file->filename();
|
||||
|
||||
bool noError = true;
|
||||
|
||||
for (int i = 0; i < funcNum; ++i)
|
||||
|
||||
@@ -1283,4 +1283,80 @@ void DvmhRegionInserter::addUsedWriteArrays(set<DIST::Array*>& arrays)
|
||||
if (loop->inDvmhRegion == 1)
|
||||
arrays.insert(loop->usedArraysWriteAll.begin(), loop->usedArraysWriteAll.end());
|
||||
}
|
||||
}
|
||||
|
||||
void insertDvmhRegions(SgProject& project, int files, const vector<ParallelRegion*>& parallelRegions,
|
||||
map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
map<string, vector<LoopGraph*>> loopGraph,
|
||||
ReadWriteAnalyzer& rw_analyzer,
|
||||
const map<DIST::Array*, set<DIST::Array*>> arrayLinksByFuncCalls)
|
||||
{
|
||||
vector<DvmhRegionInserter*> inserters;
|
||||
const bool regionCondition = ((parallelRegions.size() == 0 && parallelRegions[0]->GetName() == "DEFAULT") || mpiProgram == 1);
|
||||
|
||||
set<DIST::Array*> usedArraysInRegions;
|
||||
set<DIST::Array*> usedWriteArraysInRegions;
|
||||
|
||||
for (int i = files - 1; i >= 0; --i)
|
||||
{
|
||||
SgFile* file = &(project.file(i));
|
||||
__spf_print(1, "Start region inserter for file %s\n", file->filename());
|
||||
|
||||
map<string, FuncInfo*> mapOfFuncs;
|
||||
createMapOfFunc(allFuncInfo, mapOfFuncs);
|
||||
|
||||
auto loopsForFile = getObjectForFileFromMap(file->filename(), loopGraph);
|
||||
auto funcsForFile = getObjectForFileFromMap(file->filename(), allFuncInfo);
|
||||
|
||||
for (auto& loop : loopsForFile)
|
||||
loop->analyzeParallelDirs();
|
||||
|
||||
DvmhRegionInserter* regionInserter = new DvmhRegionInserter(file, loopsForFile, rw_analyzer, arrayLinksByFuncCalls, mapOfFuncs, funcsForFile, mpiProgram == 1);
|
||||
inserters.push_back(regionInserter);
|
||||
|
||||
//collect info about <parallel> functions
|
||||
regionInserter->updateParallelFunctions(loopGraph);
|
||||
|
||||
if (regionCondition)
|
||||
regionInserter->insertDirectives(NULL);
|
||||
else
|
||||
regionInserter->insertDirectives(¶llelRegions);
|
||||
|
||||
//remove privates from loops out of DVMH region
|
||||
//remove parallel directives from loops out of DVMH region for MPI regime
|
||||
regionInserter->removePrivatesFromParallelLoops();
|
||||
|
||||
//add privates to parallel loops with manual parallelization in DVMH regions
|
||||
regionInserter->addPrivatesToParallelLoops();
|
||||
|
||||
regionInserter->addUsedArrays(usedArraysInRegions);
|
||||
regionInserter->addUsedWriteArrays(usedWriteArraysInRegions);
|
||||
|
||||
setPureStatus(regionInserter->getParallelFunctions());
|
||||
}
|
||||
|
||||
for (int i = files - 1, k = 0; i >= 0; --i, ++k)
|
||||
{
|
||||
SgFile* file = &(project.file(i));
|
||||
|
||||
DvmhRegionInserter* regionInserter = inserters[k];
|
||||
|
||||
for (auto& func : regionInserter->getParallelFunctions())
|
||||
createInterfacesForOutCalls(func);
|
||||
|
||||
// create interface for 'parallel' functions and
|
||||
// insert ROUTINE directive if needed
|
||||
regionInserter->createInterfaceBlockForParallelFunctions();
|
||||
}
|
||||
|
||||
for (auto& regionInserter : inserters)
|
||||
{
|
||||
regionInserter->updateUsedArrays(usedArraysInRegions, usedWriteArraysInRegions);
|
||||
|
||||
if (regionCondition)
|
||||
regionInserter->insertActualDirectives(NULL);
|
||||
else
|
||||
regionInserter->insertActualDirectives(¶llelRegions);
|
||||
delete regionInserter;
|
||||
}
|
||||
}
|
||||
@@ -105,3 +105,9 @@ public:
|
||||
delete reg;
|
||||
}
|
||||
};
|
||||
|
||||
void insertDvmhRegions(SgProject& project, int files, const std::vector<ParallelRegion*>& parallelRegions,
|
||||
std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo,
|
||||
std::map<std::string, std::vector<LoopGraph*>> loopGraph,
|
||||
ReadWriteAnalyzer& rw_analyzer,
|
||||
const std::map<DIST::Array*, std::set<DIST::Array*>> arrayLinksByFuncCalls);
|
||||
|
||||
@@ -24,6 +24,8 @@ using std::make_pair;
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
using std::to_string;
|
||||
using std::get;
|
||||
using std::tuple;
|
||||
|
||||
#define DEB 0
|
||||
|
||||
@@ -1632,10 +1634,10 @@ static map<FuncInfo*, set<SgStatement*>> fillNextDeep(const set<SgStatement*>& i
|
||||
return nextInfo;
|
||||
}
|
||||
|
||||
bool inliner(const string& fileName_in, const string& funcName, const int lineNumber,
|
||||
const map<string, vector<FuncInfo*>>& allFuncInfo, map<string, vector<Messages>>& SPF_messages,
|
||||
map<SgStatement*, set<SgSymbol*>>& newSymbsToDeclare, const map<string, CommonBlock*>& commonBlocks,
|
||||
int deepLvl)
|
||||
static bool inliner(const string& fileName_in, const string& funcName, const int lineNumber,
|
||||
const map<string, vector<FuncInfo*>>& allFuncInfo, map<string, vector<Messages>>& SPF_messages,
|
||||
map<SgStatement*, set<SgSymbol*>>& newSymbsToDeclare, const map<string, CommonBlock*>& commonBlocks,
|
||||
int deepLvl = 0)
|
||||
{
|
||||
map<string, FuncInfo*> funcMap;
|
||||
createMapOfFunc(allFuncInfo, funcMap);
|
||||
@@ -1759,10 +1761,10 @@ bool inliner(const string& fileName_in, const string& funcName, const int lineNu
|
||||
return true;
|
||||
}
|
||||
|
||||
bool inliner(const string& allInFunc, const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
map<string, vector<Messages>>& SPF_messages,
|
||||
map<SgStatement*, set<SgSymbol*>>& newSymbsToDeclare, const map<string, CommonBlock*>& commonBlocks,
|
||||
int deepLvl)
|
||||
static bool inliner(const string& allInFunc, const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
map<string, vector<Messages>>& SPF_messages,
|
||||
map<SgStatement*, set<SgSymbol*>>& newSymbsToDeclare, const map<string, CommonBlock*>& commonBlocks,
|
||||
int deepLvl = 0)
|
||||
{
|
||||
bool result = true;
|
||||
map<string, FuncInfo*> funcMap;
|
||||
@@ -1944,7 +1946,7 @@ static bool addNewCommonDecl(SgSymbol* toDec, const int posNum, const string& co
|
||||
return false;
|
||||
}
|
||||
|
||||
void createDeclarations(const map<SgStatement*, set<SgSymbol*>>& newSymbsToDeclare, const map<string, CommonBlock*>& commonBlocks)
|
||||
static void createDeclarations(const map<SgStatement*, set<SgSymbol*>>& newSymbsToDeclare, const map<string, CommonBlock*>& commonBlocks)
|
||||
{
|
||||
map<pair<string, int>, map<string, string>> preprocDataByFunc; // key is <funcName, int>
|
||||
map<pair<string, int>, map<string, SgExpression*>> initValue;
|
||||
@@ -2349,3 +2351,135 @@ void createDeclarations(const map<SgStatement*, set<SgSymbol*>>& newSymbsToDecla
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void convertLinesToAbsolute(const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
vector<tuple<string, string, int>>& inDataProc)
|
||||
{
|
||||
for (int z = 0; z < inDataProc.size(); ++z)
|
||||
{
|
||||
if (std::get<2>(inDataProc[z]) > 0)
|
||||
continue;
|
||||
|
||||
auto funcToInl = std::get<0>(inDataProc[z]);
|
||||
auto file = std::get<1>(inDataProc[z]);
|
||||
int absoluteLine = 0;
|
||||
int shilftLine = -std::get<2>(inDataProc[z]);
|
||||
|
||||
for (auto& funcByFile : allFuncInfo)
|
||||
{
|
||||
if (funcByFile.first != file)
|
||||
continue;
|
||||
|
||||
for (auto& func : funcByFile.second)
|
||||
{
|
||||
int targetLine = func->linesNum.first + shilftLine;
|
||||
__spf_print(1, "%s target %d + %d = %d\n", func->funcName.c_str(), func->linesNum.first, shilftLine, targetLine);
|
||||
for (auto& detCall : func->callsFromDetailed)
|
||||
{
|
||||
__spf_print(1, "%s %d\n", detCall.detailCallsFrom.first.c_str(), detCall.detailCallsFrom.second);
|
||||
if (detCall.detailCallsFrom == make_pair(funcToInl, targetLine))
|
||||
{
|
||||
absoluteLine = targetLine;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (absoluteLine)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (absoluteLine == 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
std::get<2>(inDataProc[z]) = absoluteLine;
|
||||
}
|
||||
}
|
||||
|
||||
void callInliner(const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
vector<tuple<string, string, int>>& inDataProc,
|
||||
map<string, set<pair<string, int>>>& inDataChains,
|
||||
const set<string>& inDataChainsStart,
|
||||
map<string, vector<Messages>>& SPF_messages,
|
||||
const map<string, CommonBlock*>& commonBlocks)
|
||||
{
|
||||
map<SgStatement*, set<SgSymbol*>> newSymbsToDeclare;
|
||||
map<string, FuncInfo*> tmpM;
|
||||
createMapOfFunc(allFuncInfo, tmpM);
|
||||
FuncInfo* mainF = NULL;
|
||||
for (auto& elem : tmpM)
|
||||
if (elem.second->isMain)
|
||||
mainF = elem.second;
|
||||
checkNull(mainF, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
#if 0
|
||||
//inliner(mainF->funcName, allFuncInfo, SPF_messages, newSymbsToDeclare);
|
||||
#else
|
||||
|
||||
if (inDataProc.size())
|
||||
{
|
||||
convertLinesToAbsolute(allFuncInfo, inDataProc);
|
||||
|
||||
map<int, vector<int>> sortByLvl;
|
||||
int maxLvlCall = 0;
|
||||
|
||||
for (int z = 0; z < inDataProc.size(); ++z)
|
||||
{
|
||||
if (std::get<2>(inDataProc[z]) != -1)
|
||||
{
|
||||
int lvl = getLvlCall(mainF, 0, std::get<0>(inDataProc[z]), std::get<1>(inDataProc[z]), std::get<2>(inDataProc[z]));
|
||||
if (lvl == -1)
|
||||
{
|
||||
bool found = false;
|
||||
for (auto& func : tmpM)
|
||||
{
|
||||
if (func.second->isMain)
|
||||
continue;
|
||||
int lvlTmp = getLvlCall(func.second, 0, std::get<0>(inDataProc[z]), std::get<1>(inDataProc[z]), std::get<2>(inDataProc[z]));
|
||||
if (lvlTmp != -1)
|
||||
lvl = std::max(lvl, lvlTmp);
|
||||
}
|
||||
|
||||
if (lvl == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
maxLvlCall = std::max(maxLvlCall, lvl);
|
||||
sortByLvl[lvl].push_back(z);
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = 0; z < inDataProc.size(); ++z)
|
||||
if (std::get<2>(inDataProc[z]) == -1)
|
||||
sortByLvl[maxLvlCall + 1].push_back(z);
|
||||
|
||||
for (auto& byLvl : sortByLvl)
|
||||
{
|
||||
for (auto& idx : byLvl.second)
|
||||
{
|
||||
auto& tup = inDataProc[idx];
|
||||
|
||||
if (std::get<2>(tup) != -1)
|
||||
{
|
||||
__spf_print(1, " call inliner with [%s %s %d]\n", std::get<1>(tup).c_str(), std::get<0>(tup).c_str(), std::get<2>(tup));
|
||||
bool isInlined = inliner(std::get<1>(tup), std::get<0>(tup), std::get<2>(tup), allFuncInfo, SPF_messages, newSymbsToDeclare, commonBlocks);
|
||||
if (!isInlined)
|
||||
{
|
||||
__spf_print(1, " missing ...\n");
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inDataChains.size())
|
||||
{
|
||||
setInlineAttributeToCalls(tmpM, inDataChains, hiddenData);
|
||||
|
||||
for (auto& startPoint : inDataChainsStart)
|
||||
{
|
||||
__spf_print(1, "call inliner from '%s'\n", startPoint.c_str());
|
||||
inliner(startPoint, allFuncInfo, SPF_messages, newSymbsToDeclare, commonBlocks);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
createDeclarations(newSymbsToDeclare, commonBlocks);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
bool inliner(const std::string& fileName, const std::string& funcName, const int lineNumber, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, std::map<std::string, std::vector<Messages>>& SPF_messages, std::map<SgStatement*, std::set<SgSymbol*>>& newSymbsToDeclare, const std::map<std::string, CommonBlock*>& commonBlocks, int deepLvl = 0);
|
||||
bool inliner(const std::string& allInFunc, const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, std::map<std::string, std::vector<Messages>>& SPF_messages, std::map<SgStatement*, std::set<SgSymbol*>>& newSymbsToDeclare, const std::map<std::string, CommonBlock*>& commonBlocks, int deepLvl = 0);
|
||||
void createDeclarations(const std::map<SgStatement*, std::set<SgSymbol*>>& newSymbsToDeclare, const std::map<std::string, CommonBlock*>& commonBlocks);
|
||||
void callInliner(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo,
|
||||
std::vector<std::tuple<std::string, std::string, int>>& inDataProc,
|
||||
std::map<std::string, std::set<std::pair<std::string, int>>>& inDataChains,
|
||||
const std::set<std::string>& inDataChainsStart,
|
||||
std::map<std::string, std::vector<Messages>>& SPF_messages,
|
||||
const std::map<std::string, CommonBlock*>& commonBlocks);
|
||||
|
||||
@@ -2020,200 +2020,9 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
else if (curr_regime == CREATE_PARALLEL_DIRS)
|
||||
filterParallelDirectives(loopGraph, createdDirectives);
|
||||
else if (curr_regime == INLINE_PROCEDURES)
|
||||
{
|
||||
map<SgStatement*, set<SgSymbol*>> newSymbsToDeclare;
|
||||
map<string, FuncInfo*> tmpM;
|
||||
createMapOfFunc(allFuncInfo, tmpM);
|
||||
FuncInfo* mainF = NULL;
|
||||
for (auto& elem : tmpM)
|
||||
if (elem.second->isMain)
|
||||
mainF = elem.second;
|
||||
checkNull(mainF, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
#if 0
|
||||
//inliner(mainF->funcName, allFuncInfo, SPF_messages, newSymbsToDeclare);
|
||||
#else
|
||||
|
||||
if (inDataProc.size())
|
||||
{
|
||||
// if inlineI -> fixed lines
|
||||
if (inDataChains.size() == 0 && inDataChainsStart.size() == 0)
|
||||
{
|
||||
for (int z = 0; z < inDataProc.size(); ++z)
|
||||
{
|
||||
if (std::get<2>(inDataProc[z]) > 0)
|
||||
continue;
|
||||
|
||||
auto funcToInl = std::get<0>(inDataProc[z]);
|
||||
auto file = std::get<1>(inDataProc[z]);
|
||||
int absoluteLine = 0;
|
||||
int shilftLine = -std::get<2>(inDataProc[z]);
|
||||
|
||||
for (auto& funcByFile : allFuncInfo)
|
||||
{
|
||||
if (funcByFile.first != file)
|
||||
continue;
|
||||
|
||||
for (auto& func : funcByFile.second)
|
||||
{
|
||||
int targetLine = func->linesNum.first + shilftLine;
|
||||
__spf_print(1, "%s target %d + %d = %d\n", func->funcName.c_str(), func->linesNum.first, shilftLine, targetLine);
|
||||
for (auto& detCall : func->callsFromDetailed)
|
||||
{
|
||||
__spf_print(1, "%s %d\n", detCall.detailCallsFrom.first.c_str(), detCall.detailCallsFrom.second);
|
||||
if (detCall.detailCallsFrom == make_pair(funcToInl, targetLine))
|
||||
{
|
||||
absoluteLine = targetLine;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (absoluteLine)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (absoluteLine == 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
std::get<2>(inDataProc[z]) = absoluteLine;
|
||||
}
|
||||
}
|
||||
|
||||
map<int, vector<int>> sortByLvl;
|
||||
|
||||
int maxLvlCall = 0;
|
||||
for (int z = 0; z < inDataProc.size(); ++z)
|
||||
{
|
||||
if (std::get<2>(inDataProc[z]) != -1)
|
||||
{
|
||||
int lvl = getLvlCall(mainF, 0, std::get<0>(inDataProc[z]), std::get<1>(inDataProc[z]), std::get<2>(inDataProc[z]));
|
||||
if (lvl == -1)
|
||||
{
|
||||
bool found = false;
|
||||
for (auto& func : tmpM)
|
||||
{
|
||||
if (func.second->isMain)
|
||||
continue;
|
||||
int lvlTmp = getLvlCall(func.second, 0, std::get<0>(inDataProc[z]), std::get<1>(inDataProc[z]), std::get<2>(inDataProc[z]));
|
||||
if (lvlTmp != -1)
|
||||
lvl = std::max(lvl, lvlTmp);
|
||||
}
|
||||
|
||||
if (lvl == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
maxLvlCall = std::max(maxLvlCall, lvl);
|
||||
sortByLvl[lvl].push_back(z);
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = 0; z < inDataProc.size(); ++z)
|
||||
if (std::get<2>(inDataProc[z]) == -1)
|
||||
sortByLvl[maxLvlCall + 1].push_back(z);
|
||||
|
||||
for (auto& byLvl : sortByLvl)
|
||||
{
|
||||
for (auto& idx : byLvl.second)
|
||||
{
|
||||
auto& tup = inDataProc[idx];
|
||||
|
||||
if (std::get<2>(tup) != -1)
|
||||
{
|
||||
__spf_print(1, " call inliner with [%s %s %d]\n", std::get<1>(tup).c_str(), std::get<0>(tup).c_str(), std::get<2>(tup));
|
||||
bool isInlined = inliner(std::get<1>(tup), std::get<0>(tup), std::get<2>(tup), allFuncInfo, SPF_messages, newSymbsToDeclare, commonBlocks);
|
||||
if (!isInlined)
|
||||
{
|
||||
__spf_print(1, " missing ...\n");
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inDataChains.size())
|
||||
{
|
||||
setInlineAttributeToCalls(tmpM, inDataChains, hiddenData);
|
||||
|
||||
for (auto& startPoint : inDataChainsStart)
|
||||
{
|
||||
__spf_print(1, "call inliner from '%s'\n", startPoint.c_str());
|
||||
inliner(startPoint, allFuncInfo, SPF_messages, newSymbsToDeclare, commonBlocks);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
createDeclarations(newSymbsToDeclare, commonBlocks);
|
||||
}
|
||||
callInliner(allFuncInfo, inDataProc, inDataChains, inDataChainsStart, SPF_messages, commonBlocks);
|
||||
else if (curr_regime == INSERT_REGIONS)
|
||||
{
|
||||
vector<DvmhRegionInserter*> inserters;
|
||||
const bool regionCondition = ((parallelRegions.size() == 0 && parallelRegions[0]->GetName() == "DEFAULT") || mpiProgram == 1);
|
||||
|
||||
set<DIST::Array*> usedArraysInRegions;
|
||||
set<DIST::Array*> usedWriteArraysInRegions;
|
||||
|
||||
for (int i = n - 1; i >= 0; --i)
|
||||
{
|
||||
SgFile* file = &(project.file(i));
|
||||
__spf_print(1, "Start region inserter for file %s\n", file->filename());
|
||||
|
||||
map<string, FuncInfo*> mapOfFuncs;
|
||||
createMapOfFunc(allFuncInfo, mapOfFuncs);
|
||||
|
||||
auto loopsForFile = getObjectForFileFromMap(file->filename(), loopGraph);
|
||||
auto funcsForFile = getObjectForFileFromMap(file->filename(), allFuncInfo);
|
||||
|
||||
for (auto& loop : loopsForFile)
|
||||
loop->analyzeParallelDirs();
|
||||
|
||||
DvmhRegionInserter* regionInserter = new DvmhRegionInserter(file, loopsForFile, rw_analyzer, arrayLinksByFuncCalls, mapOfFuncs, funcsForFile, mpiProgram == 1);
|
||||
inserters.push_back(regionInserter);
|
||||
|
||||
//collect info about <parallel> functions
|
||||
regionInserter->updateParallelFunctions(loopGraph);
|
||||
|
||||
if (regionCondition)
|
||||
regionInserter->insertDirectives(NULL);
|
||||
else
|
||||
regionInserter->insertDirectives(¶llelRegions);
|
||||
|
||||
//remove privates from loops out of DVMH region
|
||||
//remove parallel directives from loops out of DVMH region for MPI regime
|
||||
regionInserter->removePrivatesFromParallelLoops();
|
||||
|
||||
//add privates to parallel loops with manual parallelization in DVMH regions
|
||||
regionInserter->addPrivatesToParallelLoops();
|
||||
|
||||
regionInserter->addUsedArrays(usedArraysInRegions);
|
||||
regionInserter->addUsedWriteArrays(usedWriteArraysInRegions);
|
||||
|
||||
setPureStatus(regionInserter->getParallelFunctions());
|
||||
}
|
||||
|
||||
for (int i = n - 1, k = 0; i >= 0; --i, ++k)
|
||||
{
|
||||
SgFile* file = &(project.file(i));
|
||||
|
||||
DvmhRegionInserter* regionInserter = inserters[k];
|
||||
|
||||
for (auto& func : regionInserter->getParallelFunctions())
|
||||
createInterfacesForOutCalls(func);
|
||||
|
||||
// create interface for 'parallel' functions and
|
||||
// insert ROUTINE directive if needed
|
||||
regionInserter->createInterfaceBlockForParallelFunctions();
|
||||
}
|
||||
|
||||
for (auto& regionInserter : inserters)
|
||||
{
|
||||
regionInserter->updateUsedArrays(usedArraysInRegions, usedWriteArraysInRegions);
|
||||
|
||||
if (regionCondition)
|
||||
regionInserter->insertActualDirectives(NULL);
|
||||
else
|
||||
regionInserter->insertActualDirectives(¶llelRegions);
|
||||
delete regionInserter;
|
||||
}
|
||||
}
|
||||
insertDvmhRegions(project, n, parallelRegions, allFuncInfo, loopGraph, rw_analyzer, arrayLinksByFuncCalls);
|
||||
else if (curr_regime == RENAME_SYMBOLS)
|
||||
runRenameSymbols(&project, commonBlocks);
|
||||
else if (curr_regime == FIND_PARAMETERS)
|
||||
@@ -2651,7 +2460,6 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
case INSERT_INCLUDES:
|
||||
case REMOVE_DVM_DIRS:
|
||||
case REMOVE_DVM_DIRS_TO_COMMENTS:
|
||||
case REMOVE_OMP_DIRS:
|
||||
case PRIVATE_ARRAYS_EXPANSION:
|
||||
case PRIVATE_ARRAYS_SHRINKING:
|
||||
case UNROLL_LOOPS:
|
||||
@@ -2660,6 +2468,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
case SET_TO_ALL_DECL_INIT_ZERO:
|
||||
case CREATE_CHECKPOINTS:
|
||||
case PURE_INTENT_INSERT:
|
||||
case REMOVE_OMP_DIRS_TRANSFORM:
|
||||
runAnalysis(*project, curr_regime, true, "", folderName);
|
||||
break;
|
||||
case PRIVATE_REMOVING:
|
||||
|
||||
@@ -168,6 +168,7 @@ enum passes {
|
||||
|
||||
FIX_COMMON_BLOCKS,
|
||||
REMOVE_OMP_DIRS,
|
||||
REMOVE_OMP_DIRS_TRANSFORM,
|
||||
GET_MIN_MAX_BLOCK_DIST,
|
||||
|
||||
TEST_PASS,
|
||||
@@ -342,6 +343,7 @@ static void setPassValues()
|
||||
|
||||
passNames[FIX_COMMON_BLOCKS] = "FIX_COMMON_BLOCKS";
|
||||
passNames[REMOVE_OMP_DIRS] = "REMOVE_OMP_DIRS";
|
||||
passNames[REMOVE_OMP_DIRS_TRANSFORM] = "REMOVE_OMP_DIRS_TRANSFORM";
|
||||
passNames[GET_MIN_MAX_BLOCK_DIST] = "GET_MIN_MAX_BLOCK_DIST";
|
||||
|
||||
passNames[TEST_PASS] = "TEST_PASS";
|
||||
|
||||
@@ -304,6 +304,8 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
Pass(CALL_GRAPH2) <= Pass(FIX_COMMON_BLOCKS);
|
||||
|
||||
Pass(REMOVE_OMP_DIRS) <= Pass(REMOVE_OMP_DIRS_TRANSFORM);
|
||||
|
||||
passesIgnoreStateDone.insert({ CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS, INSERT_SHADOW_DIRS, EXTRACT_PARALLEL_DIRS,
|
||||
EXTRACT_SHADOW_DIRS, CREATE_REMOTES, UNPARSE_FILE, REMOVE_AND_CALC_SHADOW,
|
||||
REVERSE_CREATED_NESTED_LOOPS, PREDICT_SCHEME, CALCULATE_STATS_SCHEME, REVERT_SPF_DIRS, CLEAR_SPF_DIRS, TRANSFORM_SHADOW_IF_FULL,
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2245"
|
||||
#define VERSION_SPF "2247"
|
||||
|
||||
@@ -1783,7 +1783,7 @@ int SPF_RemoveOmpDirectives(void*& context, int winHandler, short* options, shor
|
||||
{
|
||||
MessageManager::clearCache();
|
||||
MessageManager::setWinHandler(winHandler);
|
||||
return simpleTransformPass(REMOVE_OMP_DIRS, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize);
|
||||
return simpleTransformPass(REMOVE_OMP_DIRS_TRANSFORM, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize);
|
||||
}
|
||||
|
||||
int SPF_RemoveDvmDirectives(void*& context, int winHandler, short *options, short *projName, short *folderName, short *&output,
|
||||
|
||||
Reference in New Issue
Block a user