Skip to content

Commit 1327931

Browse files
committed
Fix logging from routines for vectorized ops
Signed-off-by: Lukasz Stafiniak <lukstafi@gmail.com>
1 parent 1d51aab commit 1327931

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

arrayjit/lib/c_syntax.ml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,11 @@ module C_syntax (B : C_syntax_config) = struct
649649
(* Generate the function call *)
650650
let result_doc = B.vec_unop_syntax prec vec_unop arg_doc in
651651
(* Generate assignments for each output element *)
652+
let open PPrint in
653+
let vec_var = string "vec_result" in
654+
let vec_typ = string (B.vec_typ_of_prec ~length prec) in
655+
let vec_decl = vec_typ ^^ space ^^ vec_var ^^ string " = " ^^ result_doc ^^ semi in
652656
let assignments =
653-
let open PPrint in
654-
let vec_var = string "vec_result" in
655-
let vec_typ = string (B.vec_typ_of_prec ~length prec) in
656-
let vec_decl = vec_typ ^^ space ^^ vec_var ^^ string " = " ^^ result_doc ^^ semi in
657657
let elem_assigns =
658658
List.init length ~f:(fun i ->
659659
let offset_doc =
@@ -671,7 +671,7 @@ module C_syntax (B : C_syntax_config) = struct
671671
^^ string (".v[" ^ Int.to_string i ^ "]")
672672
^^ semi)
673673
in
674-
vec_decl ^^ hardline ^^ separate hardline elem_assigns
674+
separate hardline elem_assigns
675675
in
676676
if Utils.debug_log_from_routines () then
677677
let open PPrint in
@@ -714,13 +714,15 @@ module C_syntax (B : C_syntax_config) = struct
714714
comment_log ^^ hardline ^^ separate hardline value_logs ^^ hardline ^^ flush_log
715715
in
716716
let block_content =
717-
if PPrint.is_empty local_defs then assignments ^^ hardline ^^ log_docs
718-
else local_defs ^^ hardline ^^ assignments ^^ hardline ^^ log_docs
717+
if PPrint.is_empty local_defs then
718+
vec_decl ^^ hardline ^^ log_docs ^^ hardline ^^ assignments
719+
else
720+
local_defs ^^ hardline ^^ vec_decl ^^ hardline ^^ log_docs ^^ hardline ^^ assignments
719721
in
720722
lbrace ^^ nest 2 (hardline ^^ block_content) ^^ hardline ^^ rbrace
721-
else if PPrint.is_empty local_defs then assignments
723+
else if PPrint.is_empty local_defs then vec_decl ^^ hardline ^^ assignments
722724
else
723-
let block_content = local_defs ^^ hardline ^^ assignments in
725+
let block_content = local_defs ^^ hardline ^^ vec_decl ^^ hardline ^^ assignments in
724726
lbrace ^^ nest 2 (hardline ^^ block_content) ^^ hardline ^^ rbrace
725727
| Set_local (({ tn = { prec; _ }; _ } as id), value) ->
726728
let local_defs, value_doc = pp_scalar (Lazy.force prec) value in

0 commit comments

Comments
 (0)