PIPS
ricedg.c File Reference
#include "genC.h"
#include "local.h"
#include "workspace-util.h"
#include "prettyprint.h"
+ Include dependency graph for ricedg.c:

Go to the source code of this file.

Macros

#define Psysteme_undefined   SC_UNDEFINED
 to map statements to execution contexts More...
 
#define DG_FAST   1
 Different types of dependence tests: More...
 
#define DG_FULL   2
 
#define DG_SEMANTICS   3
 

Functions

static bool rice_dependence_graph (char *)
 INTERFACE FUNCTIONS
More...
 
bool rice_fast_dependence_graph (char *mod_name)
 
bool rice_full_dependence_graph (char *mod_name)
 
bool rice_semantics_dependence_graph (char *mod_name)
 
bool rice_regions_dependence_graph (char *mod_name)
 
static void rdg_unstructured (unstructured)
 STATIC FUNCTION DECLARATIONS
More...
 
static void rdg_statement (statement)
 
static void rdg_loop (statement)
 
static void rice_update_dependence_graph (statement stat, set region)
 Update of dependence graph. More...
 
static list TestCoupleOfEffects (statement s1, effect e1, statement s2, effect e2, list llv, Ptsg *gs, list *levelsop, Ptsg *gsop)
 DEPENDENCE TEST
More...
 
static list TestDependence (list n1, Psysteme sc1, statement s1, effect ef1, reference r1, list n2, Psysteme sc2, statement s2, effect ef2, reference r2, list llv, Ptsg *gs, list *levelsop, Ptsg *gsop)
 static list TestDependence(list n1, n2, Psysteme sc1, sc2, statement s1, s2, effect ef1, ef2, reference r1, r2, list llv, list *levelsop, Ptsg *gs,*gsop) input : list n1, n2 : enclosing loops for statements s1 and s2; Psysteme sc1, sc2: current context for each statement; statement s1, s2 : currently analyzed statements; effect ef1, ef2 : effects of each statement upon the current variable; (maybe array regions) reference r1, r2 : current variables references; list llv : loop variant list (variables that vary in loop nests n1 and n2?); list *levelsop : dependence levels from s2 to s1 Ptsg *gs,*gsop : dependence cones from s1 to s2 and from s2 to s1 output : dependence levels from s1 to s2 modifies : levelsop, gsop, gs and returns levels More...
 
static bool build_and_test_dependence_context (reference r1, reference r2, Psysteme sc1, Psysteme sc2, Psysteme *psc_dep, list llv, list s2_enc_loops)
 static bool build_and_test_dependence_context(reference r1, r2, Psystem sc1, sc2, *psc_dep, list llv, s2_enc_loops) input : reference r1, r2 : current array references; Psystem sc1, sc2 : context systems for r1 and r2; they might be modified and even be freed (!) by normalization procedures Psystem *psc_dep : pointer toward the dependence context systeme; list llv : current loop nest variant list; list s2_enc_loops : statement s2 enclosing loops; More...
 
static bool gcd_and_constant_dependence_test (reference r1, reference r2, list llv, list s2_enc_loops, Psysteme *psc_dep)
 static bool gcd_and_constant_dependence_test(references r1, r2, list llv, s2_enc_loops, Psysteme *psc_dep) input : references r1, r2 : current references; list llv : loop nest variant list; list s2_enc_loops : enclosing loops for statement s2; Psysteme *psc_dep : pointer toward the depedence system; output : true if there is no dependence (GCD and constant test successful); false if independence could not be proved. More...
 
static void dependence_system_add_lci_and_di (Psysteme *psc_dep, list s1_enc_loops, Pvecteur *p_DiIncNonCons)
 static void dependence_system_add_lci_and_di(Psysteme *psc_dep, list s1_enc_loops, Pvecteur *p_DiIncNonCons) input : Psysteme *psc_dep : pointer toward the dependence system; list s1_enc_loops : statement s1 enclosing loops; Pvecteur *p_DiIncNonCons : pointer toward DiIncNonCons. More...
 
static list TestDiVariables (Psysteme, int, statement, effect, statement, effect)
 
static Ptsg dependence_cone_positive (Psysteme dep_sc)
 Ptsg dependence_cone_positive(Psysteme dept_syst) More...
 
static list loop_variant_list (statement)
 
static bool TestDiCnst (Psysteme, int, statement, effect, statement, effect)
 
list TestCoupleOfReferences (list n1, Psysteme sc1 __attribute__((unused)), statement s1, effect ef1, reference r1, list n2, Psysteme sc2 __attribute__((unused)), statement s2, effect ef2, reference r2, list llv, Ptsg *gs __attribute__((unused)), list *levelsop __attribute__((unused)), Ptsg *gsop __attribute__((unused)))
 
static list TestDiVariables (Psysteme ps, int cl, statement s1, effect ef1 __attribute__((unused)), statement s2, effect ef2 __attribute__((unused)))
 
static bool TestDiCnst (Psysteme ps, int cl, statement s1, effect ef1 __attribute__((unused)), statement s2, effect ef2 __attribute__((unused)))
 this function detects intra-statement, non loop carried dependence ( Di=(0,0,...0) and s1 = s2). More...
 
void writeresult (char *mod_name)
 
graph compute_dg_on_statement_from_chains_in_place (statement s, graph chains)
 
graph compute_dg_on_statement_from_chains (statement s, graph chains)
 

Variables

int NbrArrayDepInit = 0
 Dependence Graph computation for Allen & Kennedy algorithm. More...
 
int NbrIndepFind = 0
 
int NbrAllEquals = 0
 
int NbrDepCnst = 0
 
int NbrTestExact = 0
 
int NbrDepInexactEq = 0
 
int NbrDepInexactFM = 0
 
int NbrDepInexactEFM = 0
 
int NbrScalDep = 0
 
int NbrIndexDep = 0
 
int deptype [5][3]
 
int constdep [5][3]
 
int NbrTestCnst = 0
 
int NbrTestGcd = 0
 
int NbrTestSimple = 0
 
int NbrTestDiCnst = 0
 by sc_normalize() More...
 
int NbrTestProjEqDi = 0
 
int NbrTestProjFMDi = 0
 
int NbrTestProjEq = 0
 
int NbrTestProjFM = 0
 
int NbrTestDiVar = 0
 
int NbrProjFMTotal = 0
 
int NbrFMSystNonAug = 0
 
int FMComp [18]
 
bool is_test_exact = true
 or counting the number of F-M complexity less than 16. More...
 
bool is_test_inexact_eq = false
 
bool is_test_inexact_fm = false
 
bool is_dep_cnst = false
 
bool is_test_Di
 
bool Finds2s1
 
static graph dg
 to map statements to enclosing loops More...
 
static bool PRINT_RSDG = false
 
static int dg_type = DG_FAST
 
int Nbrdo
 loop.c More...
 

Macro Definition Documentation

◆ DG_FAST

#define DG_FAST   1

Different types of dependence tests:

switch dg_type:

 DG_FAST: no context constraints are added
 DG_FULL: use loop bounds as context
 DG_SEMANTICS : use preconditions as context

The use of the variable dg_type allows to add more cases in the future.

Definition at line 124 of file ricedg.c.

◆ DG_FULL

#define DG_FULL   2

Definition at line 125 of file ricedg.c.

◆ DG_SEMANTICS

#define DG_SEMANTICS   3

Definition at line 126 of file ricedg.c.

◆ Psysteme_undefined

#define Psysteme_undefined   SC_UNDEFINED

to map statements to execution contexts

Psysteme_undefined is not defined in sc.h; as Psysteme is external, I define it here. BA, September 1993

Definition at line 103 of file ricedg.c.

Function Documentation

◆ build_and_test_dependence_context()

static bool build_and_test_dependence_context ( reference  r1,
reference  r2,
Psysteme  sc1,
Psysteme  sc2,
Psysteme psc_dep,
list  llv,
list  s2_enc_loops 
)
static

static bool build_and_test_dependence_context(reference r1, r2, Psystem sc1, sc2, *psc_dep, list llv, s2_enc_loops) input : reference r1, r2 : current array references; Psystem sc1, sc2 : context systems for r1 and r2; they might be modified and even be freed (!) by normalization procedures Psystem *psc_dep : pointer toward the dependence context systeme; list llv : current loop nest variant list; list s2_enc_loops : statement s2 enclosing loops;

output : bool : false if one of the initial systems is unfeasible after normalization; true otherwise; *psc_dep : dependence system is the function value is true; SC_EMPTY otherwise; no need to sc_rm() in the latter case.

side effects : psc_dep : points toward the dependence context system built from sc1 and sc2, r1 and r2, and llv. Dependence distance variables (di) are introduced in sc2, along with the dsi variables to take care of variables in llv modified in the loop nest; irrelevant (?) existencial constraints are removed. in order to make further manipulations easier. sc1 : side_effect of sc_normalize() sc2 : side_effect of sc_normalize()

Comment :

Modifications:

  • sc1 and sc2 cannot be sc_normalized because they may be part of statement preconditions or regions; sc_normalize() is replaced by sc_empty_p(); since regions and preconditions are normalized with stronger normalization procedure, and since the feasibility of the dependence test will be tested with an even stronger test, this should have no accuracy impact (FI, 12 December 1995)

Construction of initial systems sc_dep and sc_tmp from sc1 and sc2 if not undefined

sc_dep = sc1, but: we keep only useful constraints in the predicate (To avoid overflow errors, and to make projections easier)

sc_tmp = sc2, but: we keep only useful constraints in the predicate (To avoid overflow errors, and to make projections easier)

FI: I'm not sure this is correct. I'm afraid sc2 might be unfeasible and become feasible due to a careless elimination... It all depends on:

sc_restricted_to_variables_transitive_closure()

There might be a better function for that purpose

introduce dependence distance variable if loop increment value is known or ...

FI: a more powerful evaluation function for inc should be called when preconditions are available. For instance, mdg could be handled without having to partial_evaluate it

It's not clear whether sc1 or sc2 should be used to estimate a variable increment like N.

It's not clear whether it's correct or not. You would like N (or other variables in the increment expression) to be constant within the loop nest.

It would be better to know the precondition associated to the corresponding loop statement, but the information is lost in this low-level function.

FI: this is not true, you have sc1 and sc2 at hand to call sc_minmax_of_variable()

take care of variables modified in the loop

sc_tmp is emptied and freed by sc_fusion()

Definition at line 1580 of file ricedg.c.

1586  {
1587  Psysteme sc_dep, sc_tmp;
1588  list pc;
1589  int l, inc;
1590 
1591  /* *psc_dep must be undefined */pips_assert("build_and_test_dependence_context", SC_UNDEFINED_P(*psc_dep));
1592 
1593  /* Construction of initial systems sc_dep and sc_tmp from sc1 and sc2
1594  if not undefined
1595  */
1596  if(SC_UNDEFINED_P(sc1) && SC_UNDEFINED_P(sc2)) {
1597  sc_dep = sc_new();
1598  } else {
1599  if(SC_UNDEFINED_P(sc1))
1600  sc_dep = sc_new();
1601  else {
1602  /* sc_dep = sc1, but:
1603  * we keep only useful constraints in the predicate
1604  * (To avoid overflow errors, and to make projections easier)
1605  */
1607 
1608  if(sc_empty_p(sc1)) {
1609  *psc_dep = SC_EMPTY;
1610  pips_debug(4,
1611  "first initial normalized system sc1 not feasible\n");
1612  return (false);
1613  }
1614 
1615  ifdebug(6) {
1616  debug(6, "", "Initial system sc1 before restrictions : \n");
1617  sc_syst_debug(sc1);
1618  }
1619 
1621  normalized x1 = NORMALIZE_EXPRESSION(ex1);
1622 
1623  if(normalized_linear_p(x1)) {
1624  Pvecteur v1;
1625  Pvecteur v;
1626  v1 = (Pvecteur)normalized_linear(x1);
1627  for (v = v1; !VECTEUR_NUL_P(v); v = v->succ) {
1628  if(vecteur_var(v) != TCST)
1630  }
1631  }
1632  }
1633 
1635  }
1636 
1637  if(SC_UNDEFINED_P(sc2))
1638  sc_tmp = sc_new();
1639  else {
1640  /* sc_tmp = sc2, but:
1641  * we keep only useful constraints in the predicate
1642  * (To avoid overflow errors, and to make projections easier)
1643  *
1644  * FI: I'm not sure this is correct. I'm afraid sc2 might
1645  * be unfeasible and become feasible due to a careless
1646  * elimination... It all depends on:
1647  *
1648  * sc_restricted_to_variables_transitive_closure()
1649  *
1650  * There might be a better function for that purpose
1651  */
1653 
1654  if(sc_empty_p(sc2)) {
1655  *psc_dep = SC_EMPTY;
1656  pips_debug(4,
1657  "second initial normalized system not feasible\n");
1658  return (false);
1659  }
1660 
1661  ifdebug(6) {
1662  debug(6, "", "Initial system sc2 before restrictions : \n");
1663  sc_syst_debug(sc2);
1664  }
1665 
1666  FOREACH(EXPRESSION, ex2, reference_indices(r2)) {
1667  normalized x2 = NORMALIZE_EXPRESSION(ex2);
1668 
1669  if(normalized_linear_p(x2)) {
1670  Pvecteur v2;
1671  Pvecteur v;
1672 
1673  v2 = (Pvecteur)normalized_linear(x2);
1674  for (v = v2; !VECTEUR_NUL_P(v); v = v->succ) {
1675  if(vecteur_var(v) != TCST)
1677  }
1678 
1679  }
1680  }
1681 
1682 
1684  }
1685 
1686  ifdebug(6) {
1687  debug(6, "", "Initial systems after restrictions : \n");
1688  sc_syst_debug(sc_dep);
1689  sc_syst_debug(sc_tmp);
1690  }
1691 
1692  /* introduce dependence distance variable if loop increment value
1693  is known or ... */
1694  for (pc = s2_enc_loops, l = 1; pc != NIL; pc = CDR(pc), l++) {
1695  loop lo = statement_loop(STATEMENT(CAR(pc)));
1696  entity i2 = loop_index(lo);
1697  /* FI: a more powerful evaluation function for inc should be called
1698  * when preconditions are available. For instance, mdg could
1699  * be handled without having to partial_evaluate it
1700  *
1701  * It's not clear whether sc1 or sc2 should be used to
1702  * estimate a variable increment like N.
1703  *
1704  * It's not clear whether it's correct or not. You would like
1705  * N (or other variables in the increment expression) to be
1706  * constant within the loop nest.
1707  *
1708  * It would be better to know the precondition associated
1709  * to the corresponding loop statement, but the information
1710  * is lost in this low-level function.
1711  *
1712  * FI: this is not true, you have sc1 and sc2 at hand to call
1713  * sc_minmax_of_variable()
1714  */
1715  inc = loop_increment_value(lo);
1716  if(inc != 0)
1717  sc_add_di(l, i2, sc_tmp, inc);
1718  else
1719  sc_chg_var(sc_tmp, (Variable)i2, (Variable)GetLiVar(l));
1720  }
1721 
1722  /* take care of variables modified in the loop */
1723  for (pc = llv, l = 1; pc != NIL; pc = CDR(pc), l++) {
1724  sc_add_dsi(l, ENTITY(CAR(pc)), sc_tmp);
1725  }
1726 
1727  /* sc_tmp is emptied and freed by sc_fusion() */
1728  sc_dep = sc_fusion(sc_dep, sc_tmp);
1729  vect_rm(sc_dep->base);
1730  sc_dep->base = BASE_NULLE;
1731  sc_creer_base(sc_dep);
1732 
1733  }
1734 
1735  ifdebug(6) {
1736  pips_debug(6,
1737  "\ndependence context is:\n");
1738  sc_syst_debug(sc_dep);
1739  }
1740 
1741  *psc_dep = sc_dep;
1742  return (true);
1743 }
Pbase base_add_variable(Pbase b, Variable var)
Pbase base_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b at the end...
Definition: base.c:88
void sc_syst_debug(Psysteme s)
constraint_to_text.c
int loop_increment_value(loop l)
Definition: loop.c:714
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define NORMALIZE_EXPRESSION(e)
#define normalized_linear_p(x)
Definition: ri.h:1779
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define reference_indices(x)
Definition: ri.h:2328
#define normalized_linear(x)
Definition: ri.h:1781
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
void sc_add_di(int, entity, Psysteme, int)
Definition: testdep_util.c:209
void sc_add_dsi(int, entity, Psysteme)
Definition: testdep_util.c:238
entity GetLiVar(int)
Definition: testdep_util.c:121
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
bool sc_empty_p(Psysteme sc)
bool sc_empty_p(Psysteme sc): check if the set associated to sc is the constant sc_empty or not.
Definition: sc_alloc.c:350
Psysteme sc_fusion(Psysteme s1, Psysteme s2)
package sc
Psysteme sc_restricted_to_variables_transitive_closure(Psysteme sc, Pbase variables)
for an improved dependence test (Beatrice Creusillet)
Definition: sc_misc.c:64
static int variables[MAX_VAR]
void sc_chg_var(Psysteme s, Variable v_old, Variable v_new)
void sc_chg_var(Psysteme s, Variable v_old, Variable v_new) this function replace the variable v_old ...
Definition: sc_unaires.c:98
#define ifdebug(n)
Definition: sg.c:47
Pbase base
Definition: sc-local.h:75
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define vecteur_var(v)
struct Svecteur * Pvecteur
#define VECTEUR_NUL_P(v)
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
#define BASE_UNDEFINED
#define BASE_NULLE
MACROS SUR LES BASES.
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78

References Ssysteme::base, base_add_variable(), BASE_NULLE, BASE_UNDEFINED, CAR, CDR, debug(), ENTITY, EXPRESSION, FOREACH, GetLiVar(), ifdebug, loop_increment_value(), loop_index, NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_assert, pips_debug, reference_indices, sc_add_di(), sc_add_dsi(), sc_chg_var(), sc_creer_base(), sc_empty_p(), sc_fusion(), sc_new(), sc_restricted_to_variables_transitive_closure(), sc_syst_debug(), STATEMENT, statement_loop(), Svecteur::succ, TCST, variables, vect_rm(), VECTEUR_NUL_P, and vecteur_var.

Referenced by TestDependence().

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

◆ compute_dg_on_statement_from_chains()

graph compute_dg_on_statement_from_chains ( statement  s,
graph  chains 
)
Parameters
chainshains

Definition at line 2363 of file ricedg.c.

2363  {
2364  dg = copy_graph(chains);
2366 }
graph copy_graph(graph p)
GRAPH.
Definition: graph.c:20
static bool chains(char *module_name, enum chain_type use)
Compute chain dependence for a module according different kinds of store-like effects.
Definition: chains.c:1397
graph compute_dg_on_statement_from_chains_in_place(statement s, graph chains)
Definition: ricedg.c:2342
static graph dg
to map statements to enclosing loops
Definition: ricedg.c:110

References chains(), compute_dg_on_statement_from_chains_in_place(), copy_graph(), and dg.

+ Here is the call graph for this function:

◆ compute_dg_on_statement_from_chains_in_place()

graph compute_dg_on_statement_from_chains_in_place ( statement  s,
graph  chains 
)
Parameters
chainshains

Definition at line 2342 of file ricedg.c.

2342  {
2343  dg = chains;
2344  dg_type = DG_FAST; //FIXME
2345 
2346  debug_on("QUICK_PRIVATIZER_DEBUG_LEVEL");
2348  debug_off();
2349 
2350  memset(deptype,0,sizeof(deptype));
2351  memset(constdep,0,sizeof(deptype));
2352 
2353  rdg_statement(s);
2354 
2355  return dg;
2356 }
void * memset(void *str, int c, size_t len)
memset.c – set an area of memory to a given value Copyright (C) 1991, 2003, 2009-2011 Free Software F...
Definition: memset.c:23
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
void quick_privatize_graph(graph dep_graph)
quick_privatize.c
int constdep[5][3]
Definition: ricedg.c:74
static int dg_type
Definition: ricedg.c:128
#define DG_FAST
Different types of dependence tests:
Definition: ricedg.c:124
int deptype[5][3]
Definition: ricedg.c:74
static void rdg_statement(statement)
Definition: ricedg.c:409

References chains(), constdep, debug_off, debug_on, deptype, dg, DG_FAST, dg_type, memset(), quick_privatize_graph(), and rdg_statement().

Referenced by compute_dg_on_statement_from_chains().

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

◆ dependence_cone_positive()

static Ptsg dependence_cone_positive ( Psysteme  dep_sc)
static

Ptsg dependence_cone_positive(Psysteme dept_syst)

add the contraints bj = 0 (1<=j<i)

add the contraints - bi <= -1 (1<=j<i)

dans le cas d'une erreur d'overflow, on fait comme si le test avait renvoye' true. bc.

to mimic previous behavior of sc_normalize

We get a normalized sub lexico-positive dependence system

Parameters
dep_scep_sc

Definition at line 2096 of file ricedg.c.

2097  {
2098  Psysteme volatile sc_env = SC_UNDEFINED;
2099  Ptsg volatile sg_env = NULL;
2100  Pbase b;
2101  int n, j;
2102  int volatile i;
2103 
2104  if(SC_UNDEFINED_P(dep_sc))
2105  return (sg_new());
2106 
2107  sc_env = sc_empty(base_dup(dep_sc->base));
2108  n = dep_sc->dimension;
2109  b = dep_sc->base;
2110 
2111  for (i = 1; i <= n; i++) {
2112  volatile Psysteme sub_sc = sc_dup(dep_sc);
2113  Pvecteur v;
2114  Pcontrainte pc;
2115  Pbase b1;
2116 
2117  for (j = 1, b1 = b; j <= i - 1; j++, b1 = b1->succ) {
2118  /* add the contraints bj = 0 (1<=j<i) */
2119  v = vect_new(b1->var, 1);
2120  pc = contrainte_make(v);
2121  sc_add_eg(sub_sc,pc);
2122  }
2123  /* add the contraints - bi <= -1 (1<=j<i) */
2124  v = vect_new(b1->var, -1);
2125  vect_add_elem(&v, TCST, 1);
2126  pc = contrainte_make(v);
2127  sc_add_ineg(sub_sc,pc);
2128 
2129  ifdebug(7) {
2130  fprintf(stderr, "\nInitial sub lexico-positive dependence system:\n");
2131  sc_syst_debug(sub_sc);
2132  }
2133 
2134  /* dans le cas d'une erreur d'overflow, on fait comme si le test
2135  * avait renvoye' true. bc.
2136  */CATCH(overflow_error) {
2137  pips_debug(1, "overflow error.\n");
2138  } TRY
2139  {
2140  if(!sc_integer_feasibility_ofl_ctrl(sub_sc, FWD_OFL_CTRL, true)) {
2141  sc_rm(sub_sc);
2142  pips_debug(7,"sub lexico-positive dependence system not feasible\n");
2143 
2145  continue;
2146  } else
2148 
2149  }
2150 
2151  if(sc_empty_p(sub_sc = sc_normalize(sub_sc))) {
2152  sc_rm(sub_sc); /* to mimic previous behavior of sc_normalize */
2153  pips_debug(7, "normalized system not feasible\n");
2154 
2155  continue;
2156  }
2157 
2158  /* We get a normalized sub lexico-positive dependence system */ifdebug(7) {
2159  fprintf(stderr, "Normalized sub lexico-positive dependence system :\n");
2160  sc_syst_debug(sub_sc);
2161  }
2162 
2163  {
2164  Psysteme old_sc_env = sc_env;
2165  sc_env = sc_enveloppe_chernikova(sc_env, sub_sc);
2166  sc_rm(old_sc_env);
2167  }
2168 
2169  sc_rm(sub_sc);
2170 
2171  ifdebug(7) {
2172  fprintf(stderr, "Dependence system of the enveloppe of subs "
2173  "lexico-positive dependence:\n");
2174  sc_syst_debug(sc_env);
2175 
2176  if(!SC_UNDEFINED_P(sc_env) && !sc_rn_p(sc_env)) {
2177  sg_env = sc_to_sg_chernikova(sc_env);
2178  fprintf(stderr, "Enveloppe of the subs lexico-positive "
2179  "dependence cones:\n");
2180  if(!SG_UNDEFINED_P(sg_env) && vect_size(sg_env->base) != 0) {
2181  print_dependence_cone(stderr, sg_env, sg_env->base);
2182  sg_rm(sg_env);
2183  sg_env = (Ptsg)NULL;
2184  }
2185  }
2186  }
2187 
2188  }
2189 
2190  if(!SC_UNDEFINED_P(sc_env) && sc_dimension(sc_env) != 0) {
2191 
2192  sg_env = sc_to_sg_chernikova(sc_env);
2193  sc_rm(sc_env);
2194  } else {
2195  sg_env = sg_new();
2196  }
2197 
2198  return (sg_env);
2199 }
#define CATCH(what)
@ overflow_error
#define UNCATCH(what)
#define TRY
Ptsg sc_to_sg_chernikova(Psysteme sc)
chernikova_mulprec.c
Definition: chernikova.c:42
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
Psysteme sc_enveloppe_chernikova(Psysteme, Psysteme)
Definition: sc_enveloppe.c:127
void print_dependence_cone(FILE *, Ptsg, Pbase)
Definition: util.c:974
bool sc_rn_p(Psysteme sc)
bool sc_rn_p(Psysteme sc): check if the set associated to sc is the whole space, rn
Definition: sc_alloc.c:369
Psysteme sc_empty(Pbase b)
Psysteme sc_empty(Pbase b): build a Psysteme with one unfeasible constraint to define the empty subsp...
Definition: sc_alloc.c:319
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
bool sc_integer_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
struct type_sg * Ptsg
Representation d'un systeme generateur par trois ensembles de sommets de rayons et de droites.
#define SG_UNDEFINED_P(sg)
Definition: sg-local.h:74
Ptsg sg_new()
Ptsg sg_new(): allocation d'un systeme generateur et initialisation a la valeur ensemble vide.
Definition: sg.c:55
void sg_rm(Ptsg sg)
void sg_rm(Ptsg sg): liberation de l'espace memoire occupe par un systeme generateur
Definition: sg.c:249
int dimension
Definition: sc-local.h:74
Representation d'un systeme generateur par trois ensembles de sommets de rayons et de droites.
Definition: sg-local.h:66
Pbase base
Definition: sg-local.h:70
#define FWD_OFL_CTRL
Pbase base_dup(Pbase b)
Pbase base_dup(Pbase b) Note: this function changes the value of the pointer.
Definition: alloc.c:268
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References b1, type_sg::base, base_dup(), CATCH, contrainte_make(), fprintf(), FWD_OFL_CTRL, ifdebug, overflow_error, pips_debug, print_dependence_cone(), sc_dup(), sc_empty(), sc_empty_p(), sc_enveloppe_chernikova(), sc_integer_feasibility_ofl_ctrl(), sc_normalize(), sc_rm(), sc_rn_p(), sc_syst_debug(), sc_to_sg_chernikova(), sg_new(), sg_rm(), SG_UNDEFINED_P, TCST, TRY, UNCATCH, vect_add_elem(), vect_new(), and vect_size().

Referenced by TestDependence().

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

◆ dependence_system_add_lci_and_di()

static void dependence_system_add_lci_and_di ( Psysteme psc_dep,
list  s1_enc_loops,
Pvecteur p_DiIncNonCons 
)
static

static void dependence_system_add_lci_and_di(Psysteme *psc_dep, list s1_enc_loops, Pvecteur *p_DiIncNonCons) input : Psysteme *psc_dep : pointer toward the dependence system; list s1_enc_loops : statement s1 enclosing loops; Pvecteur *p_DiIncNonCons : pointer toward DiIncNonCons.

output : none

modifies :

*psc_dep, the dependence systeme (addition of constraints with lci and di variables, if useful; lci is a loop counter, di an iteration difference variable);

DiIncNonCons: di variables are added to DiIncNonCons (means Di variables for loops with non constant increment, i.e. unknown increment), if any such loop exists.

comment : DiIncNonCons must be undefined on entry.

Addition of lck, the loop counters, and di, the iteration difference, variables (if useful).

If the loop increment is not trivial, express the current index value as the sum of the lower bound and the product of the loop counter by the loop increment.

Else, this new equation would be redundant

make nl + inc*lc# - ind = 0

If the loop increment is unknown, which is expressed by inc==0, well, I do not understand what li variables are, not how they work

make d::i - l::i + ind = 0 , add d::i in list of DiIncNonCons

Update basis

Definition at line 1883 of file ricedg.c.

1886  {
1887  int l;
1888  list pc;
1889 
1890  pips_assert("dependence_system_add_lci_and_di",
1891  VECTEUR_UNDEFINED_P(*p_DiIncNonCons));
1892 
1893  /* Addition of lck, the loop counters, and di, the iteration difference,
1894  * variables (if useful).
1895  */
1896  for (pc = s1_enc_loops, l = 1; pc != NIL; pc = CDR(pc), l++) {
1897  loop lo = statement_loop(STATEMENT(CAR(pc)));
1898  entity ind = loop_index(lo);
1899  int inc = loop_increment_value(lo);
1900 
1901  expression lb = range_lower(loop_range(lo));
1903 
1904  /* If the loop increment is not trivial, express the current
1905  * index value as the sum of the lower bound and the product
1906  * of the loop counter by the loop increment.
1907  *
1908  * Else, this new equation would be redundant
1909  */
1910  /* make nl + inc*lc# - ind = 0 */
1911  if(inc != 0 && inc != 1 && inc != -1 && normalized_linear_p(nl)) {
1912  Pcontrainte pc;
1913  entity lc;
1914  Pvecteur pv;
1915 
1916  lc = MakeLoopCounter();
1917  pv = vect_dup((Pvecteur)normalized_linear(nl));
1918  vect_add_elem(&pv, (Variable)lc, inc);
1919  vect_add_elem(&pv, (Variable)ind, -1);
1920  pc = contrainte_make(pv);
1921  sc_add_eg(*psc_dep, pc);
1922  }
1923 
1924  /* If the loop increment is unknown, which is expressed by inc==0,
1925  * well, I do not understand what li variables are, not how they work
1926  */
1927  /* make d#i - l#i + ind = 0 ,
1928  add d#i in list of DiIncNonCons*/
1929  if(inc == 0) {
1930  Pcontrainte pc;
1931  Pvecteur pv = NULL;
1932  entity di;
1933 
1934  di = GetDiVar(l);
1935  vect_add_elem(&pv, (Variable)di, 1);
1936  vect_add_elem(&pv, (Variable)GetLiVar(l), -1);
1937  vect_add_elem(&pv, (Variable)ind, 1);
1938  pc = contrainte_make(pv);
1939  sc_add_eg(*psc_dep, pc);
1940 
1941  vect_add_elem(p_DiIncNonCons, (Variable)di, 1);
1942  }
1943 
1944  }
1945 
1946  /* Update basis */
1947  if(!BASE_NULLE_P((*psc_dep)->base)) {
1948  vect_rm((*psc_dep)->base);
1949  (*psc_dep)->base = BASE_UNDEFINED;
1950  }
1951  sc_creer_base(*psc_dep);
1952 }
#define range_lower(x)
Definition: ri.h:2288
#define loop_range(x)
Definition: ri.h:1642
entity GetDiVar(int)
This functions looks up a di variable of nesting level l in table DiVars.
Definition: testdep_util.c:79
entity MakeLoopCounter(void)
Create a new loop counter variable.
Definition: testdep_util.c:334
#define BASE_NULLE_P(b)
#define VECTEUR_UNDEFINED_P(v)
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51

References BASE_NULLE_P, BASE_UNDEFINED, CAR, CDR, contrainte_make(), GetDiVar(), GetLiVar(), loop_increment_value(), loop_index, loop_range, MakeLoopCounter(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_assert, range_lower, sc_creer_base(), STATEMENT, statement_loop(), vect_add_elem(), vect_dup(), vect_rm(), and VECTEUR_UNDEFINED_P.

Referenced by TestDependence().

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

◆ gcd_and_constant_dependence_test()

static bool gcd_and_constant_dependence_test ( reference  r1,
reference  r2,
list  llv,
list  s2_enc_loops,
Psysteme psc_dep 
)
static

static bool gcd_and_constant_dependence_test(references r1, r2, list llv, s2_enc_loops, Psysteme *psc_dep) input : references r1, r2 : current references; list llv : loop nest variant list; list s2_enc_loops : enclosing loops for statement s2; Psysteme *psc_dep : pointer toward the depedence system; output : true if there is no dependence (GCD and constant test successful); false if independence could not be proved.

modifies : *psc_dep; at least adds dependence equations on phi variables comment :

  • *psc_dep must be defined on entry; it must have been initialized by build_and_test_dependence_context.
  • no side effects on r1, r2,...

Further construction of the dependence system; Constant and GCD tests at the same time.

case of T(3)=... et T(4)=...

test of GCD

C assumed

Update base of *psc_dep

Definition at line 1761 of file ricedg.c.

1765  {
1766  list pc1, pc2, pc;
1767  int l;
1768 
1769  /* Further construction of the dependence system; Constant and GCD tests
1770  * at the same time.
1771  */
1772  pc1 = reference_indices(r1);
1773  pc2 = reference_indices(r2);
1774 
1775  while(pc1 != NIL && pc2 != NIL) {
1776  expression ex1, ex2;
1777  normalized x1, x2;
1778 
1779  ex1 = EXPRESSION(CAR(pc1));
1780  x1 = NORMALIZE_EXPRESSION(ex1);
1781 
1782  ex2 = EXPRESSION(CAR(pc2));
1783  x2 = NORMALIZE_EXPRESSION(ex2);
1784 
1785  if(normalized_linear_p(x1) && normalized_linear_p(x2)) {
1786  Pvecteur v1, v2, v;
1787 
1788  v1 = (Pvecteur)normalized_linear(x1);
1789  v2 = vect_dup((Pvecteur)normalized_linear(x2));
1790 
1791  for (pc = s2_enc_loops, l = 1; pc != NIL; pc = CDR(pc), l++) {
1792  loop lo = statement_loop(STATEMENT(CAR(pc)));
1793  entity i = loop_index(lo);
1794  int li = loop_increment_value(lo);
1795  Value vli = int_to_value(li);
1796  if(value_notzero_p(vli)) {
1797  Value v = vect_coeff((Variable)i, v2);
1798  value_product(v,vli);
1799  vect_add_elem(&v2, (Variable)GetDiVar(l), v);
1800  } else
1801  vect_chg_var(&v2, (Variable)i, (Variable)GetLiVar(l));
1802  }
1803 
1804  for (pc = llv, l = 1; pc != NIL; pc = CDR(pc), l++) {
1805  vect_add_elem(&v2,
1806  (Variable)GetDsiVar(l),
1807  vect_coeff((Variable)ENTITY(CAR(pc)), v2));
1808  }
1809 
1810  if(!VECTEUR_UNDEFINED_P(v = vect_substract(v1, v2))) {
1812 
1813  /* case of T(3)=... et T(4)=... */
1815  NbrTestCnst++;
1816  pips_debug(4,"TestCnst succeeded!");
1817  return (true);
1818  }
1819  /* test of GCD */
1820  if(egalite_normalize(c) == false) {
1821  NbrTestGcd++;
1822  pips_debug(4,"TestGcd succeeded!\n");
1823  return (true);
1824  }
1825  sc_add_eg(*psc_dep, c);
1826  }
1827  vect_rm(v2);
1828  }
1829 
1830  pc1 = CDR(pc1);
1831  pc2 = CDR(pc2);
1832  }
1833 
1834  if(pc1 != NIL || pc2 != NIL) {
1836  pips_internal_error("numbers of subscript expressions differ");
1837  } else {
1838  /* C assumed */
1839  pips_user_warning("dependence tested between two memory access paths"
1840  " of different lengths for variable \"%s\".\n",
1842  }
1843  }
1844 
1845  /* Update base of *psc_dep */
1846  Pbase mb = sc_to_minimal_basis(*psc_dep);
1847  Pbase cb = sc_base(*psc_dep);
1848  if(!vect_in_basis_p(mb, cb)) {
1849  Pbase nb = base_union(cb, mb);
1850  sc_base(*psc_dep) = nb;
1851  sc_dimension(*psc_dep) = vect_size(nb); // base_dimension(nb);
1852  vect_rm(cb);
1853  }
1854  vect_rm(mb);
1855 
1856  pips_assert("The dependence system is consistent", sc_consistent_p(*psc_dep));
1857 
1858  return (false);
1859 }
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_notzero_p(val)
int Value
#define value_product(v, w)
bool vect_in_basis_p(Pvecteur v, Pbase b)
Pvecteur vect_in_basis_p(Pvecteur v, Pbase b): check that all coordinates in v are in b,...
Definition: base.c:342
Pbase base_union(Pbase b1, Pbase b2)
Pbase base_union(Pbase b1, Pbase b2): compute a new basis containing all elements of b1 and all eleme...
Definition: base.c:428
#define COEFF_CST(c)
int COEFF_CST(Pcontrainte c): terme constant d'une contrainte
bool egalite_normalize(Pcontrainte)
bool egalite_normalize(Pcontrainte eg): reduction d'une equation diophantienne par le pgcd de ses coe...
Definition: normalize.c:136
bool contrainte_constante_p(Pcontrainte)
bool contrainte_constante_p(Pcontrainte c): test de contrainte triviale sans variables (ie du type 0<...
Definition: predicats.c:192
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define pips_user_warning
Definition: misc-local.h:146
#define pips_internal_error
Definition: misc-local.h:149
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
#define reference_variable(x)
Definition: ri.h:2326
int NbrTestGcd
Definition: ricedg.c:76
int NbrTestCnst
Definition: ricedg.c:75
entity GetDsiVar(int)
Definition: testdep_util.c:164
bool sc_consistent_p(Psysteme sc)
bool sc_consistent_p(Psysteme sc): check that sc is well defined, that the numbers of equalities and ...
Definition: sc.c:282
Pbase sc_to_minimal_basis(Psysteme ps)
creation d'une base contenant toutes les variables apparaissant avec des coefficients non-nuls dans l...
Definition: sc_alloc.c:76
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
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228
void vect_chg_var(Pvecteur *ppv, Variable v_old, Variable v_new)
void vect_chg_var(Pvecteur *ppv, Variable v_old, Variable v_new) replace the variable v_old by v_new
Definition: unaires.c:168

References base_union(), CAR, CDR, COEFF_CST, contrainte_constante_p(), contrainte_make(), egalite_normalize(), ENTITY, entity_user_name(), EXPRESSION, fortran_module_p(), get_current_module_entity(), GetDiVar(), GetDsiVar(), GetLiVar(), int_to_value, loop_increment_value(), loop_index, NbrTestCnst, NbrTestGcd, NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_assert, pips_debug, pips_internal_error, pips_user_warning, reference_indices, reference_variable, sc_consistent_p(), sc_to_minimal_basis(), STATEMENT, statement_loop(), value_notzero_p, value_product, vect_add_elem(), vect_chg_var(), vect_coeff(), vect_dup(), vect_in_basis_p(), vect_rm(), vect_size(), vect_substract(), and VECTEUR_UNDEFINED_P.

Referenced by TestDependence().

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

◆ loop_variant_list()

static list loop_variant_list ( statement  stat)
static
Parameters
stattat

Definition at line 2201 of file ricedg.c.

2202  {
2203  list lv = NIL;
2204  loop l;
2205  list locals;
2206 
2207  pips_assert("statement stat is a loop", statement_loop_p(stat));
2209  entity en = effect_entity(ef);
2211  && entity_integer_scalar_p(en))
2212  lv = gen_nconc(lv, CONS(ENTITY, en, NIL));
2213  }
2214  l = statement_loop(stat);
2215  locals = loop_locals(l);
2216  FOREACH (ENTITY, v, locals) {
2217  if(gen_find_eq(v, lv) == entity_undefined)
2218  lv = CONS(ENTITY, v, lv);
2219  }
2220  locals = statement_declarations(loop_body(l));
2221  FOREACH (ENTITY, v, locals) {
2222  if(gen_find_eq(v, lv) == entity_undefined)
2223  lv = CONS(ENTITY, v, lv);
2224  }
2225  return (lv);
2226 }
bool entity_all_locations_p(entity e)
test if an entity is the top of the lattice
list load_cumulated_rw_effects_list(statement)
entity effect_entity(effect)
cproto-generated files
Definition: effects.c:52
#define effect_action(x)
Definition: effects.h:642
#define action_write_p(x)
Definition: effects.h:314
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422
bool statement_loop_p(statement)
Definition: statement.c:349
bool entity_integer_scalar_p(entity)
for variables (like I), not constants (like 1)! use integer_constant_p() for constants
Definition: variable.c:1130
#define loop_body(x)
Definition: ri.h:1644
#define entity_undefined
Definition: ri.h:2761
#define loop_locals(x)
Definition: ri.h:1650
#define statement_declarations(x)
Definition: ri.h:2460

References action_write_p, CONS, EFFECT, effect_action, effect_entity(), ENTITY, entity_all_locations_p(), entity_integer_scalar_p(), entity_undefined, FOREACH, gen_find_eq(), gen_nconc(), load_cumulated_rw_effects_list(), loop_body, loop_locals, NIL, pips_assert, statement_declarations, statement_loop(), and statement_loop_p().

Referenced by rice_update_dependence_graph().

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

◆ rdg_loop()

static void rdg_loop ( statement  stat)
static
Parameters
stattat

Definition at line 452 of file ricedg.c.

452  {
453  set region;
454 
455  if(get_bool_property("COMPUTE_ALL_DEPENDENCES")) {
456  region = region_of_loop(stat);
457  ifdebug(7) {
458  fprintf(stderr, "[rdg_loop] applied on region:\n");
459  print_statement_set(stderr, region);
460  }
462  } else {
463  if((region = distributable_loop(stat)) == set_undefined) {
464  ifdebug(1) {
465  fprintf(stderr,
466  "[rdg_loop] skipping loop %td (but recursing)\n",
467  statement_number(stat));
468  }
470  } else {
472  set_free(region);
473  }
474  }
475 }
#define region
simulation of the type region
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
set distributable_loop(statement l)
this functions checks if Kennedy's algorithm can be applied on the loop passed as argument.
Definition: loop.c:221
set region_of_loop(statement l)
this function returns the set of all statements belonging to the given loop even if the loop contains...
Definition: loop.c:254
#define set_undefined
Definition: newgen_set.h:48
void set_free(set)
Definition: set.c:332
void print_statement_set(FILE *, set)
statement.c
Definition: statement.c:49
#define statement_number(x)
Definition: ri.h:2452
static void rice_update_dependence_graph(statement, set)
Update of dependence graph.
Definition: ricedg.c:560
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59

References distributable_loop(), fprintf(), get_bool_property(), ifdebug, loop_body, print_statement_set(), rdg_statement(), region, region_of_loop(), rice_update_dependence_graph(), set_free(), set_undefined, statement_loop(), and statement_number.

Referenced by rdg_statement().

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

◆ rdg_statement()

static void rdg_statement ( statement  stat)
static
Parameters
stattat

Definition at line 409 of file ricedg.c.

409  {
413  instruction istat = statement_instruction(stat);
414 
415  switch(instruction_tag(istat)) {
416  case is_instruction_block: {
417  FOREACH (STATEMENT, s, instruction_block(istat))
418  rdg_statement(s);
419  break;
420  }
421  case is_instruction_test:
424  break;
425  case is_instruction_loop:
426  rdg_loop(stat);
427  break;
429  wl = instruction_whileloop (istat);
430  body = whileloop_body (wl);
431  rdg_statement(body);
432  break;
434  fl = instruction_forloop (istat);
435  body = forloop_body (fl);
436  rdg_statement(body);
437  break;
438  case is_instruction_goto:
439  case is_instruction_call:
441  break;
444  break;
445  default:
446  pips_internal_error("case default reached with tag %d",
447  instruction_tag(istat));
448  break;
449  }
450 }
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_expression
Definition: ri.h:1478
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define instruction_forloop(x)
Definition: ri.h:1538
#define instruction_whileloop(x)
Definition: ri.h:1523
#define whileloop_body(x)
Definition: ri.h:3162
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_test(x)
Definition: ri.h:1517
#define forloop_body(x)
Definition: ri.h:1372
#define whileloop_undefined
Definition: ri.h:3134
#define instruction_unstructured(x)
Definition: ri.h:1532
#define statement_undefined
Definition: ri.h:2419
#define forloop_undefined
Definition: ri.h:1340
static void rdg_unstructured(unstructured)
STATIC FUNCTION DECLARATIONS
Definition: ricedg.c:399
static void rdg_loop(statement)
Definition: ricedg.c:452

References FOREACH, forloop_body, forloop_undefined, instruction_block, instruction_forloop, instruction_tag, instruction_test, instruction_unstructured, instruction_whileloop, is_instruction_block, is_instruction_call, is_instruction_expression, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, pips_internal_error, rdg_loop(), rdg_unstructured(), STATEMENT, statement_instruction, statement_undefined, test_false, test_true, whileloop_body, and whileloop_undefined.

Referenced by compute_dg_on_statement_from_chains_in_place(), rdg_loop(), rdg_unstructured(), and rice_dependence_graph().

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

◆ rdg_unstructured()

static void rdg_unstructured ( unstructured  u)
static

STATIC FUNCTION DECLARATIONS

Definition at line 399 of file ricedg.c.

399  {
400  list blocs = NIL;
401 
402  CONTROL_MAP(c, {
404  }, unstructured_control(u), blocs);
405 
406  gen_free_list(blocs);
407 }
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define control_statement(x)
Definition: ri.h:941

References CONTROL_MAP, control_statement, gen_free_list(), NIL, rdg_statement(), and unstructured_control.

Referenced by rdg_statement().

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

◆ rice_dependence_graph()

static bool rice_dependence_graph ( char *  mod_name)
static

INTERFACE FUNCTIONS

The supplementary call to init_ordering_to_statement should be avoided if ordering.c were more clever.

we need to access the statements from their ordering for the dependance-graph:

Do this as late as possible as it is also used by pipsdbm...

walk thru mod_stat to find well structured loops. update dependence graph for these loops.

write the result to the file correspondant in the order of : module,NbrArrayDeptInit,NbrIndeptFind,NbrArrayDepInit,NbrScalDep, NbrIndexDep,deptype[5][3]

FI: this is not a proper way to do it

Parameters
mod_nameod_name

Definition at line 230 of file ricedg.c.

230  {
231  FILE *fp;
232 
234  int i, j;
235  graph chains;
236  string dg_name;
238 
240 
242  mod_name,
243  true));
245 
246  chains = (graph)db_get_memory_resource(DBR_CHAINS, mod_name, true);
247 
249 
250  debug_on("RICEDG_DEBUG_LEVEL");
251  pips_debug(1, "Computing Rice dependence graph for %s\n", mod_name);
252 
253  ifdebug(2) {
256  }
257 
258  ifdebug(1) {
259  fprintf(stderr,
260  "Space for chains: %d bytes\n",
262  fprintf(stderr,
263  "Space for obj_table: %d bytes\n",
265  }
266 
268  dg = copy_graph(chains);
269 
270  ifdebug(1) {
271  fprintf(stderr,
272  "Space for chains's copy: %d bytes\n",
274  fprintf(stderr,
275  "Space for obj_table: %d bytes\n",
277  }
278 
279  pips_debug(8,"original graph\n");
280  ifdebug(8) {
284  }
285 
286  debug_off();
287 
288  if(dg_type == DG_SEMANTICS)
290  mod_name,
291  true));
292 
294  mod_name,
295  true));
296 
297  debug_on("RICEDG_DEBUG_LEVEL");
298  pips_debug(1, "finding enclosing loops ...\n");
299 
301  ifdebug(3) {
302  fprintf(stderr, "\nThe number of DOs :\n");
303  fprintf(stderr, " Nbrdo=%d", Nbrdo);
304  }
305  debug_on("QUICK_PRIVATIZER_DEBUG_LEVEL");
306 
307  /* we need to access the statements from their ordering for the
308  dependance-graph: */
309  /* Do this as late as possible as it is also used by pipsdbm... */
311 
313  debug_off();
314 
315  for (i = 0; i <= 4; i++) {
316  for (j = 0; j <= 2; j++) {
317  deptype[i][j] = 0;
318  constdep[i][j] = 0;
319  }
320  }
321 
322  /* walk thru mod_stat to find well structured loops.
323  update dependence graph for these loops. */
324 
326 
327  ifdebug(3) {
328  fprintf(stderr, "\nThe results of statistique of test of dependence are:\n");
329  fprintf(stderr, "NbrArrayDepInit = %d\n", NbrArrayDepInit);
330  fprintf(stderr, "NbrIndepFind = %d\n", NbrIndepFind);
331  fprintf(stderr, "NbrAllEquals = %d\n", NbrAllEquals);
332  fprintf(stderr, "NbrDepCnst = %d\n", NbrDepCnst);
333  fprintf(stderr, "NbrTestExact= %d\n", NbrTestExact);
334  fprintf(stderr, "NbrDepInexactEq= %d\n", NbrDepInexactEq);
335  fprintf(stderr, "NbrDepInexactFM= %d\n", NbrDepInexactFM);
336  fprintf(stderr, "NbrDepInexactEFM= %d\n", NbrDepInexactEFM);
337  fprintf(stderr, "NbrScalDep = %d\n", NbrScalDep);
338  fprintf(stderr, "NbrIndexDep = %d\n", NbrIndexDep);
339  fprintf(stderr, "deptype[][]");
340  for (i = 0; i <= 4; i++)
341  for (j = 0; j <= 2; j++)
342  fprintf(stderr, "%d ", deptype[i][j]);
343  fprintf(stderr, "\nconstdep[][]");
344  for (i = 0; i <= 4; i++)
345  for (j = 0; j <= 2; j++)
346  fprintf(stderr, "%d ", constdep[i][j]);
347  fprintf(stderr, "\nNbrTestCnst = %d\n", NbrTestCnst);
348  fprintf(stderr, "NbrTestGcd = %d\n", NbrTestGcd);
349  fprintf(stderr, "NbrTestSimple = %d\n", NbrTestSimple);
350  fprintf(stderr, "NbrTestDiCnst = %d\n", NbrTestDiCnst);
351  fprintf(stderr, "NbrTestProjEqDi = %d\n", NbrTestProjEqDi);
352  fprintf(stderr, "NbrTestProjFMDi = %d\n", NbrTestProjFMDi);
353  fprintf(stderr, "NbrTestProjEq = %d\n", NbrTestProjEq);
354  fprintf(stderr, "NbrTestProjFM = %d\n", NbrTestProjFM);
355  fprintf(stderr, "NbrTestDiVar = %d\n", NbrTestDiVar);
356  fprintf(stderr, "NbrProjFMTotal = %d\n", NbrProjFMTotal);
357  fprintf(stderr, "NbrFMSystNonAug = %d\n", NbrFMSystNonAug);
358  fprintf(stderr, "FMComp[]");
359  for (i = 0; i < 18; i++)
360  fprintf(stderr, "%d ", FMComp[i]);
361  }
362  /* write the result to the file correspondant in the order of :
363  module,NbrArrayDeptInit,NbrIndeptFind,NbrArrayDepInit,NbrScalDep,
364  NbrIndexDep,deptype[5][3]*/
366  writeresult(mod_name);
367 
368  ifdebug(2) {
369  fprintf(stderr, "updated graph\n");
371  }
372 
373  /* FI: this is not a proper way to do it */
374  if(get_bool_property("PRINT_DEPENDENCE_GRAPH") || PRINT_RSDG) {
376  "/",
377  mod_name,
378  ".dg",
379  NULL));
380  fp = safe_fopen(dg_name, "w");
382  safe_fclose(fp, dg_name);
383  }
384 
385  debug_off();
386 
387  DB_PUT_MEMORY_RESOURCE(DBR_DG, mod_name, (char*) dg);
388 
395 
396  return true;
397 }
bool graph_consistent_p(graph p)
Definition: graph.c:29
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
int current_shared_obj_table_size(void)
for debug
Definition: genClib.c:654
int gen_allocated_memory(gen_chunk *obj)
re-entry is automatic for this function.
Definition: genClib.c:2690
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
void clean_enclosing_loops(void)
Definition: loop.c:58
int Nbrdo
loop.c
Definition: loop.c:54
statement_mapping loops_mapping_of_statement(statement stat)
Definition: loop.c:155
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
void hash_warn_on_redefinition(void)
these function set the variable should_i_warn_on_redefinition to the value true or false
Definition: hash.c:183
static statement mod_stat
We want to keep track of the current statement inside the recurse.
Definition: impact_check.c:41
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
Definition: ordering.c:172
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
static char * module
Definition: pips.c:74
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
#define RICEDG_PROVIDE_STATISTICS
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
void set_enclosing_loops_map(statement_mapping)
int NbrAllEquals
Definition: ricedg.c:66
int FMComp[18]
Definition: ricedg.c:86
int NbrTestProjFMDi
Definition: ricedg.c:80
int NbrArrayDepInit
Dependence Graph computation for Allen & Kennedy algorithm.
Definition: ricedg.c:64
#define DG_SEMANTICS
Definition: ricedg.c:126
int NbrTestExact
Definition: ricedg.c:68
int NbrFMSystNonAug
Definition: ricedg.c:85
int NbrScalDep
Definition: ricedg.c:72
int NbrIndepFind
Definition: ricedg.c:65
int NbrTestDiCnst
by sc_normalize()
Definition: ricedg.c:78
int NbrProjFMTotal
Definition: ricedg.c:84
int NbrTestProjEq
Definition: ricedg.c:81
int NbrDepInexactEFM
Definition: ricedg.c:71
int NbrTestSimple
Definition: ricedg.c:77
int NbrIndexDep
Definition: ricedg.c:73
void writeresult(char *mod_name)
Definition: ricedg.c:2268
static bool PRINT_RSDG
Definition: ricedg.c:112
int NbrDepCnst
Definition: ricedg.c:67
int NbrTestDiVar
Definition: ricedg.c:83
int NbrDepInexactEq
Definition: ricedg.c:69
int NbrTestProjEqDi
Definition: ricedg.c:79
int NbrDepInexactFM
Definition: ricedg.c:70
int NbrTestProjFM
Definition: ricedg.c:82
void prettyprint_dependence_graph(FILE *, statement, graph)
Print all edges and arcs.
Definition: util.c:177
void ResetLoopCounter(void)
Definition: testdep_util.c:329
char * strdup()
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
A gen_chunk is used to store every object.
Definition: genC.h:58

References chains(), clean_enclosing_loops(), concatenate(), constdep, copy_graph(), current_shared_obj_table_size(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, deptype, dg, DG_SEMANTICS, dg_type, FMComp, fprintf(), gen_allocated_memory(), get_bool_property(), get_current_module_statement(), graph_consistent_p(), hash_warn_on_redefinition(), ifdebug, local_name_to_top_level_entity(), loops_mapping_of_statement(), mod_stat, module, NbrAllEquals, NbrArrayDepInit, NbrDepCnst, NbrDepInexactEFM, NbrDepInexactEq, NbrDepInexactFM, Nbrdo, NbrFMSystNonAug, NbrIndepFind, NbrIndexDep, NbrProjFMTotal, NbrScalDep, NbrTestCnst, NbrTestDiCnst, NbrTestDiVar, NbrTestExact, NbrTestGcd, NbrTestProjEq, NbrTestProjEqDi, NbrTestProjFM, NbrTestProjFMDi, NbrTestSimple, pips_debug, prettyprint_dependence_graph(), PRINT_RSDG, quick_privatize_graph(), rdg_statement(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_precondition_map(), ResetLoopCounter(), RICEDG_PROVIDE_STATISTICS, safe_fclose(), safe_fopen(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_enclosing_loops_map(), set_ordering_to_statement(), set_precondition_map(), strdup(), and writeresult().

Referenced by rice_fast_dependence_graph(), rice_full_dependence_graph(), rice_regions_dependence_graph(), and rice_semantics_dependence_graph().

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

◆ rice_fast_dependence_graph()

bool rice_fast_dependence_graph ( char *  mod_name)
Parameters
mod_nameod_name

Definition at line 139 of file ricedg.c.

139  {
140  dg_type = DG_FAST;
141  return rice_dependence_graph(mod_name);
142 }
static bool rice_dependence_graph(char *)
INTERFACE FUNCTIONS
Definition: ricedg.c:230

References DG_FAST, dg_type, and rice_dependence_graph().

+ Here is the call graph for this function:

◆ rice_full_dependence_graph()

bool rice_full_dependence_graph ( char *  mod_name)
Parameters
mod_nameod_name

Definition at line 144 of file ricedg.c.

144  {
145  dg_type = DG_FULL;
146  return rice_dependence_graph(mod_name);
147 }
#define DG_FULL
Definition: ricedg.c:125

References DG_FULL, dg_type, and rice_dependence_graph().

+ Here is the call graph for this function:

◆ rice_regions_dependence_graph()

bool rice_regions_dependence_graph ( char *  mod_name)
Parameters
mod_nameod_name

Definition at line 154 of file ricedg.c.

154  {
156  "REGION_CHAINS"))
157  pips_user_warning("Region chains not selected - using effects instead\n");
158 
159  dg_type = DG_FAST;
160  return rice_dependence_graph(mod_name);
161 }
#define rule_phase(x)
Definition: makefile.h:244
#define same_string_p(s1, s2)
rule find_rule_by_resource(const char *rname)
This function returns the active rule to produce resource rname.
Definition: pipsmake.c:694

References DG_FAST, dg_type, find_rule_by_resource(), pips_user_warning, rice_dependence_graph(), rule_phase, and same_string_p.

+ Here is the call graph for this function:

◆ rice_semantics_dependence_graph()

bool rice_semantics_dependence_graph ( char *  mod_name)
Parameters
mod_nameod_name

Definition at line 149 of file ricedg.c.

149  {
151  return rice_dependence_graph(mod_name);
152 }

References DG_SEMANTICS, dg_type, and rice_dependence_graph().

+ Here is the call graph for this function:

◆ rice_update_dependence_graph()

static void rice_update_dependence_graph ( statement  stat,
set  region 
)
static

Update of dependence graph.

The update of conflict information is performed for all statements in a loop. This set of statements seems to be defined by "region", while the loop is defined by "stat".

Let v denote a vertex, a an arc, s a statement attached to a vertex and c a conflict, i.e. a pair of effects (e1,e2). Each arc is labelled by a list of statements. Each vertex points to a list of arcs. Each arc points to a list of conflicts. See dg.f.tex and graph.f.tex in Documentation/Newgen for more details.

The procedure is quite complex because:

  • each dependence arc carries a list of conflicts; when a conflict is found non-existent, it has to be removed from the conflict list and the arc may also have to be removed from the arc list associated to the current vertex if its associated conflict list becomes empty; removing an element from a list is a pain because you need to know the previous element and to handle the special case of the list first element removal;
  • the same conflict may appear twice, once as a def-use conflict and once as a use-def conflicts; since dependence testing may be long, the conflict and its symmetric conflict are processed simultaneously; of course, conflict list and dependence arc updates become tricky,
  • especially if the two vertices of the dependence arc are only one: you can have a s1->s1 dependence; thus you might be scanning and updating the very same list of arcs and conflicts twice... but there is a test on pchead and pchead1 to avoid it (pchead and pchead1 points to the heads of the current conflict list and of the conflict list containing the symmetrical conflict); remember, you have no guarantee that s1!=s2 and/or v1=!v2 and/or a1!=a2
  • note that there also is a test about symmetry: def-def and use-use conflicts cannot have symmetric conflicts;
  • because of the use-def/def-use symmetry, a conflict may already have been processed when it is accessed;
  • due to a strange feature in the NewGen declarations, the arcs are called "successors"; variables in the procedure are named with the same convention except... except when they are not; so a so-called "successor" may be either an arc or a vertex (or a statement since each vertex points to a statement)
  • you don't know if dg is a graph or a multigraph; apparently it's a multigraph but there is no clear semantics attaches to the different arcs joining a pair of vertices (Pierre Jouvelot, help!)
  • conflicts are assumed uniquely identifiable by the addresses of their two effects (and by labelling the same pair of vertices - but not the same arc); that calls for tricky bugs if some sharing between effects exists.

The procedure is made of many too many nested loops and tests:

for all vertex v1 in graph dg if statement s1 associated to v1 in region for all arcs a1 outgoing from v1 let v2 be the sink of a1 and s2 the statement associated to v2 if s2 in region for all conflicts c12 carried by a1 if c12 has not yet been refined if c12 may have a symmetric conflict for all arcs a2 outgoing from the sink v2 of a1 if sink(a2) equals v1 for all conflicts c21 if c21 equal c12 halleluia! compute refined dependence information for c12 and possibly c21 possibly update c21 and possibly remove a2 update c12 and possibly remove a1

Good luck for the restructuring! I'm not sure the current procedure might not end up removing as a2 the very same arc a1 it uses to iterate...

This conflict cone has been updated.

ompute this conflit and the opposite one

ooking for the opposite dependence from (s2,e2) to (s1,e1)

Make sure that you do not try to find the very same conflict: eliminate symmetric conflicts like dd's, and, if the KEEP-READ-READ-DEPENDENCE option is on, the unusual uu's.

&& (reference_indices(effect_any_reference(e1))) != NIL)

if (!Finds2s1) pips_internal_error("Expected opposite dependence are not found");

freed in of leaked.

updating DG for the dependence (s1,e1)-->(s2,e2)

updating DG for the dependence (s2,e2)-->(s1,e1)

en_free(cs2s1);

They are in the same conflicts list

This successor has only one conflict that has been killed.

gen_free_list(dg_arc_label_conflicts(dal));

fdebug(4){ prettyprint_dependence_graph(stderr, mod_stat, dg); }

Definition at line 560 of file ricedg.c.

560  {
561  list pv1, ps, pss;
562  list llv, llv1;
563 
564  pips_assert("statement is a loop", statement_loop_p(stat));
565 
566  pips_debug(1, "Begin\n");
567 
568  if(dg_type == DG_FULL) {
569  pips_debug(1, "computing execution contexts\n");
571  }
572 
573  llv = loop_variant_list(stat);
574 
575  ifdebug(6) {
576  fprintf(stderr, "The list of loop variants is :\n");
577  MAP(ENTITY, e, fprintf(stderr," %s", entity_local_name(e)), llv);
578  fprintf(stderr, "\n");
579  }
580 
581  for (pv1 = graph_vertices(dg); pv1 != NIL; pv1 = CDR(pv1)) {
582  vertex v1 = VERTEX(CAR(pv1));
585 
586  if(!set_belong_p(region, (char *)s1))
587  continue;
588 
590 
591  ps = vertex_successors(v1);
592  pss = NIL;
593  while(ps != NIL) {
594  successor su = SUCCESSOR(CAR(ps));
595  vertex v2 = successor_vertex(su);
598  list true_conflicts = NIL;
599  list pc, pchead;
600 
601  if(!set_belong_p(region, (char *)s2)) {
602  pss = ps;
603  ps = CDR(ps);
604  continue;
605  }
606 
607  pc = dg_arc_label_conflicts(dal);
608  pchead = pc;
609  while(pc != NIL) {
610  conflict c = CONFLICT(CAR(pc));
611  effect e1 = conflict_source(c);
612  effect e2 = conflict_sink(c);
613 
614  ifdebug(4) {
615  fprintf(stderr, "dep %02td (", statement_number(s1));
616  print_words(stderr, words_effect(e1));
617  fprintf(stderr, ") --> %02td (", statement_number(s2));
618  print_words(stderr, words_effect(e2));
619  fprintf(stderr, ") \n");
620  }
621 
622  if(conflict_cone(c) != cone_undefined) {
623  /* This conflict cone has been updated. */
624  ifdebug(4) {
625  fprintf(stderr, " \nThis dependence has been computed.\n");
626  }
627  true_conflicts = gen_nconc(true_conflicts, CONS(CONFLICT, c, NIL));
628  } else { /*Compute this conflit and the opposite one */
629  list ps2su = NIL, ps2sus = NIL, pcs2s1 = NIL, pchead1 = NIL;
631  vertex v1bis;
632  statement s1bis;
635  effect e1bis = effect_undefined, e2bis = effect_undefined;
636  list levels = list_undefined;
637  list levelsop = list_undefined;
638  Ptsg gs = SG_UNDEFINED;
639  Ptsg gsop = SG_UNDEFINED;
640 
641  Finds2s1 = false;
642 
643  /*looking for the opposite dependence from (s2,e2) to
644  (s1,e1) */
645 
646  /* Make sure that you do not try to find the very same
647  * conflict: eliminate symmetric conflicts like dd's,
648  * and, if the KEEP-READ-READ-DEPENDENCE option is on,
649  * the unusual uu's.
650  */
651  if(!((s1 == s2) && (action_write_p(effect_action(e1)))
652  && (action_write_p(effect_action(e2)))) && !((s1 == s2)
653  && (action_read_p(effect_action(e1)))
654  && (action_read_p(effect_action(e2)))))
655  /* && (reference_indices(effect_any_reference(e1))) != NIL) */
656  {
657  pips_debug (4, "looking for the opposite dependence");
658 
659  ps2su = vertex_successors(v2);
660  ps2sus = NIL;
661  while(ps2su != NIL && !Finds2s1) {
662  s2su = SUCCESSOR(CAR(ps2su));
663  v1bis = successor_vertex(s2su);
664  s1bis = vertex_to_statement(v1bis);
665  if(s1bis != s1) {
666  ps2sus = ps2su;
667  ps2su = CDR(ps2su);
668  continue;
669  } else {
670  dals2s1 = (dg_arc_label)successor_arc_label(s2su);
671  pcs2s1 = dg_arc_label_conflicts(dals2s1);
672  pchead1 = pcs2s1;
673  while((pcs2s1 != NIL) && !Finds2s1) {
674  cs2s1 = CONFLICT(CAR(pcs2s1));
675  e1bis = conflict_source(cs2s1);
676  e2bis = conflict_sink(cs2s1);
677  if(e1bis == e2 && e2bis == e1) {
678  Finds2s1 = true;
679  continue;
680  } else {
681  pcs2s1 = CDR(pcs2s1);
682  continue;
683  }
684  }
685  if(!Finds2s1) {
686  ps2sus = ps2su;
687  ps2su = CDR(ps2su);
688  }
689  continue;
690  }
691  }
692 
693  /* if (!Finds2s1)
694  pips_internal_error("Expected opposite dependence are not found"); */
695 
696  if(Finds2s1) {
697  ifdebug(4) {
698  fprintf(stderr, "\n dep %02td (", statement_number(s2));
699  print_words(stderr, words_effect(e1bis));
700  fprintf(stderr, ") --> %02td (", statement_number(s1));
701  print_words(stderr, words_effect(e2bis));
702  fprintf(stderr, ") \n");
703  }
704  }
705 
706  }
707 
708  llv1 = gen_copy_seq(llv);
709  /* freed in of leaked. */
710  levels = TestCoupleOfEffects(s1,
711  e1,
712  s2,
713  e2,
714  llv1,
715  &gs,
716  &levelsop,
717  &gsop);
718 
719  /* updating DG for the dependence (s1,e1)-->(s2,e2)*/
720  if(levels == NIL) {
721  debug(4, "", "\nThe dependence (s1,e1)-->(s2,e2)"
722  " must be removed. \n");
723 
726  free_conflict(c);
727  } else {
728  debug(4, "", "\nUpdating the dependence (s1,e1)-->(s2,e2)\n");
729 
730  if(!SG_UNDEFINED_P(gs))
731  conflict_cone(c) = make_cone(levels, gs);
732  else
733  conflict_cone(c) = make_cone(levels, SG_UNDEFINED);
734  true_conflicts = gen_nconc(true_conflicts, CONS(CONFLICT, c, NIL));
735  }
736 
737  if(Finds2s1) {
738  /* updating DG for the dependence (s2,e2)-->(s1,e1)*/
739  if(levelsop == NIL) {
740  debug(4, "", "\nThe dependence (s2,e2)-->(s1,e1)"
741  " must be removed.\n");
742 
745  /*gen_free(cs2s1);*/
746 
747  if(pchead == pchead1)
748  /* They are in the same conflicts list */
749  gen_remove(&pchead, cs2s1);
750  else {
751  gen_remove(&pchead1, cs2s1);
752  if(pchead1 != NIL) {
753  dg_arc_label_conflicts(dals2s1) = pchead1;
754  successor_arc_label_(s2su) = newgen_arc_label(dals2s1);
755  } else {
756  /* This successor has only one
757  conflict that has been killed.*/successor_vertex(s2su)
761  free_successor(s2su);
762  ps2su = CDR(ps2su);
763  if(ps2sus == NIL) {
764  vertex_successors(v2) = ps2su;
765  } else {
766  CDR(ps2sus) = ps2su;
767  }
768  }
769  }
770  }
771 
772  else {
773  debug(4, "", "\nUpdating the dependence (s2,e2)-->(s1,e1)\n");
774 
775  if(!SG_UNDEFINED_P(gsop))
776  conflict_cone(cs2s1) = make_cone(levelsop, gsop);
777  else
778  conflict_cone(cs2s1) = make_cone(levelsop, SG_UNDEFINED);
779  }
780  }
781  }
782  pc = CDR(pc);
783  }
784 
785  /* gen_free_list(dg_arc_label_conflicts(dal));*/
786  if(true_conflicts != NIL) {
787  dg_arc_label_conflicts(dal) = true_conflicts;
788  pss = ps;
789  ps = CDR(ps);
790  } else {
793  free_successor(su);
794  ps = CDR(ps);
795  if(pss == NIL)
796  vertex_successors(v1) = ps;
797  else
798  CDR(pss) = ps;
799  }
800  /*ifdebug(4){ prettyprint_dependence_graph(stderr, mod_stat, dg); }*/
801  }
802  }
803 
804  ifdebug(8) {
805  pips_debug(8,"updated graph\n");
806  print_statement_set(stderr, region);
808  }
809 
811 
812  // No leak
813  gen_free_list(llv);
814 }
void free_conflict(conflict p)
Definition: dg.c:63
cone make_cone(list a1, Ptsg a2)
Definition: dg.c:54
sccflags make_sccflags(scc a1, intptr_t a2, intptr_t a3, intptr_t a4)
Definition: dg.c:222
void free_successor(successor p)
Definition: graph.c:65
dg_arc_label arc_label
Definition: delay.c:63
statement_mapping contexts_mapping_of_nest(statement stat)
contexts.c
Definition: contexts.c:162
struct _newgen_struct_dg_arc_label_ * dg_arc_label
Definition: dg.h:60
#define conflict_sink(x)
Definition: dg.h:167
#define CONFLICT(x)
CONFLICT.
Definition: dg.h:134
#define dg_vertex_label_sccflags(x)
Definition: dg.h:237
#define dg_arc_label_conflicts(x)
Definition: dg.h:201
#define conflict_source(x)
Definition: dg.h:165
#define cone_undefined
Definition: dg.h:104
#define conflict_undefined
Definition: dg.h:140
struct _newgen_struct_dg_vertex_label_ * dg_vertex_label
Definition: dg.h:68
#define dg_arc_label_undefined
Definition: dg.h:179
#define scc_undefined
Definition: dg.h:321
#define conflict_cone(x)
Definition: dg.h:169
list words_effect(effect)
#define effect_undefined
Definition: effects.h:614
#define action_read_p(x)
Definition: effects.h:311
#define successor_vertex(x)
Definition: graph.h:118
#define successor_undefined
Definition: graph.h:92
#define vertex_undefined
Definition: graph.h:128
#define successor_arc_label(x)
Definition: graph.h:116
#define vertex_vertex_label(x)
Definition: graph.h:152
#define vertex_successors(x)
Definition: graph.h:154
#define newgen_arc_label(p)
Definition: graph.h:20
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
#define successor_arc_label_(x)
Definition: graph.h:115
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#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
statement vertex_to_statement(vertex v)
Vertex_to_statement looks for the statement that is pointed to by vertex v.
Definition: util.c:45
bool set_belong_p(const set, const void *)
Definition: set.c:194
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 list TestCoupleOfEffects(statement, effect, statement, effect, list, Ptsg *, list *, Ptsg *)
DEPENDENCE TEST
Definition: ricedg.c:821
static list loop_variant_list(statement)
Definition: ricedg.c:2201
bool Finds2s1
Definition: ricedg.c:97
void set_context_map(statement_mapping)
void reset_context_map(void)
s1
Definition: set.c:247
#define SG_UNDEFINED
Definition: sg-local.h:73
void print_words(FILE *fd, cons *lw)
Definition: print.c:263

References action_read_p, action_write_p, CAR, CDR, cone_undefined, CONFLICT, conflict_cone, conflict_sink, conflict_source, conflict_undefined, CONS, contexts_mapping_of_nest(), debug(), dg, dg_arc_label_conflicts, dg_arc_label_undefined, DG_FULL, dg_type, dg_vertex_label_sccflags, effect_action, effect_undefined, ENTITY, entity_local_name(), Finds2s1, fprintf(), free_conflict(), free_successor(), gen_copy_seq(), gen_free_list(), gen_nconc(), gen_remove(), get_current_module_statement(), graph_vertices, ifdebug, list_undefined, loop_variant_list(), make_cone(), make_sccflags(), MAP, newgen_arc_label, NIL, pips_assert, pips_debug, prettyprint_dependence_graph(), print_statement_set(), print_words(), region, reset_context_map(), s1, scc_undefined, set_belong_p(), set_context_map(), SG_UNDEFINED, SG_UNDEFINED_P, statement_loop_p(), statement_number, SUCCESSOR, successor_arc_label, successor_arc_label_, successor_undefined, successor_vertex, TestCoupleOfEffects(), VERTEX, vertex_successors, vertex_to_statement(), vertex_undefined, vertex_vertex_label, and words_effect().

Referenced by rdg_loop().

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

◆ TestCoupleOfEffects()

static list TestCoupleOfEffects ( statement  s1,
effect  e1,
statement  s2,
effect  e2,
list  llv,
Ptsg gs,
list levelsop,
Ptsg gsop 
)
static

DEPENDENCE TEST

use region information if some is available

This is not correct because loop bounds should be frozen on loop entry; we assume variables used in loop bounds are not too often modified by the loop body

Parameters
s11
e11
s22
e22
llvlv
gss
levelsopevelsop
gsopsop

Definition at line 821 of file ricedg.c.

828  {
830  Psysteme sc1 = SC_UNDEFINED;
831  reference r1 = effect_any_reference( e1 );
832 
834  Psysteme sc2 = SC_UNDEFINED;
836 
837  switch(dg_type) {
838  case DG_FAST: {
839  /* use region information if some is available */
840  sc1 = effect_system(e1);
841  sc2 = effect_system(e2);
842  break;
843  }
844 
845  case DG_FULL: {
846  sc1 = load_statement_context(s1);
847  sc2 = load_statement_context(s2);
848  break;
849  }
850 
851  case DG_SEMANTICS: {
852  /* This is not correct because loop bounds should be frozen on
853  loop entry; we assume variables used in loop bounds are not
854  too often modified by the loop body */
857 
860  break;
861  }
862 
863  default:
864  pips_internal_error("Unknown dependence test %d\n", dg_type);
865  break;
866  }
867 
868  return TestCoupleOfReferences(n1,
869  sc1,
870  s1,
871  e1,
872  r1,
873  n2,
874  sc2,
875  s2,
876  e2,
877  r2,
878  llv,
879  gs,
880  levelsop,
881  gsop);
882 }
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_system(e)
list load_statement_enclosing_loops(statement)
#define transformer_relation(x)
Definition: ri.h:2873
#define predicate_system(x)
Definition: ri.h:2069
list TestCoupleOfReferences(list n1, Psysteme sc1 __attribute__((unused)), statement s1, effect ef1, reference r1, list n2, Psysteme sc2 __attribute__((unused)), statement s2, effect ef2, reference r2, list llv, Ptsg *gs __attribute__((unused)), list *levelsop __attribute__((unused)), Ptsg *gsop __attribute__((unused)))
Definition: ricedg.c:905
Psysteme load_statement_context(statement)
struct Ssysteme * Psysteme
transformer load_statement_precondition(statement)

References DG_FAST, DG_FULL, DG_SEMANTICS, dg_type, effect_any_reference, effect_system, load_statement_context(), load_statement_enclosing_loops(), load_statement_precondition(), pips_internal_error, predicate_system, s1, TestCoupleOfReferences(), and transformer_relation.

Referenced by rice_update_dependence_graph().

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

◆ TestCoupleOfReferences()

list TestCoupleOfReferences ( list  n1,
Psysteme sc1   __attribute__(unused),
statement  s1,
effect  ef1,
reference  r1,
list  n2,
Psysteme sc2   __attribute__(unused),
statement  s2,
effect  ef2,
reference  r2,
list  llv,
Ptsg *gs   __attribute__(unused),
list *levelsop   __attribute__(unused),
Ptsg *gsop   __attribute__(unused) 
)

if (e1 == e2 && !entity_scalar_p(e1) && !entity_scalar_p(e2))

FI: Why have two tests under the condition e1==e2?

FI: this test must be modified to take pointer dereferencing such as p[i] into account, although p as an entity generates atomic references.

If chains.c were updated, we could also check that: gen_length(b1)==gen_length(b2).

A(*) reference appears in the dependence graph

llv is freed here

test the dependence type, constant dependence?

test the dependence type, constant dependence? exact dependence?

the case of scalar variables and equivalenced arrays

calar variable dependence

ase of scalar variable dependence

Definition at line 905 of file ricedg.c.

918  {
919  _int i, cl, dims, ty;
920  list levels = NIL, levels1 = NIL;
921 
922  entity e1 = reference_variable(r1);
923  entity e2 = reference_variable(r2);
924 
925  list b1 = reference_indices(r1);
926  list b2 = reference_indices(r2);
927 
928  type t1 = ultimate_type(entity_type(e1));
929 
930  if(e1 != e2) {
931  ifdebug(1) {
932  fprintf(stderr, "dep %02td (", statement_number(s1));
933  print_words(stderr, words_effect(ef1));
934  fprintf(stderr, ") --> %02td (", statement_number(s2));
935  print_words(stderr, words_effect(ef2));
936  fprintf(stderr, ") \n");
937  }
938  pips_user_warning("Dependence between differents variables: "
939  "%s and %s\nDependence assumed\n",
941  }
942 
943  /* if (e1 == e2 && !entity_scalar_p(e1) && !entity_scalar_p(e2)) */
944  /* FI: Why have two tests under the condition e1==e2? */
945 
946  /* FI: this test must be modified to take pointer dereferencing
947  * such as p[i] into account, although p as an entity generates
948  * atomic references.
949  *
950  * If chains.c were updated, we could also check that:
951  * gen_length(b1)==gen_length(b2).
952  */
953  if(e1 == e2 && !entity_all_locations_p(e1) && !entity_all_locations_p(e2)
955  && gen_length(b1) > 0))) {
956  if(get_bool_property("RICEDG_STATISTICS_ALL_ARRAYS")) {
957  NbrArrayDepInit++;
958  } else {
959  if(b1 != NIL && b2 != NIL)
960  NbrArrayDepInit++;
961  }
962 
963  if(b1 == NIL || b2 == NIL) {
964  /* A(*) reference appears in the dependence graph */
965  cl = FindMaximumCommonLevel(n1, n2);
966 
967  for (i = 1; i <= cl; i++)
968  levels = gen_nconc(levels, CONS(INT, i, NIL));
969 
971  levels = gen_nconc(levels, CONS(INT, cl+1, NIL));
972 
973  if(Finds2s1) {
974  for (i = 1; i <= cl; i++)
975  levels1 = gen_nconc(levels1, CONS(INT, i, NIL));
976 
978  levels1 = gen_nconc(levels1, CONS(INT, cl+1, NIL));
979 
980  *levelsop = levels1;
981  }
982 
983  gen_free_list(llv);
984  } else {
985  /* llv is freed here */
986  levels = TestDependence(n1,
987  sc1,
988  s1,
989  ef1,
990  r1,
991  n2,
992  sc2,
993  s2,
994  ef2,
995  r2,
996  llv,
997  gs,
998  levelsop,
999  gsop);
1000  }
1001 
1002  if(get_bool_property("RICEDG_STATISTICS_ALL_ARRAYS") || (b1 != NIL && b2
1003  != NIL)) {
1004  if(levels != NIL) {
1005  /* test the dependence type, constant dependence? */
1006  dims = gen_length(b1);
1007  ty = dep_type(effect_action(ef1), effect_action(ef2));
1008  deptype[dims][ty]++;
1009  if(is_dep_cnst) {
1010  NbrDepCnst++;
1011  constdep[dims][ty]++;
1012  }
1013  }
1014 
1015  if(*levelsop != NIL) {
1016  /* test the dependence type, constant dependence?
1017  exact dependence? */
1018  dims = gen_length(b1);
1019  ty = dep_type(effect_action(ef2), effect_action(ef1));
1020  deptype[dims][ty]++;
1021  if(is_dep_cnst) {
1022  NbrDepCnst++;
1023  constdep[dims][ty]++;
1024  }
1025  }
1026 
1027  if(levels != NIL || *levelsop != NIL) {
1028  if(is_test_exact)
1029  NbrTestExact++;
1030  else {
1031  if(is_test_inexact_eq) {
1032  if(is_test_inexact_fm)
1033  NbrDepInexactEFM++;
1034  else
1035  NbrDepInexactEq++;
1036  } else
1037  NbrDepInexactFM++;
1038  }
1039  }
1040 
1041  ifdebug(6) {
1042  if(is_test_exact)
1043  fprintf(stderr, "\nThis test is exact! \n");
1044  else if(is_test_inexact_eq)
1045  fprintf(stderr, "\nTest not exact : "
1046  "non-exact elimination of equation!");
1047  else
1048  fprintf(stderr, "\nTest not exact : "
1049  "non-exact elimination of F-M!");
1050  }
1051  }
1052 
1053  return (levels);
1054  } else {
1055  /* the case of scalar variables and equivalenced arrays */
1056 
1057  // llv is no longer used
1058  gen_free_list(llv);
1059 
1060  cl = FindMaximumCommonLevel(n1, n2);
1061 
1062  for (i = 1; i <= cl; i++)
1063  levels = gen_nconc(levels, CONS(INT, i, NIL));
1064 
1065  if(statement_possible_less_p(s1, s2))
1066  levels = gen_nconc(levels, CONS(INT, cl+1, NIL));
1067 
1070  NbrIndexDep++;
1071  else {/*scalar variable dependence */
1072  NbrScalDep++;
1073  ty = dep_type(effect_action(ef1), effect_action(ef2));
1074  deptype[0][ty]++;
1075  }
1076 
1077  if(Finds2s1) {
1078  for (i = 1; i <= cl; i++)
1079  levels1 = gen_nconc(levels1, CONS(INT, i, NIL));
1080 
1081  if(statement_possible_less_p(s2, s1))
1082  levels1 = gen_nconc(levels1, CONS(INT, cl+1, NIL));
1083 
1084  *levelsop = levels1;
1087  NbrIndexDep++;
1088  else {/*case of scalar variable dependence */
1089  NbrScalDep++;
1090  ty = dep_type(effect_action(ef2), effect_action(ef1));
1091  deptype[0][ty]++;
1092  }
1093  }
1094 
1095  return (levels);
1096  }
1097 }
@ INT
Definition: atomic.c:48
size_t gen_length(const list l)
Definition: list.c:150
bool statement_possible_less_p(statement, statement)
Definition: statement.c:306
intptr_t _int
_INT
Definition: newgen_types.h:53
type ultimate_type(type)
Definition: type.c:3466
bool pointer_type_p(type)
Check for scalar pointers.
Definition: type.c:2993
bool entity_atomic_reference_p(entity)
Any reference r such that reference_variable(r)==e accesses all bytes (or bits) allocated to variable...
Definition: variable.c:1163
#define instruction_loop_p(x)
Definition: ri.h:1518
#define entity_type(x)
Definition: ri.h:2792
static list TestDependence(list, Psysteme, statement, effect, reference, list, Psysteme, statement, effect, reference, list, Ptsg *, list *, Ptsg *)
static list TestDependence(list n1, n2, Psysteme sc1, sc2, statement s1, s2, effect ef1,...
Definition: ricedg.c:1151
bool is_dep_cnst
Definition: ricedg.c:95
bool is_test_inexact_eq
Definition: ricedg.c:93
bool is_test_inexact_fm
Definition: ricedg.c:94
bool is_test_exact
or counting the number of F-M complexity less than 16.
Definition: ricedg.c:92
int dep_type(action, action)
int dep_type(action ac1,action ac2) This function test the type of the dependence.
Definition: testdep_util.c:378
int FindMaximumCommonLevel(cons *, cons *)
Definition: testdep_util.c:307
Value b2
Definition: sc_gram.c:105

References b1, b2, CONS, constdep, dep_type(), deptype, effect_action, entity_all_locations_p(), entity_atomic_reference_p(), entity_type, entity_user_name(), FindMaximumCommonLevel(), Finds2s1, fprintf(), gen_free_list(), gen_length(), gen_nconc(), get_bool_property(), ifdebug, instruction_loop_p, INT, is_dep_cnst, is_test_exact, is_test_inexact_eq, is_test_inexact_fm, NbrArrayDepInit, NbrDepCnst, NbrDepInexactEFM, NbrDepInexactEq, NbrDepInexactFM, NbrIndexDep, NbrScalDep, NbrTestExact, NIL, pips_user_warning, pointer_type_p(), print_words(), reference_indices, reference_variable, s1, statement_instruction, statement_number, statement_possible_less_p(), TestDependence(), ultimate_type(), and words_effect().

Referenced by TestCoupleOfEffects().

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

◆ TestDependence()

static list TestDependence ( list  n1,
Psysteme  sc1,
statement  s1,
effect  ef1,
reference  r1,
list  n2,
Psysteme  sc2,
statement  s2,
effect  ef2,
reference  r2,
list  llv,
Ptsg gs,
list levelsop,
Ptsg gsop 
)
static

static list TestDependence(list n1, n2, Psysteme sc1, sc2, statement s1, s2, effect ef1, ef2, reference r1, r2, list llv, list *levelsop, Ptsg *gs,*gsop) input : list n1, n2 : enclosing loops for statements s1 and s2; Psysteme sc1, sc2: current context for each statement; statement s1, s2 : currently analyzed statements; effect ef1, ef2 : effects of each statement upon the current variable; (maybe array regions) reference r1, r2 : current variables references; list llv : loop variant list (variables that vary in loop nests n1 and n2?); list *levelsop : dependence levels from s2 to s1 Ptsg *gs,*gsop : dependence cones from s1 to s2 and from s2 to s1 output : dependence levels from s1 to s2 modifies : levelsop, gsop, gs and returns levels

Comments :

This procedure has been amplified twice. The initial procedure only computed the dependence levels, "levels", for conflict s1->s2. The dependence cone computation was added by Yi-Qing Yang. She later added the computation of the dependence levels and the dependence cone for symetrical conflict, s2 -> s1, because both conflicts share the same dependence system and because a set of tests can be shared.

For her PhD, Yi-Qing Yang also added intermediate tests and instrumentation.

This much too long procedure is made of three parts: 0. The initialization of the dependence system

  1. A set of feasibility tests applied to the dependence system
  2. The computation of levels and cone for s1->s2
  3. The very same computation for s2->s1

Modification :

Automatic variables read in a CATCH block need to be declared volatile as specified by the documentation

Elimination of loop indices from loop variants llv

We use n2 because we take care of variables modified in an iteration only for the second system.

llv is dead, must be freed...

Build the dependence context system from the two initial context systems sc1 and sc2. BC

the context system is not feasible : no dependence. BC

No dep_syst() to deallocate either, FI

Further construction of the dependence system; Constant and GCD tests at the same time.

independence proved

FI: the next statement was commented out...

Consistency Test

find independences (non loop carried dependence, intra-statement).

Such dependences are counted here as independence, but other parallelizer preserve them because they are useful for (assembly) instructon level scheduling

Some kind of arithmetic error, e.g. an integer overflow has occured. Assume dependence to be conservative.

FI: wouldn't it be simpler to enumerate the useful di variables?!?

eliminate non di variables from the basis

Here, the long jump overflow buffer is handled at a lower level!

keep DiIncNonCons variables if their value is unknown or different from zero. Otherwise eliminate them from the dep_syst

FI: I'm lost for this step. My guess DiIncNonCons==VECTEUR_NUL in 99.99 % of all cases...

Compute the levels for dependence arc s1 to s2 and of the opposite dependence arc s2 to s1. Also compute the dependence cones if some level exists (FI: shouldn't it be a loop-carried level?).

For both cases, two systems are allocated, one is used to find the dependence levels, the other one to compute the dependence cone.

For s1->s2, dep_syst is used to compute the levels and dep_syst1 the cone.

For s2->s1, dep_syst_op (op==oppposite) is used to find the dependence levels, and dep_syst2 the dependence cone.

Build the dependence system for the opposite arc s2->s1 before dep_syst is modified

Start processing for arc s1->s2

Make a proper copy of dep_syst before it is destroyed to compute dependence levels. The basis must be in a specific order to check lexico-positivity.

Compute dependence levels for s1->s2

dep_syst is unfeasible or almost empty, and now useless

if (levels == NIL) NbrTestDiVar++; Qui l'a enleve', pourquoi ?

If the cone is not feasible, there are no loop-carried dependences. (FI: the cone is strictly positive then...)

This might not havebeen found by the previous test when computing levels.

But the dependence cone construction does not consider non-loop carried dependences; so we can only remove those levels that are smaller than the number of common levels

print results for arc s1->s2

Start the processing for arc s2->s1

if (*levelsop == NIL) NbrTestDiVar++; Pourquoi?

if the cone is not feasible, there are no loop-carried dependences; this was not found by the previous test when computing levels; but the dependence cone construction does not consider non-loop carried dependences; so we can only remove those levels that are smaller than the number of common levels

the case of "all equals" independence at the same statement

Definition at line 1151 of file ricedg.c.

1164  {
1165  Psysteme dep_syst = SC_UNDEFINED;
1166  Psysteme dep_syst1 = SC_UNDEFINED;
1167  Psysteme dep_syst2 = SC_UNDEFINED;
1168  volatile Psysteme dep_syst_op = SC_UNDEFINED;
1169  Pbase b, coord;
1170  /* Automatic variables read in a CATCH block need to be declared volatile as
1171  * specified by the documentation*/
1172  Pbase volatile tmp_base;
1173 
1174  int l, cl;
1175  list levels;
1176  Pvecteur DiIncNonCons = NULL;
1177 
1178  /* Elimination of loop indices from loop variants llv */
1179  /* We use n2 because we take care of variables modified in
1180  an iteration only for the second system. */
1181  FOREACH(STATEMENT, s, n2) {
1183  gen_remove(&llv,i); /* llv is dead, must be freed... */
1184  }
1185 
1186  ifdebug(6) {
1187  pips_debug(6, "loop variants after removing loop indices :\n");
1188  print_arguments(llv);
1189  }
1190 
1191  /* Build the dependence context system from the two initial context systems
1192  * sc1 and sc2. BC
1193  */
1194  if(!build_and_test_dependence_context(r1, r2, sc1, sc2, &dep_syst, llv, n2)) {
1195  /* the context system is not feasible : no dependence. BC */
1196  /* No dep_syst() to deallocate either, FI */
1197  NbrIndepFind++;
1198  pips_debug(4, "context system not feasible\n");
1199  *levelsop = NIL;
1200 
1201  gen_free_list(llv);
1202  return NIL;
1203  }
1204 
1205  /* Further construction of the dependence system; Constant and GCD tests
1206  * at the same time.
1207  */
1208 
1209  // FI: why is dep_syst only weekly consistent here?
1210  assert(sc_weak_consistent_p(dep_syst));
1211 
1212  if(gcd_and_constant_dependence_test(r1, r2, llv, n2, &dep_syst)) {
1213  /* independence proved */
1214  /* FI: the next statement was commented out... */
1215  sc_rm(dep_syst);
1216  NbrIndepFind++;
1217  *levelsop = NIL;
1218 
1219  gen_free_list(llv);
1220  return NIL;
1221  }
1222 
1223  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1224 
1225  gen_free_list(llv);
1226 
1227  dependence_system_add_lci_and_di(&dep_syst, n1, &DiIncNonCons);
1228 
1229  ifdebug(6) {
1230  fprintf(stderr, "\ninitial system is:\n");
1231  sc_syst_debug(dep_syst);
1232  }
1233 
1234  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1235 
1236  /* Consistency Test */
1237  if(sc_empty_p(dep_syst = sc_normalize(dep_syst))) {
1238  sc_rm(dep_syst);
1239  NbrTestSimple++;
1240  NbrIndepFind++;
1241  pips_debug(4, "initial normalized system not feasible\n");
1242  *levelsop = NIL;
1243 
1244  return (NIL);
1245  }
1246 
1247  cl = FindMaximumCommonLevel(n1, n2);
1248 
1249  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1250 
1251  if(TestDiCnst(dep_syst, cl, s1, ef1, s2, ef2) == true) {
1252  /* find independences (non loop carried dependence, intra-statement).*/
1253  /* Such dependences are counted here as independence, but other
1254  * parallelizer preserve them because they are useful for
1255  * (assembly) instructon level scheduling
1256  */
1257  NbrTestDiCnst++;
1258  NbrIndepFind++;
1259  pips_debug(4,"\nTestDiCnst succeeded!\n");
1260  *levelsop = NIL;
1261 
1262  return (NIL);
1263  }
1264 
1265  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1266 
1267  is_test_exact = true;
1268  is_test_inexact_eq = false;
1269  is_test_inexact_fm = false;
1270  is_dep_cnst = false;
1271 
1272  tmp_base = base_dup(dep_syst->base);
1273 
1275  /* Some kind of arithmetic error, e.g. an integer overflow
1276  * has occured. Assume dependence to be conservative.
1277  */
1278  Pbase dep_syst_base = BASE_UNDEFINED;
1279 
1280  /* FI: wouldn't it be simpler to enumerate the useful di
1281  * variables?!?
1282  */
1283  /* eliminate non di variables from the basis */
1284  for (coord = tmp_base; !VECTEUR_NUL_P(coord); coord = coord->succ) {
1285  Variable v = vecteur_var(coord);
1286  l = DiVarLevel((entity)v);
1287  if(l <= 0 || l > cl)
1288  base_add_variable(dep_syst_base, v);
1289  }
1290  dep_syst = sc_rn(dep_syst_base);
1291  } TRY {
1292  if(sc_proj_optim_on_di_ofl(cl, &dep_syst) == false) {
1293  pips_debug(4,
1294  "projected system by sc_proj_optim_on_di() is not feasible\n");
1295  sc_rm(dep_syst);
1296  NbrIndepFind++;
1297  *levelsop = NIL;
1298 
1300  base_rm(tmp_base);
1301  return (NIL);
1302  } else
1304  }
1305 
1306  ifdebug(6) {
1307  fprintf(stderr, "projected system is:\n");
1308  sc_syst_debug(dep_syst);
1309  }
1310 
1311  pips_assert("The dependence system is consistent", sc_consistent_p(dep_syst));
1312 
1313  base_rm(tmp_base); // FI: delayed to help with debugging
1314 
1315  if(!sc_faisabilite_optim(dep_syst)) {
1316  /* Here, the long jump overflow buffer is handled at a lower level! */pips_debug(4, "projected system not feasible\n");
1317  NbrIndepFind++;
1318  *levelsop = NIL;
1319 
1320  return (NIL);
1321  }
1322 
1323  ifdebug(6) {
1324  fprintf(stderr, "normalised projected system is:\n");
1325  sc_syst_debug(dep_syst);
1326  fprintf(stderr, "The list of DiIncNonCons is :\n");
1327  vect_debug(DiIncNonCons);
1328  }
1329 
1330  /* keep DiIncNonCons variables if their value is unknown or different
1331  * from zero. Otherwise eliminate them from the dep_syst
1332  *
1333  * FI: I'm lost for this step. My guess DiIncNonCons==VECTEUR_NUL
1334  * in 99.99 % of all cases...
1335  */
1336  if(dep_syst != NULL) {
1337  while(DiIncNonCons != NULL) {
1338  Variable di;
1339  Value val;
1340 
1341  di = DiIncNonCons->var;
1342  if(sc_value_of_variable(dep_syst, di, &val) == true)
1343  if(value_notzero_p(val)) {
1344  sc_elim_var(dep_syst, di);
1345  }
1346  DiIncNonCons = DiIncNonCons->succ;
1347  }
1348  }
1349 
1350  ifdebug(4) {
1351  fprintf(stderr,
1352  "normalised projected system after DiIncNonCons elimination is:\n");
1353  sc_syst_debug(dep_syst);
1354  }
1355 
1356  /* Compute the levels for dependence arc s1 to s2 and of the opposite
1357  * dependence arc s2 to s1. Also compute the dependence cones if some
1358  * level exists (FI: shouldn't it be a loop-carried level?).
1359  *
1360  * For both cases, two systems are allocated, one is used to find the
1361  * dependence levels, the other one to compute the dependence cone.
1362  *
1363  * For s1->s2, dep_syst is used to compute the levels and dep_syst1
1364  * the cone.
1365  *
1366  * For s2->s1, dep_syst_op (op==oppposite) is used to find the dependence
1367  * levels, and dep_syst2 the dependence cone.
1368  */
1369 
1370  /* Build the dependence system for the opposite arc s2->s1
1371  * before dep_syst is modified
1372  */
1373 
1374  *levelsop = NIL;
1375  if(Finds2s1)
1376  dep_syst_op = sc_invers(sc_dup(dep_syst));
1377 
1378  /* Start processing for arc s1->s2 */
1379 
1380  ifdebug(4) {
1381  debug(4, "", "\nComputes the levels and DC for dep: (s1,e1)->(s2,e2)\n");
1382  fprintf(stderr, "\nThe distance system for dep is:\n");
1383  sc_syst_debug(dep_syst);
1384  }
1385 
1386  /* Make a proper copy of dep_syst before it is destroyed to compute
1387  * dependence levels. The basis must be in a specific order to check
1388  * lexico-positivity.
1389  */
1390  dep_syst1 = sc_dup(dep_syst);
1391  b = MakeDibaseinorder(cl);
1392  base_rm(dep_syst1->base);
1393  dep_syst1->base = b;
1394  dep_syst1->dimension = cl;
1395 
1396  if(dep_syst1->dimension == dep_syst1->nb_eq)
1397  is_dep_cnst = true;
1398 
1399  /* Compute dependence levels for s1->s2 */
1400  levels = TestDiVariables(dep_syst, cl, s1, ef1, s2, ef2);
1401  /* dep_syst is unfeasible or almost empty, and now useless */
1402  sc_rm(dep_syst);
1403 
1404  /* if (levels == NIL) NbrTestDiVar++; Qui l'a enleve', pourquoi ? */
1405 
1406  if(levels != NIL) {
1407 
1408  *gs = dependence_cone_positive(dep_syst1);
1409 
1410  /* If the cone is not feasible, there are no loop-carried dependences.
1411  * (FI: the cone is strictly positive then...)
1412  *
1413  * This might not havebeen found by the previous test when computing
1414  * levels.
1415  *
1416  * But the dependence cone construction does not consider non-loop
1417  * carried dependences; so we can only remove those levels that are
1418  * smaller than the number of common levels
1419  */
1420  if(sg_empty(*gs)) {
1421  list l_tmp = levels;
1422  bool ok = false;
1423 
1424  pips_debug(5, "dependence cone not feasible\n");
1425  MAP(INT, ll, {if (ll == cl+1) ok = true;}, l_tmp);
1426 
1427  if(ok) {
1428  pips_debug(5, "innermost level found and kept\n");
1429  levels = CONS(INT, cl+1, NIL);
1430  } else {
1431  pips_debug(5, "innermost level not found, no dependences");
1432  levels = NIL;
1433  }
1434  gen_free_list(l_tmp);
1435  sg_rm(*gs);
1436  *gs = SG_UNDEFINED;
1437  }
1438  }
1439  sc_rm(dep_syst1);
1440 
1441  /* print results for arc s1->s2 */
1442 
1443  ifdebug(4) {
1444  fprintf(stderr, "\nThe levels for dep (s1,s2) are:");
1445  MAP(INT, pl,
1446  {
1447  fprintf(stderr, " %d", pl);
1448  }, levels);
1449 
1450  if(!SG_UNDEFINED_P(*gs)) {
1451  fprintf(stderr, "\nThe lexico-positive dependence cone for"
1452  " dep (s1,s2) :\n");
1453  print_dependence_cone(stderr, *gs, b);
1454  } else
1455  fprintf(stderr, "\nLexico-positive dependence cone"
1456  " doesn't exist for dep (s1,s2).\n");
1457  }
1458 
1459  /* Start the processing for arc s2->s1 */
1460 
1461  if(Finds2s1) {
1462 
1463  pips_debug(4,"Computes the levels and DC for dep_op: (s2,e2)->(s1,e1)\n");
1464  ifdebug(4) {
1465  fprintf(stderr, "\nThe invers distance system for dep_op is:\n");
1466  sc_syst_debug(dep_syst_op);
1467  }
1468 
1469  dep_syst2 = sc_dup(dep_syst_op);
1470  b = MakeDibaseinorder(cl);
1471  base_rm(dep_syst2->base);
1472  dep_syst2->base = b;
1473  dep_syst2->dimension = cl;
1474 
1475  *levelsop = TestDiVariables(dep_syst_op, cl, s2, ef2, s1, ef1);
1476  sc_rm(dep_syst_op);
1477  if(*levelsop != NIL) {
1478  /* if (*levelsop == NIL) NbrTestDiVar++; Pourquoi? */
1479  *gsop = dependence_cone_positive(dep_syst2);
1480  sc_rm(dep_syst2);
1481 
1482  /* if the cone is not feasible, there are no loop-carried dependences;
1483  * this was not found by the previous test when computing levels;
1484  * but the dependence cone construction does not consider non-loop
1485  * carried dependences; so we can only remove those levels that are
1486  * smaller than the number of common levels
1487  */
1488  if(sg_empty(*gsop)) {
1489  list l_tmp = *levelsop;
1490  bool ok = false;
1491 
1492  MAP(INT, ll, {if (ll == cl+1) ok = true;}, l_tmp);
1493 
1494  if(ok) {
1495  *levelsop = CONS(INT, cl+1, NIL);
1496  } else {
1497  *levelsop = NIL;
1498  }
1499  gen_free_list(l_tmp);
1500  sg_rm(*gsop);
1501  *gsop = SG_UNDEFINED;
1502  }
1503  }
1504 
1505  ifdebug(4) {
1506  fprintf(stderr, "\nThe levels for dep_op (s2,s1) is:");
1507  MAP(INT, pl,
1508  {
1509  fprintf(stderr, " %d", pl);
1510  }, *levelsop);
1511 
1512  if(!SG_UNDEFINED_P(*gsop)) {
1513  fprintf(stderr, "\nThe lexico-positive Dependence "
1514  "cone for dep_op (s2,s1):\n");
1515  print_dependence_cone(stderr, *gsop, b);
1516  } else
1517  fprintf(stderr, "\nLexico-positive dependence cone "
1518  "does not exist for dep_op (s2,s1).\n");
1519 
1520  }
1521  }
1522 
1523  if(levels == NIL && *levelsop == NIL) {
1524  NbrTestDiVar++;
1525  NbrIndepFind++;
1526  if(s1 == s2) {
1527  /* the case of "all equals" independence at the same statement*/
1528  NbrAllEquals++;
1529  }
1530 
1531  return (NIL);
1532  }
1533 
1534  return (levels);
1535 }
void vect_debug(Pvecteur v)
constraint.c
Definition: constraint.c:43
void print_arguments(list args)
Definition: naming.c:228
#define assert(ex)
Definition: newgen_assert.h:41
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
static list TestDiVariables(Psysteme, int, statement, effect, statement, effect)
static void dependence_system_add_lci_and_di(Psysteme *, list, Pvecteur *)
static void dependence_system_add_lci_and_di(Psysteme *psc_dep, list s1_enc_loops,...
Definition: ricedg.c:1883
static bool build_and_test_dependence_context(reference, reference, Psysteme, Psysteme, Psysteme *, list, list)
static bool build_and_test_dependence_context(reference r1, r2, Psystem sc1, sc2, *psc_dep,...
Definition: ricedg.c:1580
static bool TestDiCnst(Psysteme, int, statement, effect, statement, effect)
static Ptsg dependence_cone_positive(Psysteme)
Ptsg dependence_cone_positive(Psysteme dept_syst)
Definition: ricedg.c:2096
static bool gcd_and_constant_dependence_test(reference, reference, list, list, Psysteme *)
static bool gcd_and_constant_dependence_test(references r1, r2, list llv, s2_enc_loops,...
Definition: ricedg.c:1761
Psysteme sc_invers(Psysteme)
Psysteme sc_invers(Psysteme ps): calcul un systeme des contraintes qui est l'invers du systeme initia...
Pbase MakeDibaseinorder(int)
Pbase MakeDibaseinorder(int n) make a base of D#1 ...
Definition: testdep_util.c:296
int sc_proj_optim_on_di_ofl(int, Psysteme *)
int sc_proj_optim_on_di_ofl(cl, sc)
Definition: testdep_util.c:415
bool sc_faisabilite_optim(Psysteme)
bool sc_faisabilite_optim (Psysteme sc) :
Definition: testdep_util.c:484
int DiVarLevel(entity)
this function returns the nesting level of a given di variable e.
Definition: testdep_util.c:185
bool sc_weak_consistent_p(Psysteme sc)
check that sc is well defined, that the numbers of equalities and inequalities are consistent with th...
Definition: sc.c:362
Psysteme sc_rn(Pbase b)
Psysteme sc_rn(Pbase b): build a Psysteme without constraints to define R^n, where n is b's dimension...
Definition: sc_alloc.c:336
bool sc_value_of_variable(Psysteme ps, Variable var, Value *pval)
bool sc_value_for_variable(Psysteme ps, Variable var, Value *pval): examine les egalites du systeme p...
Definition: sc_eval.c:70
Psysteme sc_elim_var(Psysteme sc, Variable v)
package sur les systemes de contraintes sc
Definition: sc_unaires.c:49
#define sg_empty(sg)
Test for an empty generating system, which corresponds to an empty set.
Definition: sg-local.h:108
static bool ok
int nb_eq
Definition: sc-local.h:72
Variable var
Definition: vecteur-local.h:90
#define base_rm(b)

References assert, Ssysteme::base, base_add_variable(), base_dup(), base_rm, BASE_UNDEFINED, build_and_test_dependence_context(), CATCH, CONS, debug(), dependence_cone_positive(), dependence_system_add_lci_and_di(), Ssysteme::dimension, DiVarLevel(), FindMaximumCommonLevel(), Finds2s1, FOREACH, fprintf(), gcd_and_constant_dependence_test(), gen_free_list(), gen_remove(), ifdebug, INT, is_dep_cnst, is_test_exact, is_test_inexact_eq, is_test_inexact_fm, loop_index, MakeDibaseinorder(), MAP, Ssysteme::nb_eq, NbrAllEquals, NbrIndepFind, NbrTestDiCnst, NbrTestDiVar, NbrTestSimple, NIL, ok, overflow_error, pips_assert, pips_debug, pl, print_arguments(), print_dependence_cone(), s1, sc_consistent_p(), sc_dup(), sc_elim_var(), sc_empty_p(), sc_faisabilite_optim(), sc_invers(), sc_normalize(), sc_proj_optim_on_di_ofl(), sc_rm(), sc_rn(), sc_syst_debug(), sc_value_of_variable(), sc_weak_consistent_p(), sg_empty, sg_rm(), SG_UNDEFINED, SG_UNDEFINED_P, STATEMENT, statement_loop(), Svecteur::succ, TestDiCnst(), TestDiVariables(), TRY, UNCATCH, value_notzero_p, Svecteur::var, vect_debug(), VECTEUR_NUL_P, and vecteur_var.

Referenced by TestCoupleOfReferences().

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

◆ TestDiCnst() [1/2]

static bool TestDiCnst ( Psysteme  ps,
int  cl,
statement  s1,
effect ef1   __attribute__(unused),
statement  s2,
effect ef2   __attribute__(unused) 
)
static

this function detects intra-statement, non loop carried dependence ( Di=(0,0,...0) and s1 = s2).

case of di zero

Definition at line 2231 of file ricedg.c.

2236  {
2237  int l;
2238 
2239  for (l = 1; l <= cl; l++) {
2240  Variable di = (Variable)GetDiVar(l);
2241  Psysteme pss;
2242  Value val;
2243  bool success_p = true;
2244 
2245  pss = sc_dup(ps);
2246  success_p = sc_value_of_variable(pss, di, &val);
2247  sc_rm(pss);
2248 
2249  if(success_p) {
2250  if(value_notzero_p(val)) {
2251  return (false);
2252  }
2253  } else {
2254  return (false);
2255  }
2256  }
2257 
2258  /* case of di zero */
2259  if(s1 == s2) {
2260  NbrAllEquals++;
2261  return (true);
2262  } else
2263  return (false);
2264 }

References GetDiVar(), NbrAllEquals, s1, sc_dup(), sc_rm(), sc_value_of_variable(), and value_notzero_p.

+ Here is the call graph for this function:

◆ TestDiCnst() [2/2]

static bool TestDiCnst ( Psysteme  ,
int  ,
statement  ,
effect  ,
statement  ,
effect   
)
static

Referenced by TestDependence().

+ Here is the caller graph for this function:

◆ TestDiVariables() [1/2]

static list TestDiVariables ( Psysteme  ps,
int  cl,
statement  s1,
effect ef1   __attribute__(unused),
statement  s2,
effect ef2   __attribute__(unused) 
)
static

FI: Keep a consistent interface in memory allocation

Psysteme pss = (l==cl) ? ps : sc_dup(ps);

This function does not test feasibility and does not deallocate ps

If there is no dependence at a common loop level: since the system is feasible, it can be a dependence at the innermost level (inside the common loop nest).

WARNING:

If the source and target statements are identical, we do not add the innermost level because the parallelization phase (rice) does not appreciate. In order to be correct, we should add this level 1) because the statement may be a call to an external routine, in which case we cannot be sure that all the writes are performed before the reads and 2) even in the case of a single assignement, the generated code must preserve the order of the write and read memory operations. BC.

Definition at line 1997 of file ricedg.c.

2002  {
2003  list levels = NIL;
2004  _int l;
2005  bool all_level_founds = false;
2006 
2007  pips_debug(7, "maximum common level (cl): %d\n", cl);
2008 
2009  for (l = 1; !all_level_founds && l <= cl; l++) {
2010  Variable di = (Variable)GetDiVar(l);
2011  Value min, max;
2012  int IsPositif, IsNegatif, IsNull, NotPositif;
2013  /* FI: Keep a consistent interface in memory allocation */
2014  /* Psysteme pss = (l==cl) ? ps : sc_dup(ps); */
2015  Psysteme pss = sc_dup(ps);
2016 
2017  ifdebug(7) {
2018  pips_debug(7, "current level: %td, variable: %s\n",
2019  l, entity_local_name((entity) di));
2020  }
2021 
2022  if(sc_minmax_of_variable_optim(pss, di, &min, &max) == false) {
2023  pips_debug(7,"sc_minmax_of_variable_optim: non feasible system\n");
2024  all_level_founds = true;
2025  break;
2026  }
2027 
2028  IsPositif = value_pos_p(min);
2029  IsNegatif = value_neg_p(max);
2030  IsNull = value_zero_p(min) && value_zero_p(max);
2031  NotPositif = value_zero_p(max) && value_neg_p(min);
2032 
2033  ifdebug(7) {
2034  pips_debug(7, "values: ");
2035  fprint_string_Value(stderr, "min = ", min);
2036  fprint_string_Value(stderr, " max = ", max);
2037  fprintf(stderr,
2038  " ==> %s\n",
2039  IsPositif ? "positive" : (IsNegatif ? "negative"
2040  : (IsNull ? "null"
2041  : "undefined")));
2042  }
2043 
2044  if(IsNegatif) {
2045  all_level_founds = true;
2046  break;
2047  }
2048 
2049  if(IsPositif) {
2050  pips_debug(7, "adding level %td\n", l);
2051  levels = gen_nconc(levels, CONS(INT, l, NIL));
2052  all_level_founds = true;
2053  break;
2054  }
2055 
2056  if(!IsNull && !NotPositif) {
2057  pips_debug(7, "adding level %td\n", l);
2058  levels = gen_nconc(levels, CONS(INT, l, NIL));
2059  }
2060 
2061  if(!all_level_founds && l <= cl - 1) {
2062  pips_debug(7, "forcing variable %s to 0 (l < cl)\n",
2063  entity_local_name((entity) di));
2064  /* This function does not test feasibility and does not
2065  * deallocate ps
2066  */
2067  sc_force_variable_to_zero(ps, di);
2068  }
2069  }
2070 
2071  /* If there is no dependence at a common loop level: since the system
2072  * is feasible, it can be a dependence at the innermost level (inside the
2073  * common loop nest).
2074  *
2075  * WARNING:
2076  *
2077  * If the source and target statements are identical, we do not
2078  * add the innermost level because the parallelization phase
2079  * (rice) does not appreciate. In order to be correct, we should
2080  * add this level 1) because the statement may be a call to an
2081  * external routine, in which case we cannot be sure that all the
2082  * writes are performed before the reads and 2) even in the case
2083  * of a single assignement, the generated code must preserve the
2084  * order of the write and read memory operations. BC.
2085  */
2086  if(!all_level_founds && s1 != s2 && statement_possible_less_p(s1, s2)) {
2087  pips_debug(7, "adding innermost level %td\n", l);
2088  levels = gen_nconc(levels, CONS(INT, l, NIL));
2089  }
2090 
2091  return (levels);
2092 }
#define value_pos_p(val)
#define value_zero_p(val)
#define value_neg_p(val)
void fprint_string_Value(FILE *, char *, Value)
Definition: io.c:47
#define min(a, b)
#define max(a, b)
bool sc_minmax_of_variable_optim(Psysteme volatile, Variable, Value *, Value *)
void sc_minmax_of_variable_optim(Psysteme ps, Variable var, Value *pmin, *pmax): examine un systeme p...
Definition: testdep_util.c:975
void sc_force_variable_to_zero(Psysteme ps, Variable var)
void sc_force_variable_to_zero(Psysteme ps, Variable var): force la variable var a prendre la valeur ...
Definition: sc_eval.c:251

References CONS, entity_local_name(), fprint_string_Value(), fprintf(), gen_nconc(), GetDiVar(), ifdebug, INT, max, min, NIL, pips_debug, s1, sc_dup(), sc_force_variable_to_zero(), sc_minmax_of_variable_optim(), statement_possible_less_p(), value_neg_p, value_pos_p, and value_zero_p.

+ Here is the call graph for this function:

◆ TestDiVariables() [2/2]

static list TestDiVariables ( Psysteme  ,
int  ,
statement  ,
effect  ,
statement  ,
effect   
)
static

Referenced by TestDependence().

+ Here is the caller graph for this function:

◆ writeresult()

void writeresult ( char *  mod_name)

to avoid warnings from compiler

Parameters
mod_nameod_name

Definition at line 2268 of file ricedg.c.

2268  {
2269  FILE *fp;
2270  string filename;
2271  int i, j;
2272 
2273  switch(dg_type) {
2274  case DG_FAST:
2275  filename = "resulttestfast";
2276  break;
2277  case DG_FULL:
2278  filename = "resulttestfull";
2279  break;
2280  case DG_SEMANTICS:
2281  filename = "resulttestseman";
2282  break;
2283  default:
2284  pips_internal_error("erroneous dg type.");
2285  return; /* to avoid warnings from compiler */
2286  }
2287 
2289  "/",
2290  mod_name,
2291  ".",
2292  filename,
2293  0));
2294 
2295  fp = safe_fopen(filename, "w");
2296 
2297  fprintf(fp, "%s", mod_name);
2298  fprintf(fp,
2299  " %d %d %d %d %d %d %d %d %d %d",
2301  NbrIndepFind,
2302  NbrAllEquals,
2303  NbrDepCnst,
2304  NbrTestExact,
2308  NbrScalDep,
2309  NbrIndexDep);
2310  for (i = 0; i <= 4; i++)
2311  for (j = 0; j <= 2; j++)
2312  fprintf(fp, " %d", deptype[i][j]);
2313  for (i = 0; i <= 4; i++)
2314  for (j = 0; j <= 2; j++)
2315  fprintf(fp, " %d", constdep[i][j]);
2316  fprintf(fp,
2317  " %d %d %d %d %d %d %d %d %d %d %d",
2318  NbrTestCnst,
2319  NbrTestGcd,
2320  NbrTestSimple,
2321  NbrTestDiCnst,
2324  NbrTestProjEq,
2325  NbrTestProjFM,
2326  NbrTestDiVar,
2328  NbrFMSystNonAug);
2329  for (i = 0; i < 18; i++)
2330  fprintf(fp, " %d", FMComp[i]);
2331  fprintf(fp, "\n");
2332 
2333  safe_fclose(fp, filename);
2334  free(filename);
2335 }
void free(void *)

References concatenate(), constdep, db_get_current_workspace_directory(), deptype, DG_FAST, DG_FULL, DG_SEMANTICS, dg_type, FMComp, fprintf(), free(), NbrAllEquals, NbrArrayDepInit, NbrDepCnst, NbrDepInexactEFM, NbrDepInexactEq, NbrDepInexactFM, NbrFMSystNonAug, NbrIndepFind, NbrIndexDep, NbrProjFMTotal, NbrScalDep, NbrTestCnst, NbrTestDiCnst, NbrTestDiVar, NbrTestExact, NbrTestGcd, NbrTestProjEq, NbrTestProjEqDi, NbrTestProjFM, NbrTestProjFMDi, NbrTestSimple, pips_internal_error, safe_fclose(), safe_fopen(), and strdup().

Referenced by rice_dependence_graph().

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

Variable Documentation

◆ constdep

◆ deptype

◆ dg

graph dg
static

to map statements to enclosing loops

DEFINE_CURRENT_MAPPING(loops, list) now defined in ri-util, BA, September 1993 the dependence graph being updated

Definition at line 110 of file ricedg.c.

Referenced by compute_dg_on_statement_from_chains(), compute_dg_on_statement_from_chains_in_place(), rice_dependence_graph(), and rice_update_dependence_graph().

◆ dg_type

◆ Finds2s1

bool Finds2s1

Definition at line 97 of file ricedg.c.

Referenced by rice_update_dependence_graph(), TestCoupleOfReferences(), and TestDependence().

◆ FMComp

int FMComp[18]

Definition at line 86 of file ricedg.c.

Referenced by combiner_ofl_with_test(), rice_dependence_graph(), and writeresult().

◆ is_dep_cnst

bool is_dep_cnst = false

Definition at line 95 of file ricedg.c.

Referenced by TestCoupleOfReferences(), and TestDependence().

◆ is_test_Di

bool is_test_Di

◆ is_test_exact

bool is_test_exact = true

or counting the number of F-M complexity less than 16.

The complexity of one projection by F-M is multiply of the nbr. of inequations positive and the nbr. of inequations negatives who containe the variable eliminated.The last elem of the array (ie FMComp[17]) is used to count cases with complexity over 16

Definition at line 92 of file ricedg.c.

Referenced by combiner_ofl_with_test(), sc_projection_optim_along_vecteur_ofl(), TestCoupleOfReferences(), and TestDependence().

◆ is_test_inexact_eq

bool is_test_inexact_eq = false

◆ is_test_inexact_fm

bool is_test_inexact_fm = false

Definition at line 94 of file ricedg.c.

Referenced by combiner_ofl_with_test(), TestCoupleOfReferences(), and TestDependence().

◆ NbrAllEquals

int NbrAllEquals = 0

Definition at line 66 of file ricedg.c.

Referenced by rice_dependence_graph(), TestDependence(), TestDiCnst(), and writeresult().

◆ NbrArrayDepInit

int NbrArrayDepInit = 0

Dependence Graph computation for Allen & Kennedy algorithm.

he variables for the statistics of test of dependence and parallelization

Remi Triolet, Yi-qing Yang

Modifications:

  • new option to use semantics analysis results (Francois Irigoin, 12 April 1991)
  • compute the dependence cone, the statistics. (Yi-Qing, August 1991)
  • updated using DEFINE_CURRENT_MAPPING, BA, September 3, 1993
  • dg_type introduced to replace dg_fast and dg_semantics; it is more general. (BC, August 1995).
  • TestDependence split into different procedures for more readability. (BC, August 1995).
  • creation of quick_privatize.c and prettyprint.c to reduce the size of ricedg.c (FI, Oct. 1995)

Notes:

  • Many values seem to be assigned to StatementToContext and never be freed; local variables he variables for the statistics of test of dependence and parallelization they should not be global ? FC.

Definition at line 64 of file ricedg.c.

Referenced by rice_dependence_graph(), TestCoupleOfReferences(), and writeresult().

◆ NbrDepCnst

int NbrDepCnst = 0

Definition at line 67 of file ricedg.c.

Referenced by rice_dependence_graph(), TestCoupleOfReferences(), and writeresult().

◆ NbrDepInexactEFM

int NbrDepInexactEFM = 0

Definition at line 71 of file ricedg.c.

Referenced by rice_dependence_graph(), TestCoupleOfReferences(), and writeresult().

◆ NbrDepInexactEq

int NbrDepInexactEq = 0

Definition at line 69 of file ricedg.c.

Referenced by rice_dependence_graph(), TestCoupleOfReferences(), and writeresult().

◆ NbrDepInexactFM

int NbrDepInexactFM = 0

Definition at line 70 of file ricedg.c.

Referenced by rice_dependence_graph(), TestCoupleOfReferences(), and writeresult().

◆ NbrFMSystNonAug

int NbrFMSystNonAug = 0

◆ NbrIndepFind

int NbrIndepFind = 0

Definition at line 65 of file ricedg.c.

Referenced by rice_dependence_graph(), TestDependence(), and writeresult().

◆ NbrIndexDep

int NbrIndexDep = 0

Definition at line 73 of file ricedg.c.

Referenced by rice_dependence_graph(), TestCoupleOfReferences(), and writeresult().

◆ NbrProjFMTotal

int NbrProjFMTotal = 0

◆ NbrScalDep

int NbrScalDep = 0

Definition at line 72 of file ricedg.c.

Referenced by rice_dependence_graph(), TestCoupleOfReferences(), and writeresult().

◆ NbrTestCnst

int NbrTestCnst = 0

Definition at line 75 of file ricedg.c.

Referenced by gcd_and_constant_dependence_test(), rice_dependence_graph(), and writeresult().

◆ NbrTestDiCnst

int NbrTestDiCnst = 0

by sc_normalize()

Definition at line 78 of file ricedg.c.

Referenced by rice_dependence_graph(), TestDependence(), and writeresult().

◆ NbrTestDiVar

int NbrTestDiVar = 0

Definition at line 83 of file ricedg.c.

Referenced by rice_dependence_graph(), TestDependence(), and writeresult().

◆ NbrTestExact

int NbrTestExact = 0

Definition at line 68 of file ricedg.c.

Referenced by rice_dependence_graph(), TestCoupleOfReferences(), and writeresult().

◆ NbrTestGcd

int NbrTestGcd = 0

Definition at line 76 of file ricedg.c.

Referenced by gcd_and_constant_dependence_test(), rice_dependence_graph(), and writeresult().

◆ NbrTestProjEq

int NbrTestProjEq = 0

◆ NbrTestProjEqDi

int NbrTestProjEqDi = 0

◆ NbrTestProjFM

int NbrTestProjFM = 0

◆ NbrTestProjFMDi

int NbrTestProjFMDi = 0

◆ NbrTestSimple

int NbrTestSimple = 0

Definition at line 77 of file ricedg.c.

Referenced by rice_dependence_graph(), TestDependence(), and writeresult().

◆ PRINT_RSDG

bool PRINT_RSDG = false
static

Definition at line 112 of file ricedg.c.

Referenced by rice_dependence_graph().