Candl 0.6.0
Functions
dependence.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <candl/candl.h>
#include <assert.h>
Include dependency graph for dependence.c:

Functions

void candl_dependence_print_structure (FILE *file, candl_dependence_p dependence, int level)
void candl_dependence_print (FILE *file, candl_dependence_p dependence)
void candl_dependence_pprint (FILE *file, candl_dependence_p dependence)
void candl_dependence_view (candl_dependence_p dependence)
static char * candl_program_deps_to_string (CandlDependence *dependence)
static CandlDependencecandl_dependence_read_one_dep (char *str, char **next, CandlProgram *program)
CandlDependencecandl_dependence_read_from_scop (scoplib_scop_p scop, CandlProgram *program)
void candl_dependence_update_scop_with_deps (scoplib_scop_p scop, CandlDependence *dependence)
void candl_dependence_print_scop (FILE *input, FILE *output, CandlDependence *dependence)
void candl_dependence_free (candl_dependence_p dependence)
candl_dependence_p candl_dependence_malloc ()
void candl_dependence_add (candl_dependence_p *start, candl_dependence_p *now, candl_dependence_p dependence)
static int candl_dependence_gcd (int a, int b)
static int candl_dependence_gcd_test_context (CandlMatrix *system, int id)
int candl_dependence_gcd_test (CandlStatement *source, CandlStatement *target, CandlMatrix *system, int level)
static CandlMatrixcandl_dependence_build_system (CandlStatement *source, CandlStatement *target, CandlMatrix *array_s, CandlMatrix *array_t, int ref_s, int ref_t, int depth, int before, int nb_par)
candl_dependence_p candl_dependence_system (CandlStatement *source, CandlStatement *target, CandlMatrix *context, CandlMatrix *array_s, CandlMatrix *array_t, int ref_s, int ref_t, int type, int depth)
candl_dependence_p candl_dependence_between (CandlStatement *source, CandlStatement *target, CandlMatrix *context, CandlOptions *options)
candl_dependence_p candl_dependence (candl_program_p program, CandlOptions *options)
int candl_dependence_var_is_scalar (candl_program_p program, int var_index)
static void candl_dependence_expand_scalar (CandlStatement **sl, int scalar_idx)
CandlStatement ** candl_dependence_refvar_chain (candl_program_p program, CandlStatement *dom, int var_index, int level)
int candl_dependence_var_is_ref (CandlStatement *s, int var_index)
static void candl_dependence_compute_lb (CandlMatrix *m, Entier *lb, int col)
int candl_dependence_check_domain_is_included (CandlStatement *s1, CandlStatement *s2, CandlMatrix *context, int level)
int * candl_dependence_extract_scalar_variables (candl_program_p program)
static void candl_dependence_get_array_refs_in_dep (CandlDependence *tmp, int *refs, int *reft)
void candl_dependence_prune_scalar_waw (candl_program_p program, CandlOptions *options, CandlDependence **deps)
int candl_dependence_scalar_renaming (candl_program_p program, CandlOptions *options, CandlDependence **deps)
int candl_dependence_is_loop_carried (candl_program_p program, CandlDependence *dep, int loop_index)
void candl_dependence_prune_with_privatization (candl_program_p program, CandlOptions *options, CandlDependence **deps)
int candl_dependence_scalar_is_privatizable_at (candl_program_p program, int var_index, int loop_index)
int candl_dependence_analyze_scalars (candl_program_p program, CandlOptions *options)
int candl_num_dependences (CandlDependence *candl_deps)
static PipMatrix ** quast_to_polyhedra (PipQuast *quast, int *num, int nvar, int npar)
static int candl_dep_compute_lastwriter (CandlDependence **dep, CandlProgram *prog)
void candl_compute_last_writer (CandlDependence *dep, CandlProgram *prog)

Detailed Description

------ ( ----------------------------------------------------------** )\ CAnDL ** ----- / ) --------------------------------------------------------** ( * ( dependence.c ** ---- #/ --------------------------------------------------------** .-"#'-. First version: september 18th 2003 ** --- |"-.-"| -------------------------------------------------------** | | | | | | ************************************************************* CAnDL '-._,-' the Chunky Analyzer for Dependences in Loops (experimental) *

* Copyright (C) 2003-2008 Cedric Bastoul * * This is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 3 of the License, or (at your option) * any later version. * * This software is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with software; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * CAnDL, the Chunky Dependence Analyzer * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr * *

Author:
Cedric Bastoul and Louis-Noel Pouchet

------ ( ----------------------------------------------------------** )\ CAnDL ** ----- / ) --------------------------------------------------------** ( * ( isl-wrapper.c ** ---- #/ --------------------------------------------------------** .-"#'-. First version: January 31st 2011 ** --- |"-.-"| -------------------------------------------------------** | | | | | | ************************************************************* CAnDL '-._,-' the Chunky Analyzer for Dependences in Loops (experimental) *

* Copyright (C) 2003-2008 Cedric Bastoul * * This is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 3 of the License, or (at your option) * any later version. * * This software is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with software; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * CAnDL, the Chunky Dependence Analyzer * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr * *

Author:
Sven Verdoolaege and Louis-Noel Pouchet

Function Documentation

void candl_compute_last_writer ( CandlDependence dep,
CandlProgram prog 
)

Compute the last writer for each RAW, WAW, and RAR dependence. This will modify the dependence polyhedra. Be careful of any references to the old dependence polyhedra. They are freed and new ones allocated.

References candl_dep_compute_lastwriter(), CANDL_RAR, CANDL_RAW, CANDL_WAW, candldependence::next, and candldependence::type.

Referenced by candl_dependence().

static int candl_dep_compute_lastwriter ( CandlDependence **  dep,
CandlProgram prog 
) [static]
candl_dependence_p candl_dependence ( candl_program_p  program,
CandlOptions options 
)
void candl_dependence_add ( candl_dependence_p start,
candl_dependence_p now,
candl_dependence_p  dependence 
)

candl_dependence_add function: This function adds a CandlDependence structure (dependence) at a given place (now) of a NULL terminated list of CandlDependence structures. The beginning of this list is (start). This function updates (now) to the end of the loop list (loop), and updates (start) if the added element is the first one -that is when (start) is NULL-.

  • 18/09/2003: first version.

References candldependence::next.

Referenced by candl_dependence(), and candl_dependence_between().

int candl_dependence_analyze_scalars ( candl_program_p  program,
CandlOptions options 
)
candl_dependence_p candl_dependence_between ( CandlStatement source,
CandlStatement target,
CandlMatrix context,
CandlOptions options 
)

candl_dependence_between function : this function builds the dependence list from the statement "source" to statement "target": it will study the dependence for each reference and for each depth, under a particular context (context) and according to some user options.

  • 18/09/2003: first version.
  • 07/12/2005: (debug) correction of depth bounds.
  • 09/12/2005: We may take commutativity into consideration.

References candl_dependence_add(), candl_dependence_system(), CANDL_eq, CANDL_notzero_p, CANDL_RAR, CANDL_RAW, candl_statement_commute(), CANDL_WAR, CANDL_WAW, candloptions::commute, candlstatement::depth, candlstatement::index, candloptions::rar, candloptions::raw, candlstatement::read, candloptions::war, candloptions::waw, and candlstatement::written.

Referenced by candl_dependence().

static CandlMatrix* candl_dependence_build_system ( CandlStatement source,
CandlStatement target,
CandlMatrix array_s,
CandlMatrix array_t,
int  ref_s,
int  ref_t,
int  depth,
int  before,
int  nb_par 
) [static]

candl_dependence_build_system function: this function builds the constraint system corresponding to a data dependence, for a given statement couple (with iteration domains "source" and "target"), for a given reference couple (the source reference is array "ref_s" in "array_s" and the target reference is the array "ref_t" in "array_t"), at a given depth "depth" and knowing if the source is textually before the target (boolean "before"). The system is built... as always ! See the [bastoul and Feautrier, PPL 2005] paper for details !

  • source is the source iteration domain,
  • target is the target iteration domain,
  • array_s is the array list for the source,
  • array_t is the array list for the target,
  • ref_s is the position of the source reference in array_s,
  • ref_s is the position of the target reference in array_t,
  • depth is the dependence depth,
  • before is 1 if the source is textually before the target, 0 otherwise,
  • nb_par is the number of parameters.
  • 13/12/2005: first version (extracted from candl_dependence_system).
  • 23/02/2006: a stupid bug corrected in the subscript equality.
  • 07/04/2007: fix the precedence condition to respect C. Bastoul PhD thesis

References CANDL_assign, CANDL_clear, CANDL_init, candl_matrix_malloc(), CANDL_oppose, CANDL_set_si, and CANDL_subtract.

Referenced by candl_dependence_system().

int candl_dependence_check_domain_is_included ( CandlStatement s1,
CandlStatement s2,
CandlMatrix context,
int  level 
)

candl_dependence_check_domain_is_included function: This function checks if the 'level'-first iterators of 2 domains are in such a way that s1 is larger or equal to s2, for the considered iterator dimensions.

References CANDL_assign, CANDL_clear, CANDL_decrement, candl_dependence_compute_lb(), CANDL_get_si, CANDL_init, candl_matrix_check_point(), candl_matrix_free(), candl_matrix_malloc(), CANDL_oppose, CANDL_set_si, candlstatement::depth, candlstatement::domain, and max.

Referenced by candl_dependence_analyze_scalars(), and candl_dependence_scalar_renaming().

static void candl_dependence_compute_lb ( CandlMatrix m,
Entier *  lb,
int  col 
) [static]

candl_dependence_compute_lb function: This function assigns to the Entier 'lb' the lexmin of variable 'col'-1 in the polyhedron 'm'.

References CANDL_assign.

Referenced by candl_dependence_check_domain_is_included().

static void candl_dependence_expand_scalar ( CandlStatement **  sl,
int  scalar_idx 
) [static]

candl_dependence_expand_scalar function: Expand the variable of index 'scalar_idx' by adding one dimension (x becomes x[0]) to each access matrix refering this variable in the statement list.

References CANDL_assign, CANDL_get_si, candl_matrix_free(), candl_matrix_malloc(), CANDL_set_si, candlstatement::read, and candlstatement::written.

Referenced by candl_dependence_analyze_scalars().

int* candl_dependence_extract_scalar_variables ( candl_program_p  program)

candl_dependence_extract_scalar_variables function: This functions returns a -1-terminated array of the program scalar variables.

References candl_dependence_var_is_scalar(), CANDL_FAIL, CANDL_get_si, candl_program::nb_statements, candlstatement::read, candl_program::statement, and candlstatement::written.

Referenced by candl_dependence_analyze_scalars(), candl_dependence_prune_scalar_waw(), and candl_dependence_scalar_renaming().

void candl_dependence_free ( candl_dependence_p  dependence)
static int candl_dependence_gcd ( int  a,
int  b 
) [static]

GCD computation.

Referenced by candl_dependence_gcd_test().

int candl_dependence_gcd_test ( CandlStatement source,
CandlStatement target,
CandlMatrix system,
int  level 
)

candl_dependence_gcd_test function: This functions performs a GCD test on a dependence polyhedra represented exactly by a set of constraints 'system' organized in such a way:

  • first lines: iteration domain of 'source'
  • then: iteration domain of 'target'
  • then: array access equality(ies)
  • then (optional): precedence constraint inequality.

The function returns false if the dependence is impossible, true otherwise. A series of simple checks (SIV/ZIV/MIV/bounds checking) are also performed before the actual GCD test.

References candl_dependence_gcd(), candl_dependence_gcd_test_context(), CANDL_get_si, candlstatement::depth, and candlstatement::domain.

Referenced by candl_dependence_system().

static int candl_dependence_gcd_test_context ( CandlMatrix system,
int  id 
) [static]
static void candl_dependence_get_array_refs_in_dep ( CandlDependence tmp,
int *  refs,
int *  reft 
) [static]
int candl_dependence_is_loop_carried ( candl_program_p  program,
CandlDependence dep,
int  loop_index 
)
candl_dependence_p candl_dependence_malloc ( )

candl_dependence_malloc function: This function allocates the memory space for a CandlDependence structure and sets its fields with default values. Then it returns a pointer to the allocated space.

  • 07/12/2005: first version.

References CANDL_FAIL, CANDL_UNSET, candldependence::depth, candldependence::domain, candldependence::next, candldependence::ref_source, candldependence::ref_target, candldependence::source, candldependence::target, candldependence::type, and candldependence::usr.

Referenced by candl_dep_compute_lastwriter(), candl_dependence_read_one_dep(), and candl_dependence_system().

void candl_dependence_pprint ( FILE *  file,
candl_dependence_p  dependence 
)
void candl_dependence_print ( FILE *  file,
candl_dependence_p  dependence 
)

References candl_dependence_print_structure().

Referenced by main().

void candl_dependence_print_scop ( FILE *  input,
FILE *  output,
CandlDependence dependence 
)

Print the scop, containing the list of dependences.

References candl_dependence_update_scop_with_deps().

Referenced by main().

void candl_dependence_print_structure ( FILE *  file,
candl_dependence_p  dependence,
int  level 
)

candl_dependence_print_structure function: Displays a CandlDependence structure (dependence) into a file (file, possibly stdout) in a way that trends to be understandable without falling in a deep depression or, for the lucky ones, getting a headache... It includes an indentation level (level) in order to work with others print_structure functions.

  • 18/09/2003: first version.

References candl_matrix_print_structure(), CANDL_RAR, CANDL_RAW, candl_statement_print_structure(), CANDL_UNSET, CANDL_WAR, CANDL_WAW, candldependence::depth, candldependence::domain, candldependence::next, candldependence::source, candldependence::target, and candldependence::type.

Referenced by candl_dependence_print(), and candl_violation_print_structure().

void candl_dependence_prune_scalar_waw ( candl_program_p  program,
CandlOptions options,
CandlDependence **  deps 
)

candl_dependence_prune_scalar_waw function: This function removes all WAW dependences between the same scalar (they are useless dependences).

References candl_dependence_extract_scalar_variables(), candl_dependence_get_array_refs_in_dep(), candl_matrix_free(), CANDL_WAW, candldependence::domain, candldependence::next, candldependence::type, and candloptions::verbose.

Referenced by candl_dependence().

void candl_dependence_prune_with_privatization ( candl_program_p  program,
CandlOptions options,
CandlDependence **  deps 
)
CandlDependence* candl_dependence_read_from_scop ( scoplib_scop_p  scop,
CandlProgram program 
)

Retrieve a CandlDependence list from the option tag in the scop.

References candl_dependence_read_one_dep(), and candldependence::next.

static CandlDependence* candl_dependence_read_one_dep ( char *  str,
char **  next,
CandlProgram program 
) [static]

candl_dependence_print_scop function: This function adds to the .scop file provided as the 'input' the optional tags to represent the dependences 'dependence' of the program. Finally, it prints the updated .scop to the file 'output'. Read one dependence from a string.

References candl_dependence_malloc(), candl_matrix_malloc(), CANDL_RAR, CANDL_RAW, CANDL_set_si, CANDL_WAR, CANDL_WAW, candldependence::depth, candldependence::domain, candlstatement::label, candl_program::nb_statements, candlstatement::read, candldependence::ref_source, candldependence::ref_target, candldependence::source, candl_program::statement, candldependence::target, candldependence::type, and candlstatement::written.

Referenced by candl_dependence_read_from_scop().

CandlStatement** candl_dependence_refvar_chain ( candl_program_p  program,
CandlStatement dom,
int  var_index,
int  level 
)

candl_dependence_refvar_chain function: This function returns a chain of statements as a feshly allocated array of pointer on statements, of all statements reading or writing the variable 'var_index', surrounded by the 'level' common loops of 'dom'. Output is a NULL-terminated array.

References candl_dependence_var_is_ref(), CANDL_VAR_UNDEF, candlstatement::depth, candlstatement::index, candl_program::nb_statements, and candl_program::statement.

Referenced by candl_dependence_analyze_scalars(), and candl_dependence_scalar_renaming().

int candl_dependence_scalar_is_privatizable_at ( candl_program_p  program,
int  var_index,
int  loop_index 
)

candl_dependence_is_privatizable function: This function checks if a given scalar 'var_index' is privatizable for loop 'loop_index'.

References candl_dependence_analyze_scalars(), candl_options_free(), candl_options_malloc(), candloptions::scalar_privatization, and candl_program::scalars_privatizable.

Referenced by candl_dependence_prune_with_privatization().

int candl_dependence_scalar_renaming ( candl_program_p  program,
CandlOptions options,
CandlDependence **  deps 
)
candl_dependence_p candl_dependence_system ( CandlStatement source,
CandlStatement target,
CandlMatrix context,
CandlMatrix array_s,
CandlMatrix array_t,
int  ref_s,
int  ref_t,
int  type,
int  depth 
)

candl_dependence_system function : this function builds a node of the dependence graph: it studies a dependence between a given statement couple, reference couple, type and depth. If a data dependence actually exists, it returns a dependence structure, it returns NULL otherwise.

  • source is the source statement,
  • target is the target statement,
  • context is the program context (contraints on global parameters),
  • array_s is the array list for the source,
  • array_t is the array list for the target,
  • ref_s is the position of the source reference in array_s,
  • ref_s is the position of the target reference in array_t,
  • depth is the dependence depth,
  • type is the dependence type (RAW, WAW, WAR or RAR).
  • 18/09/2003: first version.
  • 09/12/2005: few corrections and polishing.

References candl_dependence_build_system(), candl_dependence_gcd_test(), candl_dependence_malloc(), candl_matrix_free(), candldependence::depth, candldependence::domain, candlstatement::label, candldependence::ref_source, candldependence::ref_target, candldependence::source, candldependence::target, and candldependence::type.

Referenced by candl_dependence_between().

void candl_dependence_update_scop_with_deps ( scoplib_scop_p  scop,
CandlDependence dependence 
)

Update the scop option tag with the dependence list.

References CANDL_FAIL, and candl_program_deps_to_string().

Referenced by candl_dependence_print_scop().

int candl_dependence_var_is_ref ( CandlStatement s,
int  var_index 
)

candl_dependence_var_is_ref function: This function checks if a var 'var_index' is referenced (DEF or USE) by the statement.

References CANDL_get_si, CANDL_VAR_IS_DEF, CANDL_VAR_IS_DEF_USED, CANDL_VAR_IS_USED, CANDL_VAR_UNDEF, candlstatement::read, and candlstatement::written.

Referenced by candl_dependence_analyze_scalars(), candl_dependence_refvar_chain(), and candl_dependence_scalar_renaming().

int candl_dependence_var_is_scalar ( candl_program_p  program,
int  var_index 
)

candl_dependence_var_is_scalar function: This function returns true if the variable indexed by 'var_index' is a scalar in the whole program.

References CANDL_get_si, candl_program::nb_statements, candlstatement::read, candl_program::statement, and candlstatement::written.

Referenced by candl_dependence_extract_scalar_variables().

void candl_dependence_view ( candl_dependence_p  dependence)

References candl_dependence_pprint(), and CANDL_TEMP_OUTPUT.

Referenced by main().

int candl_num_dependences ( CandlDependence candl_deps)

candl_num_dependences function: This function returns the number of dependences in the dependence list

Parameters:
dependenceThe first dependence of the dependence list.

References candldependence::next.

static char* candl_program_deps_to_string ( CandlDependence dependence) [static]
static PipMatrix** quast_to_polyhedra ( PipQuast *  quast,
int *  num,
int  nvar,
int  npar 
) [static]