Skip to content
Snippets Groups Projects
Commit 579961d8 authored by Fort Frédéric's avatar Fort Frédéric
Browse files

Instance counting variable is now only generated when needed.

git-svn-id: https://svn.onera.fr/Prelude/Prelude/trunk@864 49f62630-d767-4ccd-930e-b3f5589f52e1
parent f25e9f70
Branches
Tags
No related merge requests found
......@@ -69,6 +69,14 @@ let pp_init_array out_f printer array =
Print.list_printer_from_printer "" "@ " "@ "
(fun out_f (v,repeat) -> pp_array_slice printer out_f (v,repeat)) out_f col_array
let any_uses_read_proto inputs = List.exists (fun (_,_,x) -> uses_read_protocol x) inputs
let any_uses_write_proto outputs =
List.exists
(fun (_,x) -> uses_write_protocol x)
(List.concat ((List.map (fun (_,x) -> x)) outputs)) ||
Options.trace_instances ()
(** Generates the initialization function for the buffer of
communication [vref_from->vref_to]. For multi-core architectures. *)
let pp_buffer_init_fun out_f task ty read_proto vref_from vref_to =
......@@ -475,6 +483,9 @@ let pp_task_body out_f types_f task =
C_buffers.pp_lwrite_allocs_task out_f types_f task false;
List.iter (pp_read_idx out_f) task.task_inputs;
List.iter (pp_write_idx out_f) task.task_outputs;
(* if any task uses protocol in ntask.task_inputs @ task.task_outputs *)
let needs_instance_var = any_uses_read_proto task.task_inputs || any_uses_write_proto task.task_outputs in
if needs_instance_var then
fprintf out_f "static int %s=0;@ @ " inst_cpt_name;
C_traces.pp_trace_buf_alloc out_f task;
......@@ -500,6 +511,7 @@ let pp_task_body out_f types_f task =
(* Update outputs *)
List.iter (pp_lwrite_updates out_f task) task.task_outputs;
if needs_instance_var then
fprintf out_f "@ %s++;@ @ " inst_cpt_name;
fprintf out_f "return 0;";
......@@ -517,10 +529,13 @@ let pp_task_A out_f task =
fprintf out_f "int %s(void* args)@ "(fun_name_A task.task_id);
fprintf out_f "@[<v 2>{@ ";
let uses_protocol = any_uses_read_proto task.task_inputs in
List.iter (pp_read_idx out_f) task.task_inputs;
if uses_protocol then
fprintf out_f "static int %s=0;@ @ " inst_cpt_name;
List.iter (pp_lread_copy_extern out_f task) task.task_inputs;
List.iter (pp_read_cell_update out_f task.task_id) task.task_inputs;
if uses_protocol then
fprintf out_f "%s++;@ @ " inst_cpt_name;
fprintf out_f "return 0;";
......@@ -541,9 +556,12 @@ let pp_task_R out_f task =
fprintf out_f "int %s(void* args)@ "(fun_name_R task.task_id);
fprintf out_f "@[<v 2>{@ ";
let uses_protocol = any_uses_write_proto task.task_outputs in
List.iter (pp_write_idx out_f) task.task_outputs;
if uses_protocol then
fprintf out_f "static int %s=0;@ @ " inst_cpt_name;
List.iter (pp_lwrite_updates out_f task) task.task_outputs;
if uses_protocol then
fprintf out_f "%s++;@ @ " inst_cpt_name;
fprintf out_f "return 0;";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment