PIPS
|
#include <stdint.h>
#include <stdlib.h>
#include "genC.h"
#include "misc.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "effects-util.h"
#include "properties.h"
#include "freia.h"
#include "freia_spoc_private.h"
#include "hwac.h"
Go to the source code of this file.
Macros | |
#define | NORTH(v) ((void*) (((_int)v)+0)) |
#define | SOUTH(v) ((void*) (((_int)v)+1)) |
#define | WEST(v) ((void*) (((_int)v)+2)) |
#define | EAST(v) ((void*) (((_int)v)+3)) |
#define | IMG_PTR "imagelet_" |
#define | RED_PTR "reduction_" |
#define | ip2s(n) i2a(get_int_property(n)) |
Functions | |
static void | compute_dead_vertices (set deads, const set computed, const dag d, const dagvtx v) |
static void | erosion_optimization (dagvtx v, bool *north, bool *south, bool *west, bool *east) |
tell whether the kernel is used on each of the 4 directions. More... | |
static void | update_erosions (const dag d, const dagvtx v, hash_table erosion) |
update_erosions(). More... | |
static int | dag_terapix_measures (const dag d, hash_table erosion, int *width, int *cost, int *nops, int *north, int *south, int *west, int *east) |
compute some measures about DAG d. More... | |
static list | dag_vertex_pred_imagelets (const dag d, const dagvtx v, const hash_table allocation) |
of ints More... | |
static bool * | terapix_gram_init (void) |
allocate bitfield to described used cells in global memory. More... | |
static void | terapix_gram_allocate (bool *used, int width, int height, int *x, int *y) |
terapix allocate widthxheight in global memory More... | |
static _int | select_imagelet (set availables, int *nimgs, bool first) |
Return the first/last available imagelet, or create one if necessary This ensures that the choice is deterministic. More... | |
static void | terapix_image (string_buffer sb, int ff, int n) |
generate an image symbolic pointer (a name:-). More... | |
static void | terapix_mcu_img (string_buffer code, int op, string ref, int n) |
set a double buffered image argument. More... | |
static void | terapix_mcu_int (string_buffer code, int op, string ref, int val) |
set an integer argument. More... | |
static void | terapix_mcu_val (string_buffer code, int op, string r, string s) |
set some value string argument. More... | |
static void | terapix_mcu_pval (string_buffer code, int op, string ref, string p, string s) |
set some prefixed value string argument. More... | |
static void | gram_param (string_buffer code, string_buffer decl, string name, dagvtx v, hash_table hparams, int width, int height, bool is_kernel, bool *used) |
copy some operator parameters in the global ram (aka gram). More... | |
static void | terapix_gram_management (string_buffer code, string_buffer decl, int op, const freia_api_t *api, const dagvtx v, hash_table hparams, bool *used) |
manage GRAM global memory to pass parameters. More... | |
static void | terapix_macro_code (string_buffer code, string_buffer decl, int op, const freia_api_t *api, bool *used, hash_table hparams, const dagvtx v, const list ins, int out) |
generate terapix code for More... | |
static void | terapix_init_row (string_buffer decl, string_buffer code, string base, string suff, string mem, int nrow, string val, bool *used) |
initialize a few rows at mem address with value val More... | |
static void | terapix_initialize_memory (string_buffer decl, string_buffer body, int nop, string mem, const freia_api_t *api, bool *used) |
initialize the memory at addr depending on the operation to perform More... | |
static void | terapix_get_reduction (string_buffer decl, string_buffer tail, int n_op, string mem, const freia_api_t *api) |
generate reduction extraction code More... | |
static _int | freia_terapix_call (const string module, const string fname_dag, string_buffer code, dag thedag, list *params) |
generate a terapix call for dag thedag. More... | |
static int | freia_trpx_compile_one_dag (string module, list ls, dag d, string fname_fulldag, int n_split, int n_cut, set global_remainings, FILE *helper_file, set helpers, int stnb, hash_table signatures) |
generate terapix code for this one dag, which should be already split. More... | |
static void | dag_terapix_erosion (const dag d, hash_table erosion) |
fill in erosion hash table from dag d. More... | |
static void | dag_terapix_reset_erosion (const dag d) |
static int | dagvtx_terapix_priority (const dagvtx *v1, const dagvtx *v2) |
comparison function for sorting dagvtx in qsort, this is deep voodoo, because the priority has an impact on correctness? that should not be the case as only computations allowed by dependencies are schedule. More... | |
static bool | not_implemented (dagvtx v) |
whether vertex is not implemented in terapix More... | |
static bool | terapix_not_implemented (dag d) |
whether dag is not implemented in terapix More... | |
static dagvtx | choose_terapix_vertex (const list lv, bool started) |
choose a vertex, avoiding non combinable stuff if the list is started More... | |
static int | cut_decision (dag d, hash_table erosion) |
would it seem interesting to split d? More... | |
static dag | cut_perform (dag d, int cut, hash_table erodes, dag fulld, const set output_images) |
cut dag "d", possibly a subdag of "fulld", at "erosion" "cut" More... | |
static void | migrate_statements (sequence sq, dag d, set dones) |
list | freia_trpx_compile_calls (string module, dag fulld, sequence sq, list ls, const hash_table occs, hash_table exchanges, const set output_images, FILE *helper_file, set helpers, int number) |
do compile a list of statements for terapix More... | |
Variables | |
static hash_table | erosion = NULL |
global variable used by the dagvtx_terapix_priority function, because qsort does not allow to pass some descriptor. More... | |
#define EAST | ( | v | ) | ((void*) (((_int)v)+3)) |
Definition at line 89 of file freia_terapix.c.
#define IMG_PTR "imagelet_" |
Definition at line 327 of file freia_terapix.c.
#define ip2s | ( | n | ) | i2a(get_int_property(n)) |
#define NORTH | ( | v | ) | ((void*) (((_int)v)+0)) |
Definition at line 86 of file freia_terapix.c.
#define RED_PTR "reduction_" |
Definition at line 328 of file freia_terapix.c.
#define SOUTH | ( | v | ) | ((void*) (((_int)v)+1)) |
Definition at line 87 of file freia_terapix.c.
#define WEST | ( | v | ) | ((void*) (((_int)v)+2)) |
Definition at line 88 of file freia_terapix.c.
choose a vertex, avoiding non combinable stuff if the list is started
Definition at line 1606 of file freia_terapix.c.
|
static |
Definition at line 52 of file freia_terapix.c.
References dag_vertex_preds(), dagvtx_succs, FOREACH, gen_free_list(), list_in_set_p(), set_add_element(), set_dup(), and set_free().
Referenced by freia_terapix_call().
|
static |
would it seem interesting to split d?
Definition at line 1625 of file freia_terapix.c.
|
static |
cut dag "d", possibly a subdag of "fulld", at "erosion" "cut"
Definition at line 1701 of file freia_terapix.c.
|
static |
fill in erosion hash table from dag d.
Definition at line 1415 of file freia_terapix.c.
References dag_terapix_measures(), and erosion.
Referenced by dag_terapix_reset_erosion().
|
static |
compute some measures about DAG d.
Definition at line 157 of file freia_terapix.c.
References freia_api_t::arg_img_out, terapix_hw_t::cost, dag_computable_vertices(), dag_inputs, dag_outputs, dagvtx_freia_api, EAST, erosion, FOREACH, freia_convolution_p(), freia_convolution_width_height(), gen_free_list(), gen_length(), hash_get(), hash_pointer, hash_table_free(), hash_table_make(), int, NORTH, out, set_append_list(), set_free(), set_make(), set_pointer, SOUTH, freia_api_t::terapix, update_erosions(), and WEST.
Referenced by dag_terapix_erosion(), and freia_terapix_call().
|
static |
Definition at line 1426 of file freia_terapix.c.
References dag_terapix_erosion(), erosion, hash_table_clear(), and pips_assert.
|
static |
of ints
Definition at line 230 of file freia_terapix.c.
References allocation, CONS, dagvtx_content, dagvtx_get_producer(), FOREACH, gen_nconc(), hash_get(), NIL, pips_assert, and vtxcontent_inputs.
Referenced by freia_terapix_call().
comparison function for sorting dagvtx in qsort, this is deep voodoo, because the priority has an impact on correctness? that should not be the case as only computations allowed by dependencies are schedule.
tells v1 < (before) v2 => -1
Definition at line 1439 of file freia_terapix.c.
References _intFMT, dagvtx_content, dagvtx_dump(), dagvtx_freia_api, dagvtx_number(), dagvtx_operation(), dagvtx_optype(), dagvtx_succs, EAST, erosion, FOREACH, freia_aipo_terapix_implemented(), gen_length(), hash_defined_p(), hash_get(), ifdebug, terapix_hw_t::inplace, int, NIL, NORTH, pips_assert, pips_debug, SOUTH, spoc_type_alu, spoc_type_mes, spoc_type_nop, spoc_type_oth, freia_api_t::terapix, vtxcontent_inputs, vtxcontent_optype, and WEST.
|
static |
tell whether the kernel is used on each of the 4 directions.
Definition at line 68 of file freia_terapix.c.
References freia_extract_kernel_vtx(), and intptr_t.
Referenced by update_erosions().
|
static |
generate a terapix call for dag thedag.
the memory allocation is managed here. however this function is dumb, the scheduling is just inherited as is...
params | of expression |
Definition at line 710 of file freia_terapix.c.
References AIPO, allocation, freia_api_t::arg_img_out, freia_api_t::arg_misc_out, freia_api_t::arg_out_types, bool_to_string(), call_arguments, CAR, cat, choice, freia_api_t::compact_name, compute_dead_vertices(), CONS, current, dag_inputs, dag_outputs, dag_remove_vertex(), dag_terapix_measures(), dag_vertex_pred_imagelets(), dag_vertices, dagvtx_content, dagvtx_opid(), dagvtx_other_stuff_p(), entity_user_name(), FOREACH, free(), free_dagvtx(), freia_add_image_arguments(), FREIA_DEFAULT_HEIGHT, freia_extract_params(), freia_get_vertex_params(), FREIA_IMAGE, freia_statement_to_call(), gen_copy_seq(), gen_free_list(), gen_in_list_p(), gen_length(), gen_nconc(), gen_nreverse(), get_freia_api(), get_int_property(), get_string_property(), hash_get(), hash_pointer, hash_put(), hash_table_free(), hash_table_make(), hwac_freia_api(), hwac_kill_statement(), i2a(), IMG_PTR, init, terapix_hw_t::inplace, int, INT, ip2s, terapix_hw_t::memory, module, NIL, out, params, pips_assert, pstatement_statement, pstatement_statement_p, RED_PTR, same_string_p, sb_cat, select_imagelet(), set_add_element(), set_belong_p(), set_clear(), SET_FOREACH, set_free(), set_make(), set_pointer, space, strdup(), string_buffer_append_sb(), string_buffer_free(), string_buffer_make(), string_buffer_size(), freia_api_t::terapix, terapix_get_reduction(), terapix_gram_init(), terapix_gram_management(), terapix_initialize_memory(), terapix_macro_code(), terapix_mcu_int(), terapix_mcu_val(), trpx_dag_cut, trpx_dmabw_prop, trpx_gram_height, trpx_gram_width, trpx_max_size, trpx_mem_prop, trpx_npe_prop, trpx_overlap_io_p, vtxcontent_out, and vtxcontent_source.
Referenced by freia_trpx_compile_one_dag().
list freia_trpx_compile_calls | ( | string | module, |
dag | fulld, | ||
sequence | sq, | ||
list | ls, | ||
const hash_table | occs, | ||
hash_table | exchanges, | ||
const set | output_images, | ||
FILE * | helper_file, | ||
set | helpers, | ||
int | number | ||
) |
do compile a list of statements for terapix
module,current | module (function) name |
ls,list | of statements taken from the sequence |
occs,occurences | of images (image -> set of statements) |
helper_file,file | to which code is to be generated |
number,number | of this statement sequence in module |
module | odule |
fulld | ulld |
sq | q |
ls | of statements |
occs | ccs |
exchanges | xchanges |
output_images | utput_images |
helper_file | elper_file |
helpers | elpers |
number | umber |
Definition at line 1808 of file freia_terapix.c.
Referenced by freia_compile().
|
static |
generate terapix code for this one dag, which should be already split.
return the statement number of the helper insertion
ls | of statements |
Definition at line 1358 of file freia_terapix.c.
References cat, dag_consistency_asserts(), dag_dot_dump(), dag_dump(), dag_vertices, free(), freia_substitute_by_helper_call(), freia_terapix_call(), hash_put(), i2a(), ifdebug, local_name_to_top_level_entity(), lparams, module, NIL, set_append_vertex_statements(), set_make(), set_pointer, strdup(), string_buffer_free(), string_buffer_make(), and string_buffer_to_file().
|
static |
copy some operator parameters in the global ram (aka gram).
the coordinates used are (x_<name>, y_<name>).
Definition at line 386 of file freia_terapix.c.
References CAR, CDR, EXPRESSION, freia_get_vertex_params(), gen_length(), hash_get(), i2a(), pips_assert, pips_internal_error, sb_cat, terapix_gram_allocate(), and x.
Referenced by terapix_gram_management().
Definition at line 1791 of file freia_terapix.c.
Return the first/last available imagelet, or create one if necessary This ensures that the choice is deterministic.
Moreover, as first numbers are IO imagelets, this help putting outputs in the right imagelet so as to avoid additionnal copies, if possible.
Definition at line 297 of file freia_terapix.c.
References _intFMT, bool_to_string(), choice, i2a(), ifdebug, pips_assert, pips_debug, set_del_element(), set_empty_p(), SET_FOREACH, and set_fprint().
Referenced by freia_terapix_call().
|
static |
generate reduction extraction code
Definition at line 670 of file freia_terapix.c.
References freia_api_t::arg_misc_out, free(), i2a(), pips_assert, sb_cat, strdup(), freia_api_t::terapix, and terapix_hw_t::ucode.
Referenced by freia_terapix_call().
terapix allocate widthxheight in global memory
Definition at line 263 of file freia_terapix.c.
References get_int_property(), ok, pips_internal_error, trpx_gram_height, trpx_gram_width, and x.
Referenced by gram_param(), and terapix_init_row().
|
static |
allocate bitfield to described used cells in global memory.
Definition at line 249 of file freia_terapix.c.
References get_int_property(), malloc(), pips_assert, trpx_gram_height, and trpx_gram_width.
Referenced by freia_terapix_call().
|
static |
manage GRAM global memory to pass parameters.
Definition at line 442 of file freia_terapix.c.
References freia_api_t::arg_misc_in, CAR, EXPRESSION, freia_convolution_p(), freia_convolution_width_height(), freia_get_vertex_params(), gram_param(), hash_defined_p(), hash_get(), hash_put(), i2a(), initialize(), terapix_hw_t::north, pips_internal_error, strdup(), freia_api_t::terapix, and terapix_mcu_pval().
Referenced by freia_terapix_call(), and terapix_macro_code().
|
static |
generate an image symbolic pointer (a name:-).
Definition at line 332 of file freia_terapix.c.
References i2a(), IMG_PTR, pips_assert, and sb_cat.
Referenced by terapix_mcu_img().
|
static |
initialize a few rows at mem address with value val
Definition at line 572 of file freia_terapix.c.
References base, cat, free(), i2a(), sb_cat, strdup(), terapix_gram_allocate(), and x.
Referenced by terapix_initialize_memory().
|
static |
initialize the memory at addr depending on the operation to perform
decl,added | declarations are put there |
body,generated | code is put there |
nop,current | operation number |
mem,memory | symbolic x address |
api,freia | operation |
used,current | use of Global RAM (gram) |
Definition at line 635 of file freia_terapix.c.
References cat, freia_api_t::compact_name, free(), i2a(), pips_assert, same_string_p, strdup(), and terapix_init_row().
Referenced by freia_terapix_call().
|
static |
generate terapix code for
code,code | stream being generated |
decl,declaration | stream being generated |
op,operation | number |
api,actual | freia operator called |
used,array | to keep track of what gram cells are used |
hparam,expression | to parameter mapping |
v,dag | vertex of the current operation |
ins,list | of image number inputs (i.e. operation arguments) |
out,image | number output for the operation |
Definition at line 503 of file freia_terapix.c.
References freia_api_t::arg_img_in, freia_api_t::arg_img_out, CAR, CDR, freia_convolution_p(), freia_convolution_width_height(), gen_length(), INT, out, pips_assert, pips_internal_error, terapix_hw_t::reverse, freia_api_t::terapix, terapix_gram_management(), terapix_mcu_img(), terapix_mcu_int(), terapix_mcu_val(), and terapix_hw_t::ucode.
Referenced by freia_terapix_call().
|
static |
set a double buffered image argument.
Definition at line 344 of file freia_terapix.c.
References i2a(), ref, sb_cat, and terapix_image().
Referenced by terapix_macro_code().
|
static |
set an integer argument.
Definition at line 356 of file freia_terapix.c.
References i2a(), ref, and sb_cat.
Referenced by freia_terapix_call(), and terapix_macro_code().
|
static |
set some prefixed value string argument.
Definition at line 374 of file freia_terapix.c.
References i2a(), ref, and sb_cat.
Referenced by terapix_gram_management().
|
static |
set some value string argument.
Definition at line 366 of file freia_terapix.c.
Referenced by freia_terapix_call(), and terapix_macro_code().
|
static |
compute and store the imagelet erosion on vertex v output.
Definition at line 94 of file freia_terapix.c.
References dag_vertex_preds(), dagvtx_freia_api, EAST, terapix_hw_t::east, erosion, erosion_optimization(), FOREACH, freia_convolution_p(), freia_convolution_width_height(), gen_free_list(), hash_get(), hash_put(), NORTH, terapix_hw_t::north, SOUTH, terapix_hw_t::south, freia_api_t::terapix, WEST, and terapix_hw_t::west.
Referenced by dag_terapix_measures().
|
static |
global variable used by the dagvtx_terapix_priority function, because qsort does not allow to pass some descriptor.
Definition at line 1424 of file freia_terapix.c.
Referenced by constant_image_p(), dag_terapix_erosion(), dag_terapix_measures(), dag_terapix_reset_erosion(), dagvtx_terapix_priority(), and update_erosions().