added new directives

This commit is contained in:
ALEXks
2024-04-09 16:41:48 +03:00
parent 1b4eb0c5c4
commit 2b48813783
23 changed files with 4084 additions and 3828 deletions

View File

@@ -619,3 +619,7 @@
#define SPF_PARAMETER_OP 969 /* SAPFOR */ #define SPF_PARAMETER_OP 969 /* SAPFOR */
#define SPF_CODE_COVERAGE_OP 970 /* SAPFOR */ #define SPF_CODE_COVERAGE_OP 970 /* SAPFOR */
#define SPF_UNROLL_OP 971 /* SAPFOR */ #define SPF_UNROLL_OP 971 /* SAPFOR */
#define SPF_COVER_OP 972 /* SAPFOR */
#define SPF_MERGE_OP 973 /* SAPFOR */
#define SPF_PROCESS_PRIVATE_OP 974 /* SAPFOR */

View File

@@ -621,3 +621,7 @@ script using "tag". Run make tag.h to regenerate this file */
tag [ SPF_PARAMETER_OP ] = "SPF_PARAMETER_OP"; tag [ SPF_PARAMETER_OP ] = "SPF_PARAMETER_OP";
tag [ SPF_CODE_COVERAGE_OP ] = "SPF_CODE_COVERAGE_OP"; tag [ SPF_CODE_COVERAGE_OP ] = "SPF_CODE_COVERAGE_OP";
tag [ SPF_UNROLL_OP ] = "SPF_UNROLL_OP"; tag [ SPF_UNROLL_OP ] = "SPF_UNROLL_OP";
tag [ SPF_COVER_OP ] = "SPF_COVER_OP";
tag [ SPF_MERGE_OP ] = "SPF_MERGE_OP";
tag [ SPF_PROCESS_PRIVATE_OP ] = "SPF_PROCESS_PRIVATE_OP";

View File

@@ -460,6 +460,9 @@ DEFNODECODE(SPF_FLEXIBLE_OP, "nodetext",'e',0,LLNODE, '_','_','_','_','_')
DEFNODECODE(SPF_PARAMETER_OP, "nodetext",'e',1,LLNODE, '_','_','_','_','_') DEFNODECODE(SPF_PARAMETER_OP, "nodetext",'e',1,LLNODE, '_','_','_','_','_')
DEFNODECODE(SPF_CODE_COVERAGE_OP, "nodetext",'e',0,LLNODE, '_','_','_','_','_') DEFNODECODE(SPF_CODE_COVERAGE_OP, "nodetext",'e',0,LLNODE, '_','_','_','_','_')
DEFNODECODE(SPF_UNROLL_OP, "nodetext",'e',1,LLNODE, '_','_','_','_','_') DEFNODECODE(SPF_UNROLL_OP, "nodetext",'e',1,LLNODE, '_','_','_','_','_')
DEFNODECODE(SPF_COVER_OP, "nodetext",'e',1,LLNODE, '_','_','_','_','_')
DEFNODECODE(SPF_MERGE_OP, "nodetext",'e',0,LLNODE, '_','_','_','_','_')
DEFNODECODE(SPF_PROCESS_PRIVATE_OP, "nodetext",'e',1,LLNODE, '_','_','_','_','_')
DEFNODECODE(SPF_ANALYSIS_DIR,"nodetext",'s',0,BIFNODE, '_','_','_','_','_') DEFNODECODE(SPF_ANALYSIS_DIR,"nodetext",'s',0,BIFNODE, '_','_','_','_','_')
DEFNODECODE(SPF_PARALLEL_DIR,"nodetext",'s',0,BIFNODE, '_','_','_','_','_') DEFNODECODE(SPF_PARALLEL_DIR,"nodetext",'s',0,BIFNODE, '_','_','_','_','_')

View File

@@ -432,5 +432,11 @@ DEFNODECODE(SPF_PARAMETER_OP, "PARAMETER (%LL1)",
'e',1,LLNODE) 'e',1,LLNODE)
DEFNODECODE(SPF_UNROLL_OP, "UNROLL %IF(%LL1 != %NULL)(%LL1)%ENDIF", DEFNODECODE(SPF_UNROLL_OP, "UNROLL %IF(%LL1 != %NULL)(%LL1)%ENDIF",
'e',1,LLNODE) 'e',1,LLNODE)
DEFNODECODE(SPF_MERGE_OP, "MERGE",
'e',0,LLNODE)
DEFNODECODE(SPF_COVER_OP, "COVER (%LL1)",
'e',1,LLNODE)
DEFNODECODE(SPF_PROCESS_PRIVATE_OP, "PROCESS_PRIVATE_OP (%LL1)",
'e',1,LLNODE)

View File

@@ -60,7 +60,9 @@ analysis_spec_list: analysis_spec
analysis_spec: analysis_reduction_spec analysis_spec: analysis_reduction_spec
| analysis_private_spec | analysis_private_spec
| analysis_process_private_spec
| analysis_parameter_spec | analysis_parameter_spec
| analysis_cover_spec
; ;
analysis_reduction_spec: needkeyword REDUCTION LEFTPAR reduction_list RIGHTPAR analysis_reduction_spec: needkeyword REDUCTION LEFTPAR reduction_list RIGHTPAR
@@ -71,6 +73,14 @@ analysis_private_spec: needkeyword PRIVATE LEFTPAR variable_list RIGHTPAR
{ $$ = make_llnd(fi,ACC_PRIVATE_OP,$4,LLNULL,SMNULL);} { $$ = make_llnd(fi,ACC_PRIVATE_OP,$4,LLNULL,SMNULL);}
; ;
analysis_process_private_spec: needkeyword SPF_PROCESS_PRIVATE LEFTPAR variable_list RIGHTPAR
{ $$ = make_llnd(fi,SPF_PROCESS_PRIVATE_OP,$4,LLNULL,SMNULL);}
;
analysis_cover_spec: needkeyword SPF_COVER LEFTPAR integer_constant RIGHTPAR
{ $$ = make_llnd(fi,SPF_COVER_OP,$4,LLNULL,SMNULL);}
;
analysis_parameter_spec: needkeyword PARAMETER LEFTPAR spf_parameter_list RIGHTPAR analysis_parameter_spec: needkeyword PARAMETER LEFTPAR spf_parameter_list RIGHTPAR
{ $$ = make_llnd(fi,SPF_PARAMETER_OP,$4,LLNULL,SMNULL);} { $$ = make_llnd(fi,SPF_PARAMETER_OP,$4,LLNULL,SMNULL);}
; ;
@@ -128,6 +138,8 @@ transform_spec: needkeyword SPF_NOINLINE
{ $$ = make_llnd(fi,SPF_UNROLL_OP,LLNULL,LLNULL,SMNULL);} { $$ = make_llnd(fi,SPF_UNROLL_OP,LLNULL,LLNULL,SMNULL);}
| needkeyword SPF_UNROLL LEFTPAR unroll_list RIGHTPAR | needkeyword SPF_UNROLL LEFTPAR unroll_list RIGHTPAR
{ $$ = make_llnd(fi,SPF_UNROLL_OP,$4,LLNULL,SMNULL);} { $$ = make_llnd(fi,SPF_UNROLL_OP,$4,LLNULL,SMNULL);}
| needkeyword SPF_MERGE
{ $$ = make_llnd(fi,SPF_MERGE_OP,LLNULL,LLNULL,SMNULL);}
; ;
unroll_list: expr COMMA expr COMMA expr unroll_list: expr COMMA expr COMMA expr

View File

@@ -281,6 +281,7 @@ static int in_vec = NO; /* set if processing array constructor */
%type <bf_node> spf_directive spf_analysis spf_parallel spf_transform spf_parallel_reg spf_end_parallel_reg %type <bf_node> spf_directive spf_analysis spf_parallel spf_transform spf_parallel_reg spf_end_parallel_reg
%type <bf_node> spf_checkpoint %type <bf_node> spf_checkpoint
%type <ll_node> analysis_spec_list analysis_spec analysis_reduction_spec analysis_private_spec analysis_parameter_spec %type <ll_node> analysis_spec_list analysis_spec analysis_reduction_spec analysis_private_spec analysis_parameter_spec
%type <ll_node> analysis_cover_spec analysis_process_private_spec
%type <ll_node> parallel_spec_list parallel_spec parallel_shadow_spec parallel_across_spec parallel_remote_access_spec %type <ll_node> parallel_spec_list parallel_spec parallel_shadow_spec parallel_across_spec parallel_remote_access_spec
%type <ll_node> transform_spec_list transform_spec array_element_list spf_parameter_list spf_parameter %type <ll_node> transform_spec_list transform_spec array_element_list spf_parameter_list spf_parameter
%type <ll_node> characteristic characteristic_list opt_clause_apply_region opt_clause_apply_fragment %type <ll_node> characteristic characteristic_list opt_clause_apply_region opt_clause_apply_fragment

File diff suppressed because it is too large Load Diff

View File

@@ -391,8 +391,11 @@
SPF_APPLY_FRAGMENT = 350, SPF_APPLY_FRAGMENT = 350,
SPF_CODE_COVERAGE = 351, SPF_CODE_COVERAGE = 351,
SPF_UNROLL = 352, SPF_UNROLL = 352,
BINARY_OP = 355, SPF_MERGE = 353,
UNARY_OP = 356 SPF_COVER = 354,
SPF_PROCESS_PRIVATE = 355,
BINARY_OP = 358,
UNARY_OP = 359
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
@@ -748,15 +751,18 @@
#define SPF_APPLY_FRAGMENT 350 #define SPF_APPLY_FRAGMENT 350
#define SPF_CODE_COVERAGE 351 #define SPF_CODE_COVERAGE 351
#define SPF_UNROLL 352 #define SPF_UNROLL 352
#define BINARY_OP 355 #define SPF_MERGE 353
#define UNARY_OP 356 #define SPF_COVER 354
#define SPF_PROCESS_PRIVATE 355
#define BINARY_OP 358
#define UNARY_OP 359
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 435 "gram1.y" #line 438 "gram1.y"
{ {
int token; int token;
char charv; char charv;
@@ -769,7 +775,7 @@ typedef union YYSTYPE
PTR_LABEL label; PTR_LABEL label;
} }
/* Line 1489 of yacc.c. */ /* Line 1489 of yacc.c. */
#line 773 "gram1.tab.h" #line 779 "gram1.tab.h"
YYSTYPE; YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1

View File

@@ -350,6 +350,9 @@
%token SPF_APPLY_FRAGMENT 350 %token SPF_APPLY_FRAGMENT 350
%token SPF_CODE_COVERAGE 351 %token SPF_CODE_COVERAGE 351
%token SPF_UNROLL 352 %token SPF_UNROLL 352
%token SPF_MERGE 353
%token SPF_COVER 354
%token SPF_PROCESS_PRIVATE 355
%{ %{
#include <string.h> #include <string.h>
@@ -633,6 +636,7 @@ static int in_vec = NO; /* set if processing array constructor */
%type <bf_node> spf_directive spf_analysis spf_parallel spf_transform spf_parallel_reg spf_end_parallel_reg %type <bf_node> spf_directive spf_analysis spf_parallel spf_transform spf_parallel_reg spf_end_parallel_reg
%type <bf_node> spf_checkpoint %type <bf_node> spf_checkpoint
%type <ll_node> analysis_spec_list analysis_spec analysis_reduction_spec analysis_private_spec analysis_parameter_spec %type <ll_node> analysis_spec_list analysis_spec analysis_reduction_spec analysis_private_spec analysis_parameter_spec
%type <ll_node> analysis_cover_spec analysis_process_private_spec
%type <ll_node> parallel_spec_list parallel_spec parallel_shadow_spec parallel_across_spec parallel_remote_access_spec %type <ll_node> parallel_spec_list parallel_spec parallel_shadow_spec parallel_across_spec parallel_remote_access_spec
%type <ll_node> transform_spec_list transform_spec array_element_list spf_parameter_list spf_parameter %type <ll_node> transform_spec_list transform_spec array_element_list spf_parameter_list spf_parameter
%type <ll_node> characteristic characteristic_list opt_clause_apply_region opt_clause_apply_fragment %type <ll_node> characteristic characteristic_list opt_clause_apply_region opt_clause_apply_fragment
@@ -8014,7 +8018,9 @@ analysis_spec_list: analysis_spec
analysis_spec: analysis_reduction_spec analysis_spec: analysis_reduction_spec
| analysis_private_spec | analysis_private_spec
| analysis_process_private_spec
| analysis_parameter_spec | analysis_parameter_spec
| analysis_cover_spec
; ;
analysis_reduction_spec: needkeyword REDUCTION LEFTPAR reduction_list RIGHTPAR analysis_reduction_spec: needkeyword REDUCTION LEFTPAR reduction_list RIGHTPAR
@@ -8025,6 +8031,14 @@ analysis_private_spec: needkeyword PRIVATE LEFTPAR variable_list RIGHTPAR
{ $$ = make_llnd(fi,ACC_PRIVATE_OP,$4,LLNULL,SMNULL);} { $$ = make_llnd(fi,ACC_PRIVATE_OP,$4,LLNULL,SMNULL);}
; ;
analysis_process_private_spec: needkeyword SPF_PROCESS_PRIVATE LEFTPAR variable_list RIGHTPAR
{ $$ = make_llnd(fi,SPF_PROCESS_PRIVATE_OP,$4,LLNULL,SMNULL);}
;
analysis_cover_spec: needkeyword SPF_COVER LEFTPAR integer_constant RIGHTPAR
{ $$ = make_llnd(fi,SPF_COVER_OP,$4,LLNULL,SMNULL);}
;
analysis_parameter_spec: needkeyword PARAMETER LEFTPAR spf_parameter_list RIGHTPAR analysis_parameter_spec: needkeyword PARAMETER LEFTPAR spf_parameter_list RIGHTPAR
{ $$ = make_llnd(fi,SPF_PARAMETER_OP,$4,LLNULL,SMNULL);} { $$ = make_llnd(fi,SPF_PARAMETER_OP,$4,LLNULL,SMNULL);}
; ;
@@ -8082,6 +8096,8 @@ transform_spec: needkeyword SPF_NOINLINE
{ $$ = make_llnd(fi,SPF_UNROLL_OP,LLNULL,LLNULL,SMNULL);} { $$ = make_llnd(fi,SPF_UNROLL_OP,LLNULL,LLNULL,SMNULL);}
| needkeyword SPF_UNROLL LEFTPAR unroll_list RIGHTPAR | needkeyword SPF_UNROLL LEFTPAR unroll_list RIGHTPAR
{ $$ = make_llnd(fi,SPF_UNROLL_OP,$4,LLNULL,SMNULL);} { $$ = make_llnd(fi,SPF_UNROLL_OP,$4,LLNULL,SMNULL);}
| needkeyword SPF_MERGE
{ $$ = make_llnd(fi,SPF_MERGE_OP,LLNULL,LLNULL,SMNULL);}
; ;
unroll_list: expr COMMA expr COMMA expr unroll_list: expr COMMA expr COMMA expr

View File

@@ -370,6 +370,7 @@ struct Keylist keys[] = {
{"copyin", OMPDVM_COPYIN},/*OMP*/ {"copyin", OMPDVM_COPYIN},/*OMP*/
{"copyprivate", OMPDVM_COPYPRIVATE},/*OMP*/ {"copyprivate", OMPDVM_COPYPRIVATE},/*OMP*/
{"corner", CORNER}, {"corner", CORNER},
{"cover", SPF_COVER}, /*SPF*/
/* {"criticalsection", CRITICALSECTION},*/ /* {"criticalsection", CRITICALSECTION},*/
{"cuda_block", ACC_CUDA_BLOCK}, /*ACC*/ {"cuda_block", ACC_CUDA_BLOCK}, /*ACC*/
{"cuda", ACC_CUDA}, /*ACC*/ {"cuda", ACC_CUDA}, /*ACC*/
@@ -494,7 +495,7 @@ struct Keylist keys[] = {
{"maxloc", MAXLOC}, {"maxloc", MAXLOC},
/* {"maxparallel", MAXPARALLEL},*/ /* {"maxparallel", MAXPARALLEL},*/
{"max", MAX}, {"max", MAX},
/* {"merger", MERGER},*/ {"merge", SPF_MERGE}, /*SPF*/
{"minloc", MINLOC}, {"minloc", MINLOC},
{"min", MIN}, {"min", MIN},
{"moduleprocedure", MODULE_PROCEDURE}, {"moduleprocedure", MODULE_PROCEDURE},
@@ -536,6 +537,7 @@ struct Keylist keys[] = {
{"private", PRIVATE}, {"private", PRIVATE},
/*!!! {"probe", PROBE}, */ /*!!! {"probe", PROBE}, */
/*!!! {"procedure", PROCEDURE},*/ /*!!! {"procedure", PROCEDURE},*/
{"process_private", SPF_PROCESS_PRIVATE}, /*SPF*/
{"product", PRODUCT}, {"product", PRODUCT},
{"program", PROGRAM}, {"program", PROGRAM},
/*!!! {"processcluster", PROCESS_CLUSTER},*/ /*!!! {"processcluster", PROCESS_CLUSTER},*/

View File

@@ -619,3 +619,7 @@
#define SPF_PARAMETER_OP 969 /* SAPFOR */ #define SPF_PARAMETER_OP 969 /* SAPFOR */
#define SPF_CODE_COVERAGE_OP 970 /* SAPFOR */ #define SPF_CODE_COVERAGE_OP 970 /* SAPFOR */
#define SPF_UNROLL_OP 971 /* SAPFOR */ #define SPF_UNROLL_OP 971 /* SAPFOR */
#define SPF_COVER_OP 972 /* SAPFOR */
#define SPF_MERGE_OP 973 /* SAPFOR */
#define SPF_PROCESS_PRIVATE_OP 974 /* SAPFOR */

View File

@@ -621,3 +621,7 @@ script using "tag". Run make tag.h to regenerate this file */
tag [ SPF_PARAMETER_OP ] = "SPF_PARAMETER_OP"; tag [ SPF_PARAMETER_OP ] = "SPF_PARAMETER_OP";
tag [ SPF_CODE_COVERAGE_OP ] = "SPF_CODE_COVERAGE_OP"; tag [ SPF_CODE_COVERAGE_OP ] = "SPF_CODE_COVERAGE_OP";
tag [ SPF_UNROLL_OP ] = "SPF_UNROLL_OP"; tag [ SPF_UNROLL_OP ] = "SPF_UNROLL_OP";
tag [ SPF_COVER_OP ] = "SPF_COVER_OP";
tag [ SPF_MERGE_OP ] = "SPF_MERGE_OP";
tag [ SPF_PROCESS_PRIVATE_OP ] = "SPF_PROCESS_PRIVATE_OP";

View File

@@ -350,3 +350,6 @@
#define SPF_APPLY_FRAGMENT 350 #define SPF_APPLY_FRAGMENT 350
#define SPF_CODE_COVERAGE 351 #define SPF_CODE_COVERAGE 351
#define SPF_UNROLL 352 #define SPF_UNROLL 352
#define SPF_MERGE 353
#define SPF_COVER 354
#define SPF_PROCESS_PRIVATE 355

View File

@@ -350,3 +350,6 @@ SPF_APPLY_REGION
SPF_APPLY_FRAGMENT SPF_APPLY_FRAGMENT
SPF_CODE_COVERAGE SPF_CODE_COVERAGE
SPF_UNROLL SPF_UNROLL
SPF_MERGE
SPF_COVER
SPF_PROCESS_PRIVATE

View File

@@ -84,7 +84,7 @@ static inline Symbol* getData(SgExpression *symb, Symbol**, bool moduleNameAdd =
} }
template<typename fillType> template<typename fillType>
void fillPrivatesFromComment(Statement *stIn, set<fillType> &privates) void fillPrivatesFromComment(Statement *stIn, set<fillType> &privates, int type)
{ {
if (stIn) if (stIn)
{ {
@@ -94,7 +94,10 @@ void fillPrivatesFromComment(Statement *stIn, set<fillType> &privates)
SgExpression *exprList = st->expr(0); SgExpression *exprList = st->expr(0);
while (exprList) while (exprList)
{ {
if (exprList->lhs()->variant() == ACC_PRIVATE_OP) const int var = exprList->lhs()->variant();
if ( ((var == ACC_PRIVATE_OP || var == SPF_PROCESS_PRIVATE_OP) && type == -1) ||
(var == ACC_PRIVATE_OP && var == type) ||
(var == SPF_PROCESS_PRIVATE_OP && var == type) )
{ {
SgExpression *list = exprList->lhs()->lhs(); SgExpression *list = exprList->lhs()->lhs();
while (list) while (list)
@@ -111,8 +114,8 @@ void fillPrivatesFromComment(Statement *stIn, set<fillType> &privates)
} }
} }
template void fillPrivatesFromComment(Statement *st, set<string> &privates); template void fillPrivatesFromComment(Statement *st, set<string> &privates, int type);
template void fillPrivatesFromComment(Statement *st, set<Symbol*> &privates); template void fillPrivatesFromComment(Statement *st, set<Symbol*> &privates, int type);
//XXX: need to remove message and to add implementation //XXX: need to remove message and to add implementation
extern map<string, vector<Messages>> SPF_messages; extern map<string, vector<Messages>> SPF_messages;
@@ -594,3 +597,28 @@ void fillInfoFromDirectives(const LoopGraph *loopInfo, ParallelDirective *direct
} }
} }
} }
int getCoverPropertyFromComment(Statement* stIn)
{
if (stIn)
{
SgStatement* st = stIn->GetOriginal();
if (st->variant() == SPF_ANALYSIS_DIR)
{
SgExpression* exprList = st->expr(0);
while (exprList)
{
if (exprList->lhs() && exprList->lhs()->variant() == SPF_COVER_OP)
{
auto value = exprList->lhs()->lhs();
if (value->isInteger())
return value->valueInteger();
else
return -1;
}
exprList = exprList->rhs();
}
}
}
return 0;
}

View File

@@ -11,7 +11,7 @@
bool isSPF_NoInline(Statement *stPrev); bool isSPF_NoInline(Statement *stPrev);
template<typename fillType> template<typename fillType>
void fillPrivatesFromComment(Statement *st, std::set<fillType> &privates); void fillPrivatesFromComment(Statement *st, std::set<fillType> &privates, int type = -1);
template<typename fillType> template<typename fillType>
void fillReductionsFromComment(Statement *st, std::map<std::string, std::set<fillType>> &reduction, bool moduleNameAdd = false); void fillReductionsFromComment(Statement *st, std::map<std::string, std::set<fillType>> &reduction, bool moduleNameAdd = false);
@@ -40,3 +40,5 @@ void fillShrinkFromComment(Statement *stIn, std::vector<std::pair<fillType, std:
template<typename fillType> template<typename fillType>
void fillCheckpointFromComment(Statement *stIn, std::map<int, Expression*> &clauses, std::set<fillType> &vars, std::set<fillType> &expt); void fillCheckpointFromComment(Statement *stIn, std::map<int, Expression*> &clauses, std::set<fillType> &vars, std::set<fillType> &expt);
int getCoverPropertyFromComment(Statement* stIn);

View File

@@ -156,6 +156,76 @@ static void fillVarsSets(SgStatement *iterator, SgStatement *end, set<string> &v
} }
} }
static bool checkCover(SgStatement* st,
SgStatement* attributeStatement,
const int coverLoops,
vector<Messages>& messagesForFile)
{
// COVER(VALUE)
const int var = st->variant();
bool retVal = true;
SgForStmt* forSt = (SgForStmt*)st;
const int nestedCount = countPerfectLoopNest(forSt);
if (coverLoops > nestedCount || coverLoops == 0)
{
__spf_print(1, "bad directive expression: expected %d nested loops on line %d but got %d on line %d\n",
coverLoops, attributeStatement->lineNumber(), nestedCount, st->lineNumber());
wstring messageE, messageR;
__spf_printToLongBuf(messageE, L"bad directive expression: expected %d nested loops on line %d but got %d",
coverLoops, attributeStatement->lineNumber(), nestedCount);
__spf_printToLongBuf(messageR, R77, coverLoops, attributeStatement->lineNumber(), nestedCount);
messagesForFile.push_back(Messages(ERROR, st->lineNumber(), messageR, messageE, 1043));
retVal = false;
}
return retVal;
}
static bool checkProcessPrivate(SgStatement* st,
SgStatement* attributeStatement,
const set<Symbol*>& privates,
vector<Messages>& messagesForFile)
{
// PROCESS_PRIVATE(VAR)
const int var = st->variant();
bool retVal = true;
if (!isSgExecutableStatement(st))
{
st = skipDvmDirs(st);
SgStatement* iterator = st;
SgStatement* end = st->lexNext();
set<string> varDef, varUse;
fillVarsSets(iterator, end, varDef, varUse);
for (auto& privElemS : privates)
{
const string privElem = privElemS->GetOriginal()->identifier();
bool defCond = true;
if (varDef.find(privElem) == varDef.end())
defCond = false;
if (!defCond)
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "variable declaration", RR1_2, "", L"", attributeStatement->lineNumber());
retVal = false;
}
}
}
else
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "variable declaration", RR1_2, "", L"", attributeStatement->lineNumber());
retVal = false;
}
return retVal;
}
static bool checkPrivate(SgStatement *st, static bool checkPrivate(SgStatement *st,
SgStatement *attributeStatement, SgStatement *attributeStatement,
const set<Symbol*> &privates, const set<Symbol*> &privates,
@@ -165,19 +235,16 @@ static bool checkPrivate(SgStatement *st,
const int var = st->variant(); const int var = st->variant();
bool retVal = true; bool retVal = true;
if (!isSgExecutableStatement(st) || var == FOR_NODE) if (var == FOR_NODE)
{ {
st = skipDvmDirs(st); st = skipDvmDirs(st);
SgStatement *iterator = st; SgStatement *iterator = st;
SgStatement *end = (var == FOR_NODE) ? st->lastNodeOfStmt() : st->lexNext(); SgStatement *end = st->lastNodeOfStmt();
set<string> varDef; set<string> varDef, varUse;
set<string> varUse;
fillVarsSets(iterator, end, varDef, varUse);
set<string> wrongPrivFromOmpParallel; set<string> wrongPrivFromOmpParallel;
for (auto &privElemS : privates) fillVarsSets(iterator, end, varDef, varUse);
for (auto& privElemS : privates)
{ {
const string privElem = privElemS->GetOriginal()->identifier(); const string privElem = privElemS->GetOriginal()->identifier();
bool defCond = true; bool defCond = true;
@@ -188,8 +255,6 @@ static bool checkPrivate(SgStatement *st,
if (varUse.find(privElem) == varUse.end()) if (varUse.find(privElem) == varUse.end())
useCond = false; useCond = false;
if (var == FOR_NODE)
{
if (!defCond && !useCond) if (!defCond && !useCond)
{ {
if (attributeStatement->localLineNumber() != 888) if (attributeStatement->localLineNumber() != 888)
@@ -222,17 +287,8 @@ static bool checkPrivate(SgStatement *st,
wrongPrivFromOmpParallel.insert(privElem); wrongPrivFromOmpParallel.insert(privElem);
} }
} }
else
{
if (!defCond)
{
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "variable declaration or", RR1_2, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
}
}
if (var == FOR_NODE && wrongPrivFromOmpParallel.size()) // remove unnecessary if (wrongPrivFromOmpParallel.size()) // remove unnecessary
{ {
if (wrongPrivFromOmpParallel.size() == privates.size()) // remove all if (wrongPrivFromOmpParallel.size() == privates.size()) // remove all
attributeStatement->expr(0)->lhs()->setLhs(NULL); attributeStatement->expr(0)->lhs()->setLhs(NULL);
@@ -252,7 +308,7 @@ static bool checkPrivate(SgStatement *st,
} }
else else
{ {
BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "variable declaration or", RR1_2, "DO statement", RR1_3, attributeStatement->lineNumber()); BAD_POSITION_FULL(1, ERROR, "before", RR1_1, "", L"", "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false; retVal = false;
} }
@@ -1246,17 +1302,17 @@ static bool checkFissionPrivatesExpansion(SgStatement *st,
addSPFtoAttr(s, currFile, usersDirectives); addSPFtoAttr(s, currFile, usersDirectives);
SgForStmt *forSt = (SgForStmt*)st; SgForStmt *forSt = (SgForStmt*)st;
if (vars.size() > countPerfectLoopNest(forSt)) const int nestedCount = countPerfectLoopNest(forSt);
if (vars.size() > nestedCount)
{ {
__spf_print(1, "bad directive expression: expected %d nested loops on line %d but got %d on line %d\n", __spf_print(1, "bad directive expression: expected %d nested loops on line %d but got %d on line %d\n",
(int)vars.size(), attributeStatement->lineNumber(), countPerfectLoopNest(forSt), st->lineNumber()); (int)vars.size(), attributeStatement->lineNumber(), nestedCount, st->lineNumber());
wstring messageE, messageR; wstring messageE, messageR;
__spf_printToLongBuf(messageE, L"bad directive expression: expected %d nested loops on line %d but got %d", __spf_printToLongBuf(messageE, L"bad directive expression: expected %d nested loops on line %d but got %d",
(int)vars.size(), attributeStatement->lineNumber(), countPerfectLoopNest(forSt)); (int)vars.size(), attributeStatement->lineNumber(), nestedCount);
__spf_printToLongBuf(messageR, R77, __spf_printToLongBuf(messageR, R77, (int)vars.size(), attributeStatement->lineNumber(), nestedCount);
(int)vars.size(), attributeStatement->lineNumber(), countPerfectLoopNest(forSt));
messagesForFile.push_back(Messages(ERROR, st->lineNumber(), messageR, messageE, 1043)); messagesForFile.push_back(Messages(ERROR, st->lineNumber(), messageR, messageE, 1043));
@@ -1708,18 +1764,29 @@ static inline bool processStat(SgStatement *st, const string &currFile,
SgAttribute *attr = st->getAttribute(i); SgAttribute *attr = st->getAttribute(i);
SgStatement *attributeStatement = (SgStatement *)(attr->getAttributeData()); SgStatement *attributeStatement = (SgStatement *)(attr->getAttributeData());
int type = st->attributeType(i); int type = st->attributeType(i);
int count;
if (type == SPF_ANALYSIS_DIR) if (type == SPF_ANALYSIS_DIR)
{ {
// !$SPF ANALYSIS // !$SPF ANALYSIS
// PRIVATE(VAR) // PRIVATE(VAR)
set<Symbol*> privates; set<Symbol*> privates;
fillPrivatesFromComment(new Statement(attributeStatement), privates); fillPrivatesFromComment(new Statement(attributeStatement), privates, ACC_PRIVATE_OP);
if (privates.size()) if (privates.size())
{ {
bool result = checkPrivate(st, attributeStatement, privates, messagesForFile); bool result = checkPrivate(st, attributeStatement, privates, messagesForFile);
retVal = retVal && result; retVal = retVal && result;
} }
// PROCESS_PRIVATE(VAR)
privates.clear();
fillPrivatesFromComment(new Statement(attributeStatement), privates, SPF_PROCESS_PRIVATE_OP);
if (privates.size())
{
bool result = checkProcessPrivate(st, attributeStatement, privates, messagesForFile);
retVal = retVal && result;
}
// REDUCTION(OP(VAR), MIN/MAXLOC(VAR, ARRAY, CONST)) // REDUCTION(OP(VAR), MIN/MAXLOC(VAR, ARRAY, CONST))
map<string, set<Symbol*>> reduction; map<string, set<Symbol*>> reduction;
map<string, set<tuple<Symbol*, Symbol*, int>>> reductionLoc; map<string, set<tuple<Symbol*, Symbol*, int>>> reductionLoc;
@@ -1740,10 +1807,27 @@ static inline bool processStat(SgStatement *st, const string &currFile,
bool result = checkParameter(st, attributeStatement, assigns, messagesForFile); bool result = checkParameter(st, attributeStatement, assigns, messagesForFile);
retVal = retVal && result; retVal = retVal && result;
} }
// COVER
if (isSPF_OP(attributeStatement, SPF_COVER_OP) && (count = countSPF_OP(st, SPF_ANALYSIS_DIR, SPF_COVER_OP)))
{
attributeStatement->setLocalLineNumber(-1);
if (count > 1 || st->variant() != FOR_NODE)
{
BAD_POSITION_FULL(1, ERROR, "once", RR1_7, "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
else
{
bool result = checkCover(st, attributeStatement, getCoverPropertyFromComment(new Statement(attributeStatement)), messagesForFile);
retVal = retVal && result;
}
}
} }
else if (type == SPF_PARALLEL_DIR) else if (type == SPF_PARALLEL_DIR)
{ {
// !$SPF PARALLEL // !$SPF PARALLEL
// SHADOW (VAR(list of shadows)) / ACROSS (VAR(list of shadows)) // SHADOW (VAR(list of shadows)) / ACROSS (VAR(list of shadows))
vector<pair<pair<Symbol*, string>, vector<pair<int, int>>>> data; vector<pair<pair<Symbol*, string>, vector<pair<int, int>>>> data;
fillShadowAcrossFromComment(SHADOW_OP, new Statement(attributeStatement), data); fillShadowAcrossFromComment(SHADOW_OP, new Statement(attributeStatement), data);
@@ -1766,7 +1850,6 @@ static inline bool processStat(SgStatement *st, const string &currFile,
else if (type == SPF_TRANSFORM_DIR) else if (type == SPF_TRANSFORM_DIR)
{ {
// !$SPF TRANSFORM // !$SPF TRANSFORM
int count;
// NOINLINE // NOINLINE
if (isSPF_NoInline(new Statement(st))) if (isSPF_NoInline(new Statement(st)))
@@ -1815,7 +1898,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
// SHRINK // SHRINK
if (isSPF_OP(attributeStatement, SPF_SHRINK_OP)) if (isSPF_OP(attributeStatement, SPF_SHRINK_OP))
{ {
attributeStatement->setLocalLineNumber(-1); // is it needed? attributeStatement->setLocalLineNumber(-1);
if (st->variant() != FOR_NODE) if (st->variant() != FOR_NODE)
{ {
BAD_POSITION_FULL(1, ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber()); BAD_POSITION_FULL(1, ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
@@ -1838,6 +1921,17 @@ static inline bool processStat(SgStatement *st, const string &currFile,
retVal = false; retVal = false;
} }
} }
// MERGE
if (isSPF_OP(attributeStatement, SPF_MERGE_OP))
{
attributeStatement->setLocalLineNumber(-1);
if (st->variant() != FOR_NODE)
{
BAD_POSITION_FULL(1, ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
retVal = false;
}
}
} }
else if (type == SPF_CHECKPOINT_DIR) else if (type == SPF_CHECKPOINT_DIR)
{ {

View File

@@ -1041,9 +1041,14 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
if (internalExit < 0) if (internalExit < 0)
throw -1; throw -1;
bool applyFor = (curr_regime == LOOPS_SPLITTER || curr_regime == LOOPS_COMBINER || curr_regime == PRIVATE_REMOVING || set<int> applyFor = { LOOPS_SPLITTER,
curr_regime == PRIVATE_ARRAYS_EXPANSION || curr_regime == PRIVATE_ARRAYS_SHRINKING); LOOPS_COMBINER,
if ((countOfTransform == 0 || internalExit > 0) && applyFor) PRIVATE_REMOVING,
PRIVATE_ARRAYS_EXPANSION,
PRIVATE_ARRAYS_SHRINKING,
REMOVE_DEAD_CODE };
if ((countOfTransform == 0 || internalExit > 0) && applyFor.find(curr_regime) != applyFor.end())
{ {
SgStatement* mainUnit = findMainUnit(&project, SPF_messages); SgStatement* mainUnit = findMainUnit(&project, SPF_messages);
checkNull(mainUnit, convertFileName(__FILE__).c_str(), __LINE__); checkNull(mainUnit, convertFileName(__FILE__).c_str(), __LINE__);

View File

@@ -381,11 +381,12 @@ public:
}; };
void removeDeadCode(SgStatement* func, int removeDeadCode(SgStatement* func,
const map<string, vector<FuncInfo*>>& allFuncs, const map<string, vector<FuncInfo*>>& allFuncs,
const map<string, CommonBlock*>& commonBlocks, const map<string, CommonBlock*>& commonBlocks,
SgStatement* intervalDelStart, SgStatement* intervalDelEnd) SgStatement* intervalDelStart, SgStatement* intervalDelEnd)
{ {
int countOfTransform = 0;
if (intervalDelStart && !intervalDelEnd || !intervalDelStart && intervalDelEnd) if (intervalDelStart && !intervalDelEnd || !intervalDelStart && intervalDelEnd)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
@@ -521,6 +522,7 @@ void removeDeadCode(SgStatement* func,
__spf_print(PRINT_USELESS_STATEMENTS, "[Useless statement on line %d and file %s]\n", rem->lineNumber(), rem->fileName()); __spf_print(PRINT_USELESS_STATEMENTS, "[Useless statement on line %d and file %s]\n", rem->lineNumber(), rem->fileName());
rem->deleteStmt(); rem->deleteStmt();
} }
countOfTransform += remove.size();
//remove empty blocks //remove empty blocks
do do
@@ -559,7 +561,10 @@ void removeDeadCode(SgStatement* func,
__spf_print(PRINT_USELESS_STATEMENTS, "[Useless block statement on line %d and file %s]\n", rem->lineNumber(), rem->fileName()); __spf_print(PRINT_USELESS_STATEMENTS, "[Useless block statement on line %d and file %s]\n", rem->lineNumber(), rem->fileName());
rem->deleteStmt(); rem->deleteStmt();
} }
countOfTransform += remove.size();
} while (remove.size()); } while (remove.size());
deleteCFG(cfg); deleteCFG(cfg);
return countOfTransform;
} }

View File

@@ -9,7 +9,7 @@
#include "../CFGraph/DataFlow/data_flow.h" #include "../CFGraph/DataFlow/data_flow.h"
#include "../CFGraph/DataFlow/backward_data_flow.h" #include "../CFGraph/DataFlow/backward_data_flow.h"
void removeDeadCode(SgStatement* func, int removeDeadCode(SgStatement* func,
const std::map<std::string, std::vector<FuncInfo*>>&allFuncs, const std::map<std::string, std::vector<FuncInfo*>>&allFuncs,
const std::map<std::string, CommonBlock*>& commonBlocks, const std::map<std::string, CommonBlock*>& commonBlocks,
SgStatement* intervalDelStart = NULL, SgStatement* intervalDelEnd = NULL); SgStatement* intervalDelStart = NULL, SgStatement* intervalDelEnd = NULL);

View File

@@ -1153,7 +1153,7 @@ bool isSPF_stat(SgStatement *st)
const int var = st->variant(); const int var = st->variant();
//for details see dvm_tag.h //for details see dvm_tag.h
if (var >= SPF_ANALYSIS_DIR && var <= SPF_UNROLL_OP) if (var >= SPF_ANALYSIS_DIR && var <= SPF_PROCESS_PRIVATE_OP)
ret = true; ret = true;
return ret; return ret;
} }

View File

@@ -1,7 +1,7 @@
//1001 //1001
R1 = "Неверное расположение директивы: можно располагать только %s %s %s" R1 = "Неверное расположение директивы: можно располагать только %s %s %s"
RR1_1 = "перед" RR1_1 = "перед"
RR1_2 = "объявлением переменных или" RR1_2 = "объявлением переменных"
RR1_3 = "циклом" RR1_3 = "циклом"
RR1_4 = "после" RR1_4 = "после"
RR1_5 = "всех операторов объявления" RR1_5 = "всех операторов объявления"

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2308" #define VERSION_SPF "2311"