From 1be169e7ff245b9ade30395ca0a7be0a8d751a5e Mon Sep 17 00:00:00 2001 From: Mikhail Kocharmin Date: Wed, 19 Jun 2024 18:08:27 +0300 Subject: [PATCH] Rename mpiProgram flag to sharedMemoryParallelization --- .../DirectiveProcessing/directive_creator.cpp | 4 +-- .../directive_creator_base.cpp | 6 ++-- .../DirectiveProcessing/insert_directive.cpp | 6 ++-- .../Sapfor_2017/_src/Distribution/Array.h | 4 +-- .../Distribution/CreateDistributionDirs.cpp | 4 +-- .../_src/Distribution/DvmhDirective.cpp | 22 ++++++------ .../_src/Distribution/DvmhDirective.h | 2 +- .../_src/Distribution/DvmhDirectiveBase.cpp | 6 ++-- .../_src/DvmhRegions/DvmhRegionInserter.cpp | 6 ++-- .../_src/GraphCall/graph_calls_base.cpp | 4 +-- .../_src/GraphCall/graph_calls_func.h | 2 +- .../_src/GraphLoop/graph_loops.cpp | 4 +-- .../Sapfor_2017/_src/GraphLoop/graph_loops.h | 2 +- .../_src/GraphLoop/graph_loops_base.cpp | 8 ++--- .../_src/GraphLoop/graph_loops_func.h | 2 +- .../_src/LoopAnalyzer/loop_analyzer.cpp | 12 +++---- .../LoopAnalyzer/loop_analyzer_internal.h | 2 +- .../resolve_par_reg_conflicts.cpp | 10 +++--- .../resolve_par_reg_conflicts.h | 4 +-- sapfor/experts/Sapfor_2017/_src/Sapfor.cpp | 36 +++++++++---------- sapfor/experts/Sapfor_2017/_src/Sapfor.h | 2 +- sapfor/experts/Sapfor_2017/_src/SapforData.h | 2 +- .../Sapfor_2017/_src/Utils/SgUtils.cpp | 2 +- .../experts/Sapfor_2017/_src/Utils/utils.cpp | 2 +- .../_src/VisualizerCalls/get_information.cpp | 14 ++++---- 25 files changed, 84 insertions(+), 84 deletions(-) diff --git a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_creator.cpp b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_creator.cpp index a4fd864..e9e804d 100644 --- a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_creator.cpp +++ b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_creator.cpp @@ -45,7 +45,7 @@ using std::get; using std::string; using std::wstring; -extern int mpiProgram; +extern int sharedMemoryParallelization; static vector>> groupRealignsDirs(const vector>>& toRealign) @@ -453,7 +453,7 @@ void createParallelDirs(File *file, auto& tmp = dataDirectives.distrRules; vector> currentVar; - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { for (int z1 = 0; z1 < currentVariant.size(); ++z1) currentVar.push_back(make_pair(tmp[z1].first, &tmp[z1].second[currentVariant[z1]])); diff --git a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_creator_base.cpp b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_creator_base.cpp index 6277dd2..8730a95 100644 --- a/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_creator_base.cpp +++ b/sapfor/experts/Sapfor_2017/_src/DirectiveProcessing/directive_creator_base.cpp @@ -525,7 +525,7 @@ void createParallelDirectives(const mapcalculatedCountOfIters; uint64_t regId = currReg->GetId(); - if (mpiProgram) + if (sharedMemoryParallelization) regId = (uint64_t)currLoop; const DIST::Arrays &allArrays = currReg->GetAllArrays(); @@ -749,7 +749,7 @@ void createParallelDirectives(const mapIsLoopArray())) + if (mainArray.underAcross == false && !(sharedMemoryParallelization == 1 && mainArray.arrayRef->IsLoopArray())) { set realArrayRef; getRealArrayRefs(mainArray.arrayRef, mainArray.arrayRef, realArrayRef, arrayLinksByFuncCalls); @@ -1762,7 +1762,7 @@ static bool addRedistributionDirs(File* file, const vector &exprs) @@ -2384,7 +2384,7 @@ void insertParallelDirs(SgFile *file, bool extract, const char* file_name = file->filename(); insertDirectiveToFile(file, file_name, createdDirectives, extract, messages); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { map mapFuncInfo; createMapOfFunc(callGraph, mapFuncInfo); @@ -2420,7 +2420,7 @@ void insertParallelDirs(SgFile *file, bool extract, for (auto& array : declaredArrays) array.second.first->ClearShadowSpecs(); } - else if (mpiProgram == 0) + else if (sharedMemoryParallelization == 0) { set regNum; for (int z = 0; z < parallelRegions.size(); ++z) diff --git a/sapfor/experts/Sapfor_2017/_src/Distribution/Array.h b/sapfor/experts/Sapfor_2017/_src/Distribution/Array.h index 7dd823e..8380a6b 100644 --- a/sapfor/experts/Sapfor_2017/_src/Distribution/Array.h +++ b/sapfor/experts/Sapfor_2017/_src/Distribution/Array.h @@ -22,7 +22,7 @@ struct FuncInfo; #define TO_STR std::to_string #if __SPF -extern int mpiProgram; +extern int sharedMemoryParallelization; #endif namespace Distribution @@ -117,7 +117,7 @@ namespace Distribution if (it == templateInfo.end()) { #if __SPF - if (withCheck && mpiProgram != 0) + if (withCheck && sharedMemoryParallelization != 0) printInternalError(convertFileName(__FILE__).c_str(), __LINE__); #endif currLink = new TemplateLink(dimSize); diff --git a/sapfor/experts/Sapfor_2017/_src/Distribution/CreateDistributionDirs.cpp b/sapfor/experts/Sapfor_2017/_src/Distribution/CreateDistributionDirs.cpp index ada8f0e..ef34757 100644 --- a/sapfor/experts/Sapfor_2017/_src/Distribution/CreateDistributionDirs.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Distribution/CreateDistributionDirs.cpp @@ -530,7 +530,7 @@ int createAlignDirs(DIST::GraphCSR &reducedG, const DIST: { DIST::Array* array = arrayPair.second; - if (mpiProgram != 0) + if (sharedMemoryParallelization != 0) if (onlyThese.find(array) == onlyThese.end()) continue; @@ -604,7 +604,7 @@ int createAlignDirs(DIST::GraphCSR &reducedG, const DIST: printInternalError(convertFileName(__FILE__).c_str(), __LINE__); } - if (isAllRulesEqualWithoutArray(rules) || mpiProgram != 0) + if (isAllRulesEqualWithoutArray(rules) || sharedMemoryParallelization != 0) { bool hasError = createNewAlignRule(array, allArrays, rules[0], dataDirectives, SPF_messages, canNotAlign == NULL); if (hasError) diff --git a/sapfor/experts/Sapfor_2017/_src/Distribution/DvmhDirective.cpp b/sapfor/experts/Sapfor_2017/_src/Distribution/DvmhDirective.cpp index c50c644..cb8dbd9 100644 --- a/sapfor/experts/Sapfor_2017/_src/Distribution/DvmhDirective.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Distribution/DvmhDirective.cpp @@ -281,10 +281,10 @@ static vector for (int z = 0; z < loops.size(); ++z) { currLoop = loops[z]; - const uint64_t regId = mpiProgram ? (uint64_t)currLoop : currLoop->region->GetId(); + const uint64_t regId = sharedMemoryParallelization ? (uint64_t)currLoop : currLoop->region->GetId(); auto dirForLoop = currLoop->directiveForLoop; - auto tmplP = pairs.first->GetTemplateArray(regId, mpiProgram != 0); + auto tmplP = pairs.first->GetTemplateArray(regId, sharedMemoryParallelization != 0); auto links = pairs.first->GetLinksWithTemplate(regId); // no mapping for this loop, skip this @@ -324,10 +324,10 @@ static vector if (realRefsLocal.size() == 0) printInternalError(convertFileName(__FILE__).c_str(), __LINE__); - auto tmplP = (*realRefsLocal.begin())->GetTemplateArray(regId, mpiProgram != 0); + auto tmplP = (*realRefsLocal.begin())->GetTemplateArray(regId, sharedMemoryParallelization != 0); auto links = (*realRefsLocal.begin())->GetLinksWithTemplate(regId); - auto tmplP_et = pairs.first->GetTemplateArray(regId, mpiProgram != 0); + auto tmplP_et = pairs.first->GetTemplateArray(regId, sharedMemoryParallelization != 0); auto links_et = pairs.first->GetLinksWithTemplate(regId); if (tmplP == tmplP_et) @@ -557,7 +557,7 @@ ParallelDirective::genDirective(File* file, const vectorGetShortName() + "("; @@ -565,7 +565,7 @@ ParallelDirective::genDirective(File* file, const vectorIsTemplate()) @@ -652,7 +652,7 @@ ParallelDirective::genDirective(File* file, const vectorsetLhs(makeExprList(list)); } - if (mpiProgram || across.size() != 0) + if (sharedMemoryParallelization || across.size() != 0) { if (!arrayRef2->IsLoopArray()) { @@ -662,7 +662,7 @@ ParallelDirective::genDirective(File* file, const vector onlyFor; - if (mpiProgram == 0 && across.size()) + if (sharedMemoryParallelization == 0 && across.size()) { for (int k = 0; k < (int)across.size(); ++k) { @@ -672,7 +672,7 @@ ParallelDirective::genDirective(File* file, const vector tieList; - if (mpiProgram) + if (sharedMemoryParallelization) tieList = compliteTieList(currLoop, loopsTie, arrayLinksByFuncCalls, byUseInFunc, file, lineRange, onlyFor); else if (onlyFor.size()) // not MPI regime tieList = compliteTieList(currLoop, loopsTie, arrayLinksByFuncCalls, byUseInFunc, file, lineRange, onlyFor); @@ -807,7 +807,7 @@ ParallelDirective::genDirective(File* file, const vectorarrayRef == second->arrayRef; - if (mpiProgram) + if (sharedMemoryParallelization) condition = !hasConflictUniteOnRules(first->on, second->on) && !hasConflictUniteOnRules(first->on2, second->on2); if (condition) @@ -279,7 +279,7 @@ static inline string calculateShifts(DIST::GraphCSR &redu set refs; getRealArrayRefs(calcForArray, calcForArray, refs, arrayLinksByFuncCalls); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) {//TODO: need to correct errors /*for (auto& array : refs) { @@ -501,7 +501,7 @@ string ParallelDirective::genBounds(pair, vectorIsTemplate() == false && mpiProgram == 0) + if (arrayRef->IsTemplate() == false && sharedMemoryParallelization == 0) { vector>> ruleForRef = getAlignRuleWithTemplate(arrayRef, arrayLinksByFuncCalls, reducedG, allArrays, regionId); diff --git a/sapfor/experts/Sapfor_2017/_src/DvmhRegions/DvmhRegionInserter.cpp b/sapfor/experts/Sapfor_2017/_src/DvmhRegions/DvmhRegionInserter.cpp index a76a193..f051e22 100644 --- a/sapfor/experts/Sapfor_2017/_src/DvmhRegions/DvmhRegionInserter.cpp +++ b/sapfor/experts/Sapfor_2017/_src/DvmhRegions/DvmhRegionInserter.cpp @@ -1166,7 +1166,7 @@ void DvmhRegionInserter::removePrivatesFromParallelLoops() if (lexPrev->variant() == DVM_PARALLEL_ON_DIR) { - if (mpiProgram == 1) + if (sharedMemoryParallelization == 1) lexPrev->deleteStmt(); else { @@ -1309,7 +1309,7 @@ void insertDvmhRegions(SgProject& project, int files, const vector> arrayLinksByFuncCalls) { vector inserters; - const bool regionCondition = ((parallelRegions.size() == 0 && parallelRegions[0]->GetName() == "DEFAULT") || mpiProgram == 1); + const bool regionCondition = ((parallelRegions.size() == 0 && parallelRegions[0]->GetName() == "DEFAULT") || sharedMemoryParallelization == 1); set usedArraysInRegions; set usedWriteArraysInRegions; @@ -1328,7 +1328,7 @@ void insertDvmhRegions(SgProject& project, int files, const vectoranalyzeParallelDirs(); - DvmhRegionInserter* regionInserter = new DvmhRegionInserter(file, loopsForFile, rw_analyzer, arrayLinksByFuncCalls, mapOfFuncs, funcsForFile, mpiProgram == 1); + DvmhRegionInserter* regionInserter = new DvmhRegionInserter(file, loopsForFile, rw_analyzer, arrayLinksByFuncCalls, mapOfFuncs, funcsForFile, sharedMemoryParallelization == 1); inserters.push_back(regionInserter); //collect info about functions diff --git a/sapfor/experts/Sapfor_2017/_src/GraphCall/graph_calls_base.cpp b/sapfor/experts/Sapfor_2017/_src/GraphCall/graph_calls_base.cpp index f2c835a..824e8f5 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphCall/graph_calls_base.cpp +++ b/sapfor/experts/Sapfor_2017/_src/GraphCall/graph_calls_base.cpp @@ -849,12 +849,12 @@ void excludeArraysFromDistribution(const map>& a vector parallelRegions, map>& SPF_messages, map, DIST::Array*>& createdArrays, - int mpiProgram) + int sharedMemoryParallelization) { checkArraysMapping(loopGraph, SPF_messages, arrayLinksByFuncCalls); propagateArrayFlags(arrayLinksByFuncCalls, declaredArrays, SPF_messages); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { for (int z = 0; z < parallelRegions.size(); ++z) filterArrayInCSRGraph(loopGraph, allFuncInfo, parallelRegions[z], arrayLinksByFuncCalls, SPF_messages); diff --git a/sapfor/experts/Sapfor_2017/_src/GraphCall/graph_calls_func.h b/sapfor/experts/Sapfor_2017/_src/GraphCall/graph_calls_func.h index 94c5b56..a4d3715 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphCall/graph_calls_func.h +++ b/sapfor/experts/Sapfor_2017/_src/GraphCall/graph_calls_func.h @@ -34,7 +34,7 @@ void createMapOfFunc(const std::vector &allFuncInfo, std::map &funcMap, const std::string &funcName); void updateFuncInfo(const std::map> &allFuncInfo); -void excludeArraysFromDistribution(const std::map>& arrayLinksByFuncCalls, const std::map, std::pair> declaredArrays, std::map>& loopGraph, std::vector parallelRegions, std::map>& SPF_messages, std::map, DIST::Array*>& createdArrays, int mpiProgram = 0); +void excludeArraysFromDistribution(const std::map>& arrayLinksByFuncCalls, const std::map, std::pair> declaredArrays, std::map>& loopGraph, std::vector parallelRegions, std::map>& SPF_messages, std::map, DIST::Array*>& createdArrays, int sharedMemoryParallelization = 0); #if __SPF void functionAnalyzer(SgFile *file, std::map> &allFuncInfo, const std::vector &loops, std::vector &messagesForFile, std::map>& fullIR); diff --git a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.cpp b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.cpp index f2d02c4..4b22dc3 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.cpp +++ b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.cpp @@ -423,7 +423,7 @@ static bool hasNonRect(SgForStmt *st, const vector &parentLoops, vec SgExpression* end = st->end(); SgExpression* step = st->step(); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { set usedArrays; @@ -609,7 +609,7 @@ static bool hasSubstringRef(SgStatement* loop) return false; } -void loopGraphAnalyzer(SgFile *file, vector &loopGraph, const vector &intervalTree, vector &messages, int mpiProgram) +void loopGraphAnalyzer(SgFile *file, vector &loopGraph, const vector &intervalTree, vector &messages, int sharedMemoryParallelization) { map mapIntervals; createMapOfinterval(mapIntervals, intervalTree); diff --git a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.h b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.h index 6faef07..ce3939e 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.h +++ b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.h @@ -327,7 +327,7 @@ public: bool isArrayTemplatesTheSame(DIST::Array*& sameTemplate, const uint64_t regId, const std::map>& arrayLinksByFuncCalls) { - if (mpiProgram != 0) + if (sharedMemoryParallelization != 0) return true; std::set usedForRegAccess; diff --git a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops_base.cpp b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops_base.cpp index 6c97d05..b1f9e35 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops_base.cpp +++ b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops_base.cpp @@ -567,12 +567,12 @@ void addToDistributionGraph(const map> getRealArrayRefs(access.first, access.first, realArrayRefs[access.first], arrayLinksByFuncCalls); bool has_Wr_edges = false, has_Ww_edges = false, has_Rr_edges = false; - has_Wr_edges = processLinks(currAccessesV, allArrays, realArrayRefs, mpiProgram == 0 ? G :loopGraph, WW_link); - has_Ww_edges |= processLinks(currAccessesV, allArrays, realArrayRefs, mpiProgram == 0 ? G : loopGraph, WR_link); + has_Wr_edges = processLinks(currAccessesV, allArrays, realArrayRefs, sharedMemoryParallelization == 0 ? G :loopGraph, WW_link); + has_Ww_edges |= processLinks(currAccessesV, allArrays, realArrayRefs, sharedMemoryParallelization == 0 ? G : loopGraph, WR_link); if (!has_Wr_edges && !has_Ww_edges) - has_Rr_edges = processLinks(currAccessesV, allArrays, realArrayRefs, mpiProgram == 0 ? G : loopGraph, RR_link); + has_Rr_edges = processLinks(currAccessesV, allArrays, realArrayRefs, sharedMemoryParallelization == 0 ? G : loopGraph, RR_link); - if (mpiProgram) + if (sharedMemoryParallelization) { if (!has_Wr_edges && !has_Ww_edges && !has_Rr_edges) for (auto& elem : realArrayRefs) diff --git a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops_func.h b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops_func.h index 99cfa0b..92f7576 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops_func.h +++ b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops_func.h @@ -7,7 +7,7 @@ struct SpfInterval; -void loopGraphAnalyzer(SgFile *file, std::vector &loopGraph, const std::vector &statisticTimes, std::vector &messages, int mpiProgram); +void loopGraphAnalyzer(SgFile *file, std::vector &loopGraph, const std::vector &statisticTimes, std::vector &messages, int sharedMemoryParallelization); void findAllRefsToLables(SgStatement *st, std::map> &labelsRef, bool includeWrite = true); std::map findAllDirectives(SgFile *file, const std::vector &loops, const uint64_t regId); std::vector, std::pair>> findAllSingleRemotes(SgFile *file, const uint64_t regId, std::vector ®ions); diff --git a/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer.cpp b/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer.cpp index 393f234..caadd09 100644 --- a/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer.cpp +++ b/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer.cpp @@ -335,7 +335,7 @@ vector matchSubscriptToLoopSymbols(const vector &parentLoops, S addInfoToMap(loopInfo, parentLoops[position], currOrigArrayS, arrayRef, dimNum, REMOTE_FALSE, currLine, numOfSubscriptions); } - if (coefs.first < 0 && mpiProgram == 0) + if (coefs.first < 0 && sharedMemoryParallelization == 0) { if (currRegime == DATA_DISTR) { @@ -583,7 +583,7 @@ static void findArrayRef(const vector &parentLoops, SgExpression *cu if (itLoop->second->perfectLoop != depth) break; itLoop->second->hasIndirectAccess = true; - if (mpiProgram && side == RIGHT) + if (sharedMemoryParallelization && side == RIGHT) itLoop->second->hasIndirectAccess = false; } mapArrayRef(currentSt, currExp, parentLoops, side, lineNum, loopInfo, sortedLoopGraph, @@ -654,7 +654,7 @@ static void findArrayRef(const vector &parentLoops, SgExpression *cu const string key = string(OriginalSymbol(currExp->symbol())->identifier()); if (loopsPrivates.find(key) == loopsPrivates.end()) { - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { for (auto& loop : parentLoops) { @@ -687,7 +687,7 @@ static void findArrayRef(const vector &parentLoops, SgExpression *cu if (wasMapped) { - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { int z = 0; for (auto& loop : parentLoops) @@ -2257,7 +2257,7 @@ void loopAnalyzer(SgFile *file, vector ®ions, mapexpr(0)->lhs()->symbol(); if (s && privates.find(s->identifier()) == privates.end()) - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) hasWritesToArray = true; } } @@ -2776,7 +2776,7 @@ static void findArrayRefs(SgExpression *ex, SgStatement *st, string fName, int p new DIST::Array(getShortName(uniqKey), symb->identifier(), ((SgArrayType*)(symb->type()))->dimension(), getUniqArrayId(), decl->fileName(), decl->lineNumber(), arrayLocation, new Symbol(symb), findOmpThreadPrivDecl(scope, ompThreadPrivate, symb), false, false, - inRegion, typeSize, mpiProgram ? DIST::NO_DISTR : DIST::DISTR); + inRegion, typeSize, sharedMemoryParallelization ? DIST::NO_DISTR : DIST::DISTR); itNew = declaredArrays.insert(itNew, make_pair(uniqKey, make_pair(arrayToAdd, new DIST::ArrayAccessInfo()))); diff --git a/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer_internal.h b/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer_internal.h index 9ab28a7..dcaeb58 100644 --- a/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer_internal.h +++ b/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer_internal.h @@ -50,7 +50,7 @@ extern int passDone; extern REGIME currRegime; extern std::vector* currMessages; -extern int mpiProgram; +extern int sharedMemoryParallelization; extern int ignoreIO; extern int parallizeFreeLoops; diff --git a/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/resolve_par_reg_conflicts.cpp b/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/resolve_par_reg_conflicts.cpp index 4df11ec..4321705 100644 --- a/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/resolve_par_reg_conflicts.cpp +++ b/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/resolve_par_reg_conflicts.cpp @@ -1251,7 +1251,7 @@ void fillUsedArraysInExp(const pair &interval, const int bool checkRegionsResolving(const vector ®ions, const map> &allFuncInfo, const map &commonBlocks, - map> &SPF_messages, bool mpiProgram) + map> &SPF_messages, bool sharedMemoryParallelization) { bool error = false; @@ -1319,7 +1319,7 @@ bool checkRegionsResolving(const vector ®ions, } } - if (mpiProgram) + if (sharedMemoryParallelization) return error; // check local arrays @@ -1611,7 +1611,7 @@ static void compliteUseOnlyList(SgStatement *func, const string &location, const } int resolveParRegions(vector ®ions, const map> &allFuncInfo, - map> &SPF_messages, bool mpiProgram, + map> &SPF_messages, bool sharedMemoryParallelization, map>> &newDeclsToInclude) { bool error = false; @@ -1619,7 +1619,7 @@ int resolveParRegions(vector ®ions, const map funcMap; createMapOfFunc(allFuncInfo, funcMap); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { map>> copied; @@ -1905,7 +1905,7 @@ int resolveParRegions(vector ®ions, const map ®ions, const std::map ®ions, const std::map> &allFuncInfo, std::map> &SPF_messages); int printCheckRegions(const char *fileName, const std::vector ®ions, const std::map> &allFuncInfo); -bool checkRegionsResolving(const std::vector ®ions, const std::map> &allFuncInfo, const std::map &commonBlocks, std::map> &SPF_messages, bool mpiProgram); -int resolveParRegions(std::vector& regions, const std::map>& allFuncInfo, std::map>& SPF_messages, bool mpiProgram, std::map>>& copyDecls); +bool checkRegionsResolving(const std::vector ®ions, const std::map> &allFuncInfo, const std::map &commonBlocks, std::map> &SPF_messages, bool sharedMemoryParallelization); +int resolveParRegions(std::vector& regions, const std::map>& allFuncInfo, std::map>& SPF_messages, bool sharedMemoryParallelization, std::map>>& copyDecls); void insertRealignsBeforeFragments(ParallelRegion* reg, SgFile* file, const std::set& distrArrays, const std::map>& arrayLinksByFuncCalls); \ No newline at end of file diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp index fa3c72f..ae13641 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp @@ -506,7 +506,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne insertIntrinsicStat(getObjectForFileFromMap(file_name, allFuncInfo)); } else if (curr_regime == LOOP_GRAPH) - loopGraphAnalyzer(file, getObjectForFileFromMap(file_name, loopGraph), getObjectForFileFromMap(file_name, intervals), getObjectForFileFromMap(file_name, SPF_messages), mpiProgram); + loopGraphAnalyzer(file, getObjectForFileFromMap(file_name, loopGraph), getObjectForFileFromMap(file_name, intervals), getObjectForFileFromMap(file_name, SPF_messages), sharedMemoryParallelization); else if (curr_regime == VERIFY_ENDDO) { bool res = EndDoLoopChecker(file, getObjectForFileFromMap(file_name, SPF_messages)); @@ -1076,7 +1076,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne if (curr_regime == ONLY_ARRAY_GRAPH) keepFiles = 1; - if (mpiProgram) + if (sharedMemoryParallelization) { for (auto& byFile : loopGraph) for (auto& loop : byFile.second) @@ -1387,7 +1387,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne vector result; set arraysDone; - if (mpiProgram) + if (sharedMemoryParallelization) { bool wasDone = false; for (int z = 0; z < parallelRegions.size(); ++z) @@ -1411,7 +1411,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne { for (auto& byFile : loopGraph) for (auto& loop : byFile.second) - loop->createVirtualTemplateLinks(arrayLinksByFuncCalls, SPF_messages, mpiProgram > 0); + loop->createVirtualTemplateLinks(arrayLinksByFuncCalls, SPF_messages, sharedMemoryParallelization > 0); //add dummy array DataDirective& dataDirectives = parallelRegions[0]->GetDataDirToModify(); @@ -1456,7 +1456,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne //recalculate array sizes after expression substitution recalculateArraySizes(arraysDone, allArrays.GetArrays(), arrayLinksByFuncCalls, allFuncInfo); - createDistributionDirs(reducedG, allArrays, dataDirectives, SPF_messages, arrayLinksByFuncCalls, mpiProgram > 0); + createDistributionDirs(reducedG, allArrays, dataDirectives, SPF_messages, arrayLinksByFuncCalls, sharedMemoryParallelization > 0); ALGORITHMS_DONE[CREATE_DISTIBUTION][z] = 1; } @@ -1574,7 +1574,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne } else if (curr_regime == RESOLVE_PAR_REGIONS) { - bool error = resolveParRegions(parallelRegions, allFuncInfo, SPF_messages, mpiProgram, newCopyDeclToIncl); + bool error = resolveParRegions(parallelRegions, allFuncInfo, SPF_messages, sharedMemoryParallelization, newCopyDeclToIncl); if (error) internalExit = 1; } @@ -1610,7 +1610,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne else if (curr_regime == INSERT_PARALLEL_DIRS || curr_regime == EXTRACT_PARALLEL_DIRS) { bool cond = (folderName != NULL) || (consoleMode) || (!consoleMode && curr_regime == EXTRACT_PARALLEL_DIRS); - if (cond && mpiProgram == 0) + if (cond && sharedMemoryParallelization == 0) { //insert template declaration to main program const bool extract = (curr_regime == EXTRACT_PARALLEL_DIRS); @@ -1659,7 +1659,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne printDefUseSets("_defUseList.txt", defUseByFunctions); } else if (curr_regime == LOOP_ANALYZER_DATA_DIST_S0) - excludeArraysFromDistribution(arrayLinksByFuncCalls, declaredArrays, loopGraph, parallelRegions, SPF_messages, createdArrays, mpiProgram); + excludeArraysFromDistribution(arrayLinksByFuncCalls, declaredArrays, loopGraph, parallelRegions, SPF_messages, createdArrays, sharedMemoryParallelization); else if (curr_regime == LOOP_ANALYZER_DATA_DIST_S1) { for (int z = 0; z < parallelRegions.size(); ++z) @@ -1671,7 +1671,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne } else if (curr_regime == PRINT_PAR_REGIONS_ERRORS) { - bool error = checkRegionsResolving(parallelRegions, allFuncInfo, commonBlocks, SPF_messages, mpiProgram); + bool error = checkRegionsResolving(parallelRegions, allFuncInfo, commonBlocks, SPF_messages, sharedMemoryParallelization); if (error) internalExit = 1; } @@ -2135,7 +2135,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam case INSERT_PARALLEL_DIRS_NODIST: { - mpiProgram = 1; + sharedMemoryParallelization = 1; string additionalName = (consoleMode && folderName == NULL) ? "__shared" : ""; @@ -2168,7 +2168,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam int maxDimsIdxReg = -1; int lastI = 1; - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) lastI = countMaxValuesForParallelVariants(maxDims, maxDimsIdx, maxDimsIdxReg, currentVariants); if (genAllVars == 0) lastI = 1; @@ -2176,7 +2176,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam for (int i = 0; i < lastI; ++i) { //if specific variant number is requested, skip all others - if (genSpecificVar >= 0 && i != genSpecificVar && mpiProgram == 0) + if (genSpecificVar >= 0 && i != genSpecificVar && sharedMemoryParallelization == 0) continue; string tmpFolder = ""; @@ -2203,7 +2203,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam runAnalysis(*project, INSERT_PARALLEL_DIRS, false, consoleMode ? additionalName.c_str() : NULL, folderName); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { runPass(CREATE_REMOTES, proj_name, folderName); runPass(REMOVE_AND_CALC_SHADOW, proj_name, folderName); @@ -2214,11 +2214,11 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam runPass(RESTORE_LOOP_FROM_ASSIGN, proj_name, folderName); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) runPass(ADD_TEMPL_TO_USE_ONLY, proj_name, folderName); runAnalysis(*project, INSERT_REGIONS, false); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) runPass(GROUP_ACTUAL_AND_REMOTE, proj_name, folderName); runAnalysis(*project, CALCULATE_STATS_SCHEME, false); @@ -2242,7 +2242,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam runPass(REVERSE_CREATED_NESTED_LOOPS, proj_name, folderName); runPass(CLEAR_SPF_DIRS, proj_name, folderName); runPass(RESTORE_LOOP_FROM_ASSIGN_BACK, proj_name, folderName); - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) runPass(GROUP_ACTUAL_AND_REMOTE_RESTORE, proj_name, folderName); //clear shadow grouping @@ -2567,7 +2567,7 @@ int main(int argc, char **argv) else if (string(curr_arg) == "-fdvm") convertFiles(argc - i, argv + i); else if (string(curr_arg) == "-mpi") { - mpiProgram = 1; + sharedMemoryParallelization = 1; ignoreArrayDistributeState = true; } else if (string(curr_arg) == "-client") @@ -2622,7 +2622,7 @@ int main(int argc, char **argv) } } - if (mpiProgram == 1) + if (sharedMemoryParallelization == 1) { keepDvmDirectives = 0; ignoreIO = 1; diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.h b/sapfor/experts/Sapfor_2017/_src/Sapfor.h index 70e3f7c..e9d8bf9 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.h +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.h @@ -9,7 +9,7 @@ extern int automaticDeprecateArrays; extern int maxShadowWidth; extern int langOfMessages; extern bool removeNestedIntervals; -extern int mpiProgram; +extern int sharedMemoryParallelization; extern int parallizeFreeLoops; extern int ignoreIO; extern int parseForInlining; diff --git a/sapfor/experts/Sapfor_2017/_src/SapforData.h b/sapfor/experts/Sapfor_2017/_src/SapforData.h index d495e12..d3df28c 100644 --- a/sapfor/experts/Sapfor_2017/_src/SapforData.h +++ b/sapfor/experts/Sapfor_2017/_src/SapforData.h @@ -35,7 +35,7 @@ int intervals_threshold = 100; // threshold for intervals bool removeNestedIntervals = false; // nested intervals removal flag int langOfMessages = 1; // 0 - ENG, 1 - RUS int parallizeFreeLoops = 0; // parallize free calculations -int mpiProgram = 0; // detected mpi calls +int sharedMemoryParallelization = 0; // detected mpi calls int ignoreIO = 0; // ignore io checker for arrays (DVM IO limitations) int parseForInlining = 0; // special regime for files parsing for inliner int dumpIR = 0; // allow dump IR after BUILD_IR pass diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp b/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp index befe3e6..f0e217a 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp @@ -3344,7 +3344,7 @@ SgProject* createProject(const char* proj_name, if (detectMpiCalls(project, SPF_messages)) { - mpiProgram = 1; + sharedMemoryParallelization = 1; keepDvmDirectives = 0; ignoreIO = 1; parallizeFreeLoops = 0; diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp b/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp index 4b60f13..76fec47 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp @@ -203,7 +203,7 @@ const string printVersionAsFortranComm() ret += "! *** consider DVMH directives\n"; if (keepSpfDirs) ret += "! *** save SPF directives\n"; - if (mpiProgram) + if (sharedMemoryParallelization) ret += "! *** MPI program regime (shared memory parallelization)\n"; if (ignoreIO) ret += "! *** ignore I/O checker for arrays (DVM I/O limitations)\n"; diff --git a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp index 958f673..28be54d 100644 --- a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp +++ b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp @@ -166,10 +166,10 @@ static void setOptions(const short* options, bool isBuildParallel = false, const removeNestedIntervals = (intOptions[KEEP_LOOPS_CLOSE_NESTING] == 1); showDebug = (intOptions[DEBUG_PRINT_ON] == 1); - mpiProgram = (mpiProgram != 1) ? intOptions[MPI_PROGRAM] : mpiProgram; - parallizeFreeLoops = (mpiProgram == 1) ? 0 : intOptions[PARALLIZE_FREE_LOOPS]; - ignoreIO = (mpiProgram == 1) ? 1 : intOptions[IGNORE_IO_SAPFOR]; - keepDvmDirectives = (mpiProgram == 1) ? 0 : intOptions[KEEP_DVM_DIRECTIVES]; + sharedMemoryParallelization = (sharedMemoryParallelization != 1) ? intOptions[MPI_PROGRAM] : sharedMemoryParallelization; + parallizeFreeLoops = (sharedMemoryParallelization == 1) ? 0 : intOptions[PARALLIZE_FREE_LOOPS]; + ignoreIO = (sharedMemoryParallelization == 1) ? 1 : intOptions[IGNORE_IO_SAPFOR]; + keepDvmDirectives = (sharedMemoryParallelization == 1) ? 0 : intOptions[KEEP_DVM_DIRECTIVES]; parseForInlining = intOptions[PARSE_FOR_INLINE]; @@ -819,7 +819,7 @@ int SPF_GetArrayDistribution(void*& context, int winHandler, short *options, sho runPassesForVisualizer(projName, { CREATE_TEMPLATE_LINKS }); else if (regime == 1) { - if (mpiProgram) + if (sharedMemoryParallelization) runPassesForVisualizer(projName, { SELECT_ARRAY_DIM_CONF }); else runPassesForVisualizer(projName, { LOOP_ANALYZER_DATA_DIST_S1 }); @@ -1061,7 +1061,7 @@ int SPF_CreateParallelVariant(void*& context, int winHandler, short *options, sh throw (-5); int countOfDist = 0; - if (mpiProgram == 0) + if (sharedMemoryParallelization == 0) { map>> varLens; for (int i = 0, k = 0; i < *varLen; i += 3, ++k) @@ -1892,7 +1892,7 @@ int SPF_SharedMemoryParallelization(void*& context, int winHandler, short* optio MessageManager::clearCache(); MessageManager::setWinHandler(winHandler); ignoreArrayDistributeState = true; - mpiProgram = 1; + sharedMemoryParallelization = 1; return simpleTransformPass(INSERT_PARALLEL_DIRS_NODIST, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize, true); }