@@ -180,7 +180,7 @@ module Multicore_backend (Backend : No_device_backend) : Backend = struct
180180 mut : (Mut .t [@ sexp.opaque]);
181181 host_wait_for_idle : (Stdlib.Condition .t [@ sexp.opaque]);
182182 dev_wait_for_work : (Stdlib.Condition .t [@ sexp.opaque]);
183- mutable is_idle : bool ;
183+ mutable is_ready : bool ;
184184 mutable host_is_waiting : bool ; (* * The host is waiting for this specific device. *)
185185 }
186186 [@@ deriving sexp_of ]
@@ -206,17 +206,17 @@ module Multicore_backend (Backend : No_device_backend) : Backend = struct
206206 let expected_merge_node (code : code ) = Backend. expected_merge_node code
207207 let expected_merge_nodes (codes : code_batch ) = Backend. expected_merge_nodes codes
208208 let is_dev_queue_empty state = Queue. size state.queue = 0
209- let is_idle device = is_dev_queue_empty device.state && device.state.is_idle
209+ let is_idle device = is_dev_queue_empty device.state && device.state.is_ready
210210 let name = " multicore " ^ Backend. name
211211
212212 let % track3_l_sexp await device =
213213 assert (Domain. is_main_domain () );
214214 let d = device.state in
215- if (not d. is_idle) && d.keep_spinning then (
215+ if (not @@ is_idle device ) && d.keep_spinning then (
216216 Mut. lock d.mut;
217- if (not d. is_idle) && d.keep_spinning then (
217+ if (not @@ is_idle device ) && d.keep_spinning then (
218218 d.host_is_waiting < - true ;
219- while (not d. is_idle) && d.keep_spinning do
219+ while (not @@ is_idle device ) && d.keep_spinning do
220220 Stdlib.Condition. wait d.host_wait_for_idle d.mut
221221 done ;
222222 d.host_is_waiting < - false );
@@ -234,7 +234,7 @@ module Multicore_backend (Backend : No_device_backend) : Backend = struct
234234 if not @@ Queue. try_push d.queue task then (
235235 await device;
236236 Queue. push_exn d.queue task);
237- if d.is_idle then (
237+ if d.is_ready then (
238238 Mut. lock d.mut;
239239 Stdlib.Condition. broadcast d.dev_wait_for_work;
240240 Mut. unlock d.mut)
@@ -249,25 +249,26 @@ module Multicore_backend (Backend : No_device_backend) : Backend = struct
249249 device_error = None ;
250250 queue = Queue. create ~size_exponent: 12 ;
251251 mut = Mut. create () ;
252- is_idle = false ;
252+ is_ready = false ;
253253 host_wait_for_idle = Stdlib.Condition. create () ;
254254 dev_wait_for_work = Stdlib.Condition. create () ;
255255 host_is_waiting = false ;
256256 }
257257 in
258258 let % track3_l_sexp worker (() : unit ) : unit =
259+ assert (not @@ Domain. is_main_domain () );
259260 try
260261 while state.keep_spinning do
261262 match Queue. pop_opt state.queue with
262263 | None ->
263264 Mut. lock state.mut;
264265 if is_dev_queue_empty state && state.keep_spinning then (
265- state.is_idle < - true ;
266+ state.is_ready < - true ;
266267 while is_dev_queue_empty state && state.keep_spinning do
267268 if state.host_is_waiting then Stdlib.Condition. broadcast state.host_wait_for_idle;
268269 Stdlib.Condition. wait state.dev_wait_for_work state.mut
269270 done ;
270- state.is_idle < - false );
271+ state.is_ready < - false );
271272 Mut. unlock state.mut
272273 | Some task -> Tnode. run task
273274 done
0 commit comments