From 8b26666bfcb40d0ddf6fda3f2fe95f812b7c6fb1 Mon Sep 17 00:00:00 2001 From: mkoch Date: Fri, 6 Oct 2023 15:38:00 +0300 Subject: [PATCH] Fix for analysis in mpi mode, add warnig in SELECT_ARRAY_DIM_CONF pass --- .../_src/GraphCall/select_array_conf.cpp | 47 +++++++++++++++++-- .../Sapfor_2017/_src/Utils/PassManager.h | 2 +- .../experts/Sapfor_2017/_src/Utils/errors.h | 5 +- .../_src/Utils/russian_errors_text.txt | 2 + 4 files changed, 49 insertions(+), 7 deletions(-) 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 f5ce3ab..ef2b8b8 100644 --- a/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.cpp +++ b/sapfor/experts/Sapfor_2017/_src/GraphCall/select_array_conf.cpp @@ -10,8 +10,10 @@ using std::wstring; using std::inserter; using std::copy; +using std::to_string; -bool IsSetsIntersect(const set& lhs, const set& rhs) { +bool IsSetsIntersect(const set& lhs, const set& rhs) +{ if (lhs.empty() || rhs.empty()) return false; @@ -53,7 +55,8 @@ bool IsSetsIntersect(const set& lhs, const set& rhs) return false; } -static void findUsedArraysInParallelLoops(LoopGraph* loop, set& res) { +static void findUsedArraysInParallelLoops(LoopGraph* loop, set& res) +{ if(loop->directive) copy(loop->usedArraysAll.begin(), loop->usedArraysAll.end(), inserter(res, res.end())); else @@ -62,7 +65,8 @@ static void findUsedArraysInParallelLoops(LoopGraph* loop, set& re } static void preventLoopsFromParallelizations(LoopGraph* loop, const set& prevent, - vector& createdDirectives) { + vector& createdDirectives,vector& messagesForFile) +{ if (loop->directive) { if (IsSetsIntersect(prevent, loop->usedArraysAll)) @@ -83,12 +87,44 @@ static void preventLoopsFromParallelizations(LoopGraph* loop, const setdirective; loop->directive = NULL; + + vector conflict_arrays; // = prevent \intersection loop->usedArraysAll + + set_intersection(prevent.begin(), prevent.end(), + loop->usedArraysAll.begin(), loop->usedArraysAll.end(), + back_inserter(conflict_arrays)); + + for(DIST::Array* conflict_array: conflict_arrays) + { + // constructing string with array and it's sizes + string array_bounds; + const auto& array_sizes = conflict_array->GetSizes(); + for(int i = 0; i < array_sizes.size(); i++) + { + if(i != 0) + array_bounds += ","; + + const auto& bounds_pair = array_sizes[i]; + array_bounds += bounds_pair.first >= 0 ? to_string(bounds_pair.first) : "*"; + array_bounds += ":"; + array_bounds += bounds_pair.second >= 0 ? to_string(bounds_pair.second) : "*"; + } + + string array_ref = conflict_array->GetName() + "(" + array_bounds + ")"; + + // add conflict message + std::wstring bufE, bufR; + __spf_printToLongBuf(bufE, L"Array reference '%s' has a different size from the original array", to_wstring(array_ref).c_str()); + __spf_printToLongBuf(bufR, R202, to_wstring(array_ref).c_str()); + + messagesForFile.push_back(Messages(WARR, loop->lineNum, bufR, bufE, 3023)); + } } } else { for (LoopGraph* child : loop->children) - preventLoopsFromParallelizations(child, prevent, createdDirectives); + preventLoopsFromParallelizations(child, prevent, createdDirectives, messagesForFile); } } @@ -230,6 +266,7 @@ void SelectArrayConfForParallelization(SgProject* proj, map& fileM = getObjectForFileFromMap(byFile.first.c_str(), allMessages); auto dirs_it = createdDirectives.find(byFile.first); if (dirs_it != createdDirectives.end()) { @@ -261,7 +298,7 @@ void SelectArrayConfForParallelization(SgProject* proj, mapsecond, dirs_it->second); + preventLoopsFromParallelizations(loop, prevent_it->second, dirs_it->second, fileM); loop_analyzed = true; break; diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h b/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h index 7b584e5..bed858c 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/PassManager.h @@ -321,7 +321,7 @@ void removalsFromPassesDependencies(map>& passDepsIn, con { passDeps = &passDepsIn; - Pass(INSERT_PARALLEL_DIRS_NODIST) -= list({ FIND_FUNC_TO_INCLUDE, CHECK_FUNC_TO_INCLUDE }); + list({ INSERT_PARALLEL_DIRS_NODIST, LOOP_ANALYZER_NODIST }) -= list({ FIND_FUNC_TO_INCLUDE, CHECK_FUNC_TO_INCLUDE }); Pass(passes(curr_regime)).applyRemovals(); } diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/errors.h b/sapfor/experts/Sapfor_2017/_src/Utils/errors.h index 8c79a5e..2df946d 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/errors.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/errors.h @@ -125,6 +125,7 @@ enum typeMessage { WARR, ERROR, NOTE }; // 20 "detected distributed and non distributed array links by function's calls for array %s\n" // 21 "empty parallel regions is forbidden" // 22 "Can not find align rules" +// 23 "Array reference '%s' has a different size from the original array" // 40xx LOW LEVEL WARNINGS // 01 @@ -273,7 +274,7 @@ static void printStackTrace() { }; } \ } while (0) -// Свободный - R202 +// Свободный - R203 // Гайд по русификации сообщений: При добавлении нового сообщения, меняется последний сводобный идентификатор. // В этом файле остаются только спецификаторы, для которых будет заполнен текст. Полный текст пишется в файле // russian_errors_text.txt. Спецификаторы там тоже сохраняются, по ним в визуализаторе будет восстановлен @@ -597,6 +598,8 @@ static const wchar_t *R142 = L"R142:%s"; static const wchar_t* R151 = L"R151:"; //3022 static const wchar_t* R171 = L"R171:%s"; +//3023 +static const wchar_t* R202 = L"R202:%s"; //4001 //---TODO ошибки из SAGE diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/russian_errors_text.txt b/sapfor/experts/Sapfor_2017/_src/Utils/russian_errors_text.txt index 79e3074..34f4b74 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/russian_errors_text.txt +++ b/sapfor/experts/Sapfor_2017/_src/Utils/russian_errors_text.txt @@ -310,6 +310,8 @@ R142 = "Для массива '%s' не удается найти единого R151 = "Пустые области распараллеливания недопускаются." //3022 R171 = "Невозможно определить правила выравнивания для массива '%s'." +//3023 +R202 = "Ссылка '%s' имеет размер отличный от оригинального массива размер" //4001 //---TODO ошибки из SAGE