Improvements of shared memory parallelization #34
@@ -65,26 +65,13 @@ static void findUsedArraysInParallelLoops(LoopGraph* loop, set<DIST::Array*>& re
|
||||
}
|
||||
|
||||
static void preventLoopsFromParallelizations(LoopGraph* loop, const set<DIST::Array*>& prevent,
|
||||
vector<Directive*>& createdDirectives,vector<Messages>& messagesForFile)
|
||||
vector<Messages>& 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 set<DIST::Ar
|
||||
}
|
||||
|
||||
for (LoopGraph* child : loop->children)
|
||||
preventLoopsFromParallelizations(child, prevent, createdDirectives, messagesForFile);
|
||||
preventLoopsFromParallelizations(child, prevent, messagesForFile);
|
||||
}
|
||||
|
||||
struct DimConf
|
||||
@@ -169,9 +156,9 @@ pickBest(const map<DimConf, map<FuncInfo*, set<DIST::Array*>>>& arrs)
|
||||
}
|
||||
|
||||
void SelectArrayConfForParallelization(SgProject* proj, map<string, vector<FuncInfo*>>& funcByFile,
|
||||
const map<string, vector<LoopGraph*>>& loopGraph, map<std::string, vector<Directive*>>& createdDirectives,
|
||||
map<string, vector<Messages>>& allMessages, const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls,
|
||||
const vector<ParallelRegion*>& regions)
|
||||
const map<string, vector<LoopGraph*>>& loopGraph,
|
||||
map<string, vector<Messages>>& allMessages,
|
||||
const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls)
|
||||
{
|
||||
map<string, FuncInfo*> funcByName;
|
||||
for (const auto& byFile : funcByFile)
|
||||
@@ -265,9 +252,6 @@ void SelectArrayConfForParallelization(SgProject* proj, map<string, vector<FuncI
|
||||
for (const auto& byFile : loopGraph)
|
||||
{
|
||||
vector<Messages>& 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;
|
||||
@@ -296,7 +280,7 @@ void SelectArrayConfForParallelization(SgProject* proj, map<string, vector<FuncI
|
||||
{
|
||||
auto prevent_it = preventFromParallelization.find(byFunc);
|
||||
if (prevent_it != preventFromParallelization.end())
|
||||
preventLoopsFromParallelizations(loop, prevent_it->second, dirs_it->second, fileM);
|
||||
preventLoopsFromParallelizations(loop, prevent_it->second, fileM);
|
||||
|
||||
loop_analyzed = true;
|
||||
break;
|
||||
@@ -308,78 +292,3 @@ void SelectArrayConfForParallelization(SgProject* proj, map<string, vector<FuncI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeRegionsWithoutDirs(const map<string, vector<Directive*>>& createdDirectives,
|
||||
vector<ParallelRegion*>& parallelRegions,
|
||||
const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
map<string, vector<Messages>>& SPF_messages)
|
||||
{
|
||||
set<ParallelRegion*> 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<int> 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<Messages>& 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<Messages>& 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<ParallelRegion*> 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__);
|
||||
}
|
||||
@@ -12,11 +12,5 @@
|
||||
|
||||
void SelectArrayConfForParallelization(SgProject* proj, std::map<std::string, std::vector<FuncInfo*>>& funcByFile,
|
||||
const std::map<std::string, std::vector<LoopGraph*>>& loopGraph,
|
||||
std::map<std::string, std::vector<Directive*>>& createdDirectives,
|
||||
std::map<std::string, std::vector<Messages>>& allMessages,
|
||||
const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, const std::vector<ParallelRegion*>& regions);
|
||||
|
||||
void removeRegionsWithoutDirs(const std::map<std::string, std::vector<Directive*>>& createdDirectives,
|
||||
std::vector<ParallelRegion*>& parallelRegions,
|
||||
const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo,
|
||||
std::map<std::string, std::vector<Messages>>& SPF_messages);
|
||||
const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||
@@ -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();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <cstdio>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -2155,8 +2154,6 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
||||
|
||||
runPass(CONVERT_LOOP_TO_ASSIGN, proj_name, folderName);
|
||||
|
||||
runPass(SELECT_ARRAY_DIM_CONF, proj_name, folderName);
|
||||
|
||||
runPass(REVERT_SUBST_EXPR_RD, proj_name, folderName);
|
||||
|
||||
runAnalysis(*project, INSERT_PARALLEL_DIRS, false, consoleMode ? additionalName.c_str() : NULL, folderName);
|
||||
|
||||
@@ -233,7 +233,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
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<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
struct DataDirective;
|
||||
namespace Distribution
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2296"
|
||||
#define VERSION_SPF "2298"
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user