Skip to content

Commit 82564e4

Browse files
committed
Get rid of memset for now
1 parent fc24c2d commit 82564e4

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

arrayjit/lib/c_syntax.ml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ module C_syntax (B : C_syntax_config) = struct
6565

6666
let in_ctx tn = B.(Tn.is_in_context_force ~use_host_memory tn 46)
6767

68-
let pp_zero_out ppf tn =
69-
Stdlib.Format.fprintf ppf "@[<2>memset(%s, 0, %d);@]@ " (get_ident tn)
70-
@@ Lazy.force tn.size_in_bytes
71-
7268
let pp_include ppf s = Stdlib.Format.fprintf ppf "#include %s" s
7369

7470
open Indexing.Pp_helpers
@@ -98,7 +94,7 @@ module C_syntax (B : C_syntax_config) = struct
9894
let print_includes ppf =
9995
Stdlib.Format.(fprintf ppf {|@[<v 0>%a@,@,|} (pp_print_list pp_include) B.includes)
10096
101-
let compile_main ~traced_store ppf llc : unit =
97+
let compile_main ~traced_store:_ ppf llc : unit =
10298
let open Stdlib.Format in
10399
let visited = Hash_set.create (module Tn) in
104100
let rec pp_ll ppf c : unit =
@@ -121,9 +117,9 @@ module C_syntax (B : C_syntax_config) = struct
121117
pp_symbol i;
122118
fprintf ppf "%a@;<1 -2>}@]@," pp_ll body
123119
| Zero_out tn ->
124-
let traced = Low_level.(get_node traced_store tn) in
125-
(* The initialization will be emitted at the end of compile_proc. *)
126-
if Hash_set.mem visited tn then pp_zero_out ppf tn else assert traced.zero_initialized
120+
pp_ll ppf
121+
(Low_level.loop_over_dims (Lazy.force tn.dims) ~body:(fun idcs ->
122+
Set { tn; idcs; llv = Constant 0.0; debug = get_ident tn ^ " := 0" }))
127123
| Set { tn; idcs; llv; debug } ->
128124
Hash_set.add visited tn;
129125
let ident = get_ident tn in
@@ -326,9 +322,7 @@ module C_syntax (B : C_syntax_config) = struct
326322
(* We often don't know ahead of linking with relevant contexts what the stream sharing
327323
mode of the node will become. Conservatively, use passing as argument. *)
328324
if is_param then
329-
( B.typ_of_prec (Lazy.force tn.Tn.prec) ^ " *" ^ get_ident tn,
330-
Param_ptr tn )
331-
:: params
325+
(B.typ_of_prec (Lazy.force tn.Tn.prec) ^ " *" ^ get_ident tn, Param_ptr tn) :: params
332326
else params)
333327
in
334328
let idx_params =
@@ -406,8 +400,7 @@ module C_syntax (B : C_syntax_config) = struct
406400
fprintf ppf "%s %s[%d]%s;@ "
407401
(B.typ_of_prec @@ Lazy.force tn.prec)
408402
(get_ident tn) (Tn.num_elems tn)
409-
(if node.zero_initialized then " = {0}" else "")
410-
else if (not (Tn.is_virtual_force tn 333)) && node.zero_initialized then pp_zero_out ppf tn);
403+
(if node.zero_initialized then " = {0}" else ""));
411404
fprintf ppf "@,/* Main logic. */@ ";
412405
compile_main ~traced_store ppf llc;
413406
fprintf ppf "@;<0 -2>}@]@.";

0 commit comments

Comments
 (0)