PIPS
|
#include <stdint.h>
#include <stdlib.h>
#include "genC.h"
#include "misc.h"
#include "freia.h"
#include "freia_spoc.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "effects-util.h"
#include "properties.h"
#include "freia_spoc_private.h"
#include "hwac.h"
Go to the source code of this file.
Data Structures | |
struct | op_schedule |
a data structure to describe a schedule for an operation More... | |
Macros | |
#define | T true |
#define | F false |
Functions | |
static void | comment (string_buffer code, spoc_hardware_type hw, dagvtx v, int stage, int side, bool flip) |
static const spoc_alu_op_t * | get_spoc_alu_conf (spoc_alu_t alu) |
static void | spoc_alu_conf (spoc_alu_t alu, string_buffer body, __attribute__((__unused__)) string_buffer tail, int stage, bool flip, dagvtx orig, hash_table hp) |
generate a configuration for the ALU hardware component. More... | |
static void | spoc_poc_conf (spoc_poc_t poc, string_buffer body, __attribute__((__unused__)) string_buffer tail, int stage, int side, dagvtx orig, hash_table hp) |
generate a configuration for a POC (morpho) hardware component. More... | |
static void | spoc_th_conf (string_buffer body, __attribute__((__unused__)) string_buffer tail, int stage, int side, dagvtx orig, hash_table hp) |
generate a configuration for a threshold component. More... | |
static int | spoc_measure_n_params (spoc_measure_t measure) |
static void | spoc_measure_conf (spoc_measure_t measure, __attribute__((__unused__)) string_buffer body, string_buffer tail, int stage, int side, dagvtx orig, hash_table hp) |
there is no real configuration for the measures, the issue is just to fetch them. More... | |
static void | basic_spoc_conf (spoc_hardware_type op, string_buffer body, string_buffer tail, int stage, int side, bool flip, const spoc_hw_t *conf, dagvtx orig, hash_table hp) |
basic configuration generation for a stage, depending on hw description More... | |
static void | init_op_schedule (op_schedule *op, dagvtx v, int side) |
static int | max_stage (const op_schedule *in0, const op_schedule *in1) |
static bool | image_is_needed (dagvtx prod, dag d, set todo) |
is image needed? More... | |
static void | print_op_schedule (FILE *out, const string name, const op_schedule *op) |
static bool | check_mux_availibity (hash_table wiring, int stage, int mux) |
static void | set_mux (hash_table wiring, int stage, int mux) |
static bool | check_wiring_output (hash_table wiring, int stage, int side) |
can I get out of stage on this side? More... | |
static _int | component_index (int stage, int level, int side) |
static void | set_component (hash_table wiring, int stage, int level, int side) |
static bool | available_component (hash_table wiring, int stage, int level, int side) |
static int | find_first_crossing (hash_table wiring, int stage, int level) |
return the first stage after stage/level with both paths available More... | |
static void | find_first_available_component (hash_table wiring, int start_stage, int level, int side, int target_level, bool crossing, int *pstage, int *pside) |
return the stage & side of the first component available after (start_stage, level, side) which is the source of the used image, for an operation of type target_level More... | |
static void | set_wiring (string_buffer code, int stage, int mux, _int value, hash_table wiring) |
generate wiring code for mux if necessary. More... | |
static void | where_to_perform_operation (const dagvtx op, op_schedule *in0, op_schedule *in1, dag computed, set todo, op_schedule *out, hash_table wiring) |
depending on available images (stage d, level, side 0/1) and vertex operation to perform , tell where to perform it. More... | |
static void | generate_wiring_stage (string_buffer code, int stage, int in_side, int out_side, hash_table wiring) |
all possible wirings at one stage More... | |
static void | generate_wiring (string_buffer code, op_schedule *in, op_schedule *out, hash_table wiring) |
generate wire code from in to out, record choices in wiring. More... | |
static void | freia_spoc_code_buildup (string module, string function_name, string_buffer code, const string_buffer head, const string_buffer body, const string_buffer tail, int n_im_out, int n_im_in, bool some_reductions, bool some_kernels, const string out0, const string out1, const string in0, const string in1) |
build up final pipeline code from various pieces More... | |
static bool | is_consummed_by_vertex (dagvtx prod, dagvtx v, dag d, set todo) |
tell whether the image produced by prod is definitely consummed by v given the global dag d and the set of vertex still to be computed todo. More... | |
static _int | freia_spoc_pipeline (string module, string helper, string_buffer code, dag dpipe, list *lparams, const set output_images) |
generate a SPoC pipeline from a single DAG for module. More... | |
static bool | erode_alu_shared_p (vtxcontent c1, vtxcontent c2) |
? = Morpho(I); ? = ALU(I, ?); More... | |
static int | dagvtx_spoc_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 void | live_update (dag d, dagvtx v, set sure, set maybe) |
update sure/maybe set of live images after computing vertex v that is the images that may be output from the pipeline. More... | |
static set | output_arcs (dag d, set vs) |
returns an allocated set of vertices with live outputs. More... | |
static int | number_of_output_arcs (dag d, set vs) |
how many output arcs from this set of vertices? More... | |
static bool | convolution_33 (dagvtx v) |
static bool | dag_spoc_not_implemented (dag d) |
does this dag contains a spoc non implemented operation? More... | |
static dagvtx | first_which_may_be_added (dag dall, set current, list lv, set sure, set maybe) |
return first vertex in the list which is compatible, or NULL if none. More... | |
static list | split_dag (dag initial, const set output_images) |
split dag dall into a list of pipelinable dags which must be processed in that order (?) side effect: dall is more or less consummed... More... | |
list | freia_spoc_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) |
generate helpers for statements in ls of module output resulting functions in helper, which may be empty in some cases. More... | |
Variables | |
static const spoc_alu_op_t | ALU_OP [] |
static list | dagvtx_spoc_priority_computables = NIL |
current list of computable that may be used to know about the global context when comparing to vertices in "dagvtx_spoc_priority". More... | |
static list | dagvtx_spoc_priority_current = NIL |
#define F false |
Definition at line 50 of file freia_spoc.c.
Definition at line 49 of file freia_spoc.c.
|
static |
Definition at line 522 of file freia_spoc.c.
References component_index(), hash_defined_p(), and level.
Referenced by find_first_available_component().
|
static |
basic configuration generation for a stage, depending on hw description
Definition at line 360 of file freia_spoc.c.
References spoc_hw_t::alu, spoc_hw_t::mes, pips_internal_error, spoc_hw_t::poc, sb_cat, spoc_alu_conf(), spoc_measure_conf(), spoc_poc_conf(), spoc_th_conf(), spoc_type_alu, spoc_type_inp, spoc_type_mes, spoc_type_nop, spoc_type_poc, spoc_type_thr, and what_operation().
Referenced by freia_spoc_pipeline().
|
static |
Definition at line 485 of file freia_spoc.c.
References hash_defined_p().
Referenced by check_wiring_output(), and set_wiring().
|
static |
can I get out of stage on this side?
Definition at line 499 of file freia_spoc.c.
References check_mux_availibity().
Referenced by find_first_available_component(), find_first_crossing(), freia_spoc_pipeline(), generate_wiring(), and where_to_perform_operation().
|
static |
Definition at line 52 of file freia_spoc.c.
References dagvtx_number(), dagvtx_operation(), i2a(), sb_cat, spoc_type_alu, and what_operation().
Referenced by add_declaration_statement_here(), add_to_current_line(), build_call_STEP_WaitAll(), C_comment_to_text(), C_standard_comment_to_text(), clear_annotated_loop_nest(), close_current_line(), comment_string_p(), comments_dup(), compile_regions(), dagvtx_list_dot(), find_first_comment(), find_first_statement_comment(), gather_grid_dim(), generate_all_liveness_but(), generate_dynamic_liveness_for_primary(), generate_dynamic_liveness_management(), generate_io_statements_for_shared_arrays(), generate_remapping_include(), GENERATION(), generic_add_declaration_statement(), get_declaration_comments(), gpu_ify_statement(), io_filter(), make_layout_statement(), make_shared_statement(), MakeLabeledStatement(), number_of_use_greater_1(), parallelize_annotated_loop_nest(), prepend_comment(), remapping_compile(), remapping_stats(), spoc_alu_conf(), spoc_measure_conf(), spoc_poc_conf(), spoc_th_conf(), st_declaration_comment(), store_sc_text_line(), stub_var_decl(), text_loop_craft(), update_number_of_use(), and update_runtime_for_remapping().
Definition at line 504 of file freia_spoc.c.
References level, pips_assert, spoc_type_alu, spoc_type_mes, and spoc_type_poc.
Referenced by available_component(), and set_component().
Definition at line 1993 of file freia_spoc.c.
does this dag contains a spoc non implemented operation?
Definition at line 2005 of file freia_spoc.c.
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.
non implemented functions are pushed late. tells v1 < v2 => -1 => v1 BEFORE v2
Definition at line 1775 of file freia_spoc.c.
References _intFMT, dagvtx_content, dagvtx_number(), dagvtx_operation(), dagvtx_optype(), dagvtx_succs, erode_alu_shared_p(), FOREACH, gen_length(), int, pips_debug, spoc_type_mes, spoc_type_nop, spoc_type_oth, spoc_type_sni, vtxcontent_inputs, and vtxcontent_optype.
|
static |
? = Morpho(I); ? = ALU(I, ?);
Definition at line 1759 of file freia_spoc.c.
References CAR, ENTITY, gen_in_list_p(), gen_length(), spoc_type_alu, spoc_type_poc, vtxcontent_inputs, and vtxcontent_optype.
Referenced by dagvtx_spoc_priority().
|
static |
return the stage & side of the first component available after (start_stage, level, side) which is the source of the used image, for an operation of type target_level
Definition at line 545 of file freia_spoc.c.
References available_component(), check_wiring_output(), find_first_crossing(), level, pips_assert, and spoc_type_alu.
Referenced by where_to_perform_operation().
|
static |
return the first stage after stage/level with both paths available
Definition at line 531 of file freia_spoc.c.
References check_wiring_output(), level, and spoc_type_alu.
Referenced by find_first_available_component().
|
static |
return first vertex in the list which is compatible, or NULL if none.
Definition at line 2017 of file freia_spoc.c.
|
static |
build up final pipeline code from various pieces
module | |
function_name | to be generated |
code | output |
head | input, function parameters |
body | input, pipeline stage initialization |
tail | input, getting back reduction results |
n_im_* | number of in and out paramters to function |
some_reductions | if there are |
p_* | variables sent and received from pipeline |
Definition at line 1127 of file freia_spoc.c.
References FREIA_DEFAULT_BPP, FREIA_IMAGE, FREIA_SPOC_CALL_END, FREIA_SPOC_CALL_REDUC, FREIA_SPOC_CALL_START, FREIA_SPOC_DECL, i2a(), module, sb_cat, and string_buffer_append_sb().
Referenced by freia_spoc_pipeline().
list freia_spoc_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 | ||
) |
generate helpers for statements in ls of module output resulting functions in helper, which may be empty in some cases.
module | |
ls | list of statements for the dag (in reverse order) |
helper | output file |
helpers | created functions |
number | current helper dag count |
of expression
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 2246 of file freia_spoc.c.
Referenced by freia_compile().
|
static |
generate a SPoC pipeline from a single DAG for module.
module | current |
helper | name of function to generate |
code | output here |
dpipe | dag to consider |
lparams | parameters to call helper |
some side effects:
I should have really done an allocation on a infinite pipeline, and then cut it, instead of this half measure to handle overflows, but that would change a lot of things to go back.
of entity
Definition at line 1240 of file freia_spoc.c.
References _intFMT, basic_spoc_conf(), call_arguments, CAR, CDR, check_wiring_output(), CONS, dag_compute_outputs(), dag_inputs, dag_outputs, dag_remove_vertex(), dag_vertices, DAGVTX, dagvtx_content, dagvtx_number(), dagvtx_opid(), dagvtx_optype(), dagvtx_succs, ENTITY, entity_local_name(), FOREACH, free_dagvtx(), freia_add_image_arguments(), freia_extract_params(), freia_spoc_code_buildup(), freia_statement_to_call(), gen_copy_seq(), gen_free_list(), gen_in_list_p(), gen_length(), gen_nconc(), gen_nreverse(), gen_remove(), generate_wiring(), get_freia_api(), get_int_property(), hash_int, hash_pointer, hash_table_free(), hash_table_make(), hwac_kill_statement(), i2a(), op_schedule::image, image_is_needed(), init_op_schedule(), is_consummed_by_vertex(), op_schedule::just_used, op_schedule::level, lparams, module, NIL, out, pips_assert, pips_debug, pips_internal_error, op_schedule::producer, pstatement_statement, pstatement_statement_p, sb_cat, set_add_element(), set_assign_list(), set_belong_p(), set_component(), set_del_element(), set_difference(), set_empty_p(), SET_FOREACH, set_free(), set_make(), set_pointer, set_size(), op_schedule::side, freia_api_t::spoc, spoc_depth_prop, spoc_type_mes, spoc_type_out, spoc_type_poc, op_schedule::stage, string_buffer_free(), string_buffer_make(), op_schedule::used, vtxcontent_optype, vtxcontent_out, vtxcontent_source, and where_to_perform_operation().
|
static |
generate wire code from in to out, record choices in wiring.
Definition at line 948 of file freia_spoc.c.
References _FALLTHROUGH_, _intFMT, CAR, check_wiring_output(), dagvtx_content, dagvtx_number(), dagvtx_operation(), dagvtx_optype(), ENTITY, entity_local_name(), free(), gen_length(), generate_wiring_stage(), i2a(), op_schedule::image, op_schedule::level, out, pips_assert, pips_debug, pips_internal_error, sb_cat, set_component(), op_schedule::side, spoc_type_alu, spoc_type_inp, spoc_type_mes, spoc_type_nop, spoc_type_out, spoc_type_poc, spoc_type_thr, op_schedule::stage, strdup(), vtxcontent_inputs, and what_operation().
Referenced by freia_spoc_pipeline().
|
static |
all possible wirings at one stage
Definition at line 903 of file freia_spoc.c.
References pips_assert, pips_debug, pips_internal_error, and set_wiring().
Referenced by generate_wiring().
|
static |
Definition at line 141 of file freia_spoc.c.
References ALU_OP.
Referenced by spoc_alu_conf().
is image needed?
Definition at line 446 of file freia_spoc.c.
References _intFMT, dag_outputs, dag_vertex_preds(), dagvtx_number(), gen_free_list(), gen_in_list_p(), NIL, pips_debug, and SET_FOREACH.
Referenced by freia_spoc_pipeline(), and where_to_perform_operation().
|
static |
Definition at line 412 of file freia_spoc.c.
References dagvtx_image(), op_schedule::flip, op_schedule::image, op_schedule::just_used, op_schedule::level, op_schedule::producer, op_schedule::side, spoc_type_inp, op_schedule::stage, op_schedule::used, op_schedule::used_level, and op_schedule::used_stage.
Referenced by freia_spoc_pipeline().
tell whether the image produced by prod is definitely consummed by v given the global dag d and the set of vertex still to be computed todo.
Definition at line 1197 of file freia_spoc.c.
References _intFMT, dag_outputs, dagvtx_number(), dagvtx_succs, gen_in_list_p(), pips_debug, set_assign_list(), set_del_element(), set_free(), set_intersection_p(), set_make(), and set_pointer.
Referenced by freia_spoc_pipeline().
update sure/maybe set of live images after computing vertex v that is the images that may be output from the pipeline.
this is voodoo...
Definition at line 1885 of file freia_spoc.c.
|
static |
Definition at line 426 of file freia_spoc.c.
References op_schedule::image, and op_schedule::stage.
Referenced by where_to_perform_operation().
returns an allocated set of vertices with live outputs.
Definition at line 1950 of file freia_spoc.c.
|
static |
Definition at line 472 of file freia_spoc.c.
References _intFMT, dagvtx_number(), dagvtx_operation(), entity_local_name(), op_schedule::flip, fprintf(), op_schedule::image, op_schedule::level, out, op_schedule::producer, op_schedule::side, spoc_type_alu, op_schedule::stage, op_schedule::used, op_schedule::used_level, op_schedule::used_stage, and what_operation().
Referenced by where_to_perform_operation().
|
static |
Definition at line 511 of file freia_spoc.c.
References component_index(), hash_put(), level, spoc_type_mes, spoc_type_poc, and spoc_type_thr.
Referenced by freia_spoc_pipeline(), and generate_wiring().
|
static |
Definition at line 491 of file freia_spoc.c.
References hash_put().
Referenced by set_wiring().
|
static |
generate wiring code for mux if necessary.
code | generated |
stage | stage under consideration |
mux | multiplexer to set |
value | status for the multiplexer |
wiring | already performed wiring to check for double settings. |
Definition at line 608 of file freia_spoc.c.
References _intFMT, check_mux_availibity(), free(), i2a(), pips_assert, pips_debug, sb_cat, set_mux(), and strdup().
Referenced by generate_wiring_stage().
split dag dall into a list of pipelinable dags which must be processed in that order (?) side effect: dall is more or less consummed...
of dags
Definition at line 2103 of file freia_spoc.c.
|
static |
generate a configuration for the ALU hardware component.
Definition at line 148 of file freia_spoc.c.
References alu_unused, CAR, comment(), EXPRESSION, spoc_alu_op_t::flipped, free(), freia_get_vertex_params(), get_spoc_alu_conf(), hash_get(), i2a(), message_assert, spoc_alu_op_t::op, sb_cat, spoc_alu_op_t::setting, spoc_type_alu, strdup(), and spoc_alu_op_t::use_cst.
Referenced by basic_spoc_conf().
|
static |
there is no real configuration for the measures, the issue is just to fetch them.
Definition at line 295 of file freia_spoc.c.
References CAR, cat, CDR, comment(), EXPRESSION, free(), freia_get_vertex_params(), gen_length(), hash_get(), i2a(), measure_max, measure_max_coord, measure_min, measure_min_coord, measure_vol, pips_assert, pips_internal_error, sb_cat, spoc_measure_n_params(), spoc_type_mes, and strdup().
Referenced by basic_spoc_conf().
|
static |
Definition at line 278 of file freia_spoc.c.
References measure_max_coord, measure_min_coord, and measure_none.
Referenced by spoc_measure_conf().
|
static |
generate a configuration for a POC (morpho) hardware component.
Definition at line 189 of file freia_spoc.c.
References CAR, comment(), spoc_poc_t::connectivity, EXPRESSION, free(), freia_get_vertex_params(), hash_get(), i2a(), spoc_poc_t::op, pips_internal_error, sb_cat, spoc_poc_conv, spoc_poc_dilate, spoc_poc_erode, spoc_poc_unused, spoc_type_poc, and strdup().
Referenced by basic_spoc_conf().
|
static |
generate a configuration for a threshold component.
Definition at line 242 of file freia_spoc.c.
References CAR, CDR, comment(), EXPRESSION, free(), freia_get_vertex_params(), gen_length(), hash_get(), i2a(), pips_assert, sb_cat, spoc_type_thr, and strdup().
Referenced by basic_spoc_conf().
|
static |
depending on available images (stage d, level, side 0/1) and vertex operation to perform , tell where to perform it.
some voodoo again...
Definition at line 634 of file freia_spoc.c.
References _intFMT, CAR, check_wiring_output(), dagvtx_content, dagvtx_number(), dagvtx_operation(), ENTITY, entity_local_name(), entity_undefined, find_first_available_component(), gen_length(), ifdebug, op_schedule::image, image_is_needed(), int, op_schedule::just_used, level, op_schedule::level, max_stage(), out, pips_assert, pips_debug, pips_internal_error, print_op_schedule(), op_schedule::producer, op_schedule::side, spoc_type_alu, spoc_type_inp, spoc_type_mes, spoc_type_nop, spoc_type_poc, spoc_type_thr, op_schedule::stage, op_schedule::used, op_schedule::used_level, op_schedule::used_stage, vtxcontent_inputs, vtxcontent_optype, vtxcontent_out, and what_operation().
Referenced by freia_spoc_pipeline().
|
static |
Definition at line 66 of file freia_spoc.c.
Referenced by get_spoc_alu_conf().
current list of computable that may be used to know about the global context when comparing to vertices in "dagvtx_spoc_priority".
Definition at line 1724 of file freia_spoc.c.
Definition at line 1726 of file freia_spoc.c.