PIPS
accel-util.h File Reference
#include "transformer.h"
#include "effects.h"
+ Include dependency graph for accel-util.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define dma_load_p(e)   ((e) == dma_load )
 Add NewGen-like methods: More...
 
#define dma_store_p(e)   ((e) == dma_store )
 
#define dma_allocate_p(e)   ((e) == dma_allocate )
 
#define dma_deallocate_p(e)   ((e) == dma_deallocate )
 
#define OUTLINE_PRAGMA   "outline this"
 
#define OUTLINE_IGNORE   "outline_ignore"
 

Enumerations

enum  region_to_dma_switch {
  dma_load , dma_store , dma_allocate , dma_deallocate ,
  dma_load , dma_store , dma_allocate , dma_deallocate
}
 Warning! Do not modify this file that is automatically generated! More...
 

Functions

bool group_constants (const string)
 Dependences for accel-util.h. More...
 
void region_to_dimensions (effect, transformer, list *, list *, expression *)
 isolate_statement.c More...
 
list variable_to_dimensions (effect)
 
call dimensions_to_dma (effect, entity, list, list, enum region_to_dma_switch)
 converts dimensions to a dma call from a memory from to another memory to More...
 
void do_isolate_statement (statement, const char *, const char *)
 perform statement isolation on statement s that is make sure that all access to variables in s are made either on private variables or on new entities declared on a new memory space. More...
 
void isolate_patch_entities (void *, entity, entity, list)
 replace all references on entity old by references on entity new and adds offset offsets to its indices More...
 
bool region_to_minimal_dimensions (effect, transformer, list *, list *, bool, expression *)
 
effect find_region_on_entity (entity, list)
 
range dimension_to_range (dimension)
 
bool isolate_statement (const char *)
 
bool statement_insertion (const char *)
 statement_insertion.c More...
 
bool array_expansion (const char *)
 
bool loop_expansion (const char *)
 loop_expansion.c More...
 
bool loop_expansion_init (const char *)
 first step of the loop expansion process: create a statement to insert and flag it with a pragma More...
 
list outliner_statements_referenced_entities (list)
 outlining.c More...
 
hash_table outliner_init (entity, list)
 
list outliner_scan (entity, list, statement)
 
bool is_entity_in_list (entity, list)
 Checks if an entity is in a list. More...
 
void outliner_parameters (entity, statement, list, hash_table, list *, list *)
 
void outliner_patch_parameters (list, list, list, list, statement, statement, statement)
 we need to patch parameters , effective parameters and body in C because parameters are passed by copy in function call it's not needed if More...
 
void outliner_file (entity, list, statement *)
 
statement outliner_call (entity, list, list)
 
void remove_from_formal_parameters (list, list *)
 
void remove_from_effective_parameters (list, list *)
 
void add_induction_var_to_local_declarations (statement *, list)
 
statement outliner (const char *, list)
 outline the statements in statements_to_outline into a module named outline_module_name the outlined statements are replaced by a call to the newly generated module statements_to_outline is modified in place to represent that call More...
 
bool outline (const string)
 entry point for outline module outlining will be performed using either comment recognition or interactively More...
 
bool do_convert_this_array_to_pointer_p (entity)
 array_to_pointer.c More...
 
size_t type_dereferencement_depth (type)
 
bool linearize_array_generic (const char *)
 linearize accesses to an array, and use pointers if asked to More...
 
bool linearize_array (const char *)
 linearize accesses to an array, and use pointers if asked to More...
 
bool linearize_array_fortran (const char *)
 
bool has_entity_with_same_name (entity, list)
 inlining.c More...
 
bool inlining (const char *)
 perform inlining using effects More...
 
bool inlining_simple (const char *)
 perform inlining without using effects More...
 
bool unfolding (char *)
 perform unfolding using effect More...
 
bool unfolding_simple (char *)
 perform unfolding without using effects More...
 
bool kernel_load_store (const char *)
 kernels.c More...
 
bool kernelize (const string)
 turn a loop flagged with LOOP_LABEL into a kernel (GPU, terapix ...) More...
 
bool flag_kernel (const string)
 
bool bootstrap_kernels (const string)
 
void dump_entity_set (set)
 ikernels.c More...
 
bool is_a_kernel (const char *)
 
bool ikernel_load_store (char *)
 
bool kernel_data_mapping (char *)
 
bool wrap_kernel_argument (char *)
 This pass will wrap kernel arguments in a call to a wrapper function. More...
 
void normalize_microcode_anotate (void)
 terapixify.c More...
 
void terapix_loop_optimizer (statement)
 
bool normalize_microcode (char *)
 
bool terapix_warmup (const char *)
 
bool generate_two_addresses_code (const string)
 
bool terapix_remove_divide (const string)
 
bool solve_hardware_constraints (const char *)
 constraints.c More...
 
void remove_preferences (void *)
 delay.c More...
 
bool simd_load_stat_p (statement)
 
bool simd_work_stat_p (statement)
 
bool simd_store_stat_p (statement)
 
bool simd_dma_stat_p (statement)
 This function returns true if the statement is a simd loadsave statement. More...
 
bool simd_stat_p (statement)
 This function returns true if the statement is a simd statement. More...
 
bool delay_load_communications (char *)
 This phase looks for load or save statements that can be put out of the loop body and move these statements, if possible. More...
 
bool delay_load_communications_inter (char *)
 
bool delay_load_communications_intra (char *)
 
bool delay_store_communications (char *)
 
bool delay_store_communications_inter (char *)
 
bool delay_store_communications_intra (char *)
 
bool delay_communications_inter (const char *)
 
bool delay_communications_intra (const char *)
 
void gpu_promote_sequential_on_sequence (sequence, loop)
 gpu_promote_sequential.c More...
 
void gpu_promote_sequential_on_statement (statement)
 
bool gpu_promote_sequential (const char *)
 
bool computation_intensity (const char *)
 computation_intensity.c More...
 
bool statement_has_omp_parallel_directive_p (statement)
 manage_pragma.c More...
 
bool pragma_omp_p (pragma)
 Check that a pragma is an "omp" one. More...
 
bool omp_merge_pragma (const char *)
 merge the pragma on the outer loop More...
 
bool omp_loop_parallel_threshold_set (const char *)
 
void clear_pragma_on_statement (statement)
 Remove all pragma attached to a given statement. More...
 
bool clear_pragma (const char *)
 Clear all pragma This should be done on any input with unhandled pragma, we don't what semantic we might break... More...
 
bool outline_stmts_between_pragmas_in_sequence (sequence, void *)
 
bool pragma_outliner (char *)
 
bool ompify_code (const char *)
 generate_pragma.c More...
 
void get_variables_to_remove (list, statement, list *)
 misc.c More...
 

Macro Definition Documentation

◆ dma_allocate_p

#define dma_allocate_p (   e)    ((e) == dma_allocate )

Definition at line 14 of file accel-util.h.

◆ dma_deallocate_p

#define dma_deallocate_p (   e)    ((e) == dma_deallocate )

Definition at line 15 of file accel-util.h.

◆ dma_load_p

#define dma_load_p (   e)    ((e) == dma_load )

Add NewGen-like methods:

Definition at line 12 of file accel-util.h.

◆ dma_store_p

#define dma_store_p (   e)    ((e) == dma_store )

Definition at line 13 of file accel-util.h.

◆ OUTLINE_IGNORE

#define OUTLINE_IGNORE   "outline_ignore"

Definition at line 18 of file accel-util.h.

◆ OUTLINE_PRAGMA

#define OUTLINE_PRAGMA   "outline this"

Definition at line 17 of file accel-util.h.

Enumeration Type Documentation

◆ region_to_dma_switch

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

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

Enumerator
dma_load 
dma_store 
dma_allocate 
dma_deallocate 
dma_load 
dma_store 
dma_allocate 
dma_deallocate 

Definition at line 10 of file accel-util.h.

@ dma_store
Definition: accel-util.h:10
@ dma_allocate
Definition: accel-util.h:10
@ dma_deallocate
Definition: accel-util.h:10
@ dma_load
Definition: accel-util.h:10

Function Documentation

◆ add_induction_var_to_local_declarations()

void add_induction_var_to_local_declarations ( statement new_body,
list  induction_var 
)
Parameters
new_bodyew_body
induction_varnduction_var

Definition at line 1307 of file outlining.c.

1307  {
1309  FOREACH(entity, ent, induction_var) {
1310  *new_body = add_declaration_statement(*new_body, ent);
1311  }
1313 }
#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
void pop_generated_variable_commenter(void)
Definition: statement.c:2623
statement add_declaration_statement(statement, entity)
Definition: statement.c:2790
void push_generated_variable_commenter(string(*)(entity))
Definition: statement.c:2616
static string outlining_variable_commenter(__attribute__((unused)) entity e)
Definition: outlining.c:65

References add_declaration_statement(), FOREACH, outlining_variable_commenter(), pop_generated_variable_commenter(), and push_generated_variable_commenter().

Referenced by outliner_parameters().

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

◆ array_expansion()

bool array_expansion ( const char *  module_name)

init

do

validate

Parameters
module_nameodule_name

Definition at line 395 of file statement_insertion.c.

396 {
397  /* init */
404  debug_on("ARRAY_EXPANSION_DEBUG_LEVEL");
405 
406  /* do */
411 
412  /* validate */
415 
416  debug_off();
422  return true;
423 }
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
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
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
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
static statement expanded
Definition: inlining.c:157
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
@ hash_pointer
Definition: newgen_hash.h:32
#define HASH_DEFAULT_SIZE
Definition: newgen_hash.h:26
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
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
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 reset_precondition_map(void)
void set_precondition_map(statement_mapping)
static void do_array_expansion_aux(statement s, hash_table expanded)
static bool do_array_expansion(statement s, hash_table expanded)
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, do_array_expansion(), do_array_expansion_aux(), expanded, free_value_mappings(), gen_context_recurse, get_current_module_entity(), get_current_module_statement(), HASH_DEFAULT_SIZE, hash_pointer, hash_table_free(), hash_table_make(), module_name(), module_name_to_entity(), module_reorder(), module_to_value_mappings(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_precondition_map(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_precondition_map(), set_proper_rw_effects(), and statement_domain.

+ Here is the call graph for this function:

◆ bootstrap_kernels()

bool bootstrap_kernels ( const  string)
Parameters
stringodule_name

Definition at line 297 of file kernels.c.

298 {
299  if (db_resource_p(DBR_KERNELS, ""))
300  pips_internal_error("kernels already initialized for %s", module_name);
301  callees kernels=make_callees(NIL);
302  DB_PUT_MEMORY_RESOURCE(DBR_KERNELS,"",kernels);
303  return true;
304 }
callees make_callees(list a)
Definition: ri.c:227
bool db_resource_p(const char *rname, const char *oname)
true if exists and in loaded or stored state.
Definition: database.c:524
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define pips_internal_error
Definition: misc-local.h:149

References DB_PUT_MEMORY_RESOURCE, db_resource_p(), make_callees(), module_name(), NIL, and pips_internal_error.

+ Here is the call graph for this function:

◆ clear_pragma()

bool clear_pragma ( const char *  module_name)

Clear all pragma This should be done on any input with unhandled pragma, we don't what semantic we might break...

Put the new CODE ressource into PIPS:

Parameters
module_nameodule_name

Definition at line 403 of file manage_pragma.c.

403  {
404  debug_on("CLEAR_PRAGMA_DEBUG_LEVEL");
405  statement mod_stmt = statement_undefined;
406  // Get the code and tell PIPS_DBM we do want to modify it
407  mod_stmt = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
408 
409  // Set the current module entity and the current module statement that are
410  // required to have many things working in PIPS
413 
414  // Add the parallel threshold to all the omp for pragmas
416 
417  /* Put the new CODE ressource into PIPS: */
418  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, mod_stmt);
419 
420  // There is no longer a current module:
423 
424  pips_debug(2, "done for %s\n", module_name);
425  debug_off();
426 
427  return true;
428 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
void clear_pragma_on_statement(statement s)
Remove all pragma attached to a given statement.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define statement_undefined
Definition: ri.h:2419

References clear_pragma_on_statement(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_recurse, gen_true(), module_name(), module_name_to_entity(), pips_debug, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_domain, and statement_undefined.

+ Here is the call graph for this function:

◆ clear_pragma_on_statement()

void clear_pragma_on_statement ( statement  s)

Remove all pragma attached to a given statement.

Definition at line 388 of file manage_pragma.c.

388  {
390  list keep_exs = NIL;
391  FOREACH(EXTENSION, ex, exs) {
392  if(!extension_pragma_p(ex))
393  keep_exs = CONS(EXTENSION,ex,keep_exs);
394  }
396  gen_free_list(exs);
397 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define extension_pragma_p(x)
Definition: ri.h:1293
#define EXTENSION(x)
EXTENSION.
Definition: ri.h:1253
#define statement_extensions(x)
Definition: ri.h:2464
#define extensions_extension(x)
Definition: ri.h:1330
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, EXTENSION, extension_pragma_p, extensions_extension, FOREACH, gen_free_list(), NIL, and statement_extensions.

Referenced by clear_pragma(), is_SCOP_rich(), and outline_stmts_between_pragmas_in_sequence().

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

◆ computation_intensity()

bool computation_intensity ( const char *  module_name)

computation_intensity.c

computation_intensity.c

The computation intensity is derived from the complexity and the memory footprint. It assumes the cost model: execution_time = startup_overhead + memory_footprint / bandwidth + complexity / frequency

init stuff

do it now !

validate changes

reset

Parameters
module_nameodule_name

Definition at line 123 of file computation_intensity.c.

123  {
124  /* init stuff */
129 
132 
133  /* do it now ! */
136 
137  /* validate changes */
139 
140  /* reset */
145 
146  return true;
147 }
void reset_complexity_map(void)
void set_complexity_map(statement_mapping)
static void init_computation_intensity_param(computation_intensity_param *p)
read properties to initialize cost model
static bool do_computation_intensity(statement s, computation_intensity_param *p)
a loop statement is considered as compute intensive if transfer costs a re greater than execution cos...
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_computation_intensity(), gen_context_recurse, gen_null2(), get_current_module_statement(), init_computation_intensity_param(), module_name(), module_name_to_entity(), reset_complexity_map(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_complexity_map(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

◆ delay_communications_inter()

bool delay_communications_inter ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 970 of file delay.c.

970  {
973 }
static bool delay_communications(const char *module_name)
Definition: delay.c:924
static bool delay_communications_interprocedurally_p
Definition: delay.c:73

References delay_communications(), delay_communications_interprocedurally_p, and module_name().

+ Here is the call graph for this function:

◆ delay_communications_intra()

bool delay_communications_intra ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 974 of file delay.c.

974  {
977 }

References delay_communications(), delay_communications_interprocedurally_p, and module_name().

+ Here is the call graph for this function:

◆ delay_load_communications()

bool delay_load_communications ( char *  module_name)

This phase looks for load or save statements that can be put out of the loop body and move these statements, if possible.

Get the code of the module.

Go through all the statements

then a backward translation

propagate inter procedurally , except if we have no caller

clean badly generated sequences

Parameters
module_nameodule_name

Definition at line 607 of file delay.c.

608 {
609  /* Get the code of the module. */
611  statement module_stat = (statement)db_get_memory_resource(DBR_CODE, module_name, true);
612  set_ordering_to_statement(module_stat);
614  set_current_module_statement( module_stat);
616  (statement_effects)db_get_memory_resource(DBR_PROPER_EFFECTS, module_name, true)
617  );
620  (statement_effects)db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true)
621  );
622 
623 
624  debug_on("DELAY_COMMUNICATIONS_DEBUG_LEVEL");
627 
628  /* Go through all the statements */
629  context c = { true, NIL, true, false , NULL, NULL };
630 
631  /* then a backward translation */
632  delay_communications_statement(module_stat,&c,NULL);
633 
634  /* propagate inter procedurally , except if we have no caller*/
637  else
639 
640  if(c.need_flatten)
642 
643  /* clean badly generated sequences */
644  clean_up_sequences(module_stat);
645 
647 
648 
649  pips_assert("Statement is consistent\n" , statement_consistent_p(module_stat));
650 
651  module_reorder(module_stat);
652  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
653  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, module_name, compute_callees(module_stat));
654 
655  debug_off();
656 
662 
663  return c.result;
664 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
static void delay_communications_intraprocedurally(statement module_stat, context *c)
transform each caller into a load / call /store sequence
Definition: delay.c:556
static void delay_communications_reset()
Definition: delay.c:596
static void delay_communications_statement(statement, context *, list *block)
Definition: delay.c:455
static void delay_communications_interprocedurally(context *c)
Definition: delay.c:561
static void delay_communications_init()
Definition: delay.c:589
static graph dependence_graph
Definition: delay.c:93
void remove_preferences(void *obj)
entry point to transform preferences in references
Definition: delay.c:89
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
void reset_proper_rw_effects(void)
statement_effects get_proper_rw_effects(void)
bool statement_flatten_declarations(entity module, statement s)
flatten_code.c
Definition: flatten_code.c:509
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define false
Definition: newgen_types.h:80
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
static char * module
Definition: pips.c:74
Definition: delay.c:253
bool need_flatten
Definition: delay.c:257
bool result
Definition: delay.c:254

References clean_up_sequences(), compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, delay_communications_init(), delay_communications_interprocedurally(), delay_communications_interprocedurally_p, delay_communications_intraprocedurally(), delay_communications_reset(), delay_communications_statement(), dependence_graph, false, get_proper_rw_effects(), module, module_name(), module_name_to_entity(), module_reorder(), context::need_flatten, NIL, pips_assert, remove_preferences(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_proper_rw_effects(), context::result, set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_proper_rw_effects(), statement_consistent_p(), and statement_flatten_declarations().

Referenced by delay_load_communications_inter(), and delay_load_communications_intra().

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

◆ delay_load_communications_inter()

bool delay_load_communications_inter ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 665 of file delay.c.

665  {
668 }
bool delay_load_communications(char *module_name)
This phase looks for load or save statements that can be put out of the loop body and move these stat...
Definition: delay.c:607

References delay_communications_interprocedurally_p, delay_load_communications(), and module_name().

+ Here is the call graph for this function:

◆ delay_load_communications_intra()

bool delay_load_communications_intra ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 669 of file delay.c.

References delay_communications_interprocedurally_p, delay_load_communications(), and module_name().

+ Here is the call graph for this function:

◆ delay_store_communications()

bool delay_store_communications ( char *  module_name)

Get the code of the module.

Go through all the statements

a first forward translation

propagate inter procedurally , except if we have no caller

clean badly generated sequences

Parameters
module_nameodule_name

Definition at line 674 of file delay.c.

675 {
676  /* Get the code of the module. */
678  statement module_stat = (statement)db_get_memory_resource(DBR_CODE, module_name, true);
679  set_ordering_to_statement(module_stat);
681  set_current_module_statement( module_stat);
683  (statement_effects)db_get_memory_resource(DBR_PROPER_EFFECTS, module_name, true)
684  );
687  (statement_effects)db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true)
688  );
690 
692 
693  debug_on("DELAY_COMMUNICATIONS_DEBUG_LEVEL");
694 
695 
696 
697  /* Go through all the statements */
698  context c = { true, NIL, false, false, NULL, NULL };
699 
700  /* a first forward translation */
701  delay_communications_statement(module_stat,&c,NULL);
702 
703  /* propagate inter procedurally , except if we have no caller*/
706  else
708 
709  if(c.need_flatten)
711 
712  /* clean badly generated sequences */
713  clean_up_sequences(module_stat);
714 
716 
717  pips_assert("Statement is consistent\n" , statement_consistent_p(module_stat));
718 
719  module_reorder(module_stat);
720  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
721  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, module_name, compute_callees(module_stat));
722 
723  debug_off();
724 
730 
731  return c.result;
732 }

References clean_up_sequences(), compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, delay_communications_init(), delay_communications_interprocedurally(), delay_communications_interprocedurally_p, delay_communications_intraprocedurally(), delay_communications_reset(), delay_communications_statement(), dependence_graph, get_proper_rw_effects(), module, module_name(), module_name_to_entity(), module_reorder(), context::need_flatten, NIL, pips_assert, remove_preferences(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_proper_rw_effects(), context::result, set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_proper_rw_effects(), statement_consistent_p(), and statement_flatten_declarations().

Referenced by delay_store_communications_inter(), and delay_store_communications_intra().

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

◆ delay_store_communications_inter()

bool delay_store_communications_inter ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 733 of file delay.c.

733  {
736 }
bool delay_store_communications(char *module_name)
Definition: delay.c:674

References delay_communications_interprocedurally_p, delay_store_communications(), and module_name().

+ Here is the call graph for this function:

◆ delay_store_communications_intra()

bool delay_store_communications_intra ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 737 of file delay.c.

References delay_communications_interprocedurally_p, delay_store_communications(), and module_name().

+ Here is the call graph for this function:

◆ dimension_to_range()

range dimension_to_range ( dimension  d)
Returns
a range suitable for iteration over all the elements of dimension d

Definition at line 1336 of file isolate_statement.c.

1337 {
1338  return make_range(
1341  int_to_expression(1));
1342 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
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
#define dimension_lower(x)
Definition: ri.h:980
#define dimension_upper(x)
Definition: ri.h:982

References copy_expression(), dimension_lower, dimension_upper, int_to_expression(), and make_range().

Referenced by do_group_constants_terapix().

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

◆ dimensions_to_dma()

call dimensions_to_dma ( effect  reg_from,
entity  to,
list  ld,
list  lo,
enum region_to_dma_switch  m 
)

converts dimensions to a dma call from a memory from to another memory to

Parameters
fromexpression giving the adress of the input memory
toexpression giving the adress of the output memory
ldlist of dimensions to analyze
mkind of call to generate
Returns

Scalar detection:

Need the address for the allocator to modify the pointer itself:

Generate a "void **" type:

dest = "(void **) &to"

Except for the deallocation or if we have a scalar and then we have already created a pointer to it, the original array is referenced through pointer dereferencing:

sizeof(element)*number elements of the array:

Generate communication functions:

Build the sizes of the array block to transfer:

f expressions

Build the sizes of the array with element to transfer:

of expressions

Build the offsets of the array block to transfer:

of expressions

Use a special transfert function for scalars instead of reusing the 1D function. It may useful for example if it is implemented as a FIFO at the hardware level:

Generate host and accel adresses:

Output parameters in an order compatible with some C99 implementation of the runtime: size and block size first, so that some arguments can be defined with them:

Insert offset:

Insert the block size to transfert:

Insert the array sizes:

Insert the element size expression:

Parameters
reg_fromeg_from
too
ldf dimensions
lof offsets

Definition at line 379 of file isolate_statement.c.

384 {
386  expression dest;
387  list args = NIL;
388  const char* function_name = get_dma_name(m,get_dma_dimension(reg_from));
389 
390  entity mcpy = module_name_to_entity(function_name);
391  if (entity_undefined_p(mcpy)) {
393  pips_user_warning("Cannot find \"%s\" method. Are you sure you have set\n"
394  "KERNEL_LOAD_STORE_..._FUNCTION "
395  "to a defined entity and added the correct .c file?\n",function_name);
396  }
399  } else
401 
402  /* Scalar detection: */
403  bool scalar_entity = entity_scalar_p(from);
404 
405  if (dma_allocate_p(m)) {
406  /* Need the address for the allocator to modify the pointer itself: */
408  /* Generate a "void **" type: */
409  type voidpp = make_type_variable(
416  ),
417  NIL,NIL
418  )
419  )
420  ),
421  NIL,NIL
422  )
423  );
424  /* dest = "(void **) &to" */
425  dest = make_expression(
427  make_cast(voidpp,dest)
428  ),
430  }
431  else if (!dma_deallocate_p(m) && !scalar_entity)
432  /* Except for the deallocation or if we have a scalar and then we have
433  already created a pointer to it, the original array is referenced
434  through pointer dereferencing: */
437  else
438  dest=entity_to_expression(to);
439 
440 
441  switch(m) {
442  case dma_deallocate:
443  args = make_expression_list(dest);
444  break;
445  case dma_allocate:
446  {
447  expression sizeof_exp = get_sizeofexpression_for_region(reg_from);
448 
449  /* sizeof(element)*number elements of the array: */
450  expression transfer_size = SizeOfDimensions(ld);
451  transfer_size=MakeBinaryCall(
453  sizeof_exp,
454  transfer_size);
455 
456  args = make_expression_list(dest, transfer_size);
457  } break;
458  case dma_load:
459  case dma_store:
460  /* Generate communication functions: */
461  {
462  //if(!scalar_entity) {
463  /* Build the sizes of the array block to transfer: */
464  list /*of expressions*/ transfer_sizes = NIL;
465  FOREACH(DIMENSION,d,ld) {
466  expression transfer_size=
467  SizeOfDimension(d);
468  transfer_sizes=CONS(EXPRESSION,transfer_size,transfer_sizes);
469  }
470  transfer_sizes=gen_nreverse(transfer_sizes);
471 
472  /* Build the sizes of the array with element to transfer: */
473  list/* of expressions*/ from_dims = NIL;
474  list vardims = variable_to_dimensions(reg_from);
475  FOREACH(DIMENSION,d, vardims) {
476  from_dims=CONS(EXPRESSION,SizeOfDimension(d),from_dims);
477  }
478  gen_full_free_list(vardims);
479  from_dims=gen_nreverse(from_dims);
480 
481  /* Build the offsets of the array block to transfer: */
482  list/* of expressions*/ offsets = NIL;
483  FOREACH(EXPRESSION,e,lo)
484  offsets=CONS(EXPRESSION,e,offsets);
485  offsets=gen_nreverse(offsets);
486  /* Use a special transfert function for scalars instead of reusing
487  the 1D function. It may useful for example if it is implemented
488  as a FIFO at the hardware level: */
489  //} else {
490  // /* If we have a scalar variable to transfert, generate
491  // synthetic transfer parameters: */
492  // /* 1 element to transfert */
493  // transfer_sizes = make_expression_list(int_to_expression(1));
494  // /* 1 dimension */
495  // from_dims = make_expression_list(int_to_expression(1));
496  // /* At the begining of the « array »: */
497  // offsets = make_expression_list(int_to_expression(0));
498  // }
499 
500  expression source = region_to_address(reg_from);
501  /* Generate host and accel adresses: */
502  args = CONS(EXPRESSION,source,CONS(EXPRESSION,dest,NIL));
503  //if(dma_load_p(m))
504  // args=gen_nreverse(args);
505  /* Output parameters in an order compatible with some C99
506  implementation of the runtime: size and block size first, so
507  that some arguments can be defined with them: */
508  /* Insert offset: */
509  args = gen_append(offsets, args);
510  /* Insert the block size to transfert: */
511  args = gen_append(transfer_sizes, args);
512  /* Insert the array sizes: */
513  args = gen_append(from_dims, args);
514  /* Insert the element size expression: */
515  expression sizeof_exp = get_sizeofexpression_for_region(reg_from);
516  args = CONS(EXPRESSION,
517  sizeof_exp,
518  args);
519  } break;
520  default:
521  pips_internal_error("should not happen");
522  }
523  return make_call(mcpy, args);
524 }
cast make_cast(type a1, expression a2)
Definition: ri.c:311
call make_call(entity a1, list a2)
Definition: ri.c:269
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
type make_type_variable(variable _field_)
Definition: ri.c:2715
type make_type_void(list _field_)
Definition: ri.c:2727
basic make_basic_pointer(type _field_)
Definition: ri.c:179
language copy_language(language p)
LANGUAGE.
Definition: ri.c:1202
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
syntax make_syntax_cast(cast _field_)
Definition: ri.c:2503
#define dma_allocate_p(e)
#define dma_deallocate_p(e)
@ dma_store
@ dma_allocate
@ dma_deallocate
@ dma_load
#define region_any_reference(reg)
To be avoided.
void gen_full_free_list(list l)
Definition: genClib.c:1023
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
list gen_append(list l1, const list l2)
Definition: list.c:471
static const char * get_dma_name(enum region_to_dma_switch m, size_t d)
converts a region_to_dma_switch to corresponding dma name according to properties
static size_t get_dma_dimension(region reg_from)
static expression get_sizeofexpression_for_region(region reg)
generate an expression of the form sizeof(typeof(variable[indices]))
list variable_to_dimensions(region reg_from)
static expression region_to_address(region reg)
#define pips_user_warning
Definition: misc-local.h:146
#define make_expression_list(stats...)
#define DEREFERENCING_OPERATOR_NAME
Definition: ri-util-local.h:93
#define ADDRESS_OF_OPERATOR_NAME
#define module_language(e)
implemented as a macro to allow lhs
#define MULTIPLY_OPERATOR_NAME
entity AddEntityToModule(entity e, entity module)
!!! caution, it may not be a module, but a common...
Definition: entity.c:3171
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
Definition: expression.c:342
expression SizeOfDimensions(list)
computes the product of all dimensions in dims
Definition: size.c:522
bool entity_scalar_p(entity)
The concrete type of e is a scalar type.
Definition: variable.c:1113
expression SizeOfDimension(dimension)
Definition: size.c:503
#define normalized_undefined
Definition: ri.h:1745
#define reference_variable(x)
Definition: ri.h:2326
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined_p(x)
Definition: ri.h:2762
void AddEntityToModuleCompilationUnit(entity e, entity module)
Definition: module.c:301

References AddEntityToModule(), AddEntityToModuleCompilationUnit(), ADDRESS_OF_OPERATOR_NAME, CONS, copy_language(), DEREFERENCING_OPERATOR_NAME, DIMENSION, dma_allocate, dma_allocate_p, dma_deallocate, dma_deallocate_p, dma_load, dma_store, entity_intrinsic(), entity_scalar_p(), entity_to_expression(), entity_undefined_p, EXPRESSION, FOREACH, fortran_module_p(), gen_append(), gen_full_free_list(), gen_nreverse(), get_current_module_entity(), get_dma_dimension(), get_dma_name(), get_sizeofexpression_for_region(), make_basic_pointer(), make_call(), make_cast(), make_empty_subroutine(), make_expression(), make_expression_list, make_syntax_cast(), make_type_variable(), make_type_void(), make_variable(), MakeBinaryCall(), MakeUnaryCall(), module_language, module_name_to_entity(), MULTIPLY_OPERATOR_NAME, NIL, normalized_undefined, pips_internal_error, pips_user_warning, reference_variable, region_any_reference, region_to_address(), SizeOfDimension(), SizeOfDimensions(), and variable_to_dimensions().

Referenced by effects_to_dma().

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

◆ do_convert_this_array_to_pointer_p()

bool do_convert_this_array_to_pointer_p ( entity  e)

array_to_pointer.c

Definition at line 68 of file array_to_pointer.c.

68  {
69  if(get_bool_property("LINEARIZE_ARRAY_USE_POINTERS")) {
70  if(get_bool_property("LINEARIZE_ARRAY_SKIP_STATIC_LENGTH_ARRAYS") && !entity_variable_length_array_p(e))
71  return false;
72  value v =entity_initial(e);
74  return true;
75  if( get_bool_property("LINEARIZE_ARRAY_SKIP_LOCAL_ARRAYS") && !entity_formal_p(e) )
76  return false;
77  return true;
78  }
79  return false;
80 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
bool entity_formal_p(entity p)
is p a formal parameter?
Definition: entity.c:1935
bool entity_variable_length_array_p(entity e)
Definition: entity.c:798
bool expression_brace_p(expression e)
predicates and short cut accessors on expressions
Definition: expression.c:407
#define value_undefined_p(x)
Definition: ri.h:3017
#define value_expression_p(x)
Definition: ri.h:3080
#define value_expression(x)
Definition: ri.h:3082
#define entity_initial(x)
Definition: ri.h:2796

References entity_formal_p(), entity_initial, entity_variable_length_array_p(), expression_brace_p(), get_bool_property(), value_expression, value_expression_p, and value_undefined_p.

Referenced by do_array_to_pointer(), do_array_to_pointer_walk_expression(), and do_linearize_array().

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

◆ do_isolate_statement()

void do_isolate_statement ( statement  s,
const char *  prefix,
const char *  suffix 
)

perform statement isolation on statement s that is make sure that all access to variables in s are made either on private variables or on new entities declared on a new memory space.

The prefix is used as a prefix to new entities' name.

this hash table holds an entity to (entity + tag ) binding

Add the calls now if needed, in the correct order:

guard the whole block by according conditions

prends ton couteau suisse et viens jouer avec moi dans pips

Parameters
prefixrefix
suffixuffix

Definition at line 1018 of file isolate_statement.c.

1018  {
1019  bool fine_grain_analysis = true;
1020  statement allocates, loads, stores, deallocates;
1021  /* this hash table holds an entity to (entity + tag ) binding */
1022  hash_table e2e ;
1024  pips_user_warning("isolated statement has callees, transfers will be approximated\n");
1025  fine_grain_analysis = false; // FIXME : This could be true most of the time, especially in Par4All !
1026  }
1028  expression condition = expression_undefined;
1029  allocates = effects_to_dma(s,dma_allocate,e2e,&condition,
1030  fine_grain_analysis,prefix,suffix);
1031  loads = effects_to_dma(s,dma_load,e2e,NULL,fine_grain_analysis,prefix,
1032  suffix);
1033  stores = effects_to_dma(s,dma_store,e2e,NULL,fine_grain_analysis,prefix,
1034  suffix);
1035  deallocates = effects_to_dma(s,dma_deallocate,e2e,NULL,fine_grain_analysis,
1036  prefix,suffix);
1037  HASH_MAP(k,v,free(v),e2e);
1038  hash_table_free(e2e);
1039 
1040  /* Add the calls now if needed, in the correct order: */
1041  if (loads != statement_undefined)
1042  insert_statement(s, loads,true);
1043  if (stores != statement_undefined)
1044  insert_statement(s, stores,false);
1045  if (deallocates != statement_undefined)
1046  insert_statement(s, deallocates,false);
1047  if (allocates != statement_undefined)
1048  insert_statement(s, allocates,true);
1049  /* guard the whole block by according conditions */
1050  if(!expression_undefined_p(condition)) {
1051 
1052  /* prends ton couteau suisse et viens jouer avec moi dans pips */
1053  pips_assert("statement is a block",statement_block_p(s));
1054  for(list prev=NIL,iter=statement_block(s);!ENDP(iter);POP(iter)) {
1055  if(declaration_statement_p(STATEMENT(CAR(iter)))) prev=iter;
1056  else {
1057  pips_assert("there should be at least one declaration inserted by isolate_statement\n",!ENDP(prev));
1058  statement cond =
1061  make_test(
1062  condition,
1063  make_block_statement(iter),
1065  )
1066  )
1067  );
1068  CDR(prev)=CONS(STATEMENT,cond,NIL);
1069  break;
1070  }
1071  }
1072  }
1073 }
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
instruction make_instruction_test(test _field_)
Definition: ri.c:1172
void free(void *)
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
#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 CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
list statement_block(statement)
Get the list of block statements of a statement sequence.
Definition: statement.c:1338
void insert_statement(statement, statement, bool)
This is the normal entry point.
Definition: statement.c:2570
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
static statement effects_to_dma(statement stat, enum region_to_dma_switch s, hash_table e2e, expression *condition, bool fine_grain_analysis, const char *prefix, const char *suffix)
Compute a call to a DMA function from the effects of a statement.
static bool do_isolate_statement_preconditions_satisified_p(statement s)
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
static const char * prefix
#define statement_block_p(stat)
#define make_empty_statement
An alias for make_empty_block_statement.
#define expression_undefined
Definition: ri.h:1223
#define expression_undefined_p(x)
Definition: ri.h:1224
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CAR, CDR, CONS, declaration_statement_p(), dma_allocate, dma_deallocate, dma_load, dma_store, do_isolate_statement_preconditions_satisified_p(), effects_to_dma(), ENDP, expression_undefined, expression_undefined_p, free(), HASH_DEFAULT_SIZE, HASH_MAP, hash_pointer, hash_table_free(), hash_table_make(), insert_statement(), instruction_to_statement(), make_block_statement(), make_empty_statement, make_instruction_test(), make_test(), NIL, pips_assert, pips_user_warning, POP, prefix, STATEMENT, statement_block(), statement_block_p, and statement_undefined.

Referenced by isolate_statement(), and kernel_load_store_generator().

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

◆ dump_entity_set()

void dump_entity_set ( set  s)

ikernels.c

Definition at line 209 of file ikernels.c.

209  {
210  SET_FOREACH(entity, e, s) {
211  fprintf(stderr,"%s,",entity_name(e));
212  }
213  fprintf(stderr,"\n");
214 }
#define SET_FOREACH(type_name, the_item, the_set)
enumerate set elements in their internal order.
Definition: newgen_set.h:78
#define entity_name(x)
Definition: ri.h:2790
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References entity_name, fprintf(), and SET_FOREACH.

+ Here is the call graph for this function:

◆ find_region_on_entity()

effect find_region_on_entity ( entity  e,
list  regions 
)
Returns
region from regions on entity e
Parameters
regionsegions

Definition at line 1325 of file isolate_statement.c.

1326 {
1327  FOREACH(REGION,r,regions)
1329  return region_undefined;
1330 }
#define region_undefined
#define REGION
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321

References FOREACH, reference_variable, REGION, region_any_reference, region_undefined, and same_entity_p().

Referenced by do_solve_hardware_constraints_on_nb_proc(), and do_solve_hardware_constraints_on_volume().

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

◆ flag_kernel()

bool flag_kernel ( const  string)
Parameters
stringodule_name

Definition at line 287 of file kernels.c.

288 {
289  if (!db_resource_p(DBR_KERNELS, ""))
290  pips_internal_error("kernels not initialized for %s", module_name);
291  callees kernels=(callees)db_get_memory_resource(DBR_KERNELS,"",true);
293  DB_PUT_MEMORY_RESOURCE(DBR_KERNELS,"",kernels);
294  return true;
295 }
#define STRING(x)
Definition: genC.h:87
struct _newgen_struct_callees_ * callees
Definition: ri.h:55
#define callees_callees(x)
Definition: ri.h:675
char * strdup()

References callees_callees, CONS, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, db_resource_p(), module_name(), pips_internal_error, strdup(), and STRING.

+ Here is the call graph for this function:

◆ generate_two_addresses_code()

bool generate_two_addresses_code ( const  string)

prelude

validate

ostlude

Parameters
stringodule_name

Definition at line 991 of file terapixify.c.

992 {
993  /* prelude */
999 
1000  /* validate */
1003 
1004  /*postlude*/
1008  return true;
1009 }
void set_conflict_testing_properties()
conflicts.c
Definition: conflicts.c:68
static void two_addresses_code_generator(statement s)
Definition: terapixify.c:948

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, gen_recurse, gen_true(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_conflict_testing_properties(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), statement_domain, and two_addresses_code_generator().

+ Here is the call graph for this function:

◆ get_variables_to_remove()

void get_variables_to_remove ( list  ref_ent,
statement  s,
list l 
)

misc.c

misc.c

Required by R-Stream. Depending on the activated option, only loop indexes or both loop indexes and written scalar variables are put into the list.

Parameters
ref_entef_ent

Definition at line 58 of file misc.c.

58  {
60  switch(instruction_tag(instTop)) {
62  {
64  FOREACH(statement, stmt, stmts) {
65  list enclosing_loops = load_statement_enclosing_loops(s);
66  if (!ENDP(enclosing_loops) && !statement_loop_p(stmt)) {
67  FOREACH(entity, e, ref_ent) {
68  if (get_bool_property("OUTLINE_REMOVE_VARIABLE_RSTREAM_IMAGE")) {
69  bool write_p = find_write_effect_on_entity(stmt, e);
70  if (index_of_a_loop_p((Variable)e, enclosing_loops) || (write_p && !entity_array_p(e))) {
71  *l = gen_once(e,*l);
72  }
73  }
74  else if (get_bool_property("OUTLINE_REMOVE_VARIABLE_RSTREAM_SCOP")) {
75  if (index_of_a_loop_p((Variable)e, enclosing_loops)) {
76  *l = gen_once(e,*l);
77  }
78  }
79  }
80  }
82  switch(instruction_tag(inst)) {
83  case is_instruction_loop :
85  break;
88  break;
89  case is_instruction_test :
92  break;
93  default :
94  break;
95  }
96 
97  }
98  }
99  break;
100  case is_instruction_loop :
101  {
102  get_variables_to_remove(ref_ent, loop_body(instruction_loop(instTop)), l);
103  }
104  break;
106  {
108  }
109  break;
110  case is_instruction_test :
111  {
112  get_variables_to_remove(ref_ent, test_true(instruction_test(instTop)), l);
113  get_variables_to_remove(ref_ent, test_false(instruction_test(instTop)), l);
114  }
115  break;
116  default :
117  {
118  list enclosing_loops = load_statement_enclosing_loops(s);
119  if (!ENDP(enclosing_loops)) {
120  FOREACH(entity, e, ref_ent) {
121  if (get_bool_property("OUTLINE_REMOVE_VARIABLE_RSTREAM_IMAGE")) {
122  bool write_p = find_write_effect_on_entity(s, e);
123  if (index_of_a_loop_p((Variable)e, enclosing_loops) || (write_p && !entity_array_p(e))) {
124  *l = gen_once(e,*l);
125  }
126  }
127  else if (get_bool_property("OUTLINE_REMOVE_VARIABLE_RSTREAM_SCOP")) {
128  if (index_of_a_loop_p((Variable)e, enclosing_loops)) {
129  *l = gen_once(e,*l);
130  }
131  }
132  }
133  }
134  }
135  break;
136  }
137 }
void get_variables_to_remove(list ref_ent, statement s, list *l)
Modifies the list l so it contains all the loop indexes and scalar written variables It is a little "...
Definition: misc.c:58
bool find_write_effect_on_entity(statement, entity)
bool index_of_a_loop_p(Variable v, list loops)
Check if variable v is an index for an enclosing loop.
Definition: loop.c:980
list gen_once(const void *vo, list l)
Prepend an item to a list only if it is not already in the list.
Definition: list.c:722
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
whileloop statement_whileloop(statement)
Get the whileloop of a statement.
Definition: statement.c:1383
bool statement_loop_p(statement)
Definition: statement.c:349
bool entity_array_p(entity e)
Is e a variable with an array type?
Definition: entity.c:754
list load_statement_enclosing_loops(statement)
#define loop_body(x)
Definition: ri.h:1644
#define instruction_loop(x)
Definition: ri.h:1520
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_sequence
Definition: ri.h:1469
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514
#define instruction_whileloop(x)
Definition: ri.h:1523
#define whileloop_body(x)
Definition: ri.h:3162
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_test(x)
Definition: ri.h:1517
Definition: statement.c:54
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 ENDP, entity_array_p(), find_write_effect_on_entity(), FOREACH, gen_once(), get_bool_property(), get_variables_to_remove(), index_of_a_loop_p(), instruction_loop, instruction_sequence, instruction_tag, instruction_test, instruction_whileloop, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_whileloop, load_statement_enclosing_loops(), loop_body, sequence_statements, statement_instruction, statement_loop(), statement_loop_p(), statement_whileloop(), test_false, test_true, and whileloop_body.

Referenced by get_variables_to_remove(), and outliner_parameters().

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

◆ gpu_promote_sequential()

bool gpu_promote_sequential ( const char *  module_name)

Initialize set for each statement

Parameters
module_nameodule_name

Definition at line 143 of file gpu_promote_sequential.c.

143  {
144  statement module_stat = (statement)db_get_memory_resource(DBR_CODE,
145  module_name,
146  true);
147  set_current_module_statement(module_stat);
149 
150  debug_on("GPU_PROMOTE_SEQUENTIAL_DEBUG_LEVEL");
151 
152  /* Initialize set for each statement */
154 
155  debug_off();
156 
157  module_reorder(module_stat);
158 
159  DB_PUT_MEMORY_RESOURCE(DBR_CODE,
160  module_name,
161  module_stat);
162 
163 
166 
167  return true;
168 
169 
170 
171 }
void gpu_promote_sequential_on_statement(statement s)
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gpu_promote_sequential_on_statement(), local_name_to_top_level_entity(), module_name(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), and set_current_module_statement().

+ Here is the call graph for this function:

◆ gpu_promote_sequential_on_sequence()

void gpu_promote_sequential_on_sequence ( sequence  seq,
loop  l 
)

gpu_promote_sequential.c

gpu_promote_sequential.c

The heuristic that trigger the promotion is quite simple at that time, all sequential code is promoted if a parallel loop is present in the sequence

Parameters
seqis the sequence on which to operate @loop l is an optionnal param that give the enclosing loop
Parameters
seqeq

Definition at line 83 of file gpu_promote_sequential.c.

83  {
84  list stmts = sequence_statements(seq);
85 
86  // Try to find a parallel loop in the sequence
87  bool found_parallel_loop_p = false;
88  FOREACH(statement,s,stmts) {
90  found_parallel_loop_p = true;
91  break;
92  }
93  }
94 
95  if(found_parallel_loop_p) {
96  list new_stmts = NIL;
97  list promoted_stmts = NIL;
98  FOREACH(statement,s,stmts) {
101  ifdebug(2) {
102  pips_debug(2,"Promote statement :");
103  print_statement(s);
104  }
105 
106  promoted_stmts = CONS(statement,s,promoted_stmts);
107  }
108  } else if(promoted_stmts) {
109  promoted_stmts = gen_nreverse(promoted_stmts);
110  statement promoted = promote_statement(promoted_stmts, l);
111  new_stmts = CONS(statement,promoted,CONS(statement,s,new_stmts));
112  promoted_stmts = NIL;
113 
114  ifdebug(2) {
115  pips_debug(2,"Promote statements in loop :");
116  print_statement(promoted);
117  }
118  }
119  }
120  if(promoted_stmts) {
121  promoted_stmts = gen_nreverse(promoted_stmts);
122  statement promoted = promote_statement(promoted_stmts, l);
123  new_stmts = CONS(statement,promoted,new_stmts);
124  }
125  sequence_statements(seq) = gen_nreverse(new_stmts); // FIXME Free old sequence
126  }
127 }
static statement promote_statement(list promoted_stmts, loop l)
bool parallel_loop_statement_p(statement s)
Test if a statement is a parallel loop.
Definition: loop.c:420
bool empty_statement_or_continue_p(statement)
Return true if the statement is an empty instruction block or a continue or a recursive combination o...
Definition: statement.c:474
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define ifdebug(n)
Definition: sg.c:47

References CONS, empty_statement_or_continue_p(), FOREACH, gen_nreverse(), ifdebug, NIL, parallel_loop_statement_p(), pips_debug, print_statement(), promote_statement(), and sequence_statements.

Referenced by gpu_promote_sequential_walker_in().

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

◆ gpu_promote_sequential_on_statement()

void gpu_promote_sequential_on_statement ( statement  s)

Definition at line 139 of file gpu_promote_sequential.c.

139  {
141 }
static bool gpu_promote_sequential_walker_in(loop l)
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218

References gen_null(), gen_recurse, gpu_promote_sequential_walker_in(), and loop_domain.

Referenced by gpu_promote_sequential().

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

◆ group_constants()

bool group_constants ( const  string)

Dependences for accel-util.h.

cproto-generated files group_constants.c

prelude

f entities

gather statement constants

gather constants

pack all constants and perform replacement

validate

ostlude

Parameters
stringodule_name

Definition at line 347 of file group_constants.c.

348 {
349  /* prelude */
353 
354  set/*of entities*/ constants=set_make(set_pointer);;
355 
356  /* gather statement constants */
357  statement constant_statement = find_statement_from_label_name(get_current_module_statement(),module_name,get_string_property("GROUP_CONSTANTS_STATEMENT_LABEL"));
358  if(statement_undefined_p(constant_statement)) constant_statement=get_current_module_statement();
359  do_group_statement_constant(constant_statement,constants);
360 
361  /* gather constants */
362  gen_context_multi_recurse(constant_statement,constants,
367 
368  /* pack all constants and perform replacement */
369  do_group_constants(constant_statement,constants);
370 
371  set_free(constants);
372 
373  /* validate */
376 
377  /*postlude*/
381  return true;
382 }
void set_rw_effects(statement_effects)
void reset_rw_effects(void)
char * get_string_property(const char *)
static bool group_constant_range_filter(range r, set constants)
static void do_group_constant_entity(expression exp, set constants)
static void do_group_constants(statement in, set constants)
static void do_group_statement_constant(statement st, set constants)
gather all entities that are read and constant in statement s in the set of constant entities
static bool declaration_filter(call c)
Do not touch to the prettyprint control list.
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
Definition: genClib.c:2796
statement find_statement_from_label_name(statement, const char *, const char *)
Definition: statement.c:3816
void set_free(set)
Definition: set.c:332
@ set_pointer
Definition: newgen_set.h:44
set set_make(set_type)
Create an empty set of any type but hash_private.
Definition: set.c:102
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define statement_undefined_p(x)
Definition: ri.h:2420
#define range_domain
newgen_ram_domain_defined
Definition: ri.h:330
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59

References call_domain, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, declaration_filter(), do_group_constant_entity(), do_group_constants(), do_group_statement_constant(), expression_domain, find_statement_from_label_name(), gen_context_multi_recurse(), gen_false(), gen_null(), gen_true(), get_current_module_statement(), get_string_property(), group_constant_range_filter(), module_name(), module_name_to_entity(), module_reorder(), range_domain, reference_domain, reset_current_module_entity(), reset_current_module_statement(), reset_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_free(), set_make(), set_pointer, set_rw_effects(), and statement_undefined_p.

+ Here is the call graph for this function:

◆ has_entity_with_same_name()

bool has_entity_with_same_name ( entity  e,
list  l 
)

inlining.c

Definition at line 256 of file inlining.c.

256  {
257  FOREACH(ENTITY,ent,l)
258  if(same_entity_name_p(e,ent)) return true;
259  return false;
260 }
bool same_entity_name_p(entity e1, entity e2)
compare entity names
Definition: entity.c:2208
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755

References ENTITY, FOREACH, and same_entity_name_p().

Referenced by check_private_variables_loop_walker(), inline_expression_call(), and outliner_independent_recursively().

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

◆ ikernel_load_store()

bool ikernel_load_store ( char *  )

◆ inlining()

bool inlining ( const char *  module_name)

perform inlining using effects

Parameters
module_namename of the module to inline
Returns
Parameters
module_nameodule_name

Definition at line 957 of file inlining.c.

958 {
959  iparam p =IPARAM_INIT;
960  use_effects(&p)=true;
961  return do_inlining(&p,module_name);
962 }
#define use_effects(p)
Definition: inlining.c:103
#define IPARAM_INIT
Definition: inlining.c:84
static bool do_inlining(inlining_parameters p, const char *module_name)
this should inline all calls to module ‘module_name’ in calling modules, if possible ....
Definition: inlining.c:885
structure containing all the parameters needed by inlining.
Definition: inlining.c:73

References do_inlining(), IPARAM_INIT, module_name(), and use_effects.

+ Here is the call graph for this function:

◆ inlining_simple()

bool inlining_simple ( const char *  module_name)

perform inlining without using effects

Parameters
module_namename of the module to inline
Returns
Parameters
module_nameodule_name

Definition at line 971 of file inlining.c.

972 {
973  iparam p =IPARAM_INIT;
974  use_effects(&p)=false;
975  return do_inlining(&p,module_name);
976 }

References do_inlining(), IPARAM_INIT, module_name(), and use_effects.

+ Here is the call graph for this function:

◆ is_a_kernel()

bool is_a_kernel ( const char *  func_name)
Parameters
func_nameunc_name

Definition at line 369 of file ikernels.c.

369  {
370  callees kernels = (callees)db_get_memory_resource(DBR_KERNELS, "", true);
371  bool found = false;
372  FOREACH(STRING,kernel_name,callees_callees(kernels)) {
373  if((found = (same_string_p(kernel_name,func_name))))
374  break;
375  }
376  return found;
377 }
#define same_string_p(s1, s2)

References callees_callees, db_get_memory_resource(), FOREACH, same_string_p, and STRING.

Referenced by copy_from_call(), copy_to_call(), kernel_data_mapping(), and opencl_compile_mergeable_dag().

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

◆ is_entity_in_list()

bool is_entity_in_list ( entity  e,
list  l 
)

Checks if an entity is in a list.

Done by comparing the minimal user name.

Definition at line 688 of file outlining.c.

688  {
689  if (ENDP(l))
690  return false;
691  FOREACH(entity, ent, l) {
693  return true;
694  }
695  return false;
696 }
const char * entity_minimal_user_name(entity e)
Do not preserve scope information.
Definition: naming.c:223

References ENDP, entity_minimal_user_name(), and FOREACH.

Referenced by outliner_parameters().

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

◆ isolate_patch_entities()

void isolate_patch_entities ( void *  where,
entity  old,
entity  new,
list  offsets 
)

replace all references on entity old by references on entity new and adds offset offsets to its indices

Parameters
wherehere
oldld
newew
offsetsffsets

Definition at line 1148 of file isolate_statement.c.

1149 {
1150  isolate_param p = { old,new,offsets };
1151  gen_context_multi_recurse(where,&p,
1154  0);
1155 }
static void isolate_patch_reference(reference r, isolate_param *p)
replace reference r on entity p->old by a reference on entity p->new with offsets p->offsets
static void isolate_patch_statement(statement s, isolate_param *p)
run isolate_patch_entities on all declared entities from s

References gen_context_multi_recurse(), gen_true(), isolate_patch_reference(), isolate_patch_statement(), reference_domain, and statement_domain.

Referenced by effects_to_dma(), and isolate_patch_statement().

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

◆ isolate_statement()

bool isolate_statement ( const char *  module_name)
Returns
a statement holding the loop necessary to initialize new from old, knowing the dimension of the isolated entity dimensions and its offsets offsets and the direction of the transfer t

init stuff

get user input

and proceed

validate

Parameters
module_nameodule_name

Definition at line 1349 of file isolate_statement.c.

1350 {
1351  /* init stuff */
1358 
1359 
1360  /* get user input */
1361  const char* stmt_label=get_string_property("ISOLATE_STATEMENT_LABEL");
1362  statement statement_to_isolate;
1363  if(!empty_string_p(stmt_label)) {
1365  } else {
1366  statement_to_isolate = get_current_module_statement();
1367  }
1368  /* and proceed */
1369  if(statement_undefined_p(statement_to_isolate))
1370  pips_user_error("statement labeled '%s' not found\n",stmt_label);
1371  else
1372  {
1373  const char* prefix = get_string_property ("ISOLATE_STATEMENT_VAR_PREFIX");
1374  const char* suffix = get_string_property ("ISOLATE_STATEMENT_VAR_SUFFIX");
1375  pips_debug (5, "isolate_statement prefix : %s\n", prefix);
1376  pips_debug (5, "isolate_statement suffix : %s\n", suffix);
1377  do_isolate_statement(statement_to_isolate, prefix, suffix);
1378  }
1379 
1380 
1381 
1382  /* validate */
1386 
1393 
1394  return true;
1395 }
bool empty_string_p(const char *s)
Definition: entity_names.c:239
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
void do_isolate_statement(statement s, const char *prefix, const char *suffix)
perform statement isolation on statement s that is make sure that all access to variables in s are ma...
#define pips_user_error
Definition: misc-local.h:147

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_isolate_statement(), empty_string_p(), find_statement_from_label_name(), free_value_mappings(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), get_string_property(), module_name(), module_name_to_entity(), module_reorder(), module_to_value_mappings(), pips_debug, pips_user_error, prefix, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_precondition_map(), reset_proper_rw_effects(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_precondition_map(), set_proper_rw_effects(), and statement_undefined_p.

+ Here is the call graph for this function:

◆ kernel_data_mapping()

bool kernel_data_mapping ( char *  module_name)

set_entity_to_size(); should be performed at the workspace level

regions

out regions

in regions

preconditions

preconditions

Initialize global hashtables

Initialize set for each statement

Run the pass except if current module is a kernel

Parameters
module_nameodule_name

Definition at line 1344 of file ikernels.c.

1344  {
1345  statement module_stat;
1346 
1348  module_name,
1349  true));
1350  module_stat = get_current_module_statement();
1352  /* set_entity_to_size(); should be performed at the workspace level */
1353 
1354  debug_on("KERNEL_DATA_MAPPING_DEBUG_LEVEL");
1355 
1356 
1357  /* regions */
1358  string region = db_get_memory_resource(DBR_REGIONS, module_name, true);
1360 
1361 
1362  /* out regions */
1363  string or = db_get_memory_resource(DBR_OUT_REGIONS, module_name, true);
1365 
1366  /* in regions */
1367  string ir = db_get_memory_resource(DBR_IN_REGIONS, module_name, true);
1369 
1370  /* preconditions */
1371  string precond = db_get_memory_resource(DBR_PRECONDITIONS, module_name, true);
1373 
1374  /* preconditions */
1375  string cumu = db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true);
1377 
1378  // Stuff for ... ?
1380 
1381 
1382  /* Initialize global hashtables */
1387 
1388  /* Initialize set for each statement */
1390 
1391  /* Run the pass except if current module is a kernel */
1392  if(!is_a_kernel(module_name)) {
1393  copy_from_statement(module_stat);
1394  copy_to_statement(module_stat);
1395  // Is it a bad hack ? Should we need a fix point here ?
1396  copy_from_statement(module_stat);
1397 
1398  transfert_statement(module_stat, MAKE_SET(), MAKE_SET(), MAKE_SET(), MAKE_SET());
1399  }
1400 
1401  ifdebug(1) {
1402  pips_debug(1,"Interprocedural summary for %s :\n To :",module_name);
1403  print_entities(set_to_list(COPY_TO_IN(module_stat)));
1404  fprintf(stderr,"\n From :");
1405  print_entities(set_to_list(COPY_FROM_OUT(module_stat)));
1406  fprintf(stderr,"\n");
1407  }
1408 
1409  DB_PUT_MEMORY_RESOURCE(DBR_CODE,
1410  module_name,
1411  module_stat);
1412 
1413  DB_PUT_MEMORY_RESOURCE(DBR_KERNEL_COPY_IN,
1414  module_name,
1415  make_memory_mapping(COPY_TO_IN(module_stat)));
1416  DB_PUT_MEMORY_RESOURCE(DBR_KERNEL_COPY_OUT,
1417  module_name,
1418  make_memory_mapping(COPY_FROM_OUT(module_stat)));
1419 
1420 #define TABLE_FREE(t) \
1421  {HASH_MAP( k, v, {set_free( (set)v ) ;}, t ) ; hash_table_free(t);}
1422 
1423  // TABLE_FREE(copies_from_in);
1424  // TABLE_FREE(copies_from_out);
1425 
1428  reset_in_effects();
1434 
1435  return true;
1436 }
memory_mapping make_memory_mapping(set a)
#define region
simulation of the type region
void reset_out_effects(void)
void set_out_effects(statement_effects)
void set_in_effects(statement_effects)
void reset_in_effects(void)
bool is_a_kernel(const char *func_name)
Definition: ikernels.c:369
#define INIT_STATEMENT_SIZE
Definition: ikernels.c:141
#define MAKE_SET()
Macro to create set.
Definition: ikernels.c:145
#define COPY_TO_IN(st)
Definition: ikernels.c:181
static void copy_from_statement(statement st)
Definition: ikernels.c:580
static hash_table copies_to_in
copy_to_in maps each statement to the "copy to" data that are in-coming the statement
Definition: ikernels.c:180
static hash_table copies_to_out
copy_to_out maps each statement to the "copy to" data that are out-going from the statement
Definition: ikernels.c:195
#define COPY_FROM_OUT(st)
Definition: ikernels.c:166
static void init_one_statement(statement st)
Definition: ikernels.c:379
static hash_table copies_from_out
copy_from_out maps each statement to the "copy from" data that are out-going from the statement
Definition: ikernels.c:165
static void transfert_statement(statement st, set already_transfered_to, set already_transfered_from, set array_to_transfer_to_after, set array_to_transfer_from_before)
Definition: ikernels.c:1152
static void copy_to_statement(statement st)
Definition: ikernels.c:863
static hash_table copies_from_in
copy_from_in maps each statement to the "copy from" data that are in-coming the statement
Definition: ikernels.c:150
list set_to_list(const set)
create a list from a set the set is not freed
Definition: set.c:436
void print_entities(list l)
Definition: entity.c:167

References copies_from_in, copies_from_out, copies_to_in, copies_to_out, COPY_FROM_OUT, copy_from_statement(), COPY_TO_IN, copy_to_statement(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_on, fprintf(), free_value_mappings(), gen_recurse, gen_true(), get_current_module_entity(), get_current_module_statement(), hash_pointer, hash_table_make(), ifdebug, init_one_statement(), INIT_STATEMENT_SIZE, is_a_kernel(), local_name_to_top_level_entity(), make_memory_mapping(), MAKE_SET, module_name(), module_to_value_mappings(), pips_debug, print_entities(), region, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_in_effects(), reset_out_effects(), reset_precondition_map(), reset_proper_rw_effects(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_in_effects(), set_out_effects(), set_precondition_map(), set_proper_rw_effects(), set_to_list(), statement_domain, and transfert_statement().

+ Here is the call graph for this function:

◆ kernel_load_store()

bool kernel_load_store ( const char *  module_name)

kernels.c

kernels.c

based on convex array regions

Parameters
module_nameodule_name

Definition at line 143 of file kernels.c.

143  {
144  return kernel_load_store_engine(module_name, DBR_REGIONS);
145 }
static bool kernel_load_store_engine(const char *module_name, const string enginerc)
run kernel load store using either region or effect engine
Definition: kernels.c:93

References kernel_load_store_engine(), and module_name().

+ Here is the call graph for this function:

◆ kernelize()

bool kernelize ( const string  module_name)

turn a loop flagged with LOOP_LABEL into a kernel (GPU, terapix ...)

Parameters
module_namename of the module
Returns
true

prelude

retreive loop label

run kernelize

validate

ostlude

Parameters
module_nameodule_name

Definition at line 259 of file kernels.c.

260 {
261  /* prelude */
264 
265  /* retreive loop label */
266  const char* loop_label_name = get_string_property_or_ask("LOOP_LABEL","label of the loop to turn into a kernel ?\n");
267  entity loop_label_entity = find_label_entity(module_name,loop_label_name);
268  if( entity_undefined_p(loop_label_entity) )
269  pips_user_error("label '%s' not found in module '%s' \n",loop_label_name,module_name);
270 
271 
272  /* run kernelize */
275 
276  /* validate */
280 
281  /*postlude*/
284  return true;
285 }
static bool do_kernelize(statement s, entity loop_label)
create a statement eligible for outlining into a kernel #1 find the loop flagged with loop_label #2 m...
Definition: kernels.c:162
const char * get_string_property_or_ask(const char *, const char[])
entity find_label_entity(const char *, const char *)
util.c
Definition: util.c:43

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_kernelize(), entity_undefined_p, find_label_entity(), gen_context_recurse, gen_null2(), get_current_module_statement(), get_string_property_or_ask(), module_name(), module_name_to_entity(), module_reorder(), pips_user_error, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

◆ linearize_array()

bool linearize_array ( const char *  module_name)

linearize accesses to an array, and use pointers if asked to

Parameters
module_nameodule_name

Definition at line 987 of file array_to_pointer.c.

988 {
990 }
bool linearize_array_generic(const char *module_name)
linearize accesses to an array, and use pointers if asked to

References linearize_array_generic(), and module_name().

+ Here is the call graph for this function:

◆ linearize_array_fortran()

bool linearize_array_fortran ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 992 of file array_to_pointer.c.

993 {
995 }

References linearize_array_generic(), and module_name().

+ Here is the call graph for this function:

◆ linearize_array_generic()

bool linearize_array_generic ( const char *  module_name)

linearize accesses to an array, and use pointers if asked to

prelude

Do we have to cast the array at call site ?

it is too dangerous to perform this task on compilation unit, system variables may be changed

just linearize accesses and change signature from n-D arrays to 1-D arrays

additionally perform array-to-pointer conversion for c modules only

validate

ostlude

Parameters
module_nameodule_name

Definition at line 930 of file array_to_pointer.c.

931 {
932 
933  debug_on("LINEARIZE_ARRAY_DEBUG_LEVEL");
934  /* prelude */
936 
937  param_t param = { .use_pointers_p = false , .modify_call_site_p = false, .cast_at_call_site_p = false };
938  /* Do we have to cast the array at call site ? */
940  param.use_pointers_p = get_bool_property("LINEARIZE_ARRAY_USE_POINTERS");
941  param.cast_at_call_site_p = get_bool_property("LINEARIZE_ARRAY_CAST_AT_CALL_SITE");
942  }
943  param.modify_call_site_p = get_bool_property("LINEARIZE_ARRAY_MODIFY_CALL_SITE");
944 
945  /* it is too dangerous to perform this task on compilation unit, system variables may be changed */
947 
949 
950  /* just linearize accesses and change signature from n-D arrays to 1-D arrays */
952 
953  /* additionally perform array-to-pointer conversion for c modules only */
954  if(param.use_pointers_p) {
959  if(entity_variable_p(e)) {
961  }
962  }
963  }
964  else pips_user_warning("no pointers in fortran !,LINEARIZE_ARRAY_USE_POINTERS ignored\n");
965  }
966 
967  /* validate */
972  // remove decls_text or the prettyprinter will use that field
974  } else {
975  //compilation unti doesn't exit in fortran
977  }
978  /*postlude*/
980  }
982  debug_off();
983  return true;
984 }
bool db_touch_resource(const char *rname, const char *oname)
touch logical time for resource[owner], possibly behind the back of pipsdbm.
Definition: database.c:538
static void do_linearize_array(entity m, statement s, param_t *param)
static void do_array_to_pointer(entity m, statement s, _UNUSED_ param_t *p)
transform each array type in module m with statement s
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
Definition: module.c:350
void cleanup_subscripts(void *)
#define entity_declarations(e)
MISC: newgen shorthands.
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
bool compilation_unit_entity_p(entity e)
Check if the given module entity is a compilation unit.
Definition: module.c:87
void discard_module_declaration_text(entity)
Discard the decls_text string of the module code to make the prettyprinter ignoring the textual decla...
Definition: variable.c:1696
Definition: replace.c:135

References c_module_p(), cleanup_subscripts(), compilation_unit_entity_p(), compilation_unit_of_module(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, db_touch_resource(), debug_off, debug_on, discard_module_declaration_text(), do_array_to_pointer(), do_linearize_array(), ENTITY, entity_declarations, entity_initial, entity_variable_p, false, FOREACH, fortran_module_p(), get_bool_property(), get_current_module_entity(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), pips_assert, pips_user_warning, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_consistent_p().

Referenced by linearize_array(), and linearize_array_fortran().

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

◆ loop_expansion()

bool loop_expansion ( const char *  module_name)

loop_expansion.c

first case: statement inserted by loop_expansion_init were illegal

generate guard if no statement to merge or no statement to clean

remove the test statement

second case: statement inserted by loop_expansion_init were legal

remove the test statement and merge

ok for the ui part, let's do something !

commit changes

< we may have add statements

Parameters
module_nameodule_name

Definition at line 261 of file loop_expansion.c.

262 {
266 
267  debug_on("LOOP_EXPANSION_DEBUG_LEVEL");
268  /* first case: statement inserted by loop_expansion_init were illegal */
269  list statements_to_clean = find_statements_with_pragma(get_current_module_statement(),get_string_property("STATEMENT_INSERTION_FAILURE_PRAGMA"));
270  list statements_to_merge = find_statements_with_pragma(get_current_module_statement(),get_string_property("STATEMENT_INSERTION_SUCCESS_PRAGMA"));
271  /* generate guard if no statement to merge or no statement to clean */
272  bool apply_guard = ENDP(statements_to_merge) && ENDP(statements_to_clean);
273 
274  /* remove the test statement */
275  FOREACH(STATEMENT,statement_to_clean,statements_to_clean)
276  {
278  free_extensions(statement_extensions(statement_to_clean));
279  statement_extensions(statement_to_clean)=empty_extensions();
280  }
281 
282  /* second case: statement inserted by loop_expansion_init were legal */
283  /* remove the test statement and merge */
284  FOREACH(STATEMENT,statement_to_clean,statements_to_merge)
285  {
287  free_extensions(statement_extensions(statement_to_clean));
288  statement_extensions(statement_to_clean)=empty_extensions();
289 
290  }
291 
292  gen_free_list(statements_to_clean);
293  gen_free_list(statements_to_merge);
294 
295  const char* lp_label=get_string_property_or_ask(
296  "LOOP_LABEL",
297  "Which loop do you want to expand?\n(give its label):"
298  );
299  if( !empty_string_p(lp_label) )
300  {
301  entity lb_entity = find_label_entity(module_name,lp_label);
302  if( !entity_undefined_p(lb_entity) )
303  {
304  statement loop_statement = find_loop_from_label(get_current_module_statement(),lb_entity);
305  if(!statement_undefined_p(loop_statement))
306  {
307  const char* srate = get_string_property("LOOP_EXPANSION_SIZE");
309  /* ok for the ui part, let's do something !*/
310  do_loop_expansion(loop_statement,rate,get_bool_property("LOOP_EXPANSION_CENTER"),apply_guard);
311  /* commit changes */
312  module_reorder(get_current_module_statement()); ///< we may have add statements
314 
315  }
316  else pips_user_error("label '%s' is not put on a loop\n",lp_label);
317 
318 
319  }
320  else pips_user_error("loop label `%s' does not exist\n", lp_label);
321  }
322  else pips_user_error("transformation cancelled \n", lp_label);
323 
324  debug_off();
328  return true;;
329 
330 }
void free_extensions(extensions p)
Definition: ri.c:950
expression string_to_expression(const char *s, entity module)
Functions using simultaneously pipsdbm, which is based on strings, and ri-util, which contains basic ...
Definition: expressions.c:50
instruction make_continue_instruction()
Creates a CONTINUE instruction, that is the FORTRAN nop, the ";" in C or the "pass" in Python for exa...
Definition: instruction.c:79
statement update_statement_instruction(statement, instruction)
Replace the instruction in statement s by instruction i.
Definition: statement.c:3039
list find_statements_with_pragma(statement, const char *)
Get a list of statements with pragma begining with a prefix.
Definition: statement.c:3912
static void do_loop_expansion(statement st, expression size, bool center, bool apply_guard)
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
statement find_loop_from_label(statement, entity)
Definition: util.c:218

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, do_loop_expansion(), empty_extensions(), empty_string_p(), ENDP, entity_undefined_p, find_label_entity(), find_loop_from_label(), find_statements_with_pragma(), FOREACH, free_extensions(), gen_free_list(), get_bool_property(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), get_string_property(), get_string_property_or_ask(), make_continue_instruction(), module_name(), module_name_to_entity(), module_reorder(), pips_user_error, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), STATEMENT, statement_extensions, statement_undefined_p, string_to_expression(), and update_statement_instruction().

+ Here is the call graph for this function:

◆ loop_expansion_init()

bool loop_expansion_init ( const char *  module_name)

first step of the loop expansion process: create a statement to insert and flag it with a pragma

ok for the ui part, let's do something !

commit changes

< we may have add statements

Parameters
module_nameodule_name

Definition at line 401 of file loop_expansion.c.

402 {
405 
406  debug_on("LOOP_EXPANSION_INIT_DEBUG_LEVEL");
407 
408 
409  const char* lp_label=get_string_property_or_ask(
410  "LOOP_LABEL",
411  "Which loop do you want to expand?\n(give its label):"
412  );
413 
414  if( !empty_string_p(lp_label) )
415  {
416  entity lb_entity = find_label_entity(module_name,lp_label);
417  if( !entity_undefined_p(lb_entity) )
418  {
419  statement loop_statement = find_loop_from_label(get_current_module_statement(),lb_entity);
420  if(!statement_undefined_p(loop_statement))
421  {
422  const char* srate = get_string_property("LOOP_EXPANSION_SIZE");
424  /* ok for the ui part, let's do something !*/
425  do_loop_expansion_init(loop_statement,rate);
426  /* commit changes */
427  module_reorder(get_current_module_statement()); ///< we may have add statements
429 
430  }
431  else pips_user_error("label '%s' is not put on a loop\n",lp_label);
432 
433 
434  }
435  else pips_user_error("loop label `%s' does not exist\n", lp_label);
436  }
437  else pips_user_error("transformation cancelled \n", lp_label);
438 
439  debug_off();
442  return true;;
443 
444 }
static void do_loop_expansion_init(statement st, expression size)
creates a new statement that perfom the expansion of the loop this statement is flagged for further p...

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, do_loop_expansion_init(), empty_string_p(), entity_undefined_p, find_label_entity(), find_loop_from_label(), get_current_module_entity(), get_current_module_statement(), get_string_property(), get_string_property_or_ask(), module_name(), module_name_to_entity(), module_reorder(), pips_user_error, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_undefined_p, and string_to_expression().

+ Here is the call graph for this function:

◆ normalize_microcode()

bool normalize_microcode ( char *  module_name)

prelude

checks

make sure

  • only do loops remain
  • no call to external functions
  • no float / double etc

unroll some loops with constant trip count

reorder some loops

detect initial array sizes

now, try to guess the goal of the parameters

  • parameters are 32 bits signed integers (TODO)
  • read-only arrays might be mask, but can also be images (depend of their size ?)
  • written arrays must be images
  • integer are loop parameters
  • others are not allowed

reserve some register for internal use

it's a pointer

a rom array with only one element, outlining and isolate_statement where too smart :)

pips bonus step: the consistency

rename all declared entities using terasm convention

need a copy otherwise goes in infinite loop

it's a pointer

it's an int

reorder arguments to match terapix conventions

loops in terasm iterate over a given parameter, in the form DO I=1:N I is hidden to the user and N must be a parameter

normalize test

try some simple optimizations

validate

ostlude

Parameters
module_nameodule_name

Definition at line 626 of file terapixify.c.

627 {
628  bool can_terapixify =true;
629  /* prelude */
633 
634  /* checks */
635 
636  /* make sure
637  * - only do loops remain
638  * - no call to external functions
639  * - no float / double etc
640  */
646  NULL);
647 
648  /* unroll some loops with constant trip count */
651 
652  /* reorder some loops */
654 
655 
656  /* detect initial array sizes */
658 
659  /* now, try to guess the goal of the parameters
660  * - parameters are 32 bits signed integers (TODO)
661  * - read-only arrays might be mask, but can also be images (depend of their size ?)
662  * - written arrays must be images
663  * - integer are loop parameters
664  * - others are not allowed
665  */
666  size_t nb_fifo = 1;
667  size_t nb_lu = 1;
668  size_t nb_ptr = 1;
669  size_t nb_ma = 1;
670  size_t nb_re = 5;/* reserve some register for internal use */
672  {
673  if(!entity_area_p(e))
674  {
676  basic vb = variable_basic(v);
677  if(formal_parameter_p(e))
678  {
679  if( basic_pointer_p(vb) ) /* it's a pointer */
680  {
681  string prefix = NULL;
684  if( strstr(entity_user_name(e),get_string_property("GROUP_CONSTANTS_HOLDER")) ) {
685  printf("%s seems a mask\n",entity_user_name(e));
687  }
688  else {
689  printf("%s seems an image\n",entity_user_name(e));
691  }
693  }
694  else if( entity_used_in_loop_bound_p(e) )
695  {
696  printf("%s belongs to a loop bound\n",entity_user_name(e));
697  //terapix_argument_handler(e,TERAPIX_LOOPARG_PREFIX,&nb_lu,NULL,NULL);
698  }
699  /* a rom array with only one element, outlining and isolate_statement where too smart :) */
700  else if ( strstr(entity_user_name(e),get_string_property("GROUP_CONSTANTS_HOLDER")) &&
701  entity_scalar_p(e)) {
702 
706  NIL,
707  NIL
708  )
709  );
710  expression repl = MakeUnaryCall(
713  );
716  e,
717  repl);
718  free_expression(repl);
719  /* pips bonus step: the consistency */
720  intptr_t i=1,
723  if(i++==offset) {
724  dummy d = parameter_dummy(p);
725  if(dummy_identifier_p(d))
726  {
727  entity di = dummy_identifier(d);
731  NIL,
732  NIL
733  )
734  );
735  }
739  NIL,
740  NIL
741  )
742  );
743  break;
744  }
745  }
747  list callers_statement = callers_to_statements(callers);
748  list call_sites = callers_to_call_sites(callers_statement,get_current_module_entity());
749  pips_assert("only one caller here\n",
750  !ENDP(call_sites) && ENDP(CDR(call_sites)));
751  list args = call_arguments(CALL(CAR(call_sites)));
752  for(intptr_t i=1;i<offset;i++) POP(args);
753  expression *exp = (expression*)REFCAR(args);
754  *exp=
757  *exp
758  );
759 
760 
761  for(list citer=callers,siter=callers_statement;!ENDP(citer);POP(citer),POP(siter))
762  DB_PUT_MEMORY_RESOURCE(DBR_CODE, STRING(CAR(citer)),STATEMENT(CAR(siter)));
764  gen_free_list(callers_statement);
765 
766  printf("%s seems a mask\n",entity_user_name(e));
768  }
769  }
770  else if( basic_pointer_p(vb) ) {
771  terapix_argument_handler(e,NULL,NULL,TERAPIX_IMAGE_PREFIX,&nb_ptr);
772  } else if( entity_scalar_p(e))
774  else
776  }
777  }
778 
779  /* rename all declared entities using terasm convention*/
781  bool stop=true;
782  do {
783  stop=true;
784  /* need a copy otherwise goes in infinite loop */
785  FOREACH(ENTITY,e,tmp)
786  {
787  if(entity_variable_p(e))
788  {
790  if( basic_pointer_p(variable_basic(v)) ) {/* it's a pointer */
793  stop=false;
794  }
795  else
796  terapix_argument_handler(e,NULL,NULL,TERAPIX_IMAGE_PREFIX,&nb_ptr);
797  }
798  else if( basic_int_p(variable_basic(v))) /* it's an int */
800  }
801  }
802  } while(!stop);
803  gen_free_list(tmp);
804 
805  /* reorder arguments to match terapix conventions */
807 
808  /* loops in terasm iterate over a given parameter, in the form DO I=1:N
809  * I is hidden to the user and N must be a parameter */
810  {
813  .cnt=&nb_lu
814  };
816  }
817 
819 
820  /* normalize test */
822 
823  /* try some simple optimizations */
826 
827 
828  /* validate */
831 
832  /*postlude*/
836  return true || can_terapixify;
837 }
void free_expression(expression p)
Definition: ri.c:853
list callers_to_call_sites(list callers_statement, entity called_module)
given a list callers_statement of module statements returns a list of calls to module called_module
Definition: callgraph.c:149
list callers_to_statements(list callers)
given a list callers of module name calling module called module return a list of their body
Definition: callgraph.c:163
int dummy
A dummy file, to prevent empty libraries from breaking builds.
Definition: dummy.c:41
static Value offset
Definition: translation.c:283
void replace_entity_by_expression(void *s, entity ent, expression exp)
replace all reference to entity ent by expression exp in s.
Definition: replace.c:220
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
#define REFCAR(pc)
Get the adress of the first element of a list.
Definition: newgen_list.h:119
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define module_functional_parameters(func)
bool entity_area_p(entity e)
Definition: area.c:149
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
type ultimate_type(type)
Definition: type.c:3466
bool formal_parameter_p(entity)
Definition: variable.c:1489
#define forloop_domain
newgen_extensions_domain_defined
Definition: ri.h:178
#define formal_offset(x)
Definition: ri.h:1408
#define dummy_identifier(x)
Definition: ri.h:1033
#define basic_pointer(x)
Definition: ri.h:637
#define parameter_dummy(x)
Definition: ri.h:1823
#define parameter_type(x)
Definition: ri.h:1819
#define basic_int_p(x)
Definition: ri.h:614
#define type_variable(x)
Definition: ri.h:2949
#define basic_pointer_p(x)
Definition: ri.h:635
#define entity_storage(x)
Definition: ri.h:2794
#define storage_formal(x)
Definition: ri.h:2524
#define PARAMETER(x)
PARAMETER.
Definition: ri.h:1788
#define whileloop_domain
newgen_variable_domain_defined
Definition: ri.h:466
#define statement_declarations(x)
Definition: ri.h:2460
#define CALL(x)
CALL.
Definition: ri.h:679
#define call_arguments(x)
Definition: ri.h:711
#define entity_type(x)
Definition: ri.h:2792
#define dummy_identifier_p(x)
Definition: ri.h:1031
#define variable_basic(x)
Definition: ri.h:3120
int printf()
#define intptr_t
Definition: stdint.in.h:294
#define TERAPIX_MASK_PREFIX
Definition: terapixify.c:131
static bool terapix_pointer_initialized_from_a_mask_p(entity e)
Definition: terapixify.c:354
static bool can_terapixify_expression_p(expression e, bool *can_terapixify)
Definition: terapixify.c:86
static void stmt_rm_useless_label_rwt(statement s)
Definition: terapixify.c:621
static void normalize_microcode_parameter_orders(entity module)
Definition: terapixify.c:318
static void terapix_normalize_tests(call c)
a test is normalized when it is in the form a>0
Definition: terapixify.c:362
void normalize_microcode_anotate()
terapixify.c
Definition: terapixify.c:410
#define TERAPIX_IMAGE_PREFIX
Definition: terapixify.c:130
static bool cannot_terapixify(gen_chunk *elem, bool *can_terapixify)
terapixify
Definition: terapixify.c:68
static bool can_terapixify_call_p(call c, bool *can_terapixify)
Definition: terapixify.c:75
static void terapixify_loops(statement s)
Definition: terapixify.c:565
static void terapix_loop_handler(statement sl, terapix_loop_handler_param *p)
Definition: terapixify.c:245
static void terapix_argument_handler(entity e, string arg_prefix, size_t *arg_cnt, string ass_prefix, size_t *ass_cnt)
Definition: terapixify.c:217
#define TERAPIX_PTRARG_PREFIX
Definition: terapixify.c:128
static void terapix_optimize_accumulator(statement st)
if only one register is ever written by a sequence of assignment, take advantage of it
Definition: terapixify.c:442
static void force_terapix_argument_handler(entity e, string arg_prefix, size_t *arg_cnt, string ass_prefix, size_t *ass_cnt)
Definition: terapixify.c:220
#define TERAPIX_REGISTER_PREFIX
Definition: terapixify.c:132
void terapix_loop_optimizer(statement st)
Definition: terapixify.c:498
static bool entity_used_in_loop_bound_p(entity e)
Definition: terapixify.c:121
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References ADDRESS_OF_OPERATOR_NAME, basic_int_p, basic_pointer, basic_pointer_p, CALL, call_arguments, call_domain, callees_callees, callers_to_call_sites(), callers_to_statements(), can_terapixify_call_p(), can_terapixify_expression_p(), cannot_terapixify(), CAR, CDR, clean_up_sequences(), compilation_unit_of_module(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, db_touch_resource(), DEREFERENCING_OPERATOR_NAME, dummy_identifier, dummy_identifier_p, ENDP, ENTITY, entity_area_p(), entity_declarations, entity_intrinsic(), entity_scalar_p(), entity_storage, entity_to_expression(), entity_type, entity_used_in_loop_bound_p(), entity_user_name(), entity_variable_p, exp, expression_domain, force_terapix_argument_handler(), FOREACH, forloop_domain, formal_offset, formal_parameter_p(), free_expression(), gen_context_multi_recurse(), gen_context_recurse, gen_copy_seq(), gen_free_list(), gen_null(), gen_recurse, gen_true(), gen_true2(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), get_string_property(), HASH_DEFAULT_SIZE, hash_pointer, hash_table_make(), terapix_loop_handler_param::ht, intptr_t, make_basic_pointer(), make_type_variable(), make_variable(), MakeUnaryCall(), module_functional_parameters, module_name(), module_name_to_entity(), module_reorder(), NIL, normalize_microcode_anotate(), normalize_microcode_parameter_orders(), offset, PARAMETER, parameter_dummy, parameter_type, pips_assert, POP, prefix, printf(), REFCAR, replace_entity_by_expression(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), STATEMENT, statement_declarations, statement_domain, stmt_rm_useless_label_rwt(), storage_formal, STRING, terapix_argument_handler(), TERAPIX_IMAGE_PREFIX, terapix_loop_handler(), terapix_loop_optimizer(), TERAPIX_MASK_PREFIX, terapix_normalize_tests(), terapix_optimize_accumulator(), terapix_pointer_initialized_from_a_mask_p(), TERAPIX_PTRARG_PREFIX, TERAPIX_REGISTER_PREFIX, terapixify_loops(), type_variable, ultimate_type(), variable_basic, and whileloop_domain.

◆ normalize_microcode_anotate()

void normalize_microcode_anotate ( void  )

terapixify.c

there should be only one caller

Eeny, meeny, miny, moe

get ready for annotation insertion

Definition at line 410 of file terapixify.c.

410  {
412  /* there should be only one caller */
413  string caller = STRING(CAR(callers));
414  /* Eeny, meeny, miny, moe */
416  if(entity_pointer_p(fa)) {
417  const char* fa_name = entity_user_name(fa);
418  entity caller_faname = FindEntityFromUserName(caller,fa_name);
419  if(entity_undefined_p(caller_faname)){
420  string tmp=strdup(fa_name);
421  tmp[strlen(tmp)-1]=0;
422  caller_faname = FindEntityFromUserName(caller,tmp);
423  free(tmp);
424  }
425  pips_assert("parameter found",!entity_undefined_p(caller_faname));
426  /* get ready for annotation insertion */
427  string pragma;
428  asprintf(&pragma,"terapix %s", fa_name);
430  string tmp = pragma;
431  asprintf(&pragma,"%s %d",pragma, dimension_size(d));
432  free(tmp);
433  }
436  pragma,false);
437  }
438  }
439 }
#define asprintf
Definition: misc-local.h:225
entity FindEntityFromUserName(const char *package, const char *name)
Definition: entity.c:1520
bool entity_pointer_p(entity e)
Definition: entity.c:745
list module_formal_parameters(entity func)
list module_formal_parameters(entity func) input : an entity representing a function.
Definition: module.c:327
void add_pragma_str_to_statement(statement st, const char *s, bool copy_flag)
Add a string as a pragma to a statement.
Definition: pragma.c:425
int dimension_size(dimension)
this function computes the size of a dimension.
Definition: size.c:491
struct _newgen_struct_pragma_ * pragma
Definition: ri.h:295
#define variable_dimensions(x)
Definition: ri.h:3122

References add_pragma_str_to_statement(), asprintf, callees_callees, CAR, db_get_memory_resource(), DIMENSION, dimension_size(), entity_pointer_p(), entity_type, entity_undefined_p, entity_user_name(), FindEntityFromUserName(), FOREACH, free(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), module_formal_parameters(), pips_assert, STATEMENT, statement_block(), strdup(), STRING, type_variable, and variable_dimensions.

Referenced by normalize_microcode().

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

◆ omp_loop_parallel_threshold_set()

bool omp_loop_parallel_threshold_set ( const char *  module_name)

Should never arise

Put the new CODE ressource into PIPS:

Parameters
module_nameodule_name

Definition at line 351 of file manage_pragma.c.

351  {
352  debug_on("OPMIFY_CODE_DEBUG_LEVEL");
353  statement mod_stmt = statement_undefined;
354  // Get the code and tell PIPS_DBM we do want to modify it
355  mod_stmt = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
356 
357  // Set the current module entity and the current module statement that are
358  // required to have many things working in PIPS
361 
362  // generate pragma string or expression using the correct language:
364  if(value_code_p(mv)) {
365  code c = value_code(mv);
367  } else {
368  /* Should never arise */
370  }
371 
372  // Add the parallel threshold to all the omp for pragmas
374 
375  /* Put the new CODE ressource into PIPS: */
376  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, mod_stmt);
377  // There is no longer a current module:
380 
381  pips_debug(2, "done for %s\n", module_name);
382  debug_off();
383 
384  return true;
385 }
void set_prettyprint_language_from_property(enum language_utype native)
set the prettyprint language according to the property PRETTYPRINT_LANGUAGE @description If the prope...
Definition: language.c:103
static void add_loop_parallel_threshold(pragma pr)
add a if condition to the omp pragma
#define value_code_p(x)
Definition: ri.h:3065
#define pragma_domain
newgen_persistant_statement_to_statement_domain_defined
Definition: ri.h:290
#define value_code(x)
Definition: ri.h:3067
#define code_language(x)
Definition: ri.h:792
#define language_tag(x)
Definition: ri.h:1590
@ is_language_fortran
Definition: ri.h:1566

References add_loop_parallel_threshold(), code_language, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, entity_initial, gen_recurse, gen_true(), is_language_fortran, language_tag, module_name(), module_name_to_entity(), pips_debug, pragma_domain, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), set_prettyprint_language_from_property(), statement_undefined, value_code, and value_code_p.

+ Here is the call graph for this function:

◆ omp_merge_pragma()

bool omp_merge_pragma ( const char *  module_name)

merge the pragma on the outer loop

Should never arise

Parameters
module_nameodule_name

Definition at line 297 of file manage_pragma.c.

297  {
298  // Use this module name and this environment variable to set
300  "OPMIFY_CODE_DEBUG_LEVEL");
301 
302  /* // generate pragma string or expression using the correct language: */
304  if(value_code_p(mv)) {
305  code c = value_code(mv);
307  } else {
308  /* Should never arise */
310  }
311 
312  // getting the properties to configure the phase
313  const char* merge_policy = get_string_property("OMP_MERGE_POLICY");
314  bool outer = (strcmp(merge_policy, "outer") == 0);
315 
316  // The list of outer loop as a list of statements
317  list l_outer = NIL;
318 
319  // build the list of outer loop with pragma this is also needed by the
320  // inner mode
321  gen_context_recurse(mod_stmt, &l_outer,
323 
324  if(outer == true) {
325  pips_debug(3, "outer mode\n");
326  // merge the pragma on the outer loop
327  merge_on_outer(l_outer);
328  } else { //inner
329  pips_debug(3, "inner mode\n");
330  // The inner flag
331  bool inner_flag = true;
332  FOREACH(statement, stmt, l_outer)
333  {
335  &inner_flag,
336  loop_domain,
337  inner_filter,
338  inner_rewrite);
339  }
340  }
341 
342  // freeing memory
343  gen_free_list(l_outer);
344 
345  //Put back the new statement module
346  PIPS_PHASE_POSTLUDE(mod_stmt);
347 
348  return true;
349 }
#define PIPS_PHASE_POSTLUDE(new_module_statement)
End a transformation phase by putting back into PIPS the (possibly) modified statement.
#define PIPS_PHASE_PRELUDE(module_name, debug_env_var)
Start a phase that use a module CODE.
static void inner_rewrite(loop l, bool *inner_flag)
static void merge_on_outer(list l_outer)
merge the omp pragma on the most outer parallel loop
static bool inner_filter(loop l, bool *inner_flag)
static bool build_outer(loop l, list *l_outer)

References build_outer(), code_language, entity_initial, FOREACH, gen_context_recurse, gen_free_list(), gen_null2(), get_string_property(), inner_filter(), inner_rewrite(), is_language_fortran, language_tag, loop_domain, merge_on_outer(), module_name(), module_name_to_entity(), NIL, pips_debug, PIPS_PHASE_POSTLUDE, PIPS_PHASE_PRELUDE, set_prettyprint_language_from_property(), value_code, and value_code_p.

+ Here is the call graph for this function:

◆ ompify_code()

bool ompify_code ( const char *  )

◆ outline()

bool outline ( const string  module_name)

entry point for outline module outlining will be performed using either comment recognition or interactively

Parameters
module_namename of the module containing the statements to outline

prelude

retrieve name of the outlined module

retrieve statement to outline

apply outlining

validate

ostlude

Parameters
module_nameodule_name

Definition at line 1385 of file outlining.c.

1386 {
1387  /* prelude */
1392 
1393  debug_on("OUTLINE_DEBUG_LEVEL");
1394 
1395  /* retrieve name of the outlined module */
1396  const char* outline_module_name = get_string_property_or_ask("OUTLINE_MODULE_NAME","outline module name ?\n");
1397 
1398  // Check the language. In case of Fortran the module name must be in
1399  // capital letters.
1400  char * omn=strdup(outline_module_name);
1402  omn=strupper(omn,omn);
1403 
1404  /* retrieve statement to outline */
1405  list statements_to_outline = find_statements_with_pragma(get_current_module_statement(),get_string_property("OUTLINE_PRAGMA")) ;
1406  if(ENDP(statements_to_outline)) {
1407  const char* label_name = get_string_property("OUTLINE_LABEL");
1408  if( empty_string_p(label_name) ) {
1410  }
1411  else {
1414  pips_user_error("Could not find loop labeled %s\n",label_name);
1415  if(statement_loop_p(statement_to_outline) && get_bool_property("OUTLINE_LOOP_STATEMENT"))
1417  statements_to_outline=make_statement_list(statement_to_outline);
1418  }
1419  }
1420 
1421  /* apply outlining */
1422  (void)outliner(omn,statements_to_outline);
1423  free(omn);
1424 
1425 
1426  debug_off();
1427 
1428  /* validate */
1433 
1434  /*postlude*/
1436  reset_rw_effects();
1439 
1440  return true;
1441 }
string strupper(string, const char *)
Definition: string.c:213
statement outliner(const char *outline_module_name, list statements_to_outline)
outline the statements in statements_to_outline into a module named outline_module_name the outlined ...
Definition: outlining.c:1327
list find_statements_interactively(statement)
prompt the user to select contiguous statement in s
Definition: statement.c:258
#define make_statement_list(stats...)
easy list constructor
list statement_to_outline
scalopragma.c
Definition: scalopragma.c:25

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, empty_string_p(), ENDP, find_statement_from_label_name(), find_statements_interactively(), find_statements_with_pragma(), fortran_module_p(), free(), get_bool_property(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), get_string_property(), get_string_property_or_ask(), loop_body, make_statement_list, module_name(), module_name_to_entity(), module_reorder(), outliner(), pips_user_error, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_rw_effects(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_rw_effects(), statement_loop(), statement_loop_p(), statement_to_outline, statement_undefined_p, strdup(), and strupper().

+ Here is the call graph for this function:

◆ outline_stmts_between_pragmas_in_sequence()

bool outline_stmts_between_pragmas_in_sequence ( sequence  s,
void *  _ctx 
)
Parameters
_ctxctx

Definition at line 454 of file manage_pragma.c.

454  {
455  // Cast of the void pointer
456  context *ctx = (context *) _ctx;
457  // Are we in a SCoP of the code ?
458  bool in_scop = false;
459  // A list of the statements contained in the sequence
460  list stmts = sequence_statements(s);
461  list stmts_to_outline = NIL;
462 
463  FOREACH(statement, stmt, stmts) {
464  // Flag that check if we are at the end of a list of stmts to outline
465  bool has_to_outline_p = false;
466  // If we are not already in a SCoP of the code and if the statement is preceded
467  // by pragma_start
468  // Else if we are already in a SCoP of the code and if the statement is followed
469  //by pragma_end
471  in_scop = true;
473  } else if(in_scop
475  in_scop = false;
476  has_to_outline_p = true;
478  }
479  // If we are in a SCoP : create an one-element statement list (cons) containing stmt
480  if(in_scop) {
481  stmts_to_outline = CONS(STATEMENT, stmt, stmts_to_outline );
482  }
483  // ENDP : true if list is empty, false if is a cons
484  if(has_to_outline_p && !ENDP(stmts_to_outline)) {
485  // Reverse the order of the list
486  stmts_to_outline = gen_nreverse(stmts_to_outline);
487  string func_name = build_new_top_level_module_name(ctx->prefix, false);
488  // Here we call the outliner on the collected statements
489  outliner(func_name, stmts_to_outline);
490  // Free the list of statement so that we can continue to build one
491  gen_free_list(stmts_to_outline);
492  stmts_to_outline = NIL;
493 
494  // Mark that a substitution have been done
495  ctx->outline_done = true;
496  }
497  }
498  if(in_scop) {
499  pips_user_warning("End of a sequence with a sentinel starting SCoP pragma "
500  "(%s) but did not encountered any pragma end (%s)\n",
501  ctx->pragma_begin, ctx->pragma_end);
502  }
503  return true;
504 }
statement outliner(const char *, list)
outline the statements in statements_to_outline into a module named outline_module_name the outlined ...
Definition: outlining.c:1327
#define statement_has_this_pragma_string_p(stmt, str)
string build_new_top_level_module_name(const char *prefix, bool prevent_suffix)
Get a new name for a module built from a prefix.
Definition: module.c:55
string prefix
string pragma_end
string pragma_begin
bool outline_done

References build_new_top_level_module_name(), clear_pragma_on_statement(), CONS, ENDP, FOREACH, gen_free_list(), gen_nreverse(), NIL, context::outline_done, outliner(), pips_user_warning, context::pragma_begin, context::pragma_end, context::prefix, sequence_statements, STATEMENT, and statement_has_this_pragma_string_p.

Referenced by pragma_outliner().

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

◆ outliner()

statement outliner ( const char *  outline_module_name,
list  statements_to_outline 
)

outline the statements in statements_to_outline into a module named outline_module_name the outlined statements are replaced by a call to the newly generated module statements_to_outline is modified in place to represent that call

Parameters
outline_module_namename of the new module
statements_to_outlineis a list of consecutive statements to outline into outline_module_name
Returns
pointer to the newly generated statement (already inserted in statements_to_outline)

1 : init

pass loop bounds as parameters if required

2 : scan

3 : parameters

4 : patch parameters

5 : file

6 : call

7: remove obsolete entities, this is needed otherwise the IR keeps some obsolete data

Parameters
outline_module_nameutline_module_name
statements_to_outlinetatements_to_outline

Definition at line 1327 of file outlining.c.

1328 {
1329  pips_assert("there are some statements to outline",!ENDP(statements_to_outline));
1331 
1332  statement new_body = make_block_statement(statements_to_outline);
1333 
1334  /* 1 : init */
1335  hash_table entity_to_effective_parameter = outliner_init(new_fun, statements_to_outline);
1336 
1337  /* pass loop bounds as parameters if required */
1338  const char* loop_label = get_string_property("OUTLINE_LOOP_BOUND_AS_PARAMETER");
1340  if(!statement_undefined_p(theloop) && statement_loop(theloop))
1341  outliner_extract_loop_bound(theloop,entity_to_effective_parameter);
1342 
1343  /* 2 : scan */
1344  list referenced_entities = outliner_scan(new_fun, statements_to_outline, new_body);
1345 
1346  /* 3 : parameters */
1347  list effective_parameters = NIL;
1348  list formal_parameters = NIL;
1349  outliner_parameters(new_fun, new_body, referenced_entities, entity_to_effective_parameter, &effective_parameters, &formal_parameters);
1350 
1351  /* 4 : patch parameters */
1353  && get_bool_property("OUTLINE_WRITTEN_SCALAR_BY_REFERENCE"))
1354  outliner_patch_parameters(statements_to_outline, referenced_entities, effective_parameters, formal_parameters, new_body, new_body, new_body);
1355 
1356  /* 5 : file */
1357  outliner_file(new_fun, formal_parameters, &new_body );
1358 
1359  /* 6 : call */
1360  statement new_stmt = outliner_call(new_fun, statements_to_outline, effective_parameters);
1361 
1362  /* 7: remove obsolete entities, this is needed otherwise the IR keeps some obsolete data */
1363  list declared_entities = statements_to_declarations(statements_to_outline);
1364  FOREACH(ENTITY,de,declared_entities) {
1365  FOREACH(STATEMENT, sde, statements_to_outline) {
1366  gen_context_multi_recurse(sde, de,
1369  NULL);
1371  free_entity(de);
1372  }
1373  }
1374  gen_free_list(declared_entities);
1375  return new_stmt;
1376 }
void free_entity(entity p)
Definition: ri.c:2524
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
list statements_to_declarations(list)
Returns the declarations contained in a list of statement.
Definition: statement.c:3265
void outliner_patch_parameters(list statements_to_outline, list referenced_entities, list effective_parameters, list formal_parameters, statement new_body, statement begin, statement end)
we need to patch parameters , effective parameters and body in C because parameters are passed by cop...
Definition: outlining.c:809
static void do_remove_entity_from_decl(statement s, entity e)
Definition: outlining.c:918
hash_table outliner_init(entity new_fun, list statements_to_outline)
Definition: outlining.c:546
static void outliner_extract_loop_bound(statement sloop, hash_table entity_to_effective_parameter)
Definition: outlining.c:453
list outliner_scan(entity new_fun, list statements_to_outline, statement new_body)
Definition: outlining.c:555
statement outliner_call(entity new_fun, list statements_to_outline, list effective_parameters)
Definition: outlining.c:1235
void outliner_file(entity new_fun, list formal_parameters, statement *new_body)
Definition: outlining.c:1138
void outliner_parameters(entity new_fun, statement new_body, list referenced_entities, hash_table entity_to_effective_parameter, list *effective_parameters_, list *formal_parameters_)
Definition: outlining.c:698
static void do_remove_entity_from_private(loop l, entity e)
Definition: outlining.c:914
#define loop_label(x)
Definition: ri.h:1646

References c_module_p(), copy_language(), do_remove_entity_from_decl(), do_remove_entity_from_private(), ENDP, ENTITY, entity_declarations, find_statement_from_label_name(), FOREACH, free_entity(), gen_context_multi_recurse(), gen_free_list(), gen_remove(), gen_true(), get_bool_property(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), get_string_property(), loop_domain, loop_label, make_block_statement(), make_empty_subroutine(), module_language, NIL, outliner_call(), outliner_extract_loop_bound(), outliner_file(), outliner_init(), outliner_parameters(), outliner_patch_parameters(), outliner_scan(), pips_assert, STATEMENT, statement_domain, statement_loop(), statement_undefined_p, and statements_to_declarations().

Referenced by do_kernelize(), gpu_ify_statement(), gpu_memory_apply(), outline(), outline_stmts_between_pragmas_in_sequence(), scalopragma(), and taskify_statement().

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

◆ outliner_call()

statement outliner_call ( entity  new_fun,
list  statements_to_outline,
list  effective_parameters 
)

and return the replacement statement

perform substitution : replace the original statements by a single call and patch the remaining statement (yes it's ugly)

trash any extensions|comments, they may not be valid now

Parameters
new_funew_fun
statements_to_outlinetatements_to_outline
effective_parametersffective_parameters

Definition at line 1235 of file outlining.c.

1236 {
1237 
1238  /* and return the replacement statement */
1239  instruction new_inst = make_instruction_call(make_call(new_fun,effective_parameters));
1240  statement new_stmt = statement_undefined;
1241 
1242  /* perform substitution :
1243  * replace the original statements by a single call
1244  * and patch the remaining statement (yes it's ugly)
1245  */
1246  FOREACH(STATEMENT,old_statement,statements_to_outline)
1247  {
1248  //free_instruction(statement_instruction(old_statement));
1249  if(statement_undefined_p(new_stmt))
1250  {
1251  statement_instruction(old_statement)=new_inst;
1252  new_stmt=old_statement;
1253  }
1254  else
1256  gen_free_list(statement_declarations(old_statement));
1257  statement_declarations(old_statement)=NIL;
1258  /* trash any extensions|comments, they may not be valid now */
1259  free_extensions(statement_extensions(old_statement));
1260  statement_extensions(old_statement)=empty_extensions();
1261  if(!string_undefined_p(statement_comments(old_statement))) free(statement_comments(old_statement));
1262  statement_comments(old_statement)=empty_comments;
1263 
1264  }
1265  return new_stmt;
1266 }
instruction make_instruction_call(call _field_)
Definition: ri.c:1184
#define string_undefined_p(s)
Definition: newgen_types.h:41
#define empty_comments
Empty comments (i.e.
#define statement_comments(x)
Definition: ri.h:2456

References empty_comments, empty_extensions(), FOREACH, free(), free_extensions(), gen_free_list(), make_call(), make_continue_instruction(), make_instruction_call(), NIL, STATEMENT, statement_comments, statement_declarations, statement_extensions, statement_instruction, statement_undefined, statement_undefined_p, and string_undefined_p.

Referenced by compile_mpi(), and outliner().

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

◆ outliner_file()

void outliner_file ( entity  new_fun,
list  formal_parameters,
statement new_body 
)

prepare parameters and body

5-0 : create new compilation unit

5-1 : add all callees to the same foreign compilation units

5-2: fix the types of the formal parameter in case a new compilation unit is used. Make sure that the function type and the types of the formal parameters are consistent. The function type is correct because the compilation unit has just been parsed.

add a return at the end of the body, in all cases

we can now begin the outlining

et_current_module_entity()

horrible hack to prevent declaration duplication signed : Serge Guelton

we need to free them now, otherwise recompilation fails

Parameters
new_funew_fun
formal_parametersormal_parameters
new_bodyew_body

Definition at line 1138 of file outlining.c.

1139 {
1140  string outline_module_name = (string)entity_user_name(new_fun);
1141 
1142  /* prepare parameters and body*/
1143  module_functional_parameters(new_fun)=formal_parameters;
1144  FOREACH(PARAMETER,p,formal_parameters) {
1148  }
1149 
1150  /* 5-0 : create new compilation unit */
1151  outliner_compilation_unit(new_fun, formal_parameters);
1152 
1155 
1156  /* 5-1 : add all callees to the same foreign compilation units */
1157  outliner_independent(outline_module_name, *new_body);
1158 
1159  /* 5-2: fix the types of the formal parameter in case a new
1160  compilation unit is used. Make sure that the function type and
1161  the types of the formal parameters are consistent. The function
1162  type is correct because the compilation unit has just been
1163  parsed. */
1164  if(false) {
1165  functional ft = type_functional(entity_type(new_fun));
1166  list fpl = functional_parameters(ft);
1167  int i, nparams = gen_length(fpl);
1168 
1169  for (i = 1; i <= nparams; i++) {
1170  entity param = find_ith_parameter(new_fun, i);
1171  type formal_pt = entity_type(param);
1172  type functional_pt = parameter_type(PARAMETER(CAR(fpl)));
1173  if(!type_equal_p(formal_pt, functional_pt)) {
1174  entity_type(param) = copy_type(functional_pt);
1175  }
1176  fpl = CDR(fpl);
1177  }
1178  }
1179 
1180  // In fortran we always want to generate the outline function
1181  // in its own new file
1182  char * cun = string_undefined;
1184  ;
1185  } else if(get_bool_property("OUTLINE_INDEPENDENT_COMPILATION_UNIT")) {
1186  // Declare in current module so that it's not undefined at call site
1187  char * the_cu = NULL,*iter;
1188  if((iter=strchr(outline_module_name,FILE_SEP))) {
1189  the_cu = strndup(outline_module_name,iter-outline_module_name);
1190  }
1191  else the_cu = strdup(outline_module_name);
1192  asprintf(&cun,"%s" FILE_SEP_STRING, the_cu);
1193  free(the_cu);
1194  }
1195  else {
1197  }
1198  /* add a return at the end of the body, in all cases */
1199  insert_statement(*new_body, make_return_statement(new_fun), false);
1200 
1201  /* we can now begin the outlining */
1202  bool saved_order = get_bool_property(STAT_ORDER),
1203  saved_block = get_bool_property("PRETTYPRINT_BLOCKS");
1205  set_bool_property("PRETTYPRINT_BLOCKS",false);
1206  text t = text_named_module(new_fun, new_fun /*get_current_module_entity()*/, *new_body);
1207 
1208 
1210  if(!string_undefined_p(cun)) free(cun);
1211  free_text(t);
1212 
1213  set_bool_property(STAT_ORDER,saved_order);
1214  set_bool_property("PRETTYPRINT_BLOCKS",saved_block);
1215 
1216 
1217 
1218  /* horrible hack to prevent declaration duplication
1219  * signed : Serge Guelton
1220  */
1222  code_declarations(EntityCode(new_fun))=NIL;
1223 
1224  /* we need to free them now, otherwise recompilation fails */
1225  FOREACH(PARAMETER,p,formal_parameters) {
1227  if(!type_undefined_p(entity_type(e)) &&
1228  entity_variable_p(e)) {
1229  free_type(entity_type(e));
1231  }
1232  }
1233 }
type copy_type(type p)
TYPE.
Definition: ri.c:2655
void free_type(type p)
Definition: ri.c:2658
void free_text(text p)
Definition: text.c:74
size_t gen_length(const list l)
Definition: list.c:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
statement make_return_statement(entity)
Definition: statement.c:779
bool add_new_module_from_text(const char *module_name, text code_text, bool is_fortran, const char *compilation_unit_name)
Add the new resource files associated to a module with its more-or-less correct code.
Definition: initializer.c:431
#define FILE_SEP_STRING
Definition: naming-local.h:41
#define FILE_SEP
Definition: naming-local.h:39
#define string_undefined
Definition: newgen_types.h:40
char * string
STRING.
Definition: newgen_types.h:39
static void outliner_independent(const char *module_name, statement body)
redeclare all callees of outlined function in the same compilation unit
Definition: outlining.c:1065
static void outliner_compilation_unit(entity new_fun, list formal_parameters __attribute__((unused)))
Definition: outlining.c:922
#define STAT_ORDER
Definition: outlining.c:75
text text_named_module(entity, entity, statement)
void set_bool_property(const char *, bool)
code EntityCode(entity e)
this function checks that e has an initial value code.
Definition: entity.c:301
bool type_equal_p(type, type)
Definition: type.c:547
entity find_ith_parameter(entity, int)
Definition: util.c:93
#define type_functional(x)
Definition: ri.h:2952
#define code_declarations(x)
Definition: ri.h:784
#define type_undefined_p(x)
Definition: ri.h:2884
#define functional_parameters(x)
Definition: ri.h:1442
#define type_undefined
Definition: ri.h:2883
char * strndup(char const *s, size_t n)
A replacement function, for systems that lack strndup.
Definition: strndup.c:26

References add_new_module_from_text(), AddEntityToModuleCompilationUnit(), asprintf, c_module_p(), CAR, CDR, code_declarations, compilation_unit_of_module(), CONS, copy_type(), dummy_identifier, ENTITY, entity_initial, entity_type, entity_user_name(), entity_variable_p, EntityCode(), FILE_SEP, FILE_SEP_STRING, find_ith_parameter(), FOREACH, fortran_module_p(), free(), free_text(), free_type(), functional_parameters, gen_free_list(), gen_length(), gen_nconc(), get_bool_property(), get_current_module_entity(), get_current_module_name(), insert_statement(), make_return_statement(), module_functional_parameters, NIL, outliner_compilation_unit(), outliner_independent(), PARAMETER, parameter_dummy, parameter_type, set_bool_property(), STAT_ORDER, strdup(), string_undefined, string_undefined_p, strndup(), text_named_module(), type_equal_p(), type_functional, type_undefined, type_undefined_p, and value_code.

Referenced by compile_mpi(), and outliner().

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

◆ outliner_init()

hash_table outliner_init ( entity  new_fun,
list  statements_to_outline 
)

try to be smart concerning array references

Parameters
new_funew_fun
statements_to_outlinetatements_to_outline

Definition at line 546 of file outlining.c.

547 {
548  /* try to be smart concerning array references */
549  if(get_bool_property("OUTLINE_SMART_REFERENCE_COMPUTATION"))
550  return outliner_smart_references_computation(statements_to_outline, new_fun);
551  else
552  return hash_table_make(hash_pointer,1);
553 }
static hash_table outliner_smart_references_computation(list outlined_statements, entity new_module)
purge the list of referenced entities by replacing calls to a[i][j] where i is a constant in statemen...
Definition: outlining.c:291

References get_bool_property(), hash_pointer, hash_table_make(), and outliner_smart_references_computation().

Referenced by compile_mpi(), and outliner().

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

◆ outliner_parameters()

void outliner_parameters ( entity  new_fun,
statement  new_body,
list  referenced_entities,
hash_table  entity_to_effective_parameter,
list effective_parameters_,
list formal_parameters_ 
)

all variables are promoted parameters

this create the dummy parameter

FI: when a new compilation unit is used, why declare type in the initial compilation unit? It generates derived types within the wrong compilation unit... and back fires in the prettyprinter

this adds the effective parameter

this is a constant variable or fortran function result

Parameters
new_funew_fun
new_bodyew_body
referenced_entitieseferenced_entities
entity_to_effective_parameterntity_to_effective_parameter
effective_parameters_ffective_parameters_
formal_parameters_ormal_parameters_

Definition at line 698 of file outlining.c.

701 {
702  string outline_module_name = (string)entity_user_name(new_fun);
703 
704 
705  /* all variables are promoted parameters */
706  list effective_parameters = *effective_parameters_;
707  list formal_parameters = *formal_parameters_;
708  intptr_t i=0;
709 
710  // Addition for R-Stream compatibility
711  // Prevent from adding a parameter if the entity is in the list
712  list induction_var = NIL;
713  // If no property activated then induction_var should stay to NIL
714  bool is_rstream = get_bool_property("OUTLINE_REMOVE_VARIABLE_RSTREAM_IMAGE") || get_bool_property("OUTLINE_REMOVE_VARIABLE_RSTREAM_SCOP");
715  if (is_rstream) {
716  // Enclosing loops map needed for get_variables_to_remove
718  get_variables_to_remove(referenced_entities, new_body, &induction_var);
720  // Adding the declarations to the new body
721  add_induction_var_to_local_declarations(&new_body, induction_var);
722  }
723 
724  FOREACH(ENTITY,e,referenced_entities)
725  {
726  if( (entity_variable_p(e) || entity_symbolic_p(e)) && (!is_entity_in_list(e, induction_var)))
727  {
728  pips_debug(6,"Add %s to outlined function parameters\n",entity_name(e));
729 
730  /* this create the dummy parameter */
731  entity dummy_entity = FindOrCreateEntity(
732  outline_module_name,
734  );
735  entity_initial(dummy_entity)=make_value_unknown();
736 
737  if(entity_symbolic_p(e))
738  entity_type(dummy_entity) = fortran_module_p(new_fun)?
741  else {
743  /* FI: when a new compilation unit is used, why
744  declare type in the *initial* compilation unit?
745  It generates derived types within the wrong
746  compilation unit... and back fires in the prettyprinter */
748  entity_type(dummy_entity)=copy_type(entity_type(e));
749  }
750 
751 
752  entity_storage(dummy_entity)=make_storage_formal(make_formal(dummy_entity,++i));
753 
754 
755  formal_parameters=CONS(PARAMETER,make_parameter(
756  copy_type(entity_type(dummy_entity)),
758  make_dummy_identifier(dummy_entity)),formal_parameters);
759 
760  /* this adds the effective parameter */
761  expression effective_parameter = (expression)hash_get(entity_to_effective_parameter,e);
762  if(effective_parameter == HASH_UNDEFINED_VALUE)
763  effective_parameter = entity_to_expression(e);
764 
765  effective_parameters=CONS(EXPRESSION,effective_parameter,effective_parameters);
766  }
767  /* this is a constant variable or fortran function result */
768  else if(entity_constant_p(e)||(fortran_module_p(new_fun) && entity_function_p(e))) {
769  AddLocalEntityToDeclarations(e,new_fun,new_body);
770  }
771 
772  }
773  *formal_parameters_= gen_nreverse(formal_parameters);
774  *effective_parameters_= gen_nreverse(effective_parameters);
775  hash_table_free(entity_to_effective_parameter);
776  gen_free_list(induction_var);
777  ifdebug(5) {
778  pips_debug(5,"Formals : \n");
779  print_parameters(*formal_parameters_);
780  pips_debug(5,"Effectives : \n");
781  print_expressions(*effective_parameters_);
782  }
783 }
dummy make_dummy_identifier(entity _field_)
Definition: ri.c:620
value make_value_unknown(void)
Definition: ri.c:2847
parameter make_parameter(type a1, mode a2, dummy a3)
Definition: ri.c:1495
mode make_mode_reference(void)
Definition: ri.c:1356
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
storage make_storage_formal(formal _field_)
Definition: ri.c:2282
mode make_mode_value(void)
Definition: ri.c:1353
formal make_formal(entity a1, intptr_t a2)
Definition: ri.c:1067
void get_variables_to_remove(list, statement, list *)
misc.c
Definition: misc.c:58
struct _newgen_struct_expression_ * expression
Definition: alias_private.h:21
void clean_enclosing_loops(void)
Definition: loop.c:58
statement_mapping loops_mapping_of_statement(statement stat)
Definition: loop.c:155
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 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
void add_induction_var_to_local_declarations(statement *new_body, list induction_var)
Definition: outlining.c:1307
static type type_to_named_type(type t, entity cu)
create a new type from given type, eventually renaming unnamed structures inside all new entities gen...
Definition: outlining.c:631
bool is_entity_in_list(entity e, list l)
Checks if an entity is in a list.
Definition: outlining.c:688
void print_parameters(list lp)
Display a parameter on stderr, useful for debugging.
Definition: parameter.c:63
void print_expressions(list le)
Definition: expression.c:98
#define DEFAULT_INTEGER_TYPE_SIZE
#define entity_symbolic_p(e)
#define entity_constant_p(e)
entity FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
Definition: entity.c:1586
bool entity_function_p(entity e)
Definition: entity.c:724
void AddLocalEntityToDeclarations(entity, entity, statement)
Add the variable entity e to the list of variables of the function module.
Definition: variable.c:233
void set_enclosing_loops_map(statement_mapping)
#define functional_result(x)
Definition: ri.h:1444
entity module_entity_to_compilation_unit_entity(entity m)
Retrieve the compilation unit containing a module definition.
Definition: module.c:116

References add_induction_var_to_local_declarations(), AddLocalEntityToDeclarations(), clean_enclosing_loops(), CONS, copy_type(), DEFAULT_INTEGER_TYPE_SIZE, ENTITY, entity_constant_p, entity_function_p(), entity_initial, entity_name, entity_storage, entity_symbolic_p, entity_to_expression(), entity_type, entity_user_name(), entity_variable_p, EXPRESSION, FindOrCreateEntity(), FOREACH, fortran_module_p(), functional_result, gen_free_list(), gen_nreverse(), get_bool_property(), get_current_module_entity(), get_variables_to_remove(), hash_get(), hash_table_free(), HASH_UNDEFINED_VALUE, ifdebug, intptr_t, is_entity_in_list(), loops_mapping_of_statement(), make_basic_int(), make_dummy_identifier(), make_formal(), make_mode_reference(), make_mode_value(), make_parameter(), make_storage_formal(), make_type_variable(), make_value_unknown(), make_variable(), module_entity_to_compilation_unit_entity(), NIL, PARAMETER, pips_debug, print_expressions(), print_parameters(), set_enclosing_loops_map(), type_functional, and type_to_named_type().

Referenced by compile_mpi(), and outliner().

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

◆ outliner_patch_parameters()

void outliner_patch_parameters ( list  statements_to_outline,
list  referenced_entities,
list  effective_parameters,
list  formal_parameters,
statement  new_body,
statement  begin,
statement  end 
)

we need to patch parameters , effective parameters and body in C because parameters are passed by copy in function call it's not needed if

  • the parameter is only read (FI: or if it is written before it is read?)
  • it's an array / pointer

Here a scalar will be passed by address and a prelude/postlude will be used in the outlined module as below :

void new_module( int *scalar_0 ) { int scalar; scalar = *scalar_0; ... // Work on scalar ... *scalar_0 = scalar; }

Note FI: this is also useless when the variable does not appear in the out region of the outlined piece of code. However, the out effets and out regions are not available for every piece of code.

e is no longer a formal parameter, but a local variable

storage eos = entity_storage(e); // e's old storage

pips_assert("eos is a formal storage", storage_formal_p(eos));

formal fs = storage_formal(eos);

entity f = formal_function(fs); // In fact, f is not a function but a variable!

entity a = module_to_dynamic_area(f);

ram r = make_ram(f, a, UNKNOWN_RAM_OFFSET, NIL);

storage ens = make_storage_ram(r);

entity_storage(e) = ens;

free_storage(eos);

Parameters
statements_to_outlinetatements_to_outline
referenced_entitieseferenced_entities
effective_parametersffective_parameters
formal_parametersormal_parameters
new_bodyew_body
beginegin
endnd

Definition at line 809 of file outlining.c.

811 {
812  list iter = effective_parameters;
813  list riter = referenced_entities;
814 
815  FOREACH(PARAMETER,p,formal_parameters)
816  {
817  expression x = EXPRESSION(CAR(iter));
818  entity re = ENTITY(CAR(riter));
822 
826  bool entity_written=false;
827  FOREACH(STATEMENT,stmt,statements_to_outline) {
828  bool write_p = find_write_effect_on_entity(stmt,ex);
829  ifdebug(5) {
830  if(write_p) {
831  pips_debug(5,"Entity %s written by statement (%d) : \n",entity_name(ex),the_current_debug_level);
833  }
834  }
835  entity_written|=write_p;
836  }
837 
838  if( (!basic_pointer_p(variable_basic(v))) &&
840  entity_written
841  )
842  {
846  CONS(DIMENSION,
849  NIL),
850  NIL)
851  );
852 
855 
856  //Change at call site (scalar=>&scalar)
857  syntax s = expression_syntax(x); // FIXME Leak ?
860 
861 
862  //Create prelude && postlude
864 
865  // FIXME : is it ok to alias dereferenced expression in 2 statements ?
868 
869  // Cheat on effects
872 
873 
874  insert_statement(begin,in,true);
875  insert_statement(end,out,false);
876 
877  /* e is no longer a formal parameter, but a local variable */
878  pips_debug(4,"Add declaration for %s",entity_name(e));
879 
880  /* storage eos = entity_storage(e); // e's old storage */
881  /* pips_assert("eos is a formal storage", storage_formal_p(eos)); */
882  /* formal fs = storage_formal(eos); */
883  /* entity f = formal_function(fs); // In fact, f is *not* a function but a variable! */
884  /* // No dependent type assumed, should be a scalar type */
885  /* // since a pointer had to be introduced */
886  /* entity a = module_to_dynamic_area(f); */
887  /* ram r = make_ram(f, a, UNKNOWN_RAM_OFFSET, NIL); */
888  /* storage ens = make_storage_ram(r); */
889  /* // add_C_variable_to_area() to fix the offset? */
890  /* entity_storage(e) = ens; */
891  /* free_storage(eos); */
892 
893  // We could add a push_generated_variable_commenter()
894  // to explain the generation
896  add_declaration_statement(new_body,e);
898  }
899  }
900  if(type_variable_p(entity_type(re))) {
904  convert_pointer_to_array(e,re,x,statements_to_outline);
905 
906  }
907  }
908  POP(iter);
909  POP(riter);
910  }
911  pips_assert("no effective parameter left", ENDP(iter));
912 }
syntax make_syntax_call(call _field_)
Definition: ri.c:2500
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
static FILE * out
Definition: alias_check.c:128
void store_cumulated_rw_effects_list(statement, list)
statement make_assign_statement(expression, expression)
Definition: statement.c:583
char end
Definition: gtk_status.c:82
int the_current_debug_level
Debugging functions.
Definition: debug.c:53
static void convert_pointer_to_array(entity e, entity re, expression x, list statements)
Definition: outlining.c:494
static string outlining_patched_variable_commenter(__attribute__((unused)) entity e)
Definition: outlining.c:70
#define X
Definition: r1.c:42
entity make_entity_copy_with_new_name(entity e, string global_new_name, bool move_initialization_p)
Create a copy of an entity, with (almost) identical type, storage and initial value if move_initializ...
Definition: entity.c:2463
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
bool array_type_p(type)
Definition: type.c:2942
#define entity_undefined
Definition: ri.h:2761
#define expression_syntax(x)
Definition: ri.h:1247
#define type_variable_p(x)
Definition: ri.h:2947
static char * x
Definition: split_file.c:159

References add_C_variable_to_area(), add_declaration_statement(), ADDRESS_OF_OPERATOR_NAME, array_type_p(), basic_pointer, basic_pointer_p, CAR, CONS, convert_pointer_to_array(), copy_type(), DEREFERENCING_OPERATOR_NAME, DIMENSION, dummy_identifier, end, ENDP, ENTITY, entity_intrinsic(), entity_name, entity_to_expression(), entity_type, entity_undefined, entity_undefined_p, EXPRESSION, expression_reference(), expression_reference_p(), expression_syntax, find_write_effect_on_entity(), FOREACH, gen_append(), ifdebug, insert_statement(), int_to_expression(), make_assign_statement(), make_call(), make_dimension(), make_entity_copy_with_new_name(), make_expression(), make_syntax_call(), MakeUnaryCall(), NIL, normalized_undefined, offset, out, outlining_patched_variable_commenter(), PARAMETER, parameter_dummy, parameter_type, pips_assert, pips_debug, POP, pop_generated_variable_commenter(), print_statement(), push_generated_variable_commenter(), reference_variable, STATEMENT, store_cumulated_rw_effects_list(), the_current_debug_level, type_variable, type_variable_p, variable_basic, variable_dimensions, X, and x.

Referenced by compile_mpi(), and outliner().

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

◆ outliner_scan()

list outliner_scan ( entity  new_fun,
list  statements_to_outline,
statement  new_body 
)

Retrieve referenced entities

Retrieve declared entities

get the relative complements and create the parameter list

purge the functions from the parameter list, we assume they are declared externally also purge the formal parameters from other modules, gathered by get_referenced_entities but wrong here

function should be added to compilation unit

fortran function results must be declared in the new function

remove global variables if needed

sort list, and put parameters first

in some rare case, we can have too functions with the same local name

Parameters
new_funew_fun
statements_to_outlinetatements_to_outline
new_bodyew_body

Definition at line 555 of file outlining.c.

556 {
557  /* Retrieve referenced entities */
558  list referenced_entities = outliner_statements_referenced_entities(statements_to_outline);
559 
560  ifdebug(5) {
561  pips_debug(5,"Referenced entities :\n");
562  print_entities(referenced_entities);
563  }
564 
565  /* Retrieve declared entities */
567  list localized = statements_localize_declarations(statements_to_outline,new_fun,new_body);
569  list declared_entities = statements_to_declarations(statements_to_outline);
570  FOREACH(ENTITY,e,declared_entities)
572  declared_entities=gen_nconc(declared_entities,localized);
573 
574  /* get the relative complements and create the parameter list*/
575  gen_list_and_not(&referenced_entities,declared_entities);
576  gen_free_list(declared_entities);
577 
578 
579  /* purge the functions from the parameter list, we assume they are declared externally
580  * also purge the formal parameters from other modules, gathered by get_referenced_entities but wrong here
581  */
582  list tmp = gen_copy_seq(referenced_entities);
583  FOREACH(ENTITY,e,referenced_entities)
584  {
585  //basic b = entity_basic(e);
586  /* function should be added to compilation unit */
587  if(entity_function_p(e))
588  {
589  ;//AddEntityToModuleCompilationUnit(e,get_current_module_entity());
590  if(!fortran_module_p(new_fun)) /* fortran function results must be declared in the new function */
591  gen_remove_once(&referenced_entities,e);
592  }
593  }
594  gen_free_list(tmp);
595 
596 
597 
598  /* remove global variables if needed */
599  if(get_bool_property("OUTLINE_ALLOW_GLOBALS"))
600  {
602  entity cu = module_name_to_entity(cu_name);
603  list cu_decls = entity_declarations(cu);
604 
605  list tmp_list=NIL;
606 
607  FOREACH(ENTITY,e,referenced_entities)
608  {
609  if( !top_level_entity_p(e) && gen_chunk_undefined_p(gen_find_eq(e,cu_decls) ) )
610  tmp_list=CONS(ENTITY,e,tmp_list);
611  else if (gen_chunk_undefined_p(gen_find_eq(e,cu_decls)))
612  {
613  AddLocalEntityToDeclarations(e,new_fun,new_body);
614  }
615  }
616  gen_free_list(referenced_entities);
617  referenced_entities=tmp_list;
618  }
619 
620  /* sort list, and put parameters first */
621  sort_entities_with_dep(&referenced_entities);
622 
623 
624  /* in some rare case, we can have too functions with the same local name */
625  outline_remove_duplicates(&referenced_entities);
626  return referenced_entities;
627 }
#define gen_chunk_undefined_p(c)
Definition: genC.h:75
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
Definition: list.c:691
void gen_list_and_not(list *a, const list b)
Compute A = A inter non B:
Definition: list.c:963
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422
static void outline_remove_duplicates(list *entities)
Definition: outlining.c:531
list outliner_statements_referenced_entities(list statements)
outlining.c
Definition: outlining.c:251
static list statements_localize_declarations(list statements, entity module, statement module_statement)
Definition: outlining.c:420
static void sort_entities_with_dep(list *l)
Definition: outlining.c:136
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130

References AddLocalEntityToDeclarations(), compilation_unit_of_module(), CONS, ENTITY, entity_declarations, entity_function_p(), FOREACH, fortran_module_p(), gen_chunk_undefined_p, gen_copy_seq(), gen_find_eq(), gen_free_list(), gen_list_and_not(), gen_nconc(), gen_remove_once(), get_bool_property(), get_current_module_entity(), get_current_module_name(), ifdebug, module_name_to_entity(), NIL, outline_remove_duplicates(), outliner_statements_referenced_entities(), outlining_variable_commenter(), pips_debug, pop_generated_variable_commenter(), print_entities(), push_generated_variable_commenter(), sort_entities_with_dep(), statements_localize_declarations(), statements_to_declarations(), and top_level_entity_p().

Referenced by compile_mpi(), and outliner().

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

◆ outliner_statements_referenced_entities()

list outliner_statements_referenced_entities ( list  statements)

outlining.c

we don't want initial values of outer entities

gather local initial values skipped by the previous call

set to list

Parameters
statementstatements

Definition at line 251 of file outlining.c.

252 {
253  list referenced_entities = NIL;
254  set sreferenced_entities = set_make(set_pointer);
255 
256  FOREACH(STATEMENT, s, statements)
257  {
258  /* we don't want initial values of outer entities */
260  /* gather local initial values skipped by the previous call*/
262  FOREACH(ENTITY,e,decl) {
264  set_union(tmp,tmp,se);
265  set_free(se);
267  set_union(tmp,tmp,se);
268  set_free(se);
269  }
270 
271  ifdebug(7) {
272  pips_debug(7,"Statement :");
273  print_statement(s);
274  pips_debug(7,"referenced entities :");
276  fprintf(stderr,"\n");
277  }
278 
279  set_union(sreferenced_entities,tmp,sreferenced_entities);
280  set_free(tmp);
281  }
282  /* set to list */
283  referenced_entities=set_to_list(sreferenced_entities);
284  set_free(sreferenced_entities);
285  return referenced_entities;
286 }
list statement_to_declarations(void *)
Get a list of all variables declared recursively within a statement.
Definition: statement.c:3253
set set_union(set, const set, const set)
Definition: set.c:211
static bool skip_constants_intrinsics_members(entity e)
Definition: outlining.c:129
static bool skip_values(void *v)
Definition: outlining.c:125
set get_referenced_entities_filtered(void *elem, bool(*chunk_filter)(void *), bool(*entity_filter)(entity))
Same as get_referenced_entities, but will only consider entities that fulfills entity_filter and will...
Definition: entity.c:2982

References ENTITY, entity_initial, entity_type, FOREACH, fprintf(), get_referenced_entities_filtered(), ifdebug, NIL, pips_debug, print_entities(), print_statement(), set_free(), set_make(), set_pointer, set_to_list(), set_union(), skip_constants_intrinsics_members(), skip_values(), STATEMENT, and statement_to_declarations().

Referenced by outliner_scan(), outliner_smart_references_computation(), and update_referenced_entities().

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

◆ pragma_omp_p()

bool pragma_omp_p ( pragma  p)

Check that a pragma is an "omp" one.

Definition at line 78 of file manage_pragma.c.

78  {
79  bool pragma_omp = false;
80  if(pragma_expression_p(p)) {
81  list expr = pragma_expression(p);
82  // The list is reversed !
83  expression begin = EXPRESSION(CAR(gen_last(expr)));
84  if(expression_call_p(begin)) {
85  entity called = call_function(expression_call(begin));
87  pragma_omp = true;
88  }
89  }
90  } else if(pragma_string_p(p)) {
91  if(strncasecmp("omp", pragma_string(p), 3) == 0) {
92  pragma_omp = true;
93  }
94  } else {
95  pips_internal_error("We don't know how to handle this kind of pragma !\n");
96  }
97  return pragma_omp;
98 }
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
#define OMP_OMP_FUNCTION_NAME
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
bool expression_call_p(expression e)
Definition: expression.c:415
call expression_call(expression e)
Definition: expression.c:445
#define pragma_expression_p(x)
Definition: ri.h:2034
#define pragma_string(x)
Definition: ri.h:2033
#define call_function(x)
Definition: ri.h:709
#define pragma_string_p(x)
Definition: ri.h:2031
#define pragma_expression(x)
Definition: ri.h:2036

References call_function, CAR, entity_local_name(), EXPRESSION, expression_call(), expression_call_p(), gen_last(), OMP_OMP_FUNCTION_NAME, pips_internal_error, pragma_expression, pragma_expression_p, pragma_string, pragma_string_p, and same_string_p.

Referenced by build_omp_pragma_list().

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

◆ pragma_outliner()

bool pragma_outliner ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 512 of file manage_pragma.c.

512  {
513  // Standard procedure for phases
515 
517  module_name,
518  true));
519  statement module_stat = get_current_module_statement();
520 
521  // Needed for outliner !
523  module_name,
524  true));
526  module_name,
527  true));
528  // Needed for outliner using option OUTLINE_SMART_REFERENCE_COMPUTATION TRUE
530  // Needed for induction variable removal
534 
536 
537  // Recursion context
538  // Getting the parameters of the pragmas in order to be able to parse them later
539  context ctx;
540  ctx.pragma_begin = (string) get_string_property("PRAGMA_OUTLINER_BEGIN");
541  ctx.pragma_end = (string) get_string_property("PRAGMA_OUTLINER_END");
542  ctx.prefix = (string) get_string_property("PRAGMA_OUTLINER_PREFIX");
543  ctx.outline_done = false;
544  // Recurse over sequence
545  gen_context_recurse(module_stat, &ctx,
547  // If a substitution has been done correctly, we put the new resources
548  if(ctx.outline_done) {
549  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES,
550  module_name,
551  compute_callees(module_stat));
552 
553  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
554  }
555  // Standard procedure for reseting after a phase
565  return true;
566 }
void set_methods_for_convex_effects(void)
methods.c
Definition: methods.c:235
void generic_effects_reset_all_methods(void)
bool outline_stmts_between_pragmas_in_sequence(sequence s, void *_ctx)
#define sequence_domain
newgen_reference_domain_defined
Definition: ri.h:346
void set_transformer_map(statement_mapping)
void reset_transformer_map(void)

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, free_value_mappings(), gen_context_recurse, gen_null2(), generic_effects_reset_all_methods(), get_current_module_entity(), get_current_module_statement(), get_string_property(), local_name_to_top_level_entity(), module_name(), module_to_value_mappings(), context::outline_done, outline_stmts_between_pragmas_in_sequence(), context::pragma_begin, context::pragma_end, context::prefix, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_precondition_map(), reset_proper_rw_effects(), reset_rw_effects(), reset_transformer_map(), sequence_domain, set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_methods_for_convex_effects(), set_precondition_map(), set_proper_rw_effects(), set_rw_effects(), and set_transformer_map().

+ Here is the call graph for this function:

◆ region_to_dimensions()

void region_to_dimensions ( effect  reg,
transformer  tr,
list dimensions,
list offsets,
expression condition 
)

isolate_statement.c

Parameters
regeg
trr
dimensionsimensions
offsetsffsets
conditionondition

Definition at line 204 of file isolate_statement.c.

204  {
205  pips_assert("effects are regions\n",effect_region_p(reg));
206  if( ! region_to_minimal_dimensions(reg,tr,dimensions,offsets,true,condition) ) {
207  pips_user_warning("failed to convert regions to minimal array dimensions, using whole array instead\n");
208 
209  bool success_p = false;
210  // Try using a region based on the declaration (Old way)
211  //success_p=declaration_region_to_dimensions(reg,tr,dimensions,offsets,condition);
212 
213  // Use directly the dimensions from the declaration without building a region!
215  success_p=declarations_to_dimensions(e, dimensions, offsets);
216 
217  if(!success_p) {
218  // Don't know how to recover from that...
219  pips_internal_error("Abort");
220  }
221  }
222 }
#define effect_region_p(e)
static bool declarations_to_dimensions(entity e, list *dimensions, list *offsets)
bool region_to_minimal_dimensions(region r, transformer tr, list *dims, list *offsets, bool exact, expression *condition)
generate a list of dimensions dims and of offsets from a region r for example if r = a[phi0,...

References declarations_to_dimensions(), effect_region_p, pips_assert, pips_internal_error, pips_user_warning, reference_variable, region_any_reference, and region_to_minimal_dimensions().

Referenced by effects_to_dma().

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

◆ region_to_minimal_dimensions()

bool region_to_minimal_dimensions ( effect  ,
transformer  ,
list ,
list ,
bool  ,
expression  
)

◆ remove_from_effective_parameters()

void remove_from_effective_parameters ( list  induction_var,
list effective_parameters 
)
Parameters
induction_varnduction_var
effective_parametersffective_parameters

Definition at line 1288 of file outlining.c.

1288  {
1289  list eff_par = gen_copy_seq(*effective_parameters);
1290  FOREACH(entity, ent, induction_var) {
1291  FOREACH(expression, exp, eff_par) {
1292  entity exp_ent = expression_to_entity(exp);
1293  if (!entity_undefined_p(exp_ent) && !strcmp(entity_minimal_user_name(exp_ent), entity_minimal_user_name(ent))) {
1294  printf("removing : \n");
1295  printf("effective parameter \n");
1296  printf("%s\n", entity_minimal_user_name(exp_ent));
1297  printf("induction var\n");
1298  printf("%s\n", entity_minimal_user_name(ent));
1299  printf("\n\n");
1300  gen_remove_once(effective_parameters, exp);
1301  }
1302  }
1303  }
1304  gen_free_list(eff_par);
1305 }
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
Definition: expression.c:3140

References entity_minimal_user_name(), entity_undefined_p, exp, expression_to_entity(), FOREACH, gen_copy_seq(), gen_free_list(), gen_remove_once(), and printf().

+ Here is the call graph for this function:

◆ remove_from_formal_parameters()

void remove_from_formal_parameters ( list  induction_var,
list formal_parameters 
)
Parameters
induction_varnduction_var
formal_parametersormal_parameters

Definition at line 1268 of file outlining.c.

1268  {
1269  list form_par = gen_copy_seq(*formal_parameters);
1270  FOREACH(entity, ent, induction_var) {
1271  FOREACH(parameter, param, form_par) {
1272  dummy dum = parameter_dummy(param);
1273  entity param_ent = dummy_identifier(dum);
1274  if (!entity_undefined_p(ent) && !strcmp(entity_minimal_user_name(param_ent), entity_minimal_user_name(ent))) {
1275  printf("removing : \n");
1276  printf("formal parameter \n");
1277  printf("%s\n", entity_minimal_user_name(param_ent));
1278  printf("induction var\n");
1279  printf("%s\n", entity_minimal_user_name(ent));
1280  printf("\n\n");
1281  gen_remove_once(formal_parameters, param);
1282  }
1283  }
1284  }
1285  gen_free_list(form_par);
1286 }

References dummy_identifier, entity_minimal_user_name(), entity_undefined_p, FOREACH, gen_copy_seq(), gen_free_list(), gen_remove_once(), parameter_dummy, and printf().

+ Here is the call graph for this function:

◆ remove_preferences()

void remove_preferences ( void *  obj)

delay.c

delay.c

Parameters
objbj

Definition at line 89 of file delay.c.

89  {
91 }
static bool do_remove_preference(cell c)
helper to transform preferences in references
Definition: delay.c:76
#define cell_domain
newgen_cell_interpretation_domain_defined
Definition: effects.h:85

References cell_domain, do_remove_preference(), gen_null(), and gen_recurse.

Referenced by delay_communications(), delay_load_communications(), delay_store_communications(), loop_annotate(), and simdizer().

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

◆ simd_dma_stat_p()

bool simd_dma_stat_p ( statement  stat)

This function returns true if the statement is a simd loadsave statement.

Parameters
stattat

Definition at line 127 of file delay.c.

128 {
129  return simd_load_stat_p(stat) || simd_store_stat_p(stat);
130 }
bool simd_load_stat_p(statement stat)
Definition: delay.c:111
bool simd_store_stat_p(statement stat)
Definition: delay.c:119

References simd_load_stat_p(), and simd_store_stat_p().

Referenced by dmas_invert_p(), do_remove_redundant_communications_in_anyloop(), do_remove_redundant_communications_in_sequence(), select_independent_dmas(), simd_stat_p(), and simd_trace_call().

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

◆ simd_load_stat_p()

bool simd_load_stat_p ( statement  stat)
Parameters
stattat

Definition at line 111 of file delay.c.

112 {
113  return statement_call_p(stat) && simd_load_call_p(statement_call(stat));
114 }
static bool simd_load_call_p(call c)
Definition: delay.c:95
call statement_call(statement)
Get the call of a statement.
Definition: statement.c:1406
bool statement_call_p(statement)
Definition: statement.c:364

References simd_load_call_p(), statement_call(), and statement_call_p().

Referenced by delay_communications_call(), do_recurse_statements_conflict_p(), and simd_dma_stat_p().

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

◆ simd_stat_p()

bool simd_stat_p ( statement  stat)

This function returns true if the statement is a simd statement.

Parameters
stattat

Definition at line 135 of file delay.c.

136 {
137  return simd_dma_stat_p(stat) || simd_work_stat_p(stat);
138 }
bool simd_dma_stat_p(statement stat)
This function returns true if the statement is a simd loadsave statement.
Definition: delay.c:127
bool simd_work_stat_p(statement stat)
Definition: delay.c:115

References simd_dma_stat_p(), and simd_work_stat_p().

+ Here is the call graph for this function:

◆ simd_store_stat_p()

bool simd_store_stat_p ( statement  stat)
Parameters
stattat

Definition at line 119 of file delay.c.

120 {
121  return statement_call_p(stat) && simd_store_call_p(statement_call(stat));
122 }
static bool simd_store_call_p(call c)
Definition: delay.c:105

References simd_store_call_p(), statement_call(), and statement_call_p().

Referenced by delay_communications_call(), simd_dma_stat_p(), statements_conflict_p(), and statements_conflict_relaxed_p().

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

◆ simd_work_stat_p()

bool simd_work_stat_p ( statement  stat)
Parameters
stattat

Definition at line 115 of file delay.c.

116 {
117  return statement_call_p(stat) && simd_work_call_p(statement_call(stat));
118 }
static bool simd_work_call_p(call c)
Definition: delay.c:100

References simd_work_call_p(), statement_call(), and statement_call_p().

Referenced by simd_stat_p().

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

◆ solve_hardware_constraints()

bool solve_hardware_constraints ( const char *  module_name)

constraints.c

validate

Parameters
module_nameodule_name

Definition at line 267 of file constraints.c.

268 {
269  debug_on("SOLVE_HARDWARE_CONSTRAINTS");
276 
277  const char* stmt_label=get_string_property("SOLVE_HARDWARE_CONSTRAINTS_LABEL");
279 
280  bool result =false;
281  if(!statement_undefined_p(equation_to_solve))
282  {
283  if((result=do_solve_hardware_constraints(equation_to_solve))) {
284  /* validate */
287  }
288  }
289 
296  debug_off();
297  return result;
298 }
static bool do_solve_hardware_constraints(statement s)
the equation is given by sum(e) { | REGION_READ(e) U REGION_WRITE(e) | } < VOLUME
Definition: constraints.c:248

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, do_solve_hardware_constraints(), find_statement_from_label_name(), free_value_mappings(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), get_string_property(), module_name(), module_name_to_entity(), module_reorder(), module_to_value_mappings(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_precondition_map(), reset_proper_rw_effects(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_precondition_map(), set_proper_rw_effects(), and statement_undefined_p.

+ Here is the call graph for this function:

◆ statement_has_omp_parallel_directive_p()

bool statement_has_omp_parallel_directive_p ( statement  s)

manage_pragma.c

Definition at line 52 of file manage_pragma.c.

52  {
53  bool found = false;
55  pragma p = extension_pragma(ex);
56  if(pragma_string_p(p)) {
57  string ps = pragma_string(p);
58  if((found = (strstr(ps, "omp parallel") || strstr(ps, "OMP PARALLEL"))))
59  goto found;
60  } else if(pragma_expression_p(p)) {
62  {
63  if(expression_call_p(pe)) {
64  call c = expression_call(pe);
65  if((found = (same_entity_p(call_function(c),
67  goto found;
68  }
69  }
70  }
71  }
72  found: return found;
73 }
entity CreateIntrinsic(string name)
this function does not create an intrinsic function because they must all be created beforehand by th...
Definition: entity.c:1311
#define extension_pragma(x)
Definition: ri.h:1295

References call_function, CreateIntrinsic(), EXPRESSION, expression_call(), expression_call_p(), EXTENSION, extension_pragma, extensions_extension, FOREACH, OMP_OMP_FUNCTION_NAME, pragma_expression, pragma_expression_p, pragma_string, pragma_string_p, same_entity_p(), and statement_extensions.

+ Here is the call graph for this function:

◆ statement_insertion()

bool statement_insertion ( const char *  module_name)

statement_insertion.c

init

do

validate

Parameters
module_nameodule_name

Definition at line 240 of file statement_insertion.c.

241 {
242  /* init */
247  debug_on("STATEMENT_INSERTION_DEBUG_LEVEL");
248 
249  /* do */
251  {
252  /* validate */
255  }
256 
257  debug_off();
262  return true;
263 }
static bool do_statement_insertion(statement s)

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, do_statement_insertion(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_proper_rw_effects(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), and set_proper_rw_effects().

+ Here is the call graph for this function:

◆ terapix_loop_optimizer()

void terapix_loop_optimizer ( statement  st)

look for iterators from the end

now try to hide the iteration in a pointer access somewhere

Parameters
stt

Definition at line 498 of file terapixify.c.

498  {
499  if(statement_loop_p(st)) {
500  loop l =statement_loop(st);
501 
502  statement sb = loop_body(l);
505  if(statement_block_p(sb)) {
507  list bblock = gen_nreverse(gen_copy_seq(block));
508  list added = NIL;
509 
510  /* look for iterators from the end */
511  FOREACH(STATEMENT,s,bblock) {
512  if(assignment_statement_p(s)) {
513  call c = statement_call(s);
514  expression lhs = binary_call_lhs(c),
515  rhs = binary_call_rhs(c);
516  if(expression_call_p(rhs)) {
517  call c = expression_call(rhs);
518  entity op = call_function(c);
519  if(ENTITY_PLUS_C_P(op) || ENTITY_MINUS_C_P(op)) {
520  bool plus = ENTITY_PLUS_C_P(op);
521  intptr_t step;
522  if(expression_equal_p(binary_call_lhs(c),lhs) &&
523  expression_integer_value(binary_call_rhs(c),&step)&&step==1) {
524  entity iterator = expression_to_entity(lhs);
525  statement copy = copy_statement(s);
528 
529  gen_remove(&block,s);
530  /* now try to hide the iteration in a pointer access somewhere */
531  tlo_context_t ctxt = {iterator,plus,false };
532  FOREACH(STATEMENT,ss,block) {
533  set re = get_referenced_entities(ss);
534  if(set_belong_p(re,iterator)) {
536  if(ctxt.success) {
537  set_free(re);
538  break;
539  }
540  }
541  set_free(re);
542  }
543  if(!ctxt.success)
545  else
546  free_statement(s);
547  added=CONS(STATEMENT,copy,added);
548  continue;
549  }
550  }
551  }
552  }
553  break;
554  }
556  gen_free_list(bblock);
557  if(!ENDP(added)) {
558  added=gen_nreverse(added);
559  insert_statement(st,make_block_statement(added),true);
560  }
561  }
562  }
563 }
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
void free_statement(statement p)
Definition: ri.c:2189
sequence statement_sequence(statement)
Get the sequence of a statement sequence.
Definition: statement.c:1328
bool assignment_statement_p(statement)
Test if a statement is an assignment.
Definition: statement.c:135
bool set_belong_p(const set, const void *)
Definition: set.c:194
#define binary_call_rhs(c)
#define ENTITY_PLUS_C_P(e)
#define ENTITY_MINUS_C_P(e)
#define binary_call_lhs(c)
#define MINUS_C_OPERATOR_NAME
#define PLUS_C_OPERATOR_NAME
set get_referenced_entities(void *elem)
retrieves the set of entities used in elem beware that this entities may be formal parameters,...
Definition: entity.c:3063
bool expression_integer_value(expression e, intptr_t *pval)
Definition: eval.c:792
bool expression_equal_p(expression e1, expression e2)
Syntactic equality e1==e2.
Definition: expression.c:1347
entity make_new_scalar_variable(entity, basic)
Definition: variable.c:741
Definition: statement.c:4047
struct block block
static bool do_terapix_loop_optimizer(call c, tlo_context_t *ctxt)
Definition: terapixify.c:479

References AddLocalEntityToDeclarations(), assignment_statement_p(), binary_call_lhs, binary_call_rhs, call_domain, call_function, CONS, copy_statement(), DEFAULT_INTEGER_TYPE_SIZE, do_terapix_loop_optimizer(), ENDP, entity_intrinsic(), ENTITY_MINUS_C_P, ENTITY_PLUS_C_P, expression_call(), expression_call_p(), expression_equal_p(), expression_integer_value(), expression_to_entity(), FOREACH, free_statement(), gen_context_recurse, gen_copy_seq(), gen_free_list(), gen_nreverse(), gen_null2(), gen_remove(), get_current_module_entity(), get_referenced_entities(), insert_statement(), intptr_t, loop_body, make_basic_int(), make_block_statement(), make_new_scalar_variable(), MINUS_C_OPERATOR_NAME, NIL, PLUS_C_OPERATOR_NAME, sequence_statements, set_belong_p(), set_free(), STATEMENT, statement_block(), statement_block_p, statement_call(), statement_loop(), statement_loop_p(), statement_sequence(), and tlo_context_t::success.

Referenced by normalize_microcode().

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

◆ terapix_remove_divide()

bool terapix_remove_divide ( const  string)

prelude

converts divide operator into multiply operator: a/cste = a* (1/b) ~= a * ( 128 / cste ) / 128

validate

ostlude

Parameters
stringodule_name

Definition at line 1045 of file terapixify.c.

1046 {
1047  /* prelude */
1050 
1051  /* converts divide operator into multiply operator:
1052  * a/cste = a* (1/b) ~= a * ( 128 / cste ) / 128
1053  */
1055 
1056  /* validate */
1058 
1059  /*postlude*/
1062  return true;
1063 }
static void do_terapix_remove_divide(call c)
Definition: terapixify.c:1011

References call_domain, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_terapix_remove_divide(), gen_recurse, gen_true(), get_current_module_statement(), module_name(), module_name_to_entity(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), and set_current_module_statement().

+ Here is the call graph for this function:

◆ terapix_warmup()

bool terapix_warmup ( const char *  module_name)

prelude

go go power rangers

validate

ostlude

Parameters
module_nameodule_name

Definition at line 908 of file terapixify.c.

908  {
909  /* prelude */
912 
913  /* go go power rangers */
914  bool can_terapixify =
916 
917  /* validate */
920 
921  /*postlude*/
924  return can_terapixify;
925 
926 }
static bool do_terapix_warmup(statement top)
make sure s is of the form decl loop nest
Definition: terapixify.c:879

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_terapix_warmup(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), and set_current_module_statement().

+ Here is the call graph for this function:

◆ type_dereferencement_depth()

size_t type_dereferencement_depth ( type  t)
Returns
the number of dimensions in
Parameters
t,countingpointers as a dimension

BEWARE: does not take structs and unions into account

Definition at line 89 of file array_to_pointer.c.

89  {
90  t = ultimate_type(t);
91  if(type_variable_p(t)) {
92  ifdebug(8) {
93  pips_debug(8,"Type is : ");
94  print_type(t);
95  }
96  variable v = type_variable(t);
97  basic b = variable_basic(v);
100  }
101  return 0;
102 }
size_t type_dereferencement_depth(type t)
void print_type(type)
For debugging.
Definition: type.c:111

References basic_pointer, basic_pointer_p, gen_length(), ifdebug, pips_debug, print_type(), type_dereferencement_depth(), type_variable, type_variable_p, ultimate_type(), variable_basic, and variable_dimensions.

Referenced by type_dereferencement_depth().

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

◆ unfolding()

bool unfolding ( char *  module_name)

perform unfolding using effect

Parameters
module_namename of the module to unfold
Returns
Parameters
module_nameodule_name

Definition at line 1118 of file inlining.c.

1119 {
1120  iparam p = IPARAM_INIT;
1121  use_effects(&p)=true;
1122  return do_unfolding(&p,module_name);
1123 }
static bool do_unfolding(inlining_parameters p, char *module_name)
this should inline all call in module ‘module_name’ it does not works recursievly,...
Definition: inlining.c:1032

References do_unfolding(), IPARAM_INIT, module_name(), and use_effects.

+ Here is the call graph for this function:

◆ unfolding_simple()

bool unfolding_simple ( char *  module_name)

perform unfolding without using effects

Parameters
module_namename of the module to unfold
Returns
true upon success
Parameters
module_nameodule_name

Definition at line 1133 of file inlining.c.

1134 {
1135  iparam p = IPARAM_INIT;
1136  use_effects(&p)=false;
1137  return do_unfolding(&p,module_name);
1138 }

References do_unfolding(), IPARAM_INIT, module_name(), and use_effects.

+ Here is the call graph for this function:

◆ variable_to_dimensions()

list variable_to_dimensions ( effect  )

◆ wrap_kernel_argument()

bool wrap_kernel_argument ( char *  module_name)

This pass will wrap kernel arguments in a call to a wrapper function.

prelude

o the job

validate

ostlude

Parameters
module_nameodule_name

Definition at line 1486 of file ikernels.c.

1486  {
1487 
1489 
1490  debug_on("WRAP_KERNEL_ARGUMENT_DEBUG_LEVEL");
1491 
1492  callees callers = (callees)db_get_memory_resource(DBR_CALLERS,
1493  module_name,
1494  true);
1495 
1496  // Get the wrapper function
1497  const char* function_name = get_string_property("WRAP_KERNEL_ARGUMENT_FUNCTION_NAME");
1498  wrapper_function = module_name_to_entity(function_name);
1501  = make_empty_subroutine(function_name,
1502  copy_language(module_language(kernel_entity)));
1503  pips_user_warning("Cannot find \"%s\" method. Are you sure you have set\n"
1504  "WRAP_KERNEL_ARGUMENT_FUNCTION_NAME"
1505  "to a defined entity and added the correct .c file?\n",function_name);
1506  }
1507 
1508 
1509 
1510 
1512  /* prelude */
1515  caller_name,
1516  true));
1517 
1518  /*do the job */
1521  /* validate */
1525 
1526  /*postlude*/
1529  }
1530 
1531  return true;
1532 }
static const char * caller_name
Definition: alias_check.c:122
static void wrap_call_argument(call c, const char *module_name)
Definition: ikernels.c:1469
static entity wrapper_function
Definition: ikernels.c:1442

References call_domain, callees_callees, caller_name, compute_callees(), copy_language(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_on, entity_undefined_p, FOREACH, gen_context_recurse, gen_true2(), get_current_module_statement(), get_string_property(), local_name_to_top_level_entity(), make_empty_subroutine(), module_language, module_name(), module_name_to_entity(), module_reorder(), pips_user_warning, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), STRING, wrap_call_argument(), and wrapper_function.

+ Here is the call graph for this function: