Compare commits
5 Commits
e658861962
...
eb39f0eeed
| Author | SHA1 | Date | |
|---|---|---|---|
| eb39f0eeed | |||
| 9ba67d2fd6 | |||
| 068a1a1293 | |||
| 7906703f7b | |||
|
|
f3f7368bdc |
@@ -1787,6 +1787,8 @@ public:
|
|||||||
inline SgSymbol *construct_name();
|
inline SgSymbol *construct_name();
|
||||||
inline void replaceTrueBody(SgStatement &s);// new body=s and lex successors.
|
inline void replaceTrueBody(SgStatement &s);// new body=s and lex successors.
|
||||||
inline void replaceFalseBody(SgStatement &s);//new body=s and lex successors.
|
inline void replaceFalseBody(SgStatement &s);//new body=s and lex successors.
|
||||||
|
// added by A.S. Kolganov 12.12.2024
|
||||||
|
inline void setConditional(SgExpression* cond) { BIF_LL1(thebif) = cond->thellnd; }
|
||||||
inline ~SgIfStmt();
|
inline ~SgIfStmt();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ static int has_region, in_arg_list, analyzing, has_max_minloc, for_shadow_comput
|
|||||||
|
|
||||||
static SgStatement *cur_in_block, *cur_in_source, *mod_gpu_end;
|
static SgStatement *cur_in_block, *cur_in_source, *mod_gpu_end;
|
||||||
static SgStatement *call_kernel;
|
static SgStatement *call_kernel;
|
||||||
static SgExpression *dvm_array_list, *do_st_list, *indexing_info_list;
|
static SgExpression *dvm_array_list, *do_st_list, *indexing_info_list, *acc_declared_list;
|
||||||
static SgExpression *argument_list, *base_mem_list, *coeff_list, *gpu_coeff_list, *registered_uses_list;
|
static SgExpression *argument_list, *base_mem_list, *coeff_list, *gpu_coeff_list, *registered_uses_list;
|
||||||
static SgExpression *red_var_list, *formal_red_offset_list, *red_offset_list, *copy_uses_list;
|
static SgExpression *red_var_list, *formal_red_offset_list, *red_offset_list, *copy_uses_list;
|
||||||
static SgConstantSymb *device_const[Ndev], *const_LONG, *intent_const[Nintent], *handler_const[Nhandler];
|
static SgConstantSymb *device_const[Ndev], *const_LONG, *intent_const[Nintent], *handler_const[Nhandler];
|
||||||
@@ -288,6 +288,7 @@ void InitializeInFuncACC()
|
|||||||
acc_return_list = NULL; /*ACC*/
|
acc_return_list = NULL; /*ACC*/
|
||||||
acc_registered_list = NULL; /*ACC*/
|
acc_registered_list = NULL; /*ACC*/
|
||||||
registered_uses_list = NULL; /*ACC*/
|
registered_uses_list = NULL; /*ACC*/
|
||||||
|
acc_declared_list = NULL; /*ACC*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int GeneratedForCuda()
|
int GeneratedForCuda()
|
||||||
@@ -977,6 +978,8 @@ void DeclareVarGPU(SgStatement *lstat, SgType *tlen)
|
|||||||
/************************************************************************************/
|
/************************************************************************************/
|
||||||
void EnterDataRegionForAllocated(SgStatement *stmt)
|
void EnterDataRegionForAllocated(SgStatement *stmt)
|
||||||
{SgExpression *al;
|
{SgExpression *al;
|
||||||
|
if(!ACC_program)
|
||||||
|
return;
|
||||||
for(al=stmt->expr(0); al; al=al->rhs())
|
for(al=stmt->expr(0); al; al=al->rhs())
|
||||||
EnterDataRegion(al->lhs(),stmt);
|
EnterDataRegion(al->lhs(),stmt);
|
||||||
|
|
||||||
@@ -1044,7 +1047,7 @@ void UnregisterVariables(int begin_block)
|
|||||||
{
|
{
|
||||||
stmt_list *stl;
|
stmt_list *stl;
|
||||||
int is;
|
int is;
|
||||||
if (IN_MAIN_PROGRAM)
|
if (!ACC_program || IN_MAIN_PROGRAM)
|
||||||
return;
|
return;
|
||||||
for (stl = acc_return_list; stl; stl = stl->next)
|
for (stl = acc_return_list; stl; stl = stl->next)
|
||||||
{
|
{
|
||||||
@@ -1101,6 +1104,15 @@ void DeclareDataRegionSaveVariables(SgStatement *lstat, SgType *tlen)
|
|||||||
if (attr)
|
if (attr)
|
||||||
DeclareVariableWithInitialization (*attr, tlen, lstat);
|
DeclareVariableWithInitialization (*attr, tlen, lstat);
|
||||||
}
|
}
|
||||||
|
for (el = acc_declared_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
symb = el->lhs()->symbol();
|
||||||
|
if (!(IS_ARRAY(symb)) || isInExprList(el->lhs(), registered_uses_list) || isInSymbList(symb, acc_registered_list))
|
||||||
|
continue;
|
||||||
|
SgSymbol **attr = (SgSymbol **)(symb)->attributeValue(0,DATA_REGION_SYMB);
|
||||||
|
if (attr)
|
||||||
|
DeclareVariableWithInitialization (*attr, tlen, lstat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SgSymbol *DataRegionVar(SgSymbol *symb)
|
SgSymbol *DataRegionVar(SgSymbol *symb)
|
||||||
@@ -1124,9 +1136,9 @@ void EnterDataRegionForLocalVariables(SgStatement *st, SgStatement *first_exec,
|
|||||||
{
|
{
|
||||||
if (!el->lhs()) continue;
|
if (!el->lhs()) continue;
|
||||||
SgSymbol *sym = el->lhs()->symbol();
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
if (sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT)) // //!(el->lhs()->symbol()->attributes() & PARAMETER_BIT) )
|
if (IS_ARRAY(sym) && sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT)) // //!(el->lhs()->symbol()->attributes() & PARAMETER_BIT) )
|
||||||
{
|
{
|
||||||
if ((HAS_SAVE_ATTR(sym) || IN_DATA(sym)) && IS_ARRAY(sym))
|
if (HAS_SAVE_ATTR(sym) || IN_DATA(sym))
|
||||||
newst = doIfThenForDataRegion(DataRegionVar(sym), st, DataEnter(new SgVarRefExp(sym),ConstRef(0)));
|
newst = doIfThenForDataRegion(DataRegionVar(sym), st, DataEnter(new SgVarRefExp(sym),ConstRef(0)));
|
||||||
else
|
else
|
||||||
st->insertStmtAfter(*(newst=DataEnter(new SgVarRefExp(sym),ConstRef(0))),*st->controlParent());
|
st->insertStmtAfter(*(newst=DataEnter(new SgVarRefExp(sym),ConstRef(0))),*st->controlParent());
|
||||||
@@ -1134,14 +1146,30 @@ void EnterDataRegionForLocalVariables(SgStatement *st, SgStatement *first_exec,
|
|||||||
}
|
}
|
||||||
for (sl = acc_registered_list; sl; sl = sl->next)
|
for (sl = acc_registered_list; sl; sl = sl->next)
|
||||||
{
|
{
|
||||||
if (sl->symb->variant() != CONST_NAME && IS_LOCAL_VAR(sl->symb) && !IS_ALLOCATABLE(sl->symb) && !IS_POINTER_F90(sl->symb) && !HEADER(sl->symb)) //!(sl->symb->attributes() & PARAMETER_BIT))
|
if (IS_ARRAY(sl->symb) && sl->symb->variant() != CONST_NAME && IS_LOCAL_VAR(sl->symb) && !IS_ALLOCATABLE(sl->symb) && !IS_POINTER_F90(sl->symb) && !HEADER(sl->symb)) //!(sl->symb->attributes() & PARAMETER_BIT))
|
||||||
{
|
{
|
||||||
if ((HAS_SAVE_ATTR(sl->symb) || IN_DATA(sl->symb)) && IS_ARRAY(sl->symb))
|
if (HAS_SAVE_ATTR(sl->symb) || IN_DATA(sl->symb))
|
||||||
newst = doIfThenForDataRegion(DataRegionVar(sl->symb), st, DataEnter(new SgVarRefExp(sl->symb),ConstRef(0)));
|
newst = doIfThenForDataRegion(DataRegionVar(sl->symb), st, DataEnter(new SgVarRefExp(sl->symb),ConstRef(0)));
|
||||||
else
|
else
|
||||||
st->insertStmtAfter(*(newst=DataEnter(new SgVarRefExp(sl->symb),ConstRef(0))),*st->controlParent());
|
st->insertStmtAfter(*(newst=DataEnter(new SgVarRefExp(sl->symb),ConstRef(0))),*st->controlParent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (el = acc_declared_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
|
if (!IS_ARRAY(sym) || isInExprList(el->lhs(), registered_uses_list) || isInSymbList(sym, acc_registered_list))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT) && !HEADER(sym))
|
||||||
|
{
|
||||||
|
if (HAS_SAVE_ATTR(sym) || IN_DATA(sym))
|
||||||
|
newst = doIfThenForDataRegion(DataRegionVar(sym), st, DataEnter(new SgVarRefExp(sym),ConstRef(0)));
|
||||||
|
else
|
||||||
|
st->insertStmtAfter(*(newst=DataEnter(new SgVarRefExp(sym),ConstRef(0))),*st->controlParent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (newst && !begin_block)
|
if (newst && !begin_block)
|
||||||
LINE_NUMBER_AFTER(first_exec,st);
|
LINE_NUMBER_AFTER(first_exec,st);
|
||||||
}
|
}
|
||||||
@@ -1155,9 +1183,9 @@ void ExitDataRegionForLocalVariables(SgStatement *st, int is)
|
|||||||
{
|
{
|
||||||
if (!el->lhs()) continue;
|
if (!el->lhs()) continue;
|
||||||
SgSymbol *sym = el->lhs()->symbol();
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
if (sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT)) // //!(el->lhs()->symbol()->attributes() & PARAMETER_BIT) )
|
if (IS_ARRAY(sym) && sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT)) // //!(el->lhs()->symbol()->attributes() & PARAMETER_BIT) )
|
||||||
{
|
{
|
||||||
if ((HAS_SAVE_ATTR(sym) || IN_DATA(sym)) && IS_ARRAY(sym))
|
if (HAS_SAVE_ATTR(sym) || IN_DATA(sym))
|
||||||
continue;
|
continue;
|
||||||
if (!is++)
|
if (!is++)
|
||||||
LINE_NUMBER_BEFORE(st,st);
|
LINE_NUMBER_BEFORE(st,st);
|
||||||
@@ -1166,18 +1194,71 @@ void ExitDataRegionForLocalVariables(SgStatement *st, int is)
|
|||||||
}
|
}
|
||||||
for (sl = acc_registered_list; sl; sl = sl->next)
|
for (sl = acc_registered_list; sl; sl = sl->next)
|
||||||
{
|
{
|
||||||
if (sl->symb->variant() != CONST_NAME && IS_LOCAL_VAR(sl->symb) && !IS_ALLOCATABLE(sl->symb) && !IS_POINTER_F90(sl->symb) && !HEADER(sl->symb)) //!(sl->symb->attributes() & PARAMETER_BIT))
|
if (IS_ARRAY(sl->symb) && sl->symb->variant() != CONST_NAME && IS_LOCAL_VAR(sl->symb) && !IS_ALLOCATABLE(sl->symb) && !IS_POINTER_F90(sl->symb) && !HEADER(sl->symb)) //!(sl->symb->attributes() & PARAMETER_BIT))
|
||||||
{
|
{
|
||||||
if ((HAS_SAVE_ATTR(sl->symb) || IN_DATA(sl->symb)) && IS_ARRAY(sl->symb))
|
if (HAS_SAVE_ATTR(sl->symb) || IN_DATA(sl->symb))
|
||||||
continue;
|
continue;
|
||||||
if (!is++)
|
if (!is++)
|
||||||
LINE_NUMBER_BEFORE(st,st);
|
LINE_NUMBER_BEFORE(st,st);
|
||||||
InsertNewStatementBefore(DataExit(new SgVarRefExp(sl->symb),0),st);
|
InsertNewStatementBefore(DataExit(new SgVarRefExp(sl->symb),0),st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (el = acc_declared_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
if (!el->lhs()) continue;
|
||||||
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
|
if (!IS_ARRAY(sym) || isInExprList(el->lhs(), registered_uses_list) || isInSymbList(sym, acc_registered_list))
|
||||||
|
continue;
|
||||||
|
if (sym->variant() != CONST_NAME && IS_LOCAL_VAR(sym) && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT) && !HEADER(sym))
|
||||||
|
{
|
||||||
|
if (HAS_SAVE_ATTR(sym) || IN_DATA(sym))
|
||||||
|
continue;
|
||||||
|
if (!is++)
|
||||||
|
LINE_NUMBER_BEFORE(st,st);
|
||||||
|
InsertNewStatementBefore(DataExit(new SgVarRefExp(sym),0),st);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void testScopeOfDeclaredVariables(SgStatement *stmt)
|
||||||
|
{
|
||||||
|
SgExpression *el;
|
||||||
|
for (el = stmt->expr(0); el; el = el->rhs())
|
||||||
|
{
|
||||||
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
|
if (!IS_LOCAL_VAR(sym))
|
||||||
|
Error("Non-local data object in DECLARE directive: %s", sym->identifier(), 668, stmt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDeclareDirectives(SgStatement *first_dvm_exec)
|
||||||
|
{
|
||||||
|
SgStatement *stmt;
|
||||||
|
for (stmt = cur_func->lexNext(); stmt && (stmt != first_dvm_exec); stmt = stmt->lastNodeOfStmt()->lexNext())
|
||||||
|
{
|
||||||
|
if (stmt->variant()==ACC_DECLARE_DIR)
|
||||||
|
{
|
||||||
|
if (IN_MODULE)
|
||||||
|
err("Illegal directive in module", 632, stmt);
|
||||||
|
else if (!IN_MAIN_PROGRAM)
|
||||||
|
testScopeOfDeclaredVariables(stmt);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// eliminating duplicate objects from the acc_declared_list
|
||||||
|
SgExpression *el, *el2, *prev;
|
||||||
|
for (el = acc_declared_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
for (el2 = el->rhs(), prev = el; el2; )
|
||||||
|
if (ORIGINAL_SYMBOL(el->lhs()->symbol()) == ORIGINAL_SYMBOL(el2->lhs()->symbol()))
|
||||||
|
{ prev->setRhs(el2->rhs()); el2 = el2->rhs(); }
|
||||||
|
else
|
||||||
|
{ prev = el2; el2 = el2->rhs(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ExtractCopy(SgExpression *elist)
|
void ExtractCopy(SgExpression *elist)
|
||||||
{
|
{
|
||||||
SgExpression *el;
|
SgExpression *el;
|
||||||
@@ -1204,6 +1285,8 @@ void CleanAllocatedList()
|
|||||||
int ExitDataRegionForAllocated(SgStatement *st,int begin_block)
|
int ExitDataRegionForAllocated(SgStatement *st,int begin_block)
|
||||||
{
|
{
|
||||||
SgExpression *el;
|
SgExpression *el;
|
||||||
|
if (!ACC_program)
|
||||||
|
return(0);
|
||||||
|
|
||||||
if (TestLocal(allocated_list))
|
if (TestLocal(allocated_list))
|
||||||
{
|
{
|
||||||
@@ -1251,6 +1334,7 @@ int hasSameOriginalName(SgSymbol *s)
|
|||||||
|
|
||||||
void EnterDataRegionForVariablesInMainProgram(SgStatement *st)
|
void EnterDataRegionForVariablesInMainProgram(SgStatement *st)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
symb_list *sl;
|
symb_list *sl;
|
||||||
SgSymbol *s;
|
SgSymbol *s;
|
||||||
for(sl=registration; sl; sl=sl->next)
|
for(sl=registration; sl; sl=sl->next)
|
||||||
@@ -1266,10 +1350,34 @@ void EnterDataRegionForVariablesInMainProgram(SgStatement *st)
|
|||||||
st->insertStmtAfter(*DataEnter(new SgVarRefExp(s),ConstRef(0)),*st->controlParent());
|
st->insertStmtAfter(*DataEnter(new SgVarRefExp(s),ConstRef(0)),*st->controlParent());
|
||||||
s = s->next();
|
s = s->next();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
SgExpression *el;
|
||||||
|
symb_list *sl;
|
||||||
|
for (el = registered_uses_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
|
if (IS_ARRAY(sym) && sym->variant() != CONST_NAME && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT))
|
||||||
|
st->insertStmtAfter(*DataEnter(new SgVarRefExp(sym),ConstRef(0)),*st->controlParent());
|
||||||
|
}
|
||||||
|
for (sl = acc_registered_list; sl; sl = sl->next)
|
||||||
|
{
|
||||||
|
if (sl->symb->variant() != CONST_NAME && !IS_ALLOCATABLE(sl->symb) && !IS_POINTER_F90(sl->symb) && !HEADER(sl->symb))
|
||||||
|
st->insertStmtAfter(*DataEnter(new SgVarRefExp(sl->symb),ConstRef(0)),*st->controlParent());
|
||||||
|
}
|
||||||
|
for (el = acc_declared_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
|
if (!IS_ARRAY(sym) || isInExprList(el->lhs(), registered_uses_list) || isInSymbList(sym, acc_registered_list))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (sym->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !HEADER(sym) && !(sym->attributes() & HEAP_BIT))
|
||||||
|
st->insertStmtAfter(*DataEnter(new SgVarRefExp(sym),ConstRef(0)),*st->controlParent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExitDataRegionForVariablesInMainProgram(SgStatement *st)
|
void ExitDataRegionForVariablesInMainProgram(SgStatement *st)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
symb_list *sl;
|
symb_list *sl;
|
||||||
SgSymbol *s;
|
SgSymbol *s;
|
||||||
for(sl=registration; sl; sl=sl->next)
|
for(sl=registration; sl; sl=sl->next)
|
||||||
@@ -1286,6 +1394,37 @@ void ExitDataRegionForVariablesInMainProgram(SgStatement *st)
|
|||||||
InsertNewStatementBefore(DataExit(new SgVarRefExp(s),0),st);
|
InsertNewStatementBefore(DataExit(new SgVarRefExp(s),0),st);
|
||||||
s = s->next();
|
s = s->next();
|
||||||
}
|
}
|
||||||
|
SgSymbol *s;
|
||||||
|
SgExpression *el;
|
||||||
|
for (el = acc_declared_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
s = el->lhs()->symbol();
|
||||||
|
if (IS_ARRAY(s) && s->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(s) && !IS_POINTER_F90(s) && !HEADER(s) && !(s->attributes() & HEAP_BIT))
|
||||||
|
InsertNewStatementBefore(DataExit(new SgVarRefExp(s),0),st);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
SgExpression *el;
|
||||||
|
symb_list *sl;
|
||||||
|
for (el = registered_uses_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
|
if (IS_ARRAY(sym) && sym->variant() != CONST_NAME && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !(sym->attributes() & HEAP_BIT))
|
||||||
|
InsertNewStatementBefore(DataExit(new SgVarRefExp(sym),0),st);
|
||||||
|
}
|
||||||
|
for (sl = acc_registered_list; sl; sl = sl->next)
|
||||||
|
{
|
||||||
|
if (sl->symb->variant() != CONST_NAME && !IS_ALLOCATABLE(sl->symb) && !IS_POINTER_F90(sl->symb) && !HEADER(sl->symb))
|
||||||
|
InsertNewStatementBefore(DataExit(new SgVarRefExp(sl->symb),0),st);
|
||||||
|
}
|
||||||
|
for (el = acc_declared_list; el; el = el->rhs())
|
||||||
|
{
|
||||||
|
SgSymbol *sym = el->lhs()->symbol();
|
||||||
|
if (!IS_ARRAY(sym) || isInExprList(el->lhs(), registered_uses_list) || isInSymbList(sym, acc_registered_list))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (sym->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(sym) && !IS_POINTER_F90(sym) && !HEADER(sym) && !(sym->attributes() & HEAP_BIT))
|
||||||
|
InsertNewStatementBefore(DataExit(new SgVarRefExp(sym),0),st);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
@@ -1345,9 +1484,15 @@ SgStatement *ACC_Directive(SgStatement *stmt)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACC_DECLARE_Directive(SgStatement *stmt)
|
||||||
|
{
|
||||||
|
if (ACC_program)
|
||||||
|
acc_declared_list = ExpressionListsUnion(acc_declared_list, &(stmt->expr(0)->copy()));
|
||||||
|
}
|
||||||
|
|
||||||
void ACC_ROUTINE_Directive(SgStatement *stmt)
|
void ACC_ROUTINE_Directive(SgStatement *stmt)
|
||||||
{
|
{
|
||||||
if( options.isOn(NO_CUDA) )
|
if(!ACC_program || options.isOn(NO_CUDA) )
|
||||||
return;
|
return;
|
||||||
int control_variant = stmt->controlParent()->controlParent()->variant();
|
int control_variant = stmt->controlParent()->controlParent()->variant();
|
||||||
if (control_variant == INTERFACE_STMT || control_variant == INTERFACE_OPERATOR || control_variant == INTERFACE_ASSIGNMENT)
|
if (control_variant == INTERFACE_STMT || control_variant == INTERFACE_OPERATOR || control_variant == INTERFACE_ASSIGNMENT)
|
||||||
@@ -1658,11 +1803,8 @@ SgStatement *ACC_REGION_Directive(SgStatement *stmt)
|
|||||||
|
|
||||||
|
|
||||||
// creating lists of registered variables in procedure
|
// creating lists of registered variables in procedure
|
||||||
if (!IN_MAIN_PROGRAM)
|
|
||||||
{
|
|
||||||
acc_registered_list = SymbolListsUnion(acc_registered_list, acc_array_list);
|
acc_registered_list = SymbolListsUnion(acc_registered_list, acc_array_list);
|
||||||
registered_uses_list = ExpressionListsUnion(registered_uses_list, uses_list);
|
registered_uses_list = ExpressionListsUnion(registered_uses_list, uses_list);
|
||||||
}
|
|
||||||
|
|
||||||
return(cur_st);
|
return(cur_st);
|
||||||
}
|
}
|
||||||
@@ -10664,7 +10806,18 @@ void ReductionBlockInKernel_On_C_Cuda(SgStatement *stat, SgSymbol *i_var, SgExpr
|
|||||||
|
|
||||||
stat->insertStmtBefore(*new SgCExpStmt(*fun_ref), *stat->controlParent());
|
stat->insertStmtBefore(*new SgCExpStmt(*fun_ref), *stat->controlParent());
|
||||||
|
|
||||||
|
if (across)
|
||||||
{
|
{
|
||||||
|
newst = AssignStatement(new SgArrayRefExp(*rsl->red_grid, *ex), new SgVarRefExp(rsl->redvar));
|
||||||
|
|
||||||
|
SgExpression* cond = if_st->conditional();
|
||||||
|
int redVar = RedFuncNumber(ered->lhs());
|
||||||
|
if (redVar == 9) // maxloc
|
||||||
|
cond = &(*cond && (*new SgVarRefExp(rsl->redvar) > *new SgArrayRefExp(*rsl->red_grid, *ex)));
|
||||||
|
else if (redVar == 10) // minloc
|
||||||
|
cond = &(*cond && (*new SgVarRefExp(rsl->redvar) < *new SgArrayRefExp(*rsl->red_grid, *ex)));
|
||||||
|
|
||||||
|
if_st->setConditional(cond);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
newst = AssignStatement(new SgArrayRefExp(*rsl->red_grid, *BlockIdxRefExpr("x") * *ex1 + *ex), new SgVarRefExp(rsl->redvar));
|
newst = AssignStatement(new SgArrayRefExp(*rsl->red_grid, *BlockIdxRefExpr("x") * *ex1 + *ex), new SgVarRefExp(rsl->redvar));
|
||||||
|
|||||||
@@ -5923,7 +5923,11 @@ SgStatement *CreateLoopKernelAcross(SgSymbol *skernel, ArgsForKernel* argsKer, i
|
|||||||
else if (num == 9 || num == 10)
|
else if (num == 9 || num == 10)
|
||||||
{
|
{
|
||||||
st = AssignStatement(*new SgArrayRefExp(*redGrid, *e1), red_expr_ref->copy());
|
st = AssignStatement(*new SgArrayRefExp(*redGrid, *e1), red_expr_ref->copy());
|
||||||
ifSt = new SgIfStmt(red_expr_ref->copy() > *new SgArrayRefExp(*redGrid, *e1), *st);
|
if (num == 9)
|
||||||
|
ifSt = new SgIfStmt(red_expr_ref->copy() > *new SgArrayRefExp(*redGrid, *e1), *st);
|
||||||
|
else
|
||||||
|
ifSt = new SgIfStmt(red_expr_ref->copy() < *new SgArrayRefExp(*redGrid, *e1), *st);
|
||||||
|
|
||||||
for (int i = loc_el_num - 1; i >= 0; i--)
|
for (int i = loc_el_num - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
SgSymbol *locGrid = new SgSymbol(VARIABLE_NAME, tmp_list->loc_grid->identifier());
|
SgSymbol *locGrid = new SgSymbol(VARIABLE_NAME, tmp_list->loc_grid->identifier());
|
||||||
|
|||||||
@@ -2191,6 +2191,9 @@ void TransFunc(SgStatement *func,SgStatement* &end_of_unit) {
|
|||||||
case(ACC_ROUTINE_DIR):
|
case(ACC_ROUTINE_DIR):
|
||||||
ACC_ROUTINE_Directive(stmt);
|
ACC_ROUTINE_Directive(stmt);
|
||||||
continue;
|
continue;
|
||||||
|
case(ACC_DECLARE_DIR):
|
||||||
|
ACC_DECLARE_Directive(stmt);
|
||||||
|
continue;
|
||||||
case(HPF_TEMPLATE_STAT):
|
case(HPF_TEMPLATE_STAT):
|
||||||
if(IN_MODULE && stmt->expr(1))
|
if(IN_MODULE && stmt->expr(1))
|
||||||
err("Illegal directive in module",632,stmt);
|
err("Illegal directive in module",632,stmt);
|
||||||
@@ -2679,6 +2682,8 @@ void TransFunc(SgStatement *func,SgStatement* &end_of_unit) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// checking semantics of DECLARE directives
|
||||||
|
testDeclareDirectives(stmt);
|
||||||
|
|
||||||
if(pstmt && (stmt != last))
|
if(pstmt && (stmt != last))
|
||||||
pstmt = pstmt->next; //deleting first executable statement from
|
pstmt = pstmt->next; //deleting first executable statement from
|
||||||
@@ -4239,7 +4244,6 @@ END_: // end of program unit
|
|||||||
if(last_dvm_entry)
|
if(last_dvm_entry)
|
||||||
lentry = last_dvm_entry->lexNext(); // lentry - statement following first_dvm_exec or last generated dvm-initialization statement(before first_exec)
|
lentry = last_dvm_entry->lexNext(); // lentry - statement following first_dvm_exec or last generated dvm-initialization statement(before first_exec)
|
||||||
// before first_exec may be new statements generated for first_exec
|
// before first_exec may be new statements generated for first_exec
|
||||||
|
|
||||||
if(!IN_MODULE) {
|
if(!IN_MODULE) {
|
||||||
if(has_contains)
|
if(has_contains)
|
||||||
MarkCoeffsAsUsed();
|
MarkCoeffsAsUsed();
|
||||||
@@ -5294,7 +5298,8 @@ void DEALLOCATEf90_arrays(SgStatement *stmt)
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
{ apr = al;
|
{ apr = al;
|
||||||
InsertNewStatementAfter(DataExit(&al->lhs()->copy(),0),cur_st,stmt->controlParent()); /*26.10.17*/
|
if(ACC_program) /*ACC*/
|
||||||
|
InsertNewStatementAfter(DataExit(&al->lhs()->copy(),0),cur_st,stmt->controlParent()); /*26.10.17*/
|
||||||
//if(ACC_program) /*ACC*/
|
//if(ACC_program) /*ACC*/
|
||||||
// InsertNewStatementAfter(DestroyScalar(&al->lhs()->copy()),cur_st,stmt->controlParent());
|
// InsertNewStatementAfter(DestroyScalar(&al->lhs()->copy()),cur_st,stmt->controlParent());
|
||||||
//doCallAfter(DataExit(&al->lhs()->copy(),0)); /*ACC*/
|
//doCallAfter(DataExit(&al->lhs()->copy(),0)); /*ACC*/
|
||||||
@@ -10600,6 +10605,7 @@ void InsertDebugStat(SgStatement *func, SgStatement* &end_of_unit)
|
|||||||
pstmt = addToStmtList(pstmt, stmt);
|
pstmt = addToStmtList(pstmt, stmt);
|
||||||
continue;
|
continue;
|
||||||
case(ACC_ROUTINE_DIR):
|
case(ACC_ROUTINE_DIR):
|
||||||
|
case(ACC_DECLARE_DIR):
|
||||||
case(HPF_PROCESSORS_STAT):
|
case(HPF_PROCESSORS_STAT):
|
||||||
case(HPF_TEMPLATE_STAT):
|
case(HPF_TEMPLATE_STAT):
|
||||||
case(DVM_DYNAMIC_DIR):
|
case(DVM_DYNAMIC_DIR):
|
||||||
@@ -13760,6 +13766,7 @@ SgStatement *InterfaceBody(SgStatement *hedr)
|
|||||||
case (DVM_POINTER_DIR):
|
case (DVM_POINTER_DIR):
|
||||||
case (DVM_HEAP_DIR):
|
case (DVM_HEAP_DIR):
|
||||||
case (DVM_ASYNCID_DIR):
|
case (DVM_ASYNCID_DIR):
|
||||||
|
case (ACC_DECLARE_DIR):
|
||||||
dvm_pred = stmt;
|
dvm_pred = stmt;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1453,6 +1453,8 @@ SgExpression *CreatePrivateDummyList();
|
|||||||
SgExpression *CreatePrivateDummyList();
|
SgExpression *CreatePrivateDummyList();
|
||||||
char *PointerNameForPrivateArray(SgSymbol *symb);
|
char *PointerNameForPrivateArray(SgSymbol *symb);
|
||||||
void GetMemoryForPrivateArrays(SgSymbol *private_first, SgSymbol *s_loop_ref, int nump, SgStatement *st_end, SgStatement *st_hedr, SgExpression *e_totalThreads);
|
void GetMemoryForPrivateArrays(SgSymbol *private_first, SgSymbol *s_loop_ref, int nump, SgStatement *st_end, SgStatement *st_hedr, SgExpression *e_totalThreads);
|
||||||
|
SgSymbol *LocRedVariableSymbolInKernel(reduction_operation_list *rsl);
|
||||||
|
void testDeclareDirectives(SgStatement *first_dvm_exec);
|
||||||
void ACC_DECLARE_Directive(SgStatement *stmt);
|
void ACC_DECLARE_Directive(SgStatement *stmt);
|
||||||
|
|
||||||
/* acc_analyzer.cpp */
|
/* acc_analyzer.cpp */
|
||||||
|
|||||||
@@ -1345,11 +1345,16 @@ body:/* if(newname) {
|
|||||||
{ prefix[5]=BLANKC; *endcd++ = '\0';}
|
{ prefix[5]=BLANKC; *endcd++ = '\0';}
|
||||||
else
|
else
|
||||||
*endcd++ = '\0'; /* put NULL char in buffer as end marker */
|
*endcd++ = '\0'; /* put NULL char in buffer as end marker */
|
||||||
if((c==';') && (char_cntx==0)) {
|
stmt_end: if((c==';') && (char_cntx==0)) {
|
||||||
restcd = bend - endcd;
|
restcd = bend - endcd;
|
||||||
while( ((c = getc(infile)) == ';') || (c == ' '))
|
while( ((c = getc(infile)) == ';') || (c == ' '))
|
||||||
restcd--;
|
restcd--;
|
||||||
(void) ungetc(c,infile);
|
if(c == '!') { /* delimiter ';' is ignored before comment */
|
||||||
|
restcd = 0;
|
||||||
|
goto stmt_end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
(void) ungetc(c,infile);
|
||||||
}
|
}
|
||||||
else if((c=='!') && (char_cntx==0)) {
|
else if((c=='!') && (char_cntx==0)) {
|
||||||
cmt = tempbuf;
|
cmt = tempbuf;
|
||||||
@@ -1615,11 +1620,16 @@ body: /* Read body of line */
|
|||||||
/*('\r\n' is end line marker in Windows) */
|
/*('\r\n' is end line marker in Windows) */
|
||||||
else
|
else
|
||||||
*endcd++ = '\0'; /* put NULL char in buffer as end marker */
|
*endcd++ = '\0'; /* put NULL char in buffer as end marker */
|
||||||
if((c==';') && (char_cntx==0)) {
|
stmt_end: if((c==';') && (char_cntx==0)) {
|
||||||
restcd = 1;
|
restcd = 1;
|
||||||
while( ((c = getc(infile)) == ';') || (c == ' '))
|
while( ((c = getc(infile)) == ';') || (c == ' '))
|
||||||
;
|
;
|
||||||
(void) ungetc(c,infile);
|
if(c == '!') { /* delimiter ';' is ignored before comment */
|
||||||
|
restcd = 0;
|
||||||
|
goto stmt_end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
(void) ungetc(c,infile);
|
||||||
}
|
}
|
||||||
else if((c=='!') && (char_cntx==0)) {
|
else if((c=='!') && (char_cntx==0)) {
|
||||||
cmt = tempbuf;
|
cmt = tempbuf;
|
||||||
|
|||||||
@@ -126,7 +126,9 @@ set(OMEGA _src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
|||||||
_src/SageAnalysisTool/set.cpp)
|
_src/SageAnalysisTool/set.cpp)
|
||||||
|
|
||||||
set(PRIV _src/PrivateAnalyzer/private_analyzer.cpp
|
set(PRIV _src/PrivateAnalyzer/private_analyzer.cpp
|
||||||
_src/PrivateAnalyzer/private_analyzer.h)
|
_src/PrivateAnalyzer/private_analyzer.h
|
||||||
|
_src/PrivateAnalyzer/private_arrays_search.cpp
|
||||||
|
_src/PrivateAnalyzer/private_arrays_search.h)
|
||||||
|
|
||||||
set(FDVM ${fdvm_sources}/acc.cpp
|
set(FDVM ${fdvm_sources}/acc.cpp
|
||||||
${fdvm_sources}/acc_across.cpp
|
${fdvm_sources}/acc_across.cpp
|
||||||
@@ -196,6 +198,7 @@ set(TR_IMPLICIT_NONE _src/Transformations/set_implicit_none.cpp
|
|||||||
set(TR_REPLACE_ARRAYS_IN_IO _src/Transformations/replace_dist_arrays_in_io.cpp
|
set(TR_REPLACE_ARRAYS_IN_IO _src/Transformations/replace_dist_arrays_in_io.cpp
|
||||||
_src/Transformations/replace_dist_arrays_in_io.h)
|
_src/Transformations/replace_dist_arrays_in_io.h)
|
||||||
|
|
||||||
|
|
||||||
set(TRANSFORMS
|
set(TRANSFORMS
|
||||||
${TR_DEAD_CODE}
|
${TR_DEAD_CODE}
|
||||||
${TR_CP}
|
${TR_CP}
|
||||||
@@ -477,6 +480,7 @@ source_group (Parser FILES ${PARSER})
|
|||||||
source_group (PPPA\\PPPA FILES ${PPPA})
|
source_group (PPPA\\PPPA FILES ${PPPA})
|
||||||
source_group (PPPA\\ZLib FILES ${ZLIB})
|
source_group (PPPA\\ZLib FILES ${ZLIB})
|
||||||
|
|
||||||
|
|
||||||
if (MSVC_IDE)
|
if (MSVC_IDE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zc:__cplusplus")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zc:__cplusplus")
|
||||||
else()
|
else()
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
|||||||
return arg1;
|
return arg1;
|
||||||
|
|
||||||
auto reg = isLeft ? NULL : createRegister();
|
auto reg = isLeft ? NULL : createRegister();
|
||||||
Instruction* instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(numArgs), isLeft ? isLeft : reg);
|
Instruction* instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(numArgs), isLeft ? isLeft : reg, NULL, ex);
|
||||||
blocks.push_back(new IR_Block(instr));
|
blocks.push_back(new IR_Block(instr));
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,398 @@
|
|||||||
|
#include <map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
#include <queue>
|
||||||
|
#include <numeric>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "private_arrays_search.h"
|
||||||
|
#include "../Utils/SgUtils.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void print_info(LoopGraph* loop)
|
||||||
|
{
|
||||||
|
cout << "loopSymbol: " << loop->loopSymbol << endl;
|
||||||
|
for (const auto& ops : loop->writeOpsForLoop)
|
||||||
|
{
|
||||||
|
cout << "Array name: " << ops.first->GetShortName() << endl;
|
||||||
|
for (const auto i : ops.second)
|
||||||
|
{
|
||||||
|
i.printInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!loop->children.empty())
|
||||||
|
{
|
||||||
|
for (const auto child : loop->children)
|
||||||
|
{
|
||||||
|
print_info(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isParentStmt(SgStatement* stmt, SgStatement* parent)
|
||||||
|
{
|
||||||
|
for (; stmt; stmt = stmt->controlParent())
|
||||||
|
if (stmt == parent)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*returns head block and loop*/
|
||||||
|
pair<SAPFOR::BasicBlock*, unordered_set<SAPFOR::BasicBlock*>> GetBasicBlocksForLoop(LoopGraph* loop, vector<SAPFOR::BasicBlock*> blocks)
|
||||||
|
{
|
||||||
|
unordered_set<SAPFOR::BasicBlock*> block_loop;
|
||||||
|
SAPFOR::BasicBlock* head_block = nullptr;
|
||||||
|
auto loop_operator = loop->loop->GetOriginal();
|
||||||
|
for (const auto& block : blocks)
|
||||||
|
{
|
||||||
|
if (!block || (block->getInstructions().size() == 0))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SgStatement* first = block->getInstructions().front()->getInstruction()->getOperator();
|
||||||
|
SgStatement* last = block->getInstructions().back()->getInstruction()->getOperator();
|
||||||
|
if (isParentStmt(first, loop_operator) && isParentStmt(last, loop_operator))
|
||||||
|
{
|
||||||
|
block_loop.insert(block);
|
||||||
|
|
||||||
|
if ((!head_block) && (first == loop_operator) && (last == loop_operator) &&
|
||||||
|
(block->getInstructions().size() == 2) &&
|
||||||
|
(block->getInstructions().back()->getInstruction()->getOperation() == SAPFOR::CFG_OP::JUMP_IF))
|
||||||
|
{
|
||||||
|
head_block = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { head_block, block_loop };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BuildLoopIndex(map<string, LoopGraph*>& loopForIndex, LoopGraph* loop) {
|
||||||
|
string index = loop->loopSymbol;
|
||||||
|
loopForIndex[index] = loop;
|
||||||
|
for (const auto& childLoop : loop->children) {
|
||||||
|
BuildLoopIndex(loopForIndex, childLoop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string FindIndexName(int pos, SAPFOR::BasicBlock* block, map<string, LoopGraph*>& loopForIndex) {
|
||||||
|
unordered_set<SAPFOR::Argument*> args = {block->getInstructions()[pos]->getInstruction()->getArg1()};
|
||||||
|
|
||||||
|
for (int i = pos-1; i >= 0; i--) {
|
||||||
|
SAPFOR::Argument* res = block->getInstructions()[i]->getInstruction()->getResult();
|
||||||
|
if (res && args.find(res) != args.end()) {
|
||||||
|
SAPFOR::Argument* arg1 = block->getInstructions()[i]->getInstruction()->getArg1();
|
||||||
|
SAPFOR::Argument* arg2 = block->getInstructions()[i]->getInstruction()->getArg2();
|
||||||
|
if (arg1) {
|
||||||
|
string name = arg1->getValue();
|
||||||
|
int idx = name.find('%');
|
||||||
|
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
||||||
|
return name.substr(idx + 1);
|
||||||
|
else {
|
||||||
|
args.insert(arg1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (arg2) {
|
||||||
|
string name = arg2->getValue();
|
||||||
|
int idx = name.find('%');
|
||||||
|
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
||||||
|
return name.substr(idx + 1);
|
||||||
|
else {
|
||||||
|
args.insert(arg2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAccessingIndexes& def, ArrayAccessingIndexes& use) {
|
||||||
|
auto instructions = block->getInstructions();
|
||||||
|
map<string, LoopGraph*> loopForIndex;
|
||||||
|
BuildLoopIndex(loopForIndex, loop);
|
||||||
|
for(int i = 0; i < instructions.size(); i++)
|
||||||
|
{
|
||||||
|
auto instruction = instructions[i];
|
||||||
|
if(!instruction->getInstruction()->getArg1()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto operation = instruction->getInstruction()->getOperation();
|
||||||
|
auto type = instruction->getInstruction()->getArg1()->getType();
|
||||||
|
if ((operation == SAPFOR::CFG_OP::STORE && type == SAPFOR::CFG_ARG_TYPE::ARRAY) ||
|
||||||
|
(operation == SAPFOR::CFG_OP::LOAD && type == SAPFOR::CFG_ARG_TYPE::ARRAY))
|
||||||
|
{
|
||||||
|
|
||||||
|
vector<SAPFOR::Argument*> index_vars;
|
||||||
|
vector<int> refPos;
|
||||||
|
string array_name;
|
||||||
|
if (operation == SAPFOR::CFG_OP::STORE)
|
||||||
|
{
|
||||||
|
array_name = instruction->getInstruction()->getArg1()->getValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
array_name = instruction->getInstruction()->getArg2()->getValue();
|
||||||
|
}
|
||||||
|
int j = i - 1;
|
||||||
|
while (j >= 0 && instructions[j]->getInstruction()->getOperation() == SAPFOR::CFG_OP::REF)
|
||||||
|
{
|
||||||
|
index_vars.push_back(instructions[j]->getInstruction()->getArg1());
|
||||||
|
refPos.push_back(j);
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
/*to choose correct dimension*/
|
||||||
|
int n = index_vars.size();
|
||||||
|
if (operation == SAPFOR::CFG_OP::STORE)
|
||||||
|
{
|
||||||
|
if (def[array_name].empty())
|
||||||
|
{
|
||||||
|
def[array_name].resize(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (use[array_name].empty())
|
||||||
|
{
|
||||||
|
use[array_name].resize(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SgArrayRefExp* ref = (SgArrayRefExp*)instruction->getInstruction()->getExpression();
|
||||||
|
vector<pair<int, int>> coefsForDims;
|
||||||
|
for (int i = 0; i < ref->numberOfSubscripts(); ++i)
|
||||||
|
{
|
||||||
|
const vector<int*>& coefs = getAttributes<SgExpression*, int*>(ref->subscript(i), set<int>{ INT_VAL });
|
||||||
|
if (coefs.size() == 1)
|
||||||
|
{
|
||||||
|
const pair<int, int> coef(coefs[0][0], coefs[0][1]);
|
||||||
|
coefsForDims.push_back(coef);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!index_vars.empty())
|
||||||
|
{
|
||||||
|
auto var = index_vars.back();
|
||||||
|
int currentVarPos = refPos.back();
|
||||||
|
pair currentCoefs = coefsForDims.back();
|
||||||
|
ArrayDimension current_dim;
|
||||||
|
if (var->getType() == SAPFOR::CFG_ARG_TYPE::CONST) {
|
||||||
|
current_dim = { stoul(var->getValue()), 1, 1 };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string name, full_name = var->getValue();
|
||||||
|
int pos = full_name.find('%');
|
||||||
|
LoopGraph* currentLoop;
|
||||||
|
if (pos != -1) {
|
||||||
|
name = full_name.substr(pos+1);
|
||||||
|
if (loopForIndex.find(name) != loopForIndex.end()) {
|
||||||
|
currentLoop = loopForIndex[name];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
name = FindIndexName(currentVarPos, block, loopForIndex);
|
||||||
|
if (name == "") {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (loopForIndex.find(name) != loopForIndex.end()) {
|
||||||
|
currentLoop = loopForIndex[name];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint64_t start = currentLoop->startVal * currentCoefs.first + currentCoefs.second;
|
||||||
|
uint64_t step = currentCoefs.first;
|
||||||
|
current_dim = { start, step, (uint64_t)currentLoop->calculatedCountOfIters };
|
||||||
|
}
|
||||||
|
if (operation == SAPFOR::CFG_OP::STORE)
|
||||||
|
{
|
||||||
|
def[array_name][n - index_vars.size()].push_back(current_dim);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
use[array_name][n - index_vars.size()].push_back(current_dim);
|
||||||
|
}
|
||||||
|
index_vars.pop_back();
|
||||||
|
refPos.pop_back();
|
||||||
|
coefsForDims.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<uint64_t> FindParticularSolution(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
||||||
|
{
|
||||||
|
for (uint64_t i = 0; i < dim1.tripCount; i++)
|
||||||
|
{
|
||||||
|
uint64_t leftPart = dim1.start + i * dim1.step;
|
||||||
|
for (uint64_t j = 0; j < dim2.tripCount; j++)
|
||||||
|
{
|
||||||
|
uint64_t rightPart = dim2.start + j * dim2.step;
|
||||||
|
if (leftPart == rightPart)
|
||||||
|
{
|
||||||
|
return {i, j};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
/* dim1 /\ dim2 */
|
||||||
|
ArrayDimension* DimensionIntersection(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
||||||
|
{
|
||||||
|
vector<uint64_t> partSolution = FindParticularSolution(dim1, dim2);
|
||||||
|
if (partSolution.empty())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
int64_t x0 = partSolution[0], y0 = partSolution[1];
|
||||||
|
/* x = x_0 + c * t */
|
||||||
|
/* y = y_0 + d * t */
|
||||||
|
int64_t c = dim2.step / gcd(dim1.step, dim2.step);
|
||||||
|
int64_t d = dim1.step / gcd(dim1.step, dim2.step);
|
||||||
|
int64_t tXMin, tXMax, tYMin, tYMax;
|
||||||
|
tXMin = -x0 / c;
|
||||||
|
tXMax = (dim1.tripCount - 1 - x0) / c;
|
||||||
|
tYMin = -y0 / d;
|
||||||
|
tYMax = (dim2.tripCount - 1 - y0) / d;
|
||||||
|
int64_t tMin = max(tXMin, tYMin);
|
||||||
|
uint64_t tMax = min(tXMax, tYMax);
|
||||||
|
if (tMin > tMax)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
uint64_t start3 = dim1.start + x0 * dim1.step;
|
||||||
|
uint64_t step3 = c * dim1.step;
|
||||||
|
ArrayDimension* result = new(ArrayDimension){ start3, step3, tMax + 1 };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* dim1 / dim2 */
|
||||||
|
vector<ArrayDimension> DimensionDifference(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
||||||
|
{
|
||||||
|
ArrayDimension* intersection = DimensionIntersection(dim1, dim2);
|
||||||
|
if (!intersection)
|
||||||
|
{
|
||||||
|
return {dim1};
|
||||||
|
}
|
||||||
|
vector<ArrayDimension> result;
|
||||||
|
/* add the part before intersection */
|
||||||
|
if (dim1.start < intersection->start)
|
||||||
|
{
|
||||||
|
result.push_back({ dim1.start, dim1.step, (intersection->start - dim1.start) / dim1.step });
|
||||||
|
}
|
||||||
|
/* add the parts between intersection steps */
|
||||||
|
uint64_t start = (intersection->start - dim1.start) / dim1.step;
|
||||||
|
uint64_t interValue = intersection->start;
|
||||||
|
for (int64_t i = start; dim1.start + i * dim1.step <= intersection->start + intersection->step * (intersection->tripCount - 1); i++)
|
||||||
|
{
|
||||||
|
uint64_t centerValue = dim1.start + i * dim1.step;
|
||||||
|
if (centerValue == interValue)
|
||||||
|
{
|
||||||
|
if (i - start > 1)
|
||||||
|
{
|
||||||
|
result.push_back({ dim1.start + (start + 1) * dim1.step, dim1.step, i - start - 1 });
|
||||||
|
start = i;
|
||||||
|
}
|
||||||
|
interValue += intersection->step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* add the part after intersection */
|
||||||
|
if (intersection->start + intersection->step * (intersection->tripCount - 1) < dim1.start + dim1.step * (dim1.tripCount - 1))
|
||||||
|
{
|
||||||
|
/* first value after intersection */
|
||||||
|
uint64_t right_start = intersection->start + intersection->step * (intersection->tripCount - 1) + dim1.step;
|
||||||
|
uint64_t tripCount = (dim1.start + dim1.step * dim1.tripCount - right_start) / dim1.step;
|
||||||
|
result.push_back({right_start, dim1.step, tripCount});
|
||||||
|
}
|
||||||
|
delete(intersection);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<ArrayDimension> DimensionUnion(const ArrayDimension& dim1, const ArrayDimension& dim2)
|
||||||
|
{
|
||||||
|
vector<ArrayDimension> res;
|
||||||
|
ArrayDimension* inter = DimensionIntersection(dim1, dim2);
|
||||||
|
if(!inter)
|
||||||
|
{
|
||||||
|
return { dim1, dim2 };
|
||||||
|
}
|
||||||
|
res.push_back(*inter);
|
||||||
|
delete(inter);
|
||||||
|
vector<ArrayDimension> diff1, diff2;
|
||||||
|
diff1 = DimensionDifference(dim1, dim2);
|
||||||
|
diff2 = DimensionDifference(dim2, dim1);
|
||||||
|
res.insert(res.end(), diff1.begin(), diff1.end());
|
||||||
|
res.insert(res.end(), diff2.begin(), diff2.end());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
||||||
|
{
|
||||||
|
for (const auto& curr_graph_pair: loopGraph)
|
||||||
|
{
|
||||||
|
for (const auto& curr_loop : curr_graph_pair.second)
|
||||||
|
{
|
||||||
|
auto block_loop = GetBasicBlocksForLoop(curr_loop, (*FullIR.begin()).second);
|
||||||
|
for (const auto& bb : block_loop.second) {
|
||||||
|
ArrayAccessingIndexes def, use;
|
||||||
|
//GetDefUseArray(bb, curr_loop, def, use);
|
||||||
|
}
|
||||||
|
ArrayAccessingIndexes loopDimensionsInfo;
|
||||||
|
//GetDimensionInfo(curr_loop, loopDimensionsInfo, 0);
|
||||||
|
//print_info(curr_loop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetDimensionInfo(LoopGraph* loop, map<DIST::Array*, vector<vector<ArrayDimension>>>& loopDimensionsInfo, int level)
|
||||||
|
{
|
||||||
|
cout << "line_num: " << loop->lineNum << endl;
|
||||||
|
for (const auto& writeOpPairs : loop->writeOpsForLoop)
|
||||||
|
{
|
||||||
|
vector<vector<ArrayDimension>> arrayDimensions(writeOpPairs.first->GetDimSize());
|
||||||
|
loopDimensionsInfo[writeOpPairs.first] = arrayDimensions;
|
||||||
|
for (const auto& writeOp : writeOpPairs.second)
|
||||||
|
{
|
||||||
|
for (const auto& coeficient_pair : writeOp.coefficients)
|
||||||
|
{
|
||||||
|
uint64_t start, step, tripCount;
|
||||||
|
start = loop->startVal * coeficient_pair.first.first + coeficient_pair.first.second;
|
||||||
|
step = loop->stepVal * coeficient_pair.first.first;
|
||||||
|
tripCount = (loop->endVal - coeficient_pair.first.second) / step;
|
||||||
|
if (start <= loop->endVal)
|
||||||
|
{
|
||||||
|
loopDimensionsInfo[writeOpPairs.first][level].push_back({start, step, tripCount});
|
||||||
|
cout << "level: " << level << endl;
|
||||||
|
cout << "start: " << start << endl;
|
||||||
|
cout << "step: " << step << endl;
|
||||||
|
cout << "trip_count: " << tripCount << endl;
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << "line_num_after: " << loop->lineNumAfterLoop << endl;
|
||||||
|
if (!loop->children.empty())
|
||||||
|
{
|
||||||
|
for (const auto& childLoop : loop->children)
|
||||||
|
{
|
||||||
|
GetDimensionInfo(childLoop, loopDimensionsInfo, level+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../GraphLoop/graph_loops.h"
|
||||||
|
#include "../CFGraph/CFGraph.h"
|
||||||
|
|
||||||
|
struct ArrayDimension
|
||||||
|
{
|
||||||
|
uint64_t start, step, tripCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::vector<std::vector<ArrayDimension>>> ArrayAccessingIndexes;
|
||||||
|
|
||||||
|
void FindPrivateArrays(std::map<std::string, std::vector<LoopGraph*>>& loopGraph, std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& FullIR);
|
||||||
|
void GetDimensionInfo(LoopGraph* loop, std::map<DIST::Array*, std::vector<std::vector<ArrayDimension>>>& loopDimensionsInfo, int level);
|
||||||
|
std::set<SAPFOR::BasicBlock> GetBasicBlocksForLoop(LoopGraph* loop, std::vector<SAPFOR::BasicBlock>);
|
||||||
@@ -98,6 +98,8 @@
|
|||||||
|
|
||||||
#include "Inliner/inliner.h"
|
#include "Inliner/inliner.h"
|
||||||
|
|
||||||
|
#include "PrivateAnalyzer/private_arrays_search.h"
|
||||||
|
|
||||||
#include "dvm.h"
|
#include "dvm.h"
|
||||||
#include "Sapfor.h"
|
#include "Sapfor.h"
|
||||||
#include "Utils/PassManager.h"
|
#include "Utils/PassManager.h"
|
||||||
@@ -1892,7 +1894,10 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
doDumpLive(fullIR);
|
doDumpLive(fullIR);
|
||||||
}
|
}
|
||||||
else if (curr_regime == PRIVATE_ANALYSIS_IR)
|
else if (curr_regime == PRIVATE_ANALYSIS_IR)
|
||||||
|
{
|
||||||
runPrivateVariableAnalysis(loopGraph, fullIR, commonBlocks, SPF_messages);
|
runPrivateVariableAnalysis(loopGraph, fullIR, commonBlocks, SPF_messages);
|
||||||
|
FindPrivateArrays(loopGraph, fullIR);
|
||||||
|
}
|
||||||
else if (curr_regime == FIX_COMMON_BLOCKS)
|
else if (curr_regime == FIX_COMMON_BLOCKS)
|
||||||
fixCommonBlocks(allFuncInfo, commonBlocks, &project);
|
fixCommonBlocks(allFuncInfo, commonBlocks, &project);
|
||||||
else if (curr_regime == GET_MIN_MAX_BLOCK_DIST)
|
else if (curr_regime == GET_MIN_MAX_BLOCK_DIST)
|
||||||
@@ -1902,7 +1907,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
calculateStatsForPredictor(allFuncInfo, gCovInfo);
|
calculateStatsForPredictor(allFuncInfo, gCovInfo);
|
||||||
parseDvmDirForPredictor(declaredArrays, commonBlocks, allFuncInfo, gCovInfo);
|
parseDvmDirForPredictor(declaredArrays, commonBlocks, allFuncInfo, gCovInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;
|
const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;
|
||||||
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;
|
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;
|
||||||
__spf_print(1, "PROFILE: time for this pass = %f sec (total %f sec)\n", elapsed, elapsedGlobal);
|
__spf_print(1, "PROFILE: time for this pass = %f sec (total %f sec)\n", elapsed, elapsedGlobal);
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ static void setPassValues()
|
|||||||
passNames[RENAME_INLCUDES] = "RENAME_INLCUDES";
|
passNames[RENAME_INLCUDES] = "RENAME_INLCUDES";
|
||||||
passNames[INSERT_NO_DISTR_FLAGS_FROM_GUI] = "INSERT_NO_DISTR_FLAGS_FROM_GUI";
|
passNames[INSERT_NO_DISTR_FLAGS_FROM_GUI] = "INSERT_NO_DISTR_FLAGS_FROM_GUI";
|
||||||
|
|
||||||
|
|
||||||
passNames[TEST_PASS] = "TEST_PASS";
|
passNames[TEST_PASS] = "TEST_PASS";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
|||||||
|
|
||||||
list({ BUILD_IR, CALL_GRAPH }) <= Pass(LIVE_ANALYSIS_IR);
|
list({ BUILD_IR, CALL_GRAPH }) <= Pass(LIVE_ANALYSIS_IR);
|
||||||
|
|
||||||
list({ BUILD_IR, LOOP_GRAPH, LIVE_ANALYSIS_IR }) <= Pass(PRIVATE_ANALYSIS_IR);
|
list({ BUILD_IR, LOOP_GRAPH, LIVE_ANALYSIS_IR, ARRAY_ACCESS_ANALYSIS_FOR_CORNER }) <= Pass(PRIVATE_ANALYSIS_IR);
|
||||||
|
|
||||||
Pass(FILE_LINE_INFO) <= Pass(GET_MIN_MAX_BLOCK_DIST);
|
Pass(FILE_LINE_INFO) <= Pass(GET_MIN_MAX_BLOCK_DIST);
|
||||||
|
|
||||||
@@ -314,6 +314,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
|||||||
|
|
||||||
list({ VERIFY_INCLUDES, CORRECT_VAR_DECL }) <= Pass(SET_IMPLICIT_NONE);
|
list({ VERIFY_INCLUDES, CORRECT_VAR_DECL }) <= Pass(SET_IMPLICIT_NONE);
|
||||||
|
|
||||||
|
|
||||||
passesIgnoreStateDone.insert({ CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS, INSERT_SHADOW_DIRS, EXTRACT_PARALLEL_DIRS,
|
passesIgnoreStateDone.insert({ CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS, INSERT_SHADOW_DIRS, EXTRACT_PARALLEL_DIRS,
|
||||||
EXTRACT_SHADOW_DIRS, CREATE_REMOTES, UNPARSE_FILE, REMOVE_AND_CALC_SHADOW,
|
EXTRACT_SHADOW_DIRS, CREATE_REMOTES, UNPARSE_FILE, REMOVE_AND_CALC_SHADOW,
|
||||||
REVERSE_CREATED_NESTED_LOOPS, PREDICT_SCHEME, CALCULATE_STATS_SCHEME, REVERT_SPF_DIRS, CLEAR_SPF_DIRS, TRANSFORM_SHADOW_IF_FULL,
|
REVERSE_CREATED_NESTED_LOOPS, PREDICT_SCHEME, CALCULATE_STATS_SCHEME, REVERT_SPF_DIRS, CLEAR_SPF_DIRS, TRANSFORM_SHADOW_IF_FULL,
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2374"
|
#define VERSION_SPF "2375"
|
||||||
|
|||||||
Reference in New Issue
Block a user