improved and fixed FDVM, added ISNERT_INCLUDES pass

This commit is contained in:
ALEXks
2023-12-16 17:42:11 +03:00
parent 110970caa6
commit 1f3d9944b8
10 changed files with 613 additions and 775 deletions

View File

@@ -2532,7 +2532,10 @@ void ACC_ParallelLoopEnd(SgStatement *pardo)
}
if (options.isOn(LOOP_ANALYSIS))
{
delete currentLoop;
currentLoop = NULL;
}
}
if (options.isOn(RTC))

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,12 @@
#include "dvm.h"
#include "aks_structs.h"
#include <vector>
#include <map>
#include <string>
using std::vector;
using std::string;
using std::map;
#define DEBUG_LV1 true
#if 1
@@ -16,22 +23,20 @@ SgExpression* findDirect(SgExpression *inExpr, int DIR)
if (inExpr)
{
if (inExpr->variant() == DIR)
{
return inExpr;
}
else
{
if (inExpr->lhs())
temp = findDirect(inExpr->lhs(), DIR);
if (inExpr->lhs())
temp = findDirect(inExpr->lhs(), DIR);
if(temp == NULL && inExpr->rhs())
if(temp == NULL && inExpr->rhs())
temp = findDirect(inExpr->rhs(), DIR);
}
}
return temp;
}
static SgSymbol** fillDataOfArray(SgExpression* on, int& dimInPar)
static vector<SgSymbol*> fillDataOfArray(SgExpression* on, int& dimInPar)
{
dimInPar = 0;
SgExpression* temp = on;
@@ -40,7 +45,8 @@ static SgSymbol** fillDataOfArray(SgExpression* on, int& dimInPar)
dimInPar++;
temp = temp->rhs();
}
SgSymbol** symbInPar = new SgSymbol * [dimInPar];
vector<SgSymbol*> symbInPar(dimInPar);
temp = on;
for (int i = 0; i < dimInPar; ++i)
{
@@ -50,20 +56,20 @@ static SgSymbol** fillDataOfArray(SgExpression* on, int& dimInPar)
return symbInPar;
}
SageArrayIdxs* GetIdxInParDir(const std::map<std::string, SgExpression*>& on, SgExpression *across, bool tie = false)
static void printError()
{
SageArrayIdxs *ret = new SageArrayIdxs();
SageArrayIdxs *act = ret;
int allDim = 0;
int dimInPar = 0;
SgSymbol** symbInPar = NULL;
ret->next = NULL;
ret->array_expr = NULL;
ret->read_write = -1;
ret->dim = 0;
ret->symb = NULL;
err("internal error in across", 424, first_do_par);
exit(-1);
}
static vector<SageArrayIdxs> GetIdxInParDir(const map<string, SgExpression*>& on, SgExpression *across, bool tie = false)
{
vector<SageArrayIdxs> ret;
int dimInPar = 0;
vector<SgSymbol*> symbInPar;
vector<SgExpression*> toAnalyze;
std::vector<SgExpression*> toAnalyze;
if (across->lhs()->variant() == EXPR_LIST)
toAnalyze.push_back(across->lhs());
else
@@ -80,15 +86,12 @@ SageArrayIdxs* GetIdxInParDir(const std::map<std::string, SgExpression*>& on, Sg
across = toAnalyze[i];
while (across)
{
if (symbInPar == NULL)
if (symbInPar.size() == 0)
{
if (on.size() == 0)
{
fprintf(stderr, "internal error in across convertion for GPU\n");
exit(-1);
}
printError();
else if (on.size() == 1)
symbInPar = fillDataOfArray(on.begin()->second, dimInPar);
symbInPar = fillDataOfArray(on.begin()->second, dimInPar);
}
SgExpression *t = across->lhs();
@@ -99,20 +102,14 @@ SageArrayIdxs* GetIdxInParDir(const std::map<std::string, SgExpression*>& on, Sg
if (t->variant() == ARRAY_REF)
{
if (on.find(t->symbol()->identifier()) == on.end())
{
fprintf(stderr, "internal error in across convertion for GPU\n");
exit(-1);
}
printError();
else
symbInPar = fillDataOfArray(on.find(t->symbol()->identifier())->second, dimInPar);
}
else if (t->variant() == ARRAY_OP)
{
if (on.find(t->lhs()->symbol()->identifier()) == on.end())
{
fprintf(stderr, "internal error in across convertion for GPU\n");
exit(-1);
}
printError();
else
symbInPar = fillDataOfArray(on.find(t->lhs()->symbol()->identifier())->second, dimInPar);
}
@@ -134,53 +131,50 @@ SageArrayIdxs* GetIdxInParDir(const std::map<std::string, SgExpression*>& on, Sg
dim++;
tmp = tmp->rhs();
}
act->next = new SageArrayIdxs();
act = act->next;
act->next = NULL;
act->symb = new SageSymbols*[dim];
act->dim = dim;
SageArrayIdxs act;
act.symb.resize(dim);
act.dim = dim;
for (int i = 0; i < dim; ++i)
{
act->symb[i] = new SageSymbols();
act->symb[i]->across_left = t->lhs()->lhs()->valueInteger();
act->symb[i]->across_right = t->lhs()->rhs()->valueInteger();
if (act->symb[i]->across_left != 0 || act->symb[i]->across_right != 0)
act->symb[i]->symb = symbInPar[i];
act.symb[i].across_left = t->lhs()->lhs()->valueInteger();
act.symb[i].across_right = t->lhs()->rhs()->valueInteger();
if (act.symb[i].across_left != 0 || act.symb[i].across_right != 0)
act.symb[i].symb = symbInPar[i];
else if (i < dimInPar)
act->symb[i]->symb = symbInPar[i];
act.symb[i].symb = symbInPar[i];
else
act->symb[i]->symb = NULL;
act->symb[i]->next = NULL;
act.symb[i].symb = NULL;
t = t->rhs();
}
allDim++;
ret.push_back(act);
across = across->rhs();
}
}
ret->dim = allDim;
return ret;
}
SageAcrossInfo* GetLoopsWithParAndAcrDir()
SageAcrossInfo GetLoopsWithParAndAcrDir()
{
SageAcrossInfo *q = NULL;
SageAcrossInfo retVal;
SgStatement *temp = dvm_parallel_dir;
if (temp->variant() == DVM_PARALLEL_ON_DIR)
{
SgExpression *t = findDirect(temp->expr(1), ACROSS_OP);
SgExpression *tie = findDirect(temp->expr(1), ACC_TIE_OP);
std::map<std::string, SgExpression*> arrays;
map<string, SgExpression*> arrays;
if (t != NULL)
{
q = new SageAcrossInfo();
if (temp->expr(0) && temp->expr(0)->lhs())
{
arrays[temp->expr(0)->symbol()->identifier()] = temp->expr(0)->lhs();
q->idx = GetIdxInParDir(arrays, t);
}
retVal.idxs = GetIdxInParDir(arrays, t);
}
else if (tie)
{
SgExpression* list = tie->lhs();
@@ -189,34 +183,24 @@ SageAcrossInfo* GetLoopsWithParAndAcrDir()
arrays[list->lhs()->symbol()->identifier()] = list->lhs()->lhs();
list = list->rhs();
}
q->idx = GetIdxInParDir(arrays, t, true);
retVal.idxs = GetIdxInParDir(arrays, t, true);
}
else
{
fprintf(stderr, "internal error in across convertion for GPU\n");
exit(-1);
}
q->next = NULL;
printError();
}
}
return q;
}
return retVal;
}
SageSymbols *GetSymbInParalell(int *n, SgExpression *first)
vector<SageSymbols> GetSymbInParalell(SgExpression *first)
{
SageSymbols *retval;
SageSymbols *p_t = new SageSymbols();
retval = p_t;
vector<SageSymbols> retval;
while(first)
{
SageSymbols *q = new SageSymbols();
q->len = -1;
q->next = NULL;
q->symb = first->lhs()->symbol();
p_t->next = q;
p_t = q;
n[0]++;
SageSymbols q(first->lhs()->symbol(), -1, 0, 0);
retval.push_back(q);
first = first->rhs();
}
return retval->next;
return retval;
}

View File

@@ -4757,7 +4757,7 @@ void RedistributeArray(SgSymbol *das, int idisars, SgExpression *distr_rule_list
if_st = doIfThenConstrForRedis(headref_flag,stdis,iamv); /*08.05.17*/
where = end_if = if_st->lexNext()->lexNext(); // reffer to ENDIF statement
i1 = ndvm;
if(ACC_program) /*ACC*/
if(ACC_program || parloop_by_handler) /*ACC*/
where->insertStmtBefore(*Redistribute_H(headref,sign),*where->controlParent());
amvref = (ia & TEMPLATE_BIT) ? headref : GetAMView( headref);
//inserting after ELSE
@@ -4838,7 +4838,7 @@ void RedistributeArray(SgSymbol *das, int idisars, SgExpression *distr_rule_list
else {
SgExpression *amvref;
if(ACC_program) /*ACC*/
if(ACC_program || parloop_by_handler) /*ACC*/
where->insertStmtBefore(*Redistribute_H(headref,sign),*where->controlParent());
amvref = (ia & TEMPLATE_BIT) ? headref : GetAMView( headref);
@@ -5108,7 +5108,7 @@ void RealignArray(SgSymbol *als, SgSymbol *tgs, int iaxis, int nr, SgExpression
return;
}
iamv = ndvm;
if(ACC_program ) /*ACC*/
if(ACC_program || parloop_by_handler) /*ACC*/
{ if( !(ia & POSTPONE_BIT) )
doCallAfter(Realign_H(HeaderRef(als),new_sign));
else {

View File

@@ -2668,7 +2668,7 @@ SgStatement *RTL_GPU_Init()
SgCallStmt *call = new SgCallStmt(*fdvm[DVMH_INIT]);
fmask[DVMH_INIT] = 2;
call -> addArg(*DVM000(ndvm));
if(!only_debug && ACC_program)
if(!only_debug && (ACC_program || parloop_by_handler))
call -> addComment(OpenMpComment_InitFlags(ndvm));
int flag = 1;

View File

@@ -282,7 +282,7 @@ void EndOfParallelLoopNest(SgStatement *stmt, SgStatement *end_stmt, SgStatement
ConsistentArraysStart(cons_list);
if(iconsg) {//there is synchronous CONSISTENT clause in PARALLEL
if(IN_COMPUTE_REGION || parloop_by_handler) /*ACC*/
if(IN_COMPUTE_REGION) /*ACC*/
// generating call statement:
// call dvmh_handle_consistent(ConsistGroupRef)
doCallAfter(HandleConsistent(consgref));
@@ -2227,6 +2227,8 @@ SgExpression *MappingList(SgStatement *stmt, SgExpression *aref)
(el = new SgExprListExp(*e))->setRhs(arglist);
arglist = el;
}
(el = new SgExprListExp(*ConstRef(nt)))->setRhs(arglist); // add rank to axis list
arglist = el;
return arglist;
}