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 6774907..9ec630e 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.cpp +++ b/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.cpp @@ -1,10 +1,12 @@ #include "select_array_conf.h" +#include "../Utils/utils.h" using std::map; using std::string; using std::vector; using std::set; using std::pair; +using std::wstring; using std::inserter; using std::copy; @@ -229,3 +231,77 @@ void SelectArrayConfForParallelization(SgProject* proj, 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)); + } + } + } + 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); + } + } + + 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 ac6cffd..cb35893 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.h +++ b/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.h @@ -14,4 +14,9 @@ void SelectArrayConfForParallelization(SgProject* proj, std::map>& loopGraph, std::map>& createdDirectives, std::map>& allMessages, - const std::map>& arrayLinksByFuncCalls, const std::vector& regions); \ No newline at end of file + 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 diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp index 81ec7bb..9dda347 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.cpp @@ -2179,6 +2179,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne map> localMessages; SelectArrayConfForParallelization(&project, allFuncInfo, loopGraph, createdDirectives, localMessages, arrayLinksByFuncCalls, parallelRegions); + removeRegionsWithoutDirs(createdDirectives, parallelRegions, allFuncInfo, SPF_messages); } const float elapsed = duration_cast(high_resolution_clock::now() - timeForPass).count() / 1000.;