PIPS
|
#include "genC.h"
#include "linear.h"
#include "misc.h"
#include "ri-util.h"
#include "ri.h"
#include "prettyprint.h"
#include "properties.h"
#include "freia.h"
#include "hwac.h"
#include "freia_mppa.h"
Go to the source code of this file.
Macros | |
#define | MPPA_DEFAULT_SMEM_SLOTS 4 |
Default number of memory slots. More... | |
#define | SMEM_SLOT_UNDEFINED get_int_property("HWAC_MPPA_MAX_SMEM_SLOTS") |
Placeholder for an undefined slot. More... | |
Functions | |
static _int | get_free_slot () |
Get first unused SMEM slot. More... | |
static _int | get_output_slot (dagvtx vtx) |
Get output slot used by input vertex. More... | |
static _int | get_a_smem_slot (const dagvtx vtx, hash_table slot_uses_ht) |
Provide a valid unused SMEM slot and link it to vertex. More... | |
static _int | reuse_pred_slot (const dagvtx vtx, const list preds, hash_table slot_uses_ht) |
Try to find a reusable memory slot for in-place operators. More... | |
static _int | use_output_slot (const dagvtx vtx, hash_table slot_uses_ht) |
Provide vertex used SMEM slot, update uses table. More... | |
static void | process_used_slots (list vtx_preds, hash_table slot_uses_ht) |
Update preds usage table, unused slot list. More... | |
static string | dots2us (string str) |
Replace dots in string with underscores. More... | |
static list | mppa_helper_args_params (const dag cdg, string *params) |
Build a dag list of arguments and a string of corresponding parameters. More... | |
static void | mppa_call_helper (const dag dg, const string fname, unsigned int dagi, list largs) |
Replace FREIA calls by PIPS generated ones. More... | |
static void | mppa_compile_dag (const string module, const dag cdg, const string fname, const int dagi, FILE *const helper) |
Generate an optimized, FREIA-MPPA low level version of this dag. More... | |
static list | mppa_dag_split (const dag dg, unsigned int n_dags, unsigned int n_vtx_dag) |
Split a dag into several subdags. More... | |
static list | mppa_dag_maybe_split_instrs_cmd (const dag dg) |
Split a dag in several sub-dags if too large. More... | |
list | freia_mppa_compile_calls (string module, dag fulld, sequence sq, list ls, const hash_table occs, hash_table exchanges, const set output_images, FILE *helper_file, __attribute__((__unused__)) set helpers, int number) |
Compile one dag with AIPO optimizations. More... | |
Variables | |
static dagvtx * | smem_slot_users |
Array of vertices using SMEM slots (indices) as output. More... | |
#define MPPA_DEFAULT_SMEM_SLOTS 4 |
Default number of memory slots.
Definition at line 45 of file freia_mppa.c.
#define SMEM_SLOT_UNDEFINED get_int_property("HWAC_MPPA_MAX_SMEM_SLOTS") |
Placeholder for an undefined slot.
Definition at line 50 of file freia_mppa.c.
Replace dots in string with underscores.
[in,out] | str | allocated string with (or without) dots |
Definition at line 194 of file freia_mppa.c.
Referenced by mppa_compile_dag(), and mppa_helper_args_params().
list freia_mppa_compile_calls | ( | string | module, |
dag | fulld, | ||
sequence | sq, | ||
list | ls, | ||
const hash_table | occs, | ||
hash_table | exchanges, | ||
const set | output_images, | ||
FILE * | helper_file, | ||
__attribute__((__unused__)) set | helpers, | ||
int | number | ||
) |
Compile one dag with AIPO optimizations.
ls | statements underlying the full dag |
occs | image occurences |
exchanges | statements to exchange because of dependences |
split on scalars
split large dags
Definition at line 711 of file freia_mppa.c.
References cat, dag_dot_dump_prefix(), dag_fix_image_reuse(), dag_no_image_operation(), dag_split_on_scalars(), dag_statements(), dagvtx_ordering(), dg, FOREACH, freia_allocate_new_images_if_needed(), freia_dag_optimize(), freia_insert_added_stats(), freia_migrate_statements(), gen_free_list(), gen_length(), hash_pointer, hash_table_free(), hash_table_make(), HELPER, i2a(), init, module, mppa_compile_dag(), mppa_dag_maybe_split_instrs_cmd(), NIL, pips_assert, pips_debug, set_free(), set_make(), set_pointer, set_union(), and strdup().
Referenced by freia_compile().
|
static |
Provide a valid unused SMEM slot and link it to vertex.
[in] | vtx | vertex in need of a memory slot |
[out] | slot_users_ht | number of uses for this slot |
get first unused slot
link this slot to current vtx for later use
several successors, slot should be stored
and the consumer should deal itself with freeing the slot
Definition at line 98 of file freia_mppa.c.
References dagvtx_succs, gen_length(), get_free_slot(), hash_put(), and smem_slot_users.
Referenced by mppa_compile_dag().
|
static |
Get first unused SMEM slot.
Definition at line 62 of file freia_mppa.c.
References get_int_property(), pips_assert, SMEM_SLOT_UNDEFINED, and smem_slot_users.
Referenced by get_a_smem_slot().
Get output slot used by input vertex.
Definition at line 78 of file freia_mppa.c.
References get_int_property(), SMEM_SLOT_UNDEFINED, and smem_slot_users.
Referenced by mppa_compile_dag(), process_used_slots(), reuse_pred_slot(), and use_output_slot().
|
static |
Replace FREIA calls by PIPS generated ones.
[in] | dg | dag of several FREIA operations |
[in] | fname | function to call |
[in] | split | splitted dag index |
Definition at line 317 of file freia_mppa.c.
References cat, dag_vertices, dagvtx_opid(), dagvtx_statement(), dg, entity_undefined_p, FOREACH, freia_create_helper_function(), freia_ok(), hwac_replace_statement(), i2a(), local_name_to_top_level_entity(), make_call(), NIL, and strdup().
Referenced by mppa_compile_dag().
|
static |
Generate an optimized, FREIA-MPPA low level version of this dag.
[in] | module | current module name |
[in] | cdg | current dag |
[in] | fname | function name |
[in] | dagi | dag index |
[in,out] | helper | file to host the output |
debug
DEBUG_INFO
slot -> dagvtx user or NULL if free
prologue
global?
global?
set number of SMEM slots using property set to non-default value
input nodes
put image in an unused SMEM slot
non-input nodes
loop over preds to get slots
reductions results
remove '&' in first position
good memory management \o/
store vtx -> offset variable id
declare offset variable
there is an output image
preds outputs are reused after
and maybe some extra input parameters...
deal with structuring elements
se is statically known, do some partial eval
use a function to convert se to binary constant
deal with every parameter of other-than-morphological ops
partial eval threshold third parameter to redirect to relevant MPPA kernel
hack: overwrite current kernel...
skip writing third parameter (avoid obvious overflow)
add put instructions for output nodes (releases slot)
effectively launch computation
post-process reductions offset
epilogue
dump to helper file
replace statements
cleanup
Definition at line 349 of file freia_mppa.c.
References freia_api_t::arg_misc_out, CAR, cat, dag_dump(), dag_outputs, dag_vertex_preds(), dag_vertices, dagvtx_content, dagvtx_image(), dagvtx_is_measurement_p(), dagvtx_number(), dagvtx_operation(), dagvtx_optype(), dots2us(), ENTITY, entity_to_expression(), EXPRESSION, expression_to_string(), FOREACH, fprintf(), free(), freia_extract_kernel_vtx(), freia_get_vertex_params(), gen_copy_seq(), gen_free_list(), gen_in_list_p(), gen_nreverse(), gen_nth(), get_a_smem_slot(), get_freia_api_vtx(), get_int_property(), get_output_slot(), HASH_FOREACH, hash_pointer, hash_put(), hash_table_free(), hash_table_make(), i2a(), intptr_t, mppa_hw_t::kernel_enum, malloc(), module, freia_api_t::mppa, mppa_call_helper(), MPPA_DEFAULT_SMEM_SLOTS, mppa_helper_args_params(), pips_assert, process_used_slots(), reuse_pred_slot(), same_string_p, sb_cat, sb_prf, SMEM_SLOT_UNDEFINED, smem_slot_users, spoc_type_poc, spoc_type_thr, strdup(), string_buffer_free(), string_buffer_make(), string_buffer_to_file(), use_output_slot(), and vtxcontent_inputs.
Referenced by freia_mppa_compile_calls().
Split a dag in several sub-dags if too large.
[in] | dag | to split |
ok: dag should not be splitted
not ok: split!
one more if maybe too large
educated guess...
constraints: balanced dags, try not to separate outputs from producers...
Definition at line 672 of file freia_mppa.c.
References CONS, dag_outputs, dag_vertices, dg, gen_length(), get_int_property(), mppa_dag_split(), n_dags, NIL, and pips_assert.
Referenced by freia_mppa_compile_calls().
Split a dag into several subdags.
[in] | dg | input dag |
[in] | n_dags | number of returned sub-dags |
[in] | n_vtx_dag | number of vertices per sub-dag |
add input nodes
replace by an input node
get the right entity
create an input node of opid 0 (undefined)
add input vertex right before first consumer to optimize memory slots usage
add output nodes
mark vtx as an output node
remove succ from successors list
clean some weird cases when an input vtx is also an output
Definition at line 579 of file freia_mppa.c.
References CAR, CONS, dag_cleanup_other_statements(), dag_inputs, dag_outputs, dag_vertex_preds(), dag_vertices, DAGVTX, dagvtx_content, dagvtx_succs, dg, entity_undefined, FOREACH, gen_in_list_p(), gen_insert_before(), gen_length(), gen_nreverse(), gen_remove(), get_int_property(), make_dag(), make_dagvtx(), make_pstatement_empty(), make_vtxcontent(), n_dags, NIL, pips_assert, vtxcontent_inputs, and vtxcontent_out.
Referenced by mppa_dag_maybe_split_instrs_cmd().
Build a dag list of arguments and a string of corresponding parameters.
[in] | cdg | current dag |
[out] | args | allocated empty list of arguments (entities) |
[out] | fargs | pointer to string of helper parameters |
list of argument expressions
string buffer of helper parameters
loop over input/output nodes and store image variables into list
loop over image expressions to fill string buffer
loop over measure vertices
non partially evaluated structuring elements
pass SE name as helper parameter
post-process parameters
arguments string ends with ", "
replace '&' by '*'
cleanup
Definition at line 213 of file freia_mppa.c.
References CAR, CONS, dag_inputs, dag_outputs, dag_vertices, dagvtx_image(), dagvtx_is_measurement_p(), dagvtx_optype(), dots2us(), entity_to_expression(), EXPRESSION, expression_to_string(), FOREACH, freia_extract_kernel_vtx(), freia_get_vertex_params(), gen_full_copy_list(), gen_length(), gen_nconc(), gen_nreverse(), gen_nth(), intptr_t, NIL, out, params, sb_prf, set_add_element(), set_belong_p(), set_free(), set_make(), set_string, spoc_type_poc, string_buffer_free(), string_buffer_make(), and string_buffer_to_string().
Referenced by mppa_compile_dag().
|
static |
Update preds usage table, unused slot list.
[in] | vtx_preds | list of predecessors |
[out] | slot_users_ht | number of uses |
can reuse slot
delete entry in uses ht
Definition at line 174 of file freia_mppa.c.
References FOREACH, get_output_slot(), hash_del(), hash_get(), and smem_slot_users.
Referenced by mppa_compile_dag().
|
static |
Try to find a reusable memory slot for in-place operators.
[in] | vtx | current vertex |
[in] | preds | list of predecessors of current vertex |
[in,out] | slot_uses_ht | number of uses for this slot |
pred slot can be reused
several successors, slot should be stored
Definition at line 124 of file freia_mppa.c.
References dagvtx_optype(), dagvtx_succs, FOREACH, gen_length(), get_output_slot(), hash_get(), hash_put(), hash_update(), SMEM_SLOT_UNDEFINED, smem_slot_users, and spoc_type_poc.
Referenced by mppa_compile_dag().
|
static |
Provide vertex used SMEM slot, update uses table.
[in] | vtx | vertex using an output slot |
[out] | slot_uses_ht | number of uses for this slot |
update uses
Definition at line 157 of file freia_mppa.c.
References get_output_slot(), hash_get(), and hash_update().
Referenced by mppa_compile_dag().
|
static |
Array of vertices using SMEM slots (indices) as output.
Links a SMEM slot to a dagvtx user, or NULL if unused
Definition at line 57 of file freia_mppa.c.
Referenced by get_a_smem_slot(), get_free_slot(), get_output_slot(), mppa_compile_dag(), process_used_slots(), and reuse_pred_slot().