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

@@ -436,7 +436,7 @@ DEFNODECODE(SPF_MERGE_OP, "MERGE",
'e',0,LLNODE) 'e',0,LLNODE)
DEFNODECODE(SPF_COVER_OP, "COVER (%LL1)", DEFNODECODE(SPF_COVER_OP, "COVER (%LL1)",
'e',1,LLNODE) 'e',1,LLNODE)
DEFNODECODE(SPF_PROCESS_PRIVATE_OP, "PROCESS_PRIVATE_OP (%LL1)", DEFNODECODE(SPF_PROCESS_PRIVATE_OP, "PROCESS_PRIVATE (%LL1)",
'e',1,LLNODE) 'e',1,LLNODE)

View File

@@ -134,14 +134,7 @@ void selectParallelDirectiveForVariantNoDist(File* file, ParallelRegion* currPar
#if __SPF #if __SPF
//move label before loop //move label before loop
if (loop->hasRedistribute()) if(loop->lineNum > 0)
{
auto prev = loop->loop->lexPrev();
if (!prev)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
moveLabelBefore(prev, loop->loop);
}
else if(loop->lineNum > 0)
moveLabelBefore(loop->loop, NULL); moveLabelBefore(loop->loop, NULL);
// check correctness // check correctness

View File

@@ -106,7 +106,7 @@ static bool isPrivateVar(SgStatement *st, SgSymbol *symbol)
return retVal; 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); \ __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;\ 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()); \ __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) 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; retVal = false;
} }
} }
} }
else 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; retVal = false;
} }
@@ -308,7 +308,7 @@ static bool checkPrivate(SgStatement *st,
} }
else 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; retVal = false;
} }
@@ -372,7 +372,7 @@ static bool checkReduction(SgStatement *st,
} }
else 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; retVal = false;
} }
@@ -769,7 +769,7 @@ static bool checkShadowAcross(SgStatement *st,
} }
else 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; retVal = false;
} }
@@ -993,7 +993,7 @@ static bool checkRemote(SgStatement *st,
} }
else 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; retVal = false;
} }
@@ -1225,7 +1225,7 @@ static bool checkParallelRegions(SgStatement *st,
} }
else 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; retVal = false;
} }
@@ -1814,7 +1814,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1); attributeStatement->setLocalLineNumber(-1);
if (count > 1 || st->variant() != FOR_NODE) 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; retVal = false;
} }
else else
@@ -1858,7 +1858,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
const int prevVar = prev->variant(); const int prevVar = prev->variant();
if (prevVar != PROC_HEDR && prevVar != FUNC_HEDR) 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; retVal = false;
} }
} }
@@ -1869,7 +1869,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1); attributeStatement->setLocalLineNumber(-1);
if (count > 1 || st->variant() != FOR_NODE) 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; retVal = false;
} }
else else
@@ -1885,7 +1885,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1); attributeStatement->setLocalLineNumber(-1);
if (count > 1 || st->variant() != FOR_NODE) 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; retVal = false;
} }
else else
@@ -1901,7 +1901,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1); attributeStatement->setLocalLineNumber(-1);
if (st->variant() != FOR_NODE) 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; retVal = false;
} }
else else
@@ -1917,7 +1917,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1); attributeStatement->setLocalLineNumber(-1);
if (st->variant() != FOR_NODE) 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; retVal = false;
} }
} }
@@ -1928,7 +1928,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
attributeStatement->setLocalLineNumber(-1); attributeStatement->setLocalLineNumber(-1);
if (st->variant() != FOR_NODE) 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; retVal = false;
} }
} }

View File

@@ -29,11 +29,12 @@ using std::map;
using std::make_pair; using std::make_pair;
static vector<SgExpression*> 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<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls,
const map<string, set<SgSymbol*>>& byUseInFunc, const map<string, set<SgSymbol*>>& byUseInFunc,
File* file, const pair<int, int>& lineRange, File* file, const pair<int, int>& lineRange)
const set<DIST::Array*>& onlyFor)
{ {
vector<SgExpression*> tieList; vector<SgExpression*> tieList;
@@ -44,6 +45,9 @@ compliteTieListNoDist(const LoopGraph* currLoop, const vector<LoopGraph*>& loops
for (auto& elem : currLoop->usedArraysAll) for (auto& elem : currLoop->usedArraysAll)
{ {
if (privates.find(elem->GetShortName()) != privates.end())
continue;
auto type = elem->GetDeclSymbol(currLoop->fileName, lineRange, getAllFilesInProject())->GetOriginal()->type(); auto type = elem->GetDeclSymbol(currLoop->fileName, lineRange, getAllFilesInProject())->GetOriginal()->type();
SgSymbol* arrayS = getFromModule(byUseInFunc, findSymbolOrCreate(file, elem->GetShortName(), type)); SgSymbol* arrayS = getFromModule(byUseInFunc, findSymbolOrCreate(file, elem->GetShortName(), type));
SgArrayRefExp* array = new SgArrayRefExp(*arrayS); SgArrayRefExp* array = new SgArrayRefExp(*arrayS);
@@ -233,11 +237,8 @@ ParallelDirective::genDirectiveNoDist(File* file, LoopGraph* currLoop, DIST::Arr
if (parallel[i] != "*") if (parallel[i] != "*")
loopsTie.push_back(loops[i]); loopsTie.push_back(loops[i]);
set<DIST::Array*> onlyFor;
vector<SgExpression*> tieList; vector<SgExpression*> tieList;
tieList = compliteTieListNoDist(currLoop, uniqNamesOfPrivates, loopsTie, arrayLinksByFuncCalls, byUseInFunc, file, lineRange);
tieList = compliteTieListNoDist(currLoop, loopsTie, arrayLinksByFuncCalls, byUseInFunc, file, lineRange, onlyFor);
if (tieList.size()) 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, void addPrivatesToArraysFromGUI(SgFile* file, const map<tuple<int, string, string>, pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays,
const map<string, int>& distrStateFromGUI) const map<string, int>& distrStateFromGUI)
{ {
map<SgStatement*, set<string>> added; map<SgStatement*, set<SgSymbol*>> added;
for (auto& arrayPair : declaredArrays) 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); SgStatement* declSt = SgStatement::getStatementByFileAndLine(place.first, place.second);
checkNull(declSt, convertFileName(__FILE__).c_str(), __LINE__); checkNull(declSt, convertFileName(__FILE__).c_str(), __LINE__);
string toAdd = "!$SPF ANALYSIS(PRIVATE(" + string(symb->identifier()) + "))\n"; added[declSt].insert(symb);
added[declSt].insert(toAdd);
} }
} }
for (auto& toInsert : added) for (auto& toInsert : added)
{
vector<SgExpression*> list;
for (auto& elem : toInsert.second) 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 #pragma once
#define VERSION_SPF "2311" #define VERSION_SPF "2314"