weighted_par_regions #57

Merged
Alexander_KS merged 5 commits from weighted_par_regions into master 2025-05-29 06:08:48 +00:00
5 changed files with 17 additions and 89 deletions
Showing only changes of commit ba632b29ce - Show all commits

View File

@@ -1635,9 +1635,9 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> &regions, map<tuple<int,
string fName = file->functions(i)->symbol()->identifier(); string fName = file->functions(i)->symbol()->identifier();
#if _WIN32 #if _WIN32
if (file->functions(i)->variant() != MODULE_STMT) if (file->functions(i)->variant() != MODULE_STMT)
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '") + wstring(fName.begin(), fName.end()) + L"'"); sendMessage_2lvl(wstring(L"обработка функции '") + wstring(fName.begin(), fName.end()) + L"'");
else else
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '") + wstring(fName.begin(), fName.end()) + L"'"); sendMessage_2lvl(wstring(L"обработка модуля '") + wstring(fName.begin(), fName.end()) + L"'");
#else #else
if (file->functions(i)->variant() != MODULE_STMT) if (file->functions(i)->variant() != MODULE_STMT)
sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'"); sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'");
@@ -1712,8 +1712,8 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> &regions, map<tuple<int,
const ParallelRegionLines* prevParLines = NULL; const ParallelRegionLines* prevParLines = NULL;
double prevLinesWeight = 1.0; double prevLinesWeight = 1.0;
double currentWeight = 1.0; double currentWeight = 1.0;
while (st != lastNode) while (st != lastNode)
{ {
createNeededException(); createNeededException();
@@ -2189,7 +2189,7 @@ void loopAnalyzer(SgFile *file, vector<ParallelRegion*> &regions, map<tuple<int,
{ {
string fName = file->functions(i)->symbol()->identifier(); string fName = file->functions(i)->symbol()->identifier();
#ifdef _WIN32 #ifdef _WIN32
sendMessage_2lvl(wstring(L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ") + 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 #else
sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size()));
#endif #endif

View File

@@ -106,7 +106,7 @@ static void updateRegionInfo(SgStatement *st, map<string, pair<Statement*, State
extendRegionInfo(st, startEnd, lines_); extendRegionInfo(st, startEnd, lines_);
set<string> calls_from_statement; set<string> callsFromStatement;
if (st->variant() == PROC_STAT) if (st->variant() == PROC_STAT)
{ {
@@ -114,16 +114,16 @@ static void updateRegionInfo(SgStatement *st, map<string, pair<Statement*, State
//check contains //check contains
if (mapFuncs.find(containsPrefix + fullName) != mapFuncs.end()) if (mapFuncs.find(containsPrefix + fullName) != mapFuncs.end())
fullName = containsPrefix + fullName; fullName = containsPrefix + fullName;
calls_from_statement.insert(fullName); callsFromStatement.insert(fullName);
} }
for (int z = 0; z < 3; ++z) for (int z = 0; z < 3; ++z)
findFuncCalls(st->expr(z), calls_from_statement, containsPrefix, mapFuncs); findFuncCalls(st->expr(z), callsFromStatement, containsPrefix, mapFuncs);
string filename = st->fileName(); string filename = st->fileName();
int line = st->lineNumber(); int line = st->lineNumber();
for (const auto &func_name : calls_from_statement) for (const auto &func_name : callsFromStatement)
funcCallFromReg[func_name][filename].insert(line); funcCallFromReg[func_name][filename].insert(line);
} }
@@ -294,71 +294,6 @@ static void checkForEmpty(SgStatement *start, SgStatement *end, vector<Messages>
} }
} }
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<ParallelRegion*> &regions, vector<Messages>& messagesForFile, vector<LoopGraph*> *loops, vector<FuncInfo*> *funcs) void fillRegionLines(SgFile *file, vector<ParallelRegion*> &regions, vector<Messages>& messagesForFile, vector<LoopGraph*> *loops, vector<FuncInfo*> *funcs)
{ {
map<string, FuncInfo*> mapFuncs; map<string, FuncInfo*> mapFuncs;
@@ -453,7 +388,6 @@ void fillRegionLines(SgFile *file, vector<ParallelRegion*> &regions, vector<Mess
while (apply_fragment) while (apply_fragment)
{ {
auto *curr = apply_fragment->lhs(); auto *curr = apply_fragment->lhs();
if (curr) if (curr)
{ {
__spf_print(1, "%s %d\n", curr->unparse(), curr->variant()); __spf_print(1, "%s %d\n", curr->unparse(), curr->variant());
@@ -462,18 +396,15 @@ void fillRegionLines(SgFile *file, vector<ParallelRegion*> &regions, vector<Mess
{ {
if (curr->lhs() && if (curr->lhs() &&
isSgValueExp(curr->lhs()) && isSgValueExp(curr->lhs()) &&
isSgValueExp(curr->lhs())->doubleValue() && isSgValueExp(curr->lhs())->doubleValue())
parseFortranDouble(isSgValueExp(curr->lhs())->doubleValue(), fragmentWeight))
{ {
fragmentWeight = strtod(isSgValueExp(curr->lhs())->doubleValue(), NULL);
__spf_print(1, "->> %lf\n", fragmentWeight); __spf_print(1, "->> %lf\n", fragmentWeight);
} }
else else
{
__spf_print(1, "WEIGHT clause without double argument\n"); __spf_print(1, "WEIGHT clause without double argument\n");
} }
} }
}
apply_fragment = apply_fragment->rhs(); apply_fragment = apply_fragment->rhs();
} }
} }

View File

@@ -1419,12 +1419,10 @@ std::pair<ParallelRegion*, const ParallelRegionLines*> getRegionAndLinesByLine(c
{ {
if (regions.size() == 1 && regions[0]->GetName() == "DEFAULT") // only default if (regions.size() == 1 && regions[0]->GetName() == "DEFAULT") // only default
return { regions[0], NULL }; return { regions[0], NULL };
else if (regions.size() > 0) else if (regions.size() > 0)
{ {
map<ParallelRegion*, const ParallelRegionLines*> regFound; map<ParallelRegion*, const ParallelRegionLines*> regFound;
const ParallelRegionLines* foundLines = NULL;
const ParallelRegionLines* foundLines = nullptr;
for (int i = 0; i < regions.size(); ++i) for (int i = 0; i < regions.size(); ++i)
if (regions[i]->HasThisLine(line, file, &foundLines)) if (regions[i]->HasThisLine(line, file, &foundLines))

View File

@@ -1,4 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2422" #define VERSION_SPF "2422"