Compare commits
10 Commits
private_ar
...
8fdf7e7063
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fdf7e7063 | ||
|
|
54e83e194d | ||
|
|
b87b18615d | ||
|
|
e733d3d68a | ||
| fb3ac921cc | |||
|
|
a8ddc94734 | ||
| db5062c416 | |||
| b71df882fb | |||
|
|
2d25a61ee7 | ||
| 3378ae5fbd |
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include<unordered_map>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "SgUtils.h"
|
||||
#include "CommonBlock.h"
|
||||
|
||||
@@ -1289,6 +1289,9 @@ static set<DIST::Array*>
|
||||
|
||||
SgStatement* declStat = NULL;
|
||||
|
||||
if (realArray->GetLocation().first == DIST::l_PARAMETER)
|
||||
continue;
|
||||
|
||||
if (realArray->GetLocation().first == DIST::l_COMMON)
|
||||
{
|
||||
commonArrays.insert(realArray);
|
||||
|
||||
@@ -723,7 +723,7 @@ static void fillIn(FuncInfo *currF, SgExpression *ex, const map<string, int> &pa
|
||||
{
|
||||
if (ex)
|
||||
{
|
||||
if (!isInFuncPar && (ex->variant() == VAR_REF || isArrayRef(ex)))
|
||||
if (!isInFuncPar && (ex->variant() == VAR_REF || ex->variant() == ARRAY_REF))
|
||||
{
|
||||
const char *name = ex->symbol()->identifier();
|
||||
if (name && name != string(""))
|
||||
@@ -880,7 +880,7 @@ static void fillInOut(FuncInfo *currF, SgStatement *start, SgStatement *last, co
|
||||
for (auto ex = read->itemList(); ex; ex = ex->rhs())
|
||||
{
|
||||
SgExpression* item = ex->lhs();
|
||||
if (item->variant() == VAR_REF || isArrayRef(item))
|
||||
if (item && (item->variant() == VAR_REF || item->variant() == ARRAY_REF))
|
||||
{
|
||||
string symb = "";
|
||||
if (item->symbol())
|
||||
@@ -901,7 +901,7 @@ static void fillInOut(FuncInfo *currF, SgStatement *start, SgStatement *last, co
|
||||
if (item->rhs())
|
||||
queue.push(item->rhs());
|
||||
|
||||
if (item->variant() == VAR_REF || isArrayRef(item))
|
||||
if (item->variant() == VAR_REF || item->variant() == ARRAY_REF)
|
||||
{
|
||||
string symb = "";
|
||||
if (item->symbol())
|
||||
|
||||
@@ -6,14 +6,12 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
using std::vector;
|
||||
using std::map;
|
||||
using std::unordered_map;
|
||||
using std::tuple;
|
||||
using std::set;
|
||||
using std::string;
|
||||
|
||||
@@ -24,6 +24,7 @@ using std::make_pair;
|
||||
using std::map;
|
||||
using std::set;
|
||||
using std::wstring;
|
||||
using std::tuple;
|
||||
|
||||
extern void createMapLoopGraph(map<int, LoopGraph*> &sortedLoopGraph, const vector<LoopGraph*> *loopGraph);
|
||||
|
||||
@@ -954,4 +955,65 @@ void calculateLinesOfCode(vector<ParallelRegion*> &allRegions)
|
||||
|
||||
__spf_print(1, " Count of lines in region '%s' = %d\n", elem->GetName().c_str(), lineCounter);
|
||||
}
|
||||
}
|
||||
|
||||
void propagateRegionInfo(map<tuple<int, string, string>, pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays,
|
||||
const map<DIST::Array*, set<DIST::Array*>>& arrayLinksByFuncCalls,
|
||||
const vector<ParallelRegion*> ¶llelRegions)
|
||||
{
|
||||
bool modified = true;
|
||||
while (modified)
|
||||
{
|
||||
modified = false;
|
||||
|
||||
for (auto &array_pair: declaredArrays)
|
||||
{
|
||||
auto array = array_pair.second.first;
|
||||
if (array->GetLocation().first == DIST::l_PARAMETER)
|
||||
{
|
||||
set<DIST::Array*> realArrayRef;
|
||||
getAllArrayRefs(array, array, realArrayRef, arrayLinksByFuncCalls);
|
||||
|
||||
auto regs = array->GetRegionsName();
|
||||
for (auto& ref : realArrayRef)
|
||||
{
|
||||
auto regsRef = ref->GetRegionsName();
|
||||
for (auto& reg : regsRef)
|
||||
{
|
||||
if (regs.count(reg) == 0)
|
||||
{
|
||||
array->SetRegionPlace(reg);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hasNonDefaultReg = false;
|
||||
for (auto& elem : parallelRegions)
|
||||
{
|
||||
string regName = elem->GetName();
|
||||
convertToLower(regName);
|
||||
if (regName != "default")
|
||||
hasNonDefaultReg = true;
|
||||
}
|
||||
|
||||
if (hasNonDefaultReg)
|
||||
{
|
||||
for (auto array : declaredArrays)
|
||||
{
|
||||
if (array.second.first->GetRegionsName().size() == 0)
|
||||
array.second.first->SetDistributeFlag(DIST::NO_DISTR);
|
||||
else if (array.second.first->GetRegionsName().size() == 1)
|
||||
{
|
||||
string regName = *array.second.first->GetRegionsName().begin();
|
||||
convertToLower(regName);
|
||||
if (regName == "default")
|
||||
array.second.first->SetDistributeFlag(DIST::NO_DISTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,7 @@ int printParalleRegions(const char *fileName, std::vector<ParallelRegion*> ®i
|
||||
bool buildGraphFromUserDirectives(const std::vector<Statement*> &userDvmAlignDirs, DIST::GraphCSR<int, double, attrType> &G, DIST::Arrays<int> &allArrays, const std::map<DIST::Array*, std::set<DIST::Array*>> &arrayLinksByFuncCalls, const std::set<DIST::Array*>& alignedArrays, std::set<DIST::Array*>& addedArrays, const std::map<std::string, std::vector<FuncInfo*>>& funcsByFile);
|
||||
void clearRegionStaticData();
|
||||
void calculateLinesOfCode(std::vector<ParallelRegion*> &allRegions);
|
||||
|
||||
void propagateRegionInfo(std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays,
|
||||
const std::map<DIST::Array*, std::set<DIST::Array*>>& arrayLinksByFuncCall,
|
||||
const std::vector<ParallelRegion*>& parallelRegions);
|
||||
|
||||
@@ -741,7 +741,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
else if (curr_regime == LOOP_DATA_DEPENDENCIES)
|
||||
doDependenceAnalysisOnTheFullFile(file, 1, 1, 1);
|
||||
else if (curr_regime == REMOVE_DVM_DIRS || curr_regime == REMOVE_DVM_DIRS_TO_COMMENTS || curr_regime == REMOVE_SPF_DIRS) {
|
||||
bool removeDvm = (curr_regime == REMOVE_DVM_DIRS || curr_regime == REMOVE_DVM_DIRS);
|
||||
bool removeDvm = (curr_regime == REMOVE_DVM_DIRS);
|
||||
bool removeSpf = (curr_regime == REMOVE_SPF_DIRS);
|
||||
bool toComment = (curr_regime == REMOVE_DVM_DIRS_TO_COMMENTS);
|
||||
removeDvmSpfDirectives(file, removeDvm, removeSpf, toComment);
|
||||
@@ -1264,6 +1264,8 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
|
||||
moveAllocatesInterproc(arrayLinksByFuncCalls);
|
||||
|
||||
propagateRegionInfo(declaredArrays, arrayLinksByFuncCalls, subs_parallelRegions);
|
||||
|
||||
removeDistrStateFromDeadFunctions(allFuncInfo, declaredArrays);
|
||||
propagateArrayFlags(arrayLinksByFuncCalls, declaredArrays, SPF_messages);
|
||||
}
|
||||
@@ -1681,30 +1683,11 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
findDeadFunctionsAndFillCalls(allFuncInfo_IR, SPF_messages, true);
|
||||
else if (curr_regime == GET_ALL_ARRAY_DECL)
|
||||
{
|
||||
bool hasNonDefaultReg = false;
|
||||
for (auto &elem : subs_parallelRegions)
|
||||
if (elem->GetName() != "DEFAULT")
|
||||
hasNonDefaultReg = true;
|
||||
|
||||
if (hasNonDefaultReg)
|
||||
if (ignoreArrayDistributeState)
|
||||
{
|
||||
for (auto array : declaredArrays)
|
||||
{
|
||||
if (array.second.first->GetRegionsName().size() == 0)
|
||||
array.second.first->SetDistributeFlag(DIST::NO_DISTR);
|
||||
else if (array.second.first->GetRegionsName().size() == 1)
|
||||
{
|
||||
string regName = *array.second.first->GetRegionsName().begin();
|
||||
convertToLower(regName);
|
||||
if (regName == "default")
|
||||
array.second.first->SetDistributeFlag(DIST::NO_DISTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreArrayDistributeState)
|
||||
for (auto array : declaredArrays)
|
||||
array.second.first->SetDistributeFlag(DIST::NO_DISTR);
|
||||
}
|
||||
}
|
||||
else if (curr_regime == GCOV_PARSER)
|
||||
{
|
||||
|
||||
@@ -234,9 +234,8 @@ static bool hasDvmParallel(SgStatement *func)
|
||||
return false;
|
||||
}
|
||||
|
||||
void transformAssumedSizeParameters(const map<string, vector<FuncInfo*>>& allFuncInfo)
|
||||
{
|
||||
map<string, vector<int>> assumedSizeArraysByFunc;
|
||||
static map<FuncInfo*, bool> createDvmParallelInfo(const map<string, vector<FuncInfo*>>& allFuncInfo) {
|
||||
map<FuncInfo*, bool> hasDvmParallelMap;
|
||||
|
||||
for (auto& funcByFile : allFuncInfo)
|
||||
{
|
||||
@@ -249,7 +248,63 @@ void transformAssumedSizeParameters(const map<string, vector<FuncInfo*>>& allFun
|
||||
if (prog == NULL)
|
||||
continue;
|
||||
|
||||
if (!hasDvmParallel(prog))
|
||||
hasDvmParallelMap[func] = hasDvmParallel(prog);
|
||||
}
|
||||
}
|
||||
|
||||
bool changed = true;
|
||||
while (changed)
|
||||
{
|
||||
changed = false;
|
||||
|
||||
for (auto& funcByFile : allFuncInfo)
|
||||
{
|
||||
for (auto& func : funcByFile.second)
|
||||
{
|
||||
if (!hasDvmParallelMap[func])
|
||||
{
|
||||
bool hasParallel = false;
|
||||
for (auto& callF : func->callsFromV)
|
||||
{
|
||||
if (hasDvmParallelMap[callF])
|
||||
{
|
||||
hasParallel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasParallel)
|
||||
{
|
||||
changed = true;
|
||||
hasDvmParallelMap[func] = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasDvmParallelMap;
|
||||
}
|
||||
|
||||
|
||||
void transformAssumedSizeParameters(const map<string, vector<FuncInfo*>>& allFuncInfo)
|
||||
{
|
||||
map<string, vector<int>> assumedSizeArraysByFunc;
|
||||
const map<FuncInfo*, bool> hasDvmParallelMap = createDvmParallelInfo(allFuncInfo);
|
||||
|
||||
for (auto& funcByFile : allFuncInfo)
|
||||
{
|
||||
if (SgFile::switchToFile(funcByFile.first) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto& func : funcByFile.second)
|
||||
{
|
||||
SgProgHedrStmt* prog = isSgProgHedrStmt(func->funcPointer->GetOriginal());
|
||||
if (prog == NULL)
|
||||
continue;
|
||||
|
||||
if (!hasDvmParallelMap.at(func))
|
||||
continue;
|
||||
|
||||
vector<SgSymbol*> parNames;
|
||||
@@ -259,7 +314,8 @@ void transformAssumedSizeParameters(const map<string, vector<FuncInfo*>>& allFun
|
||||
bool hasRefs = false;
|
||||
for (int z = 0; z < func->funcParams.countOfPars; ++z)
|
||||
{
|
||||
if (func->funcParams.parametersT[z] == ARRAY_T)
|
||||
if (func->funcParams.parametersT[z] == ARRAY_T ||
|
||||
func->funcParams.parametersT[z] == STRING_ARRAY_T)
|
||||
{
|
||||
auto s = prog->parameter(z);
|
||||
const string name = s->identifier();
|
||||
|
||||
@@ -504,7 +504,7 @@ static void replaceArrayInFragment(SgSymbol* replace_symb,
|
||||
}
|
||||
}
|
||||
|
||||
static bool ioReginBorder(SgStatement* stat, SgStatement* last_io_bound)
|
||||
static bool ioRegionBorder(SgStatement* stat, SgStatement* last_io_bound)
|
||||
{
|
||||
auto var = stat->variant();
|
||||
|
||||
@@ -535,14 +535,24 @@ static bool ioReginBorder(SgStatement* stat, SgStatement* last_io_bound)
|
||||
if (last_io_bound && last_io_bound->lastNodeOfStmt() && last_io_bound->lastNodeOfStmt() == stat)
|
||||
return true;
|
||||
|
||||
int parent_var;
|
||||
|
||||
if (var == CONTROL_END && border_stats.find(stat->controlParent()->variant()) != border_stats.end())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FuncInfo* getCurrentFuncInfo(const vector<FuncInfo*>& fileFuncInfo, int line)
|
||||
{
|
||||
for (auto* func : fileFuncInfo)
|
||||
{
|
||||
if (func->linesNum.first <= line && line <= func->linesNum.second)
|
||||
return func;
|
||||
}
|
||||
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
||||
const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
map<string, vector<Messages>>& SPF_messages,
|
||||
@@ -562,6 +572,8 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
||||
if (SgFile::switchToFile(current_file_name) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
FuncInfo *current_func_info = NULL;
|
||||
|
||||
auto func_info_it = allFuncInfo.find(current_file_name);
|
||||
if (func_info_it == allFuncInfo.end())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
@@ -588,13 +600,12 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
||||
{
|
||||
curr_stmt = lines.stats.first->GetOriginal();
|
||||
end = lines.stats.second->GetOriginal()->lexNext();
|
||||
current_func_info = getCurrentFuncInfo(func_info_it->second, curr_stmt->lineNumber());
|
||||
}
|
||||
|
||||
map<SgSymbol*, set<SgStatement*>> need_replace;
|
||||
SgStatement* last_io_bound = NULL;
|
||||
|
||||
FuncInfo *current_func_info = NULL;
|
||||
|
||||
while (curr_stmt != end)
|
||||
{
|
||||
if (!curr_stmt)
|
||||
@@ -604,18 +615,7 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
||||
|
||||
if (var == PROC_HEDR || var == PROG_HEDR || var == FUNC_HEDR)
|
||||
{
|
||||
current_func_info = NULL;
|
||||
for (auto *func_info : func_info_it->second)
|
||||
{
|
||||
if (func_info->funcName == curr_stmt->symbol()->identifier())
|
||||
{
|
||||
current_func_info = func_info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!current_func_info)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
current_func_info = getCurrentFuncInfo(func_info_it->second, curr_stmt->lineNumber());
|
||||
|
||||
curr_stmt = curr_stmt->lexNext();
|
||||
while (curr_stmt && !isSgExecutableStatement(curr_stmt))
|
||||
@@ -628,7 +628,7 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
||||
break;
|
||||
}
|
||||
|
||||
if (ioReginBorder(curr_stmt, last_io_bound))
|
||||
if (ioRegionBorder(curr_stmt, last_io_bound))
|
||||
{
|
||||
for (const auto& by_array_to_copy : need_replace)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2474"
|
||||
#define VERSION_SPF "2479"
|
||||
|
||||
Reference in New Issue
Block a user