PIPS
complexity.h File Reference
#include "matrice.h"
+ Include dependency graph for complexity.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  intrinsic_cost_rec
 Intrinsics costs defines. More...
 

Macros

#define COMPLEXITY_PACKAGE_NAME   "COMPLEXITY"
 Warning! Do not modify this file that is automatically generated! More...
 
#define COMPLEXITY_UNDEFINED   complexity_undefined
 
#define COMPLEXITY_UNDEFINED_P(c)   ((c)==complexity_undefined)
 
#define COMPLEXITY_NOT_FOUND   ((complexity) HASH_UNDEFINED_VALUE)
 
#define MAX_CONTROLS_IN_UNSTRUCTURED   100
 
#define UNKNOWN_VARIABLE_NAME   "UNKNOWN_VARIABLE"
 pseudo-variable for unknown variables
More...
 
#define UNKNOWN_RANGE_NAME   "UNKNOWN_RANGE"
 pseudo-variable for default iteration number of a loop More...
 
#define TCST_NAME   "_TCST_"
 
#define UNKNOWN_VARIABLE_VALUE_PREFIX   "U_"
 Prefix added to a variable name when its value is unknown but has to be used in a complexity formulae. More...
 
#define COST_DATA   "operation index memory trigo transcend overhead"
 defined complexity data file names here. More...
 
#define DO_PRINT_STATS   true
 defines for "complexity_fprint" calls More...
 
#define DONT_PRINT_STATS   false
 
#define PRINT_LOCAL_NAMES   true
 
#define PRINT_GLOBAL_NAMES   false
 
#define HASH_LOOP_INDEX   ((char *) 4) /**Used as `value' field in the hash-table */
 
#define HASH_USER_VARIABLE   ((char *) 8) /**"hash_complexity_parameters"... useful? */
 
#define HASH_FORMAL_PARAM   ((char *) 12)
 
#define HASH_COMMON_VARIABLE   ((char *) 16) /**used for variable in common. LZ 04/12/91 */
 
#define ZERO_BYTE   0
 
#define INT_NBYTES   4 /**number of bytes used by a standard int */
 
#define FLOAT_NBYTES   4 /**number of bytes used by a single-precision */
 
#define DOUBLE_NBYTES   8 /**number of bytes used by a double-precision */
 
#define COMPLEX_NBYTES   2*FLOAT_NBYTES /**complex, single-precision */
 
#define DCOMPLEX_NBYTES   2*DOUBLE_NBYTES /**complex, double-precision */
 
#define MAKE_INT_BASIC   make_basic(is_basic_int, (void *) INT_NBYTES)
 
#define MAKE_ADDRESS_BASIC   make_basic(is_basic_int, (void *) DEFAULT_POINTER_TYPE_SIZE)
 
#define MAKE_FLOAT_BASIC   make_basic(is_basic_float, (void *) FLOAT_NBYTES)
 
#define MAKE_DOUBLE_BASIC   make_basic(is_basic_float, (void *) DOUBLE_NBYTES)
 
#define MAKE_COMPLEX_BASIC   make_basic(is_basic_complex, (void *) COMPLEX_NBYTES)
 
#define MAKE_DCOMPLEX_BASIC   make_basic(is_basic_complex, (void *) DCOMPLEX_NBYTES)
 
#define MAKE_STRING_BASIC   make_basic(is_basic_string, make_value(is_value_unknown, UU))
 
#define hash_contains_p(htp, key)   (hash_get(htp, key) != HASH_UNDEFINED_VALUE)
 
#define hash_contains_formal_param_p(htp, key)   (hash_get(htp, key) == HASH_FORMAL_PARAM)
 
#define hash_contains_user_var_p(htp, key)   (hash_get(htp, key) == HASH_USER_VARIABLE)
 
#define hash_contains_common_var_p(htp, key)   (hash_get(htp, key) == HASH_COMMON_VARIABLE)
 
#define hash_contains_loop_index_p(htp, key)   (hash_get(htp, key) == HASH_LOOP_INDEX)
 
#define KEEP_SYMBOLS   true
 defines for "expression_to_polynome" parameters More...
 
#define DONT_KEEP_SYMBOLS   false
 
#define MAXIMUM_VALUE   1
 
#define MINIMUM_VALUE   -1
 
#define EXACT_VALUE   0
 
#define TAKE_MAX(m)   ((m) == MAXIMUM_VALUE)
 
#define TAKE_MIN(m)   ((m) == MINIMUM_VALUE)
 
#define KEEP_EXACT(m)   ((m) == EXACT_VALUE)
 
#define LOOP_INIT_OVERHEAD   "LOOP-INIT-OVERHEAD"
 
#define LOOP_BRANCH_OVERHEAD   "LOOP-BRANCH-OVERHEAD"
 
#define CONDITION_OVERHEAD   "CONDITION-OVERHEAD"
 
#define CALL_ZERO_OVERHEAD   "CALL-ZERO-OVERHEAD"
 
#define CALL_ONE_OVERHEAD   "CALL-ONE-OVERHEAD"
 
#define CALL_TWO_OVERHEAD   "CALL-TWO-OVERHEAD"
 
#define CALL_THREE_OVERHEAD   "CALL-THREE-OVERHEAD"
 
#define CALL_FOUR_OVERHEAD   "CALL-FOUR-OVERHEAD"
 
#define CALL_FIVE_OVERHEAD   "CALL-FIVE-OVERHEAD"
 
#define CALL_SIX_OVERHEAD   "CALL-SIX-OVERHEAD"
 
#define CALL_SEVEN_OVERHEAD   "CALL-SEVEN-OVERHEAD"
 
#define TYPE_CAST_COST   "TypeCast"
 TYPE_CAST_COST added to handle cast case ; Molka Becher
More...
 
#define MEMORY_READ_NAME   "MEMORY-READ"
 the above two lines are added for 6th cost file, overhead. More...
 
#define ONE_INDEX_NAME   "ONE-INDEX" /**to count indexation costs in multi-dim arrays */
 
#define TWO_INDEX_NAME   "TWO-INDEX" /**to count indexation costs in multi-dim arrays */
 
#define THREE_INDEX_NAME   "THREE-INDEX"
 
#define FOUR_INDEX_NAME   "FOUR-INDEX"
 
#define FIVE_INDEX_NAME   "FIVE-INDEX"
 
#define SIX_INDEX_NAME   "SIX-INDEX"
 
#define SEVEN_INDEX_NAME   "SEVEN-INDEX"
 
#define STRING_INTRINSICS_COST   1
 
#define LOGICAL_INTRINSICS_COST   1
 
#define DONT_COUNT_THAT   0, 0, 0, 0, 0
 
#define EMPTY_COST   0,0,0,0,0
 
#define DISCRIMINE_TYPES   1, 10, 100,1000,10000
 
#define REAL_INTRINSIC   100, 100, 100, 100, 100
 
#define DOUBLE_INTRINSIC   200, 200, 200, 200, 200
 
#define COMPLEX_INTRINSIC   400, 400, 400, 400, 400
 
#define MEMORY_READ_COST   DONT_COUNT_THAT
 
#define MEMORY_WRITE_COST   DONT_COUNT_THAT
 
#define PLUS_MINUS_COST   1, 10, 20, 20, 40
 
#define MULTIPLY_COST   PLUS_MINUS_COST
 
#define DIVIDE_COST   PLUS_MINUS_COST
 
#define POWER_COST   100, 100, 200, 200, 400
 
#define TRANSC_COST   REAL_INTRINSIC
 
#define DTRANSC_COST   DOUBLE_INTRINSIC
 
#define CTRANSC_COST   COMPLEX_INTRINSIC
 
#define TRIGO_COST   REAL_INTRINSIC
 
#define DTRIGO_COST   DOUBLE_INTRINSIC
 
#define CTRIGO_COST   COMPLEX_INTRINSIC
 
#define TRIGOH_COST   REAL_INTRINSIC
 
#define DTRIGOH_COST   DOUBLE_INTRINSIC
 
#define CTRIGOH_COST   COMPLEX_INTRINSIC
 
#define TWO_INDEX_COST   DONT_COUNT_THAT
 
#define THREE_INDEX_COST   DONT_COUNT_THAT
 
#define FOUR_INDEX_COST   DONT_COUNT_THAT
 
#define FIVE_INDEX_COST   DONT_COUNT_THAT
 
#define SIX_INDEX_COST   DONT_COUNT_THAT
 
#define SEVEN_INDEX_COST   DONT_COUNT_THAT
 

Typedefs

typedef struct intrinsic_cost_rec intrinsic_cost_record
 Intrinsics costs defines. More...
 

Functions

bool complexity_map_undefined_p (void)
 
void set_complexity_map (statement_mapping)
 
statement_mapping get_complexity_map (void)
 
void reset_complexity_map (void)
 
void free_complexity_map (void)
 
void make_complexity_map (void)
 
complexity load_statement_complexity (statement)
 
void delete_statement_complexity (statement)
 
bool statement_complexity_undefined_p (statement)
 
void store_statement_complexity (statement, complexity)
 
void update_statement_complexity (statement, complexity)
 
bool uniform_complexities (const string)
 declares the static variable complexity_map and defines its access functions More...
 
bool fp_complexities (const string)
 
bool any_complexities (const string)
 
bool summary_complexity (const string)
 
complexity statement_to_complexity (statement, transformer, list)
 
complexity instruction_to_complexity (instruction, transformer, list)
 The only element available of the statement. More...
 
complexity block_to_complexity (list, transformer, list)
 1st element of instruction More...
 
complexity test_to_complexity (test, transformer, list)
 2nd element of instruction More...
 
complexity loop_to_complexity (loop, transformer, list)
 3rd element of instruction More...
 
complexity goto_to_complexity (statement, transformer, list)
 
complexity whileloop_to_complexity (whileloop, transformer, list)
 5th element of instruction More...
 
complexity call_to_complexity (call, basic *, transformer, list)
 3rd element of syntax More...
 
complexity arguments_to_complexity (list, basic *, transformer, list)
 2nd element of call More...
 
complexity expression_to_complexity (expression, basic *, transformer, list)
 2nd element of call –arguments More...
 
complexity subscript_to_complexity (subscript, basic *, transformer, list)
 
complexity syntax_to_complexity (syntax, basic *, transformer, list)
 the only available element of expression More...
 
complexity reference_to_complexity (reference, basic *, transformer, list)
 1st element of syntax More...
 
complexity indices_to_complexity (list, basic *, transformer, list)
 2nd element of reference More...
 
complexity range_to_complexity (range, transformer, list)
 2nd element of syntax More...
 
char * noms_var (entity)
 comp_expr_to_pnome.c More...
 
complexity make_complexity_unknown (const char *)
 builds a new unknown complexity attached to a virtual package More...
 
complexity expression_to_complexity_polynome (expression, transformer, list, bool, int)
 Entry point routine of this file: More...
 
complexity syntax_to_polynome (syntax, transformer, list, bool, int)
 1st element of expression More...
 
complexity normalized_to_polynome (normalized, transformer, list, bool, int)
 2nd element of expression More...
 
complexity pvecteur_to_polynome (Pvecteur, transformer, list, bool, int)
 The only element available of normalized. More...
 
complexity reference_to_polynome (reference, transformer, list, bool, int)
 First element of the "syntax" domain. More...
 
complexity range_to_polynome (range, transformer, list, bool, int)
 
complexity call_to_polynome (call, transformer, list, bool, int)
 3rd element of syntax More...
 
complexity cast_to_polynome (cast, transformer, list, bool, int)
 4th element of syntax : Molka Becher More...
 
complexity plus_op_handler (list, transformer, list, bool, int)
 
complexity minus_op_handler (list, transformer, list, bool, int)
 
complexity multiply_op_handler (list, transformer, list, bool, int)
 
complexity field_op_handler (list, transformer, list, bool, int)
 
complexity unary_minus_op_handler (list, transformer, list, bool, int)
 
complexity unary_plus_op_handler (list, transformer, list, bool, int)
 
complexity divide_op_handler (list, transformer, list, bool, int)
 
complexity power_op_handler (list, transformer, list, bool, int)
 
complexity evaluate_var_to_complexity (entity, transformer, list, int)
 
complexity simplify_sc_to_complexity (Psysteme, Variable)
 This function is recently added by L.Zhou June 5, 91 simplify_sc_to_complexity(Psysteme ps, Variable var) It looks for the egality formula containing (Variable)var in the system (Psysteme)ps. More...
 
complexity unstructured_to_complexity (unstructured, transformer, list)
 comp_unstr.c More...
 
void controls_to_hash_table (control, int *, control[], hash_table, transformer, list)
 
int control_element_position_in_control_array (control, control[], int)
 
matrice average_probability_matrix (unstructured, int, control[])
 
void node_successors_to_matrix (control, matrice, int, control[], bool[])
 
bool complexity_check (complexity)
 comp_util.c More...
 
void complexity_check_and_warn (const char *, complexity)
 
void good_complexity_assert (string, complexity)
 
complexity complexity_dup (complexity)
 duplicates complexity comp More...
 
void complexity_rm (complexity *)
 remove complexity comp More...
 
char * complexity_sprint (complexity, bool, bool)
 
void complexity_fprint (FILE *, complexity, bool, bool)
 
void complexity_dump (complexity)
 
void prc (complexity)
 
void prp (Ppolynome)
 
void prv (Pvecteur)
 
void fprint_statement_complexity (entity, statement, hash_table)
 
void fprint_cost_table (FILE *)
 
void init_cost_table (void)
 Completes the intrinsic cost table with the costs read from the files specified in the "COMPLEXITY_COST_TABLE" string property See properties.rc and ~pips/Pips/pipsrc.csh for more information. More...
 
void load_cost_file (FILE *, double)
 
int intrinsic_cost (const char *, basic *)
 
float constant_entity_to_float (entity)
 Return if possible the value of e in a float. More...
 
void trace_on (char *,...)
 
void trace_off (void)
 "trace off" More...
 
bool is_linear_unstructured (unstructured)
 return true if unstr is simply a linear string of controls More...
 
list entity_list_reverse (list)
 
void add_formal_parameters_to_hash_table (entity, hash_table)
 
void remove_formal_parameters_from_hash_table (entity, hash_table)
 
hash_table free_callees_complexities (hash_table)
 
hash_table fetch_callees_complexities (char *)
 
hash_table fetch_complexity_parameters (char *)
 
void add_common_variables_to_hash_table (entity, hash_table)
 
void remove_common_variables_from_hash_table (entity, hash_table)
 
bool is_must_be_written_var (list, char *)
 
complexity final_statement_to_complexity_evaluation (complexity, transformer, list)
 
complexity translate_complexity_from_local_to_current_name (complexity, string, string)
 translate_complexity_from_local_to_current_name(callee_comp,oldname,newname) B:M -> A:M if A calls B 5 Feb. More...
 
bool complexity_is_monomial_p (complexity)
 
int complexity_degree (complexity)
 
complexity complexity_sigma (complexity, Variable, complexity, complexity)
 comp_math.c More...
 
complexity complexity_var_subst (complexity, Variable, complexity)
 complexity complexity_var_subst(comp, var, compsubst) replaces every occurrence of variable var in complexity comp by the polynomial of complexity compsubst. More...
 
complexity polynome_to_new_complexity (Ppolynome)
 Create a complexity equal to Ppolynome pp with null statistics. More...
 
complexity make_single_var_complexity (double, Variable)
 
complexity make_constant_complexity (double)
 
complexity make_zero_complexity (void)
 make a zero complexity "0.0000 * TCST" with null statistics More...
 
bool complexity_zero_p (complexity)
 zero complexity check. More...
 
bool complexity_constant_p (complexity)
 true if comp is constant. More...
 
bool complexity_unknown_p (complexity)
 true if comp is unknown. More...
 
float complexity_TCST (complexity)
 return the constant term of comp. More...
 
void complexity_scalar_mult (complexity *, double)
 
void complexity_stats_add (complexity *, complexity)
 Add comp2's statistics to *pcomp1's comp2 keeps unchanged. More...
 
void complexity_add (complexity *, complexity)
 void complexity_add(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 + comp2; !usage: complexity_add(&comp1, comp2); comp2 keeps unchanged More...
 
void complexity_sub (complexity *, complexity)
 void complexity_sub(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 - comp2; !usage: complexity_sub(&comp1, comp2); comp2 keeps unchanged More...
 
void complexity_mult (complexity *, complexity)
 void complexity_mult(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 * comp2; !usage: complexity_mult(&comp1, comp2); More...
 
void complexity_div (complexity *, complexity)
 void complexity_div(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 / comp2; !usage: complexity_div(&comp1, comp2); More...
 
void complexity_polynome_add (complexity *, Ppolynome)
 
void complexity_float_add (complexity *, double)
 
Ppolynome complexity_polynome (complexity)
 Because complexity is composed of two elements, we use this function to get the first element : polynome Usage : complexity_polynome(complexity comp) you will get a pointer to the polynome May 3, 91 lz. More...
 
complexity replace_formal_parameters_by_real_ones (complexity, entity, list, transformer, list)
 transform formal params into real ones (args) in complexity comp More...
 
list list_ith_element (list, int)
 return a pointer to the (i)th element of the list if i = 1, the pointer doesn't change at all. More...
 
bool print_code_complexities (const string)
 comp_prettyprint.c More...
 
bool print_code_as_a_graph_complexities (const string)
 
bool print_source_complexities (const string)
 
bool print_call_graph_with_complexities (const string)
 
bool print_icfg_with_complexities (const string)
 
bool print_icfg_with_loops_complexities (const string)
 
bool print_icfg_with_control_complexities (const string)
 
char * variable_name (Variable)
 polynome_ri.c More...
 
char * variable_local_name (Variable)
 
bool is_inferior_var (Variable, Variable)
 
int is_inferior_varval (Pvecteur, Pvecteur)
 
int is_inferior_pvarval (Pvecteur *, Pvecteur *)
 
Variable name_to_variable (char *)
 
Variable local_name_to_variable (char *)
 
void lu_decomposition (float *, int, int *, int *)
 comp_matrice.c More...
 
void lu_back_substitution (float *, int, int *, float *)
 
void float_matrice_inversion (float *, int, int *, int *)
 

Variables

hash_table hash_callee_to_complexity
 cproto-generated files More...
 
hash_table hash_complexity_parameters
 
intrinsic_cost_record intrinsic_cost_table []
 The table intrinsic_cost_table[] gathers cost information of each intrinsic's cost; those costs are dynamically loaded from user files. More...
 

Macro Definition Documentation

◆ CALL_FIVE_OVERHEAD

#define CALL_FIVE_OVERHEAD   "CALL-FIVE-OVERHEAD"

Definition at line 137 of file complexity.h.

◆ CALL_FOUR_OVERHEAD

#define CALL_FOUR_OVERHEAD   "CALL-FOUR-OVERHEAD"

Definition at line 136 of file complexity.h.

◆ CALL_ONE_OVERHEAD

#define CALL_ONE_OVERHEAD   "CALL-ONE-OVERHEAD"

Definition at line 133 of file complexity.h.

◆ CALL_SEVEN_OVERHEAD

#define CALL_SEVEN_OVERHEAD   "CALL-SEVEN-OVERHEAD"

Definition at line 139 of file complexity.h.

◆ CALL_SIX_OVERHEAD

#define CALL_SIX_OVERHEAD   "CALL-SIX-OVERHEAD"

Definition at line 138 of file complexity.h.

◆ CALL_THREE_OVERHEAD

#define CALL_THREE_OVERHEAD   "CALL-THREE-OVERHEAD"

Definition at line 135 of file complexity.h.

◆ CALL_TWO_OVERHEAD

#define CALL_TWO_OVERHEAD   "CALL-TWO-OVERHEAD"

Definition at line 134 of file complexity.h.

◆ CALL_ZERO_OVERHEAD

#define CALL_ZERO_OVERHEAD   "CALL-ZERO-OVERHEAD"

Definition at line 132 of file complexity.h.

◆ COMPLEX_INTRINSIC

#define COMPLEX_INTRINSIC   400, 400, 400, 400, 400

Definition at line 163 of file complexity.h.

◆ COMPLEX_NBYTES

#define COMPLEX_NBYTES   2*FLOAT_NBYTES /**complex, single-precision */

Definition at line 88 of file complexity.h.

◆ COMPLEXITY_NOT_FOUND

#define COMPLEXITY_NOT_FOUND   ((complexity) HASH_UNDEFINED_VALUE)

Definition at line 53 of file complexity.h.

◆ COMPLEXITY_PACKAGE_NAME

#define COMPLEXITY_PACKAGE_NAME   "COMPLEXITY"

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/complexity/complexity-local.h instead, to add your own modifications. header file built by cproto complexity-local.h

Definition at line 47 of file complexity.h.

◆ COMPLEXITY_UNDEFINED

#define COMPLEXITY_UNDEFINED   complexity_undefined

Definition at line 48 of file complexity.h.

◆ COMPLEXITY_UNDEFINED_P

#define COMPLEXITY_UNDEFINED_P (   c)    ((c)==complexity_undefined)

Definition at line 52 of file complexity.h.

◆ CONDITION_OVERHEAD

#define CONDITION_OVERHEAD   "CONDITION-OVERHEAD"

Definition at line 130 of file complexity.h.

◆ COST_DATA

#define COST_DATA   "operation index memory trigo transcend overhead"

defined complexity data file names here.

LZ 13/03/92

Definition at line 71 of file complexity.h.

◆ CTRANSC_COST

#define CTRANSC_COST   COMPLEX_INTRINSIC

Definition at line 178 of file complexity.h.

◆ CTRIGO_COST

#define CTRIGO_COST   COMPLEX_INTRINSIC

Definition at line 181 of file complexity.h.

◆ CTRIGOH_COST

#define CTRIGOH_COST   COMPLEX_INTRINSIC

Definition at line 184 of file complexity.h.

◆ DCOMPLEX_NBYTES

#define DCOMPLEX_NBYTES   2*DOUBLE_NBYTES /**complex, double-precision */

Definition at line 89 of file complexity.h.

◆ DISCRIMINE_TYPES

#define DISCRIMINE_TYPES   1, 10, 100,1000,10000

Definition at line 160 of file complexity.h.

◆ DIVIDE_COST

#define DIVIDE_COST   PLUS_MINUS_COST

Definition at line 173 of file complexity.h.

◆ DO_PRINT_STATS

#define DO_PRINT_STATS   true

defines for "complexity_fprint" calls

Definition at line 74 of file complexity.h.

◆ DONT_COUNT_THAT

#define DONT_COUNT_THAT   0, 0, 0, 0, 0

Definition at line 158 of file complexity.h.

◆ DONT_KEEP_SYMBOLS

#define DONT_KEEP_SYMBOLS   false

Definition at line 107 of file complexity.h.

◆ DONT_PRINT_STATS

#define DONT_PRINT_STATS   false

Definition at line 75 of file complexity.h.

◆ DOUBLE_INTRINSIC

#define DOUBLE_INTRINSIC   200, 200, 200, 200, 200

Definition at line 162 of file complexity.h.

◆ DOUBLE_NBYTES

#define DOUBLE_NBYTES   8 /**number of bytes used by a double-precision */

Definition at line 87 of file complexity.h.

◆ DTRANSC_COST

#define DTRANSC_COST   DOUBLE_INTRINSIC

Definition at line 177 of file complexity.h.

◆ DTRIGO_COST

#define DTRIGO_COST   DOUBLE_INTRINSIC

Definition at line 180 of file complexity.h.

◆ DTRIGOH_COST

#define DTRIGOH_COST   DOUBLE_INTRINSIC

Definition at line 183 of file complexity.h.

◆ EMPTY_COST

#define EMPTY_COST   0,0,0,0,0

Definition at line 159 of file complexity.h.

◆ EXACT_VALUE

#define EXACT_VALUE   0

Definition at line 110 of file complexity.h.

◆ FIVE_INDEX_COST

#define FIVE_INDEX_COST   DONT_COUNT_THAT

Definition at line 189 of file complexity.h.

◆ FIVE_INDEX_NAME

#define FIVE_INDEX_NAME   "FIVE-INDEX"

Definition at line 152 of file complexity.h.

◆ FLOAT_NBYTES

#define FLOAT_NBYTES   4 /**number of bytes used by a single-precision */

Definition at line 86 of file complexity.h.

◆ FOUR_INDEX_COST

#define FOUR_INDEX_COST   DONT_COUNT_THAT

Definition at line 188 of file complexity.h.

◆ FOUR_INDEX_NAME

#define FOUR_INDEX_NAME   "FOUR-INDEX"

Definition at line 151 of file complexity.h.

◆ HASH_COMMON_VARIABLE

#define HASH_COMMON_VARIABLE   ((char *) 16) /**used for variable in common. LZ 04/12/91 */

Definition at line 82 of file complexity.h.

◆ hash_contains_common_var_p

#define hash_contains_common_var_p (   htp,
  key 
)    (hash_get(htp, key) == HASH_COMMON_VARIABLE)

Definition at line 101 of file complexity.h.

◆ hash_contains_formal_param_p

#define hash_contains_formal_param_p (   htp,
  key 
)    (hash_get(htp, key) == HASH_FORMAL_PARAM)

Definition at line 99 of file complexity.h.

◆ hash_contains_loop_index_p

#define hash_contains_loop_index_p (   htp,
  key 
)    (hash_get(htp, key) == HASH_LOOP_INDEX)

Definition at line 102 of file complexity.h.

◆ hash_contains_p

#define hash_contains_p (   htp,
  key 
)    (hash_get(htp, key) != HASH_UNDEFINED_VALUE)

Definition at line 98 of file complexity.h.

◆ hash_contains_user_var_p

#define hash_contains_user_var_p (   htp,
  key 
)    (hash_get(htp, key) == HASH_USER_VARIABLE)

Definition at line 100 of file complexity.h.

◆ HASH_FORMAL_PARAM

#define HASH_FORMAL_PARAM   ((char *) 12)

Definition at line 81 of file complexity.h.

◆ HASH_LOOP_INDEX

#define HASH_LOOP_INDEX   ((char *) 4) /**Used as `value' field in the hash-table */

Definition at line 79 of file complexity.h.

◆ HASH_USER_VARIABLE

#define HASH_USER_VARIABLE   ((char *) 8) /**"hash_complexity_parameters"... useful? */

Definition at line 80 of file complexity.h.

◆ INT_NBYTES

#define INT_NBYTES   4 /**number of bytes used by a standard int */

Definition at line 85 of file complexity.h.

◆ KEEP_EXACT

#define KEEP_EXACT (   m)    ((m) == EXACT_VALUE)

Definition at line 113 of file complexity.h.

◆ KEEP_SYMBOLS

#define KEEP_SYMBOLS   true

defines for "expression_to_polynome" parameters

Definition at line 106 of file complexity.h.

◆ LOGICAL_INTRINSICS_COST

#define LOGICAL_INTRINSICS_COST   1

Definition at line 156 of file complexity.h.

◆ LOOP_BRANCH_OVERHEAD

#define LOOP_BRANCH_OVERHEAD   "LOOP-BRANCH-OVERHEAD"

Definition at line 129 of file complexity.h.

◆ LOOP_INIT_OVERHEAD

#define LOOP_INIT_OVERHEAD   "LOOP-INIT-OVERHEAD"

Definition at line 128 of file complexity.h.

◆ MAKE_ADDRESS_BASIC

#define MAKE_ADDRESS_BASIC   make_basic(is_basic_int, (void *) DEFAULT_POINTER_TYPE_SIZE)

Definition at line 91 of file complexity.h.

◆ MAKE_COMPLEX_BASIC

#define MAKE_COMPLEX_BASIC   make_basic(is_basic_complex, (void *) COMPLEX_NBYTES)

Definition at line 94 of file complexity.h.

◆ MAKE_DCOMPLEX_BASIC

#define MAKE_DCOMPLEX_BASIC   make_basic(is_basic_complex, (void *) DCOMPLEX_NBYTES)

Definition at line 95 of file complexity.h.

◆ MAKE_DOUBLE_BASIC

#define MAKE_DOUBLE_BASIC   make_basic(is_basic_float, (void *) DOUBLE_NBYTES)

Definition at line 93 of file complexity.h.

◆ MAKE_FLOAT_BASIC

#define MAKE_FLOAT_BASIC   make_basic(is_basic_float, (void *) FLOAT_NBYTES)

Definition at line 92 of file complexity.h.

◆ MAKE_INT_BASIC

#define MAKE_INT_BASIC   make_basic(is_basic_int, (void *) INT_NBYTES)

Definition at line 90 of file complexity.h.

◆ MAKE_STRING_BASIC

#define MAKE_STRING_BASIC   make_basic(is_basic_string, make_value(is_value_unknown, UU))

Definition at line 96 of file complexity.h.

◆ MAX_CONTROLS_IN_UNSTRUCTURED

#define MAX_CONTROLS_IN_UNSTRUCTURED   100

Definition at line 55 of file complexity.h.

◆ MAXIMUM_VALUE

#define MAXIMUM_VALUE   1

Definition at line 108 of file complexity.h.

◆ MEMORY_READ_COST

#define MEMORY_READ_COST   DONT_COUNT_THAT

Definition at line 165 of file complexity.h.

◆ MEMORY_READ_NAME

#define MEMORY_READ_NAME   "MEMORY-READ"

the above two lines are added for 6th cost file, overhead.

LZ 280993 overhead is divided into two. init and branch 081093

Definition at line 147 of file complexity.h.

◆ MEMORY_WRITE_COST

#define MEMORY_WRITE_COST   DONT_COUNT_THAT

Definition at line 166 of file complexity.h.

◆ MINIMUM_VALUE

#define MINIMUM_VALUE   -1

Definition at line 109 of file complexity.h.

◆ MULTIPLY_COST

#define MULTIPLY_COST   PLUS_MINUS_COST

Definition at line 172 of file complexity.h.

◆ ONE_INDEX_NAME

#define ONE_INDEX_NAME   "ONE-INDEX" /**to count indexation costs in multi-dim arrays */

Definition at line 148 of file complexity.h.

◆ PLUS_MINUS_COST

#define PLUS_MINUS_COST   1, 10, 20, 20, 40

Definition at line 167 of file complexity.h.

◆ POWER_COST

#define POWER_COST   100, 100, 200, 200, 400

Definition at line 174 of file complexity.h.

◆ PRINT_GLOBAL_NAMES

#define PRINT_GLOBAL_NAMES   false

Definition at line 77 of file complexity.h.

◆ PRINT_LOCAL_NAMES

#define PRINT_LOCAL_NAMES   true

Definition at line 76 of file complexity.h.

◆ REAL_INTRINSIC

#define REAL_INTRINSIC   100, 100, 100, 100, 100

Definition at line 161 of file complexity.h.

◆ SEVEN_INDEX_COST

#define SEVEN_INDEX_COST   DONT_COUNT_THAT

Definition at line 191 of file complexity.h.

◆ SEVEN_INDEX_NAME

#define SEVEN_INDEX_NAME   "SEVEN-INDEX"

Definition at line 154 of file complexity.h.

◆ SIX_INDEX_COST

#define SIX_INDEX_COST   DONT_COUNT_THAT

Definition at line 190 of file complexity.h.

◆ SIX_INDEX_NAME

#define SIX_INDEX_NAME   "SIX-INDEX"

Definition at line 153 of file complexity.h.

◆ STRING_INTRINSICS_COST

#define STRING_INTRINSICS_COST   1

Definition at line 155 of file complexity.h.

◆ TAKE_MAX

#define TAKE_MAX (   m)    ((m) == MAXIMUM_VALUE)

Definition at line 111 of file complexity.h.

◆ TAKE_MIN

#define TAKE_MIN (   m)    ((m) == MINIMUM_VALUE)

Definition at line 112 of file complexity.h.

◆ TCST_NAME

#define TCST_NAME   "_TCST_"

Definition at line 63 of file complexity.h.

◆ THREE_INDEX_COST

#define THREE_INDEX_COST   DONT_COUNT_THAT

Definition at line 187 of file complexity.h.

◆ THREE_INDEX_NAME

#define THREE_INDEX_NAME   "THREE-INDEX"

Definition at line 150 of file complexity.h.

◆ TRANSC_COST

#define TRANSC_COST   REAL_INTRINSIC

Definition at line 176 of file complexity.h.

◆ TRIGO_COST

#define TRIGO_COST   REAL_INTRINSIC

Definition at line 179 of file complexity.h.

◆ TRIGOH_COST

#define TRIGOH_COST   REAL_INTRINSIC

Definition at line 182 of file complexity.h.

◆ TWO_INDEX_COST

#define TWO_INDEX_COST   DONT_COUNT_THAT

Definition at line 186 of file complexity.h.

◆ TWO_INDEX_NAME

#define TWO_INDEX_NAME   "TWO-INDEX" /**to count indexation costs in multi-dim arrays */

Definition at line 149 of file complexity.h.

◆ TYPE_CAST_COST

#define TYPE_CAST_COST   "TypeCast"

TYPE_CAST_COST added to handle cast case ; Molka Becher

Definition at line 142 of file complexity.h.

◆ UNKNOWN_RANGE_NAME

#define UNKNOWN_RANGE_NAME   "UNKNOWN_RANGE"

pseudo-variable for default iteration number of a loop

Definition at line 61 of file complexity.h.

◆ UNKNOWN_VARIABLE_NAME

#define UNKNOWN_VARIABLE_NAME   "UNKNOWN_VARIABLE"

pseudo-variable for unknown variables

Definition at line 58 of file complexity.h.

◆ UNKNOWN_VARIABLE_VALUE_PREFIX

#define UNKNOWN_VARIABLE_VALUE_PREFIX   "U_"

Prefix added to a variable name when its value is unknown but has to be used in a complexity formulae.

Definition at line 68 of file complexity.h.

◆ ZERO_BYTE

#define ZERO_BYTE   0

Definition at line 84 of file complexity.h.

Typedef Documentation

◆ intrinsic_cost_record

Intrinsics costs defines.

Function Documentation

◆ add_common_variables_to_hash_table()

void add_common_variables_to_hash_table ( entity  module,
hash_table  hash_complexity_params 
)
Parameters
moduleodule
hash_complexity_paramsash_complexity_params

Definition at line 946 of file comp_util.c.

949 {
950  const char* module_name = module_local_name(module);
951  list sefs_list = list_undefined;
952  list ce = list_undefined;
953 
954  pips_assert("add_common_variables_to_hash_table",
956 
957  sefs_list = effects_to_list( (effects)
958  db_get_memory_resource(DBR_SUMMARY_EFFECTS, module_name, true));
959 
960  ifdebug(5) {
961  debug(5, "add_common_variables_to_hash_table",
962  "Effect list for %s\n",
963  module_name);
964  print_effects(sefs_list);
965  }
966 
967  for(ce= sefs_list; !ENDP(ce); POP(ce)) {
968  effect obj = EFFECT(CAR(ce));
970  action ac = effect_action(obj);
972  entity e = reference_variable(r);
973  storage s = entity_storage(e);
974 
975  if ( !storage_formal_p(s) &&
976  action_read_p(ac) && approximation_exact_p(ap) ) {
977  debug(5,"add_common_variables_to_hash_table",
978  "%s added\n", module_local_name(e));
979  hash_put(hash_complexity_params, (char *) module_local_name(e),
981  }
982  }
983 }
#define HASH_COMMON_VARIABLE
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
list effects_to_list(effects)
Definition: effects.c:209
#define approximation_exact_p(x)
Definition: effects.h:369
#define effect_action(x)
Definition: effects.h:642
#define action_read_p(x)
Definition: effects.h:311
#define effect_approximation(x)
Definition: effects.h:644
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
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
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
#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
static char * module
Definition: pips.c:74
#define print_effects(e)
Definition: print.c:334
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool entity_module_p(entity e)
Definition: entity.c:683
#define storage_formal_p(x)
Definition: ri.h:2522
#define reference_variable(x)
Definition: ri.h:2326
#define entity_storage(x)
Definition: ri.h:2794
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References action_read_p, approximation_exact_p, CAR, db_get_memory_resource(), debug(), EFFECT, effect_action, effect_any_reference, effect_approximation, effects_to_list(), ENDP, entity_module_p(), entity_storage, HASH_COMMON_VARIABLE, hash_put(), ifdebug, list_undefined, module, module_local_name(), module_name(), pips_assert, POP, print_effects, reference_variable, and storage_formal_p.

Referenced by any_complexities().

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

◆ add_formal_parameters_to_hash_table()

void add_formal_parameters_to_hash_table ( entity  mod,
hash_table  hash_complexity_params 
)
Parameters
modod
hash_complexity_paramsash_complexity_params

Definition at line 768 of file comp_util.c.

771 {
772  list decl;
773 
774  pips_assert("add_formal_parameters_to_hash_table",
775  entity_module_p(mod));
777 
778  MAPL(pe, {
779  entity param = ENTITY(CAR(pe));
781  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
782  fprintf(stderr,"\nstorage_formal %s\n",
783  entity_name(param));
784  }
785  hash_put(hash_complexity_params, (char *) strdup(module_local_name(param)),
787  }
788  }, decl);
789 }
#define HASH_FORMAL_PARAM
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define code_declarations(x)
Definition: ri.h:784
#define entity_name(x)
Definition: ri.h:2790
#define value_code(x)
Definition: ri.h:3067
#define entity_initial(x)
Definition: ri.h:2796
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
Definition: replace.c:135

References CAR, code_declarations, ENTITY, entity_initial, entity_module_p(), entity_name, entity_storage, fprintf(), get_bool_property(), HASH_FORMAL_PARAM, hash_put(), MAPL, module_local_name(), pips_assert, storage_formal_p, strdup(), and value_code.

Referenced by any_complexities().

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

◆ any_complexities()

bool any_complexities ( const  string)

we may need to print preconditions for debugging purposes

Parameters
stringodule_name

Definition at line 99 of file comp_scan.c.

100 {
102  list effects_list = NIL;
103  entity module_entity;
104  statement module_stat;
105 
106  trace_on("complexities %s", (char *)module_name);
107  debug_on("COMPLEXITY_DEBUG_LEVEL");
108 
109  /* we may need to print preconditions for debugging purposes */
111  db_get_memory_resource(DBR_PRECONDITIONS, module_name, true));
113  db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true));
115  db_get_memory_resource(DBR_PROPER_EFFECTS, module_name, true));
118  db_get_memory_resource(DBR_CODE, module_name, true ) );
119 
120  module_entity = get_current_module_entity();
121  module_stat = get_current_module_statement();
122 
123  module_to_value_mappings(module_entity);
124 
125  precond = load_statement_precondition(module_stat);
126  effects_list = load_cumulated_rw_effects_list(module_stat);
127 
128  init_cost_table();
129 
130  if (get_bool_property("COMPLEXITY_PRINT_COST_TABLE"))
131  fprint_cost_table(stdout);
132 
134 
137 
140 
143 
144  (void)statement_to_complexity(module_stat, precond, effects_list);
145 
148 
151  debug_off();
152  trace_off();
153 
154  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
155  fprintf(stderr,"\n");
156  fprintf(stderr,"Before ------- COMPLEXITIES; module %s\n",module_name);
157  }
158 
159  DB_PUT_MEMORY_RESOURCE(DBR_COMPLEXITIES,
161  (char *) get_complexity_map() );
162  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
163  fprintf(stderr,"After ------- COMPLEXITIES; module %s\n",module_name);
164  }
165 
175 
176  return true;
177 }
hash_table hash_complexity_parameters
Definition: comp_scan.c:58
hash_table hash_callee_to_complexity
comp_expr_to_pnome.c
Definition: comp_scan.c:57
complexity statement_to_complexity(statement stat, transformer precon __attribute__((__unused__)), list eff_list __attribute__((__unused__)))
starting point of Abstract Syntax Tree
Definition: comp_scan.c:230
void remove_formal_parameters_from_hash_table(entity mod, hash_table hash_complexity_params)
Definition: comp_util.c:791
void remove_common_variables_from_hash_table(entity module, hash_table hash_complexity_params)
Definition: comp_util.c:985
void trace_on(char *fmt,...)
Definition: comp_util.c:684
hash_table free_callees_complexities(hash_table h)
Definition: comp_util.c:812
void add_common_variables_to_hash_table(entity module, hash_table hash_complexity_params)
Definition: comp_util.c:946
hash_table fetch_complexity_parameters(char *module_name)
Definition: comp_util.c:901
void trace_off()
"trace off"
Definition: comp_util.c:714
void add_formal_parameters_to_hash_table(entity mod, hash_table hash_complexity_params)
Definition: comp_util.c:768
void fprint_cost_table(FILE *fd)
Definition: comp_util.c:481
hash_table fetch_callees_complexities(char *module_name)
Definition: comp_util.c:821
void init_cost_table()
Completes the intrinsic cost table with the costs read from the files specified in the "COMPLEXITY_CO...
Definition: comp_util.c:519
statement_mapping get_complexity_map(void)
void reset_complexity_map(void)
void set_complexity_map(statement_mapping)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
list load_cumulated_rw_effects_list(statement)
void reset_cumulated_rw_effects(void)
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
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
#define MAKE_STATEMENT_MAPPING()
Definition: newgen-local.h:43
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
#define transformer_undefined
Definition: ri.h:2847
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
transformer load_statement_precondition(statement)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References add_common_variables_to_hash_table(), add_formal_parameters_to_hash_table(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, fetch_callees_complexities(), fetch_complexity_parameters(), fprint_cost_table(), fprintf(), free_callees_complexities(), free_value_mappings(), get_bool_property(), get_complexity_map(), get_current_module_entity(), get_current_module_statement(), hash_callee_to_complexity, hash_complexity_parameters, init_cost_table(), load_cumulated_rw_effects_list(), load_statement_precondition(), MAKE_STATEMENT_MAPPING, module_name(), module_name_to_entity(), module_to_value_mappings(), NIL, remove_common_variables_from_hash_table(), remove_formal_parameters_from_hash_table(), reset_complexity_map(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_precondition_map(), reset_proper_rw_effects(), set_complexity_map(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_precondition_map(), set_proper_rw_effects(), statement_to_complexity(), strdup(), trace_off(), trace_on(), and transformer_undefined.

Referenced by fp_complexities(), and uniform_complexities().

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

◆ arguments_to_complexity()

complexity arguments_to_complexity ( list  exprlist,
basic pbasic,
transformer  precond,
list  effects_list 
)

2nd element of call

arguments_to_complexity Return the sum of the complexities of the list of expressions passed. Return also in *pbasic the basic of the "biggest" argument (int/float/double/...)

Parameters
exprlistxprlist
pbasicbasic
precondrecond
effects_listffects_list

Definition at line 804 of file comp_scan.c.

809 {
811  basic abasic = MAKE_INT_BASIC;
812 
813  trace_on("arguments");
814 
815  *pbasic = MAKE_INT_BASIC;
816  MAPL (pa, {
817  expression e = EXPRESSION(CAR(pa));
818  complexity ctmp = expression_to_complexity(e, &abasic, precond, effects_list);
819  complexity_add(&comp, ctmp);
820  if (is_inferior_basic(*pbasic, abasic)) {
821  free_basic(*pbasic);
822  *pbasic = simple_basic_dup(abasic);
823  }
824  },exprlist);
825 
826  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
827  fprintf(stderr, "argument comp is at %p and value is ", comp);
828  complexity_fprint(stderr, comp, false, true);
829  }
830  complexity_check_and_warn("arguments_to_complexity", comp);
831 
832  trace_off();
833  return(comp);
834 }
void free_basic(basic p)
Definition: ri.c:107
void complexity_add(complexity *pcomp1, complexity comp2)
void complexity_add(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 + comp2; !...
Definition: comp_math.c:372
complexity make_zero_complexity()
make a zero complexity "0.0000 * TCST" with null statistics
Definition: comp_math.c:238
complexity expression_to_complexity(expression expr, basic *pbasic, transformer precond, list effects_list)
2nd element of call –arguments
Definition: comp_scan.c:838
void complexity_fprint(FILE *fd, complexity comp, bool print_stats_p, bool print_local_names_p)
Definition: comp_util.c:217
void complexity_check_and_warn(char *s, complexity comp) const
Definition: comp_util.c:108
#define MAKE_INT_BASIC
basic simple_basic_dup(basic)
Definition: type.c:2735
bool is_inferior_basic(basic, basic)
bool is_inferior_basic(basic1, basic2) return true if basic1 is less complex than basic2 ex: int is l...
Definition: type.c:2687
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217

References CAR, complexity_add(), complexity_check_and_warn(), complexity_fprint(), EXPRESSION, expression_to_complexity(), fprintf(), free_basic(), get_bool_property(), is_inferior_basic(), MAKE_INT_BASIC, make_zero_complexity(), MAPL, simple_basic_dup(), trace_off(), and trace_on().

Referenced by call_to_complexity().

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

◆ average_probability_matrix()

matrice average_probability_matrix ( unstructured  ,
int  ,
control  [] 
)

◆ block_to_complexity()

complexity block_to_complexity ( list  block,
transformer  precond,
list  effects_list 
)

1st element of instruction

Modification:

  • To postpone the variable evaluation, we reverse the block. Attention: gen_nreverse destroys the original list. LZ 4 Dec. 92
  • Secondly, we check the variables in complexity. If a certain variable is must_be_written variable ( obtained from cumulated effects ), we evaluate it. LZ 5 Dec. 92
  • When the variable is must_be_written, the precondition is no longer available with this effect. So we need to use the next statement effect with current precondition to evaluate the variable. LZ 9 Dec. 92
  • Francois suggested not to create new list, ie, reverse block. Hence we don't use MAPL any more here. Instead, gen_nthcdr is used. 16 Dec 92
Parameters
blocklock
precondrecond
effects_listffects_list

Definition at line 344 of file comp_scan.c.

347 {
349  int block_length = gen_length( block );
350  int i;
351 
352  trace_on("block");
353 
354  if (get_bool_property("COMPLEXITY_EARLY_EVALUATION")) {
355  FOREACH(STATEMENT, stat, block) {
356  complexity ctemp = statement_to_complexity(stat, precond, effects_list);
357  complexity_add(&comp, ctemp);
358  }
359  }
360  else { // default property setting
361  for ( i = block_length; i > 0 ; i-- ) {
362  statement stat = STATEMENT(CAR(gen_nthcdr( i-1, block )));
363  statement up_stat;
365  complexity ctemp = statement_to_complexity(stat,
366  prec, effects_list);
367 
368  list cumu_list = load_cumulated_rw_effects_list(stat);
369  //extern int default_is_inferior_pvarval(Pvecteur *, Pvecteur *);
370 
371  Pbase pb = VECTEUR_NUL;
372 
373  if ( i > 1 ) {
374  up_stat = STATEMENT(CAR(gen_nthcdr( i-2, block )));
375  cumu_list = load_cumulated_rw_effects_list(up_stat);
376  }
377  complexity_add(&comp, ctemp);
378 
381 
382  for ( ; !VECTEUR_NUL_P(pb); pb = pb->succ) {
383  bool mustbewritten;
384  entity v = (entity) (pb->var);
385  //char *var = variable_local_name(pb->var);
386 
387  //mustbewritten = is_must_be_written_var(cumu_list, var);
388  mustbewritten = effects_write_variable_p(cumu_list, v);
389 
390  if ( mustbewritten ) {
391  complexity csubst;
392 
393  csubst = evaluate_var_to_complexity((entity)pb->var,
394  prec,
395  cumu_list, 1);
396  comp = complexity_var_subst(comp, pb->var, csubst);
397  }
398  }
399  }
400  }
401 
402  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
403  (void) complexity_consistent_p(comp);
404  fprintf(stderr, "block comp is at %p and comp value is ", comp);
405  complexity_fprint(stderr, comp, false, true);
406  }
407  complexity_check_and_warn("block_to_complexity", comp);
408 
409  trace_off();
410  return(comp);
411 }
bool complexity_consistent_p(complexity p)
Definition: complexity_ri.c:27
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
complexity evaluate_var_to_complexity(entity var, transformer precond, list effects_list __attribute__((__unused__)), int maximize)
complexity evaluate_var_to_complexity(entity var, transformer precond, list effects_list,...
Ppolynome complexity_polynome(complexity comp)
Because complexity is composed of two elements, we use this function to get the first element : polyn...
Definition: comp_math.c:506
complexity complexity_var_subst(complexity comp, Variable var, complexity compsubst)
complexity complexity_var_subst(comp, var, compsubst) replaces every occurrence of variable var in co...
Definition: comp_math.c:155
bool effects_write_variable_p(list, entity)
Definition: effects.c:1091
size_t gen_length(const list l)
Definition: list.c:150
#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
list gen_nthcdr(int n, const list lx)
caution: the first item is 0! was: return( (n<=0) ? l : gen_nthcdr( n-1, CDR( l ))) ; if n>gen_length...
Definition: list.c:700
int default_is_inferior_pvarval(Pvecteur *pvarval1, Pvecteur *pvarval2)
bool default_is_inferior_pvarval(Pvecteur * pvarval1, Pvecteur * pvarval2) return true if var1 is bef...
Definition: pnome-io.c:286
Pbase polynome_used_var(Ppolynome pp, int *is_inferior_var)
Pbase polynome_used_var(Ppolynome pp, bool *is_inferior_var()) PRIVATE Returns, in a Pbase,...
Definition: pnome-reduc.c:204
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
#define VECTEUR_NUL_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 CAR, complexity_add(), complexity_check_and_warn(), complexity_consistent_p(), complexity_fprint(), complexity_polynome(), complexity_var_subst(), default_is_inferior_pvarval(), effects_write_variable_p(), evaluate_var_to_complexity(), FOREACH, fprintf(), gen_length(), gen_nthcdr(), get_bool_property(), load_cumulated_rw_effects_list(), load_statement_precondition(), make_zero_complexity(), polynome_used_var(), STATEMENT, statement_to_complexity(), Svecteur::succ, trace_off(), trace_on(), Svecteur::var, vect_dup(), VECTEUR_NUL, and VECTEUR_NUL_P.

Referenced by instruction_to_complexity().

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

◆ call_to_complexity()

complexity call_to_complexity ( call  call_instr,
basic pbasic,
transformer  precond,
list  effects_list 
)

3rd element of syntax

The only case that hash_callee_to_complexity is used

transform formal params into real ones

if not format case

Parameters
call_instrall_instr
pbasicbasic
precondrecond
effects_listffects_list

Definition at line 736 of file comp_scan.c.

741 {
743  entity f = call_function(call_instr);
744  list args= call_arguments(call_instr);
745  type t = entity_type(f);
746  value v = entity_initial(f);
747 
748  const char *name = module_local_name(f);
749 
750  trace_on("call %s", entity_name(f));
751 
752  pips_assert("call_to_complexity",
754 
755  switch (value_tag(v)) {
756  case is_value_code: {
757  complexity compcallee;
758 
759  /* The only case that hash_callee_to_complexity is used */
761  (char *) f);
762  if ( compcallee == COMPLEXITY_NOT_FOUND )
763  user_error("call_to_complexity", "unknown complexity\n");
764  /* transform formal params into real ones */
765  comp = replace_formal_parameters_by_real_ones(compcallee,
766  f, args,
767  precond,
768  effects_list);
769  break;
770  }
771  case is_value_symbolic:
772  case is_value_constant:
773  if ( !type_statement_p(t) ) /* if not format case */
774  *pbasic = entity_basic(f);
775  comp = make_zero_complexity();
776  break;
777  case is_value_intrinsic:
778  comp = arguments_to_complexity(args, pbasic, precond, effects_list);
779  complexity_float_add(&comp, (float) intrinsic_cost(name, pbasic));
780  break;
781  case is_value_unknown:
782  user_error("call_to_complexity", "unknown value");
783  default:
784  pips_internal_error("value_tag is %d not in 37->41", (int)value_tag(v));
785  }
786 
787  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
788  fprintf(stderr, "call '%s': ", name);
789  complexity_fprint(stderr, comp, false, true);
790  fprintf(stderr, "call comp is at %p\n", comp);
791  }
792  complexity_check_and_warn("call_to_complexity", comp);
793 
794  trace_off();
795  return(comp);
796 }
void complexity_float_add(complexity *pcomp, float f)
Add a floating point digit to the complexity May 3, 91.
Definition: comp_math.c:480
complexity replace_formal_parameters_by_real_ones(complexity comp, entity mod, list args, transformer precond, list effects_list)
transform formal params into real ones (args) in complexity comp
Definition: comp_math.c:519
complexity arguments_to_complexity(list exprlist, basic *pbasic, transformer precond, list effects_list)
2nd element of call
Definition: comp_scan.c:804
int intrinsic_cost(char *s, basic *pargsbasic) const
Return the cost of the intrinsic named s, knowing that the "basic" type of its biggest argument is *p...
Definition: comp_util.c:617
#define COMPLEXITY_NOT_FOUND
struct _newgen_struct_complexity_ * complexity
Definition: complexity_ri.h:30
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
#define pips_internal_error
Definition: misc-local.h:149
#define user_error(fn,...)
Definition: misc-local.h:265
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
#define type_functional_p(x)
Definition: ri.h:2950
#define value_tag(x)
Definition: ri.h:3064
#define call_function(x)
Definition: ri.h:709
#define type_statement_p(x)
Definition: ri.h:2941
@ is_value_intrinsic
Definition: ri.h:3034
@ is_value_unknown
Definition: ri.h:3035
@ is_value_constant
Definition: ri.h:3033
@ is_value_code
Definition: ri.h:3031
@ is_value_symbolic
Definition: ri.h:3032
#define type_void_p(x)
Definition: ri.h:2959
#define call_arguments(x)
Definition: ri.h:711
#define entity_type(x)
Definition: ri.h:2792

References arguments_to_complexity(), call_arguments, call_function, complexity_check_and_warn(), complexity_float_add(), complexity_fprint(), COMPLEXITY_NOT_FOUND, entity_basic(), entity_initial, entity_name, entity_type, f(), fprintf(), get_bool_property(), hash_callee_to_complexity, hash_get(), intrinsic_cost(), is_value_code, is_value_constant, is_value_intrinsic, is_value_symbolic, is_value_unknown, make_zero_complexity(), module_local_name(), pips_assert, pips_internal_error, replace_formal_parameters_by_real_ones(), trace_off(), trace_on(), type_functional_p, type_statement_p, type_void_p, user_error, and value_tag.

Referenced by instruction_to_complexity(), and syntax_to_complexity().

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

◆ call_to_polynome()

complexity call_to_polynome ( call  call_instr,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)

3rd element of syntax

For the moment, we don't want to evaluate the complexity of the

function defined by the users

Parameters
call_instrall_instr
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 369 of file comp_expr_to_pnome.c.

375 {
376  entity f = call_function(call_instr);
377  const char *name = module_local_name(f);
378  list args = call_arguments(call_instr);
379  type t = entity_type(f);
380  value v = entity_initial(f);
382 
383  trace_on("CALL '%s' -> pnome", name);
384 
385  if (!type_functional_p(t) ||
387  pips_internal_error("'%s' isn't an expected entity (type %d, value %d)",
388  type_tag(t), value_tag(v), name);
389 
390  switch (value_tag(v)) {
391  case is_value_code:
392  /* For the moment, we don't want to evaluate the complexity of the */
393  break; /* function defined by the users */
394  case is_value_constant:
396  break;
397  case is_value_intrinsic:
399  comp = plus_op_handler(args, precond, effects_list, keep_symbols, maximize);
400  else if (same_string_p(name, MINUS_OPERATOR_NAME))
401  comp = minus_op_handler(args, precond, effects_list, keep_symbols, maximize);
402  else if (same_string_p(name, MULTIPLY_OPERATOR_NAME))
403  comp = multiply_op_handler(args, precond, effects_list, keep_symbols, maximize);
404  else if (same_string_p(name, DIVIDE_OPERATOR_NAME))
405  comp = divide_op_handler(args, precond, effects_list, keep_symbols, maximize);
406  else if (same_string_p(name, POWER_OPERATOR_NAME))
407  comp = power_op_handler(args, precond, effects_list, keep_symbols, maximize);
409  comp = unary_minus_op_handler(args, precond, effects_list, keep_symbols, maximize);
410  else if (same_string_p(name, FIELD_OPERATOR_NAME))
411  comp = field_op_handler(args, precond, effects_list, keep_symbols, maximize);
412  else
413  pips_user_warning("operator '%s' skipped\n",name);
414  break;
415 
416  default:
417  pips_internal_error("not handled case");
418  }
419 
420  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
421  fprintf(stderr, "call->pnome '%s': ", name);
422  complexity_fprint(stderr, comp, true, true);
423  }
424 
425  trace_off();
426  return (comp);
427 }
complexity divide_op_handler(list args, transformer precond, list effects_list, bool keep_symbols, int maximize)
complexity plus_op_handler(list args, transformer precond, list effects_list, bool keep_symbols, int maximize)
complexity minus_op_handler(list args, transformer precond, list effects_list, bool keep_symbols, int maximize)
complexity multiply_op_handler(list args, transformer precond, list effects_list, bool keep_symbols, int maximize)
complexity unary_minus_op_handler(list args, transformer precond, list effects_list, bool keep_symbols, int maximize)
complexity field_op_handler(list args, transformer precond, list effects_list, bool keep_symbols, int maximize)
complexity power_op_handler(list args, transformer precond, list effects_list, bool keep_symbols, int maximize)
float constant_entity_to_float(entity e)
Return if possible the value of e in a float.
Definition: comp_util.c:664
#define pips_user_warning
Definition: misc-local.h:146
#define same_string_p(s1, s2)
#define POWER_OPERATOR_NAME
#define MINUS_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define FIELD_OPERATOR_NAME
Definition: ri-util-local.h:91
#define DIVIDE_OPERATOR_NAME
#define UNARY_MINUS_OPERATOR_NAME
#define MULTIPLY_OPERATOR_NAME
#define value_code_p(x)
Definition: ri.h:3065
#define value_intrinsic_p(x)
Definition: ri.h:3074
#define type_tag(x)
Definition: ri.h:2940
#define value_constant_p(x)
Definition: ri.h:3071

References call_arguments, call_function, complexity_float_add(), complexity_fprint(), constant_entity_to_float(), divide_op_handler(), DIVIDE_OPERATOR_NAME, entity_initial, entity_type, f(), field_op_handler(), FIELD_OPERATOR_NAME, fprintf(), get_bool_property(), is_value_code, is_value_constant, is_value_intrinsic, make_zero_complexity(), minus_op_handler(), MINUS_OPERATOR_NAME, module_local_name(), multiply_op_handler(), MULTIPLY_OPERATOR_NAME, pips_internal_error, pips_user_warning, plus_op_handler(), PLUS_OPERATOR_NAME, power_op_handler(), POWER_OPERATOR_NAME, same_string_p, trace_off(), trace_on(), type_functional_p, type_tag, unary_minus_op_handler(), UNARY_MINUS_OPERATOR_NAME, value_code_p, value_constant_p, value_intrinsic_p, and value_tag.

Referenced by syntax_to_polynome().

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

◆ cast_to_polynome()

complexity cast_to_polynome ( cast  cast_instr,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)

4th element of syntax : Molka Becher

Parameters
cast_instrast_instr
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 429 of file comp_expr_to_pnome.c.

435 {
436  expression exp = cast_expression(cast_instr);
437 
438  trace_on("CAST");
439 
440  complexity comp = expression_to_complexity_polynome(exp, precond, effects_list,
441  keep_symbols, maximize);
442 
443  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
444  fprintf(stderr, "cast->pnome");
445  complexity_fprint(stderr, comp, true, true);
446  }
447 
448  trace_off();
449  return (comp);
450 }
complexity expression_to_complexity_polynome(expression expr, transformer precond, list effects_list, bool keep_symbols, int maximize)
Entry point routine of this file:
#define cast_expression(x)
Definition: ri.h:747
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References cast_expression, complexity_fprint(), exp, expression_to_complexity_polynome(), fprintf(), get_bool_property(), trace_off(), and trace_on().

Referenced by syntax_to_polynome().

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

◆ complexity_add()

void complexity_add ( complexity pcomp1,
complexity  comp2 
)

void complexity_add(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 + comp2; !usage: complexity_add(&comp1, comp2); comp2 keeps unchanged

Parameters
pcomp1comp1
comp2omp2

Definition at line 372 of file comp_math.c.

374 {
375  if ( COMPLEXITY_UNDEFINED_P(comp2) || COMPLEXITY_UNDEFINED_P(*pcomp1) )
376  pips_internal_error("complexity undefined");
377 
378  if ( complexity_zero_p(*pcomp1) ) {
379  *pcomp1 = complexity_dup(comp2);
380  }
381  else if ( !complexity_zero_p(comp2) ) {
382  complexity_eval_(*pcomp1) =
384  complexity_eval(comp2)));
385  complexity_stats_add(pcomp1, comp2);
386  }
387 }
void complexity_stats_add(complexity *pcomp1, complexity comp2)
Add comp2's statistics to *pcomp1's comp2 keeps unchanged.
Definition: comp_math.c:323
bool complexity_zero_p(complexity comp)
zero complexity check.
Definition: comp_math.c:244
complexity complexity_dup(complexity comp)
duplicates complexity comp
Definition: comp_util.c:131
#define COMPLEXITY_UNDEFINED_P(c)
#define complexity_eval(x)
Definition: complexity_ri.h:92
#define complexity_eval_(x)
Definition: complexity_ri.h:91
#define newgen_Ppolynome(p)
Definition: complexity_ri.h:19
Ppolynome polynome_addition(Ppolynome pp, Ppolynome pp2)
Ppolynome polynome_addition(Ppolynome pp, Ppolynome pp2) pp = pp + pp2.
Definition: pnome-bin.c:195

References complexity_dup(), complexity_eval, complexity_eval_, complexity_stats_add(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), newgen_Ppolynome, pips_internal_error, and polynome_addition().

Referenced by arguments_to_complexity(), block_to_complexity(), field_op_handler(), indices_to_complexity(), new_block_to_complexity(), plus_op_handler(), pvecteur_to_polynome(), range_to_complexity(), reference_to_complexity(), simplify_sc_to_complexity(), subscript_to_complexity(), syntax_to_complexity(), test_to_complexity(), unstructured_to_complexity(), and whileloop_to_complexity().

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

◆ complexity_check()

bool complexity_check ( complexity  comp)

comp_util.c

comp_util.c

Parameters
compomp

Definition at line 96 of file comp_util.c.

98 {
99  if ( COMPLEXITY_UNDEFINED_P(comp) )
100  pips_internal_error("complexity undefined");
101 
102  if ( !complexity_zero_p(comp) ) {
103  return (polynome_check(complexity_polynome(comp)));
104  }
105  return (true);
106 }
bool polynome_check(Ppolynome pp)
bool polynome_check(Ppolynome pp) Return true if all's right.
Definition: pnome-error.c:131

References complexity_polynome(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), pips_internal_error, and polynome_check().

Referenced by complexity_check_and_warn(), and good_complexity_assert().

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

◆ complexity_check_and_warn()

void complexity_check_and_warn ( const char *  ,
complexity   
)

◆ complexity_constant_p()

bool complexity_constant_p ( complexity  comp)

true if comp is constant.

Abort if undefined

Parameters
compomp

Definition at line 256 of file comp_math.c.

258 {
259  if ( COMPLEXITY_UNDEFINED_P(comp) )
260  pips_internal_error("undefined complexity");
261 
262  if ( complexity_zero_p(comp) )
263  return (true);
264  else
265  return (polynome_constant_p(complexity_eval(comp)));
266 }
bool polynome_constant_p(Ppolynome pp)
bool polynome_constant_p(Ppolynome pp) return true if pp is a constant polynomial (including null pol...
Definition: pnome-reduc.c:180

References complexity_eval, COMPLEXITY_UNDEFINED_P, complexity_zero_p(), pips_internal_error, and polynome_constant_p().

Referenced by divide_op_handler(), loop_to_complexity(), and power_op_handler().

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

◆ complexity_degree()

int complexity_degree ( complexity  c)

Definition at line 1167 of file comp_util.c.

1168 {
1169  Ppolynome p = complexity_eval(c);
1170  int degree = polynome_max_degree(p);
1171 
1172  return degree;
1173 }
int polynome_max_degree(Ppolynome pp)
int polynome_max_degree(Ppolynome pp) returns the degree of polynomial pp Let's hope there aren't too...
Definition: pnome-reduc.c:113

References complexity_eval, and polynome_max_degree().

Referenced by loop_to_complexity().

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

◆ complexity_div()

void complexity_div ( complexity pcomp1,
complexity  comp2 
)

void complexity_div(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 / comp2; !usage: complexity_div(&comp1, comp2);

polynome_rm(&(complexity_eval(*pcomp1)));

Parameters
pcomp1comp1
comp2omp2

Definition at line 445 of file comp_math.c.

447 {
448  if ( COMPLEXITY_UNDEFINED_P(comp2) || COMPLEXITY_UNDEFINED_P(*pcomp1) )
449  pips_internal_error("complexity undefined");
450 
451  if ( complexity_zero_p(comp2) ) {
452  pips_internal_error("complexity divider is zero");
453  }
454  else if ( !complexity_zero_p(*pcomp1) ) {
455  Ppolynome ppdiv;
456  ppdiv = polynome_div(complexity_eval(*pcomp1), complexity_eval(comp2));
457 /* polynome_rm(&(complexity_eval(*pcomp1))); */
458  complexity_eval_(*pcomp1) = newgen_Ppolynome(ppdiv);
459  complexity_stats_add(pcomp1, comp2);
460  }
461 }
Ppolynome polynome_div(Ppolynome pp1, Ppolynome pp2)
Ppolynome polynome_div(Ppolynome pp1, Ppolynome pp2) returns p = pp1 / pp2.
Definition: pnome-bin.c:381

References complexity_eval, complexity_eval_, complexity_stats_add(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), newgen_Ppolynome, pips_internal_error, and polynome_div().

Referenced by loop_to_complexity().

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

◆ complexity_dump()

void complexity_dump ( complexity  comp)
Parameters
compomp

Definition at line 228 of file comp_util.c.

229 {
230  complexity_fprint(stderr, comp, false, true);
231 }

References complexity_fprint().

+ Here is the call graph for this function:

◆ complexity_dup()

complexity complexity_dup ( complexity  comp)

duplicates complexity comp

Parameters
compomp

Definition at line 131 of file comp_util.c.

133 {
134  if ( COMPLEXITY_UNDEFINED_P(comp) )
135  pips_internal_error("complexity undefined");
136 
137  if ( complexity_zero_p(comp) )
138  return (make_zero_complexity());
139  else {
140  varcount vc = complexity_varcount(comp);
142  ifcount ic = complexity_ifcount(comp);
143 
145  varcount_guessed(vc),
146  varcount_bounded(vc),
147  varcount_unknown(vc));
149  rangecount_guessed(rc),
150  rangecount_bounded(rc),
151  rangecount_unknown(rc));
153  ifcount_computed(ic),
154  ifcount_halfhalf(ic));
155 
157  complexity compl = make_complexity(ppdup, newvc, newrc, newic);
158 
159  return(compl);
160  }
161 }
rangecount make_rangecount(intptr_t a1, intptr_t a2, intptr_t a3, intptr_t a4)
varcount make_varcount(intptr_t a1, intptr_t a2, intptr_t a3, intptr_t a4)
ifcount make_ifcount(intptr_t a1, intptr_t a2, intptr_t a3)
Definition: complexity_ri.c:96
complexity make_complexity(Ppolynome a1, varcount a2, rangecount a3, ifcount a4)
Definition: complexity_ri.c:54
#define ifcount_computed(x)
#define rangecount_unknown(x)
#define varcount_guessed(x)
#define complexity_ifcount(x)
Definition: complexity_ri.h:98
#define ifcount_profiled(x)
#define complexity_varcount(x)
Definition: complexity_ri.h:94
#define complexity_rangecount(x)
Definition: complexity_ri.h:96
#define rangecount_guessed(x)
#define varcount_symbolic(x)
#define varcount_unknown(x)
#define varcount_bounded(x)
#define rangecount_profiled(x)
#define ifcount_halfhalf(x)
#define rangecount_bounded(x)
Ppolynome polynome_dup(Ppolynome pp)
Ppolynome polynome_dup(Ppolynome pp) creates and returns a copy of pp.
Definition: pnome-alloc.c:211

References complexity_ifcount, complexity_polynome(), complexity_rangecount, COMPLEXITY_UNDEFINED_P, complexity_varcount, complexity_zero_p(), ifcount_computed, ifcount_halfhalf, ifcount_profiled, make_complexity(), make_ifcount(), make_rangecount(), make_varcount(), make_zero_complexity(), pips_internal_error, polynome_dup(), rangecount_bounded, rangecount_guessed, rangecount_profiled, rangecount_unknown, varcount_bounded, varcount_guessed, varcount_symbolic, and varcount_unknown.

Referenced by complexity_add(), complexity_stats_add(), complexity_sub(), final_statement_to_complexity_evaluation(), replace_formal_parameters_by_real_ones(), test_to_complexity(), and translate_complexity_from_local_to_current_name().

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

◆ complexity_float_add()

void complexity_float_add ( complexity ,
double   
)

◆ complexity_fprint()

void complexity_fprint ( FILE *  fd,
complexity  comp,
bool  print_stats_p,
bool  print_local_names_p 
)
Parameters
fdd
compomp
print_stats_print_stats_p
print_local_names_print_local_names_p

Definition at line 217 of file comp_util.c.

221 {
222  char *s = complexity_sprint(comp, print_stats_p, print_local_names_p);
223 
224  fprintf(fd, "%s\n", s);
225  free(s);
226 }
char * complexity_sprint(complexity comp, bool print_stats_p, bool print_local_names_p)
Definition: comp_util.c:175
void free(void *)

References complexity_sprint(), fprintf(), and free().

Referenced by arguments_to_complexity(), block_to_complexity(), call_to_complexity(), call_to_polynome(), cast_to_polynome(), complexity_dump(), complexity_var_subst(), controls_to_hash_table(), expression_to_complexity_polynome(), fetch_callees_complexities(), final_statement_to_complexity_evaluation(), fprint_statement_complexity(), loop_to_complexity(), prc(), range_to_complexity(), reference_to_complexity(), statement_to_complexity(), test_to_complexity(), unstructured_to_complexity(), and whileloop_to_complexity().

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

◆ complexity_is_monomial_p()

bool complexity_is_monomial_p ( complexity  c)

Definition at line 1159 of file comp_util.c.

1160 {
1161  Ppolynome p = complexity_eval(c);
1162  bool monomial_p = is_single_monome(p);
1163 
1164  return monomial_p;
1165 }
#define is_single_monome(pp)

References complexity_eval, and is_single_monome.

Referenced by loop_to_complexity().

+ Here is the caller graph for this function:

◆ complexity_map_undefined_p()

bool complexity_map_undefined_p ( void  )

◆ complexity_mult()

void complexity_mult ( complexity pcomp1,
complexity  comp2 
)

void complexity_mult(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 * comp2; !usage: complexity_mult(&comp1, comp2);

(Ppolynome) complexity_eval(*pcomp1) = (Ppolynome) ppmult;

Parameters
pcomp1comp1
comp2omp2

Definition at line 418 of file comp_math.c.

420 {
421  if ( COMPLEXITY_UNDEFINED_P(comp2) || COMPLEXITY_UNDEFINED_P(*pcomp1) )
422  pips_internal_error("complexity undefined");
423 
424  if ( complexity_zero_p(comp2) ) {
425  complexity_rm(pcomp1);
426  *pcomp1 = make_zero_complexity();
427  }
428  else if ( !complexity_zero_p(*pcomp1) ) {
429  Ppolynome ppmult;
430 
431  ppmult = polynome_mult(complexity_eval(*pcomp1),
432  complexity_eval(comp2));
433  complexity_eval_(*pcomp1) =
435  /* (Ppolynome) complexity_eval(*pcomp1) = (Ppolynome) ppmult; */
436  complexity_eval_(*pcomp1) = newgen_Ppolynome(ppmult);
437  complexity_stats_add(pcomp1, comp2);
438  }
439 }
void complexity_rm(complexity *pcomp)
remove complexity comp
Definition: comp_util.c:164
Ppolynome polynome_free(Ppolynome pp)
Ppolynome polynome_free(Ppolynome pp) frees space occupied by polynomial pp returns pp == POLYNOME_NU...
Definition: pnome-alloc.c:191
Ppolynome polynome_mult(Ppolynome pp1, Ppolynome pp2)
Ppolynome polynome_mult(Ppolynome pp1, Ppolynome pp2) returns pp1 * pp2.
Definition: pnome-bin.c:287

References complexity_eval, complexity_eval_, complexity_rm(), complexity_stats_add(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), make_zero_complexity(), newgen_Ppolynome, pips_internal_error, polynome_free(), and polynome_mult().

Referenced by complexity_sigma(), divide_op_handler(), multiply_op_handler(), and whileloop_to_complexity().

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

◆ complexity_polynome()

Ppolynome complexity_polynome ( complexity  comp)

Because complexity is composed of two elements, we use this function to get the first element : polynome Usage : complexity_polynome(complexity comp) you will get a pointer to the polynome May 3, 91 lz.

Parameters
compomp

Definition at line 506 of file comp_math.c.

508 {
509  if ( COMPLEXITY_UNDEFINED_P(comp) )
510  pips_internal_error("complexity undefined");
511 
512  if ( complexity_zero_p(comp) )
513  return (POLYNOME_NUL);
514  else
515  return ((Ppolynome)complexity_eval(comp));
516 }
#define POLYNOME_NUL

References complexity_eval, COMPLEXITY_UNDEFINED_P, complexity_zero_p(), pips_internal_error, and POLYNOME_NUL.

Referenced by block_to_complexity(), complexity_check(), complexity_dup(), complexity_sigma(), complexity_sprint(), complexity_var_subst(), do_computation_intensity(), final_statement_to_complexity_evaluation(), if_conv_init_statement(), loop_to_complexity(), power_op_handler(), task_time(), and translate_complexity_from_local_to_current_name().

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

◆ complexity_polynome_add()

void complexity_polynome_add ( complexity pcomp,
Ppolynome  pp 
)
Parameters
pcompcomp
ppp

Definition at line 463 of file comp_math.c.

466 {
467  if ( COMPLEXITY_UNDEFINED_P(*pcomp) )
468  pips_internal_error("complexity undefined");
469  else if ( POLYNOME_UNDEFINED_P(pp) )
470  pips_internal_error("polynome undefined");
471  else {
472  complexity_eval_(*pcomp) =
474  }
475 }
#define POLYNOME_UNDEFINED_P(pp)

References complexity_eval, complexity_eval_, COMPLEXITY_UNDEFINED_P, newgen_Ppolynome, pips_internal_error, polynome_addition(), and POLYNOME_UNDEFINED_P.

Referenced by loop_to_complexity(), and pvecteur_to_polynome().

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

◆ complexity_rm()

void complexity_rm ( complexity pcomp)

remove complexity comp

Parameters
pcompcomp

Definition at line 164 of file comp_util.c.

166 {
167  if ( COMPLEXITY_UNDEFINED_P(*pcomp) )
168  pips_internal_error("undefined complexity");
169 
170  if ( !complexity_zero_p(*pcomp) )
171  free_complexity(*pcomp);
172  *pcomp = make_zero_complexity();// complexity_undefined;
173 }
void free_complexity(complexity p)
Definition: complexity_ri.c:21

References COMPLEXITY_UNDEFINED_P, complexity_zero_p(), free_complexity(), make_zero_complexity(), and pips_internal_error.

Referenced by complexity_mult(), complexity_scalar_mult(), divide_op_handler(), field_op_handler(), indices_to_complexity(), loop_to_complexity(), minus_op_handler(), multiply_op_handler(), plus_op_handler(), power_op_handler(), range_to_complexity(), reference_to_complexity(), replace_formal_parameters_by_real_ones(), simplify_sc_to_complexity(), subscript_to_complexity(), syntax_to_complexity(), test_to_complexity(), and unary_minus_op_handler().

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

◆ complexity_scalar_mult()

void complexity_scalar_mult ( complexity ,
double   
)

◆ complexity_sigma()

complexity complexity_sigma ( complexity  comp,
Variable  index,
complexity  clower,
complexity  cupper 
)

comp_math.c

"mathematical" operations on complexities

complexity complexity_sigma(comp, index, clower, cupper) complexity_var_subst(comp, var, compsubst) complexity polynome_to_new_complexity(pp) complexity complexity_dup(comp) void complexity_rm(pcomp) complexity make_single_var_complexity(float, var) bool complexity_constant_p(comp) float complexity_TCST(comp) void complexity_scalar_mult(pcomp, f) void complexity_float_add(pcomp, f) void complexity_stats_add(pcomp1, comp2) void complexity_add(pcomp1, comp2) void complexity_sub(pcomp1, comp2) void complexity_mult(pcomp1, comp2) void complexity_polynome_add(pcomp, pp) Ppolynome complexity_polynome(comp) complexity replace_formal_parameters_by_real_ones(comp, mod, args, precond) Modif: – entity_local_name is replaced by module_local_name. LZ 230993 complexity complexity_sigma(complexity comp, Variable index, complexity clower, cupper) return the integration of complexity comp when the index is running between clower and cupper. Based on the polynomial library routine polynome_sigma.

  • comp is undefined => result undefined.
  • comp is null => result is null whatever the bounds are.
  • bound(s) is(are) undefined: if comp depends on the index, the result is undefined; else the result is comp * UNKNOWN_RANGE.
  • everything is defined: the result is the integration of the respective polynomials.

FI: Too late to build a meaningful unknown range name!

tats

Parameters
compomp
indexndex
clowerlower
cupperupper

Definition at line 84 of file comp_math.c.

88 {
89  complexity cresult = make_zero_complexity();
90  Ppolynome ppsum;
91  Ppolynome pplower = POLYNOME_NUL;
92  Ppolynome ppupper = POLYNOME_NUL;
93 
94  if (COMPLEXITY_UNDEFINED_P(comp))
95  pips_internal_error("complexity undefined");
96 
97  if (complexity_zero_p(comp))
98  return (cresult);
99  else if ( COMPLEXITY_UNDEFINED_P(clower) ||
100  COMPLEXITY_UNDEFINED_P(cupper) ) {
102  (Variable)index) )
103  return (cresult);
104  else {
105  /* FI: Too late to build a meaningful unknown range name! */
106  /*
107  ppsum = make_polynome(1.0, UNKNOWN_RANGE, 1);
108  */
114  ppsum = make_polynome(1.0, (Variable) ur, VALUE_ONE);
115  cresult = polynome_to_new_complexity(ppsum); /*stats*/
116  complexity_mult(&cresult, comp);
117 
118  polynome_rm(&ppsum);
119  return(cresult);
120  }
121  }
122  else {
123  pplower = complexity_polynome(clower);
124  ppupper = complexity_polynome(cupper);
125 
126  if (false) {
127  fprintf(stderr, "summing ");
128  prp(complexity_polynome(comp));
129  fprintf(stderr, " %s running between ",
130  module_local_name((entity)index));
131  prp(pplower);
132  fprintf(stderr, " and ");
133  prp(ppupper);
134  fprintf(stderr, "\n");
135  }
136 
137  ppsum = polynome_sigma(complexity_polynome(comp),
138  (Variable) index,
139  pplower, ppupper);
140  cresult = polynome_to_new_complexity(ppsum);
141  complexity_stats_add(&cresult, comp);
142  complexity_stats_add(&cresult, clower);
143  complexity_stats_add(&cresult, cupper);
144 
145  polynome_rm(&ppsum);
146  return(cresult);
147  }
148 }
#define VALUE_ONE
void complexity_mult(complexity *pcomp1, complexity comp2)
void complexity_mult(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 * comp2; !...
Definition: comp_math.c:418
complexity polynome_to_new_complexity(Ppolynome pp)
Create a complexity equal to Ppolynome pp with null statistics.
Definition: comp_math.c:200
void prp(Ppolynome pp)
Definition: comp_util.c:239
#define UNKNOWN_RANGE_NAME
pseudo-variable for default iteration number of a loop
Ppolynome make_polynome(float coeff, Variable var, Value expo)
Ppolynome make_polynome(float coeff, Variable var, Value expo) PRIVATE allocates space for,...
Definition: pnome-alloc.c:100
void polynome_rm(Ppolynome *ppp)
void polynome_rm(Ppolynome* ppp) frees space occupied by polynomial *ppp returns *ppp pointing to POL...
Definition: pnome-alloc.c:170
bool polynome_contains_var(Ppolynome pp, Variable var)
bool polynome_contains_var(Ppolynome pp, Variable var) PRIVATE returns true if variable var is in pol...
Definition: pnome-reduc.c:238
Ppolynome polynome_sigma(Ppolynome pp, Variable var, Ppolynome ppinf, Ppolynome ppsup)
Ppolynome polynome_sigma(Ppolynome pp, Variable var, Ppolynome ppinf, ppsup) returns the sum of pp wh...
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
void AddEntityToCurrentModule(entity)
Add a variable entity to the current module declarations.
Definition: variable.c:260
entity make_new_scalar_variable_with_prefix(const char *, entity, basic)
Create a new scalar variable of type b in the given module.
Definition: variable.c:592
@ is_basic_int
Definition: ri.h:571
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References AddEntityToCurrentModule(), complexity_mult(), complexity_polynome(), complexity_stats_add(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), fprintf(), get_current_module_entity(), is_basic_int, make_new_scalar_variable_with_prefix(), make_polynome(), make_zero_complexity(), MakeBasic(), module_local_name(), pips_internal_error, polynome_contains_var(), POLYNOME_NUL, polynome_rm(), polynome_sigma(), polynome_to_new_complexity(), prp(), UNKNOWN_RANGE_NAME, and VALUE_ONE.

Referenced by loop_to_complexity().

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

◆ complexity_sprint()

char* complexity_sprint ( complexity  comp,
bool  print_stats_p,
bool  print_local_names_p 
)
Parameters
compomp
print_stats_print_stats_p
print_local_names_print_local_names_p

Definition at line 175 of file comp_util.c.

178 {
179 
180  char *s=NULL;
181 
182  if ( COMPLEXITY_UNDEFINED_P(comp) )
183  pips_internal_error("complexity undefined");
184  else {
185  varcount vc = complexity_varcount(comp);
187  ifcount ic = complexity_ifcount(comp);
188 
189  char * p = polynome_sprint(complexity_polynome(comp),
190  (print_local_names_p ? variable_local_name
191  : variable_name),
193 
194  if ( print_stats_p ) {
195  asprintf(&s,"[(var:%td/%td/%td/%td)"
196  " (rng:%td/%td/%td/%td)"
197  " (ifs:%td/%td/%td)] %s",
198  varcount_symbolic(vc),
199  varcount_guessed(vc),
200  varcount_bounded(vc),
201  varcount_unknown(vc),
203  rangecount_guessed(rc),
204  rangecount_bounded(rc),
205  rangecount_unknown(rc),
206  ifcount_profiled(ic),
207  ifcount_computed(ic),
208  ifcount_halfhalf(ic),p);
209  free(p);
210  }
211  else
212  s=p;
213  }
214  return s;
215 }
char * variable_local_name(Variable)
Definition: polynome_ri.c:95
int is_inferior_pvarval(Pvecteur *, Pvecteur *)
Definition: polynome_ri.c:149
#define asprintf
Definition: misc-local.h:225
char * polynome_sprint(Ppolynome pp, char *(*variable_name)(Variable), int *is_inferior_var)
char polynome_sprint(Ppolynome pp, char (*variable_name)(), bool (*is_inferior_var)()) Outputs to fil...
Definition: pnome-io.c:197
char * variable_name(Variable v)
polynome_ri.c
Definition: polynome_ri.c:73

References asprintf, complexity_ifcount, complexity_polynome(), complexity_rangecount, COMPLEXITY_UNDEFINED_P, complexity_varcount, free(), ifcount_computed, ifcount_halfhalf, ifcount_profiled, is_inferior_pvarval(), pips_internal_error, polynome_sprint(), rangecount_bounded, rangecount_guessed, rangecount_profiled, rangecount_unknown, varcount_bounded, varcount_guessed, varcount_symbolic, varcount_unknown, variable_local_name(), and variable_name().

Referenced by complexity_fprint(), task_complexity(), task_time_polynome(), text_complexity(), and text_summary_complexity().

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

◆ complexity_stats_add()

void complexity_stats_add ( complexity pcomp1,
complexity  comp2 
)

Add comp2's statistics to *pcomp1's comp2 keeps unchanged.

Parameters
pcomp1comp1
comp2omp2

Definition at line 323 of file comp_math.c.

325 {
326  ifdebug (1) {
327  (void) complexity_consistent_p(*pcomp1);
328  (void) complexity_consistent_p(comp2);
329  }
330 
331  if ( COMPLEXITY_UNDEFINED_P(comp2) || COMPLEXITY_UNDEFINED_P(*pcomp1) )
332  pips_internal_error("complexity undefined");
333 
334  if ( complexity_zero_p(*pcomp1) ) {
335  *pcomp1 = complexity_dup(comp2);
336  complexity_eval_(*pcomp1) =
338  }
339  else if ( !complexity_zero_p(comp2) ) {
340  varcount vc1 = complexity_varcount(*pcomp1);
341  rangecount rc1 = complexity_rangecount(*pcomp1);
342  ifcount ic1 = complexity_ifcount(*pcomp1);
343  varcount vc2 = complexity_varcount(comp2);
344  rangecount rc2 = complexity_rangecount(comp2);
345  ifcount ic2 = complexity_ifcount(comp2);
346 
348  varcount_guessed(vc1) += varcount_guessed(vc2);
349  varcount_bounded(vc1) += varcount_bounded(vc2);
350  varcount_unknown(vc1) += varcount_unknown(vc2);
351 
356 
357  ifcount_profiled(ic1) += ifcount_profiled(ic2);
358  ifcount_computed(ic1) += ifcount_computed(ic2);
359  ifcount_halfhalf(ic1) += ifcount_halfhalf(ic2);
360  }
361 
362  ifdebug (1) {
363  (void) complexity_consistent_p(*pcomp1);
364  }
365 }

References complexity_consistent_p(), complexity_dup(), complexity_eval, complexity_eval_, complexity_ifcount, complexity_rangecount, COMPLEXITY_UNDEFINED_P, complexity_varcount, complexity_zero_p(), ifcount_computed, ifcount_halfhalf, ifcount_profiled, ifdebug, newgen_Ppolynome, pips_internal_error, polynome_free(), rangecount_bounded, rangecount_guessed, rangecount_profiled, rangecount_unknown, varcount_bounded, varcount_guessed, varcount_symbolic, and varcount_unknown.

Referenced by complexity_add(), complexity_div(), complexity_mult(), complexity_sigma(), complexity_sub(), complexity_var_subst(), and loop_to_complexity().

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

◆ complexity_sub()

void complexity_sub ( complexity pcomp1,
complexity  comp2 
)

void complexity_sub(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 - comp2; !usage: complexity_sub(&comp1, comp2); comp2 keeps unchanged

Parameters
pcomp1comp1
comp2omp2

Definition at line 394 of file comp_math.c.

396 {
397  if ( COMPLEXITY_UNDEFINED_P(comp2) || COMPLEXITY_UNDEFINED_P(*pcomp1) )
398  pips_internal_error("complexity undefined");
399 
400  if ( complexity_zero_p(*pcomp1) )
401  *pcomp1 = complexity_dup(comp2);
402  else if ( !complexity_zero_p(comp2) ) {
403  complexity_eval_(comp2) =
405  complexity_eval_(*pcomp1) =
407  complexity_eval(comp2)));
408  complexity_stats_add(pcomp1, comp2);
409  complexity_eval_(comp2) =
411  }
412 }
Ppolynome polynome_opposed(Ppolynome pp)
Ppolynome polynome_opposed(Ppolynome pp); changes sign of polynomial pp.
Definition: pnome-unaires.c:59

References complexity_dup(), complexity_eval, complexity_eval_, complexity_stats_add(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), newgen_Ppolynome, pips_internal_error, polynome_addition(), and polynome_opposed().

Referenced by minus_op_handler(), and unary_minus_op_handler().

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

◆ complexity_TCST()

float complexity_TCST ( complexity  comp)

return the constant term of comp.

Abort if undefined

Parameters
compomp

Definition at line 288 of file comp_math.c.

290 {
291  if ( COMPLEXITY_UNDEFINED_P(comp) )
292  pips_internal_error("undefined complexity");
293 
294  if ( complexity_zero_p(comp) )
295  return ((float) 0);
296  else
297  return (polynome_TCST(complexity_eval(comp)));
298 }
float polynome_TCST(Ppolynome pp)
float polynome_TCST(Ppolynome pp) returns the constant term of polynomial pp.
Definition: pnome-reduc.c:156

References complexity_eval, COMPLEXITY_UNDEFINED_P, complexity_zero_p(), pips_internal_error, and polynome_TCST().

Referenced by divide_op_handler(), loop_to_complexity(), and power_op_handler().

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

◆ complexity_unknown_p()

bool complexity_unknown_p ( complexity  comp)

true if comp is unknown.

Abort if undefined

FI: Management of unknown complexities, when polynomes are in fact used to represent the value of a variables or an expression, has to be revisited

Parameters
compomp

Definition at line 269 of file comp_math.c.

271 {
272  if ( COMPLEXITY_UNDEFINED_P(comp) )
273  pips_internal_error("undefined complexity");
274 
275  /* FI: Management of unknown complexities, when polynomes are in
276  fact used to represent the value of a variables or an expression,
277  has to be revisited */
278  /*
279  if ( polynome_contains_var((Ppolynome)complexity_eval(comp),
280  UNKNOWN_RANGE) )
281  return (true);
282  else
283  */
284  return (false);
285 }

References COMPLEXITY_UNDEFINED_P, and pips_internal_error.

Referenced by expression_to_complexity_polynome(), and loop_to_complexity().

+ Here is the caller graph for this function:

◆ complexity_var_subst()

complexity complexity_var_subst ( complexity  comp,
Variable  var,
complexity  compsubst 
)

complexity complexity_var_subst(comp, var, compsubst) replaces every occurrence of variable var in complexity comp by the polynomial of complexity compsubst.

The statistics of compsubst are added to those of comp.

substitutes

Parameters
compomp
varar
compsubstompsubst

Definition at line 155 of file comp_math.c.

159 {
160  Ppolynome pp, ppsubst, ppresult;
161  complexity cresult = make_zero_complexity();
162 
163  if (COMPLEXITY_UNDEFINED_P(comp) || COMPLEXITY_UNDEFINED_P(compsubst))
164  pips_internal_error("complexity undefined");
165 
166  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
167  fprintf(stderr,"complexity_var_subst, variable name=%s\n",
168  variable_name(var) );
169  }
170 
171  if (complexity_zero_p(comp))
172  return (cresult);
173  else {
174  pp = complexity_polynome(comp);
175  ppsubst = complexity_polynome(compsubst);
176 
177  ppresult = polynome_var_subst(pp, var, ppsubst); /* substitutes */
178 
179  cresult = polynome_to_new_complexity(ppresult);
180  complexity_stats_add(&cresult, compsubst);
181 
182  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
183  (void) complexity_consistent_p(cresult);
184  fprintf(stderr,"complexity_var_subst, comp is ");
185  complexity_fprint(stderr, comp, false, true);
186  fprintf(stderr,"complexity_var_subst, compsubst is ");
187  complexity_fprint(stderr, compsubst, false, true);
188  fprintf(stderr,"complexity_var_subst, cresult is ");
189  complexity_fprint(stderr, cresult, false, true);
190  }
191  }
192 
193  return(cresult);
194 }
Ppolynome polynome_var_subst(Ppolynome pp, Variable var, Ppolynome ppsubst)
Ppolynome polynome_var_subst(Ppolynome pp, Variable var, Ppolynome ppsubst) creates and returns a Ppo...
Definition: pnome-reduc.c:47

References complexity_consistent_p(), complexity_fprint(), complexity_polynome(), complexity_stats_add(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), fprintf(), get_bool_property(), make_zero_complexity(), pips_internal_error, polynome_to_new_complexity(), polynome_var_subst(), and variable_name().

Referenced by block_to_complexity(), new_block_to_complexity(), replace_formal_parameters_by_real_ones(), and translate_complexity_from_local_to_current_name().

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

◆ complexity_zero_p()

bool complexity_zero_p ( complexity  comp)

◆ constant_entity_to_float()

float constant_entity_to_float ( entity  e)

Return if possible the value of e in a float.

it is supposed to be an int or a float.

Definition at line 664 of file comp_util.c.

666 {
667  const char *cste = module_local_name(e);
668  basic b = entity_basic(e);
669  float f;
670 
671  if (basic_int_p(b) || basic_float_p(b)) {
672  sscanf(cste, "%f", &f);
673  return (f);
674  }
675  else {
676  user_warning("constant_entity_to_float",
677  "Basic tag:%d, not 4->9, (entity %s)\n",basic_tag(b),cste);
678  return (0.0);
679  }
680 }
#define user_warning(fn,...)
Definition: misc-local.h:262
#define basic_int_p(x)
Definition: ri.h:614
#define basic_tag(x)
Definition: ri.h:613
#define basic_float_p(x)
Definition: ri.h:617

References basic_float_p, basic_int_p, basic_tag, entity_basic(), f(), module_local_name(), and user_warning.

Referenced by call_to_polynome().

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

◆ control_element_position_in_control_array()

int control_element_position_in_control_array ( control  ,
control  [],
int   
)

◆ controls_to_hash_table()

void controls_to_hash_table ( control  ,
int ,
control  [],
hash_table  ,
transformer  ,
list   
)

◆ delete_statement_complexity()

void delete_statement_complexity ( statement  )

◆ divide_op_handler()

complexity divide_op_handler ( list  args,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)
Parameters
argsrgs
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 560 of file comp_expr_to_pnome.c.

566 {
567  float denominateur;
569  precond, effects_list, keep_symbols,
570  maximize);
572  precond, effects_list, DONT_KEEP_SYMBOLS,
573  -maximize);
574  if (complexity_constant_p(c2)) {
575  denominateur = complexity_TCST(c2);
576  if (denominateur == 0)
577  user_error("divide_op_handler", "division by zero\n");
578  else
579  complexity_mult(&c1, make_constant_complexity(1.0/denominateur));
580  }
581  else {
582  complexity_rm(&c1);
583  }
584 
585  complexity_rm(&c2);
586  return (c1);
587 }
float complexity_TCST(complexity comp)
return the constant term of comp.
Definition: comp_math.c:288
bool complexity_constant_p(complexity comp)
true if comp is constant.
Definition: comp_math.c:256
complexity make_constant_complexity(float f)
make a constant complexity "f * TCST" with null statistics
Definition: comp_math.c:231
#define DONT_KEEP_SYMBOLS
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111

References CAR, CDR, complexity_constant_p(), complexity_mult(), complexity_rm(), complexity_TCST(), DONT_KEEP_SYMBOLS, EXPRESSION, expression_to_complexity_polynome(), make_constant_complexity(), and user_error.

Referenced by call_to_polynome().

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

◆ entity_list_reverse()

list entity_list_reverse ( list  l)

Definition at line 757 of file comp_util.c.

759 {
760  entity e;
761 
762  if ((l == NIL) || (l->cdr == NIL))
763  return l;
764  e = ENTITY(CAR(l));
765  return (CONS(ENTITY, e, entity_list_reverse(l->cdr)));
766 }
list entity_list_reverse(list l)
Definition: comp_util.c:757
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
struct cons * cdr
The pointer to the next element.
Definition: newgen_list.h:43

References CAR, CONS, ENTITY, and NIL.

◆ evaluate_var_to_complexity()

complexity evaluate_var_to_complexity ( entity  ,
transformer  ,
list  ,
int   
)

◆ expression_to_complexity()

complexity expression_to_complexity ( expression  expr,
basic pbasic,
transformer  precond,
list  effects_list 
)

2nd element of call –arguments

2nd element of reference –indices

Parameters
exprxpr
pbasicbasic
precondrecond
effects_listffects_list

Definition at line 838 of file comp_scan.c.

843 {
844  syntax s = expression_syntax(expr);
845  complexity comp = make_zero_complexity();// complexity_undefined;
846 
847  trace_on("expression");
848 
849  if ( s != syntax_undefined )
850  comp = syntax_to_complexity(s, pbasic, precond, effects_list);
851  else
852  pips_internal_error("syntax undefined");
853 
854  complexity_check_and_warn("expression_to_complexity", comp);
855 
856  trace_off();
857  return(comp);
858 }
complexity syntax_to_complexity(syntax s, basic *pbasic, transformer precond, list effects_list)
the only available element of expression
Definition: comp_scan.c:881
#define syntax_undefined
Definition: ri.h:2676
#define expression_syntax(x)
Definition: ri.h:1247

References complexity_check_and_warn(), expression_syntax, make_zero_complexity(), pips_internal_error, syntax_to_complexity(), syntax_undefined, trace_off(), and trace_on().

Referenced by arguments_to_complexity(), indices_to_complexity(), instruction_to_complexity(), range_to_complexity(), subscript_to_complexity(), syntax_to_complexity(), test_to_complexity(), and whileloop_to_complexity().

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

◆ expression_to_complexity_polynome()

complexity expression_to_complexity_polynome ( expression  expr,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)

Entry point routine of this file:

complexity expression_to_complexity_polynome(expression expr, transformer precond, list effects_list, bool keep_symbols, int maximize) return the polynomial associated to the expression expr, or POLYNOME_UNDEFINED if it's not a polynome. or POLYNOME_NULL if it's a 0 complexity. If keep_symbols is false, we force evaluation of variables. If they can't be evaluated, they enter the polynomial, but they are replaced by the pseudo-variable UNKNOWN_VARIABLE, except when they appear in a loop range: in that case, the whole range is replaced by UNKNOWN_RANGE. The int maximize lets us use the mins and maxs of preconditions system, to compute a WORST-CASE complexity for the upper bound , maximize is 1 for the lower bound and increment, maximize is -1 (when the precondition doesn't give an exact value)

effects_list is added on 10 Nov 92 to pass the effects which can be used to determine the "must-be-written" effects to delay the variable evaluation. LZ 10 Nov 92

FI:

  • better symbol generation for unknown complexities

The following line is merely for debugging

Parameters
exprxpr
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 118 of file comp_expr_to_pnome.c.

124 {
125  normalized no = NORMALIZE_EXPRESSION(expr);
126  syntax sy = expression_syntax(expr);
128 
129  trace_on("expression -> pnome");
130 
131  if ( expr == expression_undefined ) {
132  pips_internal_error("undefined expression");
133  }
134  if ( sy == syntax_undefined ) {
135  pips_internal_error("wrong expression");
136  }
137 
138  if ( normalized_linear_p(no) ) {
139  comp = normalized_to_polynome(no, precond, effects_list,
140  keep_symbols, maximize);
141  }
142  else {
143  comp = syntax_to_polynome(sy, precond, effects_list, keep_symbols, maximize);
144  }
145 
146  if ( complexity_unknown_p(comp) ) {
147  pips_internal_error("Better unknown value name generation required!");
148  /*
149  return(make_single_var_complexity(1.0,UNKNOWN_RANGE));
150  */
151  return complexity_undefined;
152  }
153 
154  /* The following line is merely for debugging */
155 
156  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
157  fprintf(stderr, "expr->pnome ");
158  complexity_fprint(stderr, comp, true, true);
159  }
160 
161  trace_off();
162  return (comp);
163 }
complexity normalized_to_polynome(normalized no, transformer precond, list effects_list, bool keep_symbols, int maximize)
2nd element of expression
complexity syntax_to_polynome(syntax synt, transformer precond, list effects_list, bool keep_symbols, int maximize)
1st element of expression
bool complexity_unknown_p(complexity comp)
true if comp is unknown.
Definition: comp_math.c:269
#define complexity_undefined
Definition: complexity_ri.h:66
#define NORMALIZE_EXPRESSION(e)
#define normalized_linear_p(x)
Definition: ri.h:1779
#define expression_undefined
Definition: ri.h:1223

References complexity_fprint(), complexity_undefined, complexity_unknown_p(), expression_syntax, expression_undefined, fprintf(), get_bool_property(), make_zero_complexity(), NORMALIZE_EXPRESSION, normalized_linear_p, normalized_to_polynome(), pips_internal_error, syntax_to_polynome(), syntax_undefined, trace_off(), and trace_on().

Referenced by cast_to_polynome(), divide_op_handler(), field_op_handler(), loop_to_complexity(), minus_op_handler(), multiply_op_handler(), plus_op_handler(), power_op_handler(), replace_formal_parameters_by_real_ones(), unary_minus_op_handler(), unary_plus_op_handler(), and whileloop_to_complexity().

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

◆ fetch_callees_complexities()

hash_table fetch_callees_complexities ( char *  module_name)

translate the local name to current module name. LZ 5 Feb.93

i.e. SUB:M -> MAIN:M

FI: this seems to be wrong in general because the formal parameter and actual argument are assumed to have the same name; see DemoStd/q and variables IM/IMM; 3 March 1994

Parameters
module_nameodule_name

Definition at line 821 of file comp_util.c.

823 {
824  hash_table hash_callees_comp = hash_table_make(hash_pointer, 0);
825  callees cl;
826  list callees_list;
827  complexity callee_comp;
828 
829  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
830  fprintf(stderr, "Fetching callees complexities ...\n");
831  }
832 
833  cl = (callees)db_get_memory_resource(DBR_CALLEES, module_name, true);
834  callees_list = callees_callees(cl);
835 
836  if ( callees_list == NIL ) {
837  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
838  fprintf(stderr, "Module %s has no callee! Done\n", module_name);
839  }
840  return(hash_callees_comp);
841  }
842 
843  MAPL(pc, {
844  string callee_name = STRING(CAR(pc));
845  entity callee = module_name_to_entity(callee_name);
846  type t = entity_type(callee);
847 
848  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
849  fprintf(stderr, "%s has callee %s!\n",module_name,callee_name);
850  }
851  pips_assert("call_to_complexity",
852  type_functional_p(t) || type_void_p(t));
853 
855  complexity new_comp;
856  callee_comp = (complexity)
857  db_get_memory_resource(DBR_SUMMARY_COMPLEXITY,
858  (char *) callee_name,
859  true);
860 
861  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
862  fprintf(stderr, "fetched complexity for callee %s",
863  callee_name);
864  fprintf(stderr, " of module %s:\n", module_name);
865  complexity_fprint(stderr, callee_comp,
868  }
869 
870  debug(5,"fetch_callees_complexities","callee_name %s\n",callee_name);
871 
872  /* translate the local name to current module name. LZ 5 Feb.93 */
873  /* i.e. SUB:M -> MAIN:M */
874  /* FI: this seems to be wrong in general because the
875  * formal parameter and actual argument are assumed to
876  * have the same name; see DemoStd/q and variables IM/IMM;
877  * 3 March 1994
878  */
879  new_comp = translate_complexity_from_local_to_current_name(callee_comp,
880  callee_name,module_name);
881 
882  hash_put(hash_callees_comp, (char *)callee, (char *)new_comp);
883  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
884  fprintf(stderr, "translated complexity for callee %s",
885  callee_name);
886  fprintf(stderr, " of module %s:\n", module_name);
887  complexity_fprint(stderr, new_comp,
890  }
891  }
892  }, callees_list );
893 
894  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
895  fprintf(stderr, "Fetching callees complexities ... done\n");
896  }
897 
898  return(hash_callees_comp);
899 }
static entity callee
Definition: alias_pairs.c:62
complexity translate_complexity_from_local_to_current_name(complexity callee_comp, string oldname, string newname)
translate_complexity_from_local_to_current_name(callee_comp,oldname,newname) B:M -> A:M if A calls B ...
Definition: comp_util.c:1100
#define PRINT_LOCAL_NAMES
#define DO_PRINT_STATS
defines for "complexity_fprint" calls
#define STRING(x)
Definition: genC.h:87
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_pointer
Definition: newgen_hash.h:32
struct _newgen_struct_callees_ * callees
Definition: ri.h:55
#define callees_callees(x)
Definition: ri.h:675

References callee, callees_callees, CAR, complexity_fprint(), db_get_memory_resource(), debug(), DO_PRINT_STATS, entity_initial, entity_type, fprintf(), get_bool_property(), hash_pointer, hash_put(), hash_table_make(), MAPL, module_name(), module_name_to_entity(), NIL, pips_assert, PRINT_LOCAL_NAMES, STRING, translate_complexity_from_local_to_current_name(), type_functional_p, type_void_p, and value_code_p.

Referenced by any_complexities().

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

◆ fetch_complexity_parameters()

hash_table fetch_complexity_parameters ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 901 of file comp_util.c.

903 {
904  hash_table hash_comp_params = hash_table_make(hash_pointer, 0);
905  char *parameters = strdup(get_string_property("COMPLEXITY_PARAMETERS"));
906  char *sep_chars = strdup(", ");
907  char *token = (char*) malloc(30);
908  entity e;
909 
911 
912  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
913  fprintf(stderr, "Fetching complexity parameters for module %s:\n",
914  module_name);
915  }
916 
917  token = strtok(parameters, sep_chars);
918 
919  while (token != NULL) {
922  token,
923  (char *) NULL),
924  entity_domain);
925  if (e != entity_undefined) {
926  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
927  fprintf(stderr, "{\t Defined entity %s }\n", entity_name(e));
928  }
929  hash_put(hash_comp_params,(char *)e,HASH_USER_VARIABLE);
930  }
931  else {
932  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
933  fprintf(stderr, "{\t Undefined token %s }\n", token);
934  }
935  }
936  token = strtok(NULL, sep_chars);
937  }
938 
939  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
940  fprintf(stderr, "Fetching complexity parameters: ...done.\n");
941  }
942 
943  return(hash_comp_params);
944 }
#define HASH_USER_VARIABLE
char * get_string_property(const char *)
void * malloc(YYSIZE_T)
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
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define entity_undefined
Definition: ri.h:2761
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410

References concatenate(), entity_domain, entity_name, entity_undefined, fprintf(), gen_find_tabulated(), get_bool_property(), get_string_property(), hash_pointer, hash_put(), hash_table_make(), HASH_USER_VARIABLE, hash_warn_on_redefinition(), malloc(), module_name(), MODULE_SEP_STRING, and strdup().

Referenced by any_complexities().

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

◆ field_op_handler()

complexity field_op_handler ( list  args,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)
Parameters
argsrgs
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 512 of file comp_expr_to_pnome.c.

513  {
515  precond, effects_list, keep_symbols,
516  maximize);
518  precond, effects_list, keep_symbols,
519  maximize);
520 
521  complexity_add(&c1, c2);
522  complexity_rm(&c2);
523 
524  return (c1);
525 }

References CAR, CDR, complexity_add(), complexity_rm(), EXPRESSION, and expression_to_complexity_polynome().

Referenced by call_to_polynome().

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

◆ final_statement_to_complexity_evaluation()

complexity final_statement_to_complexity_evaluation ( complexity  comp,
transformer  precond,
list  effects_list 
)
Parameters
compomp
precondrecond
effects_listffects_list

Definition at line 1052 of file comp_util.c.

1056 {
1057  complexity final_comp = complexity_dup(comp);
1058  Ppolynome pp = complexity_polynome(comp);
1060 
1061 
1062  fprintf(stderr, "Final evaluation\n");
1063 
1064  for ( ; !VECTEUR_NUL_P(pb); pb = pb->succ) {
1065  bool mustbewritten;
1066  char *var = variable_local_name(pb->var);
1067 
1068  fprintf(stderr, "Variable is %s\n", var);
1069 
1070  mustbewritten = is_must_be_written_var(effects_list, var);
1071 
1072  if ( mustbewritten ) {
1073  complexity compsubst;
1074  fprintf(stderr, "YES once\n");
1075  compsubst = evaluate_var_to_complexity((entity)pb->var,
1076  precond,
1077  effects_list, 1);
1078  complexity_fprint( stderr, compsubst, false, false);
1079 /*
1080 
1081  final_comp = complexity_var_subst(comp, pb->var, compsubst);
1082 */
1083  }
1084  comp = complexity_dup(final_comp);
1085  }
1086 
1087  complexity_fprint( stderr, final_comp, false, false);
1088 
1089  return ( final_comp );
1090 }
bool is_must_be_written_var(list effects_list, char *var_name)
Definition: comp_util.c:1014

References complexity_dup(), complexity_fprint(), complexity_polynome(), default_is_inferior_pvarval(), evaluate_var_to_complexity(), fprintf(), is_must_be_written_var(), polynome_used_var(), Svecteur::succ, Svecteur::var, variable_local_name(), vect_dup(), and VECTEUR_NUL_P.

+ Here is the call graph for this function:

◆ float_matrice_inversion()

void float_matrice_inversion ( float *  a,
int  n,
int indx,
int pd 
)

set up identity matrix

Parameters
indxndx
pdd

Definition at line 198 of file comp_matrice.c.

203 {
204  int i,j;
205  float *y = (float *) malloc(sizeof(float) * n * n);
206 
207  /* set up identity matrix */
208  for (i=0; i<n; i++ ) {
209  for ( j=0; j<n; j++ )
210  Y(i,j) = 0.0;
211  Y(i,i) = 1.0;
212  }
213 
214  lu_decomposition(a, n, indx, pd);
215 
216  for ( j=0; j<n; j++ ) {
217  lu_back_substitution(a, n, indx, &(Y(j,0)) );
218  }
219  for ( j=0; j<n; j++ )
220  for ( i=0; i<n; i++ )
221  A(i,j) = Y(j,i);
222 }
#define Y(i, j)
Added by AP, March 23rd 93: allows the simulation of a two-dimensional array with a mono-dimensional ...
Definition: comp_matrice.c:196
void lu_decomposition(float *a, int n, int *indx, int *pd)
comp_matrice.c
Definition: comp_matrice.c:65
void lu_back_substitution(float *a, int n, int *indx, float *b)
Definition: comp_matrice.c:155
#define A(i, j)
comp_matrice.c
Definition: comp_matrice.c:63

References A, lu_back_substitution(), lu_decomposition(), malloc(), and Y.

Referenced by unstructured_to_complexity().

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

◆ fp_complexities()

bool fp_complexities ( const  string)
Parameters
stringodule_name

Definition at line 89 of file comp_scan.c.

90 {
91  bool success = true;
92 
93  //set_string_property("COMPLEXITY_COST_TABLE", "fp_1");
95 
96  return success;
97 }
bool any_complexities(const string module_name)
Definition: comp_scan.c:99
bool success
Definition: gpips-local.h:59

References any_complexities(), and module_name().

+ Here is the call graph for this function:

◆ fprint_cost_table()

void fprint_cost_table ( FILE *  fd)
Parameters
fdd

Definition at line 481 of file comp_util.c.

483 {
485  bool skip_one_line = false;
486 
487  fprintf(fd, "\nIntrinsic cost table:\n\n");
488  fprintf(fd, " Intrinsic name int float double complex dcomplex\n");
489  fprintf(fd, "------------------------------------------------------------------------\n");
490 
491  for(; p->name != NULL ;p++) {
492  if (1 ||(p->int_cost != 0) ||
493  (p->float_cost != 0) ||
494  (p->double_cost != 0) ||
495  (p->complex_cost != 0) ||
496  (p->dcomplex_cost != 0)) {
497  if (skip_one_line) {
498  fprintf(fd, "%25s|\n", "");
499  skip_one_line = false;
500  }
501  fprintf(fd, "%22.21s |%6td %6td %7td %8td %8td\n",
502  p->name, p->int_cost, p->float_cost,
504  }
505  else
506  skip_one_line = true;
507  }
508  fprintf(fd, "\n");
509 }
intrinsic_cost_record intrinsic_cost_table[]
The table intrinsic_cost_table[] gathers cost information of each intrinsic's cost; those costs are d...
Definition: comp_util.c:286
Intrinsics costs defines.

References intrinsic_cost_rec::complex_cost, intrinsic_cost_rec::dcomplex_cost, intrinsic_cost_rec::double_cost, intrinsic_cost_rec::float_cost, fprintf(), intrinsic_cost_rec::int_cost, intrinsic_cost_table, and intrinsic_cost_rec::name.

Referenced by any_complexities().

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

◆ fprint_statement_complexity()

void fprint_statement_complexity ( entity  module,
statement  stat,
hash_table  hash_statement_to_complexity 
)
Parameters
moduleodule
stattat
hash_statement_to_complexityash_statement_to_complexity

Definition at line 253 of file comp_util.c.

257 {
258  text t = Text_Statement(module, 0, stat);
259  complexity comp;
260 
261  comp = ((complexity) hash_get(hash_statement_to_complexity,(char *)stat));
262  if (COMPLEXITY_UNDEFINED_P(comp))
263  pips_internal_error("undefined complexity");
264  else {
265  fprintf(stderr, "C -- ");
267  }
268  print_text(stderr, t);
269 }
text Text_Statement(entity, int, statement)
void print_text(FILE *fd, text t)
Definition: print.c:195

References complexity_fprint(), COMPLEXITY_UNDEFINED_P, DO_PRINT_STATS, fprintf(), hash_get(), module, pips_internal_error, PRINT_LOCAL_NAMES, print_text(), and Text_Statement().

+ Here is the call graph for this function:

◆ free_callees_complexities()

hash_table free_callees_complexities ( hash_table  h)

Modified copies of the summary complexities are stored

Definition at line 812 of file comp_util.c.

813 {
814  /* Modified copies of the summary complexities are stored */
815  hash_table_clear(h);
816  hash_table_free(h);
817 
818  return hash_table_undefined;
819 }
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
void hash_table_clear(hash_table htp)
Clears all entries of a hash table HTP.
Definition: hash.c:305
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49

References hash_table_clear(), hash_table_free(), and hash_table_undefined.

Referenced by any_complexities().

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

◆ free_complexity_map()

void free_complexity_map ( void  )

◆ get_complexity_map()

statement_mapping get_complexity_map ( void  )

Referenced by any_complexities().

+ Here is the caller graph for this function:

◆ good_complexity_assert()

void good_complexity_assert ( string  ,
complexity   
)

◆ goto_to_complexity()

complexity goto_to_complexity ( statement  ,
transformer  ,
list   
)

◆ indices_to_complexity()

complexity indices_to_complexity ( list  exprlist,
basic pbasic,
transformer  precond,
list  effects_list 
)

2nd element of reference

exactly the same with arguments_to_complexity I add this function in order to make the structure clearer Apr. 15,91

Parameters
exprlistxprlist
pbasicbasic
precondrecond
effects_listffects_list

Definition at line 1057 of file comp_scan.c.

1062 {
1064  basic ibasic = MAKE_INT_BASIC;
1065 
1066  trace_on("indices");
1067 
1068  *pbasic = MAKE_INT_BASIC;
1069 
1070  MAPL (pa, {
1071  expression e = EXPRESSION(CAR(pa));
1072  complexity ctmp = expression_to_complexity(e, &ibasic, precond, effects_list);
1073  complexity_add(&comp, ctmp);
1074  complexity_rm(&ctmp);
1075 
1076  if (is_inferior_basic(*pbasic, ibasic)) {
1077  free_basic(*pbasic);
1078  *pbasic = simple_basic_dup(ibasic);
1079  }
1080  },exprlist);
1081 
1082  complexity_check_and_warn("indices_to_complexity", comp);
1083 
1084  trace_off();
1085  return(comp);
1086 }

References CAR, complexity_add(), complexity_check_and_warn(), complexity_rm(), EXPRESSION, expression_to_complexity(), free_basic(), is_inferior_basic(), MAKE_INT_BASIC, make_zero_complexity(), MAPL, simple_basic_dup(), trace_off(), and trace_on().

Referenced by reference_to_complexity(), and subscript_to_complexity().

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

◆ init_cost_table()

void init_cost_table ( void  )

Completes the intrinsic cost table with the costs read from the files specified in the "COMPLEXITY_COST_TABLE" string property See properties.rc and ~pips/Pips/pipsrc.csh for more information.

L. ZHOU 13/03/91

COST_DATA are names of five data files

Definition at line 519 of file comp_util.c.

520 {
521  char *token, *comma, *filename ;
522  float file_factor;
523 
524  char *cost_data = strdup(COST_DATA);
525  char *tmp=NULL;
526 
527  for(token = strtok(cost_data, " "); (token != NULL);token = strtok(NULL, " ")) {
528  comma = strchr(token, ',');
529 
530  if (comma == NULL) {
531  tmp=strdup(token);
532  file_factor = 1.0;
533  }
534  else {
535  int ii = comma - token;
536  tmp=strndup( token, ii);
537  sscanf(++comma, "%f", &file_factor);
538  }
539 
540 
541  filename = strdup(concatenate( COMPLEXITY_COST_TABLES "/", get_string_property("COMPLEXITY_COST_TABLE"), "/", tmp, NULL));
542 
543  debug(5,"init_cost_table","file_factor is %f\n", file_factor);
544  debug(1,"init_cost_table","cost file is %s\n",filename);
545 
546  load_cost_file(fopen_config(filename,NULL,"PIPS_COSTDIR"), file_factor);
547  free(tmp);
548  free(filename);
549  }
550 
551 }
void load_cost_file(FILE *fd, float file_factor)
Load (some) intrinsics costs from file "fd", multiplying them by "file_factor".
Definition: comp_util.c:557
#define COST_DATA
defined complexity data file names here.
FILE * fopen_config(const char *canonical_name, const char *cproperty, const char *cenv)
Definition: file.c:952
char * strndup(char const *s, size_t n)
A replacement function, for systems that lack strndup.
Definition: strndup.c:26

References concatenate(), COST_DATA, debug(), fopen_config(), free(), get_string_property(), load_cost_file(), strdup(), and strndup().

Referenced by any_complexities(), generic_print_xml_application(), and print_xml_code().

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

◆ instruction_to_complexity()

complexity instruction_to_complexity ( instruction  instr,
transformer  precond,
list  effects_list 
)

The only element available of the statement.

dummy parameter

dummy parameter

Parameters
instrnstr
precondrecond
effects_listffects_list

Definition at line 275 of file comp_scan.c.

279 {
280  complexity comp = make_zero_complexity();// complexity_undefined;
281 
282  trace_on("instruction");
283 
284  switch (instruction_tag(instr)) {
286  comp = block_to_complexity(instruction_block(instr), precond, effects_list);
287  break;
288  case is_instruction_test:
289  comp = test_to_complexity(instruction_test(instr), precond, effects_list);
290  break;
291  case is_instruction_loop:
292  comp = loop_to_complexity(instruction_loop(instr), precond, effects_list);
293  break;
295  comp= whileloop_to_complexity(instruction_whileloop(instr), precond, effects_list);
296  break;
297  case is_instruction_goto:
298  comp = goto_to_complexity(instruction_goto(instr), precond, effects_list);
299  break;
300  case is_instruction_call: {
301  basic callbasic = MAKE_INT_BASIC; /* dummy parameter */
302  comp = call_to_complexity(instruction_call(instr),
303  &callbasic, precond, effects_list);
304  break;
305  }
308  precond, effects_list);
309  break;
310  case is_instruction_expression: { // copied from is_instruction_call
311  basic callbasic = MAKE_INT_BASIC; /* dummy parameter */
313  &callbasic,
314  precond, effects_list);
315  break;
316  }
317  default:
318  pips_internal_error("instruction tag %d isn't in 14->19.",
319  (int) instruction_tag(instr));
320  }
321  complexity_check_and_warn("instruction_to_complexity", comp);
322 
323  trace_off();
324  return(comp);
325 }
complexity whileloop_to_complexity(whileloop while_instr, transformer precond, list effects_list)
5th element of instruction
Definition: comp_scan.c:692
complexity call_to_complexity(call call_instr, basic *pbasic, transformer precond, list effects_list)
3rd element of syntax
Definition: comp_scan.c:736
complexity loop_to_complexity(loop loop_instr, transformer precond, list effects_list)
3rd element of instruction
Definition: comp_scan.c:460
complexity test_to_complexity(test test_instr, transformer precond, list effects_list)
2nd element of instruction
Definition: comp_scan.c:414
complexity goto_to_complexity(statement st __attribute__((__unused__)), transformer precond __attribute__((__unused__)), list effects_list __attribute__((__unused__)))
4th element of instruction
Definition: comp_scan.c:683
complexity block_to_complexity(list block, transformer precond, list effects_list)
1st element of instruction
Definition: comp_scan.c:344
complexity unstructured_to_complexity(unstructured unstr, transformer precond, list effects_list)
6th element of instruction
Definition: comp_unstr.c:75
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define instruction_loop(x)
Definition: ri.h:1520
#define instruction_goto(x)
Definition: ri.h:1526
@ 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_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define instruction_expression(x)
Definition: ri.h:1541
#define instruction_whileloop(x)
Definition: ri.h:1523
#define instruction_call(x)
Definition: ri.h:1529
#define instruction_test(x)
Definition: ri.h:1517
#define instruction_unstructured(x)
Definition: ri.h:1532

References block_to_complexity(), call_to_complexity(), complexity_check_and_warn(), expression_to_complexity(), goto_to_complexity(), instruction_block, instruction_call, instruction_expression, instruction_goto, instruction_loop, instruction_tag, instruction_test, instruction_unstructured, instruction_whileloop, is_instruction_block, is_instruction_call, is_instruction_expression, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, loop_to_complexity(), MAKE_INT_BASIC, make_zero_complexity(), pips_internal_error, test_to_complexity(), trace_off(), trace_on(), unstructured_to_complexity(), and whileloop_to_complexity().

Referenced by statement_to_complexity().

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

◆ intrinsic_cost()

int intrinsic_cost ( const char *  ,
basic  
)

◆ is_inferior_pvarval()

int is_inferior_pvarval ( Pvecteur pvarval1,
Pvecteur pvarval2 
)
Parameters
pvarval1varval1
pvarval2varval2

Definition at line 149 of file polynome_ri.c.

150 {
151  int is_inferior;
152 
153  if (term_cst(*pvarval1))
154  is_inferior = -1;
155  else if(term_cst(*pvarval2))
156  is_inferior = 1;
157  else {
158  // FI: should be entity_user_name...
159  is_inferior = strcmp(variable_local_name(vecteur_var(*pvarval1)),
160  variable_local_name(vecteur_var(*pvarval2)));
161  }
162 
163  // FI: Make sure that you do not return 0 for two different entities
164  if(is_inferior==0 && vecteur_var(*pvarval1)!=vecteur_var(*pvarval2)) {
165  is_inferior = strcmp(entity_name((entity)vecteur_var(*pvarval1)),
166  entity_name((entity)vecteur_var(*pvarval2)));
167  }
168 
169  return is_inferior;
170 }
char * variable_local_name(Variable var)
Definition: polynome_ri.c:95
#define vecteur_var(v)
#define term_cst(varval)

References entity_name, term_cst, variable_local_name(), and vecteur_var.

Referenced by complexity_sprint(), prp(), and translate_complexity_from_local_to_current_name().

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

◆ is_inferior_var()

bool is_inferior_var ( Variable  var1,
Variable  var2 
)
Parameters
var1ar1
var2ar2

Definition at line 118 of file polynome_ri.c.

120 {
121  bool is_inferior = true;
122 
123  if (var1 == TCST)
124  is_inferior = true;
125  else if(var2 == TCST)
126  is_inferior = false;
127  else
128  is_inferior = (strcmp(variable_local_name(var1),
129  variable_local_name(var2)) <= 0 );
130 
131  return is_inferior;
132 }
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.

References TCST, and variable_local_name().

Referenced by is_inferior_monome(), polynome_fprint(), polynome_sort(), polynome_sprint(), and polynome_used_var().

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

◆ is_inferior_varval()

int is_inferior_varval ( Pvecteur  varval1,
Pvecteur  varval2 
)
Parameters
varval1arval1
varval2arval2

Definition at line 134 of file polynome_ri.c.

135 {
136  int is_inferior;
137 
138  if (term_cst(varval1))
139  is_inferior = 1;
140  else if(term_cst(varval2))
141  is_inferior = -1;
142  else
143  is_inferior = - strcmp(variable_local_name(vecteur_var(varval1)),
144  variable_local_name(vecteur_var(varval2)));
145 
146  return is_inferior;
147 }

References term_cst, variable_local_name(), and vecteur_var.

+ Here is the call graph for this function:

◆ is_linear_unstructured()

bool is_linear_unstructured ( unstructured  unstr)

return true if unstr is simply a linear string of controls

Parameters
unstrnstr

Definition at line 738 of file comp_util.c.

740 {
742  control exit = unstructured_exit(unstr);
743 
744  while (current != exit) {
746 
747  if (succs == NIL)
748  pips_internal_error("control != exit one,it has no successor");
749  if (CDR(succs) != NIL)
750  return (false);
751  current = CONTROL(CAR(succs));
752  }
753 
754  return(true);
755 }
#define exit(code)
Definition: misc-local.h:54
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define CONTROL(x)
CONTROL.
Definition: ri.h:910
#define control_successors(x)
Definition: ri.h:945
#define unstructured_exit(x)
Definition: ri.h:3006
static size_t current
Definition: string.c:115

References CAR, CDR, CONTROL, control_successors, current, exit, NIL, pips_internal_error, unstructured_control, and unstructured_exit.

◆ is_must_be_written_var()

bool is_must_be_written_var ( list  effects_list,
char *  var_name 
)

fprintf(stderr, "is_must_be_written_var for entity %s\n", module_local_name(e) );

Parameters
effects_listffects_list
var_namear_name

Definition at line 1014 of file comp_util.c.

1017 {
1018  MAPL(ce, {
1019  effect eff = EFFECT(CAR(ce));
1020 
1021  if(eff == effect_undefined)
1022  pips_internal_error("unexpected effect undefined");
1023 
1024  if ( action_write_p(effect_action(eff))
1027  entity e = reference_variable(r);
1028 /*
1029  fprintf(stderr, "is_must_be_written_var for entity %s\n",
1030  module_local_name(e) );
1031 */
1032  if ( strcmp(module_local_name(e), var_name) == 0 ) {
1033  return (true);
1034  }
1035  }
1036 /*
1037  else {
1038  fprintf(stderr, "is_must_be_written_var for NOT entity %s\n",
1039  module_local_name(reference_variable(effect_any_reference(eff))) );
1040  }
1041 */
1042  },effects_list);
1043 
1044  return (false);
1045 }
#define effect_undefined
Definition: effects.h:614
#define action_write_p(x)
Definition: effects.h:314

References action_write_p, approximation_exact_p, CAR, EFFECT, effect_action, effect_any_reference, effect_approximation, effect_undefined, MAPL, module_local_name(), pips_internal_error, and reference_variable.

Referenced by final_statement_to_complexity_evaluation().

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

◆ list_ith_element()

list list_ith_element ( list  thelist,
int  ith 
)

return a pointer to the (i)th element of the list if i = 1, the pointer doesn't change at all.

Parameters
thelisthelist
ithth

Definition at line 579 of file comp_math.c.

582 {
583  for( ; --ith > 0; thelist = CDR(thelist) ) {
584  pips_assert("list_ith_element", thelist != NIL);
585  }
586 
587  return (thelist);
588 }

References CDR, NIL, and pips_assert.

◆ load_cost_file()

void load_cost_file ( FILE *  ,
double   
)

◆ load_statement_complexity()

complexity load_statement_complexity ( statement  )

◆ local_name_to_variable()

Variable local_name_to_variable ( char *  name)
Parameters
nameame

Definition at line 194 of file polynome_ri.c.

196 {
197  string s = make_entity_fullname("TOP-LEVEL", name);
198 
199  if (strcmp(name, TCST_NAME)==0)
200  return(TCST);
201  /*
202  else if (strcmp(name, UNKNOWN_VARIABLE_NAME) == 0)
203  return (UNKNOWN_VARIABLE);
204  else if (strcmp(name, UNKNOWN_RANGE_NAME) == 0)
205  return (UNKNOWN_RANGE);
206  */
207  else {
209  if (e != entity_undefined)
210  return ((Variable) e);
211  else {
212  user_warning("local_name_to_variable",
213  "entity '%s' not found:return chunk_undefined\n", name);
214  return((Variable) chunk_undefined);
215  }
216  }
217 }
#define TCST_NAME
string make_entity_fullname(const char *module_name, const char *local_name)
END_EOLE.
Definition: entity_names.c:230
#define chunk_undefined
obsolete
Definition: genC.h:79

References chunk_undefined, entity_domain, entity_undefined, gen_find_tabulated(), make_entity_fullname(), TCST, TCST_NAME, and user_warning.

+ Here is the call graph for this function:

◆ loop_to_complexity()

complexity loop_to_complexity ( loop  loop_instr,
transformer  precond,
list  effects_list 
)

3rd element of instruction

FI: Lei chose to allocate the UL and UU entities in the current module... Maybe, we are ready fo some dynamic profiling...

string mod_name = entity_module_name(ll);

if the statement were still reachable, we could try to use the statement nunber...

In order to get rid of at-sign, add 1 , LZ 010492

tell callees that they mustn't try to evaluate the loop index

cioh cboh are derived from overhead file "overhead" LZ, 280993

zero iteration for sure

at least one iteration

maybe some iteration

an intermediate test based on preconditions would give better result with affine loop bounds

Parameters
loop_instroop_instr
precondrecond
effects_listffects_list

Definition at line 460 of file comp_scan.c.

464 {
465  entity ll = loop_label (loop_instr);
466  entity index = loop_index(loop_instr);
467  range rng = loop_range(loop_instr);
468  statement s = loop_body(loop_instr);
469  execution ex = loop_execution(loop_instr);
470  complexity comp, cbody, crange, clower, cupper, cincr, cioh, cboh;
471  string sl,su,si;
472  /* FI: Lei chose to allocate the UL and UU entities in the current
473  module... Maybe, we are ready fo some dynamic profiling... */
474  /* string mod_name = entity_module_name(ll); */
475  basic ibioh = MAKE_INT_BASIC;
476  basic ibboh = MAKE_INT_BASIC;
477 
478  trace_on("loop %s label %s",entity_name(index),
479  entity_name(loop_label(loop_instr)));
480 
481  if ( empty_global_label_p(entity_name(ll)) ) {
482  /* if the statement were still reachable, we could try to use the
483  * statement nunber...
484  */
485  sl=strdup("UL_");
486  su=strdup("UU_");
487  si=strdup("UU_");
488  }
489  else {
490  /* In order to get rid of at-sign, add 1 , LZ 010492 */
491  asprintf(&sl,"UL_%s",entity_local_name(loop_label(loop_instr))+1);
492  asprintf(&su,"UU_%s",entity_local_name(loop_label(loop_instr))+1);
493  asprintf(&si,"UI_%s",entity_local_name(loop_label(loop_instr))+1);
494  }
495 
496  /* tell callees that they mustn't try to evaluate the loop index */
497 
500 
501  crange = range_to_complexity(rng, precond, effects_list);
502  cbody = statement_to_complexity(s, precond, effects_list);
503 
504  cioh = make_constant_complexity((float)
506  cboh = make_constant_complexity((float)
508  /* cioh cboh are derived from overhead file "overhead" LZ, 280993 */
509 
511 
512  if ( execution_parallel_p(ex) ) {
513  user_warning("loop_to_complexity", "DOALL not implemented yet\n");
514  }
515 
517  precond, effects_list,
519  if ( complexity_unknown_p(clower) ) {
520  /*
521  clower = make_single_var_complexity(1.0,
522  (Variable)FindOrCreateEntity(mod_name, sl));
523  */
526  clower = make_single_var_complexity(1.0,var);
527  }
528 
530  precond, effects_list,
532  if ( complexity_unknown_p(cupper) ) {
533  /*
534  cupper = make_single_var_complexity(1.0,
535  (Variable)FindOrCreateEntity(mod_name, su));
536  */
539  cupper = make_single_var_complexity(1.0,var);
540  }
541 
543  precond, effects_list,
545 
546  if ( complexity_constant_p(cincr) ) {
547  int incr = complexity_TCST(cincr);
548  if (incr == 0)
549  user_error("loop_to_complexity", "null increment\n");
550  else if ( incr < 0 ) {
551  complexity cswap;
552 
553  complexity_scalar_mult(&cincr, -1.0);
554  if ( incr != -1.0 ) {
555  complexity_div(&clower, cincr);
556  complexity_div(&cupper, cincr);
557  }
558  complexity_scalar_mult(&cincr, -1.0/incr);
559  cswap = clower;
560  clower = cupper;
561  cupper = cswap;
562  }
563  else if ( incr != 1) {
564  complexity_div(&clower, cincr);
565  complexity_div(&cupper, cincr);
566  complexity_scalar_mult(&cincr, 1.0/incr);
567  }
568  else if ( complexity_constant_p(clower) || complexity_constant_p(cupper) ) {
569  ;
570  }
571  }
572 
573  if ( complexity_constant_p(clower) && complexity_constant_p(cupper)) {
574  float lower = complexity_TCST(clower);
575  float upper = complexity_TCST(cupper);
576  if (lower>upper) {
577  /* zero iteration for sure */
578  comp = make_zero_complexity();
579  }
580  else {
581  /* at least one iteration */
582  comp = complexity_sigma(cbody, (Variable)index, clower, cupper);
583  }
584  }
585  else {
586  /* maybe some iteration */
587  comp = complexity_sigma(cbody, (Variable)index, clower, cupper);
588  /* an intermediate test based on preconditions would give better
589  result with affine loop bounds */
590  }
591 
592  /*
593  if ( !complexity_constant_p(cincr)
594  || complexity_constant_p(clower) || complexity_constant_p(cupper) ) {
595  complexity_div(&comp, cincr);
596  }
597  */
598 
599  if(!complexity_constant_p(cincr)) {
600  if(complexity_is_monomial_p(cincr) && complexity_degree(cincr)==1) {
601  complexity_div(&comp, cincr);
602  }
603  else {
604  free_complexity(cincr);
607  cincr = make_single_var_complexity(1.0,var);
608  }
609  }
610 
611  if ( complexity_constant_p(comp) && complexity_TCST(comp) < 0 )
612  comp = make_zero_complexity();
613 
614  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
615  fprintf(stderr, "\n");
616  fprintf(stderr, "@@@ body complexity: ");
617  complexity_fprint(stderr, cbody, false, true);
618  fprintf(stderr, "@@@ range complexity: ");
619  complexity_fprint(stderr, crange, false, true);
620  fprintf(stderr, "@@@ lower value : ");
621  complexity_fprint(stderr, clower, false, true);
622  fprintf(stderr, "@@@ upper value : ");
623  complexity_fprint(stderr, cupper, false, true);
624  fprintf(stderr, "@@@ increment value : ");
625  complexity_fprint(stderr, cincr, false, true);
626  fprintf(stderr, "@@@ sigma complexity: ");
627  complexity_fprint(stderr, comp, false, true);
628  }
629 /*
630  if ( !complexity_constant_p(cincr) ) {
631  complexity_div(&comp, cincr);
632  }
633  else {
634  float incr = complexity_TCST(cincr);
635  if (incr == 0)
636  user_error("loop_to_complexity", "null increment\n");
637 
638  if ( complexity_constant_p(clower) && complexity_constant_p(cupper) ) {
639  float lower = complexity_TCST(clower);
640  float upper = complexity_TCST(cupper);
641  int times=0;
642  float curf;
643 
644  for ( curf = lower; curf <= upper; curf += incr )
645  times++;
646 
647  complexity_scalar_mult(&comp, 1./(float)times);
648  if ( complexity_zero_p(comp) )
649  comp = make_constant_complexity(1.0);
650  }
651  else {
652  complexity_scalar_mult(&comp, 1.0/incr);
653  }
654  }
655 */
658  complexity_stats_add(&comp, cincr);
660 
661  complexity_rm(&crange);
662  complexity_rm(&cioh);
663  complexity_rm(&cboh);
664  complexity_rm(&clower);
665  complexity_rm(&cupper);
666  complexity_rm(&cincr);
667 
668  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
669  fprintf(stderr, "@@@ loop total compl: ");
670  complexity_fprint(stderr, comp, true, true);
671  fprintf(stderr, "\n");
672  }
673 
675  complexity_check_and_warn("loop_to_complexity", comp);
676 
677  trace_off();
678  free(sl);free(su);free(si);
679  return(comp);
680 }
void complexity_scalar_mult(complexity *pcomp, float f)
multiply a complexity by a floating-point number.
Definition: comp_math.c:303
void complexity_polynome_add(complexity *pcomp, Ppolynome pp)
Definition: comp_math.c:463
void complexity_div(complexity *pcomp1, complexity comp2)
void complexity_div(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 / comp2; !...
Definition: comp_math.c:445
complexity complexity_sigma(complexity comp, Variable index, complexity clower, complexity cupper)
comp_math.c
Definition: comp_math.c:84
complexity make_single_var_complexity(float f, Variable var)
make a complexity "f * var" with null statistics
Definition: comp_math.c:220
complexity range_to_complexity(range rng, transformer precond, list effects_list)
2nd element of syntax
Definition: comp_scan.c:1089
int complexity_degree(complexity c)
Definition: comp_util.c:1167
bool complexity_is_monomial_p(complexity c)
Definition: comp_util.c:1159
#define LOOP_BRANCH_OVERHEAD
#define MAXIMUM_VALUE
#define KEEP_SYMBOLS
defines for "expression_to_polynome" parameters
#define HASH_LOOP_INDEX
#define LOOP_INIT_OVERHEAD
#define MINIMUM_VALUE
bool empty_global_label_p(const char *gln)
Definition: entity_names.c:264
void * hash_del(hash_table htp, const void *key)
this function removes from the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:439
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
#define loop_body(x)
Definition: ri.h:1644
#define loop_execution(x)
Definition: ri.h:1648
#define range_upper(x)
Definition: ri.h:2290
#define range_increment(x)
Definition: ri.h:2292
#define loop_label(x)
Definition: ri.h:1646
#define range_lower(x)
Definition: ri.h:2288
#define loop_range(x)
Definition: ri.h:1642
#define execution_parallel_p(x)
Definition: ri.h:1211
#define loop_index(x)
Definition: ri.h:1640

References AddEntityToCurrentModule(), asprintf, complexity_check_and_warn(), complexity_constant_p(), complexity_degree(), complexity_div(), complexity_fprint(), complexity_is_monomial_p(), complexity_polynome(), complexity_polynome_add(), complexity_rangecount, complexity_rm(), complexity_scalar_mult(), complexity_sigma(), complexity_stats_add(), complexity_TCST(), complexity_unknown_p(), empty_global_label_p(), entity_local_name(), entity_name, execution_parallel_p, expression_to_complexity_polynome(), fprintf(), free(), free_complexity(), get_bool_property(), get_current_module_entity(), hash_complexity_parameters, hash_del(), HASH_LOOP_INDEX, hash_put(), intrinsic_cost(), is_basic_int, KEEP_SYMBOLS, loop_body, LOOP_BRANCH_OVERHEAD, loop_execution, loop_index, LOOP_INIT_OVERHEAD, loop_label, loop_range, make_constant_complexity(), MAKE_INT_BASIC, make_new_scalar_variable_with_prefix(), make_single_var_complexity(), make_zero_complexity(), MakeBasic(), MAXIMUM_VALUE, MINIMUM_VALUE, module_local_name(), range_increment, range_lower, range_to_complexity(), range_upper, rangecount_guessed, statement_to_complexity(), strdup(), trace_off(), trace_on(), user_error, and user_warning.

Referenced by instruction_to_complexity().

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

◆ lu_back_substitution()

void lu_back_substitution ( float *  a,
int  n,
int indx,
float *  b 
)

back substitution

Parameters
indxndx

Definition at line 155 of file comp_matrice.c.

160 {
161  int i,j;
162  int ii = -1;
163  float sum;
164  int ll;
165 
166  for (i=0; i<n; i++ ) {
167  ll = indx[i];
168  sum = b[ll];
169  b[ll] = b[i];
170  if ( ii != -1 ) {
171  for ( j=ii; j<=i-1; j++ ) {
172  sum = sum -A(i,j)*b[j];
173  }
174  }
175  else if ( sum != 0.0 ) {
176  ii = i;
177  }
178  b[i] = sum;
179  }
180 
181  /* back substitution */
182  for ( i=n-1; i>=0; i-- ) {
183  sum = b[i];
184  if ( i < n ) {
185  for ( j=i+1; j < n; j++ ) {
186  sum = sum - A(i,j)*b[j];
187  }
188  }
189  b[i] = sum/A(i,i);
190  }
191 }
t_real sum(int n1, int n2, int n3, t_real u[n1][n2][n3])
Definition: stencil.c:57

References A, and sum().

Referenced by float_matrice_inversion().

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

◆ lu_decomposition()

void lu_decomposition ( float *  a,
int  n,
int indx,
int pd 
)

comp_matrice.c

Added by AP, March 15th 93

If using gcc to compile, vv can be declared as vv[n] LZ 29/10/92 float vv[n];

loop over rows to get the implicit scaling information

loopover columns of Crout's method

Parameters
aModif by AP, March 15th 93 float a[n][n]; int indx[n];
indxndx
pdd

Definition at line 65 of file comp_matrice.c.

76 {
77  float aamax;
78 
79 /* Added by AP, March 15th 93 */
81 /* If using gcc to compile, vv can be declared as vv[n] LZ 29/10/92
82  float vv[n];
83 */
84 
85  int i,j,k;
86  float sum,dum;
87  int imax = 0;
88  float tiny = 0.000001;
89 
90  *pd = 1;
91 
92  /* loop over rows to get the implicit scaling information */
93  for (i=0; i<n; i++ ) {
94  aamax = 0.0;
95  for ( j=0; j<n; j++) {
96  if ( fabs(A(i,j)) > aamax ) {
97  aamax = fabs(A(i,j));
98  }
99  }
100 
101  if ( aamax == 0.0 ) {
102  fprintf(stderr, "Singular matrix -- No non-zero element\n");
103  user_error("lu_decomposition", "Module does not terminate\n");
104  }
105  vv[i] = 1./aamax;
106  }
107 
108  /* loopover columns of Crout's method */
109  for ( j=0; j<n; j++ ) {
110  for ( i=0; i<=j-1; i++ ) {
111  sum = A(i,j);
112  for ( k=0; k<i; k++) {
113  sum = sum - A(i,k)*A(k,j);
114  }
115  A(i,j) = sum;
116  }
117 
118  aamax = 0.0;
119 
120  for ( i=j; (i<n) ; i++ ) {
121  sum = A(i,j);
122  for ( k=0; k<j; k++ ) {
123  sum = sum - A(i,k)*A(k,j);
124  }
125  A(i,j) = sum;
126  dum = vv[i]*fabs(sum);
127  if ( dum >= aamax ) {
128  imax = i;
129  aamax = dum;
130  }
131  }
132 
133  if ( j != imax ) {
134  for ( k=0; k<n; k++ ) {
135  dum = A(imax,k);
136  A(imax,k) = A(j,k);
137  A(j,k) = dum;
138  }
139  *pd = - *pd;
140  vv[imax] = vv[j];
141  }
142 
143  indx[j] = imax;
144  if ( A(j,j) == 0.0 )
145  A(j,j) = tiny;
146  if ( j != n-1 ) {
147  dum = 1./A(j,j);
148  for ( i=j+1; i<n; i++ ) {
149  A(i,j) = A(i,j)*dum;
150  }
151  }
152  }
153 }
#define MAX_CONTROLS_IN_UNSTRUCTURED

References A, fprintf(), MAX_CONTROLS_IN_UNSTRUCTURED, sum(), and user_error.

Referenced by float_matrice_inversion().

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

◆ make_complexity_map()

void make_complexity_map ( void  )

◆ make_complexity_unknown()

complexity make_complexity_unknown ( const char *  name)

builds a new unknown complexity attached to a virtual package

Parameters
nameame

Definition at line 81 of file comp_expr_to_pnome.c.

81  {
82  entity package = FindEntity(TOP_LEVEL_MODULE_NAME,COMPLEXITY_PACKAGE_NAME);
86  return make_single_var_complexity(1.f,var);
87 }
language make_language_fortran(void)
Definition: ri.c:1250
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
#define COMPLEXITY_PACKAGE_NAME
static char * package
The package name in which functions will be defined.
Definition: genLisp.c:59
#define DEFAULT_INTEGER_TYPE_SIZE
entity make_empty_program(const char *name, language l)
Definition: entity.c:261
#define entity_undefined_p(x)
Definition: ri.h:2762

References COMPLEXITY_PACKAGE_NAME, DEFAULT_INTEGER_TYPE_SIZE, entity_undefined_p, make_basic_int(), make_empty_program(), make_language_fortran(), make_new_scalar_variable_with_prefix(), make_single_var_complexity(), and package.

Referenced by simplify_sc_to_complexity(), and whileloop_to_complexity().

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

◆ make_constant_complexity()

complexity make_constant_complexity ( double  )

◆ make_single_var_complexity()

complexity make_single_var_complexity ( double  ,
Variable   
)

◆ make_zero_complexity()

◆ minus_op_handler()

complexity minus_op_handler ( list  args,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)
Parameters
argsrgs
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 472 of file comp_expr_to_pnome.c.

478 {
480  precond, effects_list, keep_symbols,
481  maximize);
483  precond, effects_list, keep_symbols,
484  -maximize);
485 
486  complexity_sub(&c1, c2);
487  complexity_rm(&c2);
488 
489  return (c1);
490 }
void complexity_sub(complexity *pcomp1, complexity comp2)
void complexity_sub(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 - comp2; !...
Definition: comp_math.c:394

References CAR, CDR, complexity_rm(), complexity_sub(), EXPRESSION, and expression_to_complexity_polynome().

Referenced by call_to_polynome().

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

◆ multiply_op_handler()

complexity multiply_op_handler ( list  args,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)
Parameters
argsrgs
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 492 of file comp_expr_to_pnome.c.

498 {
500  precond, effects_list, keep_symbols,
501  maximize);
503  precond, effects_list, keep_symbols,
504  maximize);
505 
506  complexity_mult(&c1, c2);
507  complexity_rm(&c2);
508 
509  return (c1);
510 }

References CAR, CDR, complexity_mult(), complexity_rm(), EXPRESSION, and expression_to_complexity_polynome().

Referenced by call_to_polynome().

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

◆ name_to_variable()

Variable name_to_variable ( char *  name)
Parameters
nameame

Definition at line 172 of file polynome_ri.c.

173 {
174  if (strcmp(name, TCST_NAME) == 0)
175  return(TCST);
176  /*
177  else if (strcmp(name, UNKNOWN_VARIABLE_NAME) == 0)
178  return (UNKNOWN_VARIABLE);
179  else if (strcmp(name, UNKNOWN_RANGE_NAME) == 0)
180  return (UNKNOWN_RANGE);
181  */
182  else {
184  if (e != entity_undefined)
185  return ((Variable) e);
186  else {
187  user_warning("name_to_variable",
188  "entity '%s' not found:return chunk_undefined\n", name);
189  return((Variable) chunk_undefined);
190  }
191  }
192 }

References chunk_undefined, entity_domain, entity_undefined, gen_find_tabulated(), TCST, TCST_NAME, and user_warning.

Referenced by polynome_sscanf(), and translate_complexity_from_local_to_current_name().

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

◆ node_successors_to_matrix()

void node_successors_to_matrix ( control  ,
matrice  ,
int  ,
control  [],
bool  [] 
)

◆ noms_var()

char* noms_var ( entity  e)

comp_expr_to_pnome.c

Definition at line 60 of file comp_expr_to_pnome.c.

62 {
63  bool entity_has_values_p();
64  string external_value_name();
65 
66  if(e == (entity) TCST)
67  return "";
68  else
69  return entity_has_values_p(e) ? (char *)module_local_name(e) :
70  (char *)external_value_name(e);
71 }
const char * external_value_name(entity)
Definition: value.c:753
bool entity_has_values_p(entity)
This function could be made more robust by checking the storage of e.
Definition: value.c:911

References entity_has_values_p(), external_value_name(), module_local_name(), and TCST.

Referenced by evaluate_var_to_complexity(), plint(), plint_pas(), sc_resol_smith(), simplify_sc_to_complexity(), smith_int(), and sol_finale().

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

◆ normalized_to_polynome()

complexity normalized_to_polynome ( normalized  no,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)

2nd element of expression

Parameters
noo
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 211 of file comp_expr_to_pnome.c.

217 {
219 
220  trace_on("normalized -> pnome");
221 
222  if (normalized_linear_p(no) ) {
223  Pvecteur pvect = (Pvecteur)normalized_linear(no);
224  comp = pvecteur_to_polynome(pvect, precond, effects_list, keep_symbols, maximize);
225  }
226  else
227  pips_internal_error("vecteur undefined");
228 
229  trace_off();
230  return(comp);
231 }
complexity pvecteur_to_polynome(Pvecteur pvect, transformer precond, list effects_list, bool keep_symbols, int maximize)
The only element available of normalized.
#define normalized_linear(x)
Definition: ri.h:1781
struct Svecteur * Pvecteur

References make_zero_complexity(), normalized_linear, normalized_linear_p, pips_internal_error, pvecteur_to_polynome(), trace_off(), and trace_on().

Referenced by expression_to_complexity_polynome().

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

◆ plus_op_handler()

complexity plus_op_handler ( list  args,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)
Parameters
argsrgs
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 452 of file comp_expr_to_pnome.c.

458 {
460  precond, effects_list, keep_symbols,
461  maximize);
463  precond, effects_list, keep_symbols,
464  maximize);
465 
466  complexity_add(&c1, c2);
467  complexity_rm(&c2);
468 
469  return (c1);
470 }

References CAR, CDR, complexity_add(), complexity_rm(), EXPRESSION, and expression_to_complexity_polynome().

Referenced by call_to_polynome().

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

◆ polynome_to_new_complexity()

complexity polynome_to_new_complexity ( Ppolynome  pp)

Create a complexity equal to Ppolynome pp with null statistics.

pp IS duplicated.

Parameters
ppp

Definition at line 200 of file comp_math.c.

202 {
203  varcount vc = make_varcount(0,0,0,0);
204  rangecount rc = make_rangecount(0,0,0,0);
205  ifcount ic = make_ifcount(0,0,0);
206  Ppolynome ppdup;
207  complexity comp;
208 
209  pips_assert("polynome_to_new_complexity", !POLYNOME_UNDEFINED_P(pp));
210 
211  ppdup = polynome_dup(pp);
212  comp = make_complexity(ppdup, vc, rc, ic);
213  ifdebug(1) {
214  (void) complexity_consistent_p(comp);
215  }
216  return comp;
217 }

References complexity_consistent_p(), ifdebug, make_complexity(), make_ifcount(), make_rangecount(), make_varcount(), pips_assert, polynome_dup(), and POLYNOME_UNDEFINED_P.

Referenced by complexity_float_add(), complexity_sigma(), complexity_var_subst(), make_single_var_complexity(), pvecteur_to_polynome(), and reference_to_polynome().

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

◆ power_op_handler()

complexity power_op_handler ( list  args,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)

polynome_rm(&(complexity_eval(c1)));

(Ppolynome) complexity_eval(c1) = pp;

Parameters
argsrgs
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 589 of file comp_expr_to_pnome.c.

595 {
596  float power;
598  precond, effects_list, keep_symbols,
599  maximize);
601  precond, effects_list, DONT_KEEP_SYMBOLS,
602  maximize);
603 
604  if (complexity_constant_p(c2)) {
605  power = complexity_TCST(c2);
606  complexity_rm(&c2);
607  if (power == (int) power) {
609  (int) power);
610  Ppolynome pt = complexity_eval(c1);
611 
612  /* polynome_rm(&(complexity_eval(c1))); */
613  polynome_rm(&pt);
614  /* (Ppolynome) complexity_eval(c1) = pp; */
616  return (c1);
617  }
618  }
619  else
620  complexity_rm(&c2);
621 
622  complexity_rm(&c1);
623  return (make_zero_complexity());
624 }
Ppolynome polynome_power_n(Ppolynome pp, int n)
Ppolynome polynome_power_n(Ppolynome pp, int n) returns pp ^ n (n>=0)
Definition: pnome-scal.c:121

References CAR, CDR, complexity_constant_p(), complexity_eval, complexity_eval_, complexity_polynome(), complexity_rm(), complexity_TCST(), DONT_KEEP_SYMBOLS, EXPRESSION, expression_to_complexity_polynome(), make_zero_complexity(), newgen_Ppolynome, polynome_power_n(), and polynome_rm().

Referenced by call_to_polynome().

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

◆ prc()

void prc ( complexity  comp)
Parameters
compomp

Definition at line 233 of file comp_util.c.

235 {
236  complexity_fprint(stderr, comp, true, true);
237 }

References complexity_fprint().

Referenced by pvecteur_to_polynome().

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

◆ print_call_graph_with_complexities()

bool print_call_graph_with_complexities ( const  string)
Parameters
stringodule_name

Definition at line 254 of file comp_prettyprint.c.

255 {
256  bool success = false;
258  return success;
259 }
bool print_decorated_call_graph(const string, text(*)(const string))
Definition: print.c:64
static text get_text_complexities(const string module_name)

References get_text_complexities(), module_name(), and print_decorated_call_graph().

+ Here is the call graph for this function:

◆ print_code_as_a_graph_complexities()

bool print_code_as_a_graph_complexities ( const  string)
Parameters
stringod_name

Definition at line 234 of file comp_prettyprint.c.

235 {
236  bool success;
237 
238  set_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH", true);
239  success = print_code_complexities(mod_name);
240  set_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH", false);
241 
242  return success;
243 }
bool print_code_complexities(const string module_name)
comp_prettyprint.c
void set_bool_property(const char *, bool)

References print_code_complexities(), and set_bool_property().

+ Here is the call graph for this function:

◆ print_code_complexities()

bool print_code_complexities ( const  string)

comp_prettyprint.c

Parameters
stringodule_name

Definition at line 228 of file comp_prettyprint.c.

229 {
230  is_user_view = false;
232 }
static bool is_user_view
useful
static bool print_code_or_source_comp(const string module_name)

References is_user_view, module_name(), and print_code_or_source_comp().

Referenced by print_code_as_a_graph_complexities().

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

◆ print_icfg_with_complexities()

bool print_icfg_with_complexities ( const  string)
Parameters
stringodule_name

◆ print_icfg_with_control_complexities()

bool print_icfg_with_control_complexities ( const  string)
Parameters
stringodule_name

◆ print_icfg_with_loops_complexities()

bool print_icfg_with_loops_complexities ( const  string)
Parameters
stringodule_name

◆ print_source_complexities()

bool print_source_complexities ( const  string)
Parameters
stringodule_name

Definition at line 245 of file comp_prettyprint.c.

246 {
247  is_user_view = true;
249 }

References is_user_view, module_name(), and print_code_or_source_comp().

+ Here is the call graph for this function:

◆ prp()

void prp ( Ppolynome  pp)
Parameters
ppp

Definition at line 239 of file comp_util.c.

241 {
243  fprintf(stderr, "\n");
244 }
void polynome_fprint(FILE *fd, Ppolynome pp, char *(*variable_name)(Variable), int *is_inferior_var)
void polynome_fprint(FILE* fd, Ppolynome pp, char* (*variable_name)(), bool (*is_inferior_var)()) Out...
Definition: pnome-io.c:173

References fprintf(), is_inferior_pvarval(), polynome_fprint(), and variable_name().

Referenced by complexity_sigma().

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

◆ prv()

void prv ( Pvecteur  pv)
Parameters
pvv

Definition at line 246 of file comp_util.c.

248 {
250  fprintf(stderr, "\n");
251 }
void vect_fprint_as_monome(FILE *f, Pvecteur v, Pbase b, get_variable_name_t variable_name, char *mult_symbol)
void vect_fprint_as_monome(FILE * f, Pvecteur v, Pbase b, char * (*variable_name)(),...
Definition: io.c:201
#define BASE_NULLE
MACROS SUR LES BASES.

References BASE_NULLE, fprintf(), variable_name(), and vect_fprint_as_monome().

Referenced by sc_projection_optim_along_vecteur_ofl().

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

◆ pvecteur_to_polynome()

complexity pvecteur_to_polynome ( Pvecteur  pvect,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)

The only element available of normalized.

bool must_be_written = false;

if (we_must_evaluate && must_be_written) {

should be multiplied by "val" here

We keep this symbol (including TCST) in the polynome

Parameters
pvectvect
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 234 of file comp_expr_to_pnome.c.

240 {
242  Ppolynome ppvar;
243  Pvecteur pv;
244  Variable var;
245  Value val;
246  bool we_must_evaluate;
247 /* bool must_be_written = false; */
248 
249  trace_on("pvecteur -> pnome maximize is %d", maximize);
250 
251  if ( get_bool_property("COMPLEXITY_INTERMEDIATES") ) {
252  fprintf(stderr, "expr->pnome: pvecteur = ");
253  vect_fprint(stderr, pvect, variable_name);
254  }
255 
256  for(pv=pvect; !VECTEUR_NUL_P(pv); pv = pv->succ) {
257  var = vect_first_var(pv);
258  val = vect_coeff(var, pv);
259 
260  we_must_evaluate =
261  (var != TCST) &&
263  (char *)module_local_name((entity)var)))
264  : true);
265 /*
266  must_be_written = is_must_be_written_var(effects_list,
267  variable_local_name(var));
268 
269  if ( get_debug_level() >= 3 ) {
270  fprintf(stderr, "Must be written var %s\n", variable_local_name(var) );
271  }
272 */
273 /*
274  if (we_must_evaluate && must_be_written) {
275 */
276  if (we_must_evaluate && get_bool_property("COMPLEXITY_EARLY_EVALUATION")) {
277  complexity ctmp;
278  ctmp = evaluate_var_to_complexity((entity)var, precond, effects_list, maximize);
279  /* should be multiplied by "val" here */
281  complexity_add(&comp, ctmp);
282  }
283  else {
284  /* We keep this symbol (including TCST) in the polynome */
285  Value exp = VALUE_ONE;
286  float coeff = VALUE_TO_FLOAT(val);
287 
288  ppvar = make_polynome(coeff, var, exp);
289  if (complexity_zero_p(comp))
290  comp = polynome_to_new_complexity(ppvar);
291  else
292  complexity_polynome_add(&comp, ppvar);
294  }
295  }
296 
297  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
298  fprintf(stderr, "Pvecteur evaluation = ");
299  prc(comp);
300  }
301 
302  trace_off();
303  return (comp);
304 }
int Value
#define VALUE_TO_FLOAT(val)
hash_table hash_complexity_parameters
Definition: comp_scan.c:58
void prc(complexity comp)
Definition: comp_util.c:233
#define hash_contains_p(htp, key)
void vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
Definition: io.c:124
Variable vect_first_var(Pvecteur pvec)
PRIVATE: marquage du couple var_val comme visite par remplacement de var par -var dans le couple (OBS...
Definition: private.c:227
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

References complexity_add(), complexity_polynome_add(), complexity_scalar_mult(), complexity_varcount, complexity_zero_p(), evaluate_var_to_complexity(), exp, fprintf(), get_bool_property(), hash_complexity_parameters, hash_contains_p, make_polynome(), make_zero_complexity(), module_local_name(), polynome_to_new_complexity(), prc(), Svecteur::succ, TCST, trace_off(), trace_on(), VALUE_ONE, VALUE_TO_FLOAT, varcount_symbolic, variable_name(), vect_coeff(), vect_first_var(), vect_fprint(), and VECTEUR_NUL_P.

Referenced by normalized_to_polynome().

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

◆ range_to_complexity()

complexity range_to_complexity ( range  rng,
transformer  precond,
list  effects_list 
)

2nd element of syntax

Parameters
rngng
precondrecond
effects_listffects_list

Definition at line 1089 of file comp_scan.c.

1093 {
1094  complexity compl = NULL, compu = NULL, compi = NULL;
1095  expression lower = range_lower(rng);
1096  expression upper = range_upper(rng);
1097  expression incr = range_increment(rng);
1098  basic rngbasic;
1099 
1100  trace_on("range");
1101 
1102  if (!expression_undefined_p(lower))
1103  compl = expression_to_complexity(lower, &rngbasic, precond,
1104  effects_list);
1105  else
1106  pips_internal_error("lower undefined");
1107 
1108  if (!expression_undefined_p(upper))
1109  compu = expression_to_complexity(upper, &rngbasic, precond,
1110  effects_list);
1111  else
1112  pips_internal_error("upper undefined");
1113 
1114  if (!expression_undefined_p(incr))
1115  compi = expression_to_complexity(incr, &rngbasic, precond,
1116  effects_list);
1117  else
1118  pips_internal_error("increment undefined");
1119 
1120  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
1121  fprintf(stderr, "\n");
1122  fprintf(stderr, "--- range lower complexity: ");
1123  complexity_fprint(stderr, compl, false, true);
1124  fprintf(stderr, "--- range upper complexity: ");
1125  complexity_fprint(stderr, compu, false, true);
1126  fprintf(stderr, "--- range incr complexity: ");
1127  complexity_fprint(stderr, compi, false, true);
1128  }
1129 
1130  complexity_add(&compl, compu);
1131  complexity_add(&compl, compi);
1132  complexity_rm(&compu);
1133  complexity_rm(&compi);
1134 
1135  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
1136  fprintf(stderr, "--- range total complexity: ");
1137  complexity_fprint(stderr, compl, true, true);
1138  fprintf(stderr, "\n");
1139  }
1140  complexity_check_and_warn("range_to_complexity", compl);
1141 
1142  trace_off();
1143  return(compl);
1144 }
#define expression_undefined_p(x)
Definition: ri.h:1224

References complexity_add(), complexity_check_and_warn(), complexity_fprint(), complexity_rm(), expression_to_complexity(), expression_undefined_p, fprintf(), get_bool_property(), pips_internal_error, range_increment, range_lower, range_upper, trace_off(), and trace_on().

Referenced by loop_to_complexity(), and syntax_to_complexity().

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

◆ range_to_polynome()

complexity range_to_polynome ( range  ,
transformer  ,
list  ,
bool  ,
int   
)

◆ reference_to_complexity()

complexity reference_to_complexity ( reference  ref,
basic pbasic,
transformer  precond,
list  effects_list 
)

1st element of syntax

reference_to_complexity: return the complexity of the computing of the indices plus the complexity of one memory read Also return basic type of variable in *pbasic.

indices basic

ci=compindexation, ca=compaccess

ci=compindexation counts multi-dimension arrays indexation costs

Parameters
refef
pbasicbasic
precondrecond
effects_listffects_list

Definition at line 952 of file comp_scan.c.

957 {
959  list ind = reference_indices(ref);
960 
961  const char* name = module_local_name(var);
963  basic ib = MAKE_INT_BASIC; /* indices basic */
964  complexity comp, ci, ca; /* ci=compindexation, ca=compaccess */
965 
966  trace_on("reference %s", entity_name(var));
967 
968  if ( basic_int_p(b) || basic_float_p(b) ||
970  *pbasic = simple_basic_dup(b);
971  else if (basic_string_p(b))
972  *pbasic = MAKE_STRING_BASIC;
973  else if (basic_derived_p(b) || basic_pointer_p(b)){
974  *pbasic = MAKE_ADDRESS_BASIC;
975  }
976  else {
977  user_warning("reference_to_complexity",
978  "basic_tag %d, not in 1->9\n", (int)basic_tag(b));
979  }
980 
981  comp = indices_to_complexity(ind, &ib, precond, effects_list);
982 
983  /* ci=compindexation counts multi-dimension arrays indexation costs */
984 
985  switch ( gen_length(ind) ) {
986  case 0:
987  ci = make_zero_complexity();
988  break;
989  case 1:
990  ci = make_constant_complexity((float)
992  break;
993  case 2:
994  ci = make_constant_complexity((float)
996  break;
997  case 3:
998  ci = make_constant_complexity((float)
1000  break;
1001  case 4:
1002  ci = make_constant_complexity((float)
1004  break;
1005  case 5:
1006  ci = make_constant_complexity((float)
1008  break;
1009  case 6:
1010  ci = make_constant_complexity((float)
1012  break;
1013  default:
1014  ci = make_constant_complexity((float)
1016  }
1017 
1018  if(entity_register_p(var))
1019  ca = make_zero_complexity();
1020  else
1021  ca = make_constant_complexity((float)
1023  &ib));
1024 
1025  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
1026  fprintf(stderr, "\n");
1027  fprintf(stderr, ">>> ref. %s argus complexity: ", name);
1028  complexity_fprint(stderr, comp, false, true);
1029  fprintf(stderr, ">>> ref. %s access complexity: ", name);
1030  complexity_fprint(stderr, ca, false, true);
1031  fprintf(stderr, ">>> ref. %s indices complexity: ", name);
1032  complexity_fprint(stderr, ci, false, true);
1033  }
1034 
1035  complexity_add(&comp, ca);
1036  complexity_add(&comp, ci);
1037  complexity_rm(&ca);
1038  complexity_rm(&ci);
1039 
1040  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
1041  fprintf(stderr, ">>> ref. %s total complexity: ", name);
1042  complexity_fprint(stderr, comp, true, true);
1043  fprintf(stderr,"\n");
1044  }
1045 
1046  complexity_check_and_warn("reference_to_complexity", comp);
1047 
1048  trace_off();
1049  return(comp);
1050 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
complexity indices_to_complexity(list exprlist, basic *pbasic, transformer precond, list effects_list)
2nd element of reference
Definition: comp_scan.c:1057
#define MAKE_ADDRESS_BASIC
#define FOUR_INDEX_NAME
#define ONE_INDEX_NAME
#define MEMORY_READ_NAME
the above two lines are added for 6th cost file, overhead.
#define MAKE_STRING_BASIC
#define SIX_INDEX_NAME
#define FIVE_INDEX_NAME
#define SEVEN_INDEX_NAME
#define THREE_INDEX_NAME
#define TWO_INDEX_NAME
bool entity_register_p(entity e)
Definition: entity.c:766
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677
#define basic_complex_p(x)
Definition: ri.h:626
#define type_variable(x)
Definition: ri.h:2949
#define basic_pointer_p(x)
Definition: ri.h:635
#define basic_derived_p(x)
Definition: ri.h:638
#define reference_indices(x)
Definition: ri.h:2328
#define basic_string_p(x)
Definition: ri.h:629
#define variable_basic(x)
Definition: ri.h:3120
#define basic_logical_p(x)
Definition: ri.h:620

References basic_complex_p, basic_derived_p, basic_float_p, basic_int_p, basic_logical_p, basic_pointer_p, basic_string_p, basic_tag, complexity_add(), complexity_check_and_warn(), complexity_fprint(), complexity_rm(), entity_basic_concrete_type(), entity_name, entity_register_p(), FIVE_INDEX_NAME, FOUR_INDEX_NAME, fprintf(), gen_length(), get_bool_property(), indices_to_complexity(), intrinsic_cost(), MAKE_ADDRESS_BASIC, make_constant_complexity(), MAKE_INT_BASIC, MAKE_STRING_BASIC, make_zero_complexity(), MEMORY_READ_NAME, module_local_name(), ONE_INDEX_NAME, ref, reference_indices, reference_variable, SEVEN_INDEX_NAME, simple_basic_dup(), SIX_INDEX_NAME, THREE_INDEX_NAME, trace_off(), trace_on(), TWO_INDEX_NAME, type_variable, user_warning, and variable_basic.

Referenced by syntax_to_complexity().

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

◆ reference_to_polynome()

complexity reference_to_polynome ( reference  ref,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)

First element of the "syntax" domain.

bool must_be_written;

if it's an array: let us fail

We keep this symbol in the polynome

Parameters
refef
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 307 of file comp_expr_to_pnome.c.

312 {
314  bool we_must_evaluate;
315 /* bool must_be_written; */
317 
318  trace_on("reference -> pnome");
319 
320  if ( reference_indices(ref) == NIL) {
321  /* if it's an array: let us fail */
322  we_must_evaluate = (keep_symbols ?
324  (char *)module_local_name((entity)var) ):
325  true);
326 /*
327  must_be_written = is_must_be_written_var(effects_list, var);
328 
329  if ( get_debug_level() >= 3 ) {
330  fprintf(stderr, "Must be written var %s\n", noms_var(var) );
331  }
332 */
333 /*
334  if (we_must_evaluate && must_be_written) {
335 */
336  if (we_must_evaluate && get_bool_property("COMPLEXITY_EARLY_EVALUATION")) {
337  comp = evaluate_var_to_complexity((entity)var, precond, effects_list, maximize);
338  }
339  else { /* We keep this symbol in the polynome */
340  Ppolynome pp = make_polynome((float) 1, (Variable) var, VALUE_ONE);
341  comp = polynome_to_new_complexity(pp);
343  polynome_rm(&pp);
344  }
345  }
346 
347  trace_off();
348  return(comp);
349 }
#define true
Definition: newgen_types.h:81

References complexity_varcount, evaluate_var_to_complexity(), get_bool_property(), hash_complexity_parameters, hash_contains_p, make_polynome(), make_zero_complexity(), module_local_name(), NIL, polynome_rm(), polynome_to_new_complexity(), ref, reference_indices, reference_variable, trace_off(), trace_on(), VALUE_ONE, and varcount_symbolic.

Referenced by syntax_to_polynome().

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

◆ remove_common_variables_from_hash_table()

void remove_common_variables_from_hash_table ( entity  module,
hash_table  hash_complexity_params 
)
Parameters
moduleodule
hash_complexity_paramsash_complexity_params

Definition at line 985 of file comp_util.c.

988 {
989  const char* module_name = module_local_name(module);
990  list sefs_list;
991 
992  pips_assert("remove_common_variables_from_hash_table",
994 
995  sefs_list = effects_to_list( (effects)
996  db_get_memory_resource(DBR_SUMMARY_EFFECTS, module_name, true));
997 
998  MAPL(ce, {
999  effect obj = EFFECT(CAR(ce));
1001  action ac = effect_action(obj);
1003  entity e = reference_variable(r);
1004 
1005  if ( action_read_p(ac) && approximation_exact_p(ap) ) {
1006  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
1007  fprintf(stderr, "%s deleted\n", module_local_name(e));
1008  }
1009  hash_del(hash_complexity_params, (char *) module_local_name(e));
1010  }
1011  }, sefs_list);
1012 }

References action_read_p, approximation_exact_p, CAR, db_get_memory_resource(), EFFECT, effect_action, effect_any_reference, effect_approximation, effects_to_list(), entity_module_p(), fprintf(), get_bool_property(), hash_del(), MAPL, module, module_local_name(), module_name(), pips_assert, and reference_variable.

Referenced by any_complexities().

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

◆ remove_formal_parameters_from_hash_table()

void remove_formal_parameters_from_hash_table ( entity  mod,
hash_table  hash_complexity_params 
)
Parameters
modod
hash_complexity_paramsash_complexity_params

Definition at line 791 of file comp_util.c.

794 {
795  list decl;
796 
797  pips_assert("remove_formal_parameters_from_hash_table",
798  entity_module_p(mod));
800 
801  MAPL(pe, {
802  entity param = ENTITY(CAR(pe));
804  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
805  fprintf(stderr,"storage_formal %s to be deleted\n",
806  entity_name(param));
807  }
808  hash_del(hash_complexity_params, (char *) module_local_name(param));
809  }, decl);
810 }

References CAR, code_declarations, ENTITY, entity_initial, entity_module_p(), entity_name, entity_storage, fprintf(), get_bool_property(), hash_del(), MAPL, module_local_name(), pips_assert, storage_formal_p, and value_code.

Referenced by any_complexities().

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

◆ replace_formal_parameters_by_real_ones()

complexity replace_formal_parameters_by_real_ones ( complexity  comp,
entity  mod,
list  args,
transformer  precond,
list  effects_list 
)

transform formal params into real ones (args) in complexity comp

print out the entity name for debugging purpose

if formal parameter...

minus one because offsets start at 1 not 0

Parameters
compomp
modod
argsrgs
precondrecond
effects_listffects_list

Definition at line 519 of file comp_math.c.

525 {
526  complexity cresult = complexity_dup(comp);
527  complexity carg, ctemp;
529  char *param_name;
530  int param_rank;
531  list argument;
532 
533  pips_assert("replace_formal_parameters_by_real_ones", entity_module_p(mod));
534 
535  FOREACH (ENTITY, param,decl) {
537 
538  /* print out the entity name for debugging purpose */
539  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
540  fprintf(stderr,"in REPLACE, entity name is %s\n",
541  entity_name(param));
542  }
543 
544  if (storage_formal_p(st)) {
545  /* if formal parameter... */
546  param_name = entity_name(param);
547  param_rank = formal_offset(storage_formal(st));
548 
549  argument = gen_nthcdr(param_rank-1,args);/* minus one because offsets start at 1 not 0 */
550 
551  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
552  fprintf(stderr,"formal offset=%d, formal name=%s\n",
553  param_rank, param_name);
554  }
555 
557  precond,
558  effects_list,
559  KEEP_SYMBOLS,
560  EXACT_VALUE);
561 
562  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
563  fprintf(stderr,"variable name is %s\n", variable_name((Variable)param) );
564  }
565 
566  ctemp = complexity_var_subst(cresult, (Variable)param, carg);
567  complexity_rm(&cresult);
568  cresult = complexity_dup(ctemp);
569  complexity_rm(&carg);
570  }
571  }
572 
573  return (cresult);
574 }
#define EXACT_VALUE
#define formal_offset(x)
Definition: ri.h:1408
#define storage_formal(x)
Definition: ri.h:2524
Polymorphic argument.
Definition: printf-args.h:92

References CAR, code_declarations, complexity_dup(), complexity_rm(), complexity_var_subst(), ENTITY, entity_initial, entity_module_p(), entity_name, entity_storage, EXACT_VALUE, EXPRESSION, expression_to_complexity_polynome(), FOREACH, formal_offset, fprintf(), gen_nthcdr(), get_bool_property(), KEEP_SYMBOLS, pips_assert, storage_formal, storage_formal_p, value_code, and variable_name().

Referenced by call_to_complexity().

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

◆ reset_complexity_map()

◆ set_complexity_map()

◆ simplify_sc_to_complexity()

complexity simplify_sc_to_complexity ( Psysteme  ps,
Variable  var 
)

This function is recently added by L.Zhou June 5, 91 simplify_sc_to_complexity(Psysteme ps, Variable var) It looks for the egality formula containing (Variable)var in the system (Psysteme)ps.

If ps->egalites is NULL, zero complexity is returned. The rest of the variable in that formula should be the known variable for example: formal parameter(s), inductible variable, etc. EX: M1 - M2 = 1 where M1 is formal parameter where M2 is an inductible variable This function returns M2 = M1 - 1 packed in the polynomial of the complexity the statistics of this complexity should be all zero.

Parameters
pss
varar

Definition at line 798 of file comp_expr_to_pnome.c.

801 {
803  Value var_coeff=VALUE_ONE;
804 
805  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
806  sc_fprint(stderr, ps, (get_variable_name_t) noms_var);
807  }
808 
809  if ( !SC_UNDEFINED_P(ps) && !CONTRAINTE_UNDEFINED_P(ps->egalites) ) {
810  Pvecteur v = (ps->egalites)->vecteur;
811 
812  for ( ; !VECTEUR_NUL_P(v); v=v->succ ) {
813  if ( v->var != TCST ) {
814  if ( v->var != (Variable)var ) {
816  (VALUE_TO_FLOAT(v->val),v->var);
817  complexity_add(&comp, c);
818  complexity_rm(&c);
819  }
820  else {
821  var_coeff = value_uminus(v->val);
822  }
823  }
824  else {
826  (VALUE_TO_FLOAT(v->val));
827  complexity_add(&comp, c);
828  complexity_rm(&c);
829  }
830  }
831  }
832  else {
834  (char *)module_local_name((entity)var));
835 
836  if ( b )
837  comp = make_single_var_complexity(1.0, (Variable)var);
838  else
840  }
841 
842  complexity_scalar_mult(&comp,1.0/VALUE_TO_FLOAT(var_coeff));
844 
845  return (comp);
846 }
#define value_uminus(val)
unary operators on values
complexity make_complexity_unknown(const char *name)
builds a new unknown complexity attached to a virtual package
char * noms_var(entity e)
comp_expr_to_pnome.c
#define UNKNOWN_VARIABLE_NAME
pseudo-variable for unknown variables
#define CONTRAINTE_UNDEFINED_P(c)
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
Pcontrainte egalites
Definition: sc-local.h:70
Value val
Definition: vecteur-local.h:91
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62

References complexity_add(), complexity_rm(), complexity_scalar_mult(), complexity_varcount, CONTRAINTE_UNDEFINED_P, get_bool_property(), hash_complexity_parameters, hash_contains_p, make_complexity_unknown(), make_constant_complexity(), make_single_var_complexity(), make_zero_complexity(), module_local_name(), noms_var(), sc_fprint(), Svecteur::succ, TCST, UNKNOWN_VARIABLE_NAME, Svecteur::val, VALUE_ONE, VALUE_TO_FLOAT, value_uminus, Svecteur::var, varcount_unknown, and VECTEUR_NUL_P.

Referenced by evaluate_var_to_complexity().

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

◆ statement_complexity_undefined_p()

bool statement_complexity_undefined_p ( statement  )

◆ statement_to_complexity()

complexity statement_to_complexity ( statement  ,
transformer  ,
list   
)

◆ store_statement_complexity()

void store_statement_complexity ( statement  ,
complexity   
)

Referenced by statement_to_complexity().

+ Here is the caller graph for this function:

◆ subscript_to_complexity()

complexity subscript_to_complexity ( subscript  sub,
basic pbasic,
transformer  precond,
list  effects_list 
)

G:let us assume . cost 1

Parameters
subub
pbasicbasic
precondrecond
effects_listffects_list

Definition at line 860 of file comp_scan.c.

861  {
862 
864  subscript_array(sub),
865  pbasic,
866  precond,
867  effects_list);
869  subscript_indices(sub),
870  pbasic,
871  precond,
872  effects_list);
873  complexity_add(&cl,cr);
874  complexity_rm(&cr);
875  complexity_float_add(&cl,1.f);/*SG:let us assume . cost 1 */
876  return cl;
877 
878 }
#define subscript_indices(x)
Definition: ri.h:2563
#define subscript_array(x)
Definition: ri.h:2561

References complexity_add(), complexity_float_add(), complexity_rm(), expression_to_complexity(), indices_to_complexity(), subscript_array, and subscript_indices.

Referenced by syntax_to_complexity().

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

◆ summary_complexity()

bool summary_complexity ( const  string)

summary_comp_dup = complexity_dup(summary_comp);

Parameters
stringodule_name

Definition at line 179 of file comp_scan.c.

180 {
181  complexity summary_comp = make_zero_complexity();// complexity_undefined;
182  complexity summary_comp_dup = make_zero_complexity();// complexity_undefined;
183 
185  db_get_memory_resource(DBR_CODE, module_name, true ) );
186 
188  db_get_memory_resource(DBR_COMPLEXITIES, module_name, true));
190 
191  trace_on("summary complexity %s", module_name);
192  debug_on("COMPLEXITY_DEBUG_LEVEL");
193 
194  if ( summary_comp == COMPLEXITY_NOT_FOUND )
195  pips_internal_error("No summary complexity!");
196  else {
197  /* summary_comp_dup = complexity_dup(summary_comp); */
198  summary_comp_dup = copy_complexity(summary_comp);
199  }
200 
201  pips_assert("summary_comp is conssten",
202  complexity_consistent_p(summary_comp));
203  pips_assert("summary_comp_dup is consistent",
204  complexity_consistent_p(summary_comp_dup));
205 
206  trace_off();
207 
208  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
209  fprintf(stderr,"\n");
210  fprintf(stderr,"Before ======== SUMMARY ; module %s\n",module_name);
211  }
212 
213  debug_off();
214 
215  DB_PUT_MEMORY_RESOURCE(DBR_SUMMARY_COMPLEXITY,
217  (char *) summary_comp_dup);
218 
219  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
220  fprintf(stderr,"After ======== SUMMARY ; module %s\n",module_name);
221  }
222 
225 
226  return true;
227 }
complexity copy_complexity(complexity p)
COMPLEXITY.
Definition: complexity_ri.c:18
complexity load_statement_complexity(statement)

References complexity_consistent_p(), COMPLEXITY_NOT_FOUND, copy_complexity(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, fprintf(), get_bool_property(), get_current_module_statement(), load_statement_complexity(), make_zero_complexity(), module_name(), pips_assert, pips_internal_error, reset_complexity_map(), reset_current_module_statement(), set_complexity_map(), set_current_module_statement(), strdup(), trace_off(), and trace_on().

+ Here is the call graph for this function:

◆ syntax_to_complexity()

complexity syntax_to_complexity ( syntax  s,
basic pbasic,
transformer  precond,
list  effects_list 
)

the only available element of expression

A cost for casting could be added, although casting is mostly used for typing issue. However, (float) 2 has a cost.

TypeCast operation added by Molka Becher to complexity_cost_tables for handling the cost of cast when it is necessary, 24 March 2011

Compiler generated constant: equivalent to a constant load --> 0

Parameters
pbasicbasic
precondrecond
effects_listffects_list

Definition at line 881 of file comp_scan.c.

886 {
887  complexity comp = make_zero_complexity();// complexity_undefined;
888 
889  trace_on("syntax");
890 
891  switch (syntax_tag(s)) {
892  case is_syntax_reference:
893  comp = reference_to_complexity(syntax_reference(s), pbasic,
894  precond, effects_list);
895  break;
896  case is_syntax_range:
897  comp = range_to_complexity(syntax_range(s), precond, effects_list);
898  break;
899  case is_syntax_call:
900  comp = call_to_complexity(syntax_call(s), pbasic, precond, effects_list);
901  break;
902  case is_syntax_cast: {
903  cast c = syntax_cast(s);
904  /* A cost for casting could be added, although casting is mostly
905  used for typing issue. However, (float) 2 has a cost. */
906  /* TypeCast operation added by Molka Becher to complexity_cost_tables
907  for handling the cost of cast when it is necessary, 24 March 2011 */
908  basic ib = MAKE_INT_BASIC;
909  comp = expression_to_complexity(cast_expression(c), pbasic, precond, effects_list);
911  complexity_add(&comp, c1);
912  complexity_rm(&c1);
913  break;
914  }
919  pbasic, precond, effects_list);
920  else {
921  /* Compiler generated constant: equivalent to a constant load --> 0*/
922  comp = make_zero_complexity();
923  }
924  break;
925  }
926  case is_syntax_subscript:
927  comp=subscript_to_complexity(syntax_subscript(s),pbasic,precond,effects_list);
928  break;
930  pips_internal_error("Not implemented yet");
931  break;
932  case is_syntax_va_arg:
933  pips_internal_error("Not implemented yet");
934  break;
935  default:
936  pips_internal_error("syntax_tag %d, not in %d->%d", (int)syntax_tag(s),
938  }
939 
940  complexity_check_and_warn("syntax_to_complexity", comp);
941 
942  trace_off();
943  return(comp);
944 }
complexity reference_to_complexity(reference ref, basic *pbasic, transformer precond, list effects_list)
1st element of syntax
Definition: comp_scan.c:952
complexity subscript_to_complexity(subscript sub, basic *pbasic, transformer precond, list effects_list)
Definition: comp_scan.c:860
#define TYPE_CAST_COST
TYPE_CAST_COST added to handle cast case ; Molka Becher
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
#define sizeofexpression_expression(x)
Definition: ri.h:2409
#define syntax_cast(x)
Definition: ri.h:2739
#define syntax_range(x)
Definition: ri.h:2733
@ is_syntax_range
Definition: ri.h:2692
@ is_syntax_application
Definition: ri.h:2697
@ is_syntax_cast
Definition: ri.h:2694
@ is_syntax_call
Definition: ri.h:2693
@ is_syntax_va_arg
Definition: ri.h:2698
@ is_syntax_reference
Definition: ri.h:2691
@ is_syntax_sizeofexpression
Definition: ri.h:2695
@ is_syntax_subscript
Definition: ri.h:2696
#define syntax_sizeofexpression(x)
Definition: ri.h:2742
#define sizeofexpression_expression_p(x)
Definition: ri.h:2407
#define syntax_call(x)
Definition: ri.h:2736
#define syntax_subscript(x)
Definition: ri.h:2745

References call_to_complexity(), cast_expression, complexity_add(), complexity_check_and_warn(), complexity_rm(), expression_to_complexity(), intrinsic_cost(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, make_constant_complexity(), MAKE_INT_BASIC, make_zero_complexity(), pips_internal_error, range_to_complexity(), reference_to_complexity(), sizeofexpression_expression, sizeofexpression_expression_p, subscript_to_complexity(), syntax_call, syntax_cast, syntax_range, syntax_reference, syntax_sizeofexpression, syntax_subscript, syntax_tag, trace_off(), trace_on(), and TYPE_CAST_COST.

Referenced by expression_to_complexity().

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

◆ syntax_to_polynome()

complexity syntax_to_polynome ( syntax  synt,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)

1st element of expression

This expression cannot be used within a polynomial, just like an array reference

Parameters
syntynt
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 166 of file comp_expr_to_pnome.c.

172 {
173  complexity comp = make_zero_complexity();// complexity_undefined;
174 
175  trace_on("syntax -> pnome");
176 
177  switch (syntax_tag(synt)) {
178  case is_syntax_reference:
180  precond, effects_list, keep_symbols, maximize);
181  break;
182  case is_syntax_range:
183  comp = range_to_polynome(syntax_range(synt),
184  precond, effects_list, keep_symbols, maximize);
185  break;
186  case is_syntax_call:
187  comp = call_to_polynome(syntax_call(synt),
188  precond, effects_list, keep_symbols, maximize);
189  break;
190  case is_syntax_cast:
191  comp = cast_to_polynome(syntax_cast(synt),
192  precond, effects_list, keep_symbols, maximize);
193  break;
195  case is_syntax_subscript:
197  case is_syntax_va_arg:
198  /* This expression cannot be used within a polynomial, just like
199  an array reference */
200  comp = make_zero_complexity();
201  break;
202  default:
203  pips_internal_error("Unexpected tag:%d\n", syntax_tag(synt));
204  }
205 
206  trace_off();
207  return (comp);
208 }
complexity reference_to_polynome(reference ref, transformer precond, list effects_list, bool keep_symbols, int maximize)
First element of the "syntax" domain.
complexity call_to_polynome(call call_instr, transformer precond, list effects_list, bool keep_symbols, int maximize)
3rd element of syntax
complexity cast_to_polynome(cast cast_instr, transformer precond, list effects_list, bool keep_symbols, int maximize)
4th element of syntax : Molka Becher
complexity range_to_polynome(range rg __attribute__((__unused__)), transformer precond __attribute__((__unused__)), list effects_list __attribute__((__unused__)), bool keep_symbols __attribute__((__unused__)), int maximize __attribute__((__unused__)))
2nd element of syntax

References call_to_polynome(), cast_to_polynome(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, make_zero_complexity(), pips_internal_error, range_to_polynome(), reference_to_polynome(), syntax_call, syntax_cast, syntax_range, syntax_reference, syntax_tag, trace_off(), and trace_on().

Referenced by expression_to_complexity_polynome().

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

◆ test_to_complexity()

complexity test_to_complexity ( test  test_instr,
transformer  precond,
list  effects_list 
)

2nd element of instruction

Parameters
test_instrest_instr
precondrecond
effects_listffects_list

Definition at line 414 of file comp_scan.c.

418 {
419  complexity comp, ctrue, cfalse, ctemp;
420  basic testbasic;
421 
422  trace_on("test");
423 
424  ctrue = statement_to_complexity(test_true(test_instr), precond, effects_list);
425  cfalse = statement_to_complexity(test_false(test_instr), precond, effects_list);
426  comp = expression_to_complexity(test_condition(test_instr),
427  &testbasic, precond, effects_list);
428 
429  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
430  fprintf(stderr, "\n");
431  fprintf(stderr, "YYY test true complexity: ");
432  complexity_fprint(stderr, ctrue, false, true);
433  fprintf(stderr, "YYY test false complexity: ");
434  complexity_fprint(stderr, cfalse, false, true);
435  fprintf(stderr, "YYY test cond. complexity: ");
436  complexity_fprint(stderr, comp, false, true);
437  }
438 
439  ctemp = complexity_dup(ctrue);
440  complexity_add(&ctemp, cfalse);
441  complexity_scalar_mult(&ctemp, 0.5);
442  complexity_add(&comp, ctemp);
443  complexity_rm(&ctemp);
444 
445  if ( !complexity_zero_p(comp) )
447 
448  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
449  fprintf(stderr, "YYY test total complexity: ");
450  complexity_fprint(stderr, comp, true, true);
451  fprintf(stderr, "\n");
452  }
453  complexity_check_and_warn("test_to_complexity", comp);
454 
455  trace_off();
456  return(comp);
457 }
#define test_false(x)
Definition: ri.h:2837
#define test_true(x)
Definition: ri.h:2835
#define test_condition(x)
Definition: ri.h:2833

References complexity_add(), complexity_check_and_warn(), complexity_dup(), complexity_fprint(), complexity_ifcount, complexity_rm(), complexity_scalar_mult(), complexity_zero_p(), expression_to_complexity(), fprintf(), get_bool_property(), ifcount_halfhalf, statement_to_complexity(), test_condition, test_false, test_true, trace_off(), and trace_on().

Referenced by instruction_to_complexity().

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

◆ trace_off()

void trace_off ( void  )

"trace off"

Definition at line 714 of file comp_util.c.

715 {
716  if (get_bool_property("COMPLEXITY_TRACE_CALLS")) {
717  char *indentstring = (char*) malloc(99);
718  bool b = (call_level >= 0);
719  int i,k=1;
720 
721  indentstring[0] = '\0';
722  call_level--;
723  for (i=0; i< (b ? call_level : - call_level); i++) {
724  indentstring = strcat(indentstring,
725  strdup(b ? ( (k>0) ? INDENT_BLANKS
726  : INDENT_VLINE )
727  : INDENT_BACK));
728  k = ( k<INDENT_INTERVAL ? k+1 : 0 );
729  }
730  fprintf(stderr, "%s<\n", indentstring);
731  free(indentstring);
732  }
733 }
#define INDENT_BACK
Definition: comp_util.c:92
#define INDENT_VLINE
Definition: comp_util.c:91
static int call_level
"trace on"
Definition: comp_util.c:683
#define INDENT_INTERVAL
Definition: comp_util.c:93
#define INDENT_BLANKS
comp_util.c
Definition: comp_util.c:90

References call_level, fprintf(), free(), get_bool_property(), INDENT_BACK, INDENT_BLANKS, INDENT_INTERVAL, INDENT_VLINE, malloc(), and strdup().

Referenced by any_complexities(), arguments_to_complexity(), block_to_complexity(), call_to_complexity(), call_to_polynome(), cast_to_polynome(), evaluate_var_to_complexity(), expression_to_complexity(), expression_to_complexity_polynome(), indices_to_complexity(), instruction_to_complexity(), loop_to_complexity(), new_block_to_complexity(), normalized_to_polynome(), pvecteur_to_polynome(), range_to_complexity(), range_to_polynome(), reference_to_complexity(), reference_to_polynome(), statement_to_complexity(), summary_complexity(), syntax_to_complexity(), syntax_to_polynome(), test_to_complexity(), and unstructured_to_complexity().

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

◆ trace_on()

void trace_on ( char *  fmt,
  ... 
)
Parameters
fmtmt

Definition at line 684 of file comp_util.c.

685 {
686  if (get_bool_property("COMPLEXITY_TRACE_CALLS")) {
687  va_list args;
688  char *indentstring = (char*) malloc(99);
689  bool b = (call_level >= 0);
690  int i,k=1;
691 
692  indentstring[0] = '\0';
693 
694  for (i=0; i< (b ? call_level : - call_level); i++) {
695  indentstring = strcat(indentstring,
696  strdup(b ? ( (k>0) ? INDENT_BLANKS
697  : INDENT_VLINE )
698  : INDENT_BACK));
699  k = ( k<INDENT_INTERVAL ? k+1 : 0 );
700  }
701 
702  fprintf(stderr, "%s>", indentstring);
703  va_start(args, fmt);
704  vfprintf(stderr, fmt, args);
705  fprintf(stderr, "\n");
706  va_end(args);
707 
708  free(indentstring);
709  call_level++;
710  }
711 }

References call_level, fprintf(), free(), get_bool_property(), INDENT_BACK, INDENT_BLANKS, INDENT_INTERVAL, INDENT_VLINE, malloc(), and strdup().

Referenced by any_complexities(), arguments_to_complexity(), block_to_complexity(), call_to_complexity(), call_to_polynome(), cast_to_polynome(), evaluate_var_to_complexity(), expression_to_complexity(), expression_to_complexity_polynome(), indices_to_complexity(), instruction_to_complexity(), loop_to_complexity(), new_block_to_complexity(), normalized_to_polynome(), pvecteur_to_polynome(), range_to_complexity(), range_to_polynome(), reference_to_complexity(), reference_to_polynome(), statement_to_complexity(), summary_complexity(), syntax_to_complexity(), syntax_to_polynome(), test_to_complexity(), and unstructured_to_complexity().

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

◆ translate_complexity_from_local_to_current_name()

complexity translate_complexity_from_local_to_current_name ( complexity  callee_comp,
string  oldname,
string  newname 
)

translate_complexity_from_local_to_current_name(callee_comp,oldname,newname) B:M -> A:M if A calls B 5 Feb.

93 LZ

This is not general enough to handle: B:M -> A:N or B:M to A:N+1 FI, 3 March 1994

constant complexity

The basis associated to a polynomial includes the constant term!

constant complexity

Parameters
callee_compallee_comp
oldnameldname
newnameewname

Definition at line 1100 of file comp_util.c.

1103 {
1104  Ppolynome pp = complexity_polynome(callee_comp);
1106  Pbase pbcur = BASE_UNDEFINED;
1108  complexity old_comp = complexity_dup(callee_comp);
1109 
1110  if(BASE_NULLE_P(pb)) {
1111  /* constant complexity */
1112  comp = complexity_dup(callee_comp);
1113  return comp;
1114  }
1115 
1116  /* The basis associated to a polynomial includes the constant term! */
1117  if(base_dimension(pb)==1 && term_cst(pb)) {
1118  /* constant complexity */
1119  comp = complexity_dup(callee_comp);
1120  return comp;
1121  }
1122 
1123  for (pbcur=pb; pbcur != VECTEUR_NUL ; pbcur = pbcur->succ ) {
1124  Variable var = pbcur->var;
1125  char * stmp = strdup(variable_name(var));
1126 
1127  char *s = stmp;
1128  char *t = strchr(stmp,':');
1129 
1130  if ( t != NULL ) {
1131  int length = (int)(t - s);
1132  char *cur_name = (char *)malloc(100);
1133 
1134  (void) strncpy(cur_name,stmp,length);
1135  * (cur_name+length) = '\0';
1136 
1137  if ( 1 || strncmp(cur_name, oldname, length) == 0 ) {
1138  Variable newvar = name_to_variable(concatenate(strdup(newname),
1139  ":",strdup(t+1),NULL));
1140  if ( newvar != (Variable) chunk_undefined ) {
1141  complexity compsubst = make_single_var_complexity(1.0, newvar);
1142 
1143 /*
1144  polynome_chg_var(&pp, var, newvar);
1145 */
1146  comp = complexity_var_subst(old_comp, var, compsubst);
1147  old_comp = complexity_dup(comp);
1148  }
1149  else {
1150  comp = complexity_dup(old_comp);
1151  old_comp = complexity_dup(comp);
1152  }
1153  }
1154  }
1155  }
1156  return (comp);
1157 }
void const char const char const int
Variable name_to_variable(char *)
Definition: polynome_ri.c:172
#define BASE_UNDEFINED
#define base_dimension(b)
#define BASE_NULLE_P(b)

References base_dimension, BASE_NULLE_P, BASE_UNDEFINED, chunk_undefined, complexity_dup(), complexity_polynome(), complexity_var_subst(), concatenate(), int, is_inferior_pvarval(), make_single_var_complexity(), make_zero_complexity(), malloc(), name_to_variable(), polynome_used_var(), strdup(), Svecteur::succ, term_cst, Svecteur::var, variable_name(), and VECTEUR_NUL.

Referenced by fetch_callees_complexities().

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

◆ unary_minus_op_handler()

complexity unary_minus_op_handler ( list  args,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)
Parameters
argsrgs
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 527 of file comp_expr_to_pnome.c.

533 {
535  precond, effects_list, keep_symbols,
536  -maximize);
538 
539  complexity_sub(&c1, c2);
540  complexity_rm(&c2);
541 
542  return (c1);
543 }

References CAR, complexity_rm(), complexity_sub(), EXPRESSION, expression_to_complexity_polynome(), and make_zero_complexity().

Referenced by call_to_polynome().

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

◆ unary_plus_op_handler()

complexity unary_plus_op_handler ( list  args,
transformer  precond,
list  effects_list,
bool  keep_symbols,
int  maximize 
)
Parameters
argsrgs
precondrecond
effects_listffects_list
keep_symbolseep_symbols
maximizeaximize

Definition at line 545 of file comp_expr_to_pnome.c.

551 {
553  precond, effects_list, keep_symbols,
554  maximize);
555 
556  return (c1);
557 }

References CAR, EXPRESSION, and expression_to_complexity_polynome().

+ Here is the call graph for this function:

◆ uniform_complexities()

bool uniform_complexities ( const string  module_name)

declares the static variable complexity_map and defines its access functions

bool complexities(module_name) Entry point called by the pips makefile

"hash_callee_to_complexity" contains a list of summary_complexity of callees, Non-recursive: callees complexities are supposed to be computed when arriving here.

"hash_complexity_parameters" contains the list of variables that we don't want to evaluate; so they will appear in the polynomial. All other variables (except for the loop indices) are evaluated as the scan proceeds, thanks to semantic analysis. Those which can't be evaluated are replaced by the pseudo-variable UNKNOWN_VARIABLE, which will be given an arbitrary value at the end of the evaluation.

Parameters
module_nameodule_name

Definition at line 79 of file comp_scan.c.

80 {
81  bool success = true;
82 
83  //set_string_property("COMPLEXITY_COST_TABLE", "all_1");
85 
86  return success;
87 }

References any_complexities(), and module_name().

+ Here is the call graph for this function:

◆ unstructured_to_complexity()

complexity unstructured_to_complexity ( unstructured  unstr,
transformer  precond,
list  effects_list 
)

comp_unstr.c

comp_unstr.c

complexity unstructured_to_complexity(unstructured unstr; transformer precond; list effects_list;

Return the complexity of the unstructured graph unstr whose nodes are controls.

First runs through the graph to compute nodes' complexities, the total number of nodes, and give a number to each node. This is done in "controls_to_hash_table()".

Then runs again through it to fill the probability matrix [Pij] ( Pij = probability to go to node j when you're in node i) This is done in "build_probability_matrix()"

Then computes A = I-P, then inv_A = 1/A with the matrix package.

MAX_CONTROLS_IN_UNSTRUCTURED = 100

A is identity matrix I

B = A - P = I - P

matrice_general_inversion(B, A, n_controls);

A = 1/(B)

This region will call C routines. LZ 20/10/92

the "global" complexity is: comp = a11 * C1 + a12 * C2 + ... + a1n * Cn where Ci = complexity of control #i

Modif by AP, March 15th 93: old version had non constant int in dim decl float fa[n_controls][n_controls]; int indx[n_controls]; int d;

Parameters
unstrnstr
precondrecond
effects_listffects_list

Definition at line 75 of file comp_unstr.c.

79 {
81  hash_table hash_control_to_complexity = hash_table_make(hash_pointer,
83  int i, j, n_controls = 0;
85  matrice P, A, B;
86 
87  trace_on("unstructured");
88 
90  &n_controls,
91  control_array,
92  hash_control_to_complexity,
93  precond,
94  effects_list);
95 
96 
97  P = average_probability_matrix(unstr, n_controls, control_array);
98  A = matrice_new(n_controls, n_controls);
99  B = matrice_new(n_controls, n_controls);
100 
101  /* A is identity matrix I */
102  matrice_identite(A, n_controls, 0);
103  /* B = A - P = I - P */
104  matrice_substract(B, A, P, n_controls, n_controls);
105 
106  if (get_debug_level() >= 5) {
107  fprintf(stderr, "I - P =");
108  matrice_fprint(stderr, B, n_controls, n_controls);
109  }
110 
111  /* matrice_general_inversion(B, A, n_controls); */
112  /* A = 1/(B) */
113  /* This region will call C routines. LZ 20/10/92 */
114 
115  /*
116  the "global" complexity is:
117  comp = a11 * C1 + a12 * C2 + ... + a1n * Cn
118  where Ci = complexity of control #i
119  */
120 
121  if ( n_controls < MAX_CONTROLS_IN_UNSTRUCTURED ) {
122 
123  /* Modif by AP, March 15th 93: old version had non constant int in dim decl
124  float fa[n_controls][n_controls];
125  int indx[n_controls];
126  int d;
127  */
128  float *fa = (float *) malloc(n_controls*n_controls*sizeof(float));
129  int *indx = (int *) malloc(sizeof(int) * n_controls);
130  int d;
131 
132  for (i=1; i<=n_controls; i++) {
133  for (j=1; j<=n_controls; j++ ) {
134  Value n = ACCESS(B, n_controls, i, j),
135  de = DENOMINATOR(B);
136  float f1 = VALUE_TO_FLOAT(n),
137  f2 = VALUE_TO_FLOAT(de);
138  FA(i-1,j-1) = f1/f2;
139  }
140  }
141 
142  if ( get_debug_level() >= 5 ) {
143  fprintf(stderr, "Before float matrice inversion\n\n");
144  }
145 
146  if ( get_debug_level() >= 9 ) {
147  fprintf(stderr, "(I - P) =\n");
148  for (i=0;i<n_controls;i++) {
149  for (j=0;j<n_controls;j++)
150  fprintf(stderr, "%4.2f ",FA(i,j) );
151  fprintf(stderr, "\n");
152  }
153  }
154 
155  float_matrice_inversion(fa, n_controls, indx, &d);
156 
157  if ( get_debug_level() >= 5 ) {
158  fprintf(stderr, "After float matrice inversion\n\n");
159  }
160 
161  if ( get_debug_level() >= 9 ) {
162  fprintf(stderr, "(I - P)^(-1) =\n");
163  for (i=0;i<n_controls;i++) {
164  for (j=0;j<n_controls;j++)
165  fprintf(stderr, "%4.2f ",FA(i,j) );
166  fprintf(stderr, "\n");
167  }
168  }
169 
170  for (i=1; i<=n_controls; i++) {
171  control conti = control_array[i];
172  complexity compi = (complexity)
173  hash_get(hash_control_to_complexity, (char *) conti);
174  float f = FA(0,i-1);
175 
176  if ( get_debug_level() >= 5 ) {
177  fprintf(stderr, "control $%p:f=%f, compl.=", conti, f);
178  complexity_fprint(stderr, compi, true, false);
179  }
180 
181  complexity_scalar_mult(&compi, f);
182  complexity_add(&comp, compi);
183  }
184  }
185  else
186  pips_internal_error("Too large to compute");
187 
188  if (get_debug_level() >= 5) {
189  fprintf(stderr, "cumulated complexity=");
190  complexity_fprint(stderr, comp, true, false);
191  }
192 
193  matrice_free(B);
194  matrice_free(A);
195  matrice_free(P);
196 
197  hash_table_free(hash_control_to_complexity);
198 
199  complexity_check_and_warn("unstructured_to_complexity", comp);
200 
201  trace_off();
202  return(comp);
203 }
void float_matrice_inversion(float *a, int n, int *indx, int *pd)
Definition: comp_matrice.c:198
#define FA(i, j)
comp_unstr.c
Definition: comp_unstr.c:50
void controls_to_hash_table(control cont, int *pn_controls, control_array, hash_table hash_control_to_complexity, transformer precond, list effects_list)
Returns the hash table hash_control_to_complexity filled in with the complexities of the successors o...
Definition: comp_unstr.c:212
matrice average_probability_matrix(unstructured unstr, int n_controls, control_array)
Definition: comp_unstr.c:270
#define B(A)
Definition: iabrev.h:61
#define DENOMINATOR(matrix)
int DENOMINATEUR(matrix): acces au denominateur global d'une matrice matrix La combinaison *(&()) est...
Definition: matrice-local.h:93
#define matrice_free(m)
Definition: matrice-local.h:78
#define ACCESS(matrix, column, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrice-local.h:86
#define matrice_new(n, m)
Allocation et desallocation d'une matrice.
Definition: matrice-local.h:77
Value * matrice
package matrice
Definition: matrice-local.h:71
void matrice_substract(matrice a, matrice b, matrice c, int n, int m)
void matrice_substract(matrice a, matrice b, matrice c, int n, int m): substract rational matrix c fr...
Definition: matrice.c:468
void matrice_identite(matrice, int, int)
void matrice_identite(matrice ID, int n, int level) Construction d'une sous-matrice identite dans ID(...
Definition: sous-matrice.c:322
void matrice_fprint(FILE *, matrice, int, int)
matrice_io.c
Definition: matrice_io.c:62
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
int f2(int off1, int off2, int w, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:1
Definition: pip__tab.h:25

References A, ACCESS, average_probability_matrix(), B, complexity_add(), complexity_check_and_warn(), complexity_fprint(), complexity_scalar_mult(), controls_to_hash_table(), DENOMINATOR, f(), f2(), FA, float_matrice_inversion(), fprintf(), get_debug_level(), hash_get(), hash_pointer, hash_table_free(), hash_table_make(), make_zero_complexity(), malloc(), matrice_fprint(), matrice_free, matrice_identite(), matrice_new, matrice_substract(), MAX_CONTROLS_IN_UNSTRUCTURED, pips_internal_error, trace_off(), trace_on(), unstructured_control, and VALUE_TO_FLOAT.

Referenced by instruction_to_complexity().

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

◆ update_statement_complexity()

void update_statement_complexity ( statement  ,
complexity   
)

◆ variable_local_name()

char* variable_local_name ( Variable  var)
Parameters
varar

Definition at line 95 of file polynome_ri.c.

97 {
98  string s = NULL;
99 
100  if (var == TCST)
101  s = strdup(TCST_NAME);
102  /*
103  else if (var == UNKNOWN_VARIABLE)
104  s = strdup(UNKNOWN_VARIABLE_NAME);
105  else if (var == UNKNOWN_RANGE)
106  s = strdup(UNKNOWN_RANGE_NAME);
107  */
108  else if (var == (Variable) chunk_undefined)
109  pips_internal_error("unexpected var == chunk_undefined.");
110  else {
111  // s = strdup(entity_local_name((entity) var));
112  s = strdup(entity_minimal_name((entity) var));
113  }
114 
115  return (s);
116 }
const char * entity_minimal_name(entity e)
Do preserve scope informations.
Definition: naming.c:214

References chunk_undefined, entity_minimal_name(), pips_internal_error, strdup(), TCST, and TCST_NAME.

Referenced by complexity_sprint(), final_statement_to_complexity_evaluation(), is_inferior_pvarval(), is_inferior_var(), and is_inferior_varval().

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

◆ variable_name()

char* variable_name ( Variable  var)

polynome_ri.c

This file gathers some functions interfacing polynomial library and the RI.

The "Variable" type used by polynomials is casted to "entity", the "Value" type, to int.

char *variable_name(Variable var) return the complete name of the entity var

char *variable_local_name(Variable var) return the abbreviated, local name of var

bool is_inferior_var(Variable var1, var2) return true if the complete name of var1 is lexicographically before var2's one.

Variable name_to_variable(char *name) inverse function of variable_name. name must be the complete name of the variable. Modif: – entity_local_name is replaced by module_local_name. LZ 230993

FI: no longer useful

Parameters
varar

Definition at line 73 of file polynome_ri.c.

75 {
76  string s = (string) malloc(10);
77 
78  if (var == TCST)
79  s = strdup(TCST_NAME);
80  /* FI: no longer useful */
81  /*
82  else if (var == UNKNOWN_VARIABLE)
83  s = strdup(UNKNOWN_VARIABLE_NAME);
84  else if (var == UNKNOWN_RANGE)
85  s = strdup(UNKNOWN_RANGE_NAME);
86  */
87  else if (var == (Variable) chunk_undefined)
88  pips_internal_error("unexpected var == chunk_undefined.");
89  else
90  s = strdup(entity_name((entity) var));
91 
92  return (s);
93 }
char * string
STRING.
Definition: newgen_types.h:39

◆ whileloop_to_complexity()

complexity whileloop_to_complexity ( whileloop  while_instr,
transformer  precond,
list  effects_list 
)

5th element of instruction

Parameters
while_instrhile_instr
precondrecond
effects_listffects_list

Definition at line 692 of file comp_scan.c.

693 {
694  basic b;
695  expression exp1, exp2,exp3;
696  expression exp = whileloop_condition(while_instr);
697  complexity range ;
698  complexity cbody = statement_to_complexity(whileloop_body(while_instr), precond, effects_list),
699  ctest = expression_to_complexity(exp, &b,precond, effects_list);
700  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
701  fprintf(stderr, "\n");
702  fprintf(stderr, "YYY body complexity: ");
703  complexity_fprint(stderr, cbody, false, true);
704  fprintf(stderr, "YYY test complexity: ");
705  complexity_fprint(stderr, ctest, false, true);
706  }
707 
709  entity fun = call_function(syntax_call( s ));
710  if (ENTITY_LESS_THAN_P( fun )) {
713  exp3 = make_op_exp( MINUS_OPERATOR_NAME,exp1,exp2);
715  precond, effects_list,
717  }
718  else
719  {
721  }
722  complexity_add(&cbody,ctest);
723  complexity_mult(&cbody,range);
724 
725  if (get_bool_property("COMPLEXITY_INTERMEDIATES")) {
726  fprintf(stderr, "YYY while total complexity: ");
727  complexity_fprint(stderr, cbody, true, true);
728  fprintf(stderr, "\n");
729  }
730  complexity_check_and_warn(__FUNCTION__, cbody);
731 
732  return cbody;
733 }
struct _newgen_struct_range_ * range
Definition: message.h:21
#define ENTITY_LESS_THAN_P(e)
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
Definition: expression.c:2012
#define whileloop_body(x)
Definition: ri.h:3162
#define whileloop_condition(x)
Definition: ri.h:3160

References call_arguments, call_function, CAR, CDR, complexity_add(), complexity_check_and_warn(), complexity_fprint(), complexity_mult(), ENTITY_LESS_THAN_P, exp, EXPRESSION, expression_syntax, expression_to_complexity(), expression_to_complexity_polynome(), fprintf(), get_bool_property(), KEEP_SYMBOLS, make_complexity_unknown(), make_op_exp(), MINIMUM_VALUE, MINUS_OPERATOR_NAME, statement_to_complexity(), syntax_call, UNKNOWN_RANGE_NAME, whileloop_body, and whileloop_condition.

Referenced by instruction_to_complexity().

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

Variable Documentation

◆ hash_callee_to_complexity

hash_table hash_callee_to_complexity
extern

cproto-generated files

comp_scan.c

cproto-generated files

scan a ri expression and try to make a polynomial of it Modif: – entity_local_name is replaced by module_local_name. LZ 230993 – MAXINT replaced by INT_MAX, -MAXINT by INT_MIN FI 1/12/95 useful, pips_error is defined there

Definition at line 57 of file comp_scan.c.

Referenced by any_complexities(), and call_to_complexity().

◆ hash_complexity_parameters

hash_table hash_complexity_parameters
extern

Definition at line 58 of file comp_scan.c.

Referenced by any_complexities(), and loop_to_complexity().

◆ intrinsic_cost_table

intrinsic_cost_record intrinsic_cost_table[]
extern

The table intrinsic_cost_table[] gathers cost information of each intrinsic's cost; those costs are dynamically loaded from user files.

It also returns the "minimum" type of the result of each intrinsic, specified by its basic_tag and number of memory bytes. ("bigger" and "minimum" refer to the order relation defined in the routine "is_inferior_basic"; the tag is_basic_overloaded is used as a don't care tag) (ex: SIN has a type of FLOAT even if its arg is an INT)

Modif: – LOOP_OVERHEAD and CALL_OVERHEAD are added, 280993 LZ – LOOP_OVERHEAD is divided into two: INIT and BRAANCH 081093 LZ

Definition at line 286 of file comp_util.c.

Referenced by fprint_cost_table(), intrinsic_cost(), and load_cost_file().