diff --git a/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.cpp b/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.cpp index b4567c7..3e11f6b 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.cpp +++ b/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.cpp @@ -65,26 +65,13 @@ static void findUsedArraysInParallelLoops(LoopGraph* loop, set& re } static void preventLoopsFromParallelizations(LoopGraph* loop, const set& prevent, - vector& createdDirectives,vector& messagesForFile) + vector& messagesForFile) { if (loop->directive) { if (IsSetsIntersect(prevent, loop->usedArraysAll)) { // prevent this loop - int loopLine = loop->lineNum; - - for (auto dir_it = createdDirectives.begin(); dir_it != createdDirectives.end(); dir_it++) - { - if ((*dir_it)->line == loopLine) - { - delete *dir_it; - dir_it = createdDirectives.erase(dir_it); - - break; - } - } - delete loop->directive; loop->directive = NULL; @@ -123,7 +110,7 @@ static void preventLoopsFromParallelizations(LoopGraph* loop, const setchildren) - preventLoopsFromParallelizations(child, prevent, createdDirectives, messagesForFile); + preventLoopsFromParallelizations(child, prevent, messagesForFile); } struct DimConf @@ -169,9 +156,9 @@ pickBest(const map>>& arrs) } void SelectArrayConfForParallelization(SgProject* proj, map>& funcByFile, - const map>& loopGraph, map>& createdDirectives, - map>& allMessages, const map>& arrayLinksByFuncCalls, - const vector& regions) + const map>& loopGraph, + map>& allMessages, + const map>& arrayLinksByFuncCalls) { map funcByName; for (const auto& byFile : funcByFile) @@ -265,121 +252,43 @@ void SelectArrayConfForParallelization(SgProject* proj, map& fileM = getObjectForFileFromMap(byFile.first.c_str(), allMessages); - auto dirs_it = createdDirectives.find(byFile.first); - if (dirs_it != createdDirectives.end()) + SgFile::switchToFile(byFile.first); + + auto& loops = byFile.second; + + auto file_funcs_it = funcByFile.find(byFile.first); + + if (file_funcs_it == funcByFile.end()) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); // no such file in funcByFile + + map> usedInLoops; + + for (const auto& loop : loops) { - SgFile::switchToFile(byFile.first); + SgStatement* search_func = loop->loop->GetOriginal(); - auto& loops = byFile.second; + while (search_func && (!isSgProgHedrStmt(search_func))) + search_func = search_func->controlParent(); - auto file_funcs_it = funcByFile.find(byFile.first); + if (!search_func) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); //loop statement outside any function statement - if (file_funcs_it == funcByFile.end()) - printInternalError(convertFileName(__FILE__).c_str(), __LINE__); // no such file in funcByFile - - map> usedInLoops; - - for (const auto& loop : loops) + bool loop_analyzed = false; + for (const auto& byFunc : file_funcs_it->second) { - SgStatement* search_func = loop->loop->GetOriginal(); - - while (search_func && (!isSgProgHedrStmt(search_func))) - search_func = search_func->controlParent(); - - if (!search_func) - printInternalError(convertFileName(__FILE__).c_str(), __LINE__); //loop statement outside any function statement - - bool loop_analyzed = false; - for (const auto& byFunc : file_funcs_it->second) + if (byFunc->funcPointer->GetOriginal() == search_func) { - if (byFunc->funcPointer->GetOriginal() == search_func) - { - auto prevent_it = preventFromParallelization.find(byFunc); - if (prevent_it != preventFromParallelization.end()) - preventLoopsFromParallelizations(loop, prevent_it->second, dirs_it->second, fileM); + auto prevent_it = preventFromParallelization.find(byFunc); + if (prevent_it != preventFromParallelization.end()) + preventLoopsFromParallelizations(loop, prevent_it->second, fileM); - loop_analyzed = true; - break; - } - } - - if (!loop_analyzed) - printInternalError(convertFileName(__FILE__).c_str(), __LINE__); //no func found for loop - } - } - } -} - -void removeRegionsWithoutDirs(const map>& createdDirectives, - vector& parallelRegions, - const map>& allFuncInfo, - map>& SPF_messages) -{ - set empty_regs(parallelRegions.begin(), parallelRegions.end()); - - for (const auto& byFile : createdDirectives) - for (const auto& dir : byFile.second) - empty_regs.erase(getRegionByLine(parallelRegions, byFile.first, dir->line)); - - set idxToDel; - for (int z = 0; z < parallelRegions.size(); ++z) - { - if (empty_regs.find(parallelRegions[z]) != empty_regs.end()) - { - __spf_print(1, " no parallel directives for parallel region '%s'\n", parallelRegions[z]->GetName().c_str()); - - if (parallelRegions[z]->GetId() == 0) // DEFAULT - { - wstring bufE, bufR; - __spf_printToLongBuf(bufE, L"Can not find arrays or free loops for distribution in this project"); - __spf_printToLongBuf(bufR, R130); - - for (auto& funcByFile : allFuncInfo) - { - vector& fileM = getObjectForFileFromMap(funcByFile.first.c_str(), SPF_messages); - for (auto& func : funcByFile.second) - { - auto stat = func->funcPointer->GetOriginal(); - if (stat->variant() == PROG_HEDR) - fileM.push_back(Messages(ERROR, stat->lineNumber(), bufR, bufE, 3010)); - } + loop_analyzed = true; + break; } } - else - { - wstring bufE, bufR; - __spf_printToLongBuf(bufE, L"Can not find arrays or free loops for distribution in this region"); - __spf_printToLongBuf(bufR, R131); - for (auto& linesByFile : parallelRegions[z]->GetAllLines()) - { - vector& fileM = getObjectForFileFromMap(linesByFile.first.c_str(), SPF_messages); - for (auto& lines : linesByFile.second) - if (!lines.isImplicit()) - fileM.push_back(Messages(ERROR, lines.lines.first, bufR, bufE, 3010)); - } - } - idxToDel.insert(z); + if (!loop_analyzed) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); //no func found for loop } } - - vector newParReg; - for (int z = 0; z < parallelRegions.size(); ++z) - { - if (idxToDel.find(z) != idxToDel.end()) - { - ParallelRegion* regToDel = parallelRegions[z]; -#ifdef _WIN32 - removeFromCollection(parallelRegions[z]); -#endif - delete parallelRegions[z]; - } - else - newParReg.push_back(parallelRegions[z]); - } - parallelRegions.clear(); - parallelRegions = newParReg; - - if (parallelRegions.size() == 0) - printInternalError(convertFileName(__FILE__).c_str(), __LINE__); } \ No newline at end of file diff --git a/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.h b/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.h index cb35893..4d2e392 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.h +++ b/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.h @@ -11,12 +11,6 @@ void SelectArrayConfForParallelization(SgProject* proj, std::map>& funcByFile, - const std::map>& loopGraph, - std::map>& createdDirectives, + const std::map>& loopGraph, std::map>& allMessages, - const std::map>& arrayLinksByFuncCalls, const std::vector& regions); - -void removeRegionsWithoutDirs(const std::map>& createdDirectives, - std::vector& parallelRegions, - const std::map>& allFuncInfo, - std::map>& SPF_messages); \ No newline at end of file + const std::map>& arrayLinksByFuncCalls); \ No newline at end of file diff --git a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.cpp b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.cpp index 1141841..0eb0896 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.cpp +++ b/sapfor/experts/Sapfor_2017/_src/GraphLoop/graph_loops.cpp @@ -207,6 +207,12 @@ static inline bool hasGoto(SgStatement *begin, SgStatement *end, has = true; } + if (curr->variant() == RETURN_STAT) + { + linesOfIntGoTo.push_back(curr->lineNumber()); + has = true; + } + if (curr->variant() == CYCLE_STMT) cycleStmts.push_back(curr->lineNumber()); curr = curr->lexNext(); diff --git a/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer_nodist.cpp b/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer_nodist.cpp index e788d25..b423e47 100644 --- a/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer_nodist.cpp +++ b/sapfor/experts/Sapfor_2017/_src/LoopAnalyzer/loop_analyzer_nodist.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp index 33c7e9b..a5d55e3 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp @@ -1924,8 +1924,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne else if (curr_regime == FIX_COMMON_BLOCKS) fixCommonBlocks(allFuncInfo, commonBlocks, &project); else if (curr_regime == SELECT_ARRAY_DIM_CONF) { - SelectArrayConfForParallelization(&project, allFuncInfo, loopGraph, createdDirectives, SPF_messages, arrayLinksByFuncCalls, parallelRegions); - removeRegionsWithoutDirs(createdDirectives, parallelRegions, allFuncInfo, SPF_messages); + SelectArrayConfForParallelization(&project, allFuncInfo, loopGraph, SPF_messages, arrayLinksByFuncCalls); } else if (curr_regime == GET_MIN_MAX_BLOCK_DIST) { @@ -2154,8 +2153,6 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam runPass(REVERT_SUBST_EXPR_RD, proj_name, folderName); runPass(CONVERT_LOOP_TO_ASSIGN, proj_name, folderName); - - runPass(SELECT_ARRAY_DIM_CONF, proj_name, folderName); runPass(REVERT_SUBST_EXPR_RD, proj_name, folderName); diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h b/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h index 7a4a3f2..b8e6c2e 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h @@ -233,7 +233,7 @@ void InitPassesDependencies(map> &passDepsIn, set list({ GET_ALL_ARRAY_DECL, CALL_GRAPH2, CODE_CHECKER_PASSES, SUBST_EXPR_RD, ARRAY_ACCESS_ANALYSIS_FOR_CORNER }) <= list({ LOOP_ANALYZER_NODIST, LOOP_ANALYZER_DATA_DIST_S0, LOOP_ANALYZER_DATA_DIST_S1, ONLY_ARRAY_GRAPH }); - list({ LOOP_ANALYZER_NODIST, REMOVE_OMP_DIRS }) <= Pass(INSERT_PARALLEL_DIRS_NODIST); + list({ LOOP_ANALYZER_NODIST, REMOVE_OMP_DIRS }) <= Pass(SELECT_ARRAY_DIM_CONF) <= Pass(INSERT_PARALLEL_DIRS_NODIST); Pass(CHECK_ARGS_DECL) <= Pass(CREATE_TEMPLATE_LINKS); @@ -251,7 +251,7 @@ void InitPassesDependencies(map> &passDepsIn, set list({ CORRECT_VAR_DECL, PREPROC_SPF }) <= list({ LOOP_GRAPH, CALL_GRAPH, CALL_GRAPH2 }); - list({ PREPROC_SPF, CALL_GRAPH2 }) <= Pass(FILL_PAR_REGIONS_LINES) <= list({ EXPAND_EXTRACT_PAR_REGION, CHECK_FUNC_TO_INCLUDE, FIND_FUNC_TO_INCLUDE, CHECK_ARGS_DECL, SELECT_ARRAY_DIM_CONF}); + list({ PREPROC_SPF, CALL_GRAPH2 }) <= Pass(FILL_PAR_REGIONS_LINES) <= list({ EXPAND_EXTRACT_PAR_REGION, CHECK_FUNC_TO_INCLUDE, FIND_FUNC_TO_INCLUDE, CHECK_ARGS_DECL }); list({ PREPROC_SPF, CALL_GRAPH2, FILL_PAR_REGIONS_LINES }) <= Pass(FILL_PAR_REGIONS) <= Pass(RESOLVE_PAR_REGIONS); diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/utils.h b/sapfor/experts/Sapfor_2017/_src/Utils/utils.h index df8e325..d46a9db 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/utils.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/utils.h @@ -3,6 +3,7 @@ #include #include #include +#include struct DataDirective; namespace Distribution diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/version.h b/sapfor/experts/Sapfor_2017/_src/Utils/version.h index c7604bc..8a3f0fb 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/version.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2296" +#define VERSION_SPF "2298" diff --git a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp index 10fe288..5acca3b 100644 --- a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp +++ b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp @@ -820,7 +820,7 @@ int SPF_GetArrayDistribution(void*& context, int winHandler, short *options, sho else if (regime == 1) { if (mpiProgram) - runPassesForVisualizer(projName, { LOOP_ANALYZER_NODIST }); + runPassesForVisualizer(projName, { SELECT_ARRAY_DIM_CONF }); else runPassesForVisualizer(projName, { LOOP_ANALYZER_DATA_DIST_S1 }); }