5 Commits

8 changed files with 137 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
#pragma once
#include<unordered_map>
#include <unordered_map>
#include "SgUtils.h"
#include "CommonBlock.h"

View File

@@ -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);

View File

@@ -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;

View File

@@ -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*> &parallelRegions)
{
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);
}
}
}
}

View File

@@ -10,3 +10,7 @@ int printParalleRegions(const char *fileName, std::vector<ParallelRegion*> &regi
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);

View File

@@ -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)
{

View File

@@ -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();

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2476"
#define VERSION_SPF "2479"