PIPS
freia_sigmac.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <ctype.h>
#include "genC.h"
#include "misc.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "properties.h"
#include "freia.h"
#include "hwac.h"
#include "freia_sigmac.h"
+ Include dependency graph for freia_sigmac.c:

Go to the source code of this file.

Macros

#define SIGMAC_INSTANTIATE(a, b)   " agent " a " = new " b ";\n"
 
#define SIGMAC_CONNECT(a, b)   " connect (" a ", " b ");\n"
 
#define REPLICATION_AGENT   "rep"
 
#define SIGMAC_HELPER   "freia_mppa_launch"
 
#define N_PREDEFINED_CONTROLLERS   5
 
#define MAIN_PATH   "cd .. && ./main"
 

Functions

static void sigmac_name_instances (dag dg, hash_table htid)
 Populates the hash table htid: one dagvtx is linked to an unique id depending on its freia_api_t. More...
 
static string sc_vtx_tostring (const dagvtx v, const hash_table htid)
 Generate a unique string per dagvtx consisting in. More...
 
static bool is_param_dynamic (expression arg)
 Determine if an argument contains references to other variables (dirty hack based on isalpha) More...
 
static bool has_vtx_dynamic_params (dagvtx v)
 Determine if a dagvtx has at least one dynamic parameter. More...
 
static list sc_get_params_values (dagvtx vtx, hash_table hparams, int *nparams)
 Returns a list of values of one dagvtx misc input parameters. More...
 
static bool sc_print_kernel (string_buffer sb_par, dagvtx v)
 Print the value of a morphological kernel extracted from a dagvtx. More...
 
static bool sc_kernel_compute_loop (string_buffer sb_morpho, const dagvtx vtx, string kname)
 Print a kernel customized inner loop from a morphological kernel. More...
 
static void sc_kernel_specific_agent (string_buffer sb_morpho, hash_table hparams, const dag dg)
 
static void sigmac_params_decl (string_buffer sb_par, dag dg, hash_table hparams, int *pnparams)
 Generates the constant parameters declaration. More...
 
static void sc_inst (string_buffer sb, const dagvtx v, const hash_table htid, const hash_table hparams, string miscparams, bool is_dynamic)
 Generate the instanciation of an agent in the forme "agent instname = new agentname (parameters)". More...
 
static int sc_get_port_id (dagvtx current_vtx, dagvtx succ, dag dg)
 Helper function determine the input port of the succ dagvtx to be connected to the output port of current_vtx dagvtx succ must be in dagvtx_succs(current_vtx) More...
 
static void sc_delimiter (string_buffer sb, const string title)
 Generate a 3 lines commented code delimiter with a centered title. More...
 

Variables

static int n_dags = 0
 

Macro Definition Documentation

◆ MAIN_PATH

#define MAIN_PATH   "cd .. && ./main"

◆ N_PREDEFINED_CONTROLLERS

#define N_PREDEFINED_CONTROLLERS   5

◆ REPLICATION_AGENT

#define REPLICATION_AGENT   "rep"

Definition at line 53 of file freia_sigmac.c.

◆ SIGMAC_CONNECT

#define SIGMAC_CONNECT (   a,
 
)    " connect (" a ", " b ");\n"

Definition at line 52 of file freia_sigmac.c.

◆ SIGMAC_HELPER

#define SIGMAC_HELPER   "freia_mppa_launch"

◆ SIGMAC_INSTANTIATE

#define SIGMAC_INSTANTIATE (   a,
 
)    " agent " a " = new " b ";\n"

Definition at line 51 of file freia_sigmac.c.

Function Documentation

◆ has_vtx_dynamic_params()

static bool has_vtx_dynamic_params ( dagvtx  v)
static

Determine if a dagvtx has at least one dynamic parameter.

Definition at line 113 of file freia_sigmac.c.

113  {
114  const freia_api_t *f = get_freia_api_vtx(v);
115  if (!f)
116  return false;
117  if (strstr(f->function_name, "_const") || dagvtx_optype(v) == spoc_type_thr) {
118  list vtx_params = freia_get_vertex_params(v);
119  FOREACH(expression, arg, vtx_params) {
120  if (is_param_dynamic(arg))
121  return true;
122  }
123  }
124  return false;
125 }
_int dagvtx_optype(const dagvtx v)
Definition: dag-utils.c:116
list freia_get_vertex_params(const dagvtx v)
Definition: freia-utils.c:578
const freia_api_t * get_freia_api_vtx(dagvtx v)
Definition: freia-utils.c:483
static bool is_param_dynamic(expression arg)
Determine if an argument contains references to other variables (dirty hack based on isalpha)
Definition: freia_sigmac.c:101
@ spoc_type_thr
Definition: freia_spoc.h:178
#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
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
FREIA API function name -> SPoC hardware description (and others?)
Definition: freia.h:71

References dagvtx_optype(), f(), FOREACH, freia_get_vertex_params(), get_freia_api_vtx(), is_param_dynamic(), and spoc_type_thr.

Referenced by sc_delimiter(), and sigmac_params_decl().

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

◆ is_param_dynamic()

static bool is_param_dynamic ( expression  arg)
static

Determine if an argument contains references to other variables (dirty hack based on isalpha)

Definition at line 101 of file freia_sigmac.c.

101  {
102  string s = expression_to_string(arg);
103  bool is_dyn = false;
104  unsigned int i;
105  for (i = 0; i < strlen(s); i++)
106  if (isalpha(s[i]))
107  is_dyn = true;
108  return is_dyn;
109 }
string expression_to_string(expression e)
Definition: expression.c:77

References expression_to_string().

Referenced by has_vtx_dynamic_params(), and sc_delimiter().

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

◆ sc_delimiter()

static void sc_delimiter ( string_buffer  sb,
const string  title 
)
static

Generate a 3 lines commented code delimiter with a centered title.

); int a = (columns - l - 2) / 2; for (i = 0; i < a; i++) sb_cat(sb, "#"); if (!(l % 2)) sb_cat(sb, " ", title, " #"); else sb_cat(sb, " ", title, " "); for (i = 0; i < a; i++) sb_cat(sb, "#"); sb_cat(sb, "

); for (i = 0; i < columns; i++) sb_cat(sb, "#"); sb_cat(sb, "

If vtx is compound, returns the id of correspondant connected component. Else returns -1.

Main loop looping over the list of vertices of the given dag

call this helper for dag d ??? currently non constant parameters are NOT handled at all.

we generate an application subgraph with 4 pipes for every independant dag

Generate a root subgraph (equivalent of the main function) which initialize the image data and calls the application subgraphs

two i/o pipes for each predefined controller and four for each dag (2 for images i/o, 2 for parameters i/o)

we only need one instance of the following agents because several commands can be sent throughout the same pipe

Definition at line 351 of file freia_sigmac.c.

References _intFMT, freia_api_t::arg_misc_in, cat, CONS, dag_dot_dump_prefix(), dag_dump(), dag_fix_image_reuse(), dag_inputs, dag_no_image_operation(), dag_outputs, dag_split_on_scalars(), dag_statements(), dag_vertex_preds(), dag_vertices, dagvtx_image(), dagvtx_is_measurement_p(), dagvtx_nb_dump(), dagvtx_number(), dagvtx_operation(), dagvtx_opid(), dagvtx_optype(), dagvtx_statement(), dagvtx_succs, dg, entity_to_expression(), entity_undefined_p, expression_domain, expression_to_string(), f(), FOREACH, fprintf(), free(), freia_allocate_new_images_if_needed(), freia_create_helper_function(), freia_dag_optimize(), freia_get_vertex_params(), freia_insert_added_stats(), freia_migrate_statements(), freia_ok(), freia_sigmac_compile_calls(), FREIA_SIGMAC_SC_INCLUDES, gen_free_list(), gen_full_copy_list(), gen_in_list_p(), gen_length(), gen_make_list(), gen_nconc(), gen_nreverse(), gen_nth(), gen_position(), get_bool_property(), get_freia_api_vtx(), get_int_property(), has_vtx_dynamic_params(), HASH_FOREACH, hash_pointer, hash_put(), hash_table_free(), hash_table_make(), HELPER, helper_file_name(), hwac_replace_statement(), i2a(), init, input(), sigmac_hw_t::inst_prefix, int, int_to_expression(), is_param_dynamic(), LIST, local_name_to_top_level_entity(), MAIN_PATH, make_call(), sigmac_hw_t::mergeable, module, n_dags, N_PREDEFINED_CONTROLLERS, NIL, out, PARAM_T, pips_assert, pips_debug, PIXEL_T, REPLICATION_AGENT, safe_fopen(), same_string_p, sb_cat, sb_prf, sc_get_params_values(), sc_get_port_id(), sc_inst(), sc_kernel_specific_agent(), sc_vtx_tostring(), set_add_element(), set_belong_p(), set_free(), set_make(), set_pointer, set_size(), set_union(), freia_api_t::sigmac, SIGMAC_CONNECT, SIGMAC_HELPER, SIGMAC_INSTANTIATE, sigmac_name_instances(), sigmac_params_decl(), spoc_type_thr, strdup(), string_buffer_empty_p(), string_buffer_free(), string_buffer_make(), string_buffer_reset(), string_buffer_to_file(), string_buffer_to_string(), string_buffer_to_string_reverse(), and strupper().

◆ sc_get_params_values()

static list sc_get_params_values ( dagvtx  vtx,
hash_table  hparams,
int nparams 
)
static

Returns a list of values of one dagvtx misc input parameters.

Definition at line 130 of file freia_sigmac.c.

130  {
131  vtxcontent vtc = dagvtx_content(vtx);
133  call c = freia_statement_to_call(stm);
134 
135  // list of misc param values
136  return freia_extract_params(dagvtx_opid(vtx), call_arguments(c), NULL, NULL,
137  hparams, nparams);
138 }
_int dagvtx_opid(const dagvtx v)
Definition: dag-utils.c:121
list freia_extract_params(const int napi, list args, string_buffer head, string_buffer head2, hash_table params, int *nparams)
returns an allocated expression list of the parameters only (i.e.
Definition: freia-utils.c:613
call freia_statement_to_call(const statement s)
return the actual function call from a statement, dealing with assign and returns....
Definition: freia-utils.c:973
#define dagvtx_content(x)
#define pstatement_statement(x)
#define vtxcontent_source(x)
#define call_arguments(x)
Definition: ri.h:711

References call_arguments, dagvtx_content, dagvtx_opid(), freia_extract_params(), freia_statement_to_call(), pstatement_statement, and vtxcontent_source.

Referenced by sc_delimiter(), and sigmac_params_decl().

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

◆ sc_get_port_id()

static int sc_get_port_id ( dagvtx  current_vtx,
dagvtx  succ,
dag  dg 
)
static

Helper function determine the input port of the succ dagvtx to be connected to the output port of current_vtx dagvtx succ must be in dagvtx_succs(current_vtx)

Definition at line 344 of file freia_sigmac.c.

344  {
345  return gen_position(current_vtx, dag_vertex_preds(dg, succ)) - 1;
346 }
static graph dg
dg is the dependency graph ; FIXME : should not be static global ?
Definition: chains.c:124
list dag_vertex_preds(const dag d, const dagvtx target)
return target predecessor vertices as a list.
Definition: dag-utils.c:680
int gen_position(const void *item, const list l)
Element ranks are strictly positive as for first, second, and so on.
Definition: list.c:995

References dag_vertex_preds(), dg, and gen_position().

Referenced by sc_delimiter().

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

◆ sc_inst()

static void sc_inst ( string_buffer  sb,
const dagvtx  v,
const hash_table  htid,
const hash_table  hparams,
string  miscparams,
bool  is_dynamic 
)
static

Generate the instanciation of an agent in the forme "agent instname = new agentname (parameters)".

Definition at line 281 of file freia_sigmac.c.

283  {
284  const freia_api_t *f = get_freia_api_vtx(v);
285  string_buffer sbinst = string_buffer_make(true);
286 
287  // beginning of declaration
288  sb_cat(sbinst, f->sigmac.agent_name);
289 
290  if (is_dynamic)
291  sb_cat(sbinst, "_dyn");
292 
293  sb_prf(sbinst, "(%s", f->sigmac.agent_arg);
294 
295  // completing with misc arguments
296  if ((f->arg_misc_in + f->arg_misc_out) && hparams) {
297  if (is_dynamic)
298  sb_cat(sbinst, ", height");
299  else {
300  list largs = freia_get_vertex_params(v);
301  FOREACH(expression, arg, largs) {
302  sb_cat(sbinst, ", ", hash_get(hparams, arg));
303  if (freia_convolution_p(v))
304  break;
305  }
306  }
307  // add manually more arguments
308  if (miscparams)
309  sb_cat(sbinst, ", ", miscparams);
310  }
311  sb_cat(sbinst, ")");
312 
313  if (get_bool_property("HWAC_SIGMAC_SPECIFIC_MORPHO") &&
315 
316  string_buffer_reset(sbinst);
317  if (same_string_p(f->compact_name, "E8"))
318  sb_cat(sbinst, "erode_");
319  else if (same_string_p(f->compact_name, "D8"))
320  sb_cat(sbinst, "dilate_");
321  else if (same_string_p(f->compact_name, "conv"))
322  sb_cat(sbinst, "convole_");
323  list largs = freia_get_vertex_params(v);
324  FOREACH(expression, arg, largs) {
325  sb_prf(sbinst, "%s_%d(width, height", hash_get(hparams, arg), n_dags);
326  if (freia_convolution_p(v)) // convolution needs the kernel
327  sb_prf(sbinst, ", %s", hash_get(hparams, arg));
328  sb_prf(sbinst, ")");
329  break; // there is only 1 argument
330  }
331  }
332 
333  sb_prf(sb, SIGMAC_INSTANTIATE("%s", "%s"), sc_vtx_tostring(v, htid),
334  string_buffer_to_string(sbinst));
335 
336  string_buffer_free(&sbinst);
337 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
bool freia_convolution_p(dagvtx v)
is it the convolution special case?
Definition: freia-utils.c:1441
#define sb_prf(args...)
Definition: freia.h:43
#define sb_cat(args...)
Definition: freia.h:42
static int n_dags
Definition: freia_sigmac.c:56
#define SIGMAC_INSTANTIATE(a, b)
Definition: freia_sigmac.c:51
static string sc_vtx_tostring(const dagvtx v, const hash_table htid)
Generate a unique string per dagvtx consisting in.
Definition: freia_sigmac.c:92
@ spoc_type_poc
Definition: freia_spoc.h:176
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 same_string_p(s1, s2)
string string_buffer_to_string(const string_buffer)
return malloc'ed string from string buffer sb
void string_buffer_free(string_buffer *)
free string buffer structure, also free string contents according to the dup field
Definition: string_buffer.c:82
void string_buffer_reset(string_buffer)
remove stack contents
Definition: string_buffer.c:70
string_buffer string_buffer_make(bool dup)
allocate a new string buffer
Definition: string_buffer.c:58
internally defined structure.
Definition: string_buffer.c:47
Definition: statement.c:4047

References dagvtx_optype(), f(), FOREACH, freia_convolution_p(), freia_get_vertex_params(), get_bool_property(), get_freia_api_vtx(), hash_get(), n_dags, same_string_p, sb_cat, sb_prf, sc_vtx_tostring(), SIGMAC_INSTANTIATE, spoc_type_poc, string_buffer_free(), string_buffer_make(), string_buffer_reset(), and string_buffer_to_string().

Referenced by sc_delimiter().

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

◆ sc_kernel_compute_loop()

static bool sc_kernel_compute_loop ( string_buffer  sb_morpho,
const dagvtx  vtx,
string  kname 
)
static

Print a kernel customized inner loop from a morphological kernel.

Definition at line 157 of file freia_sigmac.c.

158  {
159  intptr_t k[9];
160 
161  if (dagvtx_optype(vtx) != spoc_type_poc)
162  return false;
163 
164  bool b = freia_extract_kernel_vtx(vtx, true, &k[0], &k[1], &k[2], &k[3],
165  &k[4], &k[5], &k[6], &k[7], &k[8]);
166 
167  string row[3] = {"olid", "clid", "ilid"};
168  int i, j;
169 
170  sb_prf(sb_morpho, "\n"
171  "#define %s_%d(OPR)\t\t\t\t\\\n",
172  kname, n_dags);
173  for (i = 0; i < 3; i++)
174  for (j = 0; j < 3; j++)
175  if (k[3 * i + j]) {
176  string neighbor = strdup(cat("buffer[", row[i], "][i+", i2a(j), "]"));
177  sb_prf(sb_morpho, "ret = PIXEL_ ## OPR(ret, %s);\t\\\n", neighbor,
178  neighbor);
179  }
180  sb_prf(sb_morpho, "\nCUSTOM_MORPHO_AGENT(%s_%d, " PIXEL_T ")\n"
181  "\n",
182  kname, n_dags);
183 
184  return b;
185 }
bool freia_extract_kernel_vtx(dagvtx v, bool strict, intptr_t *k00, intptr_t *k10, intptr_t *k20, intptr_t *k01, intptr_t *k11, intptr_t *k21, intptr_t *k02, intptr_t *k12, intptr_t *k22)
vertex-based version
Definition: freia-utils.c:2012
#define cat(args...)
Definition: freia.h:41
#define PIXEL_T
Definition: freia_sigmac.h:60
char * i2a(int)
I2A (Integer TO Ascii) yields a string for a given Integer.
Definition: string.c:121
char * strdup()
#define intptr_t
Definition: stdint.in.h:294

References cat, dagvtx_optype(), freia_extract_kernel_vtx(), i2a(), intptr_t, n_dags, PIXEL_T, sb_prf, spoc_type_poc, and strdup().

Referenced by sc_kernel_specific_agent().

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

◆ sc_kernel_specific_agent()

static void sc_kernel_specific_agent ( string_buffer  sb_morpho,
hash_table  hparams,
const dag  dg 
)
static

Definition at line 187 of file freia_sigmac.c.

188  {
189  list lparams = NIL;
190 
191  FOREACH(dagvtx, vtx, dag_vertices(dg)) {
192 
193  if (dagvtx_optype(vtx) != spoc_type_poc)
194  continue;
195 
196  list vtx_param_vars = freia_get_vertex_params(vtx);
197 
198  // tests if argument already declared
199  string parname =
200  (string)hash_get(hparams, EXPRESSION(gen_nth(0, vtx_param_vars)));
201  if (gen_in_list_p(parname, lparams))
202  continue;
203  lparams = CONS(string, parname, lparams);
204 
205  sc_kernel_compute_loop(sb_morpho, vtx, parname);
206  }
207 }
static bool sc_kernel_compute_loop(string_buffer sb_morpho, const dagvtx vtx, string kname)
Print a kernel customized inner loop from a morphological kernel.
Definition: freia_sigmac.c:157
#define dag_vertices(x)
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
char * string
STRING.
Definition: newgen_types.h:39
list lparams
Array bounds.
Definition: reindexing.c:111
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217

References CONS, dag_vertices, dagvtx_optype(), dg, EXPRESSION, FOREACH, freia_get_vertex_params(), gen_in_list_p(), gen_nth(), hash_get(), lparams, NIL, sc_kernel_compute_loop(), and spoc_type_poc.

Referenced by sc_delimiter().

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

◆ sc_print_kernel()

static bool sc_print_kernel ( string_buffer  sb_par,
dagvtx  v 
)
static

Print the value of a morphological kernel extracted from a dagvtx.

Definition at line 143 of file freia_sigmac.c.

143  {
144  intptr_t k[9];
145  bool b = freia_extract_kernel_vtx(v, true, &k[0], &k[1], &k[2], &k[3], &k[4],
146  &k[5], &k[6], &k[7], &k[8]);
147  sb_cat(sb_par, "{ ");
148  for (int i = 0; i < 8; i++)
149  sb_prf(sb_par, "%d, ", k[i]);
150  sb_prf(sb_par, "%d }", k[8]);
151  return b;
152 }

References freia_extract_kernel_vtx(), intptr_t, sb_cat, and sb_prf.

Referenced by sigmac_params_decl().

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

◆ sc_vtx_tostring()

static string sc_vtx_tostring ( const dagvtx  v,
const hash_table  htid 
)
static

Generate a unique string per dagvtx consisting in.

  • one short name, shared by all the dagvtx with the same freia_api_t
  • one integer, different for every dagvtx with the same freia_api_t

Definition at line 92 of file freia_sigmac.c.

92  {
93  string r = get_freia_api_vtx(v)->sigmac.inst_prefix;
94  _int n = (_int)hash_get(htid, v);
95  return strdup(cat(r, i2a(n)));
96 }
intptr_t _int
_INT
Definition: newgen_types.h:53
sigmac_hw_t sigmac
Definition: freia.h:92
string inst_prefix
Definition: freia_sigmac.h:52

References cat, get_freia_api_vtx(), hash_get(), i2a(), sigmac_hw_t::inst_prefix, freia_api_t::sigmac, and strdup().

Referenced by sc_delimiter(), and sc_inst().

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

◆ sigmac_name_instances()

static void sigmac_name_instances ( dag  dg,
hash_table  htid 
)
static

Populates the hash table htid: one dagvtx is linked to an unique id depending on its freia_api_t.

Definition at line 61 of file freia_sigmac.c.

61  {
62  _int nb_op;
63  const freia_api_t *f;
64 
65  // freia_api_t * -> number of encoutered vertices
67 
68  FOREACH(dagvtx, vtx, dag_vertices(dg)) {
69  f = get_freia_api_vtx(vtx);
70  if (!f)
71  continue;
72 
73  // initializating hash_table htinst
74  if (!hash_defined_p(htinst, f))
75  hash_put(htinst, f, (void *)(_int)0);
76 
77  // new instance id = total nb of instances of the same operation
78  nb_op = (_int)hash_get(htinst, f);
79  hash_put(htid, vtx, (void *)nb_op);
80  // updating nb of instances for current operation
81  nb_op++;
82  hash_update(htinst, f, (void *)nb_op);
83  }
84 
85  hash_table_free(htinst);
86 }
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
void hash_update(hash_table htp, const void *key, const void *val)
update key->val in htp, that MUST be pre-existent.
Definition: hash.c:491
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
bool hash_defined_p(const hash_table htp, const void *key)
true if key has e value in htp.
Definition: hash.c:484
@ hash_pointer
Definition: newgen_hash.h:32

References dag_vertices, dg, f(), FOREACH, get_freia_api_vtx(), hash_defined_p(), hash_get(), hash_pointer, hash_put(), hash_table_free(), hash_table_make(), and hash_update().

Referenced by sc_delimiter().

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

◆ sigmac_params_decl()

static void sigmac_params_decl ( string_buffer  sb_par,
dag  dg,
hash_table  hparams,
int pnparams 
)
static

Generates the constant parameters declaration.

Definition at line 211 of file freia_sigmac.c.

212  {
213  // dirty workaround preventing deblocking convolutions
214  // to declare several times the same parameter
215  list lparams = NIL;
216  FOREACH(dagvtx, vtx, dag_vertices(dg)) {
217 
219  continue;
220 
221  // list of misc param values
222  list vtx_param_vals = sc_get_params_values(vtx, hparams, pnparams);
223  // list of freia misc param names
224  list vtx_param_vars = freia_get_vertex_params(vtx);
225 
226 #ifdef DEBUG_INFO
227  const freia_api_t *f = get_freia_api_vtx(vtx);
228  sb_prf(sb_par, "// nb args for type %s : %d/%d, in %d, out %d\n",
229  f->sigmac.agent_name, gen_length(vtx_param_vals),
230  gen_length(vtx_param_vars), f->arg_misc_in, f->arg_misc_out);
231  FOREACH(expression, arg, vtx_param_vars) {
232  sb_prf(sb_par, "// %s\n", expression_to_string(arg));
233  }
234  FOREACH(expression, arg, vtx_param_vals) {
235  sb_prf(sb_par, "// %s\n", expression_to_string(arg));
236  }
237 #endif
238 
239  bool dynamic_agent = has_vtx_dynamic_params(vtx);
240 
241  // misc params declaration
242  unsigned int i = 0;
243  FOREACH(expression, arg, vtx_param_vals) {
244 
245  // tests if argument already declared
246  string parname =
247  (string)hash_get(hparams, EXPRESSION(gen_nth(i, vtx_param_vars)));
248  if (gen_in_list_p(parname, lparams))
249  continue;
250  lparams = CONS(string, parname, lparams);
251 
252  if (!dynamic_agent) {
253  // print parameter type (in SigmaC, everything is int16_t)
254  sb_cat(sb_par, " " PIXEL_T);
255 
256  // print parameter pips name
257  sb_prf(sb_par, " %s",
258  hash_get(hparams, EXPRESSION(gen_nth(i, vtx_param_vars))));
259 
260  // print parameter value
261  if (dagvtx_optype(vtx) == spoc_type_poc) {
262  // kernel vtx have only one misc parameter
263  sb_cat(sb_par, "[9]", " = ");
264  sc_print_kernel(sb_par, vtx); // get & print kernel
265  } else
266  sb_prf(sb_par, " = %s", expression_to_string(arg));
267 
268  sb_cat(sb_par, ";\n");
269 
270  if (freia_convolution_p(vtx))
271  break;
272  i++;
273  }
274  } // FOREACH(expression, arg, vtx_param_vals)
275  }
276 }
bool dagvtx_is_measurement_p(const dagvtx v)
returns whether the vertex is an image measurement operation.
Definition: dag-utils.c:623
static bool sc_print_kernel(string_buffer sb_par, dagvtx v)
Print the value of a morphological kernel extracted from a dagvtx.
Definition: freia_sigmac.c:143
static bool has_vtx_dynamic_params(dagvtx v)
Determine if a dagvtx has at least one dynamic parameter.
Definition: freia_sigmac.c:113
static list sc_get_params_values(dagvtx vtx, hash_table hparams, int *nparams)
Returns a list of values of one dagvtx misc input parameters.
Definition: freia_sigmac.c:130
#define dag_inputs(x)
size_t gen_length(const list l)
Definition: list.c:150

References CONS, dag_inputs, dag_vertices, dagvtx_is_measurement_p(), dagvtx_optype(), dg, EXPRESSION, expression_to_string(), f(), FOREACH, freia_convolution_p(), freia_get_vertex_params(), gen_in_list_p(), gen_length(), gen_nth(), get_freia_api_vtx(), has_vtx_dynamic_params(), hash_get(), lparams, NIL, PIXEL_T, sb_cat, sb_prf, sc_get_params_values(), sc_print_kernel(), and spoc_type_poc.

Referenced by sc_delimiter().

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

Variable Documentation

◆ n_dags