aboutsummaryrefslogtreecommitdiffstats
path: root/backend
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2021-04-13 17:17:15 +0200
committerCyril SIX <cyril.six@kalray.eu>2021-04-13 17:17:15 +0200
commit4b61b0985faecdf9c3f873b965bfb207acfc0150 (patch)
tree1d0b751e3e893db8bcece9138e372a8cd5948f77 /backend
parent5500fccca01d097f70a5cc708daf07395626fd6b (diff)
downloadcompcert-kvx-4b61b0985faecdf9c3f873b965bfb207acfc0150.tar.gz
compcert-kvx-4b61b0985faecdf9c3f873b965bfb207acfc0150.zip
Adding more precise heuristic measures
Diffstat (limited to 'backend')
-rw-r--r--backend/Duplicateaux.ml64
1 files changed, 62 insertions, 2 deletions
diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml
index c8690d46..1f1ebe9f 100644
--- a/backend/Duplicateaux.ml
+++ b/backend/Duplicateaux.ml
@@ -44,12 +44,35 @@ let stats_nb_missed_opportunities = ref 0
(* we predicted something (say Some true) but the profiling preferred not to predict anything (None) *)
let stats_nb_overpredict = ref 0
+(* heuristic specific counters *)
+let wrong_opcode = ref 0
+let wrong_return = ref 0
+let wrong_loop2 = ref 0
+let wrong_loop = ref 0
+let wrong_call = ref 0
+
+let right_opcode = ref 0
+let right_return = ref 0
+let right_loop2 = ref 0
+let right_loop = ref 0
+let right_call = ref 0
+
let reset_stats () = begin
stats_nb_total := 0;
stats_nb_correct_predicts := 0;
stats_nb_mispredicts := 0;
stats_nb_missed_opportunities := 0;
stats_nb_overpredict := 0;
+ wrong_opcode := 0;
+ wrong_return := 0;
+ wrong_loop2 := 0;
+ wrong_loop := 0;
+ wrong_call := 0;
+ right_opcode := 0;
+ right_return := 0;
+ right_loop2 := 0;
+ right_loop := 0;
+ right_call := 0;
end
let incr theref = theref := !theref + 1
@@ -62,7 +85,12 @@ let write_stats_oc () =
match !stats_oc with
| None -> ()
| Some oc -> begin
- Printf.fprintf oc "%d %d %d %d %d\n" !stats_nb_total !stats_nb_correct_predicts !stats_nb_mispredicts !stats_nb_missed_opportunities !stats_nb_overpredict;
+ Printf.fprintf oc "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n" !stats_nb_total
+ !stats_nb_correct_predicts !stats_nb_mispredicts !stats_nb_missed_opportunities
+ !stats_nb_overpredict
+ !wrong_opcode !wrong_return !wrong_loop2 !wrong_loop !wrong_call
+ !right_opcode !right_return !right_loop2 !right_loop !right_call
+ ;
close_out oc
end
@@ -446,11 +474,43 @@ let get_directions f code entrypoint = begin
do_return_heuristic; do_loop2_heuristic loop_info n; do_loop_heuristic; do_call_heuristic;
(* do_store_heuristic *) ] in
let preferred = ref None in
+ let current_heuristic = ref 0 in
begin
debug "Deciding condition for RTL node %d\n" (P.to_int n);
List.iter (fun do_heur ->
match !preferred with
- | None -> preferred := do_heur code cond ifso ifnot is_loop_header
+ | None -> begin
+ preferred := do_heur code cond ifso ifnot is_loop_header;
+ if stats_oc_recording () then begin
+ (* Getting stats about mispredictions from each heuristic *)
+ (match !preferred, pred with
+ | Some false, Some true
+ | Some true, Some false
+ (* | Some _, None *) (* Uncomment for overpredicts *)
+ -> begin
+ match !current_heuristic with
+ | 0 -> incr wrong_opcode
+ | 1 -> incr wrong_return
+ | 2 -> incr wrong_loop2
+ | 3 -> incr wrong_loop
+ | 4 -> incr wrong_call
+ | _ -> failwith "Shouldn't happen"
+ end
+ | Some false, Some false
+ | Some true, Some true -> begin
+ match !current_heuristic with
+ | 0 -> incr right_opcode
+ | 1 -> incr right_return
+ | 2 -> incr right_loop2
+ | 3 -> incr right_loop
+ | 4 -> incr right_call
+ | _ -> failwith "Shouldn't happen"
+ end
+ | _ -> ()
+ );
+ incr current_heuristic
+ end
+ end
| Some _ -> ()
) heuristics;
directions := PTree.set n !preferred !directions;