Compare commits
6 Commits
4a06430139
...
dc18a17e5a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc18a17e5a | ||
|
|
2b9301e3a0 | ||
| 694f7bf9ec | |||
| a127a092e4 | |||
| 3ff2066a05 | |||
| 46529f4c3e |
@@ -5338,18 +5338,6 @@ SgStatement *doIfThenConstrForLoop_GPU(SgExpression *ref, SgStatement *endhost,
|
|||||||
return(ifst);
|
return(ifst);
|
||||||
}
|
}
|
||||||
|
|
||||||
SgExpression *ReductionPrivateVariables()
|
|
||||||
{
|
|
||||||
reduction_operation_list *rl;
|
|
||||||
SgExpression *red_vars=NULL;
|
|
||||||
for (rl = red_struct_list; rl; rl = rl->next)
|
|
||||||
{
|
|
||||||
red_vars = AddListToList(red_vars, new SgExprListExp(*new SgVarRefExp(rl->redvar)));
|
|
||||||
if (rl->locvar)
|
|
||||||
red_vars = AddListToList(red_vars, new SgExprListExp(*new SgVarRefExp(rl->locvar)));
|
|
||||||
}
|
|
||||||
return red_vars;
|
|
||||||
}
|
|
||||||
|
|
||||||
SgExpression * TranslateReductionToOpenmp(SgExpression *reduction_clause) /* OpenMP */
|
SgExpression * TranslateReductionToOpenmp(SgExpression *reduction_clause) /* OpenMP */
|
||||||
{
|
{
|
||||||
@@ -6015,20 +6003,20 @@ SgStatement *Create_Host_Loop_Subroutine_Main (SgSymbol *sHostProc)
|
|||||||
|
|
||||||
SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
||||||
{
|
{
|
||||||
SgStatement *stmt = NULL, *st_end = NULL, *st_hedr = NULL, *cur = NULL, *last_decl = NULL, *ass = NULL;
|
SgStatement *stmt = NULL, *st_end = NULL, *st_hedr = NULL, *cur = NULL, *last_decl = NULL, *ass = NULL;
|
||||||
SgStatement *alloc = NULL;
|
SgStatement *alloc = NULL;
|
||||||
SgStatement *paralleldo = NULL;
|
SgStatement *paralleldo = NULL;
|
||||||
SgStatement *firstdopar = NULL;
|
SgStatement *firstdopar = NULL;
|
||||||
SgExprListExp *parallellist = NULL;
|
SgExprListExp *parallellist = NULL;
|
||||||
SgExprListExp *omp_dolist = NULL;
|
SgExprListExp *omp_dolist = NULL;
|
||||||
SgExprListExp *omp_perflist = NULL;
|
SgExprListExp *omp_perflist = NULL;
|
||||||
SgExpression *ae, *arg_list = NULL, *el = NULL, *de = NULL, *tail = NULL, *baseMem_list = NULL;
|
SgExpression *ae, *arg_list = NULL, *el = NULL, *de = NULL, *tail = NULL, *baseMem_list = NULL;
|
||||||
SgSymbol *s_loop_ref = NULL, *sarg = NULL, *h_first = NULL, *hl = NULL;
|
SgSymbol *s_loop_ref = NULL, *sarg = NULL, *h_first = NULL, *hl = NULL;
|
||||||
SgSymbol *s_lgsc = NULL; /* OpenMP */
|
SgSymbol *s_lgsc = NULL; /* OpenMP */
|
||||||
SgVarRefExp *v_lgsc = NULL; /* OpenMP */
|
SgVarRefExp *v_lgsc = NULL; /* OpenMP */
|
||||||
SgSymbol *s = NULL, *s_low_bound = NULL, *s_high_bound = NULL, *s_step = NULL;
|
SgSymbol *s = NULL, *s_low_bound = NULL, *s_high_bound = NULL, *s_step = NULL;
|
||||||
symb_list *sl = NULL;
|
symb_list *sl = NULL;
|
||||||
SgType *tdvm = NULL;
|
SgType *tdvm = NULL;
|
||||||
int ln, lrank, addopenmp;
|
int ln, lrank, addopenmp;
|
||||||
char *name;
|
char *name;
|
||||||
tail = NULL;
|
tail = NULL;
|
||||||
@@ -6205,9 +6193,10 @@ SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
|||||||
int nr;
|
int nr;
|
||||||
SgExpression *ev, *ered, *er, *red;
|
SgExpression *ev, *ered, *er, *red;
|
||||||
SgSymbol *loc_var;
|
SgSymbol *loc_var;
|
||||||
|
reduction_operation_list *rl;
|
||||||
|
|
||||||
red = TranslateReductionToOpenmp(&red_list->copy()); /* OpenMP */
|
red = TranslateReductionToOpenmp(&red_list->copy()); /* OpenMP */
|
||||||
if(red != NULL) parallellist->append(*red); /* OpenMP */
|
if (red != NULL) parallellist->append(*red); /* OpenMP */
|
||||||
else addopenmp = 0; /* OpenMP */
|
else addopenmp = 0; /* OpenMP */
|
||||||
for (rl = red_struct_list,nr = 1; rl; rl = rl->next, nr++)
|
for (rl = red_struct_list,nr = 1; rl; rl = rl->next, nr++)
|
||||||
{
|
{
|
||||||
@@ -6220,12 +6209,10 @@ SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
|||||||
// generate loop_red_init and loop_red_post function calls
|
// generate loop_red_init and loop_red_post function calls
|
||||||
stmt = LoopRedInit_HH(s_loop_ref, nr, sred, rl->locvar);
|
stmt = LoopRedInit_HH(s_loop_ref, nr, sred, rl->locvar);
|
||||||
cur->insertStmtAfter(*stmt, *st_hedr);
|
cur->insertStmtAfter(*stmt, *st_hedr);
|
||||||
cur = stmt;
|
|
||||||
cur = stmt;
|
cur = stmt;
|
||||||
stmt = LoopRedPost_HH(s_loop_ref, nr, sred, rl->locvar);
|
stmt = LoopRedPost_HH(s_loop_ref, nr, sred, rl->locvar);
|
||||||
st_end->insertStmtBefore(*stmt, *st_hedr);
|
st_end->insertStmtBefore(*stmt, *st_hedr);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6264,7 +6251,7 @@ SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
|||||||
if (!options.isOn(O_HOST))
|
if (!options.isOn(O_HOST))
|
||||||
DeclareArrayCoefficients(st_hedr);
|
DeclareArrayCoefficients(st_hedr);
|
||||||
|
|
||||||
// <private_variables>
|
// <private_variables>
|
||||||
if ((addopenmp == 1) && (private_list != NULL)) parallellist->append(*new SgExpression(OMP_PRIVATE, new SgExprListExp(*private_list), NULL, NULL)); /* OpenMP */
|
if ((addopenmp == 1) && (private_list != NULL)) parallellist->append(*new SgExpression(OMP_PRIVATE, new SgExprListExp(*private_list), NULL, NULL)); /* OpenMP */
|
||||||
for (el = private_list; el; el = el->rhs())
|
for (el = private_list; el; el = el->rhs())
|
||||||
{
|
{
|
||||||
@@ -6286,7 +6273,7 @@ SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
|||||||
else indexes = new SgExprListExp(*el->lhs()); /* OpenMP */
|
else indexes = new SgExprListExp(*el->lhs()); /* OpenMP */
|
||||||
} /* OpenMP */
|
} /* OpenMP */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((addopenmp == 1) && (indexes != NULL)) parallellist->append(*new SgExpression(OMP_PRIVATE, indexes, NULL, NULL)); /* OpenMP */
|
if ((addopenmp == 1) && (indexes != NULL)) parallellist->append(*new SgExpression(OMP_PRIVATE, indexes, NULL, NULL)); /* OpenMP */
|
||||||
|
|
||||||
// create dummy argument declarations
|
// create dummy argument declarations
|
||||||
@@ -6338,6 +6325,7 @@ SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
|||||||
else firstdopar = stmt = first_do_par->copyPtr();
|
else firstdopar = stmt = first_do_par->copyPtr();
|
||||||
cur->insertStmtAfter(*stmt, *st_hedr);
|
cur->insertStmtAfter(*stmt, *st_hedr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (addopenmp == 1) { /* OpenMP */
|
if (addopenmp == 1) { /* OpenMP */
|
||||||
SgCallStmt *stDvmhstat = NULL;
|
SgCallStmt *stDvmhstat = NULL;
|
||||||
@@ -6352,10 +6340,7 @@ SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
|||||||
stDvmhstat = new SgCallStmt(*fdvm[OMP_STAT_BP],*omp_perflist);/* OpenMP */
|
stDvmhstat = new SgCallStmt(*fdvm[OMP_STAT_BP],*omp_perflist);/* OpenMP */
|
||||||
stDvmhstat->setlineNumber(-1);/* OpenMP */
|
stDvmhstat->setlineNumber(-1);/* OpenMP */
|
||||||
cur->insertStmtAfter(*stDvmhstat, *st_hedr); /* OpenMP */
|
cur->insertStmtAfter(*stDvmhstat, *st_hedr); /* OpenMP */
|
||||||
}
|
}
|
||||||
if (omp_red_vars) /* MINLOC/MAXLOC */ /* OpenMP */
|
|
||||||
st_end->insertStmtBefore(*omp_endparallel,*st_hedr); /* OpenMP */
|
|
||||||
else
|
|
||||||
lastdo->insertStmtAfter(*omp_endparallel); /* OpenMP */
|
lastdo->insertStmtAfter(*omp_endparallel); /* OpenMP */
|
||||||
if (omp_perf) {/* OpenMP */
|
if (omp_perf) {/* OpenMP */
|
||||||
stDvmhstat = new SgCallStmt(*fdvm[OMP_STAT_AL],*omp_perflist);/* OpenMP */
|
stDvmhstat = new SgCallStmt(*fdvm[OMP_STAT_AL],*omp_perflist);/* OpenMP */
|
||||||
@@ -6530,17 +6515,6 @@ SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
|||||||
if (alloc != NULL) cur->insertStmtAfter(*alloc, *st_hedr); /* OpenMP */
|
if (alloc != NULL) cur->insertStmtAfter(*alloc, *st_hedr); /* OpenMP */
|
||||||
ass->setlineNumber(-1); /* OpenMP */
|
ass->setlineNumber(-1); /* OpenMP */
|
||||||
} /* OpenMP */
|
} /* OpenMP */
|
||||||
cur->insertStmtAfter(*ass, *st_hedr); /* OpenMP */
|
|
||||||
if (omp_red_vars) { /* OpenMP */
|
|
||||||
//transfer of reduction initialization statements in case of maxloc/minloc
|
|
||||||
int i; /* OpenMP */
|
|
||||||
SgStatement *from = red_init_first->lexPrev(); /* OpenMP */
|
|
||||||
cur = omp_parallel; /* OpenMP */
|
|
||||||
for (i=number_of_reductions-1; i; i--) { /* OpenMP */
|
|
||||||
stmt = from->lexNext()->extractStmt(); /* OpenMP */
|
|
||||||
cur->insertStmtAfter(*stmt); /* OpenMP */
|
|
||||||
cur = stmt; /* OpenMP */
|
|
||||||
} /* OpenMP */
|
|
||||||
cur->insertStmtAfter(*ass, *st_hedr); /* OpenMP */
|
cur->insertStmtAfter(*ass, *st_hedr); /* OpenMP */
|
||||||
if (omp_perf) {/* OpenMP */
|
if (omp_perf) {/* OpenMP */
|
||||||
stDvmhstat = new SgCallStmt(*fdvm[OMP_STAT_BL],*omp_perflist);/* OpenMP */
|
stDvmhstat = new SgCallStmt(*fdvm[OMP_STAT_BL],*omp_perflist);/* OpenMP */
|
||||||
@@ -6549,7 +6523,6 @@ SgStatement *Create_Host_Loop_Subroutine(SgSymbol *sHostProc, int dependency)
|
|||||||
stDvmhstat = new SgCallStmt(*fdvm[OMP_STAT_AP],*omp_perflist);/* OpenMP */
|
stDvmhstat = new SgCallStmt(*fdvm[OMP_STAT_AP],*omp_perflist);/* OpenMP */
|
||||||
stDvmhstat->setlineNumber(-1);/* OpenMP */
|
stDvmhstat->setlineNumber(-1);/* OpenMP */
|
||||||
omp_endparallel->insertStmtAfter(*stDvmhstat);/* OpenMP */
|
omp_endparallel->insertStmtAfter(*stDvmhstat);/* OpenMP */
|
||||||
}/* OpenMP */
|
|
||||||
}/* OpenMP */
|
}/* OpenMP */
|
||||||
} /* OpenMP */
|
} /* OpenMP */
|
||||||
|
|
||||||
@@ -7970,21 +7943,6 @@ SgSymbol *RedVariableSymbolInKernel(SgSymbol *s, SgExpression *dimSizeArgs, SgEx
|
|||||||
|
|
||||||
return(soff);
|
return(soff);
|
||||||
}
|
}
|
||||||
|
|
||||||
SgSymbol *LocRedVariableSymbolInKernel(reduction_operation_list *rsl)
|
|
||||||
{
|
|
||||||
SgType *declT;
|
|
||||||
|
|
||||||
if (isSgArrayType(rsl->locvar->type()))
|
|
||||||
{
|
|
||||||
SgArrayType *arrT = new SgArrayType(*C_Type(rsl->locvar->type()));
|
|
||||||
arrT->addDimension(new SgValueExp(rsl->number));
|
|
||||||
declT = arrT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
declT = C_Type(rsl->locvar->type());
|
|
||||||
return (new SgVariableSymb(rsl->locvar->identifier(), *declT, *kernel_st));
|
|
||||||
}
|
|
||||||
|
|
||||||
SgSymbol *SymbolInKernel(SgSymbol *s)
|
SgSymbol *SymbolInKernel(SgSymbol *s)
|
||||||
{
|
{
|
||||||
@@ -8441,7 +8399,7 @@ void MakeDeclarationsForKernelGpuO1(SgSymbol *red_count_symb, SgType *idxTypeInK
|
|||||||
// declare do_variables
|
// declare do_variables
|
||||||
DeclareDoVars();
|
DeclareDoVars();
|
||||||
|
|
||||||
// declare private(local in kernel) variables
|
// declare private(local in kernel) variables
|
||||||
DeclarePrivateVars();
|
DeclarePrivateVars();
|
||||||
|
|
||||||
// declare dummy arguments:
|
// declare dummy arguments:
|
||||||
@@ -9581,7 +9539,7 @@ void MakeDeclarationsForKernel(SgSymbol *red_count_symb, SgType *idxTypeInKernel
|
|||||||
// declare do_variables
|
// declare do_variables
|
||||||
DeclareDoVars();
|
DeclareDoVars();
|
||||||
|
|
||||||
// declare private(local in kernel) variables
|
// declare private(local in kernel) variables
|
||||||
DeclarePrivateVars();
|
DeclarePrivateVars();
|
||||||
|
|
||||||
// declare dummy arguments:
|
// declare dummy arguments:
|
||||||
@@ -9643,7 +9601,7 @@ void MakeDeclarationsForKernel_On_C(SgType *idxTypeInKernel)
|
|||||||
// declare do_variables
|
// declare do_variables
|
||||||
DeclareDoVars(idxTypeInKernel);
|
DeclareDoVars(idxTypeInKernel);
|
||||||
|
|
||||||
// declare private(local in kernel) variables
|
// declare private(local in kernel) variables
|
||||||
DeclarePrivateVars();
|
DeclarePrivateVars();
|
||||||
|
|
||||||
// declare variables, used in loop and passed by reference:
|
// declare variables, used in loop and passed by reference:
|
||||||
@@ -9833,11 +9791,6 @@ void DeclareInternalPrivateVars()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarePrivateVars()
|
|
||||||
{
|
|
||||||
DeclarePrivateVars(C_UnsignedLongLongType());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeclarePrivateVars()
|
void DeclarePrivateVars()
|
||||||
{
|
{
|
||||||
SgStatement *st = NULL, *st_first=NULL;
|
SgStatement *st = NULL, *st_first=NULL;
|
||||||
@@ -9872,7 +9825,7 @@ void DeclarePrivateVars(SgType *idxTypeInKernel)
|
|||||||
if (Rank(s)>1)
|
if (Rank(s)>1)
|
||||||
{
|
{
|
||||||
char *name = new char[strlen(s->identifier())+7];
|
char *name = new char[strlen(s->identifier())+7];
|
||||||
sprintf(name, "_%s_dims", s->identifier());
|
sprintf(name, "_%s_dims", s->identifier());
|
||||||
s_dims = ArraySymbol(name, C_UnsignedLongLongType(), new SgValueExp(Rank(s)-1), kernel_st);
|
s_dims = ArraySymbol(name, C_UnsignedLongLongType(), new SgValueExp(Rank(s)-1), kernel_st);
|
||||||
SgExpression *einit = new SgExpression(INIT_LIST);
|
SgExpression *einit = new SgExpression(INIT_LIST);
|
||||||
SgExpression *elist = NULL;
|
SgExpression *elist = NULL;
|
||||||
@@ -9888,7 +9841,7 @@ void DeclarePrivateVars(SgType *idxTypeInKernel)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i=Rank(s)-1; i; i--)
|
for (int i=Rank(s)-1; i; i--)
|
||||||
elist = AddListToList(elist, Calculate(ArrayDimSize(s,i)));
|
elist = AddListToList(elist, Calculate(ArrayDimSize(s,i)));
|
||||||
}
|
}
|
||||||
einit->setLhs(elist);
|
einit->setLhs(elist);
|
||||||
@@ -10634,7 +10587,18 @@ void ReductionBlockInKernel_On_C_Cuda(SgStatement *stat, SgSymbol *i_var, SgExpr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rsl->locvar) // maxloc/minloc reduction scalar
|
else if (rsl->locvar) // maxloc/minloc reduction scalar
|
||||||
{
|
{
|
||||||
|
SgType *decl;
|
||||||
|
int rank = rsl->number;
|
||||||
|
|
||||||
|
if (rank > 1)
|
||||||
|
{
|
||||||
|
SgArrayType *arrT = new SgArrayType(*C_Type(rsl->locvar->type()));
|
||||||
|
arrT->addDimension(new SgValueExp(rank));
|
||||||
|
decl = arrT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
decl = C_Type(rsl->locvar->type());
|
||||||
newst = Declaration_Statement(new SgVariableSymb(rsl->locvar->identifier(), *decl, *kernel_st)); //declare location variable
|
newst = Declaration_Statement(new SgVariableSymb(rsl->locvar->identifier(), *decl, *kernel_st)); //declare location variable
|
||||||
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
||||||
|
|
||||||
@@ -10651,29 +10615,19 @@ void ReductionBlockInKernel_On_C_Cuda(SgStatement *stat, SgSymbol *i_var, SgExpr
|
|||||||
fun_ref->setRhs(tmplArgs);
|
fun_ref->setRhs(tmplArgs);
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
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));
|
newst = AssignStatement(new SgArrayRefExp(*rsl->red_grid, *BlockIdxRefExpr("x") * *ex1 + *ex), new SgVarRefExp(rsl->redvar));
|
||||||
if_st->insertStmtAfter(*newst);
|
if_st->insertStmtAfter(*newst);
|
||||||
|
|
||||||
if (rsl->number > 1)
|
if (rsl->number > 1)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < rsl->number; ++i)
|
for (int i = 0; i < rsl->number; ++i)
|
||||||
{
|
|
||||||
if (across)
|
|
||||||
newst = AssignStatement(new SgArrayRefExp(*rsl->loc_grid, *new SgValueExp(rsl->number) * *ex + *new SgValueExp(i)), new SgArrayRefExp(*rsl->locvar, *new SgValueExp(i)));
|
|
||||||
{
|
{
|
||||||
newst = AssignStatement(new SgArrayRefExp(*rsl->loc_grid, *new SgValueExp(rsl->number) * (*BlockIdxRefExpr("x") * *ex1 + *ex) + *new SgValueExp(i)), new SgArrayRefExp(*rsl->locvar, *new SgValueExp(i)));
|
newst = AssignStatement(new SgArrayRefExp(*rsl->loc_grid, *new SgValueExp(rsl->number) * (*BlockIdxRefExpr("x") * *ex1 + *ex) + *new SgValueExp(i)), new SgArrayRefExp(*rsl->locvar, *new SgValueExp(i)));
|
||||||
if_st->lastExecutable()->insertStmtAfter(*newst);
|
if_st->lastExecutable()->insertStmtAfter(*newst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (across)
|
|
||||||
newst = AssignStatement(new SgArrayRefExp(*rsl->loc_grid, *ex), new SgVarRefExp(*rsl->locvar));
|
|
||||||
{
|
{
|
||||||
newst = AssignStatement(new SgArrayRefExp(*rsl->loc_grid, *BlockIdxRefExpr("x") * *ex1 + *ex), new SgVarRefExp(*rsl->locvar));
|
newst = AssignStatement(new SgArrayRefExp(*rsl->loc_grid, *BlockIdxRefExpr("x") * *ex1 + *ex), new SgVarRefExp(*rsl->locvar));
|
||||||
if_st->lastExecutable()->insertStmtAfter(*newst);
|
if_st->lastExecutable()->insertStmtAfter(*newst);
|
||||||
|
|||||||
@@ -1588,7 +1588,6 @@ vector<ArgsForKernel> Create_C_Adapter_Function_Across_OneThread(SgSymbol *sadap
|
|||||||
for (int i = NumberOfCoeffs(sg); i>0; i--)
|
for (int i = NumberOfCoeffs(sg); i>0; i--)
|
||||||
funcCall->addArg(*new SgArrayRefExp(*sg, *new SgValueExp(i)));
|
funcCall->addArg(*new SgArrayRefExp(*sg, *new SgValueExp(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (red_list)
|
if (red_list)
|
||||||
{
|
{
|
||||||
reduction_operation_list *rsl;
|
reduction_operation_list *rsl;
|
||||||
@@ -1614,7 +1613,6 @@ vector<ArgsForKernel> Create_C_Adapter_Function_Across_OneThread(SgSymbol *sadap
|
|||||||
funcCall->addArg(*new SgArrayRefExp(*s, *new SgValueExp(i)));
|
funcCall->addArg(*new SgArrayRefExp(*s, *new SgValueExp(i)));
|
||||||
}
|
}
|
||||||
s = s->next();
|
s = s->next();
|
||||||
|
|
||||||
if (options.isOn(C_CUDA))
|
if (options.isOn(C_CUDA))
|
||||||
funcCall->addArg(*new SgVarRefExp(reduction_ptr[i]));
|
funcCall->addArg(*new SgVarRefExp(reduction_ptr[i]));
|
||||||
else
|
else
|
||||||
@@ -1740,8 +1738,8 @@ static inline void insertReductionArgs(SgSymbol **reduction_ptr, SgSymbol **redu
|
|||||||
SgFunctionCallExp *funcCallKernel, SgSymbol* numBlocks, int &has_red_array)
|
SgFunctionCallExp *funcCallKernel, SgSymbol* numBlocks, int &has_red_array)
|
||||||
{
|
{
|
||||||
reduction_operation_list *rsl;
|
reduction_operation_list *rsl;
|
||||||
SgSymbol *s = NULL;
|
SgSymbol *s;
|
||||||
SgExpression *e = NULL;
|
SgExpression *e;
|
||||||
|
|
||||||
for (rsl = red_struct_list, s = red_first; rsl; rsl = rsl->next) //s!=s_blocks_info
|
for (rsl = red_struct_list, s = red_first; rsl; rsl = rsl->next) //s!=s_blocks_info
|
||||||
{
|
{
|
||||||
@@ -1778,16 +1776,13 @@ static inline void insertReductionArgs(SgSymbol **reduction_ptr, SgSymbol **redu
|
|||||||
else
|
else
|
||||||
funcCallKernel->addArg(*new SgCastExp(*C_PointerType(new SgDescriptType(*SgTypeChar(), BIT_SIGNED)), *new SgVarRefExp(reduction_ptr[i])));
|
funcCallKernel->addArg(*new SgCastExp(*C_PointerType(new SgDescriptType(*SgTypeChar(), BIT_SIGNED)), *new SgVarRefExp(reduction_ptr[i])));
|
||||||
|
|
||||||
|
//TODO!!
|
||||||
if (rsl->locvar) //MAXLOC,MINLOC
|
if (rsl->locvar) //MAXLOC,MINLOC
|
||||||
{
|
{
|
||||||
for (int k = 0; k < rsl->number; ++k)
|
for (int k = 0; k < rsl->number; ++k)
|
||||||
funcCallKernel->addArg(*new SgArrayRefExp(*reduction_loc_symb[i], *new SgValueExp(k)));
|
funcCallKernel->addArg(*new SgArrayRefExp(*reduction_loc_symb[i], *new SgValueExp(k)));
|
||||||
s = s->next();
|
s = s->next();
|
||||||
|
e = new SgCastExp(*C_PointerType(options.isOn(C_CUDA) ? C_Type(rsl->locvar->type()) : new SgDescriptType(*SgTypeChar(), BIT_SIGNED)), *new SgVarRefExp(s));
|
||||||
if (options.isOn(C_CUDA))
|
|
||||||
e = new SgCastExp(*C_PointerType(C_Type(rsl->locvar->type())), *new SgVarRefExp(reduction_loc_ptr[i]));
|
|
||||||
else
|
|
||||||
e = new SgCastExp(*C_PointerType(new SgDescriptType(*SgTypeChar(), BIT_SIGNED)), *new SgVarRefExp(s));// TODO it like in C_Cuda
|
|
||||||
funcCallKernel->addArg(*e);
|
funcCallKernel->addArg(*e);
|
||||||
s = s->next();
|
s = s->next();
|
||||||
}
|
}
|
||||||
@@ -2447,7 +2442,6 @@ vector<ArgsForKernel> Create_C_Adapter_Function_Across_variants(SgSymbol *sadapt
|
|||||||
stmt = makeSymbolDeclarationWithInit(s, new SgValueExp(0));
|
stmt = makeSymbolDeclarationWithInit(s, new SgValueExp(0));
|
||||||
st_hedr->insertStmtAfter(*stmt, *st_hedr);
|
st_hedr->insertStmtAfter(*stmt, *st_hedr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create indxs
|
// create indxs
|
||||||
for (int i = 0; i < acrossV; ++i)
|
for (int i = 0; i < acrossV; ++i)
|
||||||
{
|
{
|
||||||
@@ -4222,7 +4216,7 @@ void MakeDeclarationsForKernel_On_C_Across(SgType *indexType)
|
|||||||
DeclareDoVars(indexType);
|
DeclareDoVars(indexType);
|
||||||
|
|
||||||
// declare private(local in kernel) variables
|
// declare private(local in kernel) variables
|
||||||
DeclarePrivateVars(indexType);
|
DeclarePrivateVars();
|
||||||
|
|
||||||
// declare variables, used in loop and passed by reference:
|
// declare variables, used in loop and passed by reference:
|
||||||
// <type> &<name> = *p_<name>;
|
// <type> &<name> = *p_<name>;
|
||||||
@@ -4239,7 +4233,7 @@ void MakeDeclarationsForKernelAcross(SgType *indexType)
|
|||||||
DeclareDoVars();
|
DeclareDoVars();
|
||||||
|
|
||||||
// declare private(local in kernel) variables
|
// declare private(local in kernel) variables
|
||||||
DeclarePrivateVars(indexType);
|
DeclarePrivateVars();
|
||||||
|
|
||||||
// declare dummy arguments:
|
// declare dummy arguments:
|
||||||
|
|
||||||
@@ -5835,7 +5829,6 @@ SgStatement *CreateLoopKernelAcross(SgSymbol *skernel, ArgsForKernel* argsKer, i
|
|||||||
flag_func_call = 0; // maxloc
|
flag_func_call = 0; // maxloc
|
||||||
else if (num == 10)
|
else if (num == 10)
|
||||||
flag_func_call = 0; // minloc
|
flag_func_call = 0; // minloc
|
||||||
|
|
||||||
if (flag_func_call == 1)
|
if (flag_func_call == 1)
|
||||||
{
|
{
|
||||||
SgFunctionCallExp *funcCall = new SgFunctionCallExp(*createNewFunctionSymbol(str_operation));
|
SgFunctionCallExp *funcCall = new SgFunctionCallExp(*createNewFunctionSymbol(str_operation));
|
||||||
@@ -5930,9 +5923,9 @@ SgStatement *CreateLoopKernelAcross(SgSymbol *skernel, ArgsForKernel* argsKer, i
|
|||||||
locGrid->setType(*new SgArrayType(*tmp_list->loc_grid->type()));
|
locGrid->setType(*new SgArrayType(*tmp_list->loc_grid->type()));
|
||||||
|
|
||||||
if (options.isOn(C_CUDA))
|
if (options.isOn(C_CUDA))
|
||||||
st = AssignStatement(*new SgArrayRefExp(*locGrid, *new SgValueExp(loc_el_num) * *e1 + *new SgValueExp(i)), *new SgArrayRefExp(*loc_var_ref->symbol(), *new SgValueExp(i)));
|
st = AssignStatement(*new SgArrayRefExp(*locGrid, *new SgValueExp(i), *e1), *new SgArrayRefExp(*loc_var_ref->symbol(), *new SgValueExp(i)));
|
||||||
else
|
else
|
||||||
st = AssignStatement(*new SgArrayRefExp(*locGrid, *new SgValueExp(i + 1), *e1), *new SgArrayRefExp(*loc_var_ref->symbol(), *new SgValueExp(i + 1)));//TODO it like in C_Cuda
|
st = AssignStatement(*new SgArrayRefExp(*locGrid, *new SgValueExp(i + 1), *e1), *new SgArrayRefExp(*loc_var_ref->symbol(), *new SgValueExp(i + 1)));
|
||||||
ifSt->insertStmtAfter(*st);
|
ifSt->insertStmtAfter(*st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6160,13 +6153,13 @@ void DeclarationOfReductionBlockInKernelAcross(SgExpression *ered, reduction_ope
|
|||||||
|
|
||||||
if (rsl->locvar)
|
if (rsl->locvar)
|
||||||
{
|
{
|
||||||
newst = Declaration_Statement(LocRedVariableSymbolInKernel(rsl)); //declare location variable
|
newst = Declaration_Statement(rsl->locvar); //declare location variable
|
||||||
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rsl->redvar_size > 0)
|
if (rsl->redvar_size > 0)
|
||||||
{
|
{
|
||||||
newst = Declaration_Statement(RedVariableSymbolInKernel(rsl->redvar,NULL,NULL)); //declare reduction variable
|
newst = Declaration_Statement(rsl->redvar); //declare reduction variable
|
||||||
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
||||||
}
|
}
|
||||||
else if (rsl->redvar_size < 0)
|
else if (rsl->redvar_size < 0)
|
||||||
@@ -6175,15 +6168,20 @@ void DeclarationOfReductionBlockInKernelAcross(SgExpression *ered, reduction_ope
|
|||||||
newst = Declaration_Statement(red_var_k); //declare reduction variable
|
newst = Declaration_Statement(red_var_k); //declare reduction variable
|
||||||
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
||||||
}
|
}
|
||||||
|
|
||||||
//XXX: shared memory doesnt use in ACROSS by C_Cuda
|
|
||||||
if (!options.isOn(C_CUDA))
|
|
||||||
{
|
|
||||||
rtype = (rsl->redvar_size >= 0) ? TypeOfRedBlockSymbol(ered) : red_var_k->type();
|
rtype = (rsl->redvar_size >= 0) ? TypeOfRedBlockSymbol(ered) : red_var_k->type();
|
||||||
|
|
||||||
s_block = RedBlockSymbolInKernelAcross(red_var, rtype);
|
s_block = RedBlockSymbolInKernelAcross(red_var, rtype);
|
||||||
|
|
||||||
newst = Declaration_Statement(s_block);
|
newst = Declaration_Statement(s_block);
|
||||||
|
|
||||||
|
if (options.isOn(C_CUDA))
|
||||||
|
newst->addDeclSpec(BIT_CUDA_SHARED | BIT_EXTERN);
|
||||||
|
else
|
||||||
|
{
|
||||||
eatr = new SgExprListExp(*new SgExpression(ACC_SHARED_OP));
|
eatr = new SgExprListExp(*new SgExpression(ACC_SHARED_OP));
|
||||||
newst->setExpression(2, *eatr);
|
newst->setExpression(2, *eatr);
|
||||||
|
}
|
||||||
|
|
||||||
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
kernel_st->insertStmtAfter(*newst, *kernel_st);
|
||||||
|
|
||||||
if (isSgExprListExp(ered->rhs())) //MAXLOC,MINLOC
|
if (isSgExprListExp(ered->rhs())) //MAXLOC,MINLOC
|
||||||
@@ -6191,7 +6189,6 @@ void DeclarationOfReductionBlockInKernelAcross(SgExpression *ered, reduction_ope
|
|||||||
typedecl = MakeStructDecl(rtype->symbol());
|
typedecl = MakeStructDecl(rtype->symbol());
|
||||||
kernel_st->insertStmtAfter(*typedecl, *kernel_st);
|
kernel_st->insertStmtAfter(*typedecl, *kernel_st);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarationCreateReductionBlocksAcross(int nloop, SgExpression *red_op_list)
|
void DeclarationCreateReductionBlocksAcross(int nloop, SgExpression *red_op_list)
|
||||||
|
|||||||
@@ -5,12 +5,10 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// special storages to avoid recomputing
|
// special storages to avoid recomputing
|
||||||
static map<string, SgExpression*> lhs;
|
map<string, SgExpression*> lhs;
|
||||||
static map<string, SgExpression*> rhs;
|
map<string, SgExpression*> rhs;
|
||||||
static map<SgExpression*, string> unparsedLhs;
|
map<SgExpression*, string> unparsedLhs;
|
||||||
static map<SgExpression*, string> unparsedRhs;
|
map<SgExpression*, string> unparsedRhs;
|
||||||
|
|
||||||
extern reduction_operation_list* red_struct_list;
|
|
||||||
|
|
||||||
template<typename InIt1, typename InIt2, typename OutIt>
|
template<typename InIt1, typename InIt2, typename OutIt>
|
||||||
static inline OutIt difference(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest)
|
static inline OutIt difference(InIt1 first1, InIt1 last1, InIt2 first2, InIt2 last2, OutIt dest)
|
||||||
@@ -1223,13 +1221,6 @@ Loop::Loop(SgStatement* loop_body, bool enable_opt, bool irreg_access) :
|
|||||||
irregular_acc_opt(irreg_access), enable_opt(enable_opt), loop_body(loop_body),
|
irregular_acc_opt(irreg_access), enable_opt(enable_opt), loop_body(loop_body),
|
||||||
dimension(0), acrossType(0), acrossDims(NULL), do_irreg_opt(false)
|
dimension(0), acrossType(0), acrossDims(NULL), do_irreg_opt(false)
|
||||||
{
|
{
|
||||||
reduction_operation_list* rsl;
|
|
||||||
for (rsl = red_struct_list; rsl; rsl = rsl->next)
|
|
||||||
{
|
|
||||||
if (rsl->locvar) //MAXLOC,MINLOC
|
|
||||||
redArrays.insert(rsl->locvar);
|
|
||||||
}
|
|
||||||
|
|
||||||
lhs.clear();
|
lhs.clear();
|
||||||
rhs.clear();
|
rhs.clear();
|
||||||
unparsedLhs.clear();
|
unparsedLhs.clear();
|
||||||
@@ -1429,7 +1420,7 @@ void Loop::analyzeAssignments(SgExpression* ex, const int blockIndex)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SgSymbol* symbol = ex->symbol();
|
SgSymbol* symbol = ex->symbol();
|
||||||
if (isSgArrayType(symbol->type()) != NULL && redArrays.find(symbol) == redArrays.end())
|
if (isSgArrayType(symbol->type()) != NULL)
|
||||||
{
|
{
|
||||||
SgExpression* subscripts = ((SgArrayRefExp*)(ex))->subscripts();
|
SgExpression* subscripts = ((SgArrayRefExp*)(ex))->subscripts();
|
||||||
if (!subscripts)
|
if (!subscripts)
|
||||||
@@ -1959,13 +1950,6 @@ void Loop::buildCFG()
|
|||||||
|
|
||||||
Loop::Loop(SgStatement* stmt) : do_irreg_opt(false)
|
Loop::Loop(SgStatement* stmt) : do_irreg_opt(false)
|
||||||
{
|
{
|
||||||
reduction_operation_list* rsl;
|
|
||||||
for (rsl = red_struct_list; rsl; rsl = rsl->next)
|
|
||||||
{
|
|
||||||
if (rsl->locvar) //MAXLOC,MINLOC
|
|
||||||
redArrays.insert(rsl->locvar);
|
|
||||||
}
|
|
||||||
|
|
||||||
lhs.clear(); rhs.clear(); unparsedLhs.clear(); unparsedRhs.clear();
|
lhs.clear(); rhs.clear(); unparsedLhs.clear(); unparsedRhs.clear();
|
||||||
buildCFG();
|
buildCFG();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ private:
|
|||||||
SgStatement* loop_body;
|
SgStatement* loop_body;
|
||||||
int dimension;
|
int dimension;
|
||||||
std::map<SgSymbol*, Array*> arrays;
|
std::map<SgSymbol*, Array*> arrays;
|
||||||
std::set<SgSymbol*> redArrays;
|
|
||||||
int* acrossDims;
|
int* acrossDims;
|
||||||
int acrossType;
|
int acrossType;
|
||||||
std::vector<SgSymbol*> symbols;
|
std::vector<SgSymbol*> symbols;
|
||||||
|
|||||||
@@ -1377,7 +1377,6 @@ int TestOneGroupStatement(SgStatement *stmt);
|
|||||||
int TestOneGroupStatement(SgStatement *stmt);
|
int TestOneGroupStatement(SgStatement *stmt);
|
||||||
void DeclareUsedVars();
|
void DeclareUsedVars();
|
||||||
void DeclareInternalPrivateVars();
|
void DeclareInternalPrivateVars();
|
||||||
void DeclarePrivateVars();
|
|
||||||
void DeclarePrivateVars();
|
void DeclarePrivateVars();
|
||||||
void DeclareArrayBases();
|
void DeclareArrayBases();
|
||||||
void DeclareArrayCoeffsInKernel(SgType*);
|
void DeclareArrayCoeffsInKernel(SgType*);
|
||||||
@@ -1452,7 +1451,6 @@ SgExpression * DummyListForPrivateArrays(SgStatement *st_hedr);
|
|||||||
SgExpression * DummyListForPrivateArrays(SgStatement *st_hedr);
|
SgExpression * DummyListForPrivateArrays(SgStatement *st_hedr);
|
||||||
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);
|
void GetMemoryForPrivateArrays(SgSymbol *private_first, SgSymbol *s_loop_ref, int nump, SgStatement *st_end, SgStatement *st_hedr, SgExpression *e_totalThreads);
|
||||||
|
|
||||||
/* acc_analyzer.cpp */
|
/* acc_analyzer.cpp */
|
||||||
|
|||||||
Reference in New Issue
Block a user