Skip to content

Commit a156c25

Browse files
committed
Backends: Unused per-context used_memory
1 parent 50afe3e commit a156c25

File tree

4 files changed

+26
-28
lines changed

4 files changed

+26
-28
lines changed

arrayjit/lib/backend_types.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ let _get_local_debug_runtime = Utils._get_local_debug_runtime
99

1010
module No_device_types = struct
1111
type ctx_array = Ndarray.t [@@deriving sexp_of]
12+
type ctx_arrays = { ctx_arrays : ctx_array Map.M(Tnode).t } [@@deriving sexp_of]
1213

13-
type ctx_arrays = { used_memory : Utils.atomic_int; ctx_arrays : ctx_array Map.M(Tnode).t }
14-
[@@deriving sexp_of]
15-
16-
let empty_ctx_arrays = { used_memory = Atomic.make 0; ctx_arrays = Map.empty (module Tnode) }
14+
let empty_ctx_arrays = { ctx_arrays = Map.empty (module Tnode) }
1715
let get_array arrays = Map.find arrays.ctx_arrays
1816
end
1917

arrayjit/lib/backends.ml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,6 @@ module Multicore_backend (Backend : Backend_types.No_device_backend) = struct
9797
let sexp_of_task_queue q =
9898
Sexp.(List [ Atom "task_queue_of_size"; Atom (Int.to_string @@ Queue.size q) ])
9999

100-
type event = Not_implemented_yet (** TODO: NOT IMPLEMENTED YET *)
101-
102-
(** TODO: Blocks till the event completes, if it's not done already. *)
103-
let sync Not_implemented_yet = ()
104-
105-
(** TODO: Whether the event completed. *)
106-
let is_done Not_implemented_yet = true
107-
108-
(** TODO: If the tensor node is in the context, returns the event indicating if currently running
109-
or scheduled computations modifying that node on the context's stream have completed.
110-
111-
NOTE: [work_for ctx tn], if work tracking was not registered for [tn], will register work
112-
tracking for [tn] and return the event tracking all currently scheduled computations on
113-
[ctx]'s stream. *)
114-
let work_for _ctx _tn = Some Not_implemented_yet
115-
116-
(** TODO: Schedules waiting for the given event on the context's stream. *)
117-
let will_wait_for _ctx Not_implemented_yet = ()
118-
119100
type stream_state = {
120101
mutable keep_spinning : bool;
121102
mutable stream_error : exn option;
@@ -136,6 +117,25 @@ module Multicore_backend (Backend : Backend_types.No_device_backend) = struct
136117
}
137118
[@@deriving sexp_of]
138119

120+
type event = Not_implemented_yet
121+
122+
(** TODO: Blocks till the event completes, if it's not done already. *)
123+
let sync Not_implemented_yet = ()
124+
125+
(** TODO: Whether the event completed. *)
126+
let is_done Not_implemented_yet = true
127+
128+
(** TODO: If the tensor node is in the context, returns the event indicating if currently running
129+
or scheduled computations modifying that node on the context's stream have completed.
130+
131+
NOTE: [work_for ctx tn], if work tracking was not registered for [tn], will register work
132+
tracking for [tn] and return the event tracking all currently scheduled computations on
133+
[ctx]'s stream. *)
134+
let work_for _ctx _tn = Some Not_implemented_yet
135+
136+
(** TODO: Schedules waiting for the given event on the context's stream. *)
137+
let will_wait_for _ctx Not_implemented_yet = ()
138+
139139
let alloc_buffer ?old_buffer ~size_in_bytes _stream = alloc_buffer ?old_buffer ~size_in_bytes ()
140140
let get_used_memory _device = get_used_memory ()
141141

arrayjit/lib/cc_backend.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ let%diagn_sexp compile ~(name : string) ~opt_ctx_arrays bindings (lowered : Low_
137137
Ndarray.create_array ~debug (Lazy.force tn.Tn.prec) ~dims:(Lazy.force tn.dims)
138138
@@ Constant_fill { values = [| 0. |]; strict = false }
139139
in
140-
{ ctx_arrays with ctx_arrays = Map.add_exn ctx_arrays.ctx_arrays ~key:tn ~data }
140+
{ ctx_arrays = Map.add_exn ctx_arrays.ctx_arrays ~key:tn ~data }
141141
else ctx_arrays
142142
| Some _ -> ctx_arrays))
143143
in
@@ -176,7 +176,7 @@ let%diagn_sexp compile_batch ~names ~opt_ctx_arrays bindings
176176
else ctx_arrays
177177
| Some _ -> ctx_arrays))
178178
in
179-
{ arrays with ctx_arrays })
179+
{ ctx_arrays })
180180
in
181181
let module Syntax = C_syntax.C_syntax (C_syntax_config (struct
182182
let for_lowereds = for_lowereds
@@ -231,7 +231,7 @@ let%diagn_sexp link_compiled ~merge_buffer (prior_context : context) (code : pro
231231
Ndarray.create_array ~debug (Lazy.force tn.Tn.prec) ~dims:(Lazy.force tn.dims)
232232
@@ Constant_fill { values = [| 0. |]; strict = false }
233233
in
234-
{ ctx_arrays with ctx_arrays = Map.update ctx_arrays.ctx_arrays tn ~f }
234+
{ ctx_arrays = Map.update ctx_arrays.ctx_arrays tn ~f }
235235
| _ -> ctx_arrays)
236236
in
237237
let context = { label; arrays } in

arrayjit/lib/gcc_backend.gccjit.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ let%diagn_sexp compile_proc ~name ~opt_ctx_arrays ctx bindings ~get_ident
697697
let opt_ctx_arrays =
698698
match (opt_ctx_arrays, ctx_nodes) with
699699
| None, _ | _, Param_ptrs _ -> None
700-
| Some arrays, Ctx_arrays { contents } -> Some { arrays with ctx_arrays = contents }
700+
| Some _arrays, Ctx_arrays { contents } -> Some { ctx_arrays = contents }
701701
in
702702
(ctx_info, opt_ctx_arrays, params)
703703

@@ -786,7 +786,7 @@ let%diagn_sexp link_compiled ~merge_buffer (prior_context : context) (code : pro
786786
| _ -> arrays)
787787
in
788788
let context =
789-
{ label; arrays = { prior_context.arrays with ctx_arrays }; result = Some code.result }
789+
{ label; arrays = { ctx_arrays }; result = Some code.result }
790790
in
791791
let log_file_name = Utils.diagn_log_file [%string "debug-%{label}-%{code.name}.log"] in
792792
let run_variadic =

0 commit comments

Comments
 (0)