PIPS
|
#include <stdio.h>
#include <string.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "effects.h"
#include "complexity_ri.h"
#include "ri-util.h"
#include "effects-util.h"
#include "misc.h"
#include "matrice.h"
#include "properties.h"
#include "complexity.h"
Go to the source code of this file.
Functions | |
complexity | complexity_sigma (complexity comp, Variable index, complexity clower, complexity cupper) |
comp_math.c More... | |
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. More... | |
complexity | polynome_to_new_complexity (Ppolynome pp) |
Create a complexity equal to Ppolynome pp with null statistics. More... | |
complexity | make_single_var_complexity (float f, Variable var) |
make a complexity "f * var" with null statistics More... | |
complexity | make_constant_complexity (float f) |
make a constant complexity "f * TCST" with null statistics More... | |
complexity | make_zero_complexity () |
make a zero complexity "0.0000 * TCST" with null statistics More... | |
bool | complexity_zero_p (complexity comp) |
zero complexity check. More... | |
bool | complexity_constant_p (complexity comp) |
true if comp is constant. More... | |
bool | complexity_unknown_p (complexity comp) |
true if comp is unknown. More... | |
float | complexity_TCST (complexity comp) |
return the constant term of comp. More... | |
void | complexity_scalar_mult (complexity *pcomp, float f) |
multiply a complexity by a floating-point number. More... | |
void | complexity_stats_add (complexity *pcomp1, complexity comp2) |
Add comp2's statistics to *pcomp1's comp2 keeps unchanged. More... | |
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 More... | |
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 More... | |
void | complexity_mult (complexity *pcomp1, complexity comp2) |
void complexity_mult(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 * comp2; !usage: complexity_mult(&comp1, comp2); More... | |
void | complexity_div (complexity *pcomp1, complexity comp2) |
void complexity_div(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 / comp2; !usage: complexity_div(&comp1, comp2); More... | |
void | complexity_polynome_add (complexity *pcomp, Ppolynome pp) |
void | complexity_float_add (complexity *pcomp, float f) |
Add a floating point digit to the complexity May 3, 91. More... | |
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. More... | |
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 More... | |
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. More... | |
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
pcomp1 | comp1 |
comp2 | omp2 |
Definition at line 372 of file comp_math.c.
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().
bool complexity_constant_p | ( | complexity | comp | ) |
true if comp is constant.
Abort if undefined
comp | omp |
Definition at line 256 of file comp_math.c.
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().
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)));
pcomp1 | comp1 |
comp2 | omp2 |
Definition at line 445 of file comp_math.c.
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().
void complexity_float_add | ( | complexity * | pcomp, |
float | f | ||
) |
Add a floating point digit to the complexity May 3, 91.
Definition at line 480 of file comp_math.c.
References complexity_eval, complexity_eval_, COMPLEXITY_UNDEFINED_P, complexity_zero_p(), f(), make_polynome(), newgen_Ppolynome, pips_internal_error, polynome_rm(), polynome_scalar_addition(), polynome_to_new_complexity(), TCST, and VALUE_ONE.
Referenced by call_to_complexity(), call_to_polynome(), and subscript_to_complexity().
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;
pcomp1 | comp1 |
comp2 | omp2 |
Definition at line 418 of file comp_math.c.
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().
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.
comp | omp |
Definition at line 506 of file comp_math.c.
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().
void complexity_polynome_add | ( | complexity * | pcomp, |
Ppolynome | pp | ||
) |
pcomp | comp |
pp | p |
Definition at line 463 of file comp_math.c.
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().
void complexity_scalar_mult | ( | complexity * | pcomp, |
float | f | ||
) |
multiply a complexity by a floating-point number.
Abort if undefined.
Definition at line 303 of file comp_math.c.
References complexity_eval, complexity_eval_, complexity_rm(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), f(), make_zero_complexity(), newgen_Ppolynome, pips_internal_error, and polynome_scalar_multiply().
Referenced by loop_to_complexity(), pvecteur_to_polynome(), simplify_sc_to_complexity(), test_to_complexity(), and unstructured_to_complexity().
complexity complexity_sigma | ( | complexity | comp, |
Variable | index, | ||
complexity | clower, | ||
complexity | cupper | ||
) |
"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.
FI: Too late to build a meaningful unknown range name!
tats
comp | omp |
index | ndex |
clower | lower |
cupper | upper |
Definition at line 84 of file comp_math.c.
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().
void complexity_stats_add | ( | complexity * | pcomp1, |
complexity | comp2 | ||
) |
Add comp2's statistics to *pcomp1's comp2 keeps unchanged.
pcomp1 | comp1 |
comp2 | omp2 |
Definition at line 323 of file comp_math.c.
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().
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
pcomp1 | comp1 |
comp2 | omp2 |
Definition at line 394 of file comp_math.c.
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().
float complexity_TCST | ( | complexity | comp | ) |
return the constant term of comp.
Abort if undefined
comp | omp |
Definition at line 288 of file comp_math.c.
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().
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
comp | omp |
Definition at line 269 of file comp_math.c.
References COMPLEXITY_UNDEFINED_P, and pips_internal_error.
Referenced by expression_to_complexity_polynome(), and loop_to_complexity().
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
comp | omp |
var | ar |
compsubst | ompsubst |
Definition at line 155 of file comp_math.c.
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().
bool complexity_zero_p | ( | complexity | comp | ) |
zero complexity check.
Abort if undefined
comp | omp |
Definition at line 244 of file comp_math.c.
References complexity_eval, COMPLEXITY_UNDEFINED_P, pips_internal_error, and POLYNOME_NUL_P.
Referenced by complexity_add(), complexity_check(), complexity_check_and_warn(), complexity_constant_p(), complexity_div(), complexity_dup(), complexity_float_add(), complexity_mult(), complexity_polynome(), complexity_rm(), complexity_scalar_mult(), complexity_sigma(), complexity_stats_add(), complexity_sub(), complexity_TCST(), complexity_var_subst(), evaluate_var_to_complexity(), pvecteur_to_polynome(), task_complexity(), task_time_polynome(), and test_to_complexity().
return a pointer to the (i)th element of the list if i = 1, the pointer doesn't change at all.
thelist | helist |
ith | th |
Definition at line 579 of file comp_math.c.
References CDR, NIL, and pips_assert.
complexity make_constant_complexity | ( | float | f | ) |
make a constant complexity "f * TCST" with null statistics
Definition at line 231 of file comp_math.c.
References f(), make_single_var_complexity(), and TCST.
Referenced by divide_op_handler(), evaluate_var_to_complexity(), loop_to_complexity(), make_zero_complexity(), reference_to_complexity(), simplify_sc_to_complexity(), and syntax_to_complexity().
complexity make_single_var_complexity | ( | float | f, |
Variable | var | ||
) |
make a complexity "f * var" with null statistics
Definition at line 220 of file comp_math.c.
References f(), make_polynome(), polynome_rm(), polynome_to_new_complexity(), and VALUE_ONE.
Referenced by evaluate_var_to_complexity(), loop_to_complexity(), make_complexity_unknown(), make_constant_complexity(), simplify_sc_to_complexity(), and translate_complexity_from_local_to_current_name().
complexity make_zero_complexity | ( | void | ) |
make a zero complexity "0.0000 * TCST" with null statistics
Definition at line 238 of file comp_math.c.
References make_constant_complexity().
Referenced by arguments_to_complexity(), block_to_complexity(), call_to_complexity(), call_to_polynome(), complexity_dup(), complexity_mult(), complexity_rm(), complexity_scalar_mult(), complexity_sigma(), complexity_var_subst(), evaluate_var_to_complexity(), expression_to_complexity(), expression_to_complexity_polynome(), goto_to_complexity(), indices_to_complexity(), instruction_to_complexity(), loop_to_complexity(), new_block_to_complexity(), normalized_to_polynome(), power_op_handler(), pvecteur_to_polynome(), range_to_polynome(), reference_to_complexity(), reference_to_polynome(), simplify_sc_to_complexity(), statement_to_complexity(), summary_complexity(), syntax_to_complexity(), syntax_to_polynome(), translate_complexity_from_local_to_current_name(), unary_minus_op_handler(), and unstructured_to_complexity().
complexity polynome_to_new_complexity | ( | Ppolynome | pp | ) |
Create a complexity equal to Ppolynome pp with null statistics.
pp IS duplicated.
pp | p |
Definition at line 200 of file comp_math.c.
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().
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
comp | omp |
mod | od |
args | rgs |
precond | recond |
effects_list | ffects_list |
Definition at line 519 of file comp_math.c.
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().