PIPS
special_cases.c File Reference
#include "defines-local.h"
#include "conversion.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
+ Include dependency graph for special_cases.c:

Go to the source code of this file.

Data Structures

struct  t_reduction
 

Macros

#define MAX_REDUCTION   1
 HPFC module, Fabien Coelho, May 1993. More...
 
#define MIN_REDUCTION   2
 
#define SUM_REDUCTION   3
 
#define expression_complex_p(e)    (normalized_complex_p(expression_normalized(e)))
 bool subarray_shift_p(s, pe, plvect) statement s; entity *pe; list *plvect; More...
 
#define XDEBUG(msg)    pips_debug(6, "statement %p: " msg "\n", (void*) s)
 bool full_copy_p(statement s, reference * pleft, reference * pright) More...
 

Typedefs

typedef struct t_reduction t_reduction
 

Functions

static t_reductionfind_reduction (const char *s)
 static t_reduction *find_reduction(c) More...
 
bool hpfc_entity_reduction_p (entity e)
 bool call_reduction_p(c) More...
 
bool call_reduction_p (call c)
 
static void reduction_parameters (call c, t_reduction **pred, basic *pb, int *pdim, entity *pe, list *pl)
 
static char * reduction_name (int kind)
 
static entity make_reduction_function (string prefix, int ndim, int kind, basic base, int nargs)
 find or create an entity for the reduction function... More...
 
bool compile_reduction (statement initial, statement *phost, statement *pnode)
 bool compile_reduction(initial, phost, pnode) More...
 
static bool ref_filter (reference r)
 
static reduction_operator get_operator (entity e, statement s)
 
static hpfc_reductions reduction_of_in (entity e, statement s)
 finally, I can do without replacement: the host keeps and contributes the initial value! More...
 
list handle_hpf_reduction (statement s)
 of hpfc_reductions More...
 
static string new_reduction_name (reduction_operator op)
 for reduction directive: More...
 
static entity make_new_reduction_function (reduction_operator op, bool prolog, bool host, basic base)
 name is {H,N}{PRE,POST}_{SUM,PROD,MIN,...}_{REAL4,INTERGER4,...} More...
 
static statement compile_one_reduction (hpfc_reductions red, bool prolog, bool host)
 
list compile_hpf_reduction (list lr, bool prolog, bool host)
 of statement More...
 
void free_vector_list (list l)
 
static bool locally_constant_vector_p (Pvecteur v)
 
static bool subarray_shift_assignment_p (call c)
 
static bool loop_filter (loop l)
 
static bool call_filter (call c)
 
static bool cannot_be_a_shift (_UNUSED_ void *x)
 
bool subarray_shift_p (statement s, entity *pe, list *plvect)
 
static entity make_shift_subroutine (entity var)
 generates the needed subroutine More...
 
Psysteme get_read_effect_area (list le, entity var)
 
list make_rectangular_area (statement st, entity var)
 
statement generate_subarray_shift (statement s, entity var, list lshift)
 statement generate_subarray_shift(s, var, lshift) statement s; entity var; list lshift; More...
 
void hpfc_special_cases_error_handler ()
 
static bool not_simple (_UNUSED_ void *x)
 
static bool check_simple (call c)
 
statement simple_statement (statement s)
 
static loop find_loop (entity index, list ll)
 bool full_define_p (reference r, list ll) More...
 
bool full_define_p (reference r, list ll)
 
static int number_of_non_empty_statements (list ls)
 
bool full_copy_p (statement s, reference *pleft, reference *pright)
 
statement generate_full_copy (reference left, reference right)
 statement generate_full_copy(reference left, reference right) More...
 

Variables

static t_reduction all_reductions []
 
static entity searched_variable
 hpfc_reductions = initial:entity x replacement:entity x operator:reduction ; reduction = { min , max , sum , prod , and , or } ; More...
 
static tag found_operator
 
static bool subarray_shift_ok = true
 some static variables used for the detection... More...
 
static entity array = entity_undefined
 
static list current_regions = NIL
 
static list lvect = NIL
 
static statement simple_found
 tests whether a loop nest is a full copy loop nest, i.e. More...
 
static bool ok
 

Macro Definition Documentation

◆ expression_complex_p

#define expression_complex_p (   e)     (normalized_complex_p(expression_normalized(e)))

bool subarray_shift_p(s, pe, plvect) statement s; entity *pe; list *plvect;

checks whether a loop nest is a subarray shift, that is a parallel loop nest with one assign in the body which is a 1D shift of a locally constant value. returns false if this dimension is not distributed, because the overlap analysis will make a better job. should also check that the accessed subarray is a section. and that it is a block distribution. ??? should also check for a 1 alignment

the entity returned *pe is the shifted array the list returned is the list of the vector shifts for each dimension

Definition at line 379 of file special_cases.c.

◆ MAX_REDUCTION

#define MAX_REDUCTION   1

HPFC module, Fabien Coelho, May 1993.

Definition at line 39 of file special_cases.c.

◆ MIN_REDUCTION

#define MIN_REDUCTION   2

Definition at line 40 of file special_cases.c.

◆ SUM_REDUCTION

#define SUM_REDUCTION   3

Definition at line 41 of file special_cases.c.

◆ XDEBUG

#define XDEBUG (   msg)     pips_debug(6, "statement %p: " msg "\n", (void*) s)

bool full_copy_p(statement s, reference * pleft, reference * pright)

what: tells whether a loop nest is a 'full copy' one, that is it fully define an array from another, with perfect alignment. how: pattern matching of what we are looking for... input: the statement output: the bool result, plus both references. side effects:

  • uses some static data bugs or features:
  • pattern matching done this way is just a hack...

Definition at line 857 of file special_cases.c.

Typedef Documentation

◆ t_reduction

typedef struct t_reduction t_reduction

Function Documentation

◆ call_filter()

static bool call_filter ( call  c)
static

else: private variable assigned in a parallel loop, ok?!

Definition at line 505 of file special_cases.c.

506 {
507  entity e = call_function(c);
508 
509  pips_debug(9, "function: %s\n", entity_name(e));
510 
511  if (ENTITY_CONTINUE_P(e)) return false;
512  if (ENTITY_ASSIGN_P(e))
513  {
514  if (ref_to_dist_array_p(c))
517  /* else: private variable assigned in a parallel loop, ok?! */
518  }
519  else
520  subarray_shift_ok = false;
521 
522  return false;
523 }
bool ref_to_dist_array_p(void *obj)
this file describe a few functions usefull to the compiler to manage the hpfc data structures.
Definition: hpfc-util.c:48
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define false
Definition: newgen_types.h:80
#define ENTITY_ASSIGN_P(e)
#define ENTITY_CONTINUE_P(e)
#define call_function(x)
Definition: ri.h:709
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_name(x)
Definition: ri.h:2790
static bool subarray_shift_ok
some static variables used for the detection...
static bool subarray_shift_assignment_p(call c)
static entity array

References array, call_function, ENTITY_ASSIGN_P, ENTITY_CONTINUE_P, entity_name, entity_undefined_p, pips_debug, ref_to_dist_array_p(), subarray_shift_assignment_p(), and subarray_shift_ok.

Referenced by subarray_shift_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ call_reduction_p()

bool call_reduction_p ( call  c)

Definition at line 87 of file special_cases.c.

88 {
90 }
bool hpfc_entity_reduction_p(entity e)
bool call_reduction_p(c)
Definition: special_cases.c:82

References call_function, and hpfc_entity_reduction_p().

Referenced by compile_reduction(), and hpf_compile_call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cannot_be_a_shift()

static bool cannot_be_a_shift ( _UNUSED_ void *  x)
static

Definition at line 525 of file special_cases.c.

526 {
527  return subarray_shift_ok = false;
528 }

References subarray_shift_ok.

Referenced by subarray_shift_p().

+ Here is the caller graph for this function:

◆ check_simple()

static bool check_simple ( call  c)
static

Definition at line 718 of file special_cases.c.

719 {
722  {
723  if (simple_found)
724  {
725  ok = false;
726  gen_recurse_stop(NULL);
727  }
728  else
730  }
731 
732  return false;
733 }
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
Definition: genClib.c:3251
#define current_stmt_head()
We want to keep track of the current statement inside the recurse.
Definition: icfg_scan.c:76
#define same_string_p(s1, s2)
#define CONTINUE_FUNCTION_NAME
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
static bool ok
static statement simple_found
tests whether a loop nest is a full copy loop nest, i.e.

References call_function, CONTINUE_FUNCTION_NAME, current_stmt_head, entity_local_name(), gen_recurse_stop(), ok, same_string_p, and simple_found.

Referenced by simple_statement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compile_hpf_reduction()

list compile_hpf_reduction ( list  lr,
bool  prolog,
bool  host 
)

of statement

of statement

Parameters
lrof hpfc_reductions
prologrolog
hostost

Definition at line 347 of file special_cases.c.

351 {
352  list /* of statement */ ls = NIL;
353  MAP(HPFC_REDUCTIONS, r,
354  ls = CONS(STATEMENT, compile_one_reduction(r, prolog, host), ls),
355  lr);
356  return ls;
357 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
#define HPFC_REDUCTIONS(x)
HPFC_REDUCTIONS.
Definition: hpf_private.h:545
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
static statement compile_one_reduction(hpfc_reductions red, bool prolog, bool host)
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References compile_one_reduction(), CONS, HPFC_REDUCTIONS, MAP, NIL, and STATEMENT.

Referenced by hpf_compiler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compile_one_reduction()

static statement compile_one_reduction ( hpfc_reductions  red,
bool  prolog,
bool  host 
)
static

Definition at line 327 of file special_cases.c.

331 {
332  entity var = hpfc_reductions_initial(red);
333 
334  return call_to_statement
336  (hpfc_reductions_operator(red), prolog, host, entity_basic(var)),
341  NIL))));
342 }
call make_call(entity a1, list a2)
Definition: ri.c:269
#define hpfc_reductions_initial(x)
Definition: hpf_private.h:576
#define hpfc_reductions_operator(x)
Definition: hpf_private.h:580
#define call_to_statement(c)
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
int element_number(basic, list)
END_EOLE.
Definition: size.c:391
#define type_variable(x)
Definition: ri.h:2949
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792
#define variable_basic(x)
Definition: ri.h:3120
static entity make_new_reduction_function(reduction_operator op, bool prolog, bool host, basic base)
name is {H,N}{PRE,POST}_{SUM,PROD,MIN,...}_{REAL4,INTERGER4,...}

References call_to_statement, CONS, element_number(), entity_basic(), entity_to_expression(), entity_type, EXPRESSION, hpfc_reductions_initial, hpfc_reductions_operator, int_to_expression(), make_call(), make_new_reduction_function(), NIL, type_variable, variable_basic, and variable_dimensions.

Referenced by compile_hpf_reduction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compile_reduction()

bool compile_reduction ( statement  initial,
statement phost,
statement pnode 
)

bool compile_reduction(initial, phost, pnode)

true is the compiler succeeded in compiling the reduction that way. ??? many conditions are not yet checked...

Parameters
initialnitial
phosthost
pnodenode

Definition at line 148 of file special_cases.c.

150 {
151  instruction i = statement_instruction(initial);
152  list args = NIL;
153  expression ref, cll;
154  call reduction;
155  t_reduction *red ;
156  basic b;
157  int dim = 0, arraynum = -1;
158  list largs = NIL;
159  entity array, hostfunction, nodefunction;
160 
161  pips_assert("assignment",
162  (instruction_call_p(i) &&
165 
166  args = call_arguments(instruction_call(i));
167  ref = EXPRESSION(CAR(args));
168  cll = EXPRESSION(CAR(CDR(args)));
169 
172 
174 
175  pips_debug(7, "call to %s\n", entity_name(call_function(reduction)));
176 
177  pips_assert("reduction call", call_reduction_p(reduction));
178 
179  reduction_parameters(reduction, &red, &b, &dim, &array, &largs);
180 
181  /*
182  * the array must be distributed accross the processors, not replicated,
183  * and the reference variable mustn't be distributed.
184  */
185 
186  if (!array_distributed_p(array) ||
189  return(false);
190 
191  arraynum = load_hpf_number(array);
192 
193  hostfunction = make_reduction_function("H", dim, red->kind, b, 0);
194  nodefunction = make_reduction_function("N", dim, red->kind, b, 4*dim+2);
195 
197  make_call_expression(hostfunction, NIL));
198  *pnode =
200  ( copy_expression(ref),
202  (nodefunction,
204  CONS(EXPRESSION, int_to_expression(arraynum),
206  largs)))));
207 
208  return(true);
209 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
size_t gen_length(const list l)
Definition: list.c:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
statement make_assign_statement(expression, expression)
Definition: statement.c:583
list array_lower_upper_bounds_list(entity)
of expressions
Definition: run-time.c:539
intptr_t load_hpf_number(entity)
bool array_distributed_p(entity)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
struct _newgen_struct_reduction_ * reduction
expression make_call_expression(entity e, list l)
Build an expression that call an function entity with an argument list.
Definition: expression.c:321
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_reference(x)
Definition: ri.h:2730
#define reference_variable(x)
Definition: ri.h:2326
#define syntax_call_p(x)
Definition: ri.h:2734
#define syntax_call(x)
Definition: ri.h:2736
#define instruction_call_p(x)
Definition: ri.h:1527
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define call_arguments(x)
Definition: ri.h:711
#define expression_syntax(x)
Definition: ri.h:1247
bool call_reduction_p(call c)
Definition: special_cases.c:87
static void reduction_parameters(call c, t_reduction **pred, basic *pb, int *pdim, entity *pe, list *pl)
Definition: special_cases.c:97
static entity make_reduction_function(string prefix, int ndim, int kind, basic base, int nargs)
find or create an entity for the reduction function...

References array, array_distributed_p(), array_lower_upper_bounds_list(), call_arguments, call_function, call_reduction_p(), CAR, CDR, CONS, copy_expression(), ENTITY_ASSIGN_P, entity_name, entity_to_expression(), EXPRESSION, expression_syntax, gen_length(), gen_nconc(), instruction_call, instruction_call_p, int_to_expression(), t_reduction::kind, load_hpf_number(), make_assign_statement(), make_call_expression(), make_reduction_function(), NIL, pips_assert, pips_debug, reduction_parameters(), ref, reference_variable, statement_instruction, syntax_call, syntax_call_p, syntax_reference, and syntax_reference_p.

Referenced by hpf_compile_call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_loop()

static loop find_loop ( entity  index,
list  ll 
)
static

bool full_define_p (reference r, list ll)

what: true if the loop nest ll fully scans r how: not very beautiful. input: r and ll output: the bool result side effects: none bugs or features:

if not found

Parameters
llof loops

Definition at line 765 of file special_cases.c.

766 {
767  MAP(LOOP, l, if (loop_index(l)==index) return l, ll);
768  return (loop) NULL; /* if not found */
769 }
#define LOOP(x)
LOOP.
Definition: ri.h:1606
#define loop_index(x)
Definition: ri.h:1640

References LOOP, loop_index, and MAP.

Referenced by full_define_p().

+ Here is the caller graph for this function:

◆ find_reduction()

static t_reduction* find_reduction ( const char *  s)
static

static t_reduction *find_reduction(c)

look for the presence of the reduction in the reduction list.

Definition at line 67 of file special_cases.c.

68 {
69  t_reduction *red;
70 
71  for (red=all_reductions; red->kind; red++)
72  if (same_string_p(s, red->name)) return red;
73 
74  return NULL;
75  }
static t_reduction all_reductions[]
Definition: special_cases.c:50

References all_reductions, t_reduction::kind, t_reduction::name, and same_string_p.

Referenced by hpfc_entity_reduction_p(), and reduction_parameters().

+ Here is the caller graph for this function:

◆ free_vector_list()

void free_vector_list ( list  l)

Definition at line 382 of file special_cases.c.

383 {
385  gen_free_list(l);
386 }
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
void(* gen_iter_func_t)(void *)
Definition: newgen_types.h:116
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78

References gen_free_list(), gen_map(), and vect_rm().

Referenced by generate_subarray_shift(), subarray_shift_assignment_p(), and subarray_shift_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ full_copy_p()

bool full_copy_p ( statement  s,
reference pleft,
reference pright 
)

of lists

of loops

of expressions

the loop nest must be perfect... !!! should check for continues?

the body must be a simple assignment

compatible arities

number of enclosing loops

the lhs should be fully defined by the loop nest... but it does not matter for the rhs!

both lhs and rhs references must be aligned

??? should check the new declarations...

Parameters
pleftleft
prightright

Definition at line 869 of file special_cases.c.

870 {
871  list /* of lists */ lb = NIL, l,
872  /* of loops */ ll = NIL,
873  /* of expressions */ la = NIL;
874  statement body = parallel_loop_nest_to_body(s, &lb, &ll), simple;
875  expression e;
876  reference left, right;
877  int len;
878 
879  DEBUG_STAT(6, "considering statement", s);
880 
881  /* the loop nest must be perfect... !!!
882  * should check for continues?
883  */
884  for (l=lb; l; POP(l))
886  {
887  XDEBUG("non perfectly nested");
888  gen_free_list(lb), gen_free_list(ll); return false;
889  }
890 
891  gen_free_list(lb), lb = NIL;
892 
893  /* the body must be a simple assignment
894  */
895  simple = simple_statement(body);
896 
898  {
899  XDEBUG("body not simple"); gen_free_list(ll); return false;
900  }
901 
903  pips_assert("2 arguments to assign", gen_length(la)==2);
904 
905  left = expression_reference(EXPRESSION(CAR(la)));
906  e = EXPRESSION(CAR(CDR(la)));
907 
908  if (!expression_reference_p(e))
909  {
910  XDEBUG("rhs not a reference"); gen_free_list(ll); return false;
911  }
912 
913  right = expression_reference(e);
914 
915  /* compatible arities
916  */
917  len = (int) gen_length(ll); /* number of enclosing loops */
918 
919  if ((int) gen_length(reference_indices(left))!=len ||
920  (int) gen_length(reference_indices(right))!=len)
921  {
922  XDEBUG("incompatible arities"); gen_free_list(ll); return false;
923  }
924 
925  /* the lhs should be fully defined by the loop nest...
926  * but it does not matter for the rhs!
927  */
928  if (!full_define_p(left, ll))
929  {
930  XDEBUG("lhs not fully defined"); gen_free_list(ll); return false;
931  }
932 
933  gen_free_list(ll);
934 
935  /* both lhs and rhs references must be aligned
936  */
937  if (!references_aligned_p(left, right))
938  {
939  XDEBUG("references not aligned"); return false;
940  }
941 
942  /* ??? should check the new declarations...
943  */
944 
945  XDEBUG("ok");
946  *pleft = left;
947  *pright = right;
948  return true;
949 }
void const char const char const int
statement parallel_loop_nest_to_body(statement loop_nest, list *pblocks, list *ploops)
#define CONSP(x)
Definition: genC.h:88
bool instruction_assign_p(instruction i)
Test if an instruction is an assignment.
Definition: instruction.c:164
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
bool references_aligned_p(reference r1, reference r2)
Definition: hpfc-util.c:726
#define DEBUG_STAT(D, W, S)
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
#define reference_indices(x)
Definition: ri.h:2328
#define XDEBUG(msg)
bool full_copy_p(statement s, reference * pleft, reference * pright)
statement simple_statement(statement s)
bool full_define_p(reference r, list ll)
static int number_of_non_empty_statements(list ls)

References call_arguments, CAR, CDR, CONSP, DEBUG_STAT, EXPRESSION, expression_reference(), expression_reference_p(), full_define_p(), gen_free_list(), gen_length(), instruction_assign_p(), instruction_call, int, NIL, number_of_non_empty_statements(), parallel_loop_nest_to_body(), pips_assert, POP, reference_indices, references_aligned_p(), simple, simple_statement(), statement_instruction, and XDEBUG.

Referenced by hpf_compile_loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ full_define_p()

bool full_define_p ( reference  r,
list  ll 
)

of expression

of dimension

of entity

checks that the indices are simply the loop indexes, and that the whole dimension is scanned. Also avoids (i,i)...

checks that the loop range scans the whole dimension

increment must be 1. lowers and uppers must be equal.

Parameters
llof loops

Definition at line 771 of file special_cases.c.

772 {
774  list /* of expression */ li = reference_indices(r),
775  /* of dimension */ ld,
776  /* of entity */ lseen = NIL;
777  int ndim;
778 
779  pips_assert("variable", entity_variable_p(array));
780 
782  pips_assert("same arity", gen_length(ll)==gen_length(ld));
783 
784  /* checks that the indices are *simply* the loop indexes,
785  * and that the whole dimension is scanned. Also avoids (i,i)...
786  */
787  for(ndim=1; li; POP(li), POP(ld), ndim++)
788  {
790  entity index;
791  dimension dim;
792  range rg;
793  loop l;
794  expression inc;
795 
796  if (!syntax_reference_p(s))
797  {
798  gen_free_list(lseen);
799  return false;
800  }
801 
803 
804  if (gen_in_list_p(index, lseen))
805  {
806  gen_free_list(lseen);
807  return false;
808  }
809 
810  lseen = CONS(ENTITY, index, lseen);
811 
812  l = find_loop(index, ll);
813 
814  if (!l)
815  {
816  gen_free_list(lseen);
817  return false;
818  }
819 
820  /* checks that the loop range scans the whole dimension */
821 
822  rg = loop_range(l);
823  inc = range_increment(rg);
824  dim = DIMENSION(CAR(ld));
825 
826  /* increment must be 1.
827  * lowers and uppers must be equal.
828  */
829  if (!integer_constant_expression_p(inc) ||
833  {
834  pips_debug(9, "incomplete scan of %s[dim=%d]\n",
835  entity_name(array), ndim);
836  gen_free_list(lseen);
837  return false;
838  }
839  }
840 
841  gen_free_list(lseen);
842  return true;
843 }
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
bool integer_constant_expression_p(expression e)
positive integer constant expression: call to a positive constant or to a sum of positive integer con...
Definition: expression.c:903
bool same_expression_p(expression e1, expression e2)
this is slightly different from expression_equal_p, as it will return true for a+b vs b+a
Definition: expression.c:1426
int integer_constant_expression_value(expression e)
Definition: expression.c:1545
#define range_upper(x)
Definition: ri.h:2290
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define dimension_lower(x)
Definition: ri.h:980
#define range_increment(x)
Definition: ri.h:2292
#define dimension_upper(x)
Definition: ri.h:982
#define range_lower(x)
Definition: ri.h:2288
#define loop_range(x)
Definition: ri.h:1642
static loop find_loop(entity index, list ll)
bool full_define_p (reference r, list ll)

References array, CAR, CONS, DIMENSION, dimension_lower, dimension_upper, ENTITY, entity_name, entity_type, entity_variable_p, EXPRESSION, expression_syntax, find_loop(), gen_free_list(), gen_in_list_p(), gen_length(), integer_constant_expression_p(), integer_constant_expression_value(), loop_range, NIL, pips_assert, pips_debug, POP, range_increment, range_lower, range_upper, reference_indices, reference_variable, same_expression_p(), syntax_reference, syntax_reference_p, type_variable, and variable_dimensions.

Referenced by full_copy_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generate_full_copy()

statement generate_full_copy ( reference  left,
reference  right 
)

statement generate_full_copy(reference left, reference right)

what: copies directly right into left, that must conform... how: direct loop nest on local data input: both entities output: the returned statement side effects: bugs or features:

  • assumes that the references are ok, that is they come from a full_copy_p execution.
  • code generated based on the original entities. thus the code cleaning pass is trusted.

of entity

of dimension

indexes are reused. bounds are taken from the node entity declaration.

Parameters
lefteft
rightight

Definition at line 964 of file special_cases.c.

965 {
966  statement body;
967  int ndim, i;
968  list /* of entity */ lindexes, l,
969  /* of dimension */ ld;
971  new_array = load_new_node(array);
972 
974 
977 
978  /* indexes are reused. bounds are taken from the node entity declaration.
979  */
980  lindexes = expressions_to_entities(reference_indices(left));
982 
983  for(i=1, l=lindexes; i<=ndim; i++, POP(lindexes), POP(ld))
984  {
985  dimension d = DIMENSION(CAR(ld));
986 
988  (ENTITY(CAR(lindexes)),
991  int_to_expression(1)),
992  body,
995  NIL));
996  }
997 
998  gen_free_list(l);
999  return body;
1000 }
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
reference copy_reference(reference p)
REFERENCE.
Definition: ri.c:2047
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
entity load_new_node(entity)
#define UU
Definition: newgen_types.h:98
#define loop_to_statement(l)
entity entity_empty_label(void)
Definition: entity.c:1105
expression reference_to_expression(reference r)
Definition: expression.c:196
list expressions_to_entities(list expressions)
map expression_to_entity on expressions
Definition: expression.c:3161
@ is_execution_sequential
Definition: ri.h:1189

References array, CAR, copy_expression(), copy_reference(), DIMENSION, dimension_lower, dimension_upper, ENTITY, entity_empty_label(), entity_type, expressions_to_entities(), gen_free_list(), gen_length(), int_to_expression(), is_execution_sequential, load_new_node(), loop_to_statement, make_assign_statement(), make_execution(), make_loop(), make_range(), NIL, POP, reference_indices, reference_to_expression(), reference_variable, type_variable, UU, and variable_dimensions.

Referenced by hpf_compile_loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generate_subarray_shift()

statement generate_subarray_shift ( statement  s,
entity  var,
list  lshift 
)

statement generate_subarray_shift(s, var, lshift) statement s; entity var; list lshift;

generates a call to the runtime library shift subroutine for the given array, the given shift and the corresponding region in statement s. this function assumes that subarray_shift_p was true on s, and does not checks the conditions again.

gets the shifted dimension and the shift

all the arguments

Parameters
varar
lshiftshift

Definition at line 643 of file special_cases.c.

644 {
645  entity subroutine = make_shift_subroutine(var);
646  int array_number = load_hpf_number(array), shifted_dim = 0;
648  list ldecl = array_lower_upper_bounds_list(array), largs;
649  Pvecteur v;
650 
651  /* gets the shifted dimension and the shift
652  */
653  MAPL(cv,
654  {
655  v = (Pvecteur) PVECTOR(CAR(cv));
656  shifted_dim++;
657 
658  if (!vecteur_nul_p(v))
659  {
660  shift = make_vecteur_expression(v);
661  break;
662  }
663  },
664  lshift);
665 
666  pips_assert("shift defined", shift!=expression_undefined);
667  free_vector_list(lshift);
668 
669  /* all the arguments
670  */
671  largs =
673  CONS(EXPRESSION, int_to_expression(array_number),
674  CONS(EXPRESSION, int_to_expression(shifted_dim),
675  CONS(EXPRESSION, shift,
676  gen_nconc(ldecl, make_rectangular_area(s, var))))));
677 
678  return hpfc_make_call_statement(subroutine, largs);
679 }
bool vecteur_nul_p(Pvecteur v)
Definition: constraint.c:56
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
#define PVECTOR(v)
Definition: defines-local.h:72
statement hpfc_make_call_statement(entity, list)
statement hpfc_make_call_statement(e, l) generate a call statement to function e, with expression lis...
Definition: run-time.c:318
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
#define expression_undefined
Definition: ri.h:1223
void free_vector_list(list l)
static entity make_shift_subroutine(entity var)
generates the needed subroutine
list make_rectangular_area(statement st, entity var)
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * Pvecteur

References array, array_lower_upper_bounds_list(), CAR, CONS, entity_to_expression(), EXPRESSION, expression_undefined, free_vector_list(), gen_nconc(), hpfc_make_call_statement(), int_to_expression(), load_hpf_number(), make_rectangular_area(), make_shift_subroutine(), make_vecteur_expression(), MAPL, pips_assert, PVECTOR, and vecteur_nul_p().

Referenced by hpf_compile_loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_operator()

static reduction_operator get_operator ( entity  e,
statement  s 
)
static

Definition at line 248 of file special_cases.c.

249 {
250  make_current_call_stack();
252  searched_variable = e;
254  call_domain, current_call_filter, current_call_rewrite,
256  NULL);
257  free_current_call_stack();
258 
259  pips_assert("some operator found", found_operator!=tag_undefined);
261 }
reduction_operator make_reduction_operator(enum reduction_operator_utype tag, void *val)
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#define tag_undefined
Definition: newgen_types.h:93
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
static tag found_operator
static entity searched_variable
hpfc_reductions = initial:entity x replacement:entity x operator:reduction ; reduction = { min ,...
static bool ref_filter(reference r)

References call_domain, found_operator, gen_multi_recurse(), gen_null(), make_reduction_operator(), pips_assert, ref_filter(), reference_domain, searched_variable, tag_undefined, and UU.

Referenced by reduction_of_in().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_read_effect_area()

Psysteme get_read_effect_area ( list  le,
entity  var 
)
Parameters
lee
varar

Definition at line 584 of file special_cases.c.

585 {
586  MAP(EFFECT, e,
587  {
588  if (action_read_p(effect_action(e)) &&
590  return effect_system(e);
591  },
592  le);
593 
594  return SC_UNDEFINED;
595 }
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_system(e)
#define effect_action(x)
Definition: effects.h:642
#define action_read_p(x)
Definition: effects.h:311
#define EFFECT(x)
EFFECT.
Definition: effects.h:608

References action_read_p, EFFECT, effect_action, effect_any_reference, effect_system, MAP, and reference_variable.

Referenced by make_rectangular_area().

+ Here is the caller graph for this function:

◆ handle_hpf_reduction()

list handle_hpf_reduction ( statement  s)

of hpfc_reductions

of hpfc_reductions

Definition at line 274 of file special_cases.c.

275 {
276  list /* of hpfc_reductions */ lr = NIL;
277 
278  MAP(ENTITY, e,
279  lr = CONS(HPFC_REDUCTIONS, reduction_of_in(e, s), lr),
281 
282  return lr;
283 }
#define entities_list(x)
Definition: hpf_private.h:414
entities load_hpf_reductions(statement)
static hpfc_reductions reduction_of_in(entity e, statement s)
finally, I can do without replacement: the host keeps and contributes the initial value!

References CONS, entities_list, ENTITY, HPFC_REDUCTIONS, load_hpf_reductions(), MAP, NIL, and reduction_of_in().

Referenced by hpf_compiler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hpfc_entity_reduction_p()

bool hpfc_entity_reduction_p ( entity  e)

bool call_reduction_p(c)

special_cases.c

true if a given call is a call to reduction function. ??? a generic function name should be managed here?

Definition at line 82 of file special_cases.c.

83 {
84  return find_reduction(module_local_name(e)) != NULL;
85 }
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
static t_reduction * find_reduction(const char *s)
static t_reduction *find_reduction(c)
Definition: special_cases.c:67

References find_reduction(), and module_local_name().

Referenced by call_reduction_p(), hpfc_compile(), and hpfc_directives_handler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hpfc_special_cases_error_handler()

void hpfc_special_cases_error_handler ( void  )

Definition at line 705 of file special_cases.c.

706 {
707  error_reset_current_stmt_stack();
708  error_reset_current_call_stack();
709 }

Referenced by hpfc_error_handler().

+ Here is the caller graph for this function:

◆ locally_constant_vector_p()

static bool locally_constant_vector_p ( Pvecteur  v)
static

Definition at line 395 of file special_cases.c.

396 {
397  for(; v!=NULL; v=v->succ)
398  if (var_of(v)!=TCST && written_effect_p((entity) var_of(v),
400  return false;
401 
402  return true;
403 }
bool written_effect_p(entity var, list le)
written_effects_to_dist_arrays_p
Definition: hpfc-util.c:58
static list current_regions
struct Svecteur * succ
Definition: vecteur-local.h:92
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define var_of(varval)

References current_regions, Svecteur::succ, TCST, var_of, and written_effect_p().

Referenced by subarray_shift_assignment_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loop_filter()

static bool loop_filter ( loop  l)
static

Definition at line 499 of file special_cases.c.

500 {
502  return subarray_shift_ok = subarray_shift_ok && (stride==1 || stride==-1);
503 }
int HpfcExpressionToInt(expression e)
HpfcExpressionToInt(e)
Definition: hpfc-util.c:569

References HpfcExpressionToInt(), loop_range, range_increment, and subarray_shift_ok.

Referenced by subarray_shift_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_new_reduction_function()

static entity make_new_reduction_function ( reduction_operator  op,
bool  prolog,
bool  host,
basic  base 
)
static

name is {H,N}{PRE,POST}_{SUM,PROD,MIN,...}_{REAL4,INTERGER4,...}

Definition at line 311 of file special_cases.c.

316 {
317  char buffer[100];
318 
319  (void) sprintf(buffer, "%s", concatenate
320  (host? "H": "N", prolog? "PRE": "POST", " ",
321  new_reduction_name(op), " ", pvm_what_options(base), NULL));
322 
324 }
bdt base
Current expression.
Definition: bdt_read_paf.c:100
entity MakeRunTimeSupportSubroutine(string, int)
run-time.c
string pvm_what_options(basic)
string pvm_what_options(b)
Definition: run-time.c:86
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
static string new_reduction_name(reduction_operator op)
for reduction directive:
static string buffer
Definition: string.c:113

References base, buffer, concatenate(), MakeRunTimeSupportSubroutine(), new_reduction_name(), and pvm_what_options().

Referenced by compile_one_reduction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_rectangular_area()

list make_rectangular_area ( statement  st,
entity  var 
)
Parameters
stt
varar

Definition at line 597 of file special_cases.c.

598 {
599  list l = NIL;
600  Psysteme
602  var));
604  Variable idx;
607 
609  c = sc_inegalites(s);
610  sc_inegalites(s) = (Pcontrainte)NULL,
611  sc_rm(s);
612 
613  for(; dim>0; dim--)
614  {
615  idx = (Variable) get_ith_region_dummy(dim);
616 
617  constraints_for_bounds(idx, &c, &lower, &upper);
618 
619  l = CONS(EXPRESSION, constraints_to_loop_bound(lower, idx, true, div),
620  CONS(EXPRESSION, constraints_to_loop_bound(upper, idx, false, div),
621  l));
622 
623  (void) contraintes_free(lower), lower=NULL;
624  (void) contraintes_free(upper), upper=NULL;
625  }
626 
627  (void) contraintes_free(c);
628 
629  return l;
630 }
#define CONTRAINTE_UNDEFINED
struct Scontrainte * Pcontrainte
Pcontrainte contraintes_free(Pcontrainte pc)
Pcontrainte contraintes_free(Pcontrainte pc): desallocation de toutes les contraintes de la liste pc.
Definition: alloc.c:226
void constraints_for_bounds(Variable, Pcontrainte *, Pcontrainte *, Pcontrainte *)
void constraints_for_bounds(var, pinit, plower, pupper) Variable var; Pcontrainte *pinit,...
Definition: unaires.c:176
expression constraints_to_loop_bound(Pcontrainte, Variable, bool, entity)
expression constraints_to_loop_bound(c, var, is_lower)
list load_statement_local_regions(statement)
#define IDIVIDE
entity hpfc_name_to_entity(const char *)
Definition: run-time.c:817
entity get_ith_region_dummy(int)
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
void sc_transform_eg_in_ineg(Psysteme sc)
Package sc.
Psysteme get_read_effect_area(list le, entity var)
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References CONS, constraints_for_bounds(), constraints_to_loop_bound(), CONTRAINTE_UNDEFINED, contraintes_free(), entity_type, EXPRESSION, gen_length(), get_ith_region_dummy(), get_read_effect_area(), hpfc_name_to_entity(), IDIVIDE, load_statement_local_regions(), NIL, sc_dup(), sc_rm(), sc_transform_eg_in_ineg(), type_variable, and variable_dimensions.

Referenced by generate_subarray_shift().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_reduction_function()

static entity make_reduction_function ( string  prefix,
int  ndim,
int  kind,
basic  base,
int  nargs 
)
static

find or create an entity for the reduction function...

Definition at line 128 of file special_cases.c.

134 {
135  char buffer[100];
136 
137  (void) sprintf(buffer, "%sRED %d %s %s",
138  prefix, ndim, pvm_what_options(base), reduction_name(kind));
139 
141 }
entity MakeRunTimeSupportFunction(string, int, tag)
static const char * prefix
#define basic_tag(x)
Definition: ri.h:613
static char * reduction_name(int kind)

References base, basic_tag, buffer, MakeRunTimeSupportFunction(), prefix, pvm_what_options(), and reduction_name().

Referenced by compile_reduction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_shift_subroutine()

static entity make_shift_subroutine ( entity  var)
static

generates the needed subroutine

Definition at line 565 of file special_cases.c.

566 {
567  char buffer[100];
568  type t;
569  variable v;
570  int ndim;
571 
572  pips_assert("defined", !entity_undefined_p(var)); t = entity_type(var);
573  pips_assert("variable", type_variable_p(t)); v = type_variable(t);
574 
575  ndim = gen_length(variable_dimensions(v));
576 
577  (void) sprintf(buffer, "%s SHIFT %d",
579  ndim);
580 
581  return MakeRunTimeSupportSubroutine(buffer, ndim*4+4);
582 }
#define type_variable_p(x)
Definition: ri.h:2947

References buffer, entity_type, entity_undefined_p, gen_length(), MakeRunTimeSupportSubroutine(), pips_assert, pvm_what_options(), type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by generate_subarray_shift().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ new_reduction_name()

static string new_reduction_name ( reduction_operator  op)
static

for reduction directive:

Definition at line 287 of file special_cases.c.

288 {
289  if (reduction_operator_sum_p(op))
290  return "SUM";
291  else if (reduction_operator_prod_p(op))
292  return "PROD";
293  else if (reduction_operator_min_p(op))
294  return "MIN";
295  else if (reduction_operator_max_p(op))
296  return "MAX";
297  else if (reduction_operator_and_p(op))
298  return "AND";
299  else if (reduction_operator_or_p(op))
300  return "OR";
301  else
302  pips_internal_error("unexpected reduction_operator tag (%d)",
304 
305  return "unknown";
306 }
#define pips_internal_error
Definition: misc-local.h:149
#define reduction_operator_sum_p(x)
#define reduction_operator_min_p(x)
#define reduction_operator_tag(x)
#define reduction_operator_prod_p(x)
#define reduction_operator_or_p(x)
#define reduction_operator_and_p(x)
#define reduction_operator_max_p(x)

References pips_internal_error, reduction_operator_and_p, reduction_operator_max_p, reduction_operator_min_p, reduction_operator_or_p, reduction_operator_prod_p, reduction_operator_sum_p, and reduction_operator_tag.

Referenced by make_new_reduction_function().

+ Here is the caller graph for this function:

◆ not_simple()

static bool not_simple ( _UNUSED_ void *  x)
static

Definition at line 711 of file special_cases.c.

712 {
713  ok = false;
714  gen_recurse_stop(NULL);
715  return false;
716 }

References gen_recurse_stop(), and ok.

Referenced by simple_statement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ number_of_non_empty_statements()

static int number_of_non_empty_statements ( list  ls)
static
Parameters
lsof statement

Definition at line 861 of file special_cases.c.

863 {
864  int n = 0;
865  MAP(STATEMENT, s, if (!empty_code_p(s)) n++, ls);
866  return n;
867 }
bool empty_code_p(statement)
statement.c
Definition: statement.c:86

References empty_code_p(), MAP, and STATEMENT.

Referenced by full_copy_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reduction_name()

static char* reduction_name ( int  kind)
static

Definition at line 117 of file special_cases.c.

119 {
120  static char *reduction_names[] = {"MAX", "MIN", "SUM"};
121  pips_assert("valid kind", kind>=0 && kind<3);
122  return(reduction_names[kind-1]);
123 }

References pips_assert.

Referenced by make_reduction_function(), and translate_reduction().

+ Here is the caller graph for this function:

◆ reduction_of_in()

static hpfc_reductions reduction_of_in ( entity  e,
statement  s 
)
static

finally, I can do without replacement: the host keeps and contributes the initial value!

Definition at line 266 of file special_cases.c.

267 {
268  pips_debug(5, "considering %s in %p\n", entity_name(e), s);
269 
271 }
hpfc_reductions make_hpfc_reductions(entity a1, entity a2, reduction_operator a3)
Definition: hpf_private.c:448
#define entity_undefined
Definition: ri.h:2761
static reduction_operator get_operator(entity e, statement s)

References entity_name, entity_undefined, get_operator(), make_hpfc_reductions(), and pips_debug.

Referenced by handle_hpf_reduction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reduction_parameters()

static void reduction_parameters ( call  c,
t_reduction **  pred,
basic pb,
int pdim,
entity pe,
list pl 
)
static

Definition at line 97 of file special_cases.c.

104 {
105  expression
106  arg = EXPRESSION(CAR(call_arguments(c)));
107 
109 
111  *pl = CDR(call_arguments(c));
112  *pdim = NumberOfDimension(*pe);
114  *pb = entity_basic(*pe);
115 }
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
int NumberOfDimension(entity)
Definition: size.c:588

References call_arguments, call_function, CAR, CDR, entity_basic(), EXPRESSION, expression_syntax, find_reduction(), module_local_name(), NumberOfDimension(), pips_assert, pl, reference_variable, syntax_reference, and syntax_reference_p.

Referenced by compile_reduction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ref_filter()

static bool ref_filter ( reference  r)
static

get the call just above – well, what about intermediate casts ???

Definition at line 223 of file special_cases.c.

224 {
225  entity fun;
226 
227  if (searched_variable!=reference_variable(r)) return false;
228 
229  /* get the call just above -- well, what about intermediate casts ??? */
230  fun = call_function(current_call_head());
231 
232  if (ENTITY_PLUS_P(fun)||ENTITY_MINUS_P(fun))
234  else if (ENTITY_MULTIPLY_P(fun))
236  else if (ENTITY_MIN_P(fun)||ENTITY_MIN0_P(fun))
238  else if (ENTITY_MAX_P(fun)||ENTITY_MAX0_P(fun))
240  else if (ENTITY_AND_P(fun))
242  else if (ENTITY_OR_P(fun))
244 
245  return false;
246 }
@ is_reduction_operator_min
@ is_reduction_operator_max
@ is_reduction_operator_prod
@ is_reduction_operator_or
@ is_reduction_operator_and
@ is_reduction_operator_sum
#define ENTITY_OR_P(e)
#define ENTITY_AND_P(e)
#define ENTITY_MAX0_P(e)
#define ENTITY_MINUS_P(e)
#define ENTITY_PLUS_P(e)
#define ENTITY_MULTIPLY_P(e)
#define ENTITY_MAX_P(e)
#define ENTITY_MIN0_P(e)
#define ENTITY_MIN_P(e)

References call_function, ENTITY_AND_P, ENTITY_MAX0_P, ENTITY_MAX_P, ENTITY_MIN0_P, ENTITY_MIN_P, ENTITY_MINUS_P, ENTITY_MULTIPLY_P, ENTITY_OR_P, ENTITY_PLUS_P, found_operator, is_reduction_operator_and, is_reduction_operator_max, is_reduction_operator_min, is_reduction_operator_or, is_reduction_operator_prod, is_reduction_operator_sum, reference_variable, and searched_variable.

Referenced by get_operator().

+ Here is the caller graph for this function:

◆ simple_statement()

statement simple_statement ( statement  s)

Definition at line 735 of file special_cases.c.

736 {
737  ok = true;
738  simple_found = (statement) NULL;
739  make_current_stmt_stack();
740 
742  (s,
743  statement_domain, current_stmt_filter, current_stmt_rewrite,
748  NULL);
749 
750  free_current_stmt_stack();
751 
752  return (ok && simple_found) ? simple_found : NULL;
753 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
Definition: genClib.c:2796
#define test_domain
newgen_entity_domain_defined
Definition: ri.h:418
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
static bool check_simple(call c)
static bool not_simple(_UNUSED_ void *x)

References call_domain, check_simple(), expression_domain, gen_false(), gen_multi_recurse(), gen_null(), loop_domain, not_simple(), ok, simple_found, statement_domain, and test_domain.

Referenced by full_copy_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subarray_shift_assignment_p()

static bool subarray_shift_assignment_p ( call  c)
static

LHS must be a reference

is RHS a reference?

same array, and a block-distributed one ?

compute the difference of every indices, if possible.

else compute the difference

now checks for a constant shift on a distributed dimension and that's all. ??? I could deal with other constant shifts on non distributed dims

else the vector is not null

Definition at line 405 of file special_cases.c.

406 {
407  list lhs_ind, rhs_ind, args = call_arguments(c);
408  expression
409  lhs = EXPRESSION(CAR(args)),
410  rhs = EXPRESSION(CAR(CDR(args)));
411  reference lhs_ref, rhs_ref;
412  bool shift_was_seen = false;
413  int dim;
414 
415  /* LHS *must* be a reference
416  */
417  pips_assert("reference", expression_reference_p(lhs));
418 
419  /* is RHS a reference?
420  */
421  if (!expression_reference_p(rhs)) return false;
422 
423  lhs_ref = syntax_reference(expression_syntax(lhs)),
424  rhs_ref = syntax_reference(expression_syntax(rhs));
425  array = reference_variable(lhs_ref);
426 
427  /* same array, and a block-distributed one ?
428  */
429  if (array!=reference_variable(rhs_ref) ||
432  return false;
433 
434  lhs_ind = reference_indices(lhs_ref),
435  rhs_ind = reference_indices(rhs_ref);
436 
437  pips_assert("same arity", gen_length(lhs_ind)==gen_length(rhs_ind));
438 
439  /* compute the difference of every indices, if possible.
440  */
441  for(;
442  !ENDP(lhs_ind);
443  lhs_ind=CDR(lhs_ind), rhs_ind=CDR(rhs_ind))
444  {
445  expression
446  il = EXPRESSION(CAR(lhs_ind)),
447  ir = EXPRESSION(CAR(rhs_ind));
448 
450  {
452  return false;
453  }
454 
455  /* else compute the difference */
456  lvect =
457  CONS(PVECTOR, (VECTOR)
460  lvect);
461  }
462 
464 
465  /* now checks for a constant shift on a distributed dimension
466  * and that's all.
467  * ??? I could deal with other constant shifts on non distributed dims
468  */
469  dim = 0;
470  MAPL(cv,
471  {
472  Pvecteur v = (Pvecteur) PVECTOR(CAR(cv));
473  int p;
474 
475  dim++;
476 
477  if (vecteur_nul_p(v)) continue;
478 
479  /* else the vector is not null
480  */
481  if (shift_was_seen ||
482  !ith_dim_distributed_p(array, dim, &p) ||
484  {
485  pips_debug(7, "false on array %s, dimension %d\n",
486  entity_local_name(array), dim);
488  lvect = NIL;
489  return false;
490  }
491 
492  shift_was_seen = true;
493  },
494  lvect);
495 
496  return true;
497 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
bool ith_dim_distributed_p(entity array, int i, int *pprocdim)
whether a dimension is distributed or not.
Definition: hpfc-util.c:160
#define VECTOR
Definition: defines-local.h:73
bool block_distributed_p(entity)
o-analysis.c
Definition: o-analysis.c:44
#define expression_normalized(x)
Definition: ri.h:1249
#define normalized_linear(x)
Definition: ri.h:1781
static bool locally_constant_vector_p(Pvecteur v)
static list lvect
#define expression_complex_p(e)
bool subarray_shift_p(s, pe, plvect) statement s; entity *pe; list *plvect;
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75

References array, array_distributed_p(), block_distributed_p(), call_arguments, CAR, CDR, CONS, ENDP, entity_local_name(), EXPRESSION, expression_complex_p, expression_normalized, expression_reference_p(), expression_syntax, free_vector_list(), gen_length(), gen_nreverse(), ith_dim_distributed_p(), locally_constant_vector_p(), lvect, MAPL, NIL, normalized_linear, pips_assert, pips_debug, PVECTOR, reference_indices, reference_variable, syntax_reference, vect_substract(), vecteur_nul_p(), and VECTOR.

Referenced by call_filter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subarray_shift_p()

bool subarray_shift_p ( statement  s,
entity pe,
list plvect 
)
Parameters
pee
plvectlvect

Definition at line 530 of file special_cases.c.

534 {
536  subarray_shift_ok = true;
537  lvect = NIL;
539 
540  DEBUG_STAT(8, "considering statement", s);
541 
547  NULL);
548 
551 
552  if (subarray_shift_ok)
553  *pe = array,
554  *plvect = lvect;
555  else
558 
559  pips_debug(8, "returning %s\n", subarray_shift_ok? "TRUE": "FALSE");
560  return subarray_shift_ok;
561 }
bool rectangular_must_region_p(entity, statement)
static bool loop_filter(loop l)
static bool cannot_be_a_shift(_UNUSED_ void *x)
static bool call_filter(call c)

References array, call_domain, call_filter(), cannot_be_a_shift(), current_regions, DEBUG_STAT, entity_undefined, entity_undefined_p, expression_domain, free_vector_list(), gen_false(), gen_multi_recurse(), gen_null(), load_statement_local_regions(), loop_domain, loop_filter(), lvect, NIL, pips_debug, rectangular_must_region_p(), subarray_shift_ok, and test_domain.

Referenced by hpf_compile_loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ all_reductions

t_reduction all_reductions[]
static
Initial value:
=
{
{"REDMIN", MIN_REDUCTION, -1},
{"REDMIN1", MIN_REDUCTION, 1},
{"REDMIN2", MIN_REDUCTION, 2},
{"REDMIN3", MIN_REDUCTION, 3},
{"REDMAX", MAX_REDUCTION, -1},
{"REDMAX1", MAX_REDUCTION, 1},
{"REDMAX2", MAX_REDUCTION, 2},
{"REDMAX3", MAX_REDUCTION, 3},
{0, 0, 0}
}
#define MIN_REDUCTION
Definition: special_cases.c:40
#define MAX_REDUCTION
HPFC module, Fabien Coelho, May 1993.
Definition: special_cases.c:39

Definition at line 50 of file special_cases.c.

Referenced by find_reduction().

◆ array

entity array = entity_undefined
static

Definition at line 392 of file special_cases.c.

Referenced by add_declaration_to_host_and_link(), add_one_bound_argument(), alive_arrays(), argument_bound_entity(), array_access_to_array_ranges(), array_as_template(), array_bounds_list(), array_lower_upper_bounds_list(), array_must_fully_written_by_regions_p(), array_ranges_to_template_ranges(), array_synonym_aligned_as(), atomize_one_message(), block_distributed_p(), bound_parameter_name(), buffer_full_condition(), build_call_STEP_AllToAll(), build_call_STEP_init_regionArray(), call_filter(), clean_distributed_io_system(), clean_shared_io_system(), compile_reduction(), complementary_range(), compute_receive_content(), ComputeNewSizeOfIthDimension(), continue_propagation_p(), create_bound_entity(), create_init_common_param_for_arrays(), create_parameters_h(), deal_with_similars(), dims_array_init(), DistributionParameterOfArrayDim(), entity_to_new_declaration(), eov_add_entity_to_eliminate(), eov_get_replaced_enity(), expr_compute_local_index(), extract_the_align(), full_define_p(), generate_all_liveness_but(), generate_call_set_regionarray(), generate_call_stepalltoall(), generate_compute_local_indices(), generate_distributed_io_system(), generate_dynamic_liveness_for_primary(), generate_dynamic_liveness_management(), generate_full_copy(), generate_get_value_locally(), generate_io_collect_or_update(), generate_io_statements_for_shared_arrays(), generate_io_system(), generate_message_from_3_lists(), generate_one_message(), generate_optimized_code_for_loop_nest(), generate_receive_from_computer(), generate_send_to_computer(), generate_shared_io_system(), generate_subarray_shift(), generate_update_distributed_value_from_host(), generate_update_values_on_computer_and_nodes(), generate_update_values_on_nodes(), GENERATION(), get_alignment(), get_help_topic(), get_help_topics(), get_ith_dim_new_declaration(), global_array_cell_to_local_array_cell(), handle_prescriptive_directive(), hpfc_array_bound(), hpfc_broadcast_if_necessary(), hpfc_buffer_entity(), hpfc_buffer_packing(), hpfc_buffer_reference(), hpfc_check_for_similarities(), hpfc_compute_entity_to_new_declaration(), hpfc_compute_lid(), hpfc_hcast(), hpfc_hmessage(), hpfc_init_dummy_to_prime(), hpfc_lazy_buffer_packing(), hpfc_lazy_packing(), hpfc_nrecv(), hpfc_nsend(), hpfc_packing_of_current__buffer(), hpfc_unstutter_dummies(), initial_alignment(), io_efficient_compile(), ith_dim_distributed_p(), ith_dim_overlapable_p(), loop_nest_guard(), mchoose(), message_manageable_p(), messages_generation(), new_declaration_tag(), NewDeclarationOfDistributedArray(), NewDeclarationsOfDistributedArrays(), one_align_directive(), one_distribute_directive(), one_message_guards_and_neighbour(), one_receive_message(), Overlap_Analysis(), partial_linearization(), pips_get_fortran_list(), pips_get_workspace_list(), processor_loop(), put_variables_in_ordered_lists(), region_reduction_p(), region_to_statement(), remapping_file_name(), remove_from_entities(), remove_not_remapped_leavings(), root_statement_remapping_inits(), safe_static_domain_bound(), schoose(), set_array_dimension_checked(), set_similar_mappings_for_updates(), shape_one_message(), simple_indices_p(), st_compute_ith_local_index(), st_generate_packing(), st_one_message(), st_send_to_computer_if_necessary(), step_local_regionArray(), store_a_new_declaration(), string_array_join(), subarray_shift_assignment_p(), subarray_shift_p(), template_cell_local_mapping(), template_dimension_of_array_dimension(), top_down_abc_array(), top_down_abc_call(), top_down_abc_dimension(), top_down_abc_flt(), top_down_abc_not_exact_case(), and update_indices_for_local_computation().

◆ current_regions

list current_regions = NIL
static

Definition at line 393 of file special_cases.c.

Referenced by locally_constant_vector_p(), and subarray_shift_p().

◆ found_operator

tag found_operator
static

Definition at line 221 of file special_cases.c.

Referenced by get_operator(), and ref_filter().

◆ lvect

◆ ok

◆ searched_variable

entity searched_variable
static

hpfc_reductions = initial:entity x replacement:entity x operator:reduction ; reduction = { min , max , sum , prod , and , or } ;

looking for the reduction operator is a basic recursion. no check.

Definition at line 220 of file special_cases.c.

Referenced by get_operator(), and ref_filter().

◆ simple_found

statement simple_found
static

tests whether a loop nest is a full copy loop nest, i.e.

it copies an array into another, both being aligned. ??? it should share some code with the subarray shift detection... ??? another quick hack for testing purposes (remappings). statement simple_statement(statement s)

what: tells whether s is (after simplification) a simple statement, i.e. a call, and returns it (may be hidden by blocks and continues). how: recursion thru the IR. input: statement s output: returned statement, or NULL if not simple... side effects:

  • uses some static data bugs or features:

Definition at line 701 of file special_cases.c.

Referenced by check_simple(), and simple_statement().

◆ subarray_shift_ok

bool subarray_shift_ok = true
static

some static variables used for the detection...

Definition at line 391 of file special_cases.c.

Referenced by call_filter(), cannot_be_a_shift(), loop_filter(), and subarray_shift_p().