Skip to content

Commit a318600

Browse files
committed
A small thing
1 parent 30d7be0 commit a318600

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arrayjit/lib/backends.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,18 @@ module Add_buffer_retrieval_and_syncing (Backend : No_buffer_retrieval_or_syncin
3434
match (tn, Map.find ctx.ctx_arrays tn) with
3535
| { Tn.array = (lazy (Some hosted)); _ }, Some dst ->
3636
[%log "copying", Tn.debug_name tn, "to", (dst : Backend.buffer_ptr), "from host"];
37+
let s = ctx.stream in
38+
(* Wait for readers of the array before copying, if any are recorded. FIXME: this is
39+
invalid. *)
40+
Hashtbl.find s.device.stream_working_on tn
41+
|> Option.join
42+
|> Option.iter ~f:(fun (_work_stream_id, e) -> Backend.will_wait_for ctx e);
3743
Backend.from_host ~dst_ptr:dst ~dst:ctx hosted;
44+
(* Update the latest work event for the node. *)
45+
if Hashtbl.mem s.queried_work_for tn then (
46+
let e = Backend.all_work s in
47+
Hashtbl.update s.device.stream_working_on tn ~f:(fun _ -> Some (s.stream_id, e));
48+
Hashtbl.update s.queried_work_for tn ~f:(fun _ -> Some e));
3849
true
3950
| _ -> false
4051

0 commit comments

Comments
 (0)