Skip to content

Commit 451f36e

Browse files
committed
Add new configuration options for diffing runs debug settings
- Introduced `diff_max_distance_factor` and `debug_entry_id_pairs` in `ocannl_config.example` for enhanced diffing capabilities. - Updated `get_debug` function in `utils.ml` to utilize the new configuration options. - Modified `primitive_ops.ml` to include debug runtime settings. Signed-off-by: lukstafi <lukstafi@users.noreply.github.com>
1 parent d1038f8 commit 451f36e

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

arrayjit/lib/utils.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,21 @@ let get_debug name =
330330
let diff_ignore_pattern =
331331
str_nonempty ~f:Re.Pcre.re @@ get_global_arg ~default:"" ~arg_name:"diff_ignore_pattern_pcre"
332332
in
333+
let max_distance_factor =
334+
str_nonempty ~f:Int.of_string @@ get_global_arg ~default:"" ~arg_name:"diff_max_distance_factor"
335+
in
336+
let entry_id_pairs =
337+
let pairs_str = get_global_arg ~default:"" ~arg_name:"debug_entry_id_pairs" in
338+
if String.is_empty pairs_str then []
339+
else
340+
String.split pairs_str ~on:';'
341+
|> List.filter_map ~f:(fun pair_str ->
342+
match String.split pair_str ~on:',' with
343+
| [ id1; id2 ] ->
344+
Option.try_with (fun () ->
345+
(Int.of_string (String.strip id1), Int.of_string (String.strip id2)))
346+
| _ -> None)
347+
in
333348
if flushing then
334349
Minidebug_runtime.debug_flushing ?filename ~time_tagged ~elapsed_times ~print_entry_ids
335350
~verbose_entry_ids ~global_prefix:name ~for_append:false ~log_level:original_log_level ()
@@ -350,7 +365,7 @@ let get_debug name =
350365
~hyperlink ~toc_specific_hyperlink:"" ~highlight_terms
351366
~exclude_on_path:Re.(str "env")
352367
~backend ~log_level:original_log_level ?snapshot_every_sec ?prev_run_file
353-
?diff_ignore_pattern filename
368+
?diff_ignore_pattern ?max_distance_factor ~entry_id_pairs filename
354369

355370
let _get_local_debug_runtime =
356371
let open Stdlib.Domain in

bin/primitive_ops.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ module Rand = Arrayjit.Rand.Lib
1010

1111
module type Backend = Arrayjit.Backend_intf.Backend
1212

13-
let graph_t () =
13+
module Debug_runtime = Utils.Debug_runtime
14+
15+
let _get_local_debug_runtime = Utils._get_local_debug_runtime
16+
17+
[%%global_debug_log_level 9]
18+
[%%global_debug_log_level_from_env_var "OCANNL_LOG_LEVEL"]
19+
20+
let%debug_sexp graph_t () : unit =
1421
Tensor.unsafe_reinitialize ();
1522
Rand.init 0;
1623
let module Backend = (val Arrayjit.Backends.fresh_backend ()) in

ocannl_config.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,10 @@ prev_run_prefix=
142142
# For ppx_minidebug: a pcre syntax regular expression pattern that will be removed from messages
143143
# before comparison when highlighting differences between runs, allowing certain differences to be ignored.
144144
diff_ignore_pattern_pcre=
145+
146+
# For ppx_minidebug: (minimal) width of the search band for the minimal edit distance algorithm.
147+
diff_max_distance_factor=
148+
149+
# For ppx_minidebug: semicolon-separated list of comma-separated entry IDs from
150+
# the previous and current run, that should be considered the same by the diffing algorithm.
151+
debug_entry_id_pairs=

0 commit comments

Comments
 (0)