@@ -7,7 +7,7 @@ open optionTheory bdd_sptrees_genTheory pairTheory bdd_genTheory tables_specTheo
77open sptrees_bdd_trans_ProgTheory;
88open preamble basis ml_translatorLib ;
99
10- open miscTheory ml_translatorTheory ListProgTheory ;
10+ open miscTheory ;
1111open fromSexpTheory;
1212
1313
@@ -17,10 +17,31 @@ val _ = translation_extends "sptrees_bdd_trans_Prog";
1717val _ = type_abbrev(" action_policy_type" , “:((string# num list) action_expr) policy”);
1818
1919
20+
21+ fun time_stage (stage_name, timer_cpu, timer_real) =
22+ let
23+ val cpu_time = Timer.checkCPUTimer timer_cpu
24+ val real_time = Timer.checkRealTimer timer_real
25+ val _ = HOL_MESG (stage_name ^ " completed in: " ^
26+ Time.toString (#usr cpu_time) ^ " user, " ^
27+ Time.toString (#sys cpu_time) ^ " system, " ^
28+ Time.toString real_time ^ " real\n " )
29+ in
30+ (cpu_time, real_time)
31+ end
32+
33+
34+
35+
36+
2037fun sptrees_gen_bdds_policy_and_table (var_policy, policy_order, policy_full_order) =
2138
2239let
2340
41+ val start_cpu_stage2_io = Timer.startCPUTimer ();
42+ val start_real_stage2_io = Timer.startRealTimer ();
43+
44+
2445Definition policy_order_test_def:
2546 policy_order_test = (^policy_order:string list)
2647End
@@ -90,6 +111,9 @@ val prog =
90111
91112val _ = astToSexprLib.write_ast_to_file " ../../bdd_cake_test/test_bdd_policy.sexp" prog;
92113
114+ val _ = time_stage (" Stage 2 from var policy to sexp - cakeML trans " , start_cpu_stage2_io, start_real_stage2_io);
115+ val start_cpu_stage2_io2 = Timer.startCPUTimer ();
116+ val start_real_stage2_io2 = Timer.startRealTimer ();
93117
94118val status_compile_sexp = OS.Process.system " cd ../../bdd_cake_test/ && CML_STACK_SIZE=2048 CML_HEAP_SIZE=8192 ./cake --sexp=true --exclude_prelude=true --skip_type_inference=false --jump=false --reg_alg=0 < test_bdd_policy.sexp > test_bdd_policy.cake.S"
95119
@@ -112,7 +136,9 @@ val _ = if OS.Process.isSuccess status_exec
112136 else (print " Nej, policy cc compilation failed\n " ;
113137 OS.Process.exit OS.Process.failure)
114138
115-
139+ val _ = time_stage (" Stage 2 cakeML compiliation var policy to bdd " , start_cpu_stage2_io2, start_real_stage2_io2);
140+ val start_cpu_stage2_io3 = Timer.startCPUTimer ();
141+ val start_real_stage2_io3 = Timer.startRealTimer ();
116142
117143(*
118144
@@ -138,6 +164,8 @@ val ins = TextIO.openIn "../../bdd_cake_test/bdd_policy_cakeml_export.txt";
138164val policy_content_str = TextIO.inputAll ins;
139165val _ = TextIO.closeIn ins;
140166
167+ val _ = time_stage (" Stage 2 from Policy to var BDD total " , start_cpu_stage2_io, start_real_stage2_io);
168+
141169(* open Term;*)
142170
143171val policy_bdd_content_term =
@@ -226,6 +254,11 @@ val prog =
226254
227255val _ = astToSexprLib.write_ast_to_file " ../../bdd_cake_test/test_bdd_table.sexp" prog;
228256
257+ val _ = time_stage (" Stage 2 prepp out table and recompile cakeml translation " , start_cpu_stage2_io3, start_real_stage2_io3);
258+ val start_cpu_stage2_io4 = Timer.startCPUTimer ();
259+ val start_real_stage2_io4 = Timer.startRealTimer ();
260+
261+
229262
230263val status = OS.Process.system " cd ../../bdd_cake_test/ && CML_STACK_SIZE=2048 CML_HEAP_SIZE=8192 ./cake --sexp=true --exclude_prelude=true --skip_type_inference=false --jump=false --reg_alg=0 < test_bdd_table.sexp > test_bdd_table.cake.S && cc test_bdd_table.cake.S basis_ffi.c -lm -o test_bdd_table.cake -lm && time ./test_bdd_table.cake > bdd_table_cakeml_export.txt"
231264
272305
273306
274307
308+ val _ = time_stage (" Stage 2 cakeML compiliation var table to BDD " , start_cpu_stage2_io4, start_real_stage2_io4);
275309
276-
277-
310+ val _ = time_stage (" Stage 2 from TABLE to var BDD total " , start_cpu_stage2_io3, start_real_stage2_io3);
278311
279312in
280313(policy_bdd_content_term, gen_var_table_auto, table_bdd_content_term)
0 commit comments