Skip to content

Commit 2c2690b

Browse files
committed
In progress: getting kernel logging to work again on the cuda backend
Signed-off-by: lukstafi <lukstafi@users.noreply.github.com>
1 parent 0c149bf commit 2c2690b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

arrayjit/lib/cuda_backend.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,12 @@ end) : Ir.Backend_impl.Lowered_backend = struct
264264

265265
let use_host_memory = None
266266
let procs = Input.procs
267+
267268
let full_printf_support =
268269
not @@ Bool.of_string
269270
@@ Utils.get_global_arg ~default:"false" ~arg_name:"prefer_backend_uniformity"
270271
end)
271272

272-
let logs_to_stdout = true
273273
let main_kernel_prefix = "extern \"C\" __global__"
274274

275275
let kernel_prep_line =
@@ -450,7 +450,7 @@ end) : Ir.Backend_impl.Lowered_backend = struct
450450
let open PPrint in
451451
let format_string_literal =
452452
!Utils.captured_log_prefix ^ "%d: "
453-
^ String.substr_replace_all base_message_literal ~pattern:"\n" ~with_:"$"
453+
^ String.substr_replace_all base_message_literal ~pattern:"\n" ~with_:"$" ^ "\\n"
454454
in
455455
let all_args =
456456
match log_param_c_expr_doc with
@@ -568,7 +568,6 @@ end) : Ir.Backend_impl.Lowered_backend = struct
568568
[%log "launching the kernel"];
569569
(* Stdio.printf "launching %s\n" name; *)
570570
(if Utils.debug_log_from_routines () then
571-
(* FIXME: this needs to use Utils.log_debug_routine_logs. *)
572571
Utils.add_log_processor ~prefix:log_id_prefix @@ fun log_contents ->
573572
Utils.log_debug_routine_logs ~log_contents ~stream_name);
574573
S.launch_kernel func ~grid_dim_x:1 ~block_dim_x:1 ~shared_mem_bytes:0 stream.runner args;

test/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"--ocannl_debug_log_to_stream_files=true")))
4141

4242
(rule
43+
(deps "log_files/%{read:config/ocannl_backend.txt}-0-0.log")
4344
(target "%{read:config/ocannl_backend.txt}-0-0.log.actual")
4445
(action
4546
(progn

test/micrograd_demo_logging.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ let () =
3232
List.iter ~f:(Option.iter ~f:(fun diff -> Train.set_hosted diff.Tensor.grad)) [ a.diff; b.diff ];
3333
let update = Train.grad_update g in
3434
let step = Train.to_routine (module Backend) ctx IDX.empty update.fwd_bprop in
35+
Utils.capture_stdout_logs @@ fun () ->
3536
Train.run step;
3637
Tensor.print ~with_code:false ~with_grad:false `Default g;
3738
Tensor.print ~with_code:false ~with_grad:true `Default a;
38-
Tensor.print ~with_code:false ~with_grad:true `Default b
39+
Tensor.print ~with_code:false ~with_grad:true `Default b

0 commit comments

Comments
 (0)