Compare commits
10 Commits
78a05d1a53
...
c428f365f9
| Author | SHA1 | Date | |
|---|---|---|---|
| c428f365f9 | |||
|
|
dfb5d4796b | ||
|
|
90fb0bf6b9 | ||
|
|
2288ef3edf | ||
|
|
8a69ee3a40 | ||
| f38ce9e523 | |||
|
|
7a51e3c587 | ||
|
|
d076333a53 | ||
|
|
ec2975a2ed | ||
| 91788bd09e |
@@ -7645,14 +7645,14 @@ SgExpression *CalculateArrayBound(SgExpression *edim, SgSymbol *ar, int flag_pri
|
||||
SgSubscriptExp *sbe;
|
||||
SgExpression *low;
|
||||
if (!edim && flag_private)
|
||||
{
|
||||
{
|
||||
// Error("Illegal array bound of private/reduction array %s", ar->identifier(), 442, dvm_parallel_dir);
|
||||
return (edim);
|
||||
}
|
||||
if ((sbe = isSgSubscriptExp(edim)) != NULL){ //DDOT
|
||||
|
||||
if (!sbe->ubound() && flag_private)
|
||||
{
|
||||
{
|
||||
// Error("Illegal array bound of private/reduction array %s", ar->identifier(), 442, dvm_parallel_dir);
|
||||
return(edim);
|
||||
}
|
||||
@@ -7675,8 +7675,8 @@ SgExpression *CalculateArrayBound(SgExpression *edim, SgSymbol *ar, int flag_pri
|
||||
}
|
||||
else
|
||||
{
|
||||
edim = Calculate(edim);
|
||||
if (edim->variant() != INT_VAL && flag_private )
|
||||
edim = Calculate(edim);
|
||||
// if (edim->variant() != INT_VAL && flag_private )
|
||||
// Error("Illegal array bound of private/reduction array %s", ar->identifier(), 442, dvm_parallel_dir);
|
||||
return (edim);
|
||||
}
|
||||
@@ -11095,10 +11095,13 @@ SgExpression *BlockDimsProduct()
|
||||
{
|
||||
return &(*new SgRecordRefExp(*s_blockdim, "x") * *new SgRecordRefExp(*s_blockdim, "y") * *new SgRecordRefExp(*s_blockdim, "z"));
|
||||
}
|
||||
|
||||
|
||||
SgExpression *LowerShiftForArrays (SgSymbol *ar, int i, int type)
|
||||
{
|
||||
SgExpression *e = isConstantBound(ar, i, 1);
|
||||
SgExpression *e = isConstantBound(ar, i, 1);
|
||||
if(e) return e;
|
||||
if(type==0) //private array
|
||||
e = new SgValueExp(1);
|
||||
else // reduction array
|
||||
e = &(((SgExprListExp *)red_struct_list->lowBound_arg)->elem(i)->copy());
|
||||
return e;
|
||||
|
||||
@@ -208,7 +208,7 @@ static void addInListIfNeed(SgSymbol *tmp, int type, reduction_operation_list *t
|
||||
while (dimList)
|
||||
{
|
||||
allArraySub.push(dimList->lhs());
|
||||
allArraySubConv.push(make_pair(LowerShiftForArrays(tmp, rank), UpperShiftForArrays(tmp, rank)));
|
||||
allArraySubConv.push(make_pair(LowerShiftForArrays(tmp, rank, type), UpperShiftForArrays(tmp, rank)));
|
||||
++rank;
|
||||
dimList = dimList->rhs();
|
||||
}
|
||||
@@ -222,7 +222,7 @@ static void addInListIfNeed(SgSymbol *tmp, int type, reduction_operation_list *t
|
||||
bool ddot = false;
|
||||
if (ex->variant() == DDOT && ex->lhs() || IS_ALLOCATABLE(tmp))
|
||||
ddot = true;
|
||||
t.correctExp.push_back(LowerShiftForArrays(tmp, rank));
|
||||
t.correctExp.push_back(LowerShiftForArrays(tmp, rank, type));
|
||||
|
||||
// swap array's dimentionss
|
||||
if (inNewVars(tmp->identifier()))
|
||||
|
||||
@@ -6263,6 +6263,14 @@ SgExpression *doShapeList(SgSymbol *ar, SgStatement *st) /* RTS2 */
|
||||
l_bound = &(c1.copy());
|
||||
}
|
||||
else {
|
||||
if(sbe->ubound() && sbe->ubound()->variant() == STAR_RANGE) {
|
||||
if(st->variant()==DVM_PARALLEL_ON_DIR )
|
||||
Error("Assumed-size array in parallel loop: %s",ar->identifier(), 162,st);
|
||||
else if( st->variant()==ACC_REGION_DIR)
|
||||
Error("Assumed-size array in region: %s",ar->identifier(), 162,st);
|
||||
else
|
||||
Error("Assumed-size array: %s",ar->identifier(), 162,st);
|
||||
}
|
||||
u_bound = UBOUNDFunction(ar,i+1);
|
||||
l_bound = LBOUNDFunction(ar,i+1);
|
||||
}
|
||||
@@ -6274,6 +6282,14 @@ SgExpression *doShapeList(SgSymbol *ar, SgStatement *st) /* RTS2 */
|
||||
l_bound = &(c1.copy());
|
||||
}
|
||||
else {
|
||||
if(pe->variant() == STAR_RANGE) {
|
||||
if(st->variant()==DVM_PARALLEL_ON_DIR )
|
||||
Error("Assumed-size array in parallel loop: %s",ar->identifier(), 162,st);
|
||||
else if( st->variant()==ACC_REGION_DIR)
|
||||
Error("Assumed-size array in region: %s",ar->identifier(), 162,st);
|
||||
else
|
||||
Error("Assumed-size array: %s",ar->identifier(), 162,st);
|
||||
}
|
||||
u_bound = UBOUNDFunction(ar,i+1);
|
||||
l_bound = LBOUNDFunction(ar,i+1);
|
||||
}
|
||||
|
||||
@@ -1390,7 +1390,7 @@ void RefInImplicitLoop(SgExpression *eim, int mode);
|
||||
void RefInImplicitLoop(SgExpression *eim, int mode);
|
||||
SgSymbol *dvm000SymbolForHost(int host_dvm, SgStatement *hedr);
|
||||
SgExpression *Red_grid_index(SgSymbol *sind);
|
||||
SgExpression *BlockDimsProduct();
|
||||
SgExpression *BlockDimsProduct();
|
||||
SgExpression *LowerShiftForArrays (SgSymbol *ar, int i, int type);
|
||||
SgExpression *UpperShiftForArrays (SgSymbol *ar, int i);
|
||||
SgExpression *coefProd(int i, SgExpression *ec);
|
||||
|
||||
@@ -490,9 +490,9 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
string callName = "_ERROR_";
|
||||
for (int z = 0; z < func->pointerDetailCallsFrom.size() && callName == "_ERROR_"; ++z)
|
||||
if (func->pointerDetailCallsFrom[z].first == ex)
|
||||
callName = func->detailCallsFrom[z].first;
|
||||
for (int z = 0; z < func->callsFromDetailed.size() && callName == "_ERROR_"; ++z)
|
||||
if (func->callsFromDetailed[z].pointerDetailCallsFrom.first == ex)
|
||||
callName = func->callsFromDetailed[z].detailCallsFrom.first;
|
||||
|
||||
SAPFOR::Argument* fArg = getFuncArg(callName);
|
||||
|
||||
@@ -1094,9 +1094,9 @@ static SgStatement* processStatement(SgStatement* st, vector<IR_Block*>& blocks,
|
||||
bool hasLabelArgs = processArgs(call, call->numberOfArgs(), blocks, func, commonVars, &labelsOfArgs);
|
||||
|
||||
string callName = "_ERROR_";
|
||||
for (int z = 0; z < func->pointerDetailCallsFrom.size() && callName == "_ERROR_"; ++z)
|
||||
if (func->pointerDetailCallsFrom[z].first == st)
|
||||
callName = func->detailCallsFrom[z].first;
|
||||
for (int z = 0; z < func->callsFromDetailed.size() && callName == "_ERROR_"; ++z)
|
||||
if (func->callsFromDetailed[z].pointerDetailCallsFrom.first == st)
|
||||
callName = func->callsFromDetailed[z].detailCallsFrom.first;
|
||||
|
||||
SAPFOR::Argument* fArg = getFuncArg(callName);
|
||||
|
||||
|
||||
@@ -846,8 +846,9 @@ void uniteIntervalsBetweenProcCalls(map<string, vector<SpfInterval*>> &intervals
|
||||
{
|
||||
if (SgFile::switchToFile(callsTo->fileName) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
for (auto &callsFrom : callsTo->pointerDetailCallsFrom)
|
||||
for (auto &callsInfo: callsTo->callsFromDetailed)
|
||||
{
|
||||
auto& callsFrom = callsInfo.pointerDetailCallsFrom;
|
||||
SgStatement *base = NULL;
|
||||
if (callsFrom.second == PROC_STAT)
|
||||
{
|
||||
|
||||
@@ -598,7 +598,6 @@ void fillInfoFromDirectives(const LoopGraph *loopInfo, ParallelDirective *direct
|
||||
void removeOmpDir(void* stIn)
|
||||
{
|
||||
SgStatement* st = (SgStatement*)stIn;
|
||||
vector<OmpDir> resultAll;
|
||||
|
||||
char* lineS = st->comments();
|
||||
if (!lineS)
|
||||
|
||||
@@ -1631,8 +1631,11 @@ void GroupShadow(const map<string, vector<FuncInfo*>>& allFuncs,
|
||||
for (auto& elem : byFile.second)
|
||||
{
|
||||
mapF[elem->funcName] = elem;
|
||||
for (auto& call : elem->detailCallsFrom)
|
||||
for (auto& callInfo : elem->callsFromDetailed)
|
||||
{
|
||||
auto& call = callInfo.detailCallsFrom;
|
||||
mapCallsF[elem->fileName][call.second].insert(call.first);
|
||||
}
|
||||
}
|
||||
|
||||
map<FuncInfo*, set<FuncInfo*>> callDeps;
|
||||
|
||||
@@ -877,6 +877,34 @@ ArraySet DvmhRegionInserter::get_used_arrs_for_block(SgStatement* st, int usage_
|
||||
return usages;
|
||||
}
|
||||
|
||||
static bool filterFromList(SgStatement* st, const set<string>& idents, bool exclude = false)
|
||||
{
|
||||
bool empty = false;
|
||||
SgExpression* list = st->expr(0);
|
||||
vector<SgExpression*> newList;
|
||||
while (list)
|
||||
{
|
||||
if (exclude)
|
||||
{
|
||||
if (idents.find(list->lhs()->symbol()->identifier()) == idents.end())
|
||||
newList.push_back(list->lhs());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (idents.find(list->lhs()->symbol()->identifier()) != idents.end())
|
||||
newList.push_back(list->lhs());
|
||||
}
|
||||
list = list->rhs();
|
||||
}
|
||||
|
||||
if (newList.size() == 0)
|
||||
empty = true;
|
||||
else
|
||||
st->setExpression(0, makeExprList(newList));
|
||||
|
||||
return empty;
|
||||
}
|
||||
|
||||
static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
{
|
||||
string oldFile = current_file->filename();
|
||||
@@ -884,8 +912,7 @@ static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
auto copy = duplicateProcedure(func, NULL, false, false, false, true);
|
||||
|
||||
const set<string> ident(pars.identificators.begin(), pars.identificators.end());
|
||||
const set<string> idents(pars.identificators.begin(), pars.identificators.end());
|
||||
|
||||
//remove all exec
|
||||
SgStatement* st = copy->lexNext();
|
||||
@@ -925,26 +952,16 @@ static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
|| st->variant() == DIM_STAT
|
||||
|| st->variant() == INTENT_STMT)
|
||||
{
|
||||
SgExpression* list = st->expr(0);
|
||||
vector<SgExpression*> newList;
|
||||
while (list)
|
||||
{
|
||||
if (ident.find(list->lhs()->symbol()->identifier()) != ident.end())
|
||||
newList.push_back(list->lhs());
|
||||
list = list->rhs();
|
||||
}
|
||||
|
||||
if (newList.size() == 0)
|
||||
bool empty = filterFromList(st, idents);
|
||||
if (empty)
|
||||
{
|
||||
SgStatement* next = st->lexNext();
|
||||
toExtract.push_back(st);
|
||||
st = next;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
st->setExpression(0, makeExprList(newList));
|
||||
}
|
||||
else
|
||||
else if (!isDVM_stat(st) && !isSPF_stat(st))
|
||||
toExtract.push_back(st);
|
||||
|
||||
if (st->variant() == CONTAINS_STMT)
|
||||
@@ -963,7 +980,7 @@ static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static void insertInterface(SgStatement* func, const string& iface)
|
||||
static void insertInterface(SgStatement* func, const string& iface, const string& fName)
|
||||
{
|
||||
string oldFile = current_file->filename();
|
||||
if (!func->switchToFile())
|
||||
@@ -973,6 +990,18 @@ static void insertInterface(SgStatement* func, const string& iface)
|
||||
SgStatement* last = func->lastNodeOfStmt();
|
||||
while (st != last)
|
||||
{
|
||||
if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90)
|
||||
{
|
||||
bool empty = filterFromList(st, { fName }, true);
|
||||
if (empty)
|
||||
{
|
||||
SgStatement* next = st->lexNext();
|
||||
st->extractStmt();
|
||||
st = next;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSgExecutableStatement(st))
|
||||
break;
|
||||
st = st->lexNext();
|
||||
@@ -1033,21 +1062,57 @@ static bool isPure(SgStatement* func)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void DvmhRegionInserter::createInterfaceBlock()
|
||||
void DvmhRegionInserter::createInterfaceBlockForParallelFunctions()
|
||||
{
|
||||
for (auto& parF : parallel_functions)
|
||||
{
|
||||
for (auto& callTo : parF->callsTo)
|
||||
{
|
||||
if (callTo->fileName != parF->fileName)
|
||||
if (callTo->fileName != parF->fileName && isPure(parF->funcPointer->GetOriginal()))
|
||||
{
|
||||
if (callTo->interfaceBlocks.find(parF->funcName) == callTo->interfaceBlocks.end()
|
||||
&& parF->funcParams.countOfPars > 0
|
||||
&& isPure(parF->funcPointer->GetOriginal()))
|
||||
insertRoutine(parF->funcPointer->GetOriginal());
|
||||
auto it = callTo->interfaceBlocks.find(parF->funcName);
|
||||
if (it == callTo->interfaceBlocks.end())
|
||||
{
|
||||
insertRoutine(parF->funcPointer->GetOriginal());
|
||||
callTo->interfaceBlocks[parF->funcName] = parF;
|
||||
insertInterface(callTo->funcPointer, getInterfaceBlock(parF->funcPointer->GetOriginal(), parF->funcParams));
|
||||
callTo->interfaceBlocks[parF->funcName] = NULL;
|
||||
insertInterface(callTo->funcPointer, getInterfaceBlock(parF->funcPointer->GetOriginal(), parF->funcParams), parF->funcName);
|
||||
}
|
||||
else if (it->second) // interface not inserted as comment
|
||||
{
|
||||
SgStatement* st = callTo->funcPointer->GetOriginal();
|
||||
|
||||
string oldFile = current_file->filename();
|
||||
if (!st->switchToFile())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
SgStatement* last = st->lastNodeOfStmt();
|
||||
SgStatement* iface = NULL;
|
||||
|
||||
st = st->lexNext();
|
||||
while (st != last)
|
||||
{
|
||||
if (st->variant() == FUNC_HEDR || st->variant() == PROC_HEDR)
|
||||
{
|
||||
if (st->controlParent()->variant() == INTERFACE_STMT &&
|
||||
st->symbol()->identifier() == parF->funcName)
|
||||
{
|
||||
iface = st;
|
||||
insertRoutine(iface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (st->variant() == CONTAINS_STMT)
|
||||
break;
|
||||
if (isSgExecutableStatement(st))
|
||||
break;
|
||||
st = st->lexNext();
|
||||
}
|
||||
|
||||
checkNull(iface, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
if (SgFile::switchToFile(oldFile) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1059,14 +1124,13 @@ void DvmhRegionInserter::createInterfaceBlockForOutCalls(FuncInfo* func)
|
||||
for (auto& callFrom : func->callsFromV)
|
||||
{
|
||||
if (func->interfaceBlocks.find(callFrom->funcName) == func->interfaceBlocks.end()
|
||||
&& callFrom->funcParams.countOfPars > 0
|
||||
&& isPure(callFrom->funcPointer->GetOriginal()))
|
||||
{
|
||||
if (callFrom->fileName != func->fileName)
|
||||
insertRoutine(func->funcPointer->GetOriginal());
|
||||
|
||||
func->interfaceBlocks[callFrom->funcName] = callFrom;
|
||||
insertInterface(func->funcPointer, getInterfaceBlock(callFrom->funcPointer->GetOriginal(), callFrom->funcParams));
|
||||
insertInterface(func->funcPointer, getInterfaceBlock(callFrom->funcPointer->GetOriginal(), callFrom->funcParams), callFrom->funcName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
void insertActualDirectives(const std::vector<ParallelRegion*>* regs);
|
||||
|
||||
void updateParallelFunctions(const std::map<std::string, std::vector<LoopGraph*>>& loopGraphs);
|
||||
void createInterfaceBlock();
|
||||
void createInterfaceBlockForParallelFunctions();
|
||||
void removePrivatesFromParallelLoops();
|
||||
void addPrivatesToParallelLoops();
|
||||
void addUsedArrays(std::set<DIST::Array*>& arrays);
|
||||
|
||||
@@ -357,12 +357,15 @@ static void findFuncCalls(SgStatement *parent, SgExpression *curr, vector<FuncIn
|
||||
correctNameIfContains(NULL, curr, elem, containsFunctions, prefix);
|
||||
|
||||
proc->callsFrom.insert(nameOfCallFunc.begin(), nameOfCallFunc.end());
|
||||
proc->detailCallsFrom.push_back(make_pair(nameOfCallFunc[1], line)); // original name of call
|
||||
proc->pointerDetailCallsFrom.push_back(make_pair(curr, FUNC_CALL));
|
||||
proc->parentForPointer.push_back(parent);
|
||||
|
||||
proc->actualParams.push_back(FuncParam());
|
||||
processActualParams(curr->lhs(), commonBlocks, proc->actualParams.back(), proc->externalCalls);
|
||||
FuncInfoCallFrom newCall;
|
||||
newCall.detailCallsFrom = make_pair(nameOfCallFunc[1], line); // original name of call
|
||||
newCall.pointerDetailCallsFrom = make_pair(curr, FUNC_CALL);
|
||||
newCall.parentForPointer = parent;
|
||||
newCall.actualParams = FuncParam();
|
||||
|
||||
processActualParams(curr->lhs(), commonBlocks, newCall.actualParams, proc->externalCalls);
|
||||
proc->callsFromDetailed.push_back(newCall);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1115,13 +1118,15 @@ void functionAnalyzer(SgFile *file, map<string, vector<FuncInfo*>> &allFuncInfo,
|
||||
continue;
|
||||
|
||||
proc->callsFrom.insert(pureNameOfCallFunc.begin(), pureNameOfCallFunc.end());
|
||||
proc->detailCallsFrom.push_back(make_pair(pureNameOfCallFunc[1], st->lineNumber())); // original name of call
|
||||
proc->pointerDetailCallsFrom.push_back(make_pair(st, PROC_STAT));
|
||||
proc->parentForPointer.push_back(st);
|
||||
|
||||
proc->actualParams.push_back(FuncParam());
|
||||
FuncInfoCallFrom newCall;
|
||||
newCall.detailCallsFrom = make_pair(pureNameOfCallFunc[1], st->lineNumber()); // original name of call
|
||||
newCall.pointerDetailCallsFrom = make_pair(st, PROC_STAT);
|
||||
newCall.parentForPointer = st;
|
||||
newCall.actualParams = FuncParam();
|
||||
|
||||
processActualParams(st->expr(0), commonBlocks, proc->actualParams.back(), proc->externalCalls);
|
||||
processActualParams(st->expr(0), commonBlocks, newCall.actualParams, proc->externalCalls);
|
||||
proc->callsFromDetailed.push_back(newCall);
|
||||
|
||||
// Add func call which we've just found
|
||||
NestedFuncCall funcCall(pureNameOfCallFunc[1]);
|
||||
@@ -1150,11 +1155,14 @@ void functionAnalyzer(SgFile *file, map<string, vector<FuncInfo*>> &allFuncInfo,
|
||||
correctNameIfContains(NULL, curr, elem, containsFunctions, prefix);
|
||||
|
||||
proc->callsFrom.insert(nameOfCallFunc.begin(), nameOfCallFunc.end());
|
||||
proc->detailCallsFrom.push_back(make_pair(nameOfCallFunc[1], st->lineNumber())); // original name of call
|
||||
proc->pointerDetailCallsFrom.push_back(make_pair(curr, VAR_REF));
|
||||
proc->parentForPointer.push_back(st);
|
||||
|
||||
proc->actualParams.push_back(FuncParam());
|
||||
FuncInfoCallFrom newCall;
|
||||
newCall.detailCallsFrom = make_pair(nameOfCallFunc[1], st->lineNumber()); // original name of call
|
||||
newCall.pointerDetailCallsFrom = make_pair(curr, VAR_REF);
|
||||
newCall.parentForPointer = st;
|
||||
newCall.actualParams = FuncParam();
|
||||
|
||||
proc->callsFromDetailed.push_back(newCall);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1336,7 +1344,7 @@ static bool matchCallAndDefinition(const FuncParam &funcParDef, const FuncParam&
|
||||
messages[file].push_back(Messages(NOTE, line, bufR, bufE, 1013));
|
||||
__spf_print(1, "Function '%s': different type of call and def parameter %d\n", funcName.c_str(), i + 1);
|
||||
}
|
||||
result = false;
|
||||
//result = false;
|
||||
}
|
||||
}
|
||||
else //TODO
|
||||
@@ -1371,11 +1379,11 @@ static bool matchCallAndDefinition(SgProject* proj, const map<string, int>& file
|
||||
|
||||
for (auto& callsTo : currF->callsTo)
|
||||
{
|
||||
for (int cf = 0; cf < callsTo->detailCallsFrom.size(); ++cf)
|
||||
for (int cf = 0; cf < callsTo->callsFromDetailed.size(); ++cf)
|
||||
{
|
||||
if (callsTo->detailCallsFrom[cf].first == currF->funcName)
|
||||
if (callsTo->callsFromDetailed[cf].detailCallsFrom.first == currF->funcName)
|
||||
{
|
||||
auto callInfo = callsTo->pointerDetailCallsFrom[cf];
|
||||
auto callInfo = callsTo->callsFromDetailed[cf].pointerDetailCallsFrom;
|
||||
if (callInfo.second == VAR_REF) // external call through proc parameter
|
||||
continue;
|
||||
|
||||
@@ -1383,8 +1391,8 @@ static bool matchCallAndDefinition(SgProject* proj, const map<string, int>& file
|
||||
if (itF == files.end())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
bool localR = matchCallAndDefinition(currF->funcParams, callsTo->actualParams[cf], currF->funcName,
|
||||
callsTo->fileName, callsTo->detailCallsFrom[cf].second, messages);
|
||||
bool localR = matchCallAndDefinition(currF->funcParams, callsTo->callsFromDetailed[cf].actualParams, currF->funcName,
|
||||
callsTo->fileName, callsTo->callsFromDetailed[cf].detailCallsFrom.second, messages);
|
||||
if (!localR)
|
||||
count++;
|
||||
}
|
||||
@@ -2256,8 +2264,9 @@ void propagateWritesToArrays(map<string, vector<FuncInfo*>> &allFuncInfo)
|
||||
if (!ok)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto &callFrom : callsTo->pointerDetailCallsFrom)
|
||||
for (auto &callFromInfo : callsTo->callsFromDetailed)
|
||||
{
|
||||
auto& callFrom = callFromInfo.pointerDetailCallsFrom;
|
||||
if (callFrom.second == VAR_REF) // pass procedure through parameter
|
||||
continue;
|
||||
|
||||
@@ -2429,8 +2438,9 @@ int getLvlCall(FuncInfo* currF, int lvl, const string& func, const string& file,
|
||||
if (currF->funcName == func)
|
||||
return 0;
|
||||
|
||||
for (auto& callsFrom : currF->detailCallsFrom)
|
||||
for (auto& callsFromInfo : currF->callsFromDetailed)
|
||||
{
|
||||
auto& callsFrom = callsFromInfo.detailCallsFrom;
|
||||
if (callsFrom.first == func && callsFrom.second == line && currF->fileName == file)
|
||||
return lvl;
|
||||
}
|
||||
@@ -2465,12 +2475,12 @@ void setInlineAttributeToCalls(const map<string, FuncInfo*>& allFunctions,
|
||||
if (itNeed != inDataChains.end())
|
||||
needToInline = itNeed->second;
|
||||
|
||||
for (int k = 0; k < curr->detailCallsFrom.size(); ++k)
|
||||
for (int k = 0; k < curr->callsFromDetailed.size(); ++k)
|
||||
{
|
||||
if (needToInline.find(curr->detailCallsFrom[k]) == needToInline.end() &&
|
||||
!isIntrinsicFunctionName(curr->detailCallsFrom[k].first.c_str()))
|
||||
if (needToInline.find(curr->callsFromDetailed[k].detailCallsFrom) == needToInline.end() &&
|
||||
!isIntrinsicFunctionName(curr->callsFromDetailed[k].detailCallsFrom.first.c_str()))
|
||||
{
|
||||
pair<void*, int> detail = curr->pointerDetailCallsFrom[k];
|
||||
pair<void*, int> detail = curr->callsFromDetailed[k].pointerDetailCallsFrom;
|
||||
|
||||
if (SgFile::switchToFile(curr->fileName) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
@@ -2480,7 +2490,7 @@ void setInlineAttributeToCalls(const map<string, FuncInfo*>& allFunctions,
|
||||
else if (detail.second == FUNC_CALL)
|
||||
{
|
||||
//TODO: many functions in same statement
|
||||
SgStatement* callSt = SgStatement::getStatementByFileAndLine(curr->fileName, curr->detailCallsFrom[k].second);
|
||||
SgStatement* callSt = SgStatement::getStatementByFileAndLine(curr->fileName, curr->callsFromDetailed[k].detailCallsFrom.second);
|
||||
if (!callSt)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
//((SgExpression*)detail.first)->addAttribute(BOOL_VAL);
|
||||
@@ -2489,8 +2499,8 @@ void setInlineAttributeToCalls(const map<string, FuncInfo*>& allFunctions,
|
||||
else
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
pointsForShadowCopies.insert(make_pair(curr->fileName, curr->detailCallsFrom[k].second));
|
||||
__spf_print(1, " added attribute to '%s' <%s, %d>\n", curr->detailCallsFrom[k].first.c_str(), curr->fileName.c_str(), curr->detailCallsFrom[k].second);
|
||||
pointsForShadowCopies.insert(make_pair(curr->fileName, curr->callsFromDetailed[k].detailCallsFrom.second));
|
||||
__spf_print(1, " added attribute to '%s' <%s, %d>\n", curr->callsFromDetailed[k].detailCallsFrom.first.c_str(), curr->fileName.c_str(), curr->callsFromDetailed[k].detailCallsFrom.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,16 @@ struct NestedFuncCall
|
||||
{ }
|
||||
};
|
||||
|
||||
struct FuncInfoCallFrom {
|
||||
// <name, line>
|
||||
std::pair<std::string, int> detailCallsFrom;
|
||||
// <pointer, SG_VAR> SgStatement for PROC_STAT, SgExpression for FUNC_CALL, VAR_REF for external calls
|
||||
std::pair<void*, int> pointerDetailCallsFrom;
|
||||
// parent SgStatement* of FUNC_CALL
|
||||
void* parentForPointer;
|
||||
FuncParam actualParams;
|
||||
};
|
||||
|
||||
struct FuncInfo
|
||||
{
|
||||
std::string funcName;
|
||||
@@ -107,13 +117,14 @@ struct FuncInfo
|
||||
|
||||
std::set<std::string> callsFrom; //calls from this function
|
||||
std::set<FuncInfo*> callsFromV;
|
||||
std::vector<FuncInfoCallFrom> callsFromDetailed;
|
||||
|
||||
//TODO: create new object for grouping this info
|
||||
// grouped info of calls from
|
||||
std::vector<std::pair<std::string, int>> detailCallsFrom; // <name, line>
|
||||
/*std::vector<std::pair<std::string, int>> detailCallsFrom; // <name, line>
|
||||
std::vector<std::pair<void*, int>> pointerDetailCallsFrom; // <pointer, SG_VAR> SgStatement for PROC_STAT, SgExpression for FUNC_CALL, VAR_REF for external calls
|
||||
std::vector<void*> parentForPointer; // parent SgStatement* of FUNC_CALL
|
||||
std::vector<FuncParam> actualParams;
|
||||
std::vector<FuncParam> actualParams;*/
|
||||
// end/
|
||||
|
||||
std::map<std::string, std::set<std::string>> commonBlocks;
|
||||
@@ -176,10 +187,10 @@ struct FuncInfo
|
||||
std::vector<std::pair<void*, int>> GetDetailedCallInfo(const std::string &funcName)
|
||||
{
|
||||
std::vector<std::pair<void*, int>> result;
|
||||
for (int i = 0; i < pointerDetailCallsFrom.size(); ++i)
|
||||
for (int i = 0; i < callsFromDetailed.size(); ++i)
|
||||
{
|
||||
if (detailCallsFrom[i].first == funcName)
|
||||
result.push_back(pointerDetailCallsFrom[i]);
|
||||
if (callsFromDetailed[i].detailCallsFrom.first == funcName)
|
||||
result.push_back(callsFromDetailed[i].pointerDetailCallsFrom);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -154,8 +154,9 @@ void updateFuncInfo(const map<string, vector<FuncInfo*>> &allFuncInfo) // const
|
||||
for (auto &it : mapFuncInfo)
|
||||
{
|
||||
FuncInfo *currInfo = it.second;
|
||||
for (auto &funcCall : currInfo->detailCallsFrom)
|
||||
for (auto &callInfo : currInfo->callsFromDetailed)
|
||||
{
|
||||
auto& funcCall = callInfo.detailCallsFrom;
|
||||
auto itCalledFunc = mapFuncInfo.find(funcCall.first);
|
||||
if (itCalledFunc != mapFuncInfo.end())
|
||||
{
|
||||
@@ -375,7 +376,7 @@ string convertToString(const FuncInfo *currFunc)
|
||||
{
|
||||
result += "|" + currFunc->funcName + "|" + to_string(currFunc->linesNum.first) +
|
||||
"#" + to_string(currFunc->linesNum.second) +
|
||||
"#" + to_string(currFunc->detailCallsFrom.size()) +
|
||||
"#" + to_string(currFunc->callsFromDetailed.size()) +
|
||||
"#" + to_string(currFunc->needToInline) + "#" + to_string(currFunc->doNotInline) +
|
||||
"#" + to_string(currFunc->doNotAnalyze) + "#" + to_string((int)currFunc->isMain);
|
||||
|
||||
@@ -389,8 +390,8 @@ string convertToString(const FuncInfo *currFunc)
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < currFunc->detailCallsFrom.size(); ++i)
|
||||
result += "|" + currFunc->detailCallsFrom[i].first + "|" + to_string(currFunc->detailCallsFrom[i].second);
|
||||
for (int i = 0; i < currFunc->callsFromDetailed.size(); ++i)
|
||||
result += "|" + currFunc->callsFromDetailed[i].detailCallsFrom.first + "|" + to_string(currFunc->callsFromDetailed[i].detailCallsFrom.second);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -721,9 +722,9 @@ void createLinksBetweenFormalAndActualParams(map<string, vector<FuncInfo*>> &all
|
||||
//printf("func %s :\n", func->funcName.c_str());
|
||||
const string &name = func->funcName;
|
||||
for (auto &caller : func->callsTo)
|
||||
for (int i = 0; i < caller->detailCallsFrom.size(); ++i)
|
||||
if (caller->detailCallsFrom[i].first == name)
|
||||
addLinks(caller->actualParams[i], func->funcParams, arrayLinksByFuncCalls);
|
||||
for (int i = 0; i < caller->callsFromDetailed.size(); ++i)
|
||||
if (caller->callsFromDetailed[i].detailCallsFrom.first == name)
|
||||
addLinks(caller->callsFromDetailed[i].actualParams, func->funcParams, arrayLinksByFuncCalls);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -822,8 +823,9 @@ bool detectMpiCalls(const map<string, vector<FuncInfo*>>& allFuncInfo, map<strin
|
||||
{
|
||||
for (auto& func : byFile.second)
|
||||
{
|
||||
for (auto& callsFromThis : func->detailCallsFrom)
|
||||
for (auto& callInfo: func->callsFromDetailed)
|
||||
{
|
||||
auto& callsFromThis = callInfo.detailCallsFrom;
|
||||
if (isMpiFunction(callsFromThis.first) && funcByName.find(callsFromThis.first) == funcByName.end())
|
||||
{
|
||||
retVal = true;
|
||||
|
||||
@@ -211,6 +211,40 @@ static inline SgSymbol* createSymbAndDecl(const string& funcName, const string&
|
||||
return newS;
|
||||
}
|
||||
|
||||
static SgStatement* findDuplicateInHidden(SgStatement* data)
|
||||
{
|
||||
SgStatement* clone = NULL;
|
||||
|
||||
auto itF = hiddenData.find(current_file->filename());
|
||||
if (itF == hiddenData.end())
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto& func : itF->second)
|
||||
{
|
||||
if (func->fileName() != string(data->fileName()))
|
||||
continue;
|
||||
|
||||
SgStatement* st = func->lexNext();
|
||||
SgStatement* last = func->lastNodeOfStmt();
|
||||
|
||||
while (st != last)
|
||||
{
|
||||
if (data->lineNumber() == st->lineNumber() && data->variant() == st->variant())
|
||||
{
|
||||
clone = st;
|
||||
break;
|
||||
}
|
||||
st = st->lexNext();
|
||||
}
|
||||
|
||||
if (clone)
|
||||
break;
|
||||
}
|
||||
|
||||
checkNull(clone, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
return clone;
|
||||
}
|
||||
|
||||
static SgValueExp* oneExpr = NULL;
|
||||
static SgValueExp* zeroExpr = NULL;
|
||||
|
||||
@@ -237,11 +271,14 @@ static vector<SgExpression*> getLowBounds(SgSymbol* arrayS)
|
||||
int consistInAllocates = 0;
|
||||
const string origName = OriginalSymbol(copyFrom)->identifier();
|
||||
|
||||
for (auto& data : getAttributes<SgStatement*, SgStatement*>(decl, set<int>{ ALLOCATE_STMT }))
|
||||
for (auto data : getAttributes<SgStatement*, SgStatement*>(decl, set<int>{ ALLOCATE_STMT }))
|
||||
{
|
||||
if (data->variant() != ALLOCATE_STMT)
|
||||
continue;
|
||||
|
||||
if (data->getFileId() != current_file_id)
|
||||
data = findDuplicateInHidden(data);
|
||||
|
||||
SgExpression* iter = data->expr(0);
|
||||
|
||||
while (iter)
|
||||
@@ -1613,8 +1650,9 @@ bool inliner(const string& fileName_in, const string& funcName, const int lineNu
|
||||
{
|
||||
for (auto& callTo : func->callsTo)
|
||||
{
|
||||
for (auto& callFrom : callTo->detailCallsFrom)
|
||||
for (auto& callInfo : callTo->callsFromDetailed)
|
||||
{
|
||||
auto& callFrom = callInfo.detailCallsFrom;
|
||||
if (callFrom.first == funcName)
|
||||
{
|
||||
SgStatement* callSt = SgStatement::getStatementByFileAndLine(fileName, callFrom.second);
|
||||
@@ -1719,8 +1757,9 @@ bool inliner(const string& allInFunc, const map<string, vector<FuncInfo*>>& allF
|
||||
if (SgFile::switchToFile(func->fileName) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto& callFrom : func->detailCallsFrom)
|
||||
for (auto& callInfo : func->callsFromDetailed)
|
||||
{
|
||||
auto& callFrom = callInfo.detailCallsFrom;
|
||||
bool res = inliner(func->fileName, callFrom.first, callFrom.second, allFuncInfo, SPF_messages, newSymbsToDeclare, commonBlocks, deepLvl);
|
||||
result = result && res;
|
||||
}
|
||||
|
||||
@@ -927,20 +927,20 @@ static SgExpression* replaceConstatantProcedurePars(SgExpression *dimList, SgSta
|
||||
for (int z = 0; z < currF->callsTo.size(); ++z)
|
||||
{
|
||||
FuncInfo* callOfThis = currF->callsTo[z];
|
||||
for (int p = 0; p < callOfThis->detailCallsFrom.size(); ++p)
|
||||
for (int p = 0; p < callOfThis->callsFromDetailed.size(); ++p)
|
||||
{
|
||||
if (callOfThis->detailCallsFrom[p].first == procN)
|
||||
if (callOfThis->callsFromDetailed[p].detailCallsFrom.first == procN)
|
||||
{
|
||||
for (auto& par : idxFound)
|
||||
{
|
||||
auto parType = callOfThis->actualParams[p].parametersT[par];
|
||||
auto parType = callOfThis->callsFromDetailed[p].actualParams.parametersT[par];
|
||||
if (parType != SCALAR_INT_T)
|
||||
return dimList;
|
||||
else
|
||||
{
|
||||
if (callOfThis->actualParams[p].parameters[par] == NULL)
|
||||
if (callOfThis->callsFromDetailed[p].actualParams.parameters[par] == NULL)
|
||||
return dimList;
|
||||
values[par].insert(((int*)(callOfThis->actualParams[p].parameters[par]))[0]);
|
||||
values[par].insert(((int*)(callOfThis->callsFromDetailed[p].actualParams.parameters[par]))[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2609,17 +2609,11 @@ static bool findOmpThreadPrivDecl(SgStatement* st, map<SgStatement*, set<string>
|
||||
{
|
||||
st = st->lexNext();
|
||||
|
||||
if (st->variant() == CONTAINS_STMT)
|
||||
break;
|
||||
|
||||
if (isSgExecutableStatement(st))
|
||||
break;
|
||||
|
||||
auto res = parseOmpDirs(st, dummy);
|
||||
for (auto& dir : res)
|
||||
for (auto& var : dir.threadPrivVars)
|
||||
it->second.insert(var);
|
||||
} while (st != lastN);
|
||||
} while (st != lastN && !isSgExecutableStatement(st) && st->variant() != CONTAINS_STMT);
|
||||
}
|
||||
|
||||
if (it->second.find(toFind->identifier()) != it->second.end())
|
||||
@@ -2833,7 +2827,9 @@ static void findArrayRefs(SgExpression *ex, SgStatement *st, string fName, int p
|
||||
const auto oldVal = itNew->second.first->GetDistributeFlagVal();
|
||||
if (oldVal == DIST::DISTR || oldVal == DIST::NO_DISTR)
|
||||
{
|
||||
if (privates.find(symb->identifier()) != privates.end() || itNew->second.first->IsOmpThreadPrivate())
|
||||
if (itNew->second.first->IsOmpThreadPrivate())
|
||||
itNew->second.first->SetDistributeFlag(DIST::SPF_PRIV);
|
||||
else if (privates.find(symb->identifier()) != privates.end())
|
||||
{
|
||||
//check in module
|
||||
if (itNew->second.first->GetLocation().first == DIST::l_MODULE)
|
||||
|
||||
@@ -348,10 +348,12 @@ void fillRegionFunctions(vector<ParallelRegion*> ®ions, const map<string, vec
|
||||
// add DEFAULT region (regionId == 0)
|
||||
if (func->isIndirect())
|
||||
{
|
||||
for (auto &elem : func->detailCallsFrom)
|
||||
for (auto &callInfo : func->callsFromDetailed)
|
||||
{
|
||||
auto line = elem.second;
|
||||
auto call = elem.first;
|
||||
auto& callFrom = callInfo.detailCallsFrom;
|
||||
|
||||
auto line = callFrom.second;
|
||||
auto call = callFrom.first;
|
||||
auto callF = getFuncInfo(funcMap, call);
|
||||
auto regs = getAllRegionsByLine(regions, func->fileName, line).size();
|
||||
if (callF && !getAllRegionsByLine(regions, func->fileName, line).size())
|
||||
|
||||
@@ -1145,6 +1145,11 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
groupActualAndRemote(file, true);
|
||||
else if (curr_regime == RENAME_SYMBOLS)
|
||||
runRenameSymbolsByFiles(file, &project);
|
||||
else if (curr_regime == REMOVE_OMP_DIRS)
|
||||
{
|
||||
for (SgStatement* st = file->firstStatement(); st; st = st->lexNext())
|
||||
removeOmpDir(st);
|
||||
}
|
||||
else if (curr_regime == TEST_PASS)
|
||||
{
|
||||
//test pass
|
||||
@@ -2096,7 +2101,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
set<DIST::Array*> usedArraysInRegions;
|
||||
set<DIST::Array*> usedWriteArraysInRegions;
|
||||
|
||||
set<FuncInfo*> forPure;
|
||||
for (int i = n - 1; i >= 0; --i)
|
||||
{
|
||||
SgFile* file = &(project.file(i));
|
||||
@@ -2129,16 +2133,15 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
//add privates to parallel loops with manual parallelization in DVMH regions
|
||||
regionInserter->addPrivatesToParallelLoops();
|
||||
|
||||
//create interface for 'parallel' functions
|
||||
regionInserter->createInterfaceBlock();
|
||||
|
||||
regionInserter->addUsedArrays(usedArraysInRegions);
|
||||
regionInserter->addUsedWriteArrays(usedWriteArraysInRegions);
|
||||
|
||||
auto parallelFuncs = regionInserter->getParallelFunctions();
|
||||
forPure.insert(parallelFuncs.begin(), parallelFuncs.end());
|
||||
setPureStatus(regionInserter->getParallelFunctions());
|
||||
|
||||
//create interface for 'parallel' functions and
|
||||
// insert ROUTINE directive if needed
|
||||
regionInserter->createInterfaceBlockForParallelFunctions();
|
||||
}
|
||||
setPureStatus(forPure);
|
||||
|
||||
for (auto& regionInserter : inserters)
|
||||
{
|
||||
|
||||
@@ -167,6 +167,7 @@ enum passes {
|
||||
PRIVATE_ANALYSIS_IR,
|
||||
|
||||
FIX_COMMON_BLOCKS,
|
||||
REMOVE_OMP_DIRS,
|
||||
|
||||
TEST_PASS,
|
||||
EMPTY_PASS
|
||||
@@ -339,6 +340,7 @@ static void setPassValues()
|
||||
passNames[PRIVATE_ANALYSIS_IR] = "PRIVATE_ANALYSIS_IR";
|
||||
|
||||
passNames[FIX_COMMON_BLOCKS] = "FIX_COMMON_BLOCKS";
|
||||
passNames[REMOVE_OMP_DIRS] = "REMOVE_OMP_DIRS";
|
||||
|
||||
passNames[TEST_PASS] = "TEST_PASS";
|
||||
}
|
||||
|
||||
@@ -1011,8 +1011,9 @@ void createCheckpoints(SgFile *file, const map<string, CommonBlock*>& commonBloc
|
||||
|
||||
}
|
||||
|
||||
for (auto& call : (j->second)->pointerDetailCallsFrom)
|
||||
for (auto& callInfo : j->second->callsFromDetailed)
|
||||
{
|
||||
auto& call = callInfo.pointerDetailCallsFrom;
|
||||
SgStatement* st = NULL;
|
||||
|
||||
if (isSgFuncHedrStmt(hedrTo) && call.second == FUNC_CALL)
|
||||
|
||||
@@ -429,8 +429,9 @@ static void transferCommons(set<FuncInfo*>& allForChange, map <FuncInfo*, map<st
|
||||
if (SgFile::switchToFile(curFunc->fileName) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto& call : curFunc->pointerDetailCallsFrom)
|
||||
for (auto& callInfo : curFunc->callsFromDetailed)
|
||||
{
|
||||
auto& call = callInfo.pointerDetailCallsFrom;
|
||||
if (isSgFuncHedrStmt(precFunc->funcPointer->GetOriginal()) && call.second == FUNC_CALL)
|
||||
{
|
||||
SgFunctionCallExp* callExp = (SgFunctionCallExp*)call.first;
|
||||
@@ -792,8 +793,9 @@ static void transferSave(map<FuncInfo*, set<FuncInfo*>>& funcAddedVarsFuncs, vec
|
||||
if (SgFile::switchToFile(curFunc->fileName) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
for (auto& call : curFunc->pointerDetailCallsFrom)
|
||||
for (auto& callInfo : curFunc->callsFromDetailed)
|
||||
{
|
||||
auto& call = callInfo.pointerDetailCallsFrom;
|
||||
if (isSgFuncHedrStmt(precFunc->funcPointer->GetOriginal()) && call.second == FUNC_CALL)
|
||||
{
|
||||
SgFunctionCallExp* callExp = (SgFunctionCallExp*)call.first;
|
||||
@@ -1251,8 +1253,9 @@ static void transferModule(map<FuncInfo*, set<SgSymbol*>>& funcAddedVarsMods, se
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& call : curFunc->pointerDetailCallsFrom)
|
||||
for (auto& callInfo : curFunc->callsFromDetailed)
|
||||
{
|
||||
auto& call = callInfo.pointerDetailCallsFrom;
|
||||
if (isSgFuncHedrStmt(precFunc->funcPointer->GetOriginal()) && call.second == FUNC_CALL)
|
||||
{
|
||||
SgFunctionCallExp* callExp = (SgFunctionCallExp*)call.first;
|
||||
|
||||
@@ -885,18 +885,21 @@ static void checkImplicitDirectUsage(Context* ctx, SgExpression* exp, int stmtLi
|
||||
{
|
||||
SgFunctionCallExp* funcCallExp = (SgFunctionCallExp*)exp;
|
||||
string funcName = funcCallExp->funName()->identifier();
|
||||
auto funcInfo = findFunc(ctx->loopStmt->fileName(), funcName, ctx->allFuncInfo);
|
||||
for (int i = 0; i < funcCallExp->numberOfArgs(); ++i)
|
||||
FuncInfo* funcInfo = findFunc(ctx->loopStmt->fileName(), funcName, ctx->allFuncInfo);
|
||||
if (funcInfo != nullptr)
|
||||
{
|
||||
SgExpression* funcArg = funcCallExp->arg(i);
|
||||
if (funcInfo->funcParams.isArgOut(i)
|
||||
&& funcArg->symbol() != nullptr
|
||||
&& isEqSymbols(funcArg->symbol(), ctx->arraySymbol))
|
||||
for (int i = 0; i < funcCallExp->numberOfArgs(); ++i)
|
||||
{
|
||||
auto fixedVec = getFixedSubscriptsVector((SgArrayRefExp*)funcArg, ctx->dimensionsNum);
|
||||
fixedSubscripts.push_back(fixedVec);
|
||||
addMessageUsageInFunctionCall(ctx->messages, getDimensionVarName(ctx->arraySymbol, fixedVec),
|
||||
funcName, ctx->loop->lineNum, stmtLineNum);
|
||||
SgExpression* funcArg = funcCallExp->arg(i);
|
||||
if (funcInfo->funcParams.isArgOut(i)
|
||||
&& funcArg->symbol() != nullptr
|
||||
&& isEqSymbols(funcArg->symbol(), ctx->arraySymbol))
|
||||
{
|
||||
auto fixedVec = getFixedSubscriptsVector((SgArrayRefExp*)funcArg, ctx->dimensionsNum);
|
||||
fixedSubscripts.push_back(fixedVec);
|
||||
addMessageUsageInFunctionCall(ctx->messages, getDimensionVarName(ctx->arraySymbol, fixedVec),
|
||||
funcName, ctx->loop->lineNum, stmtLineNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -937,7 +940,7 @@ static vector<vector<FixedSubscript>> checkImplicitDirectUsage(Context* ctx)
|
||||
if (funcInfo->funcParams.isArgOut(i) || // implicit direct usage
|
||||
callArg->lhs() == nullptr) // reference to whole array
|
||||
{
|
||||
auto& mask = getFixedSubscriptsVector((SgArrayRefExp*)callArg, ctx->dimensionsNum);
|
||||
auto mask = getFixedSubscriptsVector((SgArrayRefExp*)callArg, ctx->dimensionsNum);
|
||||
fixedSubscripts.push_back(mask);
|
||||
addMessageUsageInFunctionCall(ctx->messages, getDimensionVarName(ctx->arraySymbol, mask),
|
||||
procName, ctx->loop->lineNum, st->lineNumber());
|
||||
@@ -994,7 +997,7 @@ static void checkIndirectUsage(Context* ctx, FuncInfo* curFunc, vector<Variable*
|
||||
vector<SgArrayRefExp*> directArrayRefs = getDirectArrayRefs(varUse.getFunction(), varUse.getUseS());
|
||||
for (auto arrayRef : directArrayRefs)
|
||||
{
|
||||
auto& mask = getFixedSubscriptsVector(arrayRef, ctx->dimensionsNum);
|
||||
auto mask = getFixedSubscriptsVector(arrayRef, ctx->dimensionsNum);
|
||||
indirectUsageMasks.push_back(mask);
|
||||
addMessageUsageInFunctionCall(ctx->messages, getDimensionVarName(ctx->arraySymbol, mask),
|
||||
curFunc->funcName, ctx->loop->lineNum, ctx->loop->lineNum);
|
||||
@@ -1231,32 +1234,40 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
||||
{
|
||||
vector<DefUseStmtsPair> defUsePairs;
|
||||
|
||||
for (const InsertedStatement& stmt : insertedStmts)
|
||||
for (const InsertedStatement& useInsertedStmt : insertedStmts)
|
||||
{
|
||||
if (stmt.type != TypeOfInsertedStmt::USE)
|
||||
if (useInsertedStmt.type != TypeOfInsertedStmt::USE) // analysis for USE stmt
|
||||
continue;
|
||||
|
||||
int relLineNum = stmt.relatedToStmt->lineNumber();
|
||||
int useLineNum = useInsertedStmt.relatedToStmt->lineNumber();
|
||||
|
||||
// looking for reaching definitions for the current block:
|
||||
auto useInsAndBlock = getInstructionAndBlockByStatement(CFGraph, stmt.insertedStmt);
|
||||
auto useInsAndBlock = getInstructionAndBlockByStatement(CFGraph, useInsertedStmt.insertedStmt);
|
||||
auto useArg = useInsAndBlock.first->getArg1();
|
||||
const auto& RD_In = useInsAndBlock.second->getRD_In();
|
||||
|
||||
const auto& RD_forUseArg = RD_In.find(useArg);
|
||||
if (RD_forUseArg == RD_In.end()) // cannot find reaching definitions for argument
|
||||
{
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
set<int> RD_defArgs = RD_forUseArg->second; // make copy
|
||||
|
||||
// delete recursive definition from RD def args:
|
||||
for (int defArgNum : RD_defArgs)
|
||||
{
|
||||
if (defArgNum == SAPFOR::CFG_VAL::UNINIT)
|
||||
continue;
|
||||
|
||||
auto defInsAndBlock = getInstructionAndBlockByNumber(CFGraph, defArgNum);
|
||||
if (defInsAndBlock.first == nullptr)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
SgStatement* defStmt = defInsAndBlock.first->getOperator();
|
||||
auto defInsertedStmt = findInsertedStmt(insertedStmts, defStmt);
|
||||
if (stmt.relatedToStmt == defInsertedStmt->relatedToStmt) // recursive definition
|
||||
if (useInsertedStmt.relatedToStmt == defInsertedStmt->relatedToStmt)
|
||||
{
|
||||
RD_defArgs.erase(defArgNum);
|
||||
break;
|
||||
@@ -1265,13 +1276,40 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
||||
|
||||
if (RD_defArgs.size() == 0) // argument is not initialized
|
||||
{
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RD_defArgs.find(SAPFOR::CFG_VAL::UNINIT) != RD_defArgs.end()) // argument is not initialized
|
||||
{
|
||||
bool uninitArgIsOk = false;
|
||||
if (RD_defArgs.size() == 2)
|
||||
{
|
||||
RD_defArgs.erase(SAPFOR::CFG_VAL::UNINIT);
|
||||
int defArgNum = *RD_defArgs.begin();
|
||||
|
||||
auto defInsAndBlock = getInstructionAndBlockByNumber(CFGraph, defArgNum);
|
||||
if (defInsAndBlock.first == nullptr)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
auto defInsertedStmt = findInsertedStmt(insertedStmts, defInsAndBlock.first->getOperator());
|
||||
if (defInsertedStmt->relatedToStmt->lineNumber() < useLineNum &&
|
||||
useInsAndBlock.second->getNumber() == defInsAndBlock.second->getNumber())
|
||||
{
|
||||
uninitArgIsOk = true; // argument isn't really uninitialized
|
||||
}
|
||||
}
|
||||
|
||||
if (!uninitArgIsOk)
|
||||
{
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (RD_defArgs.size() > 1) // more than one reaching definition
|
||||
{
|
||||
addMessageMoreThanOneRD(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageMoreThanOneRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1282,19 +1320,19 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
||||
auto defInsertedStmt = findInsertedStmt(insertedStmts, defStmt);
|
||||
if (defInsertedStmt == insertedStmts.end())
|
||||
{
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageCannotFindRD(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
//don't substitute def stmt into use, if def is recursive
|
||||
if (defInsertedStmt->isRecursive)
|
||||
{
|
||||
addMessageRecursiveDependency(ctx->messages, ctx->arraySymbol->identifier(), relLineNum);
|
||||
addMessageRecursiveDependency(ctx->messages, ctx->arraySymbol->identifier(), useLineNum);
|
||||
continue;
|
||||
}
|
||||
|
||||
SgAssignStmt* def = (SgAssignStmt*)defInsertedStmt->relatedToStmt;
|
||||
SgAssignStmt* use = (SgAssignStmt*)stmt.relatedToStmt;
|
||||
SgAssignStmt* use = (SgAssignStmt*)useInsertedStmt.relatedToStmt;
|
||||
defUsePairs.push_back(make_pair(def, use));
|
||||
}
|
||||
|
||||
@@ -1674,7 +1712,7 @@ void removePrivatesAnalysis(vector<LoopGraph*>& loopGraphs,
|
||||
context.dimensionsNum = getDimension(arrayToRemove);
|
||||
context.arraySymbol = arrayToRemove;
|
||||
|
||||
auto& filterMasks = checkImplicitAndIndirectUsage(&context);
|
||||
auto filterMasks = checkImplicitAndIndirectUsage(&context);
|
||||
filterArrayRefs(&context, arrayRefs, filterMasks);
|
||||
context.explicitArrayRefs.swap(arrayRefs);
|
||||
|
||||
|
||||
@@ -118,15 +118,16 @@ static map<FuncInfo*, callInfo> countOfCalls(const map<string, vector<FuncInfo*>
|
||||
for (auto& elem : fromFile.second)
|
||||
{
|
||||
int p = 0;
|
||||
for (auto& detailed : elem->detailCallsFrom)
|
||||
for (auto& callInfo : elem->callsFromDetailed)
|
||||
{
|
||||
auto& detailed = callInfo.detailCallsFrom;
|
||||
auto it = mapOfFunc.find(detailed.first);
|
||||
if (it != mapOfFunc.end())
|
||||
{
|
||||
auto var = variantCall.find(it->second);
|
||||
auto createPackCall = createParamCalls(elem->pointerDetailCallsFrom[p], elem->fileName);
|
||||
auto createPackCall = createParamCalls(elem->callsFromDetailed[p].pointerDetailCallsFrom, elem->fileName);
|
||||
|
||||
if (checkUniqAndAdd(var->second, createPackCall, elem->pointerDetailCallsFrom[p], elem->parentForPointer[p]))
|
||||
if (checkUniqAndAdd(var->second, createPackCall, elem->callsFromDetailed[p].pointerDetailCallsFrom, elem->callsFromDetailed[p].parentForPointer))
|
||||
count[it->second]++;
|
||||
}
|
||||
++p;
|
||||
@@ -554,9 +555,9 @@ static void copyGroup(const map<string, FuncInfo*> &mapOfFunc, const vector<Func
|
||||
findInterfaceBlockAndDuplicate(func->funcPointer->GetOriginal(), origName, newName, varOfCall);
|
||||
|
||||
// fill additional places to next replaces
|
||||
for (int z = 0; z < currFunc->pointerDetailCallsFrom.size(); ++z)
|
||||
for (int z = 0; z < currFunc->callsFromDetailed.size(); ++z)
|
||||
{
|
||||
pair<void*, int> place = currFunc->pointerDetailCallsFrom[z];
|
||||
pair<void*, int> place = currFunc->callsFromDetailed[z].pointerDetailCallsFrom;
|
||||
if (place.second == PROC_STAT)
|
||||
{
|
||||
SgStatement* proc = (SgStatement*)place.first;
|
||||
@@ -575,12 +576,12 @@ static void copyGroup(const map<string, FuncInfo*> &mapOfFunc, const vector<Func
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
vector<void*> tmp;
|
||||
infoAdd->second.variantCall.push_back(callVars(make_pair(copyPoint, PROC_STAT), tmp, currFunc->parentForPointer[z]));
|
||||
infoAdd->second.variantCall.push_back(callVars(make_pair(copyPoint, PROC_STAT), tmp, currFunc->callsFromDetailed[z].parentForPointer));
|
||||
}
|
||||
else if (place.second == FUNC_CALL)
|
||||
{
|
||||
SgExpression* proc = (SgExpression*)place.first;
|
||||
SgStatement* parent = (SgStatement*)currFunc->parentForPointer[z];
|
||||
SgStatement* parent = (SgStatement*)currFunc->callsFromDetailed[z].parentForPointer;
|
||||
checkNull(parent, convertFileName(__FILE__).c_str(), __LINE__);
|
||||
if (SgFile::switchToFile(parent->fileName()) == -1)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
@@ -597,7 +598,7 @@ static void copyGroup(const map<string, FuncInfo*> &mapOfFunc, const vector<Func
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
vector<void*> tmp;
|
||||
infoAdd->second.variantCall.push_back(callVars(make_pair(copyPoint, FUNC_CALL), tmp, currFunc->parentForPointer[z]));
|
||||
infoAdd->second.variantCall.push_back(callVars(make_pair(copyPoint, FUNC_CALL), tmp, currFunc->callsFromDetailed[z].parentForPointer));
|
||||
}
|
||||
else
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
@@ -232,7 +232,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
list({ GET_ALL_ARRAY_DECL, CALL_GRAPH2, CODE_CHECKER_PASSES, SUBST_EXPR_RD, ARRAY_ACCESS_ANALYSIS_FOR_CORNER }) <= list({ LOOP_ANALYZER_NODIST, LOOP_ANALYZER_DATA_DIST_S0, LOOP_ANALYZER_DATA_DIST_S1, ONLY_ARRAY_GRAPH });
|
||||
|
||||
Pass(LOOP_ANALYZER_NODIST) <= Pass(INSERT_PARALLEL_DIRS_NODIST);
|
||||
list({ LOOP_ANALYZER_NODIST, REMOVE_OMP_DIRS }) <= Pass(INSERT_PARALLEL_DIRS_NODIST);
|
||||
|
||||
Pass(CHECK_ARGS_DECL) <= Pass(CREATE_TEMPLATE_LINKS);
|
||||
|
||||
@@ -262,7 +262,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
list({ PREPROC_SPF, CORRECT_VAR_DECL }) <= Pass(FILL_PAR_REGIONS_LINES);
|
||||
|
||||
Pass(LOOP_ANALYZER_COMP_DIST) <= list({ CREATE_DISTR_DIRS, CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS });
|
||||
list({ LOOP_ANALYZER_COMP_DIST, REMOVE_OMP_DIRS }) <= list({ CREATE_DISTR_DIRS, CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS });
|
||||
|
||||
Pass(CALL_GRAPH2) <= list({ ONLY_ARRAY_GRAPH, CREATE_NESTED_LOOPS, FIND_FUNC_TO_INCLUDE, CHECK_FUNC_TO_INCLUDE, FIND_PARAMETERS });
|
||||
|
||||
|
||||
@@ -402,7 +402,6 @@ string removeIncludeStatsAndUnparse(SgFile *file, const char *fileName, const ch
|
||||
|
||||
for (SgStatement *st = file->firstStatement(); st; st = st->lexNext())
|
||||
{
|
||||
removeOmpDir(st);
|
||||
if (st->lineNumber() <= 0 || st->variant() < 0)
|
||||
continue;
|
||||
string currFileName = st->fileName();
|
||||
@@ -1154,7 +1153,8 @@ bool isDVM_stat(SgStatement *st)
|
||||
(var == DVM_DISTRIBUTE_DIR) ||
|
||||
(var >= HPF_TEMPLATE_STAT && var <= DVM_REDISTRIBUTE_DIR) ||
|
||||
(var >= BLOCK_OP && var <= STAGE_OP) ||
|
||||
(var >= INDIRECT_OP && var <= SHADOW_NAMES_OP))
|
||||
(var >= INDIRECT_OP && var <= SHADOW_NAMES_OP) ||
|
||||
(var >= ACC_REGION_DIR && var <= ACC_ASYNC_OP))
|
||||
ret = true;
|
||||
return ret;
|
||||
}
|
||||
@@ -4218,7 +4218,7 @@ SgProject* createProject(const char* proj_name,
|
||||
|
||||
|
||||
for (int z = 0; z < project->numberOfFiles(); ++z)
|
||||
removeExecutableFromModuleDeclaration(&(project->file(z)), filesInProj);
|
||||
removeExecutableFromModuleDeclaration(&(project->file(z)), filesInProj, hiddenData[project->file(z).filename()]);
|
||||
|
||||
for (int z = 0; z < project->numberOfFiles(); ++z)
|
||||
{
|
||||
|
||||
@@ -532,7 +532,7 @@ static const wchar_t *R197 = L"R197:";
|
||||
//2024
|
||||
static const wchar_t *R198 = L"R198:%d";
|
||||
//2025
|
||||
static const wchar_t *R203 = L"R203:%s%s";
|
||||
static const wchar_t *R203 = L"R203:%s#%s";
|
||||
|
||||
//3001
|
||||
static const wchar_t *R108 = L"R108:%s";
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2228"
|
||||
#define VERSION_SPF "2234"
|
||||
|
||||
@@ -1153,7 +1153,7 @@ void replaceStructuresToSimpleTypes(SgFile *file)
|
||||
}
|
||||
}
|
||||
|
||||
void removeExecutableFromModuleDeclaration(SgFile *current, const set<string> &filesInProj)
|
||||
void removeExecutableFromModuleDeclaration(SgFile *current, const set<string> &filesInProj, vector<SgStatement*>& hiddenData)
|
||||
{
|
||||
const string currF = current->filename();
|
||||
set<string> moduleInFile;
|
||||
@@ -1164,14 +1164,14 @@ void removeExecutableFromModuleDeclaration(SgFile *current, const set<string> &f
|
||||
moduleInFile.insert(st->fileName());
|
||||
}
|
||||
|
||||
vector<SgStatement*> toDel;
|
||||
vector<SgStatement*> toMove;
|
||||
for (SgStatement* st = current->firstStatement(); st; st = st->lexNext())
|
||||
{
|
||||
if (isSgProgHedrStmt(st))
|
||||
if (moduleInFile.find(st->fileName()) != moduleInFile.end())
|
||||
toDel.push_back(st);
|
||||
toMove.push_back(st);
|
||||
}
|
||||
|
||||
for (auto& elem : toDel)
|
||||
elem->deleteStmt();
|
||||
for (auto& elem : toMove)
|
||||
hiddenData.push_back(elem->extractStmt());
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ void replaceDerivedAssigns(SgFile *file, SgStatement *stToCopy, SgStatement *ins
|
||||
bool isDerivedAssign(SgStatement *st);
|
||||
std::map<std::string, SgStatement*> createDerivedTypeDeclMap(SgStatement *forS);
|
||||
void fillUseStatement(SgStatement* st, std::set<std::string>& useMod, std::map<std::string, std::vector<std::pair<SgSymbol*, SgSymbol*>>>& modByUse, std::map<std::string, std::vector<std::pair<SgSymbol*, SgSymbol*>>>& modByUseOnly);
|
||||
void removeExecutableFromModuleDeclaration(SgFile* current, const std::set<std::string>& filesInProj);
|
||||
void removeExecutableFromModuleDeclaration(SgFile* current, const std::set<std::string>& filesInProj, std::vector<SgStatement*>& hiddenData);
|
||||
bool needToReplaceInterfaceName(SgStatement* interf);
|
||||
|
||||
std::string getOrigName(const std::string& file, const std::string& s);
|
||||
@@ -64,8 +64,11 @@ buildLocationOfGraph(const map<string, vector<FuncInfo*>>& allFuncInfo, const in
|
||||
for (auto& elem : mapOfFuncs)
|
||||
{
|
||||
set<string> callsFrom;
|
||||
for (auto& callFrom_ : elem.second->detailCallsFrom)
|
||||
for (auto& callFromInfo : elem.second->callsFromDetailed)
|
||||
{
|
||||
auto& callFrom_ = callFromInfo.detailCallsFrom;
|
||||
callsFrom.insert(callFrom_.first);
|
||||
}
|
||||
callsFrom.insert(elem.second->externalCalls.begin(), elem.second->externalCalls.end());
|
||||
|
||||
for (auto& call : callsFrom)
|
||||
@@ -90,8 +93,11 @@ buildLocationOfGraph(const map<string, vector<FuncInfo*>>& allFuncInfo, const in
|
||||
continue;
|
||||
|
||||
set<string> callsFrom;
|
||||
for (auto& callFrom_ : elem.second->detailCallsFrom)
|
||||
for (auto& callFromInfo : elem.second->callsFromDetailed)
|
||||
{
|
||||
auto& callFrom_ = callFromInfo.detailCallsFrom;
|
||||
callsFrom.insert(callFrom_.first);
|
||||
}
|
||||
callsFrom.insert(elem.second->externalCalls.begin(), elem.second->externalCalls.end());
|
||||
|
||||
for (auto& call : callsFrom)
|
||||
|
||||
Reference in New Issue
Block a user