@@ -42,6 +42,13 @@ type settings = {
4242 mutable check_half_prec_constants_cutoff : float option ;
4343 (* * If given, generic code optimization should fail if a half precision FP16 constant exceeds
4444 the cutoff. *)
45+ mutable automatic_host_transfers : bool ;
46+ (* * If true, [from_host] and [to_host] happen automatically in specific situations.
47+ - When a host array is about to be read, we transfer to host from the context that most
48+ recently updated the node.
49+ - When a routine is about to be run, we transfer the routine's inputs from host to the
50+ routine's context if the host array was not yet transfered since its creation or most
51+ recent modification. *)
4552}
4653[@@ deriving sexp ]
4754
@@ -53,6 +60,7 @@ let settings =
5360 fixed_state_for_init = None ;
5461 print_decimals_precision = 2 ;
5562 check_half_prec_constants_cutoff = Some (2. **. 14. );
63+ automatic_host_transfers = true ;
5664 }
5765
5866let accessed_global_args = Hash_set. create (module String )
@@ -364,7 +372,9 @@ let restore_settings () =
364372 Int. of_string @@ get_global_arg ~arg_name: " print_decimals_precision" ~default: " 2" ;
365373 settings.check_half_prec_constants_cutoff < -
366374 Float. of_string_opt
367- @@ get_global_arg ~arg_name: " check_half_prec_constants_cutoff" ~default: " 16384.0"
375+ @@ get_global_arg ~arg_name: " check_half_prec_constants_cutoff" ~default: " 16384.0" ;
376+ settings.automatic_host_transfers < -
377+ Bool. of_string @@ get_global_arg ~arg_name: " automatic_host_transfers" ~default: " true"
368378
369379let () = restore_settings ()
370380let with_runtime_debug () = settings.output_debug_files_in_build_directory && settings.log_level > 1
0 commit comments