refactoring
This commit is contained in:
@@ -242,7 +242,6 @@ set(DIRA _src/DirectiveProcessing/DirectiveAnalyzer.cpp
|
||||
_src/DirectiveProcessing/directive_creator.h
|
||||
_src/DirectiveProcessing/directive_creator_base_nodist.cpp
|
||||
_src/DirectiveProcessing/directive_creator_nodist.h
|
||||
_src/DirectiveProcessing/directive_creator_internal.h
|
||||
_src/DirectiveProcessing/directive_parser.cpp
|
||||
_src/DirectiveProcessing/directive_parser.h
|
||||
_src/DirectiveProcessing/insert_directive.cpp
|
||||
|
||||
@@ -45,6 +45,8 @@ using std::get;
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
|
||||
extern int mpiProgram;
|
||||
|
||||
static vector<pair<string, vector<Expression*>>>
|
||||
groupRealignsDirs(const vector<pair<string, vector<Expression*>>>& toRealign)
|
||||
{
|
||||
@@ -423,6 +425,66 @@ bool analyzeLoopBody(LoopGraph* loopV,
|
||||
return true;
|
||||
}
|
||||
|
||||
void createParallelDirs(File *file,
|
||||
map<string, vector<Directive*>>& createdDirectives,
|
||||
vector<Messages>& messages,
|
||||
const vector<LoopGraph*>& loopsInFile,
|
||||
const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
const vector<ParallelRegion*>& parallelRegions,
|
||||
const map<LoopGraph*, void*>& depInfoForLoopGraph,
|
||||
const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls)
|
||||
{
|
||||
const string file_name = file->filename();
|
||||
map<int, LoopGraph*> mapLoopsInFile;
|
||||
createMapLoopGraph(loopsInFile, mapLoopsInFile);
|
||||
|
||||
map<string, FuncInfo*> mapFuncInfo;
|
||||
createMapOfFunc(allFuncInfo, mapFuncInfo);
|
||||
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
vector<Directive*> toInsert;
|
||||
|
||||
const DataDirective& dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
const vector<int>& currentVariant = parallelRegions[z]->GetCurrentVariant();
|
||||
DIST::GraphCSR<int, double, attrType>& reducedG = parallelRegions[z]->GetReducedGraphToModify();
|
||||
DIST::Arrays<int>& allArrays = parallelRegions[z]->GetAllArraysToModify();
|
||||
|
||||
auto& tmp = dataDirectives.distrRules;
|
||||
vector<pair<DIST::Array*, const DistrVariant*>> currentVar;
|
||||
|
||||
if (mpiProgram == 0)
|
||||
{
|
||||
for (int z1 = 0; z1 < currentVariant.size(); ++z1)
|
||||
currentVar.push_back(make_pair(tmp[z1].first, &tmp[z1].second[currentVariant[z1]]));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& loop : mapLoopsInFile)
|
||||
{
|
||||
auto& rules = loop.second->getDataDir().distrRules;
|
||||
for (auto& rule : rules)
|
||||
currentVar.push_back(make_pair(rule.first, &rule.second[0]));
|
||||
}
|
||||
}
|
||||
|
||||
selectParallelDirectiveForVariant(file, parallelRegions[z], reducedG, allArrays, loopsInFile,
|
||||
mapLoopsInFile, mapFuncInfo, currentVar,
|
||||
toInsert, parallelRegions[z]->GetId(), arrayLinksByFuncCalls,
|
||||
depInfoForLoopGraph, messages);
|
||||
|
||||
if (toInsert.size() > 0)
|
||||
{
|
||||
auto it = createdDirectives.find(file_name);
|
||||
if (it == createdDirectives.end())
|
||||
createdDirectives.insert(it, make_pair(file_name, toInsert));
|
||||
else
|
||||
for (int m = 0; m < toInsert.size(); ++m)
|
||||
it->second.push_back(toInsert[m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef PRINT_DIR_RESULT
|
||||
#undef FIRST
|
||||
#undef SECOND
|
||||
|
||||
@@ -44,3 +44,20 @@ DIST::Array* getRealArrayRef(DIST::Array* in, const uint64_t regId, const std::m
|
||||
void shiftAlignRulesForTemplates(const std::set<DIST::Array*>& arrays, const uint64_t regId, DataDirective& dataDirectives, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||
|
||||
void createShadowSpec(const std::map<std::string, std::vector<LoopGraph*>>& loopGraph, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, const std::set<DIST::Array*>& forArrays);
|
||||
|
||||
void addShadowFromAnalysis(ParallelDirective* dir, const std::map<DIST::Array*, ArrayInfo*>& currAccesses);
|
||||
|
||||
bool checkForConflict(const std::map<DIST::Array*, ArrayInfo*>& currAccesses,
|
||||
const LoopGraph* currentLoop,
|
||||
std::map<DIST::Array*, std::pair<int, std::pair<int, int>>, DIST::ArrayComparator>& arrayWriteAcc,
|
||||
const std::vector<std::pair<std::pair<std::string, std::string>, std::vector<std::pair<int, int>>>>& acrossInfo,
|
||||
std::set<DIST::Array*>& acrossOutArrays);
|
||||
|
||||
void createParallelDirs(File* file,
|
||||
std::map<std::string, std::vector<Directive*>>& createdDirectives,
|
||||
std::vector<Messages>& messages,
|
||||
const std::vector<LoopGraph*>& loopsInFile,
|
||||
const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo,
|
||||
const std::vector<ParallelRegion*>& parallelRegions,
|
||||
const std::map<LoopGraph*, void*>& depInfoForLoopGraph,
|
||||
const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "../Utils/errors.h"
|
||||
#include "directive_parser.h"
|
||||
#include "directive_creator.h"
|
||||
#include "directive_creator_internal.h"
|
||||
|
||||
#define PRINT_PROF_INFO 1
|
||||
#define PRINT_DIR_RESULT 0
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "../Utils/errors.h"
|
||||
#include "directive_parser.h"
|
||||
#include "directive_creator.h"
|
||||
#include "directive_creator_internal.h"
|
||||
#include "directive_creator_nodist.h"
|
||||
|
||||
#define PRINT_PROF_INFO 1
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "../Distribution/Distribution.h"
|
||||
#include "../Utils/errors.h"
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "../Utils/types.h"
|
||||
|
||||
#define FIRST(x) get<0>(x)
|
||||
#define SECOND(x) get<1>(x)
|
||||
#define THIRD(x) get<2>(x)
|
||||
|
||||
void addShadowFromAnalysis(ParallelDirective* dir, const std::map<DIST::Array*, ArrayInfo*>& currAccesses);
|
||||
|
||||
bool checkForConflict(const std::map<DIST::Array*, ArrayInfo*>& currAccesses,
|
||||
const LoopGraph* currentLoop,
|
||||
std::map<DIST::Array*, std::pair<int, std::pair<int, int>>, DIST::ArrayComparator>& arrayWriteAcc,
|
||||
const std::vector<std::pair<std::pair<std::string, std::string>, std::vector<std::pair<int, int>>>>& acrossInfo,
|
||||
std::set<DIST::Array*>& acrossOutArrays);
|
||||
@@ -39,6 +39,8 @@ using std::make_tuple;
|
||||
|
||||
static const string dvmhModuleName = "dvmh_template_mod";
|
||||
|
||||
extern int mpiProgram;
|
||||
|
||||
//the size of vector indiceates type of DVM_DIR
|
||||
SgStatement* createStatFromExprs(const vector<Expression*> &exprs)
|
||||
{
|
||||
@@ -2365,3 +2367,64 @@ void insertDistributeDirsToParallelRegions(const vector<ParallelRegionLines> *cu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void insertParallelDirs(SgFile *file, bool extract,
|
||||
vector<Directive*>& createdDirectives,
|
||||
vector<Messages>& messages,
|
||||
map<string, string>& templateDeclInIncludes,
|
||||
map<string, map<int, set<string>>>& commentsToInclude,
|
||||
const vector<FuncInfo*>& callGraph,
|
||||
const vector<ParallelRegion*>& parallelRegions,
|
||||
const map<string, vector<LoopGraph*>>& loopGraph,
|
||||
const set<string>& allFileNames,
|
||||
const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls,
|
||||
const map<tuple<int, string, string>, pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays,
|
||||
const map<DIST::Array*, tuple<int, string, string>>& tableOfUniqNamesByArray)
|
||||
{
|
||||
const char* file_name = file->filename();
|
||||
insertDirectiveToFile(file, file_name, createdDirectives, extract, messages);
|
||||
|
||||
if (mpiProgram == 0)
|
||||
{
|
||||
map<string, FuncInfo*> mapFuncInfo;
|
||||
createMapOfFunc(callGraph, mapFuncInfo);
|
||||
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
ParallelRegion* currReg = parallelRegions[z];
|
||||
|
||||
const DataDirective& dataDirectives = currReg->GetDataDir();
|
||||
const vector<int>& currentVariant = currReg->GetCurrentVariant();
|
||||
const DIST::Arrays<int>& allArrays = currReg->GetAllArrays();
|
||||
DIST::GraphCSR<int, double, attrType>& reducedG = currReg->GetReducedGraphToModify();
|
||||
|
||||
const set<string> distrArrays = fillDistributedArrays(dataDirectives, tableOfUniqNamesByArray, arrayLinksByFuncCalls);
|
||||
const vector<string> distrRules = dataDirectives.GenRule(currentVariant);
|
||||
const vector<vector<dist>> distrRulesSt = dataDirectives.GenRule(currentVariant, 0);
|
||||
const vector<string> alignRules = dataDirectives.GenAlignsRules();
|
||||
|
||||
|
||||
insertDistributionToFile(file, file_name, dataDirectives, distrArrays, distrRules, distrRulesSt, alignRules, loopGraph,
|
||||
allArrays, reducedG, commentsToInclude, templateDeclInIncludes, extract, messages,
|
||||
arrayLinksByFuncCalls, mapFuncInfo, currReg->GetId(), allFileNames);
|
||||
|
||||
insertLoopTempalteDeclaration(file, dataDirectives, distrRules, distrRulesSt, allArrays, extract, currReg->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
if (extract)
|
||||
{
|
||||
createdDirectives.clear();
|
||||
|
||||
//clear shadow specs
|
||||
for (auto& array : declaredArrays)
|
||||
array.second.first->ClearShadowSpecs();
|
||||
}
|
||||
else if (mpiProgram == 0)
|
||||
{
|
||||
set<uint64_t> regNum;
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
regNum.insert(parallelRegions[z]->GetId());
|
||||
insertTemplateModuleUse(file, regNum, arrayLinksByFuncCalls);
|
||||
}
|
||||
}
|
||||
@@ -48,3 +48,16 @@ void insertDistributeDirsToParallelRegions(const std::vector<ParallelRegionLines
|
||||
void insertTemplateModuleUse(SgFile* file, const std::set<uint64_t>& regNum, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls);
|
||||
void removeStatementsFromAllproject(const std::set<int>& variants);
|
||||
void correctTemplateModuleDeclaration(const std::string& folderName);
|
||||
|
||||
void insertParallelDirs(SgFile* file, bool extract,
|
||||
std::vector<Directive*>& createdDirectives,
|
||||
std::vector<Messages>& messages,
|
||||
std::map<std::string, std::string>& templateDeclInIncludes,
|
||||
std::map<std::string, std::map<int, std::set<std::string>>>& commentsToInclude,
|
||||
const std::vector<FuncInfo*>& callGraph,
|
||||
const std::vector<ParallelRegion*>& parallelRegions,
|
||||
const std::map<std::string, std::vector<LoopGraph*>>& loopGraph,
|
||||
const std::set<std::string>& allFileNames,
|
||||
const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls,
|
||||
const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays,
|
||||
const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray);
|
||||
@@ -378,68 +378,6 @@ string unparseProjectToString(SgFile *file, const int curr_regime)
|
||||
return unparseProjectIfNeed(file, curr_regime, true, "", NULL, allIncludeFiles, true);
|
||||
}
|
||||
|
||||
static bool isNotNullIntersection(const set<DIST::Array*> &first, const set<DIST::Array*> &second)
|
||||
{
|
||||
for (auto &elem1 : first)
|
||||
if (second.find(elem1) != second.end())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirectives, bool onlyCommon = false)
|
||||
{
|
||||
set<DIST::Array*> distrArrays;
|
||||
set<DIST::Array*> distrArraysD;
|
||||
set<DIST::Array*> distrArraysAdded;
|
||||
|
||||
for (int z = 0; z < dataDirectives.distrRules.size(); ++z)
|
||||
distrArraysD.insert(dataDirectives.distrRules[z].first);
|
||||
for (int z = 0; z < dataDirectives.alignRules.size(); ++z)
|
||||
distrArraysD.insert(dataDirectives.alignRules[z].alignArray);
|
||||
|
||||
for (auto& elem : tableOfUniqNamesByArray)
|
||||
{
|
||||
set<DIST::Array*> realRefs;
|
||||
getRealArrayRefs(elem.first, elem.first, realRefs, arrayLinksByFuncCalls);
|
||||
if (isNotNullIntersection(realRefs, distrArraysD))
|
||||
distrArraysAdded.insert(elem.first);
|
||||
}
|
||||
|
||||
for (auto& elem : distrArraysD)
|
||||
{
|
||||
if (onlyCommon)
|
||||
{
|
||||
if (elem->GetLocation().first == DIST::l_COMMON)
|
||||
distrArrays.insert(elem);
|
||||
}
|
||||
else
|
||||
distrArrays.insert(elem);
|
||||
}
|
||||
|
||||
for (auto& elem : distrArraysAdded)
|
||||
{
|
||||
if (onlyCommon)
|
||||
{
|
||||
if (elem->GetLocation().first == DIST::l_COMMON)
|
||||
distrArrays.insert(elem);
|
||||
}
|
||||
else
|
||||
distrArrays.insert(elem);
|
||||
}
|
||||
return distrArrays;
|
||||
}
|
||||
|
||||
static set<string> fillDistributedArrays(const DataDirective &dataDirectives, bool onlyCommon = false, bool shortName = false)
|
||||
{
|
||||
set<string> distrArrays;
|
||||
set<DIST::Array*> ret = fillDistributedArraysD(dataDirectives, onlyCommon);
|
||||
|
||||
for (auto& elem : ret)
|
||||
distrArrays.insert(shortName ? elem->GetShortName() : elem->GetName());
|
||||
return distrArrays;
|
||||
}
|
||||
|
||||
static bool runAnalysis(SgProject &project, const int curr_regime, const bool need_to_unparse, const char *newVer = NULL, const char *folderName = NULL)
|
||||
{
|
||||
if (PASSES_DONE_INIT == false)
|
||||
@@ -497,6 +435,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
}
|
||||
|
||||
auto rw_analyzer = ReadWriteAnalyzer(allFuncInfo); // doesn't analyze anything until first query
|
||||
int global_err = 0;
|
||||
|
||||
for (int i = n - 1; i >= 0; --i)
|
||||
{
|
||||
@@ -526,7 +465,8 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
vector<Messages> tmp;
|
||||
loopAnalyzer(file, parallelRegions, createdArrays, tmp, DATA_DISTR,
|
||||
allFuncInfo, declaredArrays, declaratedArraysSt, arrayLinksByFuncCalls, createDefUseMapByPlace(), true, &(loopGraph.find(file_name)->second));
|
||||
allFuncInfo, declaredArrays, declaratedArraysSt, arrayLinksByFuncCalls, createDefUseMapByPlace(),
|
||||
true, &(loopGraph.find(file_name)->second));
|
||||
}
|
||||
else if (curr_regime == LOOP_ANALYZER_DATA_DIST_S1 || curr_regime == ONLY_ARRAY_GRAPH)
|
||||
{
|
||||
@@ -601,108 +541,19 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
auto &loopsInFile = getObjectForFileFromMap(file_name, loopGraph);
|
||||
|
||||
map<int, LoopGraph*> mapLoopsInFile;
|
||||
createMapLoopGraph(loopsInFile, mapLoopsInFile);
|
||||
|
||||
map<string, FuncInfo*> mapFuncInfo;
|
||||
createMapOfFunc(allFuncInfo, mapFuncInfo);
|
||||
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
vector<Directive*> toInsert;
|
||||
|
||||
const DataDirective &dataDirectives = parallelRegions[z]->GetDataDir();
|
||||
const vector<int> ¤tVariant = parallelRegions[z]->GetCurrentVariant();
|
||||
DIST::GraphCSR<int, double, attrType> &reducedG = parallelRegions[z]->GetReducedGraphToModify();
|
||||
DIST::Arrays<int> &allArrays = parallelRegions[z]->GetAllArraysToModify();
|
||||
|
||||
auto& tmp = dataDirectives.distrRules;
|
||||
vector<pair<DIST::Array*, const DistrVariant*>> currentVar;
|
||||
|
||||
if (mpiProgram == 0)
|
||||
{
|
||||
for (int z1 = 0; z1 < currentVariant.size(); ++z1)
|
||||
currentVar.push_back(make_pair(tmp[z1].first, &tmp[z1].second[currentVariant[z1]]));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& loop : mapLoopsInFile)
|
||||
{
|
||||
auto& rules = loop.second->getDataDir().distrRules;
|
||||
for (auto& rule : rules)
|
||||
currentVar.push_back(make_pair(rule.first, &rule.second[0]));
|
||||
}
|
||||
}
|
||||
|
||||
map<LoopGraph*, void*> depInfoForLoopGraphV;
|
||||
for (auto& elem : depInfoForLoopGraph)
|
||||
depInfoForLoopGraphV[elem.first] = elem.second;
|
||||
|
||||
selectParallelDirectiveForVariant(new File(file), parallelRegions[z], reducedG, allArrays, loopsInFile, mapLoopsInFile, mapFuncInfo, currentVar,
|
||||
toInsert, parallelRegions[z]->GetId(), arrayLinksByFuncCalls,
|
||||
depInfoForLoopGraphV, getObjectForFileFromMap(file_name, SPF_messages));
|
||||
|
||||
if (toInsert.size() > 0)
|
||||
{
|
||||
auto it = createdDirectives.find(file_name);
|
||||
if (it == createdDirectives.end())
|
||||
createdDirectives.insert(it, make_pair(file_name, toInsert));
|
||||
else
|
||||
for (int m = 0; m < toInsert.size(); ++m)
|
||||
it->second.push_back(toInsert[m]);
|
||||
}
|
||||
}
|
||||
createParallelDirs(new File(file), createdDirectives, getObjectForFileFromMap(file_name, SPF_messages),
|
||||
loopsInFile, allFuncInfo, parallelRegions, depInfoForLoopGraphV, arrayLinksByFuncCalls);
|
||||
}
|
||||
else if (curr_regime == INSERT_PARALLEL_DIRS || curr_regime == EXTRACT_PARALLEL_DIRS)
|
||||
{
|
||||
const bool extract = (curr_regime == EXTRACT_PARALLEL_DIRS);
|
||||
|
||||
insertDirectiveToFile(file, file_name, createdDirectives[file_name], extract, getObjectForFileFromMap(file_name, SPF_messages));
|
||||
|
||||
if (mpiProgram == 0)
|
||||
{
|
||||
auto callGraph = getObjectForFileFromMap(file_name, allFuncInfo);
|
||||
map<string, FuncInfo*> mapFuncInfo;
|
||||
createMapOfFunc(callGraph, mapFuncInfo);
|
||||
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
ParallelRegion* currReg = parallelRegions[z];
|
||||
|
||||
const DataDirective& dataDirectives = currReg->GetDataDir();
|
||||
const vector<int>& currentVariant = currReg->GetCurrentVariant();
|
||||
const DIST::Arrays<int>& allArrays = currReg->GetAllArrays();
|
||||
DIST::GraphCSR<int, double, attrType>& reducedG = currReg->GetReducedGraphToModify();
|
||||
|
||||
const set<string> distrArrays = fillDistributedArrays(dataDirectives);
|
||||
const vector<string> distrRules = dataDirectives.GenRule(currentVariant);
|
||||
const vector<vector<dist>> distrRulesSt = dataDirectives.GenRule(currentVariant, 0);
|
||||
const vector<string> alignRules = dataDirectives.GenAlignsRules();
|
||||
|
||||
|
||||
insertDistributionToFile(file, file_name, dataDirectives, distrArrays, distrRules, distrRulesSt, alignRules, loopGraph,
|
||||
allArrays, reducedG, commentsToInclude, templateDeclInIncludes, extract, getObjectForFileFromMap(file_name, SPF_messages),
|
||||
arrayLinksByFuncCalls, mapFuncInfo, currReg->GetId(), allFileNames);
|
||||
|
||||
insertLoopTempalteDeclaration(file, dataDirectives, distrRules, distrRulesSt, allArrays, extract, currReg->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
if (extract)
|
||||
{
|
||||
createdDirectives[file_name].clear();
|
||||
|
||||
//clear shadow specs
|
||||
for (auto& array : declaredArrays)
|
||||
array.second.first->ClearShadowSpecs();
|
||||
}
|
||||
else if (mpiProgram == 0)
|
||||
{
|
||||
set<uint64_t> regNum;
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
regNum.insert(parallelRegions[z]->GetId());
|
||||
insertTemplateModuleUse(file, regNum, arrayLinksByFuncCalls);
|
||||
}
|
||||
insertParallelDirs(file, extract, createdDirectives[file_name], getObjectForFileFromMap(file_name, SPF_messages),
|
||||
templateDeclInIncludes, commentsToInclude, getObjectForFileFromMap(file_name, allFuncInfo),
|
||||
parallelRegions, loopGraph, allFileNames, arrayLinksByFuncCalls, declaredArrays, tableOfUniqNamesByArray);
|
||||
}
|
||||
else if (curr_regime == LOOP_ANALYZER_NODIST)
|
||||
{
|
||||
@@ -758,7 +609,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
DataDirective &dataDirectives = currReg->GetDataDirToModify();
|
||||
DIST::GraphCSR<int, double, attrType> &reducedG = parallelRegions[z]->GetReducedGraphToModify();
|
||||
|
||||
set<string> distrArraysF = fillDistributedArrays(dataDirectives);
|
||||
set<string> distrArraysF = fillDistributedArrays(dataDirectives, tableOfUniqNamesByArray, arrayLinksByFuncCalls);
|
||||
|
||||
set<string> distrArrays;
|
||||
for (auto& elem : distrArraysF)
|
||||
@@ -775,7 +626,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
ParallelRegion* currReg = parallelRegions[z];
|
||||
DataDirective& dataDirectives = currReg->GetDataDirToModify();
|
||||
const set<DIST::Array*> distrCommonArrays = fillDistributedArraysD(dataDirectives, true);
|
||||
const set<DIST::Array*> distrCommonArrays = fillDistributedArraysD(dataDirectives, tableOfUniqNamesByArray, arrayLinksByFuncCalls, true);
|
||||
insertRealignsBeforeFragments(currReg, file, distrCommonArrays, arrayLinksByFuncCalls);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,12 +386,26 @@ static SgSymbol* alterShrinkArrayDeclaration(SgStatement *declarationStatement,
|
||||
|
||||
static void extendArrayRefsInExpr(const vector<SgSymbol*>& indexes, SgExpression* expr,
|
||||
SgSymbol* arraySymbol, SgSymbol* newArraySymbol,
|
||||
const vector<SgExpression*>& lowBounds)
|
||||
const vector<SgExpression*>& lowBounds, int line)
|
||||
{
|
||||
if (expr)
|
||||
{
|
||||
extendArrayRefsInExpr(indexes, expr->lhs(), arraySymbol, newArraySymbol, lowBounds);
|
||||
extendArrayRefsInExpr(indexes, expr->rhs(), arraySymbol, newArraySymbol, lowBounds);
|
||||
if (expr->variant() == FUNC_CALL)
|
||||
{
|
||||
SgFunctionCallExp* call = isSgFunctionCallExp(expr);
|
||||
for (int arg = 0; arg < call->numberOfArgs(); ++arg)
|
||||
{
|
||||
auto argRef = call->arg(arg);
|
||||
if ((isArrayRef(argRef) || argRef->variant() == VAR_REF) && isEqSymbols(argRef->symbol(), arraySymbol))
|
||||
{
|
||||
__spf_print(1, "unsupported private array extension under call on line %d\n", line);
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extendArrayRefsInExpr(indexes, expr->lhs(), arraySymbol, newArraySymbol, lowBounds, line);
|
||||
extendArrayRefsInExpr(indexes, expr->rhs(), arraySymbol, newArraySymbol, lowBounds, line);
|
||||
|
||||
if (isArrayRef(expr) && isEqSymbols(arraySymbol, expr->symbol()))
|
||||
extendArrayRef(indexes, expr, newArraySymbol, lowBounds);
|
||||
@@ -426,7 +440,7 @@ static void extendArrayRefs(const vector<SgSymbol*> &indexes, SgStatement *st, S
|
||||
}
|
||||
|
||||
if (st->expr(i))
|
||||
extendArrayRefsInExpr(indexes, st->expr(i), arraySymbol, newArraySymbol, lowBounds);
|
||||
extendArrayRefsInExpr(indexes, st->expr(i), arraySymbol, newArraySymbol, lowBounds, st->lineNumber());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1575,3 +1575,71 @@ vector<string> splitAndArgvCreate(const string& options)
|
||||
}
|
||||
return optSplited1;
|
||||
}
|
||||
|
||||
static bool isNotNullIntersection(const set<DIST::Array*>& first, const set<DIST::Array*>& second)
|
||||
{
|
||||
for (auto& elem1 : first)
|
||||
if (second.find(elem1) != second.end())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirectives,
|
||||
const map<DIST::Array*, tuple<int, string, string>>& tableOfUniqNamesByArray,
|
||||
const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls,
|
||||
bool onlyCommon)
|
||||
{
|
||||
set<DIST::Array*> distrArrays;
|
||||
set<DIST::Array*> distrArraysD;
|
||||
set<DIST::Array*> distrArraysAdded;
|
||||
|
||||
for (int z = 0; z < dataDirectives.distrRules.size(); ++z)
|
||||
distrArraysD.insert(dataDirectives.distrRules[z].first);
|
||||
for (int z = 0; z < dataDirectives.alignRules.size(); ++z)
|
||||
distrArraysD.insert(dataDirectives.alignRules[z].alignArray);
|
||||
|
||||
for (auto& elem : tableOfUniqNamesByArray)
|
||||
{
|
||||
set<DIST::Array*> realRefs;
|
||||
getRealArrayRefs(elem.first, elem.first, realRefs, arrayLinksByFuncCalls);
|
||||
if (isNotNullIntersection(realRefs, distrArraysD))
|
||||
distrArraysAdded.insert(elem.first);
|
||||
}
|
||||
|
||||
for (auto& elem : distrArraysD)
|
||||
{
|
||||
if (onlyCommon)
|
||||
{
|
||||
if (elem->GetLocation().first == DIST::l_COMMON)
|
||||
distrArrays.insert(elem);
|
||||
}
|
||||
else
|
||||
distrArrays.insert(elem);
|
||||
}
|
||||
|
||||
for (auto& elem : distrArraysAdded)
|
||||
{
|
||||
if (onlyCommon)
|
||||
{
|
||||
if (elem->GetLocation().first == DIST::l_COMMON)
|
||||
distrArrays.insert(elem);
|
||||
}
|
||||
else
|
||||
distrArrays.insert(elem);
|
||||
}
|
||||
return distrArrays;
|
||||
}
|
||||
|
||||
set<string> fillDistributedArrays(const DataDirective& dataDirectives,
|
||||
const map<DIST::Array*, tuple<int, string, string>>& tableOfUniqNamesByArray,
|
||||
const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls,
|
||||
bool onlyCommon, bool shortName)
|
||||
{
|
||||
set<string> distrArrays;
|
||||
set<DIST::Array*> ret = fillDistributedArraysD(dataDirectives, tableOfUniqNamesByArray, arrayLinksByFuncCalls, onlyCommon);
|
||||
|
||||
for (auto& elem : ret)
|
||||
distrArrays.insert(shortName ? elem->GetShortName() : elem->GetName());
|
||||
return distrArrays;
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
struct DataDirective;
|
||||
namespace Distribution
|
||||
{
|
||||
class Array;
|
||||
@@ -90,3 +91,6 @@ std::wstring fixedLongFormat(const wchar_t* old);
|
||||
std::map<std::string, DIST::Array*> sortArraysByName(const std::set<DIST::Array*>& toSort);
|
||||
bool createDirectory(const std::string& name);
|
||||
std::vector<std::string> splitAndArgvCreate(const std::string& options);
|
||||
|
||||
std::set<DIST::Array*> fillDistributedArraysD(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false);
|
||||
std::set<std::string> fillDistributedArrays(const DataDirective& dataDirectives, const std::map<DIST::Array*, std::tuple<int, std::string, std::string>>& tableOfUniqNamesByArray, const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCalls, bool onlyCommon = false, bool shortName = false);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2292"
|
||||
#define VERSION_SPF "2293"
|
||||
|
||||
Reference in New Issue
Block a user