PIPS
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "linear.h"
#include "genC.h"
#include "database.h"
#include "ri.h"
#include "effects.h"
#include "complexity_ri.h"
#include "resources.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "pipsdbm.h"
#include "text-util.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "misc.h"
#include "constants.h"
#include "properties.h"
#include "matrice.h"
#include "polynome.h"
#include "complexity.h"
Go to the source code of this file.
Macros | |
#define | INDENT_BLANKS " " |
comp_util.c More... | |
#define | INDENT_VLINE "| " |
#define | INDENT_BACK "-" |
#define | INDENT_INTERVAL 2 |
Functions | |
bool | complexity_check (complexity comp) |
return true if allright More... | |
void | complexity_check_and_warn (char *s, complexity comp) const |
void | good_complexity_assert (_UNUSED_ string function, complexity comp) |
complexity | complexity_dup (complexity comp) |
duplicates complexity comp More... | |
void | complexity_rm (complexity *pcomp) |
remove complexity comp More... | |
char * | complexity_sprint (complexity comp, bool print_stats_p, bool print_local_names_p) |
void | complexity_fprint (FILE *fd, complexity comp, bool print_stats_p, bool print_local_names_p) |
void | complexity_dump (complexity comp) |
void | prc (complexity comp) |
void | prp (Ppolynome pp) |
void | prv (Pvecteur pv) |
void | fprint_statement_complexity (entity module, statement stat, hash_table hash_statement_to_complexity) |
void | fprint_cost_table (FILE *fd) |
void | init_cost_table () |
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 *fd, float file_factor) |
Load (some) intrinsics costs from file "fd", multiplying them by "file_factor". More... | |
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 *pargsbasic. More... | |
float | constant_entity_to_float (entity e) |
Return if possible the value of e in a float. More... | |
void | trace_on (char *fmt,...) |
void | trace_off () |
"trace off" More... | |
bool | is_linear_unstructured (unstructured unstr) |
return true if unstr is simply a linear string of controls More... | |
list | entity_list_reverse (list l) |
void | add_formal_parameters_to_hash_table (entity mod, hash_table hash_complexity_params) |
void | remove_formal_parameters_from_hash_table (entity mod, hash_table hash_complexity_params) |
hash_table | free_callees_complexities (hash_table h) |
hash_table | fetch_callees_complexities (char *module_name) |
hash_table | fetch_complexity_parameters (char *module_name) |
void | add_common_variables_to_hash_table (entity module, hash_table hash_complexity_params) |
void | remove_common_variables_from_hash_table (entity module, hash_table hash_complexity_params) |
bool | is_must_be_written_var (list effects_list, char *var_name) |
complexity | final_statement_to_complexity_evaluation (complexity comp, transformer precond, list effects_list) |
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. More... | |
bool | complexity_is_monomial_p (complexity c) |
int | complexity_degree (complexity c) |
Variables | |
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... | |
static int | call_level =0 |
"trace on" More... | |
#define INDENT_BACK "-" |
Definition at line 92 of file comp_util.c.
#define INDENT_BLANKS " " |
useful routines for evaluation of the complexity of a program
bool complexity_check(comp) void complexity_check_and_warn(function_name, comp) void good_complexity_assert(function_name, comp) void complexity_fprint(fd, comp, print_stats_p, print_local_names_p) char *complexity_sprint(comp, print_stats_p, print_local_names_p) void fprint_statement_complexity(module, stat, hash_statement_to_complexity) void prc(comp) (for dbx) void prp(pp) (for dbx) void prv(pv) (for dbx) void fprint_cost_table(fd) void init_cost_table(); int intrinsic_cost(name, argstype) bool is_inferior_basic(basic1, basic2) basic simple_basic_dup(b) float constant_entity_to_float(e) void trace_on(va_alist) void trace_off() list entity_list_reverse(l) bool is_linear_unstructured(unstr) void add_formal_parameters_to_hash_table(mod, hash_complexity_params) void remove_formal_parameters_from_hash_table(mod, hash_complexity_params) hash_table fetch_callees_complexities(module_name) hash_table fetch_complexity_parameters(module_name) Modif: – entity_local_name is replaced by module_local_name. LZ 230993 – add of missing operators to intrinsic_cost_table. Molka Becher 08.03.2011 To have strndup(): getenv print_text IMPLIED_DO_NAME is defined there get_string_property is defined there for debugging
Definition at line 90 of file comp_util.c.
#define INDENT_INTERVAL 2 |
Definition at line 93 of file comp_util.c.
#define INDENT_VLINE "| " |
Definition at line 91 of file comp_util.c.
void add_common_variables_to_hash_table | ( | entity | module, |
hash_table | hash_complexity_params | ||
) |
module | odule |
hash_complexity_params | ash_complexity_params |
Definition at line 946 of file comp_util.c.
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().
void add_formal_parameters_to_hash_table | ( | entity | mod, |
hash_table | hash_complexity_params | ||
) |
mod | od |
hash_complexity_params | ash_complexity_params |
Definition at line 768 of file comp_util.c.
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().
bool complexity_check | ( | complexity | comp | ) |
return true if allright
comp | omp |
Definition at line 96 of file comp_util.c.
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().
void complexity_check_and_warn | ( | char * | s, |
complexity | comp | ||
) | const |
Definition at line 108 of file comp_util.c.
References complexity_check(), COMPLEXITY_UNDEFINED_P, complexity_zero_p(), fprintf(), get_bool_property(), pips_internal_error, and user_warning.
Referenced by arguments_to_complexity(), block_to_complexity(), call_to_complexity(), controls_to_hash_table(), expression_to_complexity(), indices_to_complexity(), instruction_to_complexity(), loop_to_complexity(), new_block_to_complexity(), range_to_complexity(), reference_to_complexity(), statement_to_complexity(), syntax_to_complexity(), test_to_complexity(), text_complexity(), unstructured_to_complexity(), and whileloop_to_complexity().
int complexity_degree | ( | complexity | c | ) |
Definition at line 1167 of file comp_util.c.
References complexity_eval, and polynome_max_degree().
Referenced by loop_to_complexity().
void complexity_dump | ( | complexity | comp | ) |
comp | omp |
Definition at line 228 of file comp_util.c.
References complexity_fprint().
complexity complexity_dup | ( | complexity | comp | ) |
duplicates complexity comp
comp | omp |
Definition at line 131 of file comp_util.c.
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().
void complexity_fprint | ( | FILE * | fd, |
complexity | comp, | ||
bool | print_stats_p, | ||
bool | print_local_names_p | ||
) |
fd | d |
comp | omp |
print_stats_p | rint_stats_p |
print_local_names_p | rint_local_names_p |
Definition at line 217 of file comp_util.c.
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().
bool complexity_is_monomial_p | ( | complexity | c | ) |
Definition at line 1159 of file comp_util.c.
References complexity_eval, and is_single_monome.
Referenced by loop_to_complexity().
void complexity_rm | ( | complexity * | pcomp | ) |
remove complexity comp
pcomp | comp |
Definition at line 164 of file comp_util.c.
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().
char* complexity_sprint | ( | complexity | comp, |
bool | print_stats_p, | ||
bool | print_local_names_p | ||
) |
comp | omp |
print_stats_p | rint_stats_p |
print_local_names_p | rint_local_names_p |
Definition at line 175 of file comp_util.c.
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().
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.
References basic_float_p, basic_int_p, basic_tag, entity_basic(), f(), module_local_name(), and user_warning.
Referenced by call_to_polynome().
Definition at line 757 of file comp_util.c.
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
module_name | odule_name |
Definition at line 821 of file comp_util.c.
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().
hash_table fetch_complexity_parameters | ( | char * | module_name | ) |
module_name | odule_name |
Definition at line 901 of file comp_util.c.
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().
complexity final_statement_to_complexity_evaluation | ( | complexity | comp, |
transformer | precond, | ||
list | effects_list | ||
) |
comp | omp |
precond | recond |
effects_list | ffects_list |
Definition at line 1052 of file comp_util.c.
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.
void fprint_cost_table | ( | FILE * | fd | ) |
fd | d |
Definition at line 481 of file comp_util.c.
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().
void fprint_statement_complexity | ( | entity | module, |
statement | stat, | ||
hash_table | hash_statement_to_complexity | ||
) |
module | odule |
stat | tat |
hash_statement_to_complexity | ash_statement_to_complexity |
Definition at line 253 of file comp_util.c.
References complexity_fprint(), COMPLEXITY_UNDEFINED_P, DO_PRINT_STATS, fprintf(), hash_get(), module, pips_internal_error, PRINT_LOCAL_NAMES, print_text(), and Text_Statement().
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.
References hash_table_clear(), hash_table_free(), and hash_table_undefined.
Referenced by any_complexities().
void good_complexity_assert | ( | _UNUSED_ string | function, |
complexity | comp | ||
) |
Definition at line 124 of file comp_util.c.
References complexity_check(), and pips_internal_error.
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.
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().
Return the cost of the intrinsic named s, knowing that the "basic" type of its biggest argument is *pargsbasic.
Update *pargsbasic if the intrinsic returns a number of bigger complexity.
Inserted by AP, oct 24th 1995
To satisfy cproto . LZ 02 Feb. 93
Definition at line 617 of file comp_util.c.
References basic_complex, basic_float, basic_tag, intrinsic_cost_rec::complex_cost, COMPLEX_NBYTES, intrinsic_cost_rec::dcomplex_cost, intrinsic_cost_rec::double_cost, intrinsic_cost_rec::float_cost, FLOAT_NBYTES, free_basic(), intrinsic_cost_rec::int_cost, intrinsic_cost_table, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_string, is_inferior_basic(), LOGICAL_INTRINSICS_COST, make_basic(), intrinsic_cost_rec::min_basic_result, intrinsic_cost_rec::min_nbytes_result, intrinsic_cost_rec::name, pips_internal_error, same_string_p, simple_basic_dup(), STRING_INTRINSICS_COST, and user_warning.
Referenced by call_to_complexity(), loop_to_complexity(), reference_to_complexity(), and syntax_to_complexity().
bool is_linear_unstructured | ( | unstructured | unstr | ) |
return true if unstr is simply a linear string of controls
unstr | nstr |
Definition at line 738 of file comp_util.c.
References CAR, CDR, CONTROL, control_successors, current, exit, NIL, pips_internal_error, unstructured_control, and unstructured_exit.
fprintf(stderr, "is_must_be_written_var for entity %s\n", module_local_name(e) );
effects_list | ffects_list |
var_name | ar_name |
Definition at line 1014 of file comp_util.c.
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().
void load_cost_file | ( | FILE * | fd, |
float | file_factor | ||
) |
Load (some) intrinsics costs from file "fd", multiplying them by "file_factor".
Definition at line 557 of file comp_util.c.
References intrinsic_cost_rec::complex_cost, intrinsic_cost_rec::dcomplex_cost, intrinsic_cost_rec::double_cost, intrinsic_cost_rec::float_cost, fprintf(), free(), get_bool_property(), int, intrinsic_cost_rec::int_cost, intrinsic_cost_table, line, malloc(), intrinsic_cost_rec::name, same_string_p, and user_warning.
Referenced by init_cost_table().
void prc | ( | complexity | comp | ) |
comp | for dbxtool: "print complexity" |
Definition at line 233 of file comp_util.c.
References complexity_fprint().
Referenced by pvecteur_to_polynome().
void prp | ( | Ppolynome | pp | ) |
pp | for dbxtool: "print polynome" |
Definition at line 239 of file comp_util.c.
References fprintf(), is_inferior_pvarval(), polynome_fprint(), and variable_name().
Referenced by complexity_sigma().
void prv | ( | Pvecteur | pv | ) |
pv | for dbxtool: "print vecteur (as a monome)" |
Definition at line 246 of file comp_util.c.
References BASE_NULLE, fprintf(), variable_name(), and vect_fprint_as_monome().
Referenced by sc_projection_optim_along_vecteur_ofl().
void remove_common_variables_from_hash_table | ( | entity | module, |
hash_table | hash_complexity_params | ||
) |
module | odule |
hash_complexity_params | ash_complexity_params |
Definition at line 985 of file comp_util.c.
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().
void remove_formal_parameters_from_hash_table | ( | entity | mod, |
hash_table | hash_complexity_params | ||
) |
mod | od |
hash_complexity_params | ash_complexity_params |
Definition at line 791 of file comp_util.c.
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().
void trace_off | ( | void | ) |
"trace off"
Definition at line 714 of file comp_util.c.
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().
void trace_on | ( | char * | fmt, |
... | |||
) |
fmt | mt |
Definition at line 684 of file comp_util.c.
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().
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
callee_comp | allee_comp |
oldname | ldname |
newname | ewname |
Definition at line 1100 of file comp_util.c.
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().
|
static |
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.
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().