Merge branch 'master' into analyze_loops_with_IR

This commit is contained in:
2024-12-31 16:41:12 +03:00
26 changed files with 9280 additions and 9169 deletions

View File

@@ -574,6 +574,7 @@
#define ACC_CHECKSECTION_DIR 911 /* ACC Fortran */ #define ACC_CHECKSECTION_DIR 911 /* ACC Fortran */
#define ACC_END_CHECKSECTION_DIR 912 /* ACC Fortran */ #define ACC_END_CHECKSECTION_DIR 912 /* ACC Fortran */
#define ACC_ROUTINE_DIR 913 /* ACC Fortran */ #define ACC_ROUTINE_DIR 913 /* ACC Fortran */
#define ACC_DECLARE_DIR 914 /* ACC Fortran */
#define ACC_TIE_OP 930 /* ACC Fortran */ #define ACC_TIE_OP 930 /* ACC Fortran */
#define ACC_INLOCAL_OP 931 /* ACC Fortran */ #define ACC_INLOCAL_OP 931 /* ACC Fortran */

View File

@@ -576,6 +576,7 @@ script using "tag". Run make tag.h to regenerate this file */
tag [ ACC_CHECKSECTION_DIR ] = "ACC_CHECKSECTION_DIR"; tag [ ACC_CHECKSECTION_DIR ] = "ACC_CHECKSECTION_DIR";
tag [ ACC_END_CHECKSECTION_DIR ] = "ACC_END_CHECKSECTION_DIR"; tag [ ACC_END_CHECKSECTION_DIR ] = "ACC_END_CHECKSECTION_DIR";
tag [ ACC_ROUTINE_DIR ] = "ACC_ROUTINE_DIR"; tag [ ACC_ROUTINE_DIR ] = "ACC_ROUTINE_DIR";
tag [ ACC_DECLARE_DIR ] = "ACC_DECLARE_DIR";
tag [ ACC_TIE_OP ] = "ACC_TIE_OP"; tag [ ACC_TIE_OP ] = "ACC_TIE_OP";
tag [ ACC_INLOCAL_OP ] = "ACC_INLOCAL_OP"; tag [ ACC_INLOCAL_OP ] = "ACC_INLOCAL_OP";

View File

@@ -443,6 +443,7 @@ DEFNODECODE(DUMMY_REF, "nodetext",'r',0,LLNODE, '_','_','s','_','_')
DEFNODECODE(ACC_CALL_STMT,"nodetext",'s',2,BIFNODE, '_','_','_','_','_') DEFNODECODE(ACC_CALL_STMT,"nodetext",'s',2,BIFNODE, '_','_','_','_','_')
DEFNODECODE(DVM_NEW_VALUE_DIR,"nodetext",'s',1,BIFNODE, '_','_','_','_','_') DEFNODECODE(DVM_NEW_VALUE_DIR,"nodetext",'s',1,BIFNODE, '_','_','_','_','_')
DEFNODECODE(ACC_ROUTINE_DIR,"nodetext",'s',1,BIFNODE, '_','_','_','_','_') DEFNODECODE(ACC_ROUTINE_DIR,"nodetext",'s',1,BIFNODE, '_','_','_','_','_')
DEFNODECODE(ACC_DECLARE_DIR,"nodetext",'s',1,BIFNODE, '_','_','_','_','_')
/* SAPFOR */ /* SAPFOR */
DEFNODECODE(SPF_NOINLINE_OP, "nodetext",'e',0,LLNODE, '_','_','_','_','_') DEFNODECODE(SPF_NOINLINE_OP, "nodetext",'e',0,LLNODE, '_','_','_','_','_')

View File

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

View File

@@ -270,7 +270,9 @@ DEFNODECODE(ACC_CHECKSECTION_DIR, "%CMNT!DVM$%PUTTABCOMTHOSTSECTION%NL",
's',0,BIFNODE) 's',0,BIFNODE)
DEFNODECODE(ACC_END_CHECKSECTION_DIR,"%CMNT!DVM$%PUTTABCOMTEND HOSTSECTION%NL", DEFNODECODE(ACC_END_CHECKSECTION_DIR,"%CMNT!DVM$%PUTTABCOMTEND HOSTSECTION%NL",
's',0,BIFNODE) 's',0,BIFNODE)
DEFNODECODE(ACC_ROUTINE_DIR, "%CMNT!DVM$%PUTTABCOMTROUTINE %LL1%NL", DEFNODECODE(ACC_ROUTINE_DIR, "%CMNT!DVM$%PUTTABCOMTROUTINE%IF(%LL1!=%NULL), %LL1%NL",
's',1,BIFNODE)
DEFNODECODE(ACC_DECLARE_DIR, "%CMNT!DVM$%PUTTABCOMTDECLARE %LL1%NL",
's',1,BIFNODE) 's',1,BIFNODE)
DEFNODECODE(OMP_NOWAIT, "NOWAIT", DEFNODECODE(OMP_NOWAIT, "NOWAIT",

View File

@@ -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))
{ {
@@ -1250,7 +1333,8 @@ 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)
@@ -1265,11 +1349,35 @@ void EnterDataRegionForVariablesInMainProgram(SgStatement *st)
if (!is_deleted_module_symbol(s) && IS_ARRAY(s) && !hasSameOriginalName(s) && s->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(s) && !IS_POINTER_F90(s) && !HEADER(s) ) if (!is_deleted_module_symbol(s) && IS_ARRAY(s) && !hasSameOriginalName(s) && s->variant() == VARIABLE_NAME && !IS_ALLOCATABLE(s) && !IS_POINTER_F90(s) && !HEADER(s) )
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));

View File

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

View File

@@ -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);
@@ -2678,7 +2681,9 @@ void TransFunc(SgStatement *func,SgStatement* &end_of_unit) {
// current statement is executable (F77/DVM) // current statement is executable (F77/DVM)
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
@@ -4238,8 +4243,7 @@ END_: // end of program unit
cur_st = first_dvm_exec; cur_st = first_dvm_exec;
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*/
@@ -10599,7 +10604,8 @@ void InsertDebugStat(SgStatement *func, SgStatement* &end_of_unit)
//including the DVM specification directive to list //including the DVM specification directive to list
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;

View File

@@ -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 */

View File

@@ -107,6 +107,7 @@
#define ACC_CHECKSECTION_DIR 911 /* ACC Fortran */ #define ACC_CHECKSECTION_DIR 911 /* ACC Fortran */
#define ACC_END_CHECKSECTION_DIR 912 /* ACC Fortran */ #define ACC_END_CHECKSECTION_DIR 912 /* ACC Fortran */
#define ACC_ROUTINE_DIR 913 /* ACC Fortran */ #define ACC_ROUTINE_DIR 913 /* ACC Fortran */
#define ACC_DECLARE_DIR 914 /* ACC Fortran */
#define ACC_TIE_OP 930 /* ACC Fortran */ #define ACC_TIE_OP 930 /* ACC Fortran */
#define ACC_INLOCAL_OP 931 /* ACC Fortran */ #define ACC_INLOCAL_OP 931 /* ACC Fortran */

View File

@@ -1,10 +1,12 @@
acc_specification: acc_declare
| acc_routine
;
acc_directive: acc_region acc_directive: acc_region
| acc_end_region | acc_end_region
| acc_checksection | acc_checksection
| acc_end_checksection | acc_end_checksection
| acc_get_actual | acc_get_actual
| acc_actual | acc_actual
| acc_routine
; ;
acc_region: ACC_REGION end_spec opt_clause acc_region: ACC_REGION end_spec opt_clause
@@ -98,14 +100,46 @@ acc_end_region: ACC_END_REGION
acc_end_checksection: ACC_END_CHECKSECTION acc_end_checksection: ACC_END_CHECKSECTION
{ $$ = get_bfnd(fi,ACC_END_CHECKSECTION_DIR,SMNULL,LLNULL,LLNULL,LLNULL);} { $$ = get_bfnd(fi,ACC_END_CHECKSECTION_DIR,SMNULL,LLNULL,LLNULL,LLNULL);}
; ;
acc_declare: ACC_DECLARE in_dcl opt_double_colon acc_declare_list
{
$$ = get_bfnd(fi,ACC_DECLARE_DIR, SMNULL, $4, LLNULL, LLNULL);
}
;
acc_declare_list: declare_var
{ $$ = make_llnd(fi,EXPR_LIST, $1, LLNULL, SMNULL); }
| acc_declare_list COMMA declare_var
{ $$ = set_ll_list($1, $3, EXPR_LIST); }
;
declare_var: name
{
PTR_SYMB s;
s = make_scalar($1,TYNULL,LOCAL);
if((s->attr & PROCESSORS_BIT) ||(s->attr & TASK_BIT) || (s->attr & TEMPLATE_BIT) || (s->attr & ALIGN_BIT) || (s->attr & DISTRIBUTE_BIT) || (s->attr & DYNAMIC_BIT) || (s->attr & HEAP_BIT)|| (s->attr & DVM_POINTER_BIT) || (s->attr & INHERIT_BIT) ||(s->attr & SHADOW_BIT))
errstr("Inconsistent declaration of identifier %s", s->ident, 16);
$$ = make_llnd(fi,VAR_REF, LLNULL, LLNULL, s);
}
;
acc_routine: ACC_ROUTINE in_dcl opt_targets_clause acc_routine: ACC_ROUTINE in_dcl opt_routine_clauses
{ $$ = get_bfnd(fi,ACC_ROUTINE_DIR,SMNULL,$3,LLNULL,LLNULL);} { $$ = get_bfnd(fi,ACC_ROUTINE_DIR,SMNULL,$3,LLNULL,LLNULL);}
; ;
opt_targets_clause: needkeyword keywordoff opt_routine_clauses:
{ $$ = LLNULL; } { $$ = LLNULL;}
| needkeyword targets_clause | routine_clause_list
{ $$ = $2;} { $$ = $1;}
; ;
routine_clause_list: routine_clause
{ $$ = set_ll_list($1,LLNULL,EXPR_LIST); }
| routine_clause_list routine_clause
{ $$ = set_ll_list($1,$2,EXPR_LIST); }
;
routine_clause: COMMA needkeyword PRIVATE LEFTPAR acc_declare_list RIGHTPAR
{ $$ = make_llnd(fi,ACC_PRIVATE_OP,$5,LLNULL,SMNULL);}
| COMMA needkeyword targets_clause
{ $$ = $3;}
;

View File

@@ -269,10 +269,12 @@ static int in_vec = NO; /* set if processing array constructor */
%type <ll_node> paralleldo_clause_list paralleldo_clause %type <ll_node> paralleldo_clause_list paralleldo_clause
/* FORTRAN ACC */ /* FORTRAN ACC */
%type <bf_node> acc_specification acc_declare
%type <bf_node> acc_directive acc_region acc_end_region acc_checksection acc_end_checksection %type <bf_node> acc_directive acc_region acc_end_region acc_checksection acc_end_checksection
%type <bf_node> acc_get_actual acc_actual acc_routine %type <bf_node> acc_get_actual acc_actual acc_routine
%type <ll_node> opt_clause acc_clause_list acc_clause data_clause async_clause targets_clause %type <ll_node> opt_clause acc_clause_list acc_clause data_clause async_clause targets_clause
%type <ll_node> acc_var_list computer_list computer opt_targets_clause %type <ll_node> acc_var_list computer_list computer opt_routine_clauses routine_clause_list routine_clause
%type <ll_node> acc_declare_list declare_var
/* new clauses for PARALLEL directive */ /* new clauses for PARALLEL directive */
%type <ll_node> private_spec cuda_block_spec sizelist %type <ll_node> private_spec cuda_block_spec sizelist
@@ -852,6 +854,7 @@ spec: type_dcl
| common | common
| dimension | dimension
| dvm_specification /* FDVM */ | dvm_specification /* FDVM */
| acc_specification /* FDVM */
| external | external
| intrinsic | intrinsic
| equivalence | equivalence

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -318,41 +318,42 @@
%token ACC_CUDA_BLOCK 318 %token ACC_CUDA_BLOCK 318
%token ACC_ROUTINE 319 %token ACC_ROUTINE 319
%token ACC_TIE 320 %token ACC_TIE 320
%token BY 321 %token ACC_DECLARE 321
%token IO_MODE 322 %token BY 322
%token CP_CREATE 323 %token IO_MODE 323
%token CP_LOAD 324 %token CP_CREATE 324
%token CP_SAVE 325 %token CP_LOAD 325
%token CP_WAIT 326 %token CP_SAVE 326
%token FILES 327 %token CP_WAIT 327
%token VARLIST 328 %token FILES 328
%token STATUS 329 %token VARLIST 329
%token EXITINTERVAL 330 %token STATUS 330
%token TEMPLATE_CREATE 331 %token EXITINTERVAL 331
%token TEMPLATE_DELETE 332 %token TEMPLATE_CREATE 332
%token SPF_ANALYSIS 333 %token TEMPLATE_DELETE 333
%token SPF_PARALLEL 334 %token SPF_ANALYSIS 334
%token SPF_TRANSFORM 335 %token SPF_PARALLEL 335
%token SPF_NOINLINE 336 %token SPF_TRANSFORM 336
%token SPF_PARALLEL_REG 337 %token SPF_NOINLINE 337
%token SPF_END_PARALLEL_REG 338 %token SPF_PARALLEL_REG 338
%token SPF_EXPAND 339 %token SPF_END_PARALLEL_REG 339
%token SPF_FISSION 340 %token SPF_EXPAND 340
%token SPF_SHRINK 341 %token SPF_FISSION 341
%token SPF_CHECKPOINT 342 %token SPF_SHRINK 342
%token SPF_EXCEPT 343 %token SPF_CHECKPOINT 343
%token SPF_FILES_COUNT 344 %token SPF_EXCEPT 344
%token SPF_INTERVAL 345 %token SPF_FILES_COUNT 345
%token SPF_TIME 346 %token SPF_INTERVAL 346
%token SPF_ITER 347 %token SPF_TIME 347
%token SPF_FLEXIBLE 348 %token SPF_ITER 348
%token SPF_APPLY_REGION 349 %token SPF_FLEXIBLE 349
%token SPF_APPLY_FRAGMENT 350 %token SPF_APPLY_REGION 350
%token SPF_CODE_COVERAGE 351 %token SPF_APPLY_FRAGMENT 351
%token SPF_UNROLL 352 %token SPF_CODE_COVERAGE 352
%token SPF_MERGE 353 %token SPF_UNROLL 353
%token SPF_COVER 354 %token SPF_MERGE 354
%token SPF_PROCESS_PRIVATE 355 %token SPF_COVER 355
%token SPF_PROCESS_PRIVATE 356
%{ %{
#include <string.h> #include <string.h>
@@ -624,10 +625,12 @@ static int in_vec = NO; /* set if processing array constructor */
%type <ll_node> paralleldo_clause_list paralleldo_clause %type <ll_node> paralleldo_clause_list paralleldo_clause
/* FORTRAN ACC */ /* FORTRAN ACC */
%type <bf_node> acc_specification acc_declare
%type <bf_node> acc_directive acc_region acc_end_region acc_checksection acc_end_checksection %type <bf_node> acc_directive acc_region acc_end_region acc_checksection acc_end_checksection
%type <bf_node> acc_get_actual acc_actual acc_routine %type <bf_node> acc_get_actual acc_actual acc_routine
%type <ll_node> opt_clause acc_clause_list acc_clause data_clause async_clause targets_clause %type <ll_node> opt_clause acc_clause_list acc_clause data_clause async_clause targets_clause
%type <ll_node> acc_var_list computer_list computer opt_targets_clause %type <ll_node> acc_var_list computer_list computer opt_routine_clauses routine_clause_list routine_clause
%type <ll_node> acc_declare_list declare_var
/* new clauses for PARALLEL directive */ /* new clauses for PARALLEL directive */
%type <ll_node> private_spec cuda_block_spec sizelist %type <ll_node> private_spec cuda_block_spec sizelist
@@ -1207,6 +1210,7 @@ spec: type_dcl
| common | common
| dimension | dimension
| dvm_specification /* FDVM */ | dvm_specification /* FDVM */
| acc_specification /* FDVM */
| external | external
| intrinsic | intrinsic
| equivalence | equivalence
@@ -7845,13 +7849,15 @@ op_slash_0 : {
operator_slash = 0; operator_slash = 0;
}; };
acc_specification: acc_declare
| acc_routine
;
acc_directive: acc_region acc_directive: acc_region
| acc_end_region | acc_end_region
| acc_checksection | acc_checksection
| acc_end_checksection | acc_end_checksection
| acc_get_actual | acc_get_actual
| acc_actual | acc_actual
| acc_routine
; ;
acc_region: ACC_REGION end_spec opt_clause acc_region: ACC_REGION end_spec opt_clause
@@ -7945,17 +7951,49 @@ acc_end_region: ACC_END_REGION
acc_end_checksection: ACC_END_CHECKSECTION acc_end_checksection: ACC_END_CHECKSECTION
{ $$ = get_bfnd(fi,ACC_END_CHECKSECTION_DIR,SMNULL,LLNULL,LLNULL,LLNULL);} { $$ = get_bfnd(fi,ACC_END_CHECKSECTION_DIR,SMNULL,LLNULL,LLNULL,LLNULL);}
; ;
acc_declare: ACC_DECLARE in_dcl opt_double_colon acc_declare_list
{
$$ = get_bfnd(fi,ACC_DECLARE_DIR, SMNULL, $4, LLNULL, LLNULL);
}
;
acc_declare_list: declare_var
{ $$ = make_llnd(fi,EXPR_LIST, $1, LLNULL, SMNULL); }
| acc_declare_list COMMA declare_var
{ $$ = set_ll_list($1, $3, EXPR_LIST); }
;
declare_var: name
{
PTR_SYMB s;
s = make_scalar($1,TYNULL,LOCAL);
if((s->attr & PROCESSORS_BIT) ||(s->attr & TASK_BIT) || (s->attr & TEMPLATE_BIT) || (s->attr & ALIGN_BIT) || (s->attr & DISTRIBUTE_BIT) || (s->attr & DYNAMIC_BIT) || (s->attr & HEAP_BIT)|| (s->attr & DVM_POINTER_BIT) || (s->attr & INHERIT_BIT) ||(s->attr & SHADOW_BIT))
errstr("Inconsistent declaration of identifier %s", s->ident, 16);
$$ = make_llnd(fi,VAR_REF, LLNULL, LLNULL, s);
}
;
acc_routine: ACC_ROUTINE in_dcl opt_targets_clause acc_routine: ACC_ROUTINE in_dcl opt_routine_clauses
{ $$ = get_bfnd(fi,ACC_ROUTINE_DIR,SMNULL,$3,LLNULL,LLNULL);} { $$ = get_bfnd(fi,ACC_ROUTINE_DIR,SMNULL,$3,LLNULL,LLNULL);}
; ;
opt_targets_clause: needkeyword keywordoff opt_routine_clauses:
{ $$ = LLNULL; } { $$ = LLNULL;}
| needkeyword targets_clause | routine_clause_list
{ $$ = $2;} { $$ = $1;}
; ;
routine_clause_list: routine_clause
{ $$ = set_ll_list($1,LLNULL,EXPR_LIST); }
| routine_clause_list routine_clause
{ $$ = set_ll_list($1,$2,EXPR_LIST); }
;
routine_clause: COMMA needkeyword PRIVATE LEFTPAR acc_declare_list RIGHTPAR
{ $$ = make_llnd(fi,ACC_PRIVATE_OP,$5,LLNULL,SMNULL);}
| COMMA needkeyword targets_clause
{ $$ = $3;}
;
spf_directive: spf_analysis spf_directive: spf_analysis
| spf_parallel | spf_parallel
| spf_transform | spf_transform

View File

@@ -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;
@@ -2214,6 +2224,9 @@ analyz()
} else if (eqn(13, nextch, "doublecomplex")) { } else if (eqn(13, nextch, "doublecomplex")) {
stkey = DOUBLECOMPLEX; stkey = DOUBLECOMPLEX;
nextch += 13; nextch += 13;
} else if (eqn(7, nextch, "declare")) { /*ACC*/
stkey = ACC_DECLARE;
nextch += 7;
} else if (eqn(2, nextch, "do")) { /*OMP*/ } else if (eqn(2, nextch, "do")) { /*OMP*/
if (OMP_program == 1) { /*OMP*/ if (OMP_program == 1) { /*OMP*/
stkey = OMPDVM_DO; /*OMP*/ stkey = OMPDVM_DO; /*OMP*/

View File

@@ -788,6 +788,7 @@ set_stat_list(old_list, stat)
case (DVM_CONSISTENT_DIR): case (DVM_CONSISTENT_DIR):
case (DVM_ASYNCID_DIR): case (DVM_ASYNCID_DIR):
case (ACC_ROUTINE_DIR): case (ACC_ROUTINE_DIR):
case (ACC_DECLARE_DIR):
case (DATA_DECL): case (DATA_DECL):
case (EXTERN_STAT): case (EXTERN_STAT):
case (INTRIN_STAT): case (INTRIN_STAT):

View File

@@ -1952,6 +1952,8 @@ copy_module_scope(sym_mod,list)
continue; continue;
if(list && in_rename_list(source,list)) if(list && in_rename_list(source,list))
continue; continue;
if(!strcmp(source->ident, "***"))
continue;
if((copy=just_look_up_sym_in_scope(cur_scope(),source->ident)) && copy->id_attr && copy->id_attr->entry.Template.tag==sym_mod->entry.Template.func_hedr->id) if((copy=just_look_up_sym_in_scope(cur_scope(),source->ident)) && copy->id_attr && copy->id_attr->entry.Template.tag==sym_mod->entry.Template.func_hedr->id)
continue; continue;
new_symb = make_local_entity(source->parent, source->variant, source->type, LOCAL); new_symb = make_local_entity(source->parent, source->variant, source->type, LOCAL);

View File

@@ -574,6 +574,7 @@
#define ACC_CHECKSECTION_DIR 911 /* ACC Fortran */ #define ACC_CHECKSECTION_DIR 911 /* ACC Fortran */
#define ACC_END_CHECKSECTION_DIR 912 /* ACC Fortran */ #define ACC_END_CHECKSECTION_DIR 912 /* ACC Fortran */
#define ACC_ROUTINE_DIR 913 /* ACC Fortran */ #define ACC_ROUTINE_DIR 913 /* ACC Fortran */
#define ACC_DECLARE_DIR 914 /* ACC Fortran */
#define ACC_TIE_OP 930 /* ACC Fortran */ #define ACC_TIE_OP 930 /* ACC Fortran */
#define ACC_INLOCAL_OP 931 /* ACC Fortran */ #define ACC_INLOCAL_OP 931 /* ACC Fortran */

View File

@@ -576,6 +576,7 @@ script using "tag". Run make tag.h to regenerate this file */
tag [ ACC_CHECKSECTION_DIR ] = "ACC_CHECKSECTION_DIR"; tag [ ACC_CHECKSECTION_DIR ] = "ACC_CHECKSECTION_DIR";
tag [ ACC_END_CHECKSECTION_DIR ] = "ACC_END_CHECKSECTION_DIR"; tag [ ACC_END_CHECKSECTION_DIR ] = "ACC_END_CHECKSECTION_DIR";
tag [ ACC_ROUTINE_DIR ] = "ACC_ROUTINE_DIR"; tag [ ACC_ROUTINE_DIR ] = "ACC_ROUTINE_DIR";
tag [ ACC_DECLARE_DIR ] = "ACC_DECLARE_DIR";
tag [ ACC_TIE_OP ] = "ACC_TIE_OP"; tag [ ACC_TIE_OP ] = "ACC_TIE_OP";
tag [ ACC_INLOCAL_OP ] = "ACC_INLOCAL_OP"; tag [ ACC_INLOCAL_OP ] = "ACC_INLOCAL_OP";

View File

@@ -318,38 +318,39 @@
#define ACC_CUDA_BLOCK 318 #define ACC_CUDA_BLOCK 318
#define ACC_ROUTINE 319 #define ACC_ROUTINE 319
#define ACC_TIE 320 #define ACC_TIE 320
#define BY 321 #define ACC_DECLARE 321
#define IO_MODE 322 #define BY 322
#define CP_CREATE 323 #define IO_MODE 323
#define CP_LOAD 324 #define CP_CREATE 324
#define CP_SAVE 325 #define CP_LOAD 325
#define CP_WAIT 326 #define CP_SAVE 326
#define FILES 327 #define CP_WAIT 327
#define VARLIST 328 #define FILES 328
#define STATUS 329 #define VARLIST 329
#define EXITINTERVAL 330 #define STATUS 330
#define TEMPLATE_CREATE 331 #define EXITINTERVAL 331
#define TEMPLATE_DELETE 332 #define TEMPLATE_CREATE 332
#define SPF_ANALYSIS 333 #define TEMPLATE_DELETE 333
#define SPF_PARALLEL 334 #define SPF_ANALYSIS 334
#define SPF_TRANSFORM 335 #define SPF_PARALLEL 335
#define SPF_NOINLINE 336 #define SPF_TRANSFORM 336
#define SPF_PARALLEL_REG 337 #define SPF_NOINLINE 337
#define SPF_END_PARALLEL_REG 338 #define SPF_PARALLEL_REG 338
#define SPF_EXPAND 339 #define SPF_END_PARALLEL_REG 339
#define SPF_FISSION 340 #define SPF_EXPAND 340
#define SPF_SHRINK 341 #define SPF_FISSION 341
#define SPF_CHECKPOINT 342 #define SPF_SHRINK 342
#define SPF_EXCEPT 343 #define SPF_CHECKPOINT 343
#define SPF_FILES_COUNT 344 #define SPF_EXCEPT 344
#define SPF_INTERVAL 345 #define SPF_FILES_COUNT 345
#define SPF_TIME 346 #define SPF_INTERVAL 346
#define SPF_ITER 347 #define SPF_TIME 347
#define SPF_FLEXIBLE 348 #define SPF_ITER 348
#define SPF_APPLY_REGION 349 #define SPF_FLEXIBLE 349
#define SPF_APPLY_FRAGMENT 350 #define SPF_APPLY_REGION 350
#define SPF_CODE_COVERAGE 351 #define SPF_APPLY_FRAGMENT 351
#define SPF_UNROLL 352 #define SPF_CODE_COVERAGE 352
#define SPF_MERGE 353 #define SPF_UNROLL 353
#define SPF_COVER 354 #define SPF_MERGE 354
#define SPF_PROCESS_PRIVATE 355 #define SPF_COVER 355
#define SPF_PROCESS_PRIVATE 356

View File

@@ -318,6 +318,7 @@ ACC_INLOCAL
ACC_CUDA_BLOCK ACC_CUDA_BLOCK
ACC_ROUTINE ACC_ROUTINE
ACC_TIE ACC_TIE
ACC_DECLARE
BY BY
IO_MODE IO_MODE
CP_CREATE CP_CREATE

View File

@@ -101,7 +101,7 @@ void Sleep(int millisec) { usleep(millisec * 2000); }
#define SERV "[SERVER]" #define SERV "[SERVER]"
static const char* VERSION = "8"; static const char* VERSION = "9";
static FILE* logFile = NULL; static FILE* logFile = NULL;
extern void __bst_create(const char* name); extern void __bst_create(const char* name);
@@ -540,7 +540,7 @@ int main(int argc, char** argv)
else else
{ {
const size_t hashOfPath = hash<string>{}(path); const size_t hashOfPath = hash<string>{}(path);
__print(SERV, "Open ot create mutex of '%s' path, hash = %zu", path.c_str(), hashOfPath); __print(SERV, "Open or create mutex of '%s' path, hash = %zu", path.c_str(), hashOfPath);
__bst_create(to_string(hashOfPath).c_str()); __bst_create(to_string(hashOfPath).c_str());
if (argc == 2 && argv[1] == string("-unlock")) if (argc == 2 && argv[1] == string("-unlock"))

View File

@@ -5,6 +5,7 @@
#include <string> #include <string>
#include <map> #include <map>
#include <set> #include <set>
#include <ExpressionTransform/expr_transform.h>
using std::map; using std::map;
using std::set; using std::set;
@@ -12,6 +13,7 @@ using std::string;
using std::vector; using std::vector;
using std::to_string; using std::to_string;
using std::make_pair; using std::make_pair;
using std::pair;
#define DEBUG_TRACE 0 #define DEBUG_TRACE 0
@@ -27,7 +29,7 @@ static void findArrays(SgExpression* exp, set<SgSymbol*>& arrays)
} }
} }
static void populateDistributedIoArrays(map<DIST::Array*, set<SgStatement*>>& arrays, SgStatement* stat) static void populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& arrays, SgStatement* stat)
{ {
auto var = stat->variant(); auto var = stat->variant();
@@ -122,7 +124,7 @@ static void populateDistributedIoArrays(map<DIST::Array*, set<SgStatement*>>& ar
{ {
string array_name = string(by_symb->identifier()); string array_name = string(by_symb->identifier());
DIST::Array* array_p = getArrayFromDeclarated(declaratedInStmt(by_symb), array_name); DIST::Array* array_p = getArrayFromDeclarated(declaratedInStmt(by_symb), array_name);
if (array_p && array_p->GetDistributeFlagVal() == Distribution::distFlag::IO_PRIV && arrays[array_p].insert(stat).second) if (array_p && array_p->GetDistributeFlagVal() == Distribution::distFlag::IO_PRIV && arrays[by_symb].insert(stat).second)
__spf_print(DEBUG_TRACE, "[%d]: add array %s\n", stat->lineNumber(), array_p->GetName().c_str()); __spf_print(DEBUG_TRACE, "[%d]: add array %s\n", stat->lineNumber(), array_p->GetName().c_str());
} }
@@ -134,7 +136,7 @@ static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgExpression* e
if (!exp) if (!exp)
return; return;
if (exp->symbol() && strcmp(exp->symbol()->identifier(), arr->identifier()) == 0) if (exp->symbol() && exp->symbol()->identifier() && strcmp(exp->symbol()->identifier(), arr->identifier()) == 0)
{ {
has_read |= from_read; has_read |= from_read;
has_write |= from_write; has_write |= from_write;
@@ -143,24 +145,24 @@ static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgExpression* e
switch (exp->variant()) switch (exp->variant())
{ {
case FUNC_CALL: case FUNC_CALL:
{ {
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, true, false); replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, true, false);
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, true, true); replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, true, true);
break; break;
} }
case EXPR_LIST: case EXPR_LIST:
{ {
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, from_read, from_write); replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, from_read, from_write);
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, from_read, from_write); replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, from_read, from_write);
break; break;
} }
default: default:
{ {
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, true, false); replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, true, false);
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, true, false); replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, true, false);
break; break;
} }
} }
} }
@@ -171,31 +173,31 @@ static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgStatement* st
switch (st->variant()) switch (st->variant())
{ {
case ASSIGN_STAT: case ASSIGN_STAT:
case READ_STAT: case READ_STAT:
{ {
replaceArrayRec(arr, replace_by, st->expr(0), has_read, has_write, false, true); replaceArrayRec(arr, replace_by, st->expr(0), has_read, has_write, false, true);
replaceArrayRec(arr, replace_by, st->expr(1), has_read, has_write, true, false); replaceArrayRec(arr, replace_by, st->expr(1), has_read, has_write, true, false);
break; break;
} }
case PROC_STAT: case PROC_STAT:
case FUNC_STAT: case FUNC_STAT:
{ {
replaceArrayRec(arr, replace_by, st->expr(0), has_read, has_write, true, false); replaceArrayRec(arr, replace_by, st->expr(0), has_read, has_write, true, false);
replaceArrayRec(arr, replace_by, st->expr(1), has_read, has_write, true, true); replaceArrayRec(arr, replace_by, st->expr(1), has_read, has_write, true, true);
break; break;
} }
default: default:
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
replaceArrayRec(arr, replace_by, st->expr(i), has_read, has_write, true, false); replaceArrayRec(arr, replace_by, st->expr(i), has_read, has_write, true, false);
break; break;
} }
} }
} }
static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace_by, SgStatement* start, SgStatement* last) static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace_by, SgStatement* start, SgStatement* last, bool start_is_scope)
{ {
while (start->lexNext() && !isSgExecutableStatement(start->lexNext())) while (start->lexNext() && !isSgExecutableStatement(start->lexNext()))
start = start->lexNext(); start = start->lexNext();
@@ -204,7 +206,7 @@ static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace
bool has_read = false, has_write = false; bool has_read = false, has_write = false;
for (auto* st = start; st != stop; st = st->lexNext()) for (auto* st = start->lexNext(); st && st != stop->lexPrev(); st = st->lexNext())
replaceArrayRec(replace_symb, replace_by, st, has_read, has_write); replaceArrayRec(replace_symb, replace_by, st, has_read, has_write);
@@ -213,7 +215,7 @@ static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace
// A_copy = A // A_copy = A
SgAssignStmt* assign = new SgAssignStmt(*new SgArrayRefExp(*replace_by), *new SgArrayRefExp(*replace_symb)); SgAssignStmt* assign = new SgAssignStmt(*new SgArrayRefExp(*replace_by), *new SgArrayRefExp(*replace_symb));
assign->setlineNumber(getNextNegativeLineNumber()); // before region assign->setlineNumber(getNextNegativeLineNumber()); // before region
auto* parent = start->controlParent(); auto* parent = start_is_scope ? start : start->controlParent();
if (parent && parent->lastNodeOfStmt() == start) if (parent && parent->lastNodeOfStmt() == start)
parent = parent->controlParent(); parent = parent->controlParent();
@@ -230,13 +232,11 @@ static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace
} }
} }
static void replaceArrayInFragment(DIST::Array* arr, const set<SgStatement*> usages, SgSymbol* replace_by, SgStatement* start, SgStatement* last, const string& filename) static void replaceArrayInFragment(SgSymbol* replace_symb, const set<SgStatement*> usages, SgSymbol* replace_by, SgStatement* start, SgStatement* last, const string& filename)
{ {
while (start->lexNext() && !isSgExecutableStatement(start->lexNext())) while (start->lexNext() && !isSgExecutableStatement(start->lexNext()))
start = start->lexNext(); start = start->lexNext();
auto* replace_symb = arr->GetDeclSymbol();
set<SgStatement*> not_opened, not_closed, copied; set<SgStatement*> not_opened, not_closed, copied;
for (auto* it = start; it; it = it->controlParent()) for (auto* it = start; it; it = it->controlParent())
@@ -271,9 +271,9 @@ static void replaceArrayInFragment(DIST::Array* arr, const set<SgStatement*> usa
auto* scope_start = copy_scope, * scope_end = copy_scope->lastNodeOfStmt(); auto* scope_start = copy_scope, * scope_end = copy_scope->lastNodeOfStmt();
__spf_print(DEBUG_TRACE, "[scope to copy] %d\n", copy_scope->lineNumber()); __spf_print(DEBUG_TRACE, "[scope to copy] %d\n", copy_scope->lineNumber());
if (not_opened.find(copy_scope) != not_opened.end()) if (not_opened.find(copy_scope) != not_opened.end() && start != copy_scope)
{ {
auto* from = start->lastNodeOfStmt() ? start->lastNodeOfStmt() : start; auto* from = start;
for (auto* st = from; st; st = st->controlParent()) for (auto* st = from; st; st = st->controlParent())
{ {
__spf_print(DEBUG_TRACE, "[find start of parent %d] %d\n", copy_scope->lineNumber(), st->lineNumber()); __spf_print(DEBUG_TRACE, "[find start of parent %d] %d\n", copy_scope->lineNumber(), st->lineNumber());
@@ -286,7 +286,7 @@ static void replaceArrayInFragment(DIST::Array* arr, const set<SgStatement*> usa
} }
} }
if (not_closed.find(copy_scope) != not_closed.end()) if (not_closed.find(copy_scope) != not_closed.end() && last != copy_scope)
{ {
for (auto* st = last; st; st = st->controlParent()) for (auto* st = last; st; st = st->controlParent())
{ {
@@ -300,17 +300,34 @@ static void replaceArrayInFragment(DIST::Array* arr, const set<SgStatement*> usa
} }
} }
copyArrayBetweenStatements(replace_symb, replace_by, scope_start, scope_end); __spf_print(DEBUG_TRACE, "[copy %s] [%d, %d]\n", replace_symb->identifier(), scope_start->lineNumber(), scope_end->lineNumber());
__spf_print(DEBUG_TRACE, "[copy %s] [%d, %d]\n", arr->GetName().c_str(), scope_start->lineNumber(), scope_end->lineNumber()); copyArrayBetweenStatements(replace_symb, replace_by, scope_start, scope_end, copy_scope == scope_start);
copied.insert(copy_scope); copied.insert(copy_scope);
} }
} }
static bool ioReginBound(SgStatement* stat, SgStatement* last_io_bound) static bool ioReginBorder(SgStatement* stat, SgStatement* last_io_bound)
{ {
auto var = stat->variant(); auto var = stat->variant();
if (var == PROC_STAT || var == FUNC_STAT || var == PROG_HEDR || var == FUNC_HEDR || var == PROC_HEDR || var == FUNC_STAT || var == FOR_NODE || var == LOOP_NODE) static const set<int> border_stats =
{
PROC_STAT,
FUNC_STAT,
PROG_HEDR,
FUNC_HEDR,
PROC_HEDR,
FOR_NODE,
LOOP_NODE,
RETURN_NODE,
RETURN_STAT,
STOP_STAT,
STOP_NODE,
EXIT_STMT,
EXIT_NODE
};
if (border_stats.find(var) != border_stats.end())
return true; return true;
if (last_io_bound && last_io_bound->lastNodeOfStmt() && last_io_bound->lastNodeOfStmt() == stat) if (last_io_bound && last_io_bound->lastNodeOfStmt() && last_io_bound->lastNodeOfStmt() == stat)
@@ -318,23 +335,19 @@ static bool ioReginBound(SgStatement* stat, SgStatement* last_io_bound)
int parent_var; int parent_var;
if (var == CONTROL_END && if (var == CONTROL_END && border_stats.find(stat->controlParent()->variant()) != border_stats.end())
((parent_var = stat->controlParent()->variant()) == PROG_HEDR ||
parent_var == PROC_HEDR || parent_var == FUNC_HEDR))
{
return true; return true;
}
return false; return false;
} }
void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions, void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
const map<string, vector<FuncInfo*>>& allFuncInfo, const map<string, vector<FuncInfo*>>& allFuncInfo,
map<string, vector<Messages>>& SPF_messages, map<string, vector<Messages>>& SPF_messages,
map<string, map<int, set<string>>>& newDeclsToInclude) map<string, map<int, set<string>>>& newDeclsToInclude)
{ {
map<DIST::Array*, SgSymbol*> created_copies; map<SgSymbol*, SgSymbol*> created_copies;
map<string, map<int, set<string>>> copied; map<string, map<int, set<string>>> copied_syms;
for (auto& region : regions) for (auto& region : regions)
{ {
@@ -344,12 +357,14 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
{ {
const auto& filename = linesByFile.first; const auto& filename = linesByFile.first;
if (SgFile::switchToFile(filename) < 0) { if (SgFile::switchToFile(filename) < 0)
{
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
return; return;
} }
for (auto& lines : linesByFile.second) { for (auto& lines : linesByFile.second)
{
__spf_print(DEBUG_TRACE, "[fragment] %s: %d:%d %d\n", filename.c_str(), lines.lines.first, __spf_print(DEBUG_TRACE, "[fragment] %s: %d:%d %d\n", filename.c_str(), lines.lines.first,
lines.lines.second, lines.isImplicit()); lines.lines.second, lines.isImplicit());
@@ -370,7 +385,7 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
end = lines.stats.second->GetOriginal()->lexNext(); end = lines.stats.second->GetOriginal()->lexNext();
} }
map<DIST::Array*, set<SgStatement*>> need_replace; map<SgSymbol*, set<SgStatement*>> need_replace;
SgStatement* last_io_bound = NULL; SgStatement* last_io_bound = NULL;
@@ -395,8 +410,92 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
break; break;
} }
if (ioReginBound(curr_stmt, last_io_bound)) if (ioReginBorder(curr_stmt, last_io_bound))
{ {
for (const auto& by_array_to_copy : need_replace)
{
auto* array_to_copy = by_array_to_copy.first;
auto it = created_copies.find(array_to_copy);
if (it == created_copies.end())
{
string array_name = string(array_to_copy->identifier());
DIST::Array* array_p = getArrayFromDeclarated(declaratedInStmt(array_to_copy), array_name);
bool fromModule = (array_p->GetLocation().first == DIST::l_MODULE);
const string locationName = array_p->GetLocation().second;
auto place = *array_p->GetDeclInfo().begin();
string fileName = place.first;
string suffix = "_io_l";
if (fromModule)
suffix = "_io_m";
pair<SgSymbol*, SgSymbol*> copied;
copied.first = array_to_copy;
if (SgFile::switchToFile(fileName) == -1)
{
auto* func_stmt = curr_stmt->getScopeForDeclare();
SgStatement* insertPlace = NULL;
for (auto iterator = func_stmt->lexNext();
!isSgExecutableStatement(iterator) || isSPF_stat(iterator) &&
!(iterator->variant() == SPF_PARALLEL_REG_DIR || iterator->variant() == SPF_END_PARALLEL_REG_DIR);
iterator = iterator->lexNext())
{
insertPlace = iterator;
}
//NULL - no decl stats in function!
if (!insertPlace)
insertPlace = func_stmt;
auto st = insertPlace->controlParent();
if (st->variant() == GLOBAL)
st = insertPlace;
auto& copied_symb = array_to_copy->copy();
copied.second = &copied_symb;
auto new_name = string(array_to_copy->identifier()) + "_io_c";
copied_symb.changeName(new_name.c_str());
auto stat = array_to_copy->makeVarDeclStmt();
auto res = CalculateInteger(stat->expr(0)->copyPtr());
res->lhs()->setSymbol(copied_symb);
stat->setExpression(0, res);
insertPlace->insertStmtAfter(*stat, *st);
}
else
{
copied = copyArray(place, array_p, linesByFile.second, suffix + to_string(region->GetId()), fileName, newDeclsToInclude, copied_syms);
}
SgStatement* decl = SgStatement::getStatementByFileAndLine(place.first, place.second);
if (decl)
decl = decl->lexNext();
if (decl)
{
string dir_str;
if (decl->comments())
{
string str_comment = string(decl->comments());
if (str_comment.size() && str_comment.back() != '\n')
dir_str += "\n";
}
dir_str += "!$SPF ANALYSIS(PROCESS_PRIVATE(" + string(copied.second->identifier()) + "))\n";
decl->addComment(dir_str.c_str());
}
created_copies.insert({ array_to_copy, copied.second });
}
}
if (last_io_bound) if (last_io_bound)
{ {
__spf_print(DEBUG_TRACE, "[io region] [%d, %d]\n", last_io_bound->lineNumber(), curr_stmt->lineNumber()); __spf_print(DEBUG_TRACE, "[io region] [%d, %d]\n", last_io_bound->lineNumber(), curr_stmt->lineNumber());
@@ -429,47 +528,6 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
} }
populateDistributedIoArrays(need_replace, curr_stmt); populateDistributedIoArrays(need_replace, curr_stmt);
for (const auto& by_array_to_copy : need_replace)
{
auto* array_to_copy = by_array_to_copy.first;
auto it = created_copies.find(array_to_copy);
if (it == created_copies.end())
{
bool fromModule = (array_to_copy->GetLocation().first == DIST::l_MODULE);
const string locationName = array_to_copy->GetLocation().second;
auto place = *array_to_copy->GetDeclInfo().begin();
string fileName = place.first;
string suffix = "_io_l";
if (fromModule)
suffix = "_io_m";
auto origCopy = copyArray(place, array_to_copy, linesByFile.second, suffix + to_string(region->GetId()), fileName, newDeclsToInclude, copied);
SgStatement* decl = SgStatement::getStatementByFileAndLine(place.first, place.second);
if(decl)
decl = decl->lexNext();
if(decl)
{
string dir_str;
if (decl->comments())
{
string str_comment = string(decl->comments());
if(str_comment.size() && str_comment.back() != '\n')
dir_str += "\n";
}
dir_str += "!$SPF ANALYSIS(PROCESS_PRIVATE(" + string(origCopy.second->identifier()) + "))\n";
decl->addComment(dir_str.c_str());
}
created_copies.insert({ array_to_copy, origCopy.second });
}
}
curr_stmt = curr_stmt->lexNext(); curr_stmt = curr_stmt->lexNext();
} }
} }

View File

@@ -648,7 +648,7 @@ string removeIncludeStatsAndUnparse(SgFile *file, const char *fileName, const ch
if (wasDeleted) if (wasDeleted)
{ {
if (str.back() != '\n') if (str.size() || str.back() != '\n')
str += '\n'; str += '\n';
st->setComments(str.c_str()); st->setComments(str.c_str());
} }

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2372" #define VERSION_SPF "2375"