From 99f5febd58bf7ee50b84f58d88d11fa4609fb937 Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 7 May 2025 19:59:54 +0300 Subject: [PATCH 1/4] added json for SPF_GetAllDeclaratedArrays pass --- src/Distribution/Array.h | 60 +++++++++++++++++++++++++ src/Utils/version.h | 2 +- src/VisualizerCalls/get_information.cpp | 13 +++--- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/Distribution/Array.h b/src/Distribution/Array.h index 4d56db1..17365a0 100644 --- a/src/Distribution/Array.h +++ b/src/Distribution/Array.h @@ -9,6 +9,7 @@ #include "DvmhDirectiveBase.h" #include "../Utils/utils.h" #include "../Utils/errors.h" +#include "../Utils/json.hpp" class Symbol; class Expression; @@ -20,6 +21,7 @@ struct FuncInfo; #define MAP std::map #define SET std::set #define TO_STR std::to_string +#define JSON nlohmann::json #if __SPF extern int sharedMemoryParallelization; @@ -424,6 +426,7 @@ namespace Distribution void ClearShadowSpecs() { allShadowSpecs.clear(); } + //TODO: to remove STRING toString() { STRING retVal = ""; @@ -466,6 +469,63 @@ namespace Distribution return retVal; } + JSON toJson() + { + JSON retVal; + + retVal["id"] = (int64_t)id; + retVal["name"] = name; + retVal["shortName"] = shortName; + + retVal["dimSize"] = dimSize; + retVal["typeSize"] = typeSize; + retVal["state"] = (int)isNonDistribute; + retVal["location"] = (int)locationPos.first; + retVal["locName"] = locationPos.second; + + retVal["isTemplFlag"] = (int)isTemplFlag; + retVal["isLoopArrayFlag"] = (int)isLoopArrayFlag; + + JSON deprToDist = nlohmann::json::array(); + for (int i = 0; i < depracateToDistribute.size(); ++i) + deprToDist.push_back((int)depracateToDistribute[i]); + retVal["depracateToDist"] = deprToDist; + + JSON mappedDimsJ = nlohmann::json::array(); + for (int i = 0; i < mappedDims.size(); ++i) + mappedDimsJ.push_back((int)mappedDims[i]); + retVal["mappedDims"] = mappedDimsJ; + + JSON sizesJ = nlohmann::json::array(); + for (int i = 0; i < sizes.size(); ++i) + { + JSON pair; + pair["key"] = sizes[i].first; + pair["value"] = sizes[i].second; + sizesJ.push_back(pair); + } + retVal["sizes"] = sizesJ; + + JSON regions = nlohmann::json::array(); + for (auto& reg : containsInRegions) + regions.push_back(reg); + retVal["regions"] = regions; + + + JSON declPlacesJ = nlohmann::json::array(); + for (auto& place : declPlaces) + { + JSON elem; + elem["array_name"] = place.first; + elem["array_loc"] = place.second; + + declPlacesJ.push_back(elem); + } + retVal["declPlaces"] = declPlacesJ; + + return retVal; + } + Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true) { TemplateLink *currLink = getTemlateInfo(regionId, withCheck); diff --git a/src/Utils/version.h b/src/Utils/version.h index 2633120..ed408b9 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2416" +#define VERSION_SPF "2417" diff --git a/src/VisualizerCalls/get_information.cpp b/src/VisualizerCalls/get_information.cpp index 698d970..058108f 100644 --- a/src/VisualizerCalls/get_information.cpp +++ b/src/VisualizerCalls/get_information.cpp @@ -1416,14 +1416,17 @@ int SPF_GetAllDeclaratedArrays(void*& context, int winHandler, short *options, s { runPassesForVisualizer(projName, { GET_ALL_ARRAY_DECL }); - string resVal = ""; - for (auto f = declaredArrays.begin(); f != declaredArrays.end(); ++f) + json arrays = json::array(); + for (const auto& [_, array] : declaredArrays) { - if (f != declaredArrays.begin()) - resVal += "@"; - resVal += f->second.first->toString(); + json jArray = array.first->toJson(); + arrays.push_back(jArray); } + json allArrays; + allArrays["allArrays"] = arrays; + string resVal = allArrays.dump(); + copyStringToShort(result, resVal); retSize = (int)resVal.size() + 1; } -- 2.49.1 From 29a8c30370c6c02b5197efea6d72803c8e4e6d6f Mon Sep 17 00:00:00 2001 From: ALEXks Date: Wed, 7 May 2025 20:16:43 +0300 Subject: [PATCH 2/4] fixed Array::toJson --- src/Distribution/Array.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Distribution/Array.h b/src/Distribution/Array.h index 17365a0..dd9f615 100644 --- a/src/Distribution/Array.h +++ b/src/Distribution/Array.h @@ -516,8 +516,8 @@ namespace Distribution for (auto& place : declPlaces) { JSON elem; - elem["array_name"] = place.first; - elem["array_loc"] = place.second; + elem["file"] = place.first; + elem["line"] = place.second; declPlacesJ.push_back(elem); } -- 2.49.1 From 738f2c5d127133971ca3113dff787972589f199c Mon Sep 17 00:00:00 2001 From: xnpster Date: Sat, 10 May 2025 15:27:03 +0300 Subject: [PATCH 3/4] Support APPLY_FRAGMENT(WEIGHT(double)) clause: add weights to fragments of parallel regions (and use it in at loopAnalyzer) --- .gitignore | 1 + src/LoopAnalyzer/loop_analyzer.cpp | 29 +++- src/ParallelizationRegions/ParRegions.cpp | 182 ++++++++++++++++++---- src/ParallelizationRegions/ParRegions.h | 47 ++++-- src/Utils/utils.cpp | 31 ++++ 5 files changed, 246 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 0000101..d9bf98a 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,7 @@ Sapfor/Sapc++/Sapc++/x64/ Sapfor/Sapc++/x64/ /build +/cmake-build-debug Sapfor/out/ Sapfor/_bin/* diff --git a/src/LoopAnalyzer/loop_analyzer.cpp b/src/LoopAnalyzer/loop_analyzer.cpp index 785f134..4568c85 100644 --- a/src/LoopAnalyzer/loop_analyzer.cpp +++ b/src/LoopAnalyzer/loop_analyzer.cpp @@ -1635,9 +1635,9 @@ void loopAnalyzer(SgFile *file, vector ®ions, mapfunctions(i)->symbol()->identifier(); #if _WIN32 if (file->functions(i)->variant() != MODULE_STMT) - sendMessage_2lvl(wstring(L" '") + wstring(fName.begin(), fName.end()) + L"'"); + sendMessage_2lvl(wstring(L"��������� ������� '") + wstring(fName.begin(), fName.end()) + L"'"); else - sendMessage_2lvl(wstring(L" '") + wstring(fName.begin(), fName.end()) + L"'"); + sendMessage_2lvl(wstring(L"��������� ������ '") + wstring(fName.begin(), fName.end()) + L"'"); #else if (file->functions(i)->variant() != MODULE_STMT) sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'"); @@ -1710,6 +1710,9 @@ void loopAnalyzer(SgFile *file, vector ®ions, map> notMappedDistributedArrays; set mappedDistrbutedArrays; + const ParallelRegionLines* prevParLines = NULL; + double prevLinesWeight = 1.0; + double currentWeight = 1.0; while (st != lastNode) { @@ -1733,13 +1736,31 @@ void loopAnalyzer(SgFile *file, vector ®ions, maplineNumber() < -1 ? st->localLineNumber() : st->lineNumber(); - ParallelRegion *currReg = getRegionByLine(regions, st->fileName(), currentLine); + auto regAndLines = getRegionAndLinesByLine(regions, st->fileName(), currentLine); + + auto *currReg = regAndLines.first; + auto *parLines = regAndLines.second; if (currReg == NULL) { st = st->lexNext(); continue; } + if (parLines != prevParLines) + { + prevParLines = parLines; + auto newParLinesWeight = parLines ? parLines->weight : 1.0; + + if (prevParLines) + currentWeight /= prevLinesWeight; + + if (parLines) + currentWeight *= newParLinesWeight; + + prevLinesWeight = newParLinesWeight; + prevParLines = parLines; + } + if (isSgExecutableStatement(st) == NULL) delcsStatViewed.insert(st); else if (!sharedMemoryParallelization && @@ -2168,7 +2189,7 @@ void loopAnalyzer(SgFile *file, vector ®ions, mapfunctions(i)->symbol()->identifier(); #ifdef _WIN32 - sendMessage_2lvl(wstring(L" ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); + sendMessage_2lvl(wstring(L"��������� ����� ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); #else sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); #endif diff --git a/src/ParallelizationRegions/ParRegions.cpp b/src/ParallelizationRegions/ParRegions.cpp index 85d1953..d185ea9 100644 --- a/src/ParallelizationRegions/ParRegions.cpp +++ b/src/ParallelizationRegions/ParRegions.cpp @@ -93,8 +93,10 @@ static inline SgStatement* getParentStat(SgStatement *st) return iterator; } -static void updateRegionInfo(SgStatement *st, map> &startEnd, map> &lines_, - set &funcCallFromReg, const map &mapFuncs) +static void updateRegionInfo(SgStatement *st, map> &startEnd, + map> &lines_, + map>> &funcCallFromReg, + const map &mapFuncs) { string containsPrefix = ""; SgStatement *st_ps = getParentStat(st); @@ -103,17 +105,26 @@ static void updateRegionInfo(SgStatement *st, mapsymbol()->identifier() + string("."); extendRegionInfo(st, startEnd, lines_); + + set calls_from_statement; + if (st->variant() == PROC_STAT) { string fullName = st->symbol()->identifier(); //check contains if (mapFuncs.find(containsPrefix + fullName) != mapFuncs.end()) fullName = containsPrefix + fullName; - funcCallFromReg.insert(fullName); + calls_from_statement.insert(fullName); } for (int z = 0; z < 3; ++z) - findFuncCalls(st->expr(z), funcCallFromReg, containsPrefix, mapFuncs); + findFuncCalls(st->expr(z), calls_from_statement, containsPrefix, mapFuncs); + + string filename = st->fileName(); + int line = st->lineNumber(); + + for (const auto &func_name : calls_from_statement) + funcCallFromReg[func_name][filename].insert(line); } static void fillArrayNamesInReg(set &usedArrayInRegion, SgExpression *exp) @@ -283,6 +294,71 @@ static void checkForEmpty(SgStatement *start, SgStatement *end, vector } } +static bool parseFortranDouble(const char* str, double &val) +{ + int base_sign = 1, exp_sign = 1; + + int integer_part = 0, power = 0; + double decimal_part = 0; + while (*str && *str != '.' && *str != 'd' && *str != 'D') + { + if (*str >= '0' && *str <= '9') + integer_part = integer_part * 10 + (*str - '0'); + else if (*str == '-') + base_sign = -1; + else if (*str == '+') + base_sign = 1; + + str++; + } + + if (*str == '.') + { + str++; + + int base = 10; + while (*str >= '0' && *str <= '9') + { + decimal_part += double(*str - '0') / base; + str++; + base *= 10; + } + } + + if (*str == 'd' || *str == 'D') + { + str++; + + while (*str == '+' || *str == '-' || *str >= '0' && *str <= '9') + { + if (*str >= '0' && *str <= '9') + power = power * 10 + (*str - '0'); + else if (*str == '-') + exp_sign = -1; + else if (*str == '+') + exp_sign = 1; + + str++; + } + } + + double result = integer_part + decimal_part; + + for(int i = 0; i < power; i++) + { + if (exp_sign > 0) + result *= 10; + else + result /= 10; + } + + if (base_sign < 0) + result = -result; + + val = result; + return true; +} + void fillRegionLines(SgFile *file, vector ®ions, vector& messagesForFile, vector *loops, vector *funcs) { map mapFuncs; @@ -318,8 +394,9 @@ void fillRegionLines(SgFile *file, vector ®ions, vector> startEnd; map> lines_; - set funcCallFromReg; + map>> funcCallFromReg; bool regionStarted = false; + double fragmentWeight = 1.0; vector toDel; for (int i = 0; i < funcNum; ++i) @@ -368,6 +445,37 @@ void fillRegionLines(SgFile *file, vector ®ions, vectorsecond->callRegions.insert(0); } } + + // parse SPF_APPLY_FRAGMENT clause + auto *apply_fragment = data->expr(1); + fragmentWeight = 1.0; + + while (apply_fragment) + { + auto *curr = apply_fragment->lhs(); + + if (curr) + { + __spf_print(1, "%s %d\n", curr->unparse(), curr->variant()); + + if (curr->variant() == SPF_WEIGHT_OP) + { + if (curr->lhs() && + isSgValueExp(curr->lhs()) && + isSgValueExp(curr->lhs())->doubleValue() && + parseFortranDouble(isSgValueExp(curr->lhs())->doubleValue(), fragmentWeight)) + { + __spf_print(1, "->> %lf\n", fragmentWeight); + } + else + { + __spf_print(1, "WEIGHT clause without double argument\n"); + } + } + } + + apply_fragment = apply_fragment->rhs(); + } } if (next && next->variant() == SPF_END_PARALLEL_REG_DIR) @@ -400,10 +508,12 @@ void fillRegionLines(SgFile *file, vector ®ions, vectorAddLines(lines_[itRegInfo->first], itRegInfo->first, &itRegInfo->second); + currReg->AddLines(lines_[itRegInfo->first], itRegInfo->first, &itRegInfo->second, fragmentWeight); - for (auto &func : funcCallFromReg) - currReg->AddFuncCalls(func); + for (auto &by_func : funcCallFromReg) + for (auto &by_file : by_func.second) + for(auto &by_line : by_file.second) + currReg->AddFuncCalls(by_func.first, by_file.first, by_line); filterUserDirectives(currReg, usedArrayInRegion, userDvmRedistrDirs, userDvmRealignDirs, userDvmShadowDirs); currReg->AddUserDirectives(userDvmRealignDirs, DVM_REALIGN_DIR); @@ -496,34 +606,48 @@ void fillRegionLinesStep2(vector ®ions, const mapGetName() != "DEFAULT") for (auto &func : regions[i]->GetFuncCalls()) - setExplicitFlag(func, funcMap); + setExplicitFlag(func.first, funcMap); } for (int i = 0; i < regions.size(); ++i) { if (regions[i]->GetName() != "DEFAULT") { - set uniqFuncCalls; - for (auto &elem : regions[i]->GetFuncCalls()) - uniqFuncCalls.insert(elem); + map uniqFuncCalls; + map>> callPlaces; + + for (auto &elem : regions[i]->GetFuncCalls()) + { + double max_weight = 0; + for (auto* fragment : elem.second) + if (fragment->weight > max_weight) + max_weight = fragment->weight; + + uniqFuncCalls[elem.first] = max_weight; + } + + bool wasChanged = true; + auto funcsBefore = uniqFuncCalls; - bool wasChanged = 1; while (wasChanged) { - wasChanged = 0; + wasChanged = false; + auto updated = uniqFuncCalls; + for (auto &uniqF : uniqFuncCalls) { - auto func = funcMap.find(uniqF); + auto func = funcMap.find(uniqF.first); if (func != funcMap.end()) { - for (auto &calls : func->second->callsFrom) + for (auto &call : func->second->callsFromDetailed) { - auto it = uniqFuncCalls.find(calls); - if (it == uniqFuncCalls.end()) - { - uniqFuncCalls.insert(it, calls); - wasChanged = 1; - } + auto it = updated.find(call.detailCallsFrom.first); + if (it == updated.end()) + updated.insert({call.detailCallsFrom.first, uniqF.second}); + else + it->second = std::max(it->second, uniqF.second); + + callPlaces[call.detailCallsFrom.first][func->second->fileName].insert(call.detailCallsFrom.second); } } } @@ -532,21 +656,27 @@ void fillRegionLinesStep2(vector ®ions, const mapAddLines(it->second->linesNum, it->second->fileName); - regions[i]->AddFuncCallsToAllCalls(it->second); + regions[i]->AddLines(it->second->linesNum, it->second->fileName, NULL, elem.second); if (it->second->inRegion == 0) it->second->inRegion = 2; it->second->callRegions.insert(i); - toPrint += elem + " "; + toPrint += elem.first + " "; } } + for (auto &elem : callPlaces) + { + for (const auto &byFile : elem.second) + for (auto byLine : byFile.second) + regions[i]->AddFuncCalls(elem.first, byFile.first, byLine); + } + if (toPrint != "") __spf_print(1, "[%s]: funcs: %s\n", regions[i]->GetName().c_str(), toPrint.c_str()); } diff --git a/src/ParallelizationRegions/ParRegions.h b/src/ParallelizationRegions/ParRegions.h index 97a4a50..30087b0 100644 --- a/src/ParallelizationRegions/ParRegions.h +++ b/src/ParallelizationRegions/ParRegions.h @@ -17,7 +17,7 @@ struct ParallelRegionLines { - ParallelRegionLines() + ParallelRegionLines(double weight = 1.0) : weight(weight) { lines = std::make_pair(-1, -1); stats = std::make_pair(NULL, NULL); @@ -25,14 +25,15 @@ struct ParallelRegionLines intervalAfter = std::make_pair(NULL, NULL); } - ParallelRegionLines(const std::pair &lines) : lines(lines) + ParallelRegionLines(const std::pair &lines, double weight = 1.0) : lines(lines), weight(weight) { stats = std::make_pair(NULL, NULL); intervalBefore = std::make_pair(NULL, NULL); intervalAfter = std::make_pair(NULL, NULL); } - ParallelRegionLines(const std::pair &lines, const std::pair stats) : lines(lines), stats(stats) + ParallelRegionLines(const std::pair &lines, const std::pair stats, double weight = 1.0) + : lines(lines), stats(stats), weight(weight) { intervalBefore = std::make_pair(NULL, NULL); intervalAfter = std::make_pair(NULL, NULL); @@ -60,6 +61,8 @@ struct ParallelRegionLines // interval std::pair intervalBefore; std::pair intervalAfter; + + double weight; // weight of the fragment among all fragments of this region }; #if __SPF @@ -114,7 +117,7 @@ public: currentVariant = copy.currentVariant; } - int AddLines(const std::pair &linesToAdd, const std::string &file, const std::pair *startEnd = NULL) + int AddLines(const std::pair &linesToAdd, const std::string &file, const std::pair *startEnd = NULL, double weight = 1.0) { if (linesToAdd.first > linesToAdd.second) return -1; @@ -124,17 +127,29 @@ public: it = lines.insert(it, make_pair(file, std::vector())); if (startEnd) - it->second.push_back(ParallelRegionLines(linesToAdd, *startEnd)); + it->second.push_back(ParallelRegionLines(linesToAdd, *startEnd, weight)); else - it->second.push_back(ParallelRegionLines(linesToAdd)); + it->second.push_back(ParallelRegionLines(linesToAdd, weight)); return 0; } - void AddFuncCalls(const std::string &func) { functionsCall.insert(func); } + void AddFuncCalls(const std::string &func, const std::string &file, const int line) + { + auto *found_lines = GetLinesByLine(file, line); + + if (found_lines) + functionsCall[func].insert(found_lines); + } #if __SPF - void AddFuncCallsToAllCalls(FuncInfo *func) { allFunctionsCall.insert(func); } + void AddFuncCallsToAllCalls(FuncInfo *func, const std::string &file, const int line) + { + auto *found_lines = GetLinesByLine(file, line); + + if (found_lines) + allFunctionsCall[func].insert(found_lines); + } #endif uint64_t GetId() const { return regionId; } @@ -174,10 +189,10 @@ public: const DataDirective& GetDataDir() const { return dataDirectives; } DataDirective& GetDataDirToModify() { return dataDirectives; } - const std::set& GetFuncCalls() const { return functionsCall; } + const std::map>& GetFuncCalls() const { return functionsCall; } #if __SPF - const std::set& GetAllFuncCalls() const { return allFunctionsCall; } + const std::map>& GetAllFuncCalls() const { return allFunctionsCall; } const std::map>>& GetUsedLocalArrays() const { return usedLocalArrays; } const std::map>>& GetUsedCommonArrays() const { return usedCommonArrays; } @@ -216,7 +231,7 @@ public: } #endif - bool HasThisLine(const int line, const std::string &file) const + bool HasThisLine(const int line, const std::string &file, const ParallelRegionLines** found = nullptr) const { bool retVal = false; auto it = lines.find(file); @@ -227,6 +242,9 @@ public: if (it->second[i].lines.first <= line && it->second[i].lines.second >= line) { retVal = true; + if (found) + *found = &(it->second[i]); + break; } } @@ -283,7 +301,7 @@ public: fprintf(fileOut, " originalName '%s'\n", originalName.c_str()); fprintf(fileOut, " functions call from %d:\n", (int)functionsCall.size()); for (auto &func : functionsCall) - fprintf(fileOut, " '%s'\n", func.c_str()); + fprintf(fileOut, " '%s'\n", func.first.c_str()); fprintf(fileOut, " total lines %d:\n", (int)lines.size()); for (auto &line : lines) { @@ -353,11 +371,11 @@ private: std::string originalName; // file -> lines info std::map> lines; - std::set functionsCall; + std::map> functionsCall; // func name -> fragments with calls #if __SPF // for RESOLVE_PAR_REGIONS - std::set allFunctionsCall; + std::map> allFunctionsCall; // function -> fragments with calls std::map>> usedLocalArrays; // func -> array -> lines std::map>> usedCommonArrays; // func -> array -> lines // @@ -399,4 +417,5 @@ private: ParallelRegion* getRegionById(const std::vector& regions, const uint64_t regionId); ParallelRegion* getRegionByName(const std::vector& regions, const std::string& regionName); ParallelRegion* getRegionByLine(const std::vector& regions, const std::string& file, const int line); +std::pair getRegionAndLinesByLine(const std::vector& regions, const std::string& file, const int line); std::set getAllRegionsByLine(const std::vector& regions, const std::string& file, const int line); \ No newline at end of file diff --git a/src/Utils/utils.cpp b/src/Utils/utils.cpp index a7d2faf..d301100 100644 --- a/src/Utils/utils.cpp +++ b/src/Utils/utils.cpp @@ -1405,6 +1405,37 @@ ParallelRegion* getRegionByLine(const vector& regions, const st return NULL; } +std::pair getRegionAndLinesByLine(const vector& regions, const string& file, const int line) +{ + if (regions.size() == 1 && regions[0]->GetName() == "DEFAULT") // only default + return {regions[0], NULL}; + + else if (regions.size() > 0) + { + map regFound; + + const ParallelRegionLines* foundLines = nullptr; + + for (int i = 0; i < regions.size(); ++i) + if (regions[i]->HasThisLine(line, file, &foundLines)) + regFound[regions[i]] = foundLines; + + if (regFound.size() == 0) + return {NULL, NULL}; + else if (regFound.size() == 1) + return *regFound.begin(); + else + { + __spf_print(1, "WARN: this lines included in more than one region!!\n"); + return {NULL, NULL}; + } + } + else + return {NULL, NULL}; + + return {NULL, NULL}; +} + set getAllRegionsByLine(const vector& regions, const string& file, const int line) { set regFound; -- 2.49.1 From ba632b29ce34b3d77546256a8452428d40d8317c Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 29 May 2025 09:07:20 +0300 Subject: [PATCH 4/4] cleanup and replaced parseFortranDouble to strtod --- projects/libpredictor | 2 +- src/LoopAnalyzer/loop_analyzer.cpp | 8 +-- src/ParallelizationRegions/ParRegions.cpp | 81 ++--------------------- src/Utils/utils.cpp | 14 ++-- src/Utils/version.h | 1 - 5 files changed, 17 insertions(+), 89 deletions(-) diff --git a/projects/libpredictor b/projects/libpredictor index 840f9d9..d0772cd 160000 --- a/projects/libpredictor +++ b/projects/libpredictor @@ -1 +1 @@ -Subproject commit 840f9d9c1ad579825d81c46cdf70877c497fecca +Subproject commit d0772cdb57432b8c96ce634687641b1c8c76d21c diff --git a/src/LoopAnalyzer/loop_analyzer.cpp b/src/LoopAnalyzer/loop_analyzer.cpp index 4568c85..a544fca 100644 --- a/src/LoopAnalyzer/loop_analyzer.cpp +++ b/src/LoopAnalyzer/loop_analyzer.cpp @@ -1635,9 +1635,9 @@ void loopAnalyzer(SgFile *file, vector ®ions, mapfunctions(i)->symbol()->identifier(); #if _WIN32 if (file->functions(i)->variant() != MODULE_STMT) - sendMessage_2lvl(wstring(L"��������� ������� '") + wstring(fName.begin(), fName.end()) + L"'"); + sendMessage_2lvl(wstring(L"обработка функции '") + wstring(fName.begin(), fName.end()) + L"'"); else - sendMessage_2lvl(wstring(L"��������� ������ '") + wstring(fName.begin(), fName.end()) + L"'"); + sendMessage_2lvl(wstring(L"обработка модуля '") + wstring(fName.begin(), fName.end()) + L"'"); #else if (file->functions(i)->variant() != MODULE_STMT) sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'"); @@ -1712,8 +1712,8 @@ void loopAnalyzer(SgFile *file, vector ®ions, map ®ions, mapfunctions(i)->symbol()->identifier(); #ifdef _WIN32 - sendMessage_2lvl(wstring(L"��������� ����� ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); + sendMessage_2lvl(wstring(L"обработка цикла ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); #else sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); #endif diff --git a/src/ParallelizationRegions/ParRegions.cpp b/src/ParallelizationRegions/ParRegions.cpp index d185ea9..f01be39 100644 --- a/src/ParallelizationRegions/ParRegions.cpp +++ b/src/ParallelizationRegions/ParRegions.cpp @@ -106,7 +106,7 @@ static void updateRegionInfo(SgStatement *st, map calls_from_statement; + set callsFromStatement; if (st->variant() == PROC_STAT) { @@ -114,16 +114,16 @@ static void updateRegionInfo(SgStatement *st, mapexpr(z), calls_from_statement, containsPrefix, mapFuncs); + findFuncCalls(st->expr(z), callsFromStatement, containsPrefix, mapFuncs); string filename = st->fileName(); int line = st->lineNumber(); - for (const auto &func_name : calls_from_statement) + for (const auto &func_name : callsFromStatement) funcCallFromReg[func_name][filename].insert(line); } @@ -294,71 +294,6 @@ static void checkForEmpty(SgStatement *start, SgStatement *end, vector } } -static bool parseFortranDouble(const char* str, double &val) -{ - int base_sign = 1, exp_sign = 1; - - int integer_part = 0, power = 0; - double decimal_part = 0; - while (*str && *str != '.' && *str != 'd' && *str != 'D') - { - if (*str >= '0' && *str <= '9') - integer_part = integer_part * 10 + (*str - '0'); - else if (*str == '-') - base_sign = -1; - else if (*str == '+') - base_sign = 1; - - str++; - } - - if (*str == '.') - { - str++; - - int base = 10; - while (*str >= '0' && *str <= '9') - { - decimal_part += double(*str - '0') / base; - str++; - base *= 10; - } - } - - if (*str == 'd' || *str == 'D') - { - str++; - - while (*str == '+' || *str == '-' || *str >= '0' && *str <= '9') - { - if (*str >= '0' && *str <= '9') - power = power * 10 + (*str - '0'); - else if (*str == '-') - exp_sign = -1; - else if (*str == '+') - exp_sign = 1; - - str++; - } - } - - double result = integer_part + decimal_part; - - for(int i = 0; i < power; i++) - { - if (exp_sign > 0) - result *= 10; - else - result /= 10; - } - - if (base_sign < 0) - result = -result; - - val = result; - return true; -} - void fillRegionLines(SgFile *file, vector ®ions, vector& messagesForFile, vector *loops, vector *funcs) { map mapFuncs; @@ -453,7 +388,6 @@ void fillRegionLines(SgFile *file, vector ®ions, vectorlhs(); - if (curr) { __spf_print(1, "%s %d\n", curr->unparse(), curr->variant()); @@ -462,18 +396,15 @@ void fillRegionLines(SgFile *file, vector ®ions, vectorlhs() && isSgValueExp(curr->lhs()) && - isSgValueExp(curr->lhs())->doubleValue() && - parseFortranDouble(isSgValueExp(curr->lhs())->doubleValue(), fragmentWeight)) + isSgValueExp(curr->lhs())->doubleValue()) { + fragmentWeight = strtod(isSgValueExp(curr->lhs())->doubleValue(), NULL); __spf_print(1, "->> %lf\n", fragmentWeight); } else - { __spf_print(1, "WEIGHT clause without double argument\n"); - } } } - apply_fragment = apply_fragment->rhs(); } } diff --git a/src/Utils/utils.cpp b/src/Utils/utils.cpp index 7d99610..2ee26d1 100644 --- a/src/Utils/utils.cpp +++ b/src/Utils/utils.cpp @@ -1418,32 +1418,30 @@ ParallelRegion* getRegionByLine(const vector& regions, const st std::pair getRegionAndLinesByLine(const vector& regions, const string& file, const int line) { if (regions.size() == 1 && regions[0]->GetName() == "DEFAULT") // only default - return {regions[0], NULL}; - + return { regions[0], NULL }; else if (regions.size() > 0) { map regFound; - - const ParallelRegionLines* foundLines = nullptr; + const ParallelRegionLines* foundLines = NULL; for (int i = 0; i < regions.size(); ++i) if (regions[i]->HasThisLine(line, file, &foundLines)) regFound[regions[i]] = foundLines; if (regFound.size() == 0) - return {NULL, NULL}; + return { NULL, NULL }; else if (regFound.size() == 1) return *regFound.begin(); else { __spf_print(1, "WARN: this lines included in more than one region!!\n"); - return {NULL, NULL}; + return { NULL, NULL }; } } else - return {NULL, NULL}; + return { NULL, NULL }; - return {NULL, NULL}; + return { NULL, NULL }; } set getAllRegionsByLine(const vector& regions, const string& file, const int line) diff --git a/src/Utils/version.h b/src/Utils/version.h index fb91e23..43758a9 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,4 +1,3 @@ #pragma once #define VERSION_SPF "2422" - -- 2.49.1