fixed actuals
This commit is contained in:
@@ -837,9 +837,9 @@ static pair<string, string> getModuleRename(const map<string, set<SgSymbol*>>& b
|
||||
{
|
||||
auto declS = array->GetDeclSymbol(filename, lineRange, getAllFilesInProject())->GetOriginal();
|
||||
for (auto& elem : byUse)
|
||||
for (auto& localS : elem.second)
|
||||
if (OriginalSymbol(localS) == declS)
|
||||
return make_pair(elem.first, localS->identifier());
|
||||
for (auto& localS : setToMapWithSortByStr(elem.second))
|
||||
if (OriginalSymbol(localS.second) == declS)
|
||||
return make_pair(elem.first, localS.second->identifier());
|
||||
return make_pair("", "");
|
||||
}
|
||||
|
||||
|
||||
@@ -172,14 +172,6 @@ static SgExpression* genSgExpr(SgFile *file, const string &letter, const pair<in
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static std::multimap<string, Symbol*> setToMapWithSortByStr(const set<Symbol*> &setIn)
|
||||
{
|
||||
std::multimap<string, Symbol*> retMap;
|
||||
for (auto& elem : setIn)
|
||||
retMap.insert(make_pair(elem->identifier(), elem));
|
||||
return retMap;
|
||||
}
|
||||
|
||||
static void fillUsedSymbols(SgExpression* ex, set<SgSymbol*>& used)
|
||||
{
|
||||
if (ex)
|
||||
|
||||
@@ -297,7 +297,7 @@ static bool hasLoopsWithDir(LoopGraph* loop)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static void analyzeFunctionParameter(SgExpression* ex, set<string>& except, ArraySet& arrays)
|
||||
static void analyzeFunctionParameter(SgExpression* ex, set<string>& except, ArraySet& arrays, bool isIntrinsicCall)
|
||||
{
|
||||
if (ex)
|
||||
{
|
||||
@@ -313,45 +313,50 @@ static void analyzeFunctionParameter(SgExpression* ex, set<string>& except, Arra
|
||||
if (ex->lhs() || ex->rhs())
|
||||
arrays.insert(currArray);
|
||||
else if (!ex->lhs() && !ex->rhs())
|
||||
except.insert(ex->symbol()->identifier());
|
||||
{
|
||||
if (isIntrinsicCall)
|
||||
arrays.insert(currArray);
|
||||
else
|
||||
except.insert(ex->symbol()->identifier());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
analyzeFunctionParameter(ex->lhs(), except, arrays);
|
||||
analyzeFunctionParameter(ex->rhs(), except, arrays);
|
||||
analyzeFunctionParameter(ex->lhs(), except, arrays, isIntrinsicCall);
|
||||
analyzeFunctionParameter(ex->rhs(), except, arrays, isIntrinsicCall);
|
||||
}
|
||||
}
|
||||
|
||||
static void analyzeFunctionParameters(SgExpression* paramList, set<string>& except, ArraySet& arrays)
|
||||
static void analyzeFunctionParameters(SgExpression* paramList, set<string>& except, ArraySet& arrays, bool isIntrinsicCall)
|
||||
{
|
||||
while (paramList)
|
||||
{
|
||||
SgExpression* ex = paramList->lhs();
|
||||
if (ex->variant() == FUNC_CALL)
|
||||
{
|
||||
if (!isIntrinsicFunctionName(ex->symbol()->identifier()))
|
||||
analyzeFunctionParameters(ex->lhs(), except, arrays);
|
||||
bool isIntrinsic = isIntrinsicFunctionName(ex->symbol()->identifier());
|
||||
analyzeFunctionParameters(ex->lhs(), except, arrays, isIntrinsic);
|
||||
}
|
||||
else
|
||||
analyzeFunctionParameter(ex, except, arrays);
|
||||
|
||||
analyzeFunctionParameter(ex, except, arrays, isIntrinsicCall);
|
||||
|
||||
paramList = paramList->rhs();
|
||||
}
|
||||
}
|
||||
|
||||
static void createExceptList(SgExpression* ex, set<string>& except, ArraySet& arrays)
|
||||
static void createExceptListFromFunctionParameters(SgExpression* ex, set<string>& except, ArraySet& arrays, bool forGetActual)
|
||||
{
|
||||
if (ex)
|
||||
{
|
||||
if (ex->variant() == FUNC_CALL)
|
||||
{
|
||||
if (!isIntrinsicFunctionName(ex->symbol()->identifier()))
|
||||
analyzeFunctionParameters(ex->lhs(), except, arrays);
|
||||
bool isIntrinsic = isIntrinsicFunctionName(ex->symbol()->identifier()) && forGetActual;
|
||||
analyzeFunctionParameters(ex->lhs(), except, arrays, isIntrinsic);
|
||||
}
|
||||
else
|
||||
{
|
||||
createExceptList(ex->lhs(), except, arrays);
|
||||
createExceptList(ex->rhs(), except, arrays);
|
||||
createExceptListFromFunctionParameters(ex->lhs(), except, arrays, forGetActual);
|
||||
createExceptListFromFunctionParameters(ex->rhs(), except, arrays, forGetActual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,7 +387,6 @@ ArraySet DvmhRegionInserter::excludeRemotes(const ArraySet& block, SgStatement*
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
SgStatement* next = remoteDir->lexNext();
|
||||
const string leftS = "";
|
||||
|
||||
//TODO: record ref!
|
||||
if (next->variant() == ASSIGN_STAT)
|
||||
@@ -402,9 +406,6 @@ ArraySet DvmhRegionInserter::excludeRemotes(const ArraySet& block, SgStatement*
|
||||
|
||||
for (auto& remArray : remotes)
|
||||
{
|
||||
if (leftS == OriginalSymbol(remArray->symbol())->identifier())
|
||||
continue;
|
||||
|
||||
auto arrayR = OriginalSymbol(remArray->symbol());
|
||||
SgStatement* decl = declaratedInStmt(arrayR);
|
||||
DIST::Array* currArray = getArrayFromDeclarated(decl, arrayR->identifier());
|
||||
@@ -441,7 +442,7 @@ void DvmhRegionInserter::insertForProcCall(SgStatement* st, bool& skipGetActualI
|
||||
|
||||
ArraySet arraysToGetActual, arraysToActual;
|
||||
set<string> exceptSymbs;
|
||||
analyzeFunctionParameters(st->expr(0), exceptSymbs, arraysToGetActual);
|
||||
analyzeFunctionParameters(st->expr(0), exceptSymbs, arraysToGetActual, false);
|
||||
|
||||
auto writeArrays = get_used_arrs(st, DVMH_REG_WT);
|
||||
writeArrays = excludePrivates(writeArrays);
|
||||
@@ -526,18 +527,24 @@ SgStatement* DvmhRegionInserter::processSt(SgStatement *st, const vector<Paralle
|
||||
auto writeBlocks = get_used_arrs_for_block(st, DVMH_REG_WT);
|
||||
|
||||
readBlocks = excludePrivates(readBlocks);
|
||||
readBlocks = applyUseFilter(readBlocks, usedArraysInParallelLoops);
|
||||
if (raDir)
|
||||
readBlocks = excludeRemotes(readBlocks, raDir);
|
||||
|
||||
readBlocks = applyUseFilter(readBlocks, writesToArraysInParallelLoops);
|
||||
//TODO: need to exclude remotes when the analysis will be clarified
|
||||
/*if (raDir)
|
||||
readBlocks = excludeRemotes(readBlocks, raDir);*/
|
||||
|
||||
writeBlocks = excludePrivates(writeBlocks);
|
||||
writeBlocks = applyUseFilter(writeBlocks, usedArraysInParallelLoops);
|
||||
writeBlocks = applyUseFilter(writeBlocks, writesToArraysInParallelLoops);
|
||||
|
||||
ArraySet unite;
|
||||
std::merge(readBlocks.begin(), readBlocks.end(), writeBlocks.begin(), writeBlocks.end(), std::inserter(unite, unite.end()));
|
||||
|
||||
if (!(block_dir->variant() == DVM_REMOTE_ACCESS_DIR && st->variant() == ASSIGN_STAT && readBlocks.size() == 0))
|
||||
insertActualDirective(block_dir, unite, ACC_GET_ACTUAL_DIR, true);
|
||||
|
||||
writeBlocks = get_used_arrs_for_block(st, DVMH_REG_WT);
|
||||
writeBlocks = excludePrivates(writeBlocks);
|
||||
writeBlocks = applyUseFilter(writeBlocks, usedArraysInParallelLoops);
|
||||
|
||||
insertActualDirective(st->lastNodeOfStmt()->lexNext(), writeBlocks, ACC_ACTUAL_DIR, false);
|
||||
}
|
||||
return st->lastNodeOfStmt()->lexNext();
|
||||
@@ -570,7 +577,7 @@ SgStatement* DvmhRegionInserter::processSt(SgStatement *st, const vector<Paralle
|
||||
|
||||
if (var != WRITE_STAT)
|
||||
for (int z = 0; z < 3; ++z)
|
||||
createExceptList(st->expr(z), exceptSymbsForGetActual, forGetActual);
|
||||
createExceptListFromFunctionParameters(st->expr(z), exceptSymbsForGetActual, forGetActual, true);
|
||||
|
||||
auto readArrays = get_used_arrs(st, DVMH_REG_RD);
|
||||
readArrays = excludePrivates(readArrays);
|
||||
@@ -588,7 +595,7 @@ SgStatement* DvmhRegionInserter::processSt(SgStatement *st, const vector<Paralle
|
||||
|
||||
if (var != READ_STAT)
|
||||
for (int z = 0; z < 3; ++z)
|
||||
createExceptList(st->expr(z), exceptSymbsForActual, forActual);
|
||||
createExceptListFromFunctionParameters(st->expr(z), exceptSymbsForActual, forActual, false);
|
||||
|
||||
auto writeArrays = get_used_arrs(st, DVMH_REG_WT);
|
||||
writeArrays = excludePrivates(writeArrays);
|
||||
|
||||
@@ -62,10 +62,13 @@ VarUsages ReadWriteAnalyzer::findUsagesInAssignment(SgStatement* st) const
|
||||
// load usages from array indexes
|
||||
VarUsages usages_in_arr_indexing = findUsagesInExpr(st->expr(1)->lhs());
|
||||
usages.extend(usages_in_arr_indexing);
|
||||
|
||||
usages_in_arr_indexing = findUsagesInExpr(st->expr(1)->rhs());
|
||||
usages.extend(usages_in_arr_indexing);
|
||||
|
||||
usages_in_arr_indexing = findUsagesInExpr(st->expr(0)->lhs());
|
||||
usages.extend(usages_in_arr_indexing);
|
||||
|
||||
usages_in_arr_indexing = findUsagesInExpr(st->expr(0)->rhs());
|
||||
usages.extend(usages_in_arr_indexing);
|
||||
|
||||
@@ -124,7 +127,8 @@ VarUsages ReadWriteAnalyzer::findUsagesInFuncCall(SgExpression* params_tree, con
|
||||
VarUsages usages;
|
||||
|
||||
vector<int> inOutTypes;
|
||||
if (!isIntrinsicFunctionName(func_key.c_str()))
|
||||
bool isIntrinsic = isIntrinsicFunctionName(func_key.c_str());
|
||||
if (!isIntrinsic)
|
||||
{
|
||||
auto it = modified_pars.find(func_key);
|
||||
if (it != modified_pars.end())
|
||||
@@ -216,7 +220,8 @@ VarUsages ReadWriteAnalyzer::findUsagesInFuncCall(SgExpression* params_tree, con
|
||||
else
|
||||
{
|
||||
usages.insert_read(param);
|
||||
usages.insert_write(param);
|
||||
if (!isIntrinsic)
|
||||
usages.insert_write(param);
|
||||
}
|
||||
|
||||
findReadUsagesInExpression(param->lhs(), usages);
|
||||
|
||||
@@ -2306,10 +2306,12 @@ SgSymbol* getFromModule(const map<string, set<SgSymbol*>> &byUse, SgSymbol *orig
|
||||
|
||||
if (byUse.size())
|
||||
{
|
||||
for (auto& elem : byUse)
|
||||
for (auto& localS : elem.second)
|
||||
if (OriginalSymbol(localS)->thesymb == orig->thesymb)
|
||||
return localS;
|
||||
for (auto& elem : byUse)
|
||||
{
|
||||
for (auto& localS : setToMapWithSortByStr(elem.second))
|
||||
if (OriginalSymbol(localS.second)->thesymb == orig->thesymb)
|
||||
return localS.second;
|
||||
}
|
||||
}
|
||||
return orig;
|
||||
}
|
||||
|
||||
@@ -108,4 +108,13 @@ void getMaxMinBlockDistribution(SgFile* file, std::pair<int, int>& min_max);
|
||||
|
||||
void addPrivatesToArraysFromGUI(SgFile* file, const std::map<std::tuple<int, std::string, std::string>, std::pair<DIST::Array*, DIST::ArrayAccessInfo*>>& declaredArrays, const std::map<std::string, int>& distrStateFromGUI);
|
||||
|
||||
void shiftLines(SgProject* project, bool print = true);
|
||||
void shiftLines(SgProject* project, bool print = true);
|
||||
|
||||
template<typename T>
|
||||
static inline std::multimap<std::string, T> setToMapWithSortByStr(const std::set<T>& setIn)
|
||||
{
|
||||
std::multimap<std::string, T> retMap;
|
||||
for (auto& elem : setIn)
|
||||
retMap.insert(make_pair(elem->identifier(), elem));
|
||||
return retMap;
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2364"
|
||||
#define VERSION_SPF "2366"
|
||||
|
||||
Reference in New Issue
Block a user