fixed TIE for shared parallelization, fixed messages, fixed privates insertion pass

This commit is contained in:
ALEXks
2024-04-10 13:42:49 +03:00
parent b0a63cc711
commit ba70047ebf
6 changed files with 39 additions and 37 deletions

View File

@@ -134,14 +134,7 @@ void selectParallelDirectiveForVariantNoDist(File* file, ParallelRegion* currPar
#if __SPF
//move label before loop
if (loop->hasRedistribute())
{
auto prev = loop->loop->lexPrev();
if (!prev)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
moveLabelBefore(prev, loop->loop);
}
else if(loop->lineNum > 0)
if(loop->lineNum > 0)
moveLabelBefore(loop->loop, NULL);
// check correctness
@@ -157,7 +150,7 @@ void selectParallelDirectiveForVariantNoDist(File* file, ParallelRegion* currPar
checkNull(local, convertFileName(__FILE__).c_str(), __LINE__);
}
#endif
toInsert.push_back(dirImpl);
toInsert.push_back(dirImpl);
}
}
else //TODO: add checker for indexing in this loop

View File

@@ -106,7 +106,7 @@ static bool isPrivateVar(SgStatement *st, SgSymbol *symbol)
return retVal;
}
#define BAD_POSITION_FULL(NEED_PRINT, ERR_TYPE, PLACE_E, PLACE_R, BEFORE_VAR_E, BEFORE_VAR_R, BEFORE_DO_E, BEFORE_DO_R, LINE) do { \
#define BAD_POSITION_FULL(ERR_TYPE, PLACE_E, PLACE_R, BEFORE_VAR_E, BEFORE_VAR_R, BEFORE_DO_E, BEFORE_DO_R, LINE) do { \
__spf_print(1, "bad directive position on line %d, it can be placed only %s %s %s\n", LINE, PLACE_E, BEFORE_VAR_E, BEFORE_DO_E); \
wstring messageE, messageR;\
__spf_printToLongBuf(messageE, L"bad directive position, it can be placed only %s %s %s", to_wstring(PLACE_E).c_str(), to_wstring(BEFORE_VAR_E).c_str(), to_wstring(BEFORE_DO_E).c_str()); \
@@ -212,14 +212,14 @@ static bool checkProcessPrivate(SgStatement* st,
if (!defCond)
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "variable declaration", RR1_2, "", L"", attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "before", RR1_1, "variable declaration", RR1_2, "", L" ", attributeStatement->lineNumber());
retVal = false;
}
}
}
else
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "variable declaration", RR1_2, "", L"", attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "before", RR1_1, "variable declaration", RR1_2, "", L" ", attributeStatement->lineNumber());
retVal = false;
}
@@ -308,7 +308,7 @@ static bool checkPrivate(SgStatement *st,
}
else
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
@@ -372,7 +372,7 @@ static bool checkReduction(SgStatement *st,
}
else
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
@@ -769,7 +769,7 @@ static bool checkShadowAcross(SgStatement *st,
}
else
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
@@ -993,7 +993,7 @@ static bool checkRemote(SgStatement *st,
}
else
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
@@ -1225,7 +1225,7 @@ static bool checkParallelRegions(SgStatement *st,
}
else
{
BAD_POSITION_FULL(1, ERROR, "after", RR1_4, "", L"", "all declaration statements", RR1_5, st->lineNumber());
BAD_POSITION_FULL(ERROR, "after", RR1_4, "", L"", "all declaration statements", RR1_5, st->lineNumber());
retVal = false;
}
@@ -1814,7 +1814,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1);
if (count > 1 || st->variant() != FOR_NODE)
{
BAD_POSITION_FULL(1, ERROR, "once", RR1_7, "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "once", RR1_7, "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
else
@@ -1858,7 +1858,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
const int prevVar = prev->variant();
if (prevVar != PROC_HEDR && prevVar != FUNC_HEDR)
{
BAD_POSITION_FULL(1, ERROR, "after", RR1_4, "", L"", "function statements", RR1_6, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "after", RR1_4, "", L"", "function statements", RR1_6, attributeStatement->lineNumber());
retVal = false;
}
}
@@ -1869,7 +1869,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1);
if (count > 1 || st->variant() != FOR_NODE)
{
BAD_POSITION_FULL(1, ERROR, "once", RR1_7, "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "once", RR1_7, "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
else
@@ -1885,7 +1885,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1);
if (count > 1 || st->variant() != FOR_NODE)
{
BAD_POSITION_FULL(1, ERROR, "once", RR1_7, "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "once", RR1_7, "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
else
@@ -1901,7 +1901,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1);
if (st->variant() != FOR_NODE)
{
BAD_POSITION_FULL(1, ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
else
@@ -1917,7 +1917,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1);
if (st->variant() != FOR_NODE)
{
BAD_POSITION_FULL(1, ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
}
@@ -1928,7 +1928,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1);
if (st->variant() != FOR_NODE)
{
BAD_POSITION_FULL(1, ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
}

View File

@@ -29,11 +29,12 @@ using std::map;
using std::make_pair;
static vector<SgExpression*>
compliteTieListNoDist(const LoopGraph* currLoop, const vector<LoopGraph*>& loops,
compliteTieListNoDist(const LoopGraph* currLoop,
const set<string>& privates,
const vector<LoopGraph*>& loops,
const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls,
const map<string, set<SgSymbol*>>& byUseInFunc,
File* file, const pair<int, int>& lineRange,
const set<DIST::Array*>& onlyFor)
File* file, const pair<int, int>& lineRange)
{
vector<SgExpression*> tieList;
@@ -44,6 +45,9 @@ compliteTieListNoDist(const LoopGraph* currLoop, const vector<LoopGraph*>& loops
for (auto& elem : currLoop->usedArraysAll)
{
if (privates.find(elem->GetShortName()) != privates.end())
continue;
auto type = elem->GetDeclSymbol(currLoop->fileName, lineRange, getAllFilesInProject())->GetOriginal()->type();
SgSymbol* arrayS = getFromModule(byUseInFunc, findSymbolOrCreate(file, elem->GetShortName(), type));
SgArrayRefExp* array = new SgArrayRefExp(*arrayS);
@@ -233,11 +237,8 @@ ParallelDirective::genDirectiveNoDist(File* file, LoopGraph* currLoop, DIST::Arr
if (parallel[i] != "*")
loopsTie.push_back(loops[i]);
set<DIST::Array*> onlyFor;
vector<SgExpression*> tieList;
tieList = compliteTieListNoDist(currLoop, loopsTie, arrayLinksByFuncCalls, byUseInFunc, file, lineRange, onlyFor);
tieList = compliteTieListNoDist(currLoop, uniqNamesOfPrivates, loopsTie, arrayLinksByFuncCalls, byUseInFunc, file, lineRange);
if (tieList.size())
{

View File

@@ -3543,10 +3543,11 @@ void getMaxMinBlockDistribution(SgFile* file, pair<int, int>& min_max)
}
}
//TODO: need to add to includes
void addPrivatesToArraysFromGUI(SgFile* file, const map<tuple<int, string, string>, pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays,
const map<string, int>& distrStateFromGUI)
{
map<SgStatement*, set<string>> added;
map<SgStatement*, set<SgSymbol*>> added;
for (auto& arrayPair : declaredArrays)
{
@@ -3570,12 +3571,19 @@ void addPrivatesToArraysFromGUI(SgFile* file, const map<tuple<int, string, strin
SgStatement* declSt = SgStatement::getStatementByFileAndLine(place.first, place.second);
checkNull(declSt, convertFileName(__FILE__).c_str(), __LINE__);
string toAdd = "!$SPF ANALYSIS(PRIVATE(" + string(symb->identifier()) + "))\n";
added[declSt].insert(toAdd);
added[declSt].insert(symb);
}
}
for (auto& toInsert : added)
{
vector<SgExpression*> list;
for (auto& elem : toInsert.second)
toInsert.first->addComment(elem.c_str());
list.push_back(new SgVarRefExp(elem));
SgStatement* op = new SgStatement(SPF_ANALYSIS_DIR);
op->setExpression(0, new SgExpression(SPF_PROCESS_PRIVATE_OP, makeExprList(list)));
toInsert.first->insertStmtBefore(*op, *toInsert.first->controlParent());
}
}

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2311"
#define VERSION_SPF "2314"