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_END_CHECKSECTION_DIR 912 /* 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_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_END_CHECKSECTION_DIR ] = "ACC_END_CHECKSECTION_DIR";
tag [ ACC_ROUTINE_DIR ] = "ACC_ROUTINE_DIR";
tag [ ACC_DECLARE_DIR ] = "ACC_DECLARE_DIR";
tag [ ACC_TIE_OP ] = "ACC_TIE_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(DVM_NEW_VALUE_DIR,"nodetext",'s',1,BIFNODE, '_','_','_','_','_')
DEFNODECODE(ACC_ROUTINE_DIR,"nodetext",'s',1,BIFNODE, '_','_','_','_','_')
DEFNODECODE(ACC_DECLARE_DIR,"nodetext",'s',1,BIFNODE, '_','_','_','_','_')
/* SAPFOR */
DEFNODECODE(SPF_NOINLINE_OP, "nodetext",'e',0,LLNODE, '_','_','_','_','_')

View File

@@ -1787,6 +1787,8 @@ public:
inline SgSymbol *construct_name();
inline void replaceTrueBody(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();
};

View File

@@ -270,7 +270,9 @@ DEFNODECODE(ACC_CHECKSECTION_DIR, "%CMNT!DVM$%PUTTABCOMTHOSTSECTION%NL",
's',0,BIFNODE)
DEFNODECODE(ACC_END_CHECKSECTION_DIR,"%CMNT!DVM$%PUTTABCOMTEND HOSTSECTION%NL",
'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)
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 *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 *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];
@@ -288,6 +288,7 @@ void InitializeInFuncACC()
acc_return_list = NULL; /*ACC*/
acc_registered_list = NULL; /*ACC*/
registered_uses_list = NULL; /*ACC*/
acc_declared_list = NULL; /*ACC*/
}
int GeneratedForCuda()
@@ -977,6 +978,8 @@ void DeclareVarGPU(SgStatement *lstat, SgType *tlen)
/************************************************************************************/
void EnterDataRegionForAllocated(SgStatement *stmt)
{SgExpression *al;
if(!ACC_program)
return;
for(al=stmt->expr(0); al; al=al->rhs())
EnterDataRegion(al->lhs(),stmt);
@@ -1044,7 +1047,7 @@ void UnregisterVariables(int begin_block)
{
stmt_list *stl;
int is;
if (IN_MAIN_PROGRAM)
if (!ACC_program || IN_MAIN_PROGRAM)
return;
for (stl = acc_return_list; stl; stl = stl->next)
{
@@ -1101,6 +1104,15 @@ void DeclareDataRegionSaveVariables(SgStatement *lstat, SgType *tlen)
if (attr)
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)
@@ -1124,9 +1136,9 @@ void EnterDataRegionForLocalVariables(SgStatement *st, SgStatement *first_exec,
{
if (!el->lhs()) continue;
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)));
else
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)
{
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)));
else
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)
LINE_NUMBER_AFTER(first_exec,st);
}
@@ -1155,9 +1183,9 @@ void ExitDataRegionForLocalVariables(SgStatement *st, int is)
{
if (!el->lhs()) continue;
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;
if (!is++)
LINE_NUMBER_BEFORE(st,st);
@@ -1166,18 +1194,71 @@ void ExitDataRegionForLocalVariables(SgStatement *st, int is)
}
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;
if (!is++)
LINE_NUMBER_BEFORE(st,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)
{
SgExpression *el;
@@ -1204,6 +1285,8 @@ void CleanAllocatedList()
int ExitDataRegionForAllocated(SgStatement *st,int begin_block)
{
SgExpression *el;
if (!ACC_program)
return(0);
if (TestLocal(allocated_list))
{
@@ -1251,6 +1334,7 @@ int hasSameOriginalName(SgSymbol *s)
void EnterDataRegionForVariablesInMainProgram(SgStatement *st)
{
/*
symb_list *sl;
SgSymbol *s;
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());
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)
{
/*
symb_list *sl;
SgSymbol *s;
for(sl=registration; sl; sl=sl->next)
@@ -1286,6 +1394,37 @@ void ExitDataRegionForVariablesInMainProgram(SgStatement *st)
InsertNewStatementBefore(DataExit(new SgVarRefExp(s),0),st);
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)
{
if( options.isOn(NO_CUDA) )
if(!ACC_program || options.isOn(NO_CUDA) )
return;
int control_variant = stmt->controlParent()->controlParent()->variant();
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
if (!IN_MAIN_PROGRAM)
{
acc_registered_list = SymbolListsUnion(acc_registered_list, acc_array_list);
registered_uses_list = ExpressionListsUnion(registered_uses_list, uses_list);
}
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());
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
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)
{
st = AssignStatement(*new SgArrayRefExp(*redGrid, *e1), red_expr_ref->copy());
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--)
{
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):
ACC_ROUTINE_Directive(stmt);
continue;
case(ACC_DECLARE_DIR):
ACC_DECLARE_Directive(stmt);
continue;
case(HPF_TEMPLATE_STAT):
if(IN_MODULE && stmt->expr(1))
err("Illegal directive in module",632,stmt);
@@ -2679,6 +2682,8 @@ void TransFunc(SgStatement *func,SgStatement* &end_of_unit) {
break;
}
// checking semantics of DECLARE directives
testDeclareDirectives(stmt);
if(pstmt && (stmt != last))
pstmt = pstmt->next; //deleting first executable statement from
@@ -4239,7 +4244,6 @@ END_: // end of program unit
if(last_dvm_entry)
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
if(!IN_MODULE) {
if(has_contains)
MarkCoeffsAsUsed();
@@ -5294,6 +5298,7 @@ void DEALLOCATEf90_arrays(SgStatement *stmt)
} else
{ apr = al;
if(ACC_program) /*ACC*/
InsertNewStatementAfter(DataExit(&al->lhs()->copy(),0),cur_st,stmt->controlParent()); /*26.10.17*/
//if(ACC_program) /*ACC*/
// InsertNewStatementAfter(DestroyScalar(&al->lhs()->copy()),cur_st,stmt->controlParent());
@@ -10600,6 +10605,7 @@ void InsertDebugStat(SgStatement *func, SgStatement* &end_of_unit)
pstmt = addToStmtList(pstmt, stmt);
continue;
case(ACC_ROUTINE_DIR):
case(ACC_DECLARE_DIR):
case(HPF_PROCESSORS_STAT):
case(HPF_TEMPLATE_STAT):
case(DVM_DYNAMIC_DIR):
@@ -13760,6 +13766,7 @@ SgStatement *InterfaceBody(SgStatement *hedr)
case (DVM_POINTER_DIR):
case (DVM_HEAP_DIR):
case (DVM_ASYNCID_DIR):
case (ACC_DECLARE_DIR):
dvm_pred = stmt;
default:
continue;

View File

@@ -1453,6 +1453,8 @@ SgExpression *CreatePrivateDummyList();
SgExpression *CreatePrivateDummyList();
char *PointerNameForPrivateArray(SgSymbol *symb);
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);
/* acc_analyzer.cpp */

View File

@@ -107,6 +107,7 @@
#define ACC_CHECKSECTION_DIR 911 /* ACC Fortran */
#define ACC_END_CHECKSECTION_DIR 912 /* 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_INLOCAL_OP 931 /* ACC Fortran */

View File

@@ -1,10 +1,12 @@
acc_specification: acc_declare
| acc_routine
;
acc_directive: acc_region
| acc_end_region
| acc_checksection
| acc_end_checksection
| acc_get_actual
| acc_actual
| acc_routine
;
acc_region: ACC_REGION end_spec opt_clause
@@ -99,13 +101,45 @@ acc_end_checksection: ACC_END_CHECKSECTION
{ $$ = get_bfnd(fi,ACC_END_CHECKSECTION_DIR,SMNULL,LLNULL,LLNULL,LLNULL);}
;
acc_routine: ACC_ROUTINE in_dcl opt_targets_clause
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_routine_clauses
{ $$ = get_bfnd(fi,ACC_ROUTINE_DIR,SMNULL,$3,LLNULL,LLNULL);}
;
opt_targets_clause: needkeyword keywordoff
opt_routine_clauses:
{ $$ = LLNULL;}
| needkeyword targets_clause
{ $$ = $2;}
| routine_clause_list
{ $$ = $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
/* 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_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> 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 */
%type <ll_node> private_spec cuda_block_spec sizelist
@@ -852,6 +854,7 @@ spec: type_dcl
| common
| dimension
| dvm_specification /* FDVM */
| acc_specification /* FDVM */
| external
| intrinsic
| equivalence

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,13 @@
/* A Bison parser, made by GNU Bison 2.3. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Skeleton interface for Bison's Yacc-like parsers in C
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,9 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -33,12 +30,21 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YY_YY_GRAM1_TAB_H_INCLUDED
# define YY_YY_GRAM1_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
enum yytokentype
{
PERCENT = 1,
AMPERSAND = 2,
ASTER = 3,
@@ -359,411 +365,54 @@
ACC_CUDA_BLOCK = 318,
ACC_ROUTINE = 319,
ACC_TIE = 320,
BY = 321,
IO_MODE = 322,
CP_CREATE = 323,
CP_LOAD = 324,
CP_SAVE = 325,
CP_WAIT = 326,
FILES = 327,
VARLIST = 328,
STATUS = 329,
EXITINTERVAL = 330,
TEMPLATE_CREATE = 331,
TEMPLATE_DELETE = 332,
SPF_ANALYSIS = 333,
SPF_PARALLEL = 334,
SPF_TRANSFORM = 335,
SPF_NOINLINE = 336,
SPF_PARALLEL_REG = 337,
SPF_END_PARALLEL_REG = 338,
SPF_EXPAND = 339,
SPF_FISSION = 340,
SPF_SHRINK = 341,
SPF_CHECKPOINT = 342,
SPF_EXCEPT = 343,
SPF_FILES_COUNT = 344,
SPF_INTERVAL = 345,
SPF_TIME = 346,
SPF_ITER = 347,
SPF_FLEXIBLE = 348,
SPF_APPLY_REGION = 349,
SPF_APPLY_FRAGMENT = 350,
SPF_CODE_COVERAGE = 351,
SPF_UNROLL = 352,
SPF_MERGE = 353,
SPF_COVER = 354,
SPF_PROCESS_PRIVATE = 355,
BINARY_OP = 358,
UNARY_OP = 359
ACC_DECLARE = 321,
BY = 322,
IO_MODE = 323,
CP_CREATE = 324,
CP_LOAD = 325,
CP_SAVE = 326,
CP_WAIT = 327,
FILES = 328,
VARLIST = 329,
STATUS = 330,
EXITINTERVAL = 331,
TEMPLATE_CREATE = 332,
TEMPLATE_DELETE = 333,
SPF_ANALYSIS = 334,
SPF_PARALLEL = 335,
SPF_TRANSFORM = 336,
SPF_NOINLINE = 337,
SPF_PARALLEL_REG = 338,
SPF_END_PARALLEL_REG = 339,
SPF_EXPAND = 340,
SPF_FISSION = 341,
SPF_SHRINK = 342,
SPF_CHECKPOINT = 343,
SPF_EXCEPT = 344,
SPF_FILES_COUNT = 345,
SPF_INTERVAL = 346,
SPF_TIME = 347,
SPF_ITER = 348,
SPF_FLEXIBLE = 349,
SPF_APPLY_REGION = 350,
SPF_APPLY_FRAGMENT = 351,
SPF_CODE_COVERAGE = 352,
SPF_UNROLL = 353,
SPF_MERGE = 354,
SPF_COVER = 355,
SPF_PROCESS_PRIVATE = 356,
BINARY_OP = 359,
UNARY_OP = 360
};
#endif
/* Tokens. */
#define PERCENT 1
#define AMPERSAND 2
#define ASTER 3
#define CLUSTER 4
#define COLON 5
#define COMMA 6
#define DASTER 7
#define DEFINED_OPERATOR 8
#define DOT 9
#define DQUOTE 10
#define GLOBAL_A 11
#define LEFTAB 12
#define LEFTPAR 13
#define MINUS 14
#define PLUS 15
#define POINT_TO 16
#define QUOTE 17
#define RIGHTAB 18
#define RIGHTPAR 19
#define AND 20
#define DSLASH 21
#define EQV 22
#define EQ 23
#define EQUAL 24
#define FFALSE 25
#define GE 26
#define GT 27
#define LE 28
#define LT 29
#define NE 30
#define NEQV 31
#define NOT 32
#define OR 33
#define TTRUE 34
#define SLASH 35
#define XOR 36
#define REFERENCE 37
#define AT 38
#define ACROSS 39
#define ALIGN_WITH 40
#define ALIGN 41
#define ALLOCATABLE 42
#define ALLOCATE 43
#define ARITHIF 44
#define ASSIGNMENT 45
#define ASSIGN 46
#define ASSIGNGOTO 47
#define ASYNCHRONOUS 48
#define ASYNCID 49
#define ASYNCWAIT 50
#define BACKSPACE 51
#define BAD_CCONST 52
#define BAD_SYMBOL 53
#define BARRIER 54
#define BLOCKDATA 55
#define BLOCK 56
#define BOZ_CONSTANT 57
#define BYTE 58
#define CALL 59
#define CASE 60
#define CHARACTER 61
#define CHAR_CONSTANT 62
#define CHECK 63
#define CLOSE 64
#define COMMON 65
#define COMPLEX 66
#define COMPGOTO 67
#define CONSISTENT_GROUP 68
#define CONSISTENT_SPEC 69
#define CONSISTENT_START 70
#define CONSISTENT_WAIT 71
#define CONSISTENT 72
#define CONSTRUCT_ID 73
#define CONTAINS 74
#define CONTINUE 75
#define CORNER 76
#define CYCLE 77
#define DATA 78
#define DEALLOCATE 79
#define HPF_TEMPLATE 80
#define DEBUG 81
#define DEFAULT_CASE 82
#define DEFINE 83
#define DERIVED 84
#define DIMENSION 85
#define DISTRIBUTE 86
#define DOWHILE 87
#define DOUBLEPRECISION 88
#define DOUBLECOMPLEX 89
#define DP_CONSTANT 90
#define DVM_POINTER 91
#define DYNAMIC 92
#define ELEMENTAL 93
#define ELSE 94
#define ELSEIF 95
#define ELSEWHERE 96
#define ENDASYNCHRONOUS 97
#define ENDDEBUG 98
#define ENDINTERVAL 99
#define ENDUNIT 100
#define ENDDO 101
#define ENDFILE 102
#define ENDFORALL 103
#define ENDIF 104
#define ENDINTERFACE 105
#define ENDMODULE 106
#define ENDON 107
#define ENDSELECT 108
#define ENDTASK_REGION 109
#define ENDTYPE 110
#define ENDWHERE 111
#define ENTRY 112
#define EXIT 113
#define EOLN 114
#define EQUIVALENCE 115
#define ERROR 116
#define EXTERNAL 117
#define F90 118
#define FIND 119
#define FORALL 120
#define FORMAT 121
#define FUNCTION 122
#define GATE 123
#define GEN_BLOCK 124
#define HEAP 125
#define HIGH 126
#define IDENTIFIER 127
#define IMPLICIT 128
#define IMPLICITNONE 129
#define INCLUDE_TO 130
#define INCLUDE 131
#define INDEPENDENT 132
#define INDIRECT_ACCESS 133
#define INDIRECT_GROUP 134
#define INDIRECT 135
#define INHERIT 136
#define INQUIRE 137
#define INTERFACEASSIGNMENT 138
#define INTERFACEOPERATOR 139
#define INTERFACE 140
#define INTRINSIC 141
#define INTEGER 142
#define INTENT 143
#define INTERVAL 144
#define INOUT 145
#define IN 146
#define INT_CONSTANT 147
#define LABEL 148
#define LABEL_DECLARE 149
#define LET 150
#define LOCALIZE 151
#define LOGICAL 152
#define LOGICALIF 153
#define LOOP 154
#define LOW 155
#define MAXLOC 156
#define MAX 157
#define MAP 158
#define MINLOC 159
#define MIN 160
#define MODULE_PROCEDURE 161
#define MODULE 162
#define MULT_BLOCK 163
#define NAMEEQ 164
#define NAMELIST 165
#define NEW_VALUE 166
#define NEW 167
#define NULLIFY 168
#define OCTAL_CONSTANT 169
#define ONLY 170
#define ON 171
#define ON_DIR 172
#define ONTO 173
#define OPEN 174
#define OPERATOR 175
#define OPTIONAL 176
#define OTHERWISE 177
#define OUT 178
#define OWN 179
#define PARALLEL 180
#define PARAMETER 181
#define PAUSE 182
#define PLAINDO 183
#define PLAINGOTO 184
#define POINTER 185
#define POINTERLET 186
#define PREFETCH 187
#define PRINT 188
#define PRIVATE 189
#define PRODUCT 190
#define PROGRAM 191
#define PUBLIC 192
#define PURE 193
#define RANGE 194
#define READ 195
#define REALIGN_WITH 196
#define REALIGN 197
#define REAL 198
#define REAL_CONSTANT 199
#define RECURSIVE 200
#define REDISTRIBUTE_NEW 201
#define REDISTRIBUTE 202
#define REDUCTION_GROUP 203
#define REDUCTION_START 204
#define REDUCTION_WAIT 205
#define REDUCTION 206
#define REMOTE_ACCESS_SPEC 207
#define REMOTE_ACCESS 208
#define REMOTE_GROUP 209
#define RESET 210
#define RESULT 211
#define RETURN 212
#define REWIND 213
#define SAVE 214
#define SECTION 215
#define SELECT 216
#define SEQUENCE 217
#define SHADOW_ADD 218
#define SHADOW_COMPUTE 219
#define SHADOW_GROUP 220
#define SHADOW_RENEW 221
#define SHADOW_START_SPEC 222
#define SHADOW_START 223
#define SHADOW_WAIT_SPEC 224
#define SHADOW_WAIT 225
#define SHADOW 226
#define STAGE 227
#define STATIC 228
#define STAT 229
#define STOP 230
#define SUBROUTINE 231
#define SUM 232
#define SYNC 233
#define TARGET 234
#define TASK 235
#define TASK_REGION 236
#define THEN 237
#define TO 238
#define TRACEON 239
#define TRACEOFF 240
#define TRUNC 241
#define TYPE 242
#define TYPE_DECL 243
#define UNDER 244
#define UNKNOWN 245
#define USE 246
#define VIRTUAL 247
#define VARIABLE 248
#define WAIT 249
#define WHERE 250
#define WHERE_ASSIGN 251
#define WHILE 252
#define WITH 253
#define WRITE 254
#define COMMENT 255
#define WGT_BLOCK 256
#define HPF_PROCESSORS 257
#define IOSTAT 258
#define ERR 259
#define END 260
#define OMPDVM_ATOMIC 261
#define OMPDVM_BARRIER 262
#define OMPDVM_COPYIN 263
#define OMPDVM_COPYPRIVATE 264
#define OMPDVM_CRITICAL 265
#define OMPDVM_ONETHREAD 266
#define OMPDVM_DO 267
#define OMPDVM_DYNAMIC 268
#define OMPDVM_ENDCRITICAL 269
#define OMPDVM_ENDDO 270
#define OMPDVM_ENDMASTER 271
#define OMPDVM_ENDORDERED 272
#define OMPDVM_ENDPARALLEL 273
#define OMPDVM_ENDPARALLELDO 274
#define OMPDVM_ENDPARALLELSECTIONS 275
#define OMPDVM_ENDPARALLELWORKSHARE 276
#define OMPDVM_ENDSECTIONS 277
#define OMPDVM_ENDSINGLE 278
#define OMPDVM_ENDWORKSHARE 279
#define OMPDVM_FIRSTPRIVATE 280
#define OMPDVM_FLUSH 281
#define OMPDVM_GUIDED 282
#define OMPDVM_LASTPRIVATE 283
#define OMPDVM_MASTER 284
#define OMPDVM_NOWAIT 285
#define OMPDVM_NONE 286
#define OMPDVM_NUM_THREADS 287
#define OMPDVM_ORDERED 288
#define OMPDVM_PARALLEL 289
#define OMPDVM_PARALLELDO 290
#define OMPDVM_PARALLELSECTIONS 291
#define OMPDVM_PARALLELWORKSHARE 292
#define OMPDVM_RUNTIME 293
#define OMPDVM_SECTION 294
#define OMPDVM_SECTIONS 295
#define OMPDVM_SCHEDULE 296
#define OMPDVM_SHARED 297
#define OMPDVM_SINGLE 298
#define OMPDVM_THREADPRIVATE 299
#define OMPDVM_WORKSHARE 300
#define OMPDVM_NODES 301
#define OMPDVM_IF 302
#define IAND 303
#define IEOR 304
#define IOR 305
#define ACC_REGION 306
#define ACC_END_REGION 307
#define ACC_CHECKSECTION 308
#define ACC_END_CHECKSECTION 309
#define ACC_GET_ACTUAL 310
#define ACC_ACTUAL 311
#define ACC_TARGETS 312
#define ACC_ASYNC 313
#define ACC_HOST 314
#define ACC_CUDA 315
#define ACC_LOCAL 316
#define ACC_INLOCAL 317
#define ACC_CUDA_BLOCK 318
#define ACC_ROUTINE 319
#define ACC_TIE 320
#define BY 321
#define IO_MODE 322
#define CP_CREATE 323
#define CP_LOAD 324
#define CP_SAVE 325
#define CP_WAIT 326
#define FILES 327
#define VARLIST 328
#define STATUS 329
#define EXITINTERVAL 330
#define TEMPLATE_CREATE 331
#define TEMPLATE_DELETE 332
#define SPF_ANALYSIS 333
#define SPF_PARALLEL 334
#define SPF_TRANSFORM 335
#define SPF_NOINLINE 336
#define SPF_PARALLEL_REG 337
#define SPF_END_PARALLEL_REG 338
#define SPF_EXPAND 339
#define SPF_FISSION 340
#define SPF_SHRINK 341
#define SPF_CHECKPOINT 342
#define SPF_EXCEPT 343
#define SPF_FILES_COUNT 344
#define SPF_INTERVAL 345
#define SPF_TIME 346
#define SPF_ITER 347
#define SPF_FLEXIBLE 348
#define SPF_APPLY_REGION 349
#define SPF_APPLY_FRAGMENT 350
#define SPF_CODE_COVERAGE 351
#define SPF_UNROLL 352
#define SPF_MERGE 353
#define SPF_COVER 354
#define SPF_PROCESS_PRIVATE 355
#define BINARY_OP 358
#define UNARY_OP 359
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 438 "gram1.y"
union YYSTYPE
{
#line 439 "gram1.y" /* yacc.c:1909 */
int token;
char charv;
char *charp;
@@ -773,14 +422,18 @@ typedef union YYSTYPE
PTR_TYPE data_type;
PTR_HASH hash_entry;
PTR_LABEL label;
}
/* Line 1489 of yacc.c. */
#line 779 "gram1.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#line 427 "gram1.tab.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_GRAM1_TAB_H_INCLUDED */

View File

@@ -318,41 +318,42 @@
%token ACC_CUDA_BLOCK 318
%token ACC_ROUTINE 319
%token ACC_TIE 320
%token BY 321
%token IO_MODE 322
%token CP_CREATE 323
%token CP_LOAD 324
%token CP_SAVE 325
%token CP_WAIT 326
%token FILES 327
%token VARLIST 328
%token STATUS 329
%token EXITINTERVAL 330
%token TEMPLATE_CREATE 331
%token TEMPLATE_DELETE 332
%token SPF_ANALYSIS 333
%token SPF_PARALLEL 334
%token SPF_TRANSFORM 335
%token SPF_NOINLINE 336
%token SPF_PARALLEL_REG 337
%token SPF_END_PARALLEL_REG 338
%token SPF_EXPAND 339
%token SPF_FISSION 340
%token SPF_SHRINK 341
%token SPF_CHECKPOINT 342
%token SPF_EXCEPT 343
%token SPF_FILES_COUNT 344
%token SPF_INTERVAL 345
%token SPF_TIME 346
%token SPF_ITER 347
%token SPF_FLEXIBLE 348
%token SPF_APPLY_REGION 349
%token SPF_APPLY_FRAGMENT 350
%token SPF_CODE_COVERAGE 351
%token SPF_UNROLL 352
%token SPF_MERGE 353
%token SPF_COVER 354
%token SPF_PROCESS_PRIVATE 355
%token ACC_DECLARE 321
%token BY 322
%token IO_MODE 323
%token CP_CREATE 324
%token CP_LOAD 325
%token CP_SAVE 326
%token CP_WAIT 327
%token FILES 328
%token VARLIST 329
%token STATUS 330
%token EXITINTERVAL 331
%token TEMPLATE_CREATE 332
%token TEMPLATE_DELETE 333
%token SPF_ANALYSIS 334
%token SPF_PARALLEL 335
%token SPF_TRANSFORM 336
%token SPF_NOINLINE 337
%token SPF_PARALLEL_REG 338
%token SPF_END_PARALLEL_REG 339
%token SPF_EXPAND 340
%token SPF_FISSION 341
%token SPF_SHRINK 342
%token SPF_CHECKPOINT 343
%token SPF_EXCEPT 344
%token SPF_FILES_COUNT 345
%token SPF_INTERVAL 346
%token SPF_TIME 347
%token SPF_ITER 348
%token SPF_FLEXIBLE 349
%token SPF_APPLY_REGION 350
%token SPF_APPLY_FRAGMENT 351
%token SPF_CODE_COVERAGE 352
%token SPF_UNROLL 353
%token SPF_MERGE 354
%token SPF_COVER 355
%token SPF_PROCESS_PRIVATE 356
%{
#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
/* 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_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> 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 */
%type <ll_node> private_spec cuda_block_spec sizelist
@@ -1207,6 +1210,7 @@ spec: type_dcl
| common
| dimension
| dvm_specification /* FDVM */
| acc_specification /* FDVM */
| external
| intrinsic
| equivalence
@@ -7845,13 +7849,15 @@ op_slash_0 : {
operator_slash = 0;
};
acc_specification: acc_declare
| acc_routine
;
acc_directive: acc_region
| acc_end_region
| acc_checksection
| acc_end_checksection
| acc_get_actual
| acc_actual
| acc_routine
;
acc_region: ACC_REGION end_spec opt_clause
@@ -7946,16 +7952,48 @@ acc_end_checksection: ACC_END_CHECKSECTION
{ $$ = get_bfnd(fi,ACC_END_CHECKSECTION_DIR,SMNULL,LLNULL,LLNULL,LLNULL);}
;
acc_routine: ACC_ROUTINE in_dcl opt_targets_clause
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_routine_clauses
{ $$ = get_bfnd(fi,ACC_ROUTINE_DIR,SMNULL,$3,LLNULL,LLNULL);}
;
opt_targets_clause: needkeyword keywordoff
opt_routine_clauses:
{ $$ = LLNULL;}
| needkeyword targets_clause
{ $$ = $2;}
| routine_clause_list
{ $$ = $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_parallel
| spf_transform

View File

@@ -1345,10 +1345,15 @@ body:/* if(newname) {
{ prefix[5]=BLANKC; *endcd++ = '\0';}
else
*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;
while( ((c = getc(infile)) == ';') || (c == ' '))
restcd--;
if(c == '!') { /* delimiter ';' is ignored before comment */
restcd = 0;
goto stmt_end;
}
else
(void) ungetc(c,infile);
}
else if((c=='!') && (char_cntx==0)) {
@@ -1615,10 +1620,15 @@ body: /* Read body of line */
/*('\r\n' is end line marker in Windows) */
else
*endcd++ = '\0'; /* put NULL char in buffer as end marker */
if((c==';') && (char_cntx==0)) {
stmt_end: if((c==';') && (char_cntx==0)) {
restcd = 1;
while( ((c = getc(infile)) == ';') || (c == ' '))
;
if(c == '!') { /* delimiter ';' is ignored before comment */
restcd = 0;
goto stmt_end;
}
else
(void) ungetc(c,infile);
}
else if((c=='!') && (char_cntx==0)) {
@@ -2214,6 +2224,9 @@ analyz()
} else if (eqn(13, nextch, "doublecomplex")) {
stkey = DOUBLECOMPLEX;
nextch += 13;
} else if (eqn(7, nextch, "declare")) { /*ACC*/
stkey = ACC_DECLARE;
nextch += 7;
} else if (eqn(2, nextch, "do")) { /*OMP*/
if (OMP_program == 1) { /*OMP*/
stkey = OMPDVM_DO; /*OMP*/

View File

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

View File

@@ -1952,6 +1952,8 @@ copy_module_scope(sym_mod,list)
continue;
if(list && in_rename_list(source,list))
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)
continue;
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_END_CHECKSECTION_DIR 912 /* 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_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_END_CHECKSECTION_DIR ] = "ACC_END_CHECKSECTION_DIR";
tag [ ACC_ROUTINE_DIR ] = "ACC_ROUTINE_DIR";
tag [ ACC_DECLARE_DIR ] = "ACC_DECLARE_DIR";
tag [ ACC_TIE_OP ] = "ACC_TIE_OP";
tag [ ACC_INLOCAL_OP ] = "ACC_INLOCAL_OP";

View File

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

View File

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

View File

@@ -101,7 +101,7 @@ void Sleep(int millisec) { usleep(millisec * 2000); }
#define SERV "[SERVER]"
static const char* VERSION = "8";
static const char* VERSION = "9";
static FILE* logFile = NULL;
extern void __bst_create(const char* name);
@@ -540,7 +540,7 @@ int main(int argc, char** argv)
else
{
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());
if (argc == 2 && argv[1] == string("-unlock"))

View File

@@ -5,6 +5,7 @@
#include <string>
#include <map>
#include <set>
#include <ExpressionTransform/expr_transform.h>
using std::map;
using std::set;
@@ -12,6 +13,7 @@ using std::string;
using std::vector;
using std::to_string;
using std::make_pair;
using std::pair;
#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();
@@ -122,7 +124,7 @@ static void populateDistributedIoArrays(map<DIST::Array*, set<SgStatement*>>& ar
{
string array_name = string(by_symb->identifier());
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());
}
@@ -134,7 +136,7 @@ static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgExpression* e
if (!exp)
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_write |= from_write;
@@ -195,7 +197,7 @@ static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgStatement* st
}
}
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()))
start = start->lexNext();
@@ -204,7 +206,7 @@ static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace
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);
@@ -213,7 +215,7 @@ static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace
// A_copy = A
SgAssignStmt* assign = new SgAssignStmt(*new SgArrayRefExp(*replace_by), *new SgArrayRefExp(*replace_symb));
assign->setlineNumber(getNextNegativeLineNumber()); // before region
auto* parent = start->controlParent();
auto* parent = start_is_scope ? start : start->controlParent();
if (parent && parent->lastNodeOfStmt() == start)
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()))
start = start->lexNext();
auto* replace_symb = arr->GetDeclSymbol();
set<SgStatement*> not_opened, not_closed, copied;
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();
__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())
{
__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())
{
@@ -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", arr->GetName().c_str(), scope_start->lineNumber(), scope_end->lineNumber());
__spf_print(DEBUG_TRACE, "[copy %s] [%d, %d]\n", replace_symb->identifier(), scope_start->lineNumber(), scope_end->lineNumber());
copyArrayBetweenStatements(replace_symb, replace_by, scope_start, scope_end, copy_scope == scope_start);
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();
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;
if (last_io_bound && last_io_bound->lastNodeOfStmt() && last_io_bound->lastNodeOfStmt() == stat)
@@ -318,12 +335,8 @@ static bool ioReginBound(SgStatement* stat, SgStatement* last_io_bound)
int parent_var;
if (var == CONTROL_END &&
((parent_var = stat->controlParent()->variant()) == PROG_HEDR ||
parent_var == PROC_HEDR || parent_var == FUNC_HEDR))
{
if (var == CONTROL_END && border_stats.find(stat->controlParent()->variant()) != border_stats.end())
return true;
}
return false;
}
@@ -333,8 +346,8 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
map<string, vector<Messages>>& SPF_messages,
map<string, map<int, set<string>>>& newDeclsToInclude)
{
map<DIST::Array*, SgSymbol*> created_copies;
map<string, map<int, set<string>>> copied;
map<SgSymbol*, SgSymbol*> created_copies;
map<string, map<int, set<string>>> copied_syms;
for (auto& region : regions)
{
@@ -344,12 +357,14 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
{
const auto& filename = linesByFile.first;
if (SgFile::switchToFile(filename) < 0) {
if (SgFile::switchToFile(filename) < 0)
{
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
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,
lines.lines.second, lines.isImplicit());
@@ -370,7 +385,7 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
end = lines.stats.second->GetOriginal()->lexNext();
}
map<DIST::Array*, set<SgStatement*>> need_replace;
map<SgSymbol*, set<SgStatement*>> need_replace;
SgStatement* last_io_bound = NULL;
@@ -395,8 +410,92 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
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)
{
__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);
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();
}
}

View File

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

View File

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