PIPS
instrumentation.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "boolean.h"
#include <stdbool.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "database.h"
#include "misc.h"
#include "text.h"
#include "text-util.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "accel-util.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "pipsdbm.h"
#include "resources.h"
#include "control.h"
#include "conversion.h"
#include "properties.h"
#include "semantics.h"
#include "transformations.h"
#include "effects-convex.h"
#include "complexity_ri.h"
#include "complexity.h"
#include "dg.h"
#include "graph.h"
#include "ricedg.h"
#include "chains.h"
#include "task_parallelization.h"
+ Include dependency graph for instrumentation.c:

Go to the source code of this file.

Typedefs

typedef dg_arc_label arc_label
 Instantiation of the dependence graph: More...
 
typedef dg_vertex_label vertex_label
 

Functions

static void task_time_polynome (statement s)
 
static void edge_cost_polynome (statement s1, statement s2)
 
bool bdsc_code_instrumentation (char *module_name)
 instrumentation.c More...
 

Typedef Documentation

◆ arc_label

Instantiation of the dependence graph:

Definition at line 38 of file instrumentation.c.

◆ vertex_label

Definition at line 39 of file instrumentation.c.

Function Documentation

◆ bdsc_code_instrumentation()

bool bdsc_code_instrumentation ( char *  module_name)

instrumentation.c

The proper effect to detect the I/O operations:

omplexities (task processing time)

irst step is to cumulate dependences hierarchically (between sequences) on granularities : loop, test and simple instruction

Reorder the module, because new statements have been generated.

Parameters
module_nameodule_name

Definition at line 141 of file instrumentation.c.

142 {
143  statement module_stat = (statement)db_get_memory_resource(DBR_CODE, module_name, true);
144  set_ordering_to_statement(module_stat);
146  set_current_module_statement(module_stat);
149  db_get_memory_resource(DBR_TRANSFORMERS, module_name, true));
150  /* The proper effect to detect the I/O operations: */
155  db_get_memory_resource(DBR_REGIONS, module_name, true));
158 
159  kdg = (graph) db_get_memory_resource (DBR_SDG, module_name, true );
160 
161  /*Complexities (task processing time)*/
163 
164  /*first step is to cumulate dependences hierarchically (between
165  sequences) on granularities : loop, test and simple instruction*/
166  list vertices = graph_vertices(kdg);
167  FOREACH(VERTEX, v, vertices){
172  vertex s = successor_vertex(su);
173  statement child = vertex_to_statement(s);
174  edge_cost_polynome(stmt,child);
175  }
176  }
177  }
178  /* Reorder the module, because new statements have been generated. */
179  module_reorder(module_stat);
180  gen_consistent_p((gen_chunk*)module_stat);
181  DB_PUT_MEMORY_RESOURCE(DBR_CODE, strdup(module_name), module_stat);
192  return true;
193 }
graph kdg
Global variables.
Definition: HBDSC.c:52
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
void reset_complexity_map(void)
void set_complexity_map(statement_mapping)
void set_methods_for_convex_effects(void)
methods.c
Definition: methods.c:235
void init_convex_rw_prettyprint(const char *)
void set_rw_effects(statement_effects)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
void reset_rw_effects(void)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
int gen_consistent_p(gen_chunk *obj)
GEN_CONSISTENT_P dynamically checks the type correctness of OBJ.
Definition: genClib.c:2398
#define successor_vertex(x)
Definition: graph.h:118
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
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
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 FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
statement vertex_to_statement(vertex v)
Vertex_to_statement looks for the statement that is pointed to by vertex v.
Definition: util.c:45
static vertex statement_to_vertex(statement s, graph g)
Definition: impact_check.c:227
static void task_time_polynome(statement s)
static void edge_cost_polynome(statement s1, statement s2)
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
Definition: ordering.c:172
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
char * strdup()
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
void set_transformer_map(statement_mapping)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
void reset_transformer_map(void)
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: statement.c:54
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212
A gen_chunk is used to store every object.
Definition: genC.h:58

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, declaration_statement_p(), edge_cost_polynome(), FOREACH, free_value_mappings(), gen_consistent_p(), get_current_module_entity(), graph_vertices, init_convex_rw_prettyprint(), kdg, module_name(), module_name_to_entity(), module_reorder(), module_to_value_mappings(), reset_complexity_map(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_precondition_map(), reset_proper_rw_effects(), reset_rw_effects(), reset_transformer_map(), set_complexity_map(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_methods_for_convex_effects(), set_ordering_to_statement(), set_precondition_map(), set_proper_rw_effects(), set_rw_effects(), set_transformer_map(), statement_to_vertex(), strdup(), SUCCESSOR, successor_vertex, task_time_polynome(), VERTEX, vertex_successors, and vertex_to_statement().

+ Here is the call graph for this function:

◆ edge_cost_polynome()

static void edge_cost_polynome ( statement  s1,
statement  s2 
)
static

Definition at line 96 of file instrumentation.c.

97 {
98  Ppolynome transfer_time = POLYNOME_NUL;
99  string r;
102  list l_communications = RegionsIntersection(regions_dup(l_write_1), regions_dup(l_read_2), w_r_combinable_p);
103  FOREACH(REGION,reg,l_communications){
104  Ppolynome reg_footprint = region_enumerate(reg);
106  polynome_add(&transfer_time, reg_footprint);
107 
108  }
109  if(!POLYNOME_UNDEFINED_P(transfer_time)){
110  r = expression_to_string(polynome_to_expression(transfer_time));
111  }
112  else
113  r = "0";
114  string new_name3 = "finstrumented";
115  entity new_ent3 = make_constant_entity(new_name3, is_basic_string, 100);
116  expression exp3 = make_entity_expression(new_ent3, NIL);
117  string s2_ordering = strdup(concatenate( "\"", i2a(statement_ordering(s1)),NULL));
118  string new_name = strdup(concatenate( s2_ordering, "->", i2a(statement_ordering(s2))," = %lf \\n", "\"", NULL));
119  entity new_ent = make_constant_entity(new_name, is_basic_string, 1000);
121  entity new_ent2 = make_constant_entity(r, is_basic_string, 100);
123  expression exp2 = make_entity_expression(new_ent2, NIL);
125  //expression exp2 = make_entity_expression(new_ent2, NIL);
126  list args = CONS(EXPRESSION, exp3, CONS(EXPRESSION,exp,CONS(EXPRESSION,exp4,NIL)));
128  args,
131  statement new_s = copy_statement(s2);
133  statement_instruction(s2) = ins_seq;
138  return;
139 }
cast make_cast(type a1, expression a2)
Definition: ri.c:311
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
type copy_type(type p)
TYPE.
Definition: ri.c:2655
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
void free_extensions(extensions p)
Definition: ri.c:950
instruction make_instruction_sequence(sequence _field_)
Definition: ri.c:1169
syntax make_syntax_cast(cast _field_)
Definition: ri.c:2503
sequence make_sequence(list a)
Definition: ri.c:2125
entity make_constant_entity(string name, tag bt, size_t size)
For historical reason, call the Fortran version.
Definition: constant.c:301
#define region_entity(reg)
#define REGION
list RegionsIntersection(list l1, list l2, bool(*intersection_combinable_p)(effect, effect))
list RegionsIntersection(list l1,l2, bool (*intersection_combinable_p)(effect, effect)) input : outpu...
list regions_write_regions(list)
list regions_read_regions(list)
list regions_dup(list)
Ppolynome region_enumerate(effect)
bool w_r_combinable_p(effect, effect)
list load_statement_local_regions(statement)
void free(void *)
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
statement make_call_statement(string, list, entity, string)
This function is limited to intrinsics calls...
Definition: statement.c:1274
char * i2a(int)
I2A (Integer TO Ascii) yields a string for a given Integer.
Definition: string.c:121
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define UUINT(i)
Definition: newgen_types.h:99
#define string_undefined_p(s)
Definition: newgen_types.h:41
Ppolynome polynome_mult(Ppolynome pp1, Ppolynome pp2)
Ppolynome polynome_mult(Ppolynome pp1, Ppolynome pp2) returns pp1 * pp2.
Definition: pnome-bin.c:287
void polynome_add(Ppolynome *ppp, Ppolynome pp2)
void polynome_add(Ppolynome* ppp, Ppolynome pp2) (*ppp) = (*ppp) + pp2.
Definition: pnome-bin.c:171
#define POLYNOME_NUL
#define POLYNOME_UNDEFINED_P(pp)
string expression_to_string(expression e)
Definition: expression.c:77
#define FPRINTF_FUNCTION_NAME
#define make_statement_list(stats...)
easy list constructor
#define empty_comments
Empty comments (i.e.
expression make_entity_expression(entity e, cons *inds)
Definition: expression.c:176
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
Ppolynome expression_to_polynome(expression exp)
===========================================================================
Definition: expression.c:3650
expression polynome_to_expression(Ppolynome pp)
converts a polynomial to expression
Definition: expression.c:3622
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
_int SizeOfElements(basic)
This function returns the length in bytes of the Fortran or C type represented by a basic,...
Definition: size.c:297
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
Definition: type.c:116
@ is_basic_string
Definition: ri.h:576
@ is_basic_float
Definition: ri.h:572
#define normalized_undefined
Definition: ri.h:1745
#define statement_ordering(x)
Definition: ri.h:2454
#define type_variable(x)
Definition: ri.h:2949
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined
Definition: ri.h:2761
#define statement_extensions(x)
Definition: ri.h:2464
#define statement_instruction(x)
Definition: ri.h:2458
#define statement_comments(x)
Definition: ri.h:2456
#define entity_type(x)
Definition: ri.h:2792
#define variable_basic(x)
Definition: ri.h:3120
s1
Definition: set.c:247
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References concatenate(), CONS, copy_statement(), copy_type(), empty_comments, empty_extensions(), entity_type, entity_undefined, exp, EXPRESSION, expression_to_polynome(), expression_to_string(), FOREACH, FPRINTF_FUNCTION_NAME, free(), free_extensions(), i2a(), int_to_expression(), is_basic_float, is_basic_string, load_statement_local_regions(), make_basic(), make_call_statement(), make_cast(), make_constant_entity(), make_entity_expression(), make_expression(), make_instruction_sequence(), make_sequence(), make_statement_list, make_syntax_cast(), MakeTypeVariable(), NIL, normalized_undefined, polynome_add(), polynome_mult(), POLYNOME_NUL, polynome_to_expression(), POLYNOME_UNDEFINED_P, REGION, region_entity, region_enumerate(), regions_dup(), regions_read_regions(), regions_write_regions(), RegionsIntersection(), s1, SizeOfElements(), statement_comments, statement_extensions, statement_instruction, statement_ordering, strdup(), string_undefined_p, type_variable, UUINT, variable_basic, and w_r_combinable_p().

Referenced by bdsc_code_instrumentation().

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

◆ task_time_polynome()

static void task_time_polynome ( statement  s)
static

Definition at line 49 of file instrumentation.c.

50 {
51  statement st_poly ;
53  {
54  string dir = strdup(concatenate("char *file_name = \"", "./instrumented_",get_current_module_name(),".in\";", NULL));
55  string mode = "\"w\"";
56  string new_name = strdup(concatenate("FILE *finstrumented;\n ", dir, "\n finstrumented = fopen(file_name,", mode, ");\n", NULL)) ;
57  entity new_ent = make_constant_entity(new_name, is_basic_string, 1000);
59  }
60  else{
62  string r;
63  if(stat_comp != (complexity) HASH_UNDEFINED_VALUE && !complexity_zero_p(stat_comp)) {
64  cons *pc = CHAIN_SWORD(NIL, complexity_sprint(stat_comp, false, true));
65  r = words_to_string(pc);
66  }
67  else
68  r = strdup("Undefined value");
69  string new_name3 = "finstrumented";
70  entity new_ent3 = make_constant_entity(new_name3, is_basic_string, 100);
71  expression exp3 = make_entity_expression(new_ent3, NIL);
72  string new_name = strdup(concatenate( "\"", i2a(statement_ordering(s)),"->-1 = %lf \\n", "\"", NULL));
73  entity new_ent = make_constant_entity(new_name, is_basic_string, 1000);
75  entity new_ent2 = make_constant_entity(r, is_basic_string, 100);
77  expression exp2 = make_entity_expression(new_ent2, NIL);
80  list args = CONS(EXPRESSION, exp3, CONS(EXPRESSION, exp,CONS(EXPRESSION, exp4, NIL)));
82  args,
85  }
86  statement new_s = copy_statement(s);
88  statement_instruction(s) = ins_seq;
93  return;
94 }
bool complexity_zero_p(complexity comp)
zero complexity check.
Definition: comp_math.c:244
char * complexity_sprint(complexity comp, bool print_stats_p, bool print_local_names_p)
Definition: comp_util.c:175
complexity load_statement_complexity(statement)
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
statement make_expression_statement(expression)
Build a statement from a given expression.
Definition: statement.c:1308
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
static bool statement_equal_p(statement s1, statement s2)
Definition: unstructured.c:55
#define CHAIN_SWORD(l, s)
string words_to_string(cons *lw)
Definition: print.c:211

References CHAIN_SWORD, complexity_sprint(), complexity_zero_p(), concatenate(), CONS, copy_statement(), copy_type(), empty_comments, empty_extensions(), entity_undefined, exp, EXPRESSION, FPRINTF_FUNCTION_NAME, free(), free_extensions(), gen_consistent_p(), get_current_module_name(), get_current_module_statement(), HASH_UNDEFINED_VALUE, i2a(), is_basic_float, is_basic_string, load_statement_complexity(), make_basic(), make_call_statement(), make_cast(), make_constant_entity(), make_entity_expression(), make_expression(), make_expression_statement(), make_instruction_sequence(), make_sequence(), make_statement_list, make_syntax_cast(), MakeTypeVariable(), NIL, normalized_undefined, statement_comments, statement_equal_p(), statement_extensions, statement_instruction, statement_ordering, strdup(), string_undefined_p, UUINT, and words_to_string().

Referenced by bdsc_code_instrumentation().

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