Compare commits
7 Commits
1363cb4aaa
...
3682f7aa59
| Author | SHA1 | Date | |
|---|---|---|---|
| 3682f7aa59 | |||
| 400c378691 | |||
|
|
34cf4cc202 | ||
|
|
fcedc0e029 | ||
|
|
21acea498e | ||
| 77c46121a2 | |||
| 7d342c51a8 |
@@ -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 */
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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, '_','_','_','_','_')
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
@@ -98,14 +100,46 @@ acc_end_region: ACC_END_REGION
|
||||
acc_end_checksection: ACC_END_CHECKSECTION
|
||||
{ $$ = get_bfnd(fi,ACC_END_CHECKSECTION_DIR,SMNULL,LLNULL,LLNULL,LLNULL);}
|
||||
;
|
||||
|
||||
acc_declare: ACC_DECLARE in_dcl opt_double_colon acc_declare_list
|
||||
{
|
||||
$$ = get_bfnd(fi,ACC_DECLARE_DIR, SMNULL, $4, LLNULL, LLNULL);
|
||||
}
|
||||
;
|
||||
acc_declare_list: declare_var
|
||||
{ $$ = make_llnd(fi,EXPR_LIST, $1, LLNULL, SMNULL); }
|
||||
| acc_declare_list COMMA declare_var
|
||||
{ $$ = set_ll_list($1, $3, EXPR_LIST); }
|
||||
;
|
||||
|
||||
declare_var: name
|
||||
{
|
||||
PTR_SYMB s;
|
||||
s = make_scalar($1,TYNULL,LOCAL);
|
||||
if((s->attr & PROCESSORS_BIT) ||(s->attr & TASK_BIT) || (s->attr & TEMPLATE_BIT) || (s->attr & ALIGN_BIT) || (s->attr & DISTRIBUTE_BIT) || (s->attr & DYNAMIC_BIT) || (s->attr & HEAP_BIT)|| (s->attr & DVM_POINTER_BIT) || (s->attr & INHERIT_BIT) ||(s->attr & SHADOW_BIT))
|
||||
errstr("Inconsistent declaration of identifier %s", s->ident, 16);
|
||||
$$ = make_llnd(fi,VAR_REF, LLNULL, LLNULL, s);
|
||||
}
|
||||
;
|
||||
|
||||
acc_routine: ACC_ROUTINE in_dcl opt_targets_clause
|
||||
acc_routine: ACC_ROUTINE in_dcl opt_routine_clauses
|
||||
{ $$ = get_bfnd(fi,ACC_ROUTINE_DIR,SMNULL,$3,LLNULL,LLNULL);}
|
||||
;
|
||||
|
||||
opt_targets_clause: needkeyword keywordoff
|
||||
{ $$ = LLNULL; }
|
||||
| needkeyword targets_clause
|
||||
{ $$ = $2;}
|
||||
;
|
||||
opt_routine_clauses:
|
||||
{ $$ = LLNULL;}
|
||||
| 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;}
|
||||
;
|
||||
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -7945,17 +7951,49 @@ acc_end_region: ACC_END_REGION
|
||||
acc_end_checksection: ACC_END_CHECKSECTION
|
||||
{ $$ = get_bfnd(fi,ACC_END_CHECKSECTION_DIR,SMNULL,LLNULL,LLNULL,LLNULL);}
|
||||
;
|
||||
|
||||
acc_declare: ACC_DECLARE in_dcl opt_double_colon acc_declare_list
|
||||
{
|
||||
$$ = get_bfnd(fi,ACC_DECLARE_DIR, SMNULL, $4, LLNULL, LLNULL);
|
||||
}
|
||||
;
|
||||
acc_declare_list: declare_var
|
||||
{ $$ = make_llnd(fi,EXPR_LIST, $1, LLNULL, SMNULL); }
|
||||
| acc_declare_list COMMA declare_var
|
||||
{ $$ = set_ll_list($1, $3, EXPR_LIST); }
|
||||
;
|
||||
|
||||
declare_var: name
|
||||
{
|
||||
PTR_SYMB s;
|
||||
s = make_scalar($1,TYNULL,LOCAL);
|
||||
if((s->attr & PROCESSORS_BIT) ||(s->attr & TASK_BIT) || (s->attr & TEMPLATE_BIT) || (s->attr & ALIGN_BIT) || (s->attr & DISTRIBUTE_BIT) || (s->attr & DYNAMIC_BIT) || (s->attr & HEAP_BIT)|| (s->attr & DVM_POINTER_BIT) || (s->attr & INHERIT_BIT) ||(s->attr & SHADOW_BIT))
|
||||
errstr("Inconsistent declaration of identifier %s", s->ident, 16);
|
||||
$$ = make_llnd(fi,VAR_REF, LLNULL, LLNULL, s);
|
||||
}
|
||||
;
|
||||
|
||||
acc_routine: ACC_ROUTINE in_dcl opt_targets_clause
|
||||
acc_routine: ACC_ROUTINE in_dcl opt_routine_clauses
|
||||
{ $$ = get_bfnd(fi,ACC_ROUTINE_DIR,SMNULL,$3,LLNULL,LLNULL);}
|
||||
;
|
||||
|
||||
opt_targets_clause: needkeyword keywordoff
|
||||
{ $$ = LLNULL; }
|
||||
| needkeyword targets_clause
|
||||
{ $$ = $2;}
|
||||
;
|
||||
opt_routine_clauses:
|
||||
{ $$ = LLNULL;}
|
||||
| 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
|
||||
|
||||
@@ -2214,6 +2214,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*/
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -318,6 +318,7 @@ ACC_INLOCAL
|
||||
ACC_CUDA_BLOCK
|
||||
ACC_ROUTINE
|
||||
ACC_TIE
|
||||
ACC_DECLARE
|
||||
BY
|
||||
IO_MODE
|
||||
CP_CREATE
|
||||
|
||||
@@ -126,7 +126,9 @@ set(OMEGA _src/SageAnalysisTool/OmegaForSage/add-assert.cpp
|
||||
_src/SageAnalysisTool/set.cpp)
|
||||
|
||||
set(PRIV _src/PrivateAnalyzer/private_analyzer.cpp
|
||||
_src/PrivateAnalyzer/private_analyzer.h)
|
||||
_src/PrivateAnalyzer/private_analyzer.h
|
||||
_src/PrivateAnalyzer/private_arrays_search.cpp
|
||||
_src/PrivateAnalyzer/private_arrays_search.h)
|
||||
|
||||
set(FDVM ${fdvm_sources}/acc.cpp
|
||||
${fdvm_sources}/acc_across.cpp
|
||||
@@ -196,6 +198,7 @@ set(TR_IMPLICIT_NONE _src/Transformations/set_implicit_none.cpp
|
||||
set(TR_REPLACE_ARRAYS_IN_IO _src/Transformations/replace_dist_arrays_in_io.cpp
|
||||
_src/Transformations/replace_dist_arrays_in_io.h)
|
||||
|
||||
|
||||
set(TRANSFORMS
|
||||
${TR_DEAD_CODE}
|
||||
${TR_CP}
|
||||
@@ -476,6 +479,7 @@ source_group (Predictor FILES ${PREDICTOR})
|
||||
source_group (Parser FILES ${PARSER})
|
||||
source_group (PPPA\\PPPA FILES ${PPPA})
|
||||
source_group (PPPA\\ZLib FILES ${ZLIB})
|
||||
|
||||
|
||||
if (MSVC_IDE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zc:__cplusplus")
|
||||
|
||||
@@ -445,12 +445,12 @@ static SAPFOR::Argument* processExpression(SgExpression* ex, vector<IR_Block*>&
|
||||
{
|
||||
int numArgs = 0;
|
||||
auto arg1 = createArrayArg(ex, blocks, func, numArgs, commonVars);
|
||||
|
||||
|
||||
if (numArgs == 0)
|
||||
return arg1;
|
||||
|
||||
auto reg = isLeft ? NULL : createRegister();
|
||||
Instruction* instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(numArgs), isLeft ? isLeft : reg);
|
||||
Instruction* instr = new Instruction(isLeft ? CFG_OP::STORE : CFG_OP::LOAD, arg1, createConstArg(numArgs), isLeft ? isLeft : reg, NULL, ex);
|
||||
blocks.push_back(new IR_Block(instr));
|
||||
return reg;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <iostream>
|
||||
|
||||
#include "private_arrays_search.h"
|
||||
#include "../Utils/SgUtils.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void print_info(LoopGraph* loop)
|
||||
{
|
||||
cout << "loopSymbol: " << loop->loopSymbol << endl;
|
||||
for (const auto& ops : loop->writeOpsForLoop)
|
||||
{
|
||||
cout << "Array name: " << ops.first->GetShortName() << endl;
|
||||
for (const auto i : ops.second)
|
||||
{
|
||||
i.printInfo();
|
||||
}
|
||||
}
|
||||
if (!loop->children.empty())
|
||||
{
|
||||
for (const auto child : loop->children)
|
||||
{
|
||||
print_info(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool isParentStmt(SgStatement* stmt, SgStatement* parent)
|
||||
{
|
||||
for (; stmt; stmt = stmt->controlParent())
|
||||
if (stmt == parent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*returns head block and loop*/
|
||||
pair<SAPFOR::BasicBlock*, unordered_set<SAPFOR::BasicBlock*>> GetBasicBlocksForLoop(LoopGraph* loop, vector<SAPFOR::BasicBlock*> blocks)
|
||||
{
|
||||
unordered_set<SAPFOR::BasicBlock*> block_loop;
|
||||
SAPFOR::BasicBlock* head_block = nullptr;
|
||||
auto loop_operator = loop->loop->GetOriginal();
|
||||
for (const auto& block : blocks)
|
||||
{
|
||||
if (!block || (block->getInstructions().size() == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SgStatement* first = block->getInstructions().front()->getInstruction()->getOperator();
|
||||
SgStatement* last = block->getInstructions().back()->getInstruction()->getOperator();
|
||||
if (isParentStmt(first, loop_operator) && isParentStmt(last, loop_operator))
|
||||
{
|
||||
block_loop.insert(block);
|
||||
|
||||
if ((!head_block) && (first == loop_operator) && (last == loop_operator) &&
|
||||
(block->getInstructions().size() == 2) &&
|
||||
(block->getInstructions().back()->getInstruction()->getOperation() == SAPFOR::CFG_OP::JUMP_IF))
|
||||
{
|
||||
head_block = block;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return { head_block, block_loop };
|
||||
}
|
||||
|
||||
|
||||
void BuildLoopIndex(map<string, LoopGraph*>& loopForIndex, LoopGraph* loop) {
|
||||
string index = loop->loopSymbol;
|
||||
loopForIndex[index] = loop;
|
||||
for (const auto& childLoop : loop->children) {
|
||||
BuildLoopIndex(loopForIndex, childLoop);
|
||||
}
|
||||
}
|
||||
|
||||
string FindIndexName(int pos, SAPFOR::BasicBlock* block, map<string, LoopGraph*>& loopForIndex) {
|
||||
unordered_set<SAPFOR::Argument*> args = {block->getInstructions()[pos]->getInstruction()->getArg1()};
|
||||
|
||||
for (int i = pos-1; i >= 0; i--) {
|
||||
SAPFOR::Argument* res = block->getInstructions()[i]->getInstruction()->getResult();
|
||||
if (res && args.find(res) != args.end()) {
|
||||
SAPFOR::Argument* arg1 = block->getInstructions()[i]->getInstruction()->getArg1();
|
||||
SAPFOR::Argument* arg2 = block->getInstructions()[i]->getInstruction()->getArg2();
|
||||
if (arg1) {
|
||||
string name = arg1->getValue();
|
||||
int idx = name.find('%');
|
||||
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
||||
return name.substr(idx + 1);
|
||||
else {
|
||||
args.insert(arg1);
|
||||
}
|
||||
}
|
||||
if (arg2) {
|
||||
string name = arg2->getValue();
|
||||
int idx = name.find('%');
|
||||
if (idx != -1 && loopForIndex.find(name.substr(idx + 1)) != loopForIndex.end())
|
||||
return name.substr(idx + 1);
|
||||
else {
|
||||
args.insert(arg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAccessingIndexes& def, ArrayAccessingIndexes& use) {
|
||||
auto instructions = block->getInstructions();
|
||||
map<string, LoopGraph*> loopForIndex;
|
||||
BuildLoopIndex(loopForIndex, loop);
|
||||
for(int i = 0; i < instructions.size(); i++)
|
||||
{
|
||||
auto instruction = instructions[i];
|
||||
if(!instruction->getInstruction()->getArg1()) {
|
||||
continue;
|
||||
}
|
||||
auto operation = instruction->getInstruction()->getOperation();
|
||||
auto type = instruction->getInstruction()->getArg1()->getType();
|
||||
if ((operation == SAPFOR::CFG_OP::STORE && type == SAPFOR::CFG_ARG_TYPE::ARRAY) ||
|
||||
(operation == SAPFOR::CFG_OP::LOAD && type == SAPFOR::CFG_ARG_TYPE::ARRAY))
|
||||
{
|
||||
|
||||
vector<SAPFOR::Argument*> index_vars;
|
||||
vector<int> refPos;
|
||||
string array_name;
|
||||
if (operation == SAPFOR::CFG_OP::STORE)
|
||||
{
|
||||
array_name = instruction->getInstruction()->getArg1()->getValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
array_name = instruction->getInstruction()->getArg2()->getValue();
|
||||
}
|
||||
int j = i - 1;
|
||||
while (j >= 0 && instructions[j]->getInstruction()->getOperation() == SAPFOR::CFG_OP::REF)
|
||||
{
|
||||
index_vars.push_back(instructions[j]->getInstruction()->getArg1());
|
||||
refPos.push_back(j);
|
||||
j--;
|
||||
}
|
||||
/*to choose correct dimension*/
|
||||
int n = index_vars.size();
|
||||
if (operation == SAPFOR::CFG_OP::STORE)
|
||||
{
|
||||
if (def[array_name].empty())
|
||||
{
|
||||
def[array_name].resize(n);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (use[array_name].empty())
|
||||
{
|
||||
use[array_name].resize(n);
|
||||
}
|
||||
}
|
||||
|
||||
SgArrayRefExp* ref = (SgArrayRefExp*)instruction->getInstruction()->getExpression();
|
||||
vector<pair<int, int>> coefsForDims;
|
||||
for (int i = 0; i < ref->numberOfSubscripts(); ++i)
|
||||
{
|
||||
const vector<int*>& coefs = getAttributes<SgExpression*, int*>(ref->subscript(i), set<int>{ INT_VAL });
|
||||
if (coefs.size() == 1)
|
||||
{
|
||||
const pair<int, int> coef(coefs[0][0], coefs[0][1]);
|
||||
coefsForDims.push_back(coef);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while (!index_vars.empty())
|
||||
{
|
||||
auto var = index_vars.back();
|
||||
int currentVarPos = refPos.back();
|
||||
pair currentCoefs = coefsForDims.back();
|
||||
ArrayDimension current_dim;
|
||||
if (var->getType() == SAPFOR::CFG_ARG_TYPE::CONST) {
|
||||
current_dim = { stoul(var->getValue()), 0, 1 };
|
||||
}
|
||||
else
|
||||
{
|
||||
string name, full_name = var->getValue();
|
||||
int pos = full_name.find('%');
|
||||
LoopGraph* currentLoop;
|
||||
if (pos != -1) {
|
||||
name = full_name.substr(pos+1);
|
||||
if (loopForIndex.find(name) != loopForIndex.end()) {
|
||||
currentLoop = loopForIndex[name];
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
name = FindIndexName(currentVarPos, block, loopForIndex);
|
||||
if (name == "") {
|
||||
return -1;
|
||||
}
|
||||
if (loopForIndex.find(name) != loopForIndex.end()) {
|
||||
currentLoop = loopForIndex[name];
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
uint64_t start = currentLoop->startVal * currentCoefs.first + currentCoefs.second;
|
||||
uint64_t step = currentCoefs.first;
|
||||
current_dim = { start, step, (uint64_t)currentLoop->calculatedCountOfIters };
|
||||
}
|
||||
if (operation == SAPFOR::CFG_OP::STORE)
|
||||
{
|
||||
def[array_name][n - index_vars.size()].push_back(current_dim);
|
||||
}
|
||||
else
|
||||
{
|
||||
use[array_name][n - index_vars.size()].push_back(current_dim);
|
||||
}
|
||||
index_vars.pop_back();
|
||||
refPos.pop_back();
|
||||
coefsForDims.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
||||
{
|
||||
cout << "FindPrivateArrays\n";
|
||||
for (const auto& curr_graph_pair: loopGraph)
|
||||
{
|
||||
for (const auto& curr_loop : curr_graph_pair.second)
|
||||
{
|
||||
auto block_loop = GetBasicBlocksForLoop(curr_loop, (*FullIR.begin()).second);
|
||||
for (const auto& bb : block_loop.second) {
|
||||
ArrayAccessingIndexes def, use;
|
||||
//GetDefUseArray(bb, curr_loop, def, use);
|
||||
}
|
||||
ArrayAccessingIndexes loopDimensionsInfo;
|
||||
//GetDimensionInfo(curr_loop, loopDimensionsInfo, 0);
|
||||
//print_info(curr_loop);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GetDimensionInfo(LoopGraph* loop, map<DIST::Array*, vector<vector<ArrayDimension>>>& loopDimensionsInfo, int level)
|
||||
{
|
||||
cout << "line_num: " << loop->lineNum << endl;
|
||||
for (const auto& writeOpPairs : loop->writeOpsForLoop)
|
||||
{
|
||||
vector<vector<ArrayDimension>> arrayDimensions(writeOpPairs.first->GetDimSize());
|
||||
loopDimensionsInfo[writeOpPairs.first] = arrayDimensions;
|
||||
for (const auto& writeOp : writeOpPairs.second)
|
||||
{
|
||||
for (const auto& coeficient_pair : writeOp.coefficients)
|
||||
{
|
||||
uint64_t start, step, tripCount;
|
||||
start = loop->startVal * coeficient_pair.first.first + coeficient_pair.first.second;
|
||||
step = loop->stepVal * coeficient_pair.first.first;
|
||||
tripCount = (loop->endVal - coeficient_pair.first.second) / step;
|
||||
if (start <= loop->endVal)
|
||||
{
|
||||
loopDimensionsInfo[writeOpPairs.first][level].push_back({start, step, tripCount});
|
||||
cout << "level: " << level << endl;
|
||||
cout << "start: " << start << endl;
|
||||
cout << "step: " << step << endl;
|
||||
cout << "trip_count: " << tripCount << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << "line_num_after: " << loop->lineNumAfterLoop << endl;
|
||||
if (!loop->children.empty())
|
||||
{
|
||||
for (const auto& childLoop : loop->children)
|
||||
{
|
||||
GetDimensionInfo(childLoop, loopDimensionsInfo, level+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "../GraphLoop/graph_loops.h"
|
||||
#include "../CFGraph/CFGraph.h"
|
||||
|
||||
struct ArrayDimension
|
||||
{
|
||||
uint64_t start, step, tripCount;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, std::vector<std::vector<ArrayDimension>>> ArrayAccessingIndexes;
|
||||
|
||||
void FindPrivateArrays(std::map<std::string, std::vector<LoopGraph*>>& loopGraph, std::map<FuncInfo*, std::vector<SAPFOR::BasicBlock*>>& FullIR);
|
||||
void GetDimensionInfo(LoopGraph* loop, std::map<DIST::Array*, std::vector<std::vector<ArrayDimension>>>& loopDimensionsInfo, int level);
|
||||
std::set<SAPFOR::BasicBlock> GetBasicBlocksForLoop(LoopGraph* loop, std::vector<SAPFOR::BasicBlock>);
|
||||
@@ -98,6 +98,8 @@
|
||||
|
||||
#include "Inliner/inliner.h"
|
||||
|
||||
#include "PrivateAnalyzer/private_arrays_search.h"
|
||||
|
||||
#include "dvm.h"
|
||||
#include "Sapfor.h"
|
||||
#include "Utils/PassManager.h"
|
||||
@@ -1892,7 +1894,10 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
doDumpLive(fullIR);
|
||||
}
|
||||
else if (curr_regime == PRIVATE_ANALYSIS_IR)
|
||||
{
|
||||
runPrivateVariableAnalysis(loopGraph, fullIR, commonBlocks, SPF_messages);
|
||||
FindPrivateArrays(loopGraph, fullIR);
|
||||
}
|
||||
else if (curr_regime == FIX_COMMON_BLOCKS)
|
||||
fixCommonBlocks(allFuncInfo, commonBlocks, &project);
|
||||
else if (curr_regime == GET_MIN_MAX_BLOCK_DIST)
|
||||
@@ -1902,7 +1907,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
calculateStatsForPredictor(allFuncInfo, gCovInfo);
|
||||
parseDvmDirForPredictor(declaredArrays, commonBlocks, allFuncInfo, gCovInfo);
|
||||
}
|
||||
|
||||
const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;
|
||||
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;
|
||||
__spf_print(1, "PROFILE: time for this pass = %f sec (total %f sec)\n", elapsed, elapsedGlobal);
|
||||
|
||||
@@ -366,6 +366,7 @@ static void setPassValues()
|
||||
passNames[RENAME_INLCUDES] = "RENAME_INLCUDES";
|
||||
passNames[INSERT_NO_DISTR_FLAGS_FROM_GUI] = "INSERT_NO_DISTR_FLAGS_FROM_GUI";
|
||||
|
||||
|
||||
passNames[TEST_PASS] = "TEST_PASS";
|
||||
}
|
||||
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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;
|
||||
@@ -143,24 +145,24 @@ static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgExpression* e
|
||||
|
||||
switch (exp->variant())
|
||||
{
|
||||
case FUNC_CALL:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, true, false);
|
||||
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, true, true);
|
||||
break;
|
||||
}
|
||||
case EXPR_LIST:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, from_read, from_write);
|
||||
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, from_read, from_write);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, true, false);
|
||||
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, true, false);
|
||||
break;
|
||||
}
|
||||
case FUNC_CALL:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, true, false);
|
||||
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, true, true);
|
||||
break;
|
||||
}
|
||||
case EXPR_LIST:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, from_read, from_write);
|
||||
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, from_read, from_write);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, exp->lhs(), has_read, has_write, true, false);
|
||||
replaceArrayRec(arr, replace_by, exp->rhs(), has_read, has_write, true, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,31 +173,31 @@ static void replaceArrayRec(SgSymbol* arr, SgSymbol* replace_by, SgStatement* st
|
||||
|
||||
switch (st->variant())
|
||||
{
|
||||
case ASSIGN_STAT:
|
||||
case READ_STAT:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, st->expr(0), has_read, has_write, false, true);
|
||||
replaceArrayRec(arr, replace_by, st->expr(1), has_read, has_write, true, false);
|
||||
break;
|
||||
}
|
||||
case PROC_STAT:
|
||||
case FUNC_STAT:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, st->expr(0), has_read, has_write, true, false);
|
||||
replaceArrayRec(arr, replace_by, st->expr(1), has_read, has_write, true, true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
replaceArrayRec(arr, replace_by, st->expr(i), has_read, has_write, true, false);
|
||||
case ASSIGN_STAT:
|
||||
case READ_STAT:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, st->expr(0), has_read, has_write, false, true);
|
||||
replaceArrayRec(arr, replace_by, st->expr(1), has_read, has_write, true, false);
|
||||
break;
|
||||
}
|
||||
case PROC_STAT:
|
||||
case FUNC_STAT:
|
||||
{
|
||||
replaceArrayRec(arr, replace_by, st->expr(0), has_read, has_write, true, false);
|
||||
replaceArrayRec(arr, replace_by, st->expr(1), has_read, has_write, true, true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
replaceArrayRec(arr, replace_by, st->expr(i), has_read, has_write, true, false);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace_by, SgStatement* start, SgStatement* last)
|
||||
static void copyArrayBetweenStatements(SgSymbol* replace_symb, SgSymbol* replace_by, SgStatement* start, SgStatement* last, bool start_is_scope)
|
||||
{
|
||||
while (start->lexNext() && !isSgExecutableStatement(start->lexNext()))
|
||||
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,23 +335,19 @@ 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;
|
||||
}
|
||||
|
||||
void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
|
||||
const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
map<string, vector<Messages>>& SPF_messages,
|
||||
map<string, map<int, set<string>>>& newDeclsToInclude)
|
||||
const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
list({ BUILD_IR, CALL_GRAPH }) <= Pass(LIVE_ANALYSIS_IR);
|
||||
|
||||
list({ BUILD_IR, LOOP_GRAPH, LIVE_ANALYSIS_IR }) <= Pass(PRIVATE_ANALYSIS_IR);
|
||||
list({ BUILD_IR, LOOP_GRAPH, LIVE_ANALYSIS_IR, ARRAY_ACCESS_ANALYSIS_FOR_CORNER }) <= Pass(PRIVATE_ANALYSIS_IR);
|
||||
|
||||
Pass(FILE_LINE_INFO) <= Pass(GET_MIN_MAX_BLOCK_DIST);
|
||||
|
||||
@@ -314,6 +314,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
list({ VERIFY_INCLUDES, CORRECT_VAR_DECL }) <= Pass(SET_IMPLICIT_NONE);
|
||||
|
||||
|
||||
passesIgnoreStateDone.insert({ CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS, INSERT_SHADOW_DIRS, EXTRACT_PARALLEL_DIRS,
|
||||
EXTRACT_SHADOW_DIRS, CREATE_REMOTES, UNPARSE_FILE, REMOVE_AND_CALC_SHADOW,
|
||||
REVERSE_CREATED_NESTED_LOOPS, PREDICT_SCHEME, CALCULATE_STATS_SCHEME, REVERT_SPF_DIRS, CLEAR_SPF_DIRS, TRANSFORM_SHADOW_IF_FULL,
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2372"
|
||||
#define VERSION_SPF "2374"
|
||||
|
||||
Reference in New Issue
Block a user