fixed DECLARE

This commit is contained in:
ALEXks
2025-01-13 18:16:11 +03:00
committed by Dudarenko
parent 00b6026761
commit 18ac0ae47c
13 changed files with 193 additions and 82 deletions

View File

@@ -741,7 +741,7 @@ static void buildReachingDefs(const map<FuncInfo*, vector<BBlock*>>& CFG, const
vector<set<FuncInfo*>> callLvlsForRD = groupByCallDependencies(callDeps, scc); vector<set<FuncInfo*>> callLvlsForRD = groupByCallDependencies(callDeps, scc);
//TODO: take into account ssc structure //TODO: take into account ssc structure
__spf_print(DEB_PRINT, "count of functions %d, count of lvls %d\n", (int)CFG.size(), (int)callLvlsForRD.size()); __spf_print(DEB_PRINT, " count of functions %d, count of lvls %d\n", (int)CFG.size(), (int)callLvlsForRD.size());
for (auto& byLvl : callLvlsForRD) for (auto& byLvl : callLvlsForRD)
{ {
for (auto& byFunc : byLvl) for (auto& byFunc : byLvl)

View File

@@ -46,7 +46,7 @@ void printLoopInfo(const LoopGraph* loop)
if(!loop_stmt) if(!loop_stmt)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
__spf_print(PRINT_PRIVATES, "loop at file '%s' at line %d\n", loop->fileName.c_str(), loop->lineNum); __spf_print(PRINT_PRIVATES, " loop in file '%s' at line %d\n", loop->fileName.c_str(), loop->lineNum);
__spf_print(PRINT_PRIVATES, " privates:"); __spf_print(PRINT_PRIVATES, " privates:");
for(const auto& ident : priv) for(const auto& ident : priv)
__spf_print(PRINT_PRIVATES, " %s", ident.c_str()); __spf_print(PRINT_PRIVATES, " %s", ident.c_str());
@@ -67,7 +67,7 @@ void printLoopInfo(const LoopGraph* loop)
if (extra_old.size() != 0) if (extra_old.size() != 0)
{ {
__spf_print(PRINT_WARNINGS, "[WARNING] extra private variables:"); __spf_print(PRINT_WARNINGS, " [WARNING] extra private variables:");
for (const auto& ident : extra_old) for (const auto& ident : extra_old)
__spf_print(PRINT_WARNINGS, " %s", ident.c_str()); __spf_print(PRINT_WARNINGS, " %s", ident.c_str());
__spf_print(PRINT_WARNINGS, "\n"); __spf_print(PRINT_WARNINGS, "\n");

View File

@@ -626,7 +626,7 @@ void DvmhRegionInserter::insertActualDirectives(const vector<ParallelRegion*>* r
if (SgFile::switchToFile(file->filename()) == -1) if (SgFile::switchToFile(file->filename()) == -1)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
__spf_print(1, "Insert actuals for file %s\n", file->filename()); __spf_print(1, " Insert actuals for file %s\n", file->filename());
for (auto& func : funcsForFile) for (auto& func : funcsForFile)
{ {
@@ -663,7 +663,7 @@ void DvmhRegionInserter::insertActualDirectives(const vector<ParallelRegion*>* r
if (regs) if (regs)
{ {
__spf_print(1, "Insert actuals for arrays copying before and after parallelization areas\n"); __spf_print(1, " Insert actuals for arrays copying before and after parallelization areas\n");
for (auto& area : *regs) for (auto& area : *regs)
{ {
auto lines = area->GetLines(file->filename()); auto lines = area->GetLines(file->filename());
@@ -719,10 +719,10 @@ vector<SgExpression*> DvmhRegionInserter::getArrayList(Statement* start, Stateme
void DvmhRegionInserter::insertDirectives(const vector<ParallelRegion*> *regs) void DvmhRegionInserter::insertDirectives(const vector<ParallelRegion*> *regs)
{ {
__spf_print(1, "Find edges for regions\n"); __spf_print(1, " Find edges for regions\n");
findEdgesForRegions(loopGraph); findEdgesForRegions(loopGraph);
__spf_print(1, "Merging regions\n"); __spf_print(1, " Merging regions\n");
auto merger = RegionsMerger(regions, rw_analyzer); auto merger = RegionsMerger(regions, rw_analyzer);
regions = merger.mergeRegions(); regions = merger.mergeRegions();
@@ -735,7 +735,7 @@ void DvmhRegionInserter::insertDirectives(const vector<ParallelRegion*> *regs)
} }
} }
__spf_print(1, "Insert regions\n"); __spf_print(1, " Insert regions\n");
insertRegionDirectives(); insertRegionDirectives();
} }
@@ -1201,6 +1201,33 @@ static SgExpression* getPrivateArraysInPar(const FuncInfo* funcInfo, const std::
return NULL; return NULL;
} }
static SgStatement* getInsertionPlace(SgStatement* func)
{
SgStatement* place = func->lexNext();
SgStatement* insertAfter = NULL;
for (auto st = place; st != func->lastNodeOfStmt(); st = st->lexNext())
{
if (isSPF_stat(st) || isDVM_stat(st))
continue;
if (st->variant() == CONTAINS_STMT)
break;
if (isSgExecutableStatement(st))
break;
if (st->variant() == IMPL_DECL)
insertAfter = st;
else if (st->variant() == USE_STMT)
insertAfter = st;
}
if (insertAfter)
return insertAfter->lexNext();
else
return place;
}
static void insertRoutine(SgStatement* func, const FuncInfo* funcInfo, const std::set<LoopGraph*>& inLoops, static void insertRoutine(SgStatement* func, const FuncInfo* funcInfo, const std::set<LoopGraph*>& inLoops,
const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls) const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls)
{ {
@@ -1224,9 +1251,9 @@ static void insertRoutine(SgStatement* func, const FuncInfo* funcInfo, const std
if (!routine) if (!routine)
{ {
st = func->lexNext(); st = getInsertionPlace(func);
routine = new SgStatement(ACC_ROUTINE_DIR); routine = new SgStatement(ACC_ROUTINE_DIR);
st->insertStmtBefore(*routine, *st->controlParent()); st->insertStmtBefore(*routine, *func);
} }
SgExpression* list = getPrivateArraysInPar(funcInfo, inLoops, arrayLinksByFuncCalls, routine->expr(0)); SgExpression* list = getPrivateArraysInPar(funcInfo, inLoops, arrayLinksByFuncCalls, routine->expr(0));
@@ -1487,10 +1514,14 @@ void DvmhRegionInserter::addUsedWriteArrays(set<DIST::Array*>& arrays)
} }
} }
static void insertDeclare(const set<DIST::Array*>& usedArraysInRegions, static set<DIST::Array*>
insertDeclare(const set<DIST::Array*>& usedArraysInRegions,
const set<DIST::Array*>& usedWriteArraysInRegions, const set<DIST::Array*>& usedWriteArraysInRegions,
const map<DIST::Array*, set<DIST::Array*>> arrayLinksByFuncCalls) const map<DIST::Array*, set<DIST::Array*>> arrayLinksByFuncCalls,
SgStatement* main)
{ {
set<DIST::Array*> commonArrays;
vector<DIST::Array*> usedAll; vector<DIST::Array*> usedAll;
std::set_union(usedArraysInRegions.begin(), usedArraysInRegions.end(), std::set_union(usedArraysInRegions.begin(), usedArraysInRegions.end(),
usedWriteArraysInRegions.begin(), usedWriteArraysInRegions.end(), usedWriteArraysInRegions.begin(), usedWriteArraysInRegions.end(),
@@ -1506,16 +1537,40 @@ static void insertDeclare(const set<DIST::Array*>& usedArraysInRegions,
for (auto& realArray : realRef) for (auto& realArray : realRef)
{ {
if (std::count(usedAll.begin(), usedAll.end(), realArray) == 0 && added.count(realArray) == 0) if (added.count(realArray) != 0 || !realArray->IsNotDistribute())
{ continue;
added.insert(realArray);
//TODO: for common SgStatement* declStat = NULL;
if (realArray->GetLocation().first != DIST::l_COMMON) if (realArray->GetLocation().first != DIST::l_COMMON)
{
if (std::count(usedAll.begin(), usedAll.end(), realArray) == 0)
{ {
auto declInfo = *realArray->GetDeclInfo().begin(); auto declInfo = *realArray->GetDeclInfo().begin();
SgStatement* declStat = SgStatement::getStatementByFileAndLine(declInfo.first, declInfo.second); declStat = SgStatement::getStatementByFileAndLine(declInfo.first, declInfo.second);
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
}
}
else
{
commonArrays.insert(realArray);
auto decls = realArray->GetDeclInfo();
for (auto& decl : decls)
{
declStat = SgStatement::getStatementByFileAndLine(decl.first, decl.second);
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__); checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
if (declStat != main)
{
declStat = NULL;
continue;
}
}
}
if (declStat)
{
added.insert(realArray);
declStat = getFuncStat(declStat); declStat = getFuncStat(declStat);
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__); checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
@@ -1523,7 +1578,6 @@ static void insertDeclare(const set<DIST::Array*>& usedArraysInRegions,
} }
} }
} }
}
for (auto& declPair : toDeclareByFunc) for (auto& declPair : toDeclareByFunc)
{ {
@@ -1544,16 +1598,22 @@ static void insertDeclare(const set<DIST::Array*>& usedArraysInRegions,
} }
} }
func->insertStmtAfter(*new SgStatement(ACC_DECLARE_DIR, NULL, NULL, makeExprList(list)), *func); auto place = getInsertionPlace(func);
place->insertStmtBefore(*new SgStatement(ACC_DECLARE_DIR, NULL, NULL, makeExprList(list)), *func);
} }
return commonArrays;
} }
void insertDvmhRegions(SgProject& project, int files, const vector<ParallelRegion*>& parallelRegions, int insertDvmhRegions(SgProject& project, int files, const vector<ParallelRegion*>& parallelRegions,
map<string, vector<FuncInfo*>>& allFuncInfo, map<string, vector<FuncInfo*>>& allFuncInfo,
map<string, vector<LoopGraph*>> loopGraph, map<string, vector<LoopGraph*>> loopGraph,
ReadWriteAnalyzer& rw_analyzer, ReadWriteAnalyzer& rw_analyzer,
map<string, vector<Messages>>& SPF_messages,
const map<DIST::Array*, set<DIST::Array*>> arrayLinksByFuncCalls) const map<DIST::Array*, set<DIST::Array*>> arrayLinksByFuncCalls)
{ {
int internalExit = 0;
vector<DvmhRegionInserter*> inserters; vector<DvmhRegionInserter*> inserters;
const bool regionCondition = ((parallelRegions.size() == 0 && parallelRegions[0]->GetName() == "DEFAULT") || sharedMemoryParallelization == 1); const bool regionCondition = ((parallelRegions.size() == 0 && parallelRegions[0]->GetName() == "DEFAULT") || sharedMemoryParallelization == 1);
@@ -1563,7 +1623,7 @@ void insertDvmhRegions(SgProject& project, int files, const vector<ParallelRegio
for (int i = files - 1; i >= 0; --i) for (int i = files - 1; i >= 0; --i)
{ {
SgFile* file = &(project.file(i)); SgFile* file = &(project.file(i));
__spf_print(1, "Start region inserter for file %s\n", file->filename()); __spf_print(1, " ==> Start region inserter for file %s\n", file->filename());
map<string, FuncInfo*> mapOfFuncs; map<string, FuncInfo*> mapOfFuncs;
createMapOfFunc(allFuncInfo, mapOfFuncs); createMapOfFunc(allFuncInfo, mapOfFuncs);
@@ -1613,7 +1673,11 @@ void insertDvmhRegions(SgProject& project, int files, const vector<ParallelRegio
inserters[k]->createInterfaceBlockForParallelFunctions(false); inserters[k]->createInterfaceBlockForParallelFunctions(false);
} }
insertDeclare(usedArraysInRegions, usedWriteArraysInRegions, arrayLinksByFuncCalls); SgStatement* main = findMainUnit(&project, SPF_messages);
checkNull(main, convertFileName(__FILE__).c_str(), __LINE__);
set<DIST::Array*> commonArrays = insertDeclare(usedArraysInRegions, usedWriteArraysInRegions, arrayLinksByFuncCalls, main);
internalExit = checkCommonInMainUnit(project, SPF_messages, commonArrays, false);
for (auto& regionInserter : inserters) for (auto& regionInserter : inserters)
{ {
@@ -1625,4 +1689,6 @@ void insertDvmhRegions(SgProject& project, int files, const vector<ParallelRegio
regionInserter->insertActualDirectives(&parallelRegions); regionInserter->insertActualDirectives(&parallelRegions);
delete regionInserter; delete regionInserter;
} }
return internalExit;
} }

View File

@@ -112,8 +112,9 @@ public:
} }
}; };
void insertDvmhRegions(SgProject& project, int files, const std::vector<ParallelRegion*>& parallelRegions, int insertDvmhRegions(SgProject& project, int files, const std::vector<ParallelRegion*>& parallelRegions,
std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo,
std::map<std::string, std::vector<LoopGraph*>> loopGraph, std::map<std::string, std::vector<LoopGraph*>> loopGraph,
ReadWriteAnalyzer& rw_analyzer, ReadWriteAnalyzer& rw_analyzer,
std::map<std::string, std::vector<Messages>>& SPF_messages,
const std::map<DIST::Array*, std::set<DIST::Array*>> arrayLinksByFuncCalls); const std::map<DIST::Array*, std::set<DIST::Array*>> arrayLinksByFuncCalls);

View File

@@ -1444,40 +1444,11 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
ALGORITHMS_DONE[CREATE_ALIGNS][z] = 1; ALGORITHMS_DONE[CREATE_ALIGNS][z] = 1;
} }
SgStatement* mainUnit = findMainUnit(&project, SPF_messages); set<DIST::Array*> toCheck;
checkNull(mainUnit, convertFileName(__FILE__).c_str(), __LINE__);
map<string, vector<SgExpression*>> commonBlocks;
getCommonBlocksRef(commonBlocks, mainUnit, mainUnit->lastNodeOfStmt());
// check array declaration
for (auto& arrayP : dataDirectives.GenAlignsRules(NULL)) for (auto& arrayP : dataDirectives.GenAlignsRules(NULL))
{ toCheck.insert(arrayP.alignArray);
auto array = arrayP.alignArray;
if (array->IsLoopArray() || array->IsTemplate())
continue;
if (array->GetLocation().first == DIST::l_COMMON)
{
auto nameOfCommon = array->GetLocation().second;
if (commonBlocks.find(nameOfCommon) == commonBlocks.end())
{
auto declPlaces = array->GetDeclInfo();
for (auto& place : declPlaces)
{
vector<Messages>& currMessages = getObjectForFileFromMap(place.first.c_str(), SPF_messages);
__spf_print(1, " ERROR: distributed array '%s' in common block '%s' must have declaration in main unit\n", array->GetShortName().c_str(), nameOfCommon.c_str());
wstring messageE, messageR; internalExit = checkCommonInMainUnit(project, SPF_messages, toCheck, true);
__spf_printToLongBuf(messageE, L"distributed array '%s' in common block '%s' must have declaration in main unit",
to_wstring(array->GetShortName()).c_str(), to_wstring(nameOfCommon).c_str());
__spf_printToLongBuf(messageR, R75,
to_wstring(array->GetShortName()).c_str(), to_wstring(nameOfCommon).c_str());
currMessages.push_back(Messages(ERROR, place.second, messageR, messageE, 1042));
}
internalExit = 1;
}
}
}
__spf_print(1, "*** FOR PARALLEL REGION '%s':\n", parallelRegions[z]->GetName().c_str()); __spf_print(1, "*** FOR PARALLEL REGION '%s':\n", parallelRegions[z]->GetName().c_str());
result = dataDirectives.GenAlignsRules(); result = dataDirectives.GenAlignsRules();
@@ -1498,7 +1469,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
int allLineSum = 0; int allLineSum = 0;
for (auto &elem : lineInfo) for (auto &elem : lineInfo)
allLineSum += elem.second; allLineSum += elem.second;
__spf_print(1, "All lines in project %d\n", allLineSum); __spf_print(1, " All lines in project %d\n", allLineSum);
} }
else if (curr_regime == FILL_PAR_REGIONS_LINES) else if (curr_regime == FILL_PAR_REGIONS_LINES)
{ {
@@ -1875,7 +1846,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
else if (curr_regime == INLINE_PROCEDURES) else if (curr_regime == INLINE_PROCEDURES)
callInliner(allFuncInfo, inDataProc, inDataChains, inDataChainsStart, SPF_messages, commonBlocks); callInliner(allFuncInfo, inDataProc, inDataChains, inDataChainsStart, SPF_messages, commonBlocks);
else if (curr_regime == INSERT_REGIONS) else if (curr_regime == INSERT_REGIONS)
insertDvmhRegions(project, n, parallelRegions, allFuncInfo, loopGraph, rw_analyzer, arrayLinksByFuncCalls); internalExit = insertDvmhRegions(project, n, parallelRegions, allFuncInfo, loopGraph, rw_analyzer, SPF_messages, arrayLinksByFuncCalls);
else if (curr_regime == RENAME_SYMBOLS) else if (curr_regime == RENAME_SYMBOLS)
runRenameSymbols(&project, commonBlocks); runRenameSymbols(&project, commonBlocks);
else if (curr_regime == FIND_PARAMETERS) else if (curr_regime == FIND_PARAMETERS)
@@ -2623,6 +2594,9 @@ int main(int argc, char **argv)
} }
} }
if (curr_regime == INSERT_PARALLEL_DIRS_NODIST)
ignoreArrayDistributeState = true;
if (runAsClient) if (runAsClient)
{ {
printf("[SAPFOR]: Started as client with server port %d\n", serverPort); printf("[SAPFOR]: Started as client with server port %d\n", serverPort);

View File

@@ -208,7 +208,7 @@ enum options {
KEEP_GCOV, KEEP_GCOV,
ANALYSIS_OPTIONS, ANALYSIS_OPTIONS,
DEBUG_PRINT_ON, DEBUG_PRINT_ON,
MPI_PROGRAM, SHARED_MEMORY,
IGNORE_IO_SAPFOR, IGNORE_IO_SAPFOR,
KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS, KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS,
PARSE_FOR_INLINE, PARSE_FOR_INLINE,

View File

@@ -604,7 +604,7 @@ bool createNestedLoops(LoopGraph *current, const map<LoopGraph*, void*> &depInfo
if (outerTightened) if (outerTightened)
firstChild->perfectLoop = countPerfectLoopNest(firstChild->loop); firstChild->perfectLoop = countPerfectLoopNest(firstChild->loop);
__spf_print(1, "createNestedLoops for loop at %d. Tighten success: %d\n", current->lineNum, outerTightened); __spf_print(1, " createNestedLoops for loop at %d. Tighten success: %d\n", current->lineNum, outerTightened);
wchar_t buf[256]; wchar_t buf[256];
std::wstring messageE, messageR; std::wstring messageE, messageR;
@@ -619,14 +619,14 @@ bool createNestedLoops(LoopGraph *current, const map<LoopGraph*, void*> &depInfo
wasTightened = outerTightened; wasTightened = outerTightened;
for (int i = 0; i < current->children.size(); ++i) for (int i = 0; i < current->children.size(); ++i)
{ {
__spf_print(1, "createNestedLoops for loop at %d. Transform child %d\n", current->lineNum, i); __spf_print(1, " createNestedLoops for loop at %d. Transform child %d\n", current->lineNum, i);
bool result = createNestedLoops(current->children[i], depInfoForLoopGraphV, mapFuncInfo, messages); bool result = createNestedLoops(current->children[i], depInfoForLoopGraphV, mapFuncInfo, messages);
wasTightened = wasTightened || result; wasTightened = wasTightened || result;
} }
//update perfect loop //update perfect loop
current->recalculatePerfect(); current->recalculatePerfect();
__spf_print(1, "createNestedLoops for loop at %d. End\n", current->lineNum); __spf_print(1, " createNestedLoops for loop at %d. End\n", current->lineNum);
return wasTightened; return wasTightened;
} }

View File

@@ -1219,6 +1219,62 @@ void getCommonBlocksRef(map<string, vector<SgExpression*>> &commonBlocks, SgStat
} }
} }
int checkCommonInMainUnit(SgProject& project, map<string, vector<Messages>>& SPF_messages,
const set<DIST::Array*>& arrays, bool forDistrbuted)
{
int internalExit = 0;
SgStatement* mainUnit = findMainUnit(&project, SPF_messages);
checkNull(mainUnit, convertFileName(__FILE__).c_str(), __LINE__);
map<string, vector<SgExpression*>> commonBlocks;
getCommonBlocksRef(commonBlocks, mainUnit, mainUnit->lastNodeOfStmt());
// check array declaration
for (auto& array : arrays)
{
if (array->IsLoopArray() || array->IsTemplate())
continue;
if (array->GetLocation().first == DIST::l_COMMON)
{
auto nameOfCommon = array->GetLocation().second;
if (commonBlocks.find(nameOfCommon) == commonBlocks.end())
{
auto declPlaces = array->GetDeclInfo();
for (auto& place : declPlaces)
{
vector<Messages>& currMessages = getObjectForFileFromMap(place.first.c_str(), SPF_messages);
if (forDistrbuted)
{
__spf_print(1, " ERROR: distributed array '%s' in common block '%s' must have declaration in main unit\n", array->GetShortName().c_str(), nameOfCommon.c_str());
wstring messageE, messageR;
__spf_printToLongBuf(messageE, L"distributed array '%s' in common block '%s' must have declaration in main unit",
to_wstring(array->GetShortName()).c_str(), to_wstring(nameOfCommon).c_str());
__spf_printToLongBuf(messageR, R75,
to_wstring(array->GetShortName()).c_str(), to_wstring(nameOfCommon).c_str());
currMessages.push_back(Messages(ERROR, place.second, messageR, messageE, 1042));
}
else
{
__spf_print(1, " ERROR: array '%s' in common block '%s' must have declaration in main unit for DECLARE insertion\n", array->GetShortName().c_str(), nameOfCommon.c_str());
wstring messageE, messageR;
__spf_printToLongBuf(messageE, L"array '%s' in common block '%s' must have declaration in main unit for DECLARE insertion",
to_wstring(array->GetShortName()).c_str(), to_wstring(nameOfCommon).c_str());
__spf_printToLongBuf(messageR, R205,
to_wstring(array->GetShortName()).c_str(), to_wstring(nameOfCommon).c_str());
currMessages.push_back(Messages(ERROR, place.second, messageR, messageE, 1062));
}
}
internalExit = 1;
}
}
}
return internalExit;
}
static SgExpression* isInCommon(const vector<SgExpression*> &commonBlocks, const char *arrayName, int &commonPos) static SgExpression* isInCommon(const vector<SgExpression*> &commonBlocks, const char *arrayName, int &commonPos)
{ {
commonPos = 0; commonPos = 0;

View File

@@ -31,6 +31,7 @@ bool isDVM_stat(SgStatement *st);
bool isSPF_stat(SgStatement *st); bool isSPF_stat(SgStatement *st);
bool isEqExpressions(SgExpression *left, SgExpression *right, std::map<SgExpression*, std::string> &collection); bool isEqExpressions(SgExpression *left, SgExpression *right, std::map<SgExpression*, std::string> &collection);
void getCommonBlocksRef(std::map<std::string, std::vector<SgExpression*>> &commonBlocks, SgStatement *start, SgStatement *end, const std::string *nameToSkip = NULL); void getCommonBlocksRef(std::map<std::string, std::vector<SgExpression*>> &commonBlocks, SgStatement *start, SgStatement *end, const std::string *nameToSkip = NULL);
int checkCommonInMainUnit(SgProject& project, std::map<std::string, std::vector<Messages>>& SPF_messages, const std::set<DIST::Array*>& arrays, bool forDistrbuted);
std::tuple<int, std::string, std::string> getFromUniqTable(SgSymbol *symb); std::tuple<int, std::string, std::string> getFromUniqTable(SgSymbol *symb);
std::tuple<int, std::string, std::string> getUniqName(const std::map<std::string, std::vector<SgExpression*>> &commonBlocks, SgStatement *decl, SgSymbol *symb); std::tuple<int, std::string, std::string> getUniqName(const std::map<std::string, std::vector<SgExpression*>> &commonBlocks, SgStatement *decl, SgSymbol *symb);

View File

@@ -75,6 +75,7 @@ enum typeMessage { WARR, ERROR, NOTE };
// 59 "Reduction by element of array '%s' is not implemented yet" // 59 "Reduction by element of array '%s' is not implemented yet"
// 60 "Format misplaced" // 60 "Format misplaced"
// 61 "Array has declaration area conflict" // 61 "Array has declaration area conflict"
// 62 "need to move common declaration to main for DECLATE"
// //
// 20xx TRANSFORM GROUP // 20xx TRANSFORM GROUP
// 01 "can not convert array assign to loop" // 01 "can not convert array assign to loop"
@@ -276,7 +277,7 @@ static void printStackTrace() { };
} \ } \
} while (0) } while (0)
// Свободный - R205 // Свободный - R206
// Гайд по русификации сообщений: При добавлении нового сообщения, меняется последний сводобный идентификатор. // Гайд по русификации сообщений: При добавлении нового сообщения, меняется последний сводобный идентификатор.
// В этом файле остаются только спецификаторы, для которых будет заполнен текст. Полный текст пишется в файле // В этом файле остаются только спецификаторы, для которых будет заполнен текст. Полный текст пишется в файле
// russian_errors_text.txt. Спецификаторы там тоже сохраняются, по ним в визуализаторе будет восстановлен // russian_errors_text.txt. Спецификаторы там тоже сохраняются, по ним в визуализаторе будет восстановлен
@@ -473,6 +474,8 @@ static const wchar_t *R182 = L"R176:%s";
static const wchar_t *R183 = L"R183:"; static const wchar_t *R183 = L"R183:";
//1061 //1061
static const wchar_t *R184 = L"R184:%s"; static const wchar_t *R184 = L"R184:%s";
//1062
static const wchar_t* R205 = L"R205:%s#%s";
//2001 //2001
static const wchar_t *R94 = L"R94:"; static const wchar_t *R94 = L"R94:";

View File

@@ -184,6 +184,8 @@ R182 = "Редукционная операция по элементу масс
R183 = "Расположение операторов FORMAT не поддерживается, попробуйте применить проход Коррекция стиля кода". R183 = "Расположение операторов FORMAT не поддерживается, попробуйте применить проход Коррекция стиля кода".
//1061 //1061
R184 = "Область объявления массива '%s' конфликтует с предыдущей областью. Возможно, это вызвано использованием include-файлов. Попробуйте применить проход 'Подстановка заголовочных файлов'". R184 = "Область объявления массива '%s' конфликтует с предыдущей областью. Возможно, это вызвано использованием include-файлов. Попробуйте применить проход 'Подстановка заголовочных файлов'".
//1042
R205 = "Массив '%s' состоящий в common блоке '%s' должен иметь описание в главной программной единице для объявления в директиве DECLARE"
//2001 //2001
R94 = "Невозможно автоматически преобразовать данное присваивание к циклу" R94 = "Невозможно автоматически преобразовать данное присваивание к циклу"

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2380" #define VERSION_SPF "2381"

View File

@@ -96,6 +96,7 @@ static char* ConvertShortToChar(const short* source, int& strL)
return dist; return dist;
} }
extern bool ignoreArrayDistributeState;
static void setOptions(const short* options, bool isBuildParallel = false, const set<int>* turnOffOptions = NULL) static void setOptions(const short* options, bool isBuildParallel = false, const set<int>* turnOffOptions = NULL)
{ {
if (!optionNames[STATIC_SHADOW_ANALYSIS]) if (!optionNames[STATIC_SHADOW_ANALYSIS])
@@ -113,7 +114,7 @@ static void setOptions(const short* options, bool isBuildParallel = false, const
optionNames[KEEP_GCOV] = "KEEP_GCOV"; optionNames[KEEP_GCOV] = "KEEP_GCOV";
optionNames[ANALYSIS_OPTIONS] = "ANALYSIS_OPTIONS"; optionNames[ANALYSIS_OPTIONS] = "ANALYSIS_OPTIONS";
optionNames[DEBUG_PRINT_ON] = "DEBUG_PRINT_ON"; optionNames[DEBUG_PRINT_ON] = "DEBUG_PRINT_ON";
optionNames[MPI_PROGRAM] = "MPI_PROGRAM"; optionNames[SHARED_MEMORY] = "SHARED_MEMORY";
optionNames[IGNORE_IO_SAPFOR] = "IGNORE_IO_SAPFOR"; optionNames[IGNORE_IO_SAPFOR] = "IGNORE_IO_SAPFOR";
optionNames[KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS] = "KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS"; optionNames[KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS] = "KEEP_SPF_DIRECTIVES_AMONG_TRANSFORMATIONS";
optionNames[PARSE_FOR_INLINE] = "PARSE_FOR_INLINE"; optionNames[PARSE_FOR_INLINE] = "PARSE_FOR_INLINE";
@@ -137,12 +138,12 @@ static void setOptions(const short* options, bool isBuildParallel = false, const
if (splited.size() == z) if (splited.size() == z)
break; break;
__spf_print(1, "read value '%s' to '%s' option\n", splited[z].c_str(), optionNames[z]); __spf_print(1, " read value '%s' to '%s' option\n", splited[z].c_str(), optionNames[z]);
if (z != ANALYSIS_OPTIONS) if (z != ANALYSIS_OPTIONS)
{ {
if (sscanf(splited[z].c_str(), "%d", &intOptions[z]) != 1) if (sscanf(splited[z].c_str(), "%d", &intOptions[z]) != 1)
{ {
__spf_print(1, "!wrong value!\n"); __spf_print(1, " !wrong value!\n");
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
} }
} }
@@ -166,7 +167,7 @@ static void setOptions(const short* options, bool isBuildParallel = false, const
removeNestedIntervals = (intOptions[KEEP_LOOPS_CLOSE_NESTING] == 1); removeNestedIntervals = (intOptions[KEEP_LOOPS_CLOSE_NESTING] == 1);
showDebug = (intOptions[DEBUG_PRINT_ON] == 1); showDebug = (intOptions[DEBUG_PRINT_ON] == 1);
sharedMemoryParallelization = (sharedMemoryParallelization != 1) ? intOptions[MPI_PROGRAM] : sharedMemoryParallelization; sharedMemoryParallelization = (sharedMemoryParallelization != 1) ? intOptions[SHARED_MEMORY] : sharedMemoryParallelization;
parallizeFreeLoops = (sharedMemoryParallelization == 1) ? 0 : intOptions[PARALLIZE_FREE_LOOPS]; parallizeFreeLoops = (sharedMemoryParallelization == 1) ? 0 : intOptions[PARALLIZE_FREE_LOOPS];
ignoreIO = (sharedMemoryParallelization == 1) ? 1 : intOptions[IGNORE_IO_SAPFOR]; ignoreIO = (sharedMemoryParallelization == 1) ? 1 : intOptions[IGNORE_IO_SAPFOR];
keepDvmDirectives = (sharedMemoryParallelization == 1) ? 0 : intOptions[KEEP_DVM_DIRECTIVES]; keepDvmDirectives = (sharedMemoryParallelization == 1) ? 0 : intOptions[KEEP_DVM_DIRECTIVES];
@@ -175,6 +176,11 @@ static void setOptions(const short* options, bool isBuildParallel = false, const
string optAnalisys = splited.size() > ANALYSIS_OPTIONS ? splited[ANALYSIS_OPTIONS] : ""; string optAnalisys = splited.size() > ANALYSIS_OPTIONS ? splited[ANALYSIS_OPTIONS] : "";
if (sharedMemoryParallelization == 1)
ignoreArrayDistributeState = true;
else
ignoreArrayDistributeState = false;
if (!turnOffOptions) if (!turnOffOptions)
return; return;
@@ -820,7 +826,10 @@ int SPF_GetArrayDistribution(void*& context, int winHandler, short *options, sho
else if (regime == 1) else if (regime == 1)
{ {
if (sharedMemoryParallelization) if (sharedMemoryParallelization)
{
ignoreArrayDistributeState = true;
runPassesForVisualizer(projName, { LOOP_ANALYZER_NODIST }); runPassesForVisualizer(projName, { LOOP_ANALYZER_NODIST });
}
else else
runPassesForVisualizer(projName, { LOOP_ANALYZER_DATA_DIST_S1 }); runPassesForVisualizer(projName, { LOOP_ANALYZER_DATA_DIST_S1 });
} }
@@ -1875,7 +1884,6 @@ int SPF_ExpressionSubstitution(void*& context, int winHandler, short* options, s
return simpleTransformPass(SUBST_EXPR_RD_AND_UNPARSE, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize); return simpleTransformPass(SUBST_EXPR_RD_AND_UNPARSE, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize);
} }
extern bool ignoreArrayDistributeState;
int SPF_InsertDvmhRegions(void*& context, int winHandler, short* options, short* projName, short* folderName, short*& output, int SPF_InsertDvmhRegions(void*& context, int winHandler, short* options, short* projName, short* folderName, short*& output,
int*& outputSize, short*& outputMessage, int*& outputMessageSize) int*& outputSize, short*& outputMessage, int*& outputMessageSize)
{ {