added dvm declare
This commit is contained in:
@@ -1487,6 +1487,67 @@ void DvmhRegionInserter::addUsedWriteArrays(set<DIST::Array*>& arrays)
|
||||
}
|
||||
}
|
||||
|
||||
static void insertDeclare(const set<DIST::Array*>& usedArraysInRegions,
|
||||
const set<DIST::Array*>& usedWriteArraysInRegions,
|
||||
const map<DIST::Array*, set<DIST::Array*>> arrayLinksByFuncCalls)
|
||||
{
|
||||
vector<DIST::Array*> usedAll;
|
||||
std::set_union(usedArraysInRegions.begin(), usedArraysInRegions.end(),
|
||||
usedWriteArraysInRegions.begin(), usedWriteArraysInRegions.end(),
|
||||
std::back_inserter(usedAll));
|
||||
|
||||
set<DIST::Array*> added;
|
||||
map<SgStatement*, set<Symbol*>> toDeclareByFunc;
|
||||
|
||||
for (auto& array : usedAll)
|
||||
{
|
||||
set<DIST::Array*> realRef;
|
||||
getRealArrayRefs(array, array, realRef, arrayLinksByFuncCalls);
|
||||
|
||||
for (auto& realArray : realRef)
|
||||
{
|
||||
if (std::count(usedAll.begin(), usedAll.end(), realArray) == 0 && added.count(realArray) == 0)
|
||||
{
|
||||
added.insert(realArray);
|
||||
//TODO: for modules
|
||||
if (realArray->GetLocation().first != DIST::l_MODULE)
|
||||
{
|
||||
auto declInfo = *realArray->GetDeclInfo().begin();
|
||||
SgStatement* declStat = SgStatement::getStatementByFileAndLine(declInfo.first, declInfo.second);
|
||||
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
declStat = getFuncStat(declStat);
|
||||
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
toDeclareByFunc[declStat].insert(realArray->GetDeclSymbol());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& declPair : toDeclareByFunc)
|
||||
{
|
||||
SgStatement* func = declPair.first;
|
||||
const set<Symbol*>& symbols = declPair.second;
|
||||
|
||||
if (!func->switchToFile())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
set<string> added;
|
||||
vector<SgExpression*> list;
|
||||
for (auto& s : symbols)
|
||||
{
|
||||
if (added.count(s->identifier()) == 0)
|
||||
{
|
||||
added.insert(s->identifier());
|
||||
list.push_back(new SgVarRefExp(s));
|
||||
}
|
||||
}
|
||||
|
||||
func->insertStmtAfter(*new SgStatement(ACC_DECLARE_DIR, NULL, NULL, makeExprList(list)), *func);
|
||||
}
|
||||
}
|
||||
|
||||
void insertDvmhRegions(SgProject& project, int files, const vector<ParallelRegion*>& parallelRegions,
|
||||
map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
map<string, vector<LoopGraph*>> loopGraph,
|
||||
@@ -1552,6 +1613,8 @@ void insertDvmhRegions(SgProject& project, int files, const vector<ParallelRegio
|
||||
inserters[k]->createInterfaceBlockForParallelFunctions(false);
|
||||
}
|
||||
|
||||
insertDeclare(usedArraysInRegions, usedWriteArraysInRegions, arrayLinksByFuncCalls);
|
||||
|
||||
for (auto& regionInserter : inserters)
|
||||
{
|
||||
regionInserter->updateUsedArrays(usedArraysInRegions, usedWriteArraysInRegions);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2379"
|
||||
#define VERSION_SPF "2380"
|
||||
|
||||
Reference in New Issue
Block a user