Skip to content
Snippets Groups Projects
Commit 817b53ea authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Some of code refactoring.

Also, do not set the seed when comparing compilers.
parent 953ed8bb
No related branches found
No related tags found
No related merge requests found
(* Time-stamp: <modified the 08/07/2015 (at 17:53) by Erwan Jahier> *)
(* Time-stamp: <modified the 18/09/2015 (at 15:45) by Erwan Jahier> *)
open Lxm
open Lv6errors
......@@ -14,10 +14,10 @@ let info msg =
let (doit : Lv6MainArgs.t -> AstV6.pack_or_model list -> Lv6Id.idref option -> LicPrg.t) =
fun opt srclist main_node ->
(* let t0 = Sys.time() in *)
info "Start compiling to lic...\n";
let syntax_tab = AstTab.create srclist in
(* Pour chaque package, on a un solveur de rfrences
(* let t0 = Sys.time() in *)
info "Start compiling to lic...\n";
let syntax_tab = AstTab.create srclist in
(* Pour chaque package, on a un solveur de rfrences
globales, pour les types, const et node :
- les rfrences pointes (p::n) sont recherches
directement dans la syntax_tab puisqu'il n'y a pas
......@@ -26,48 +26,49 @@ let (doit : Lv6MainArgs.t -> AstV6.pack_or_model list -> Lv6Id.idref option -> L
. dans le pack lui-mme
. dans un des packs dclars "uses", avec
priorit dans l'ordre
*)
*)
let lic_tab = LicTab.create syntax_tab in
Verbose.exe ~flag:dbg (fun () -> AstTab.dump syntax_tab);
let lic_tab = LicTab.create syntax_tab in
Verbose.exe ~flag:dbg (fun () -> AstTab.dump syntax_tab);
info "Compiling into lic...\n";
let lic_tab = match main_node with
| None -> LicTab.compile_all lic_tab
| Some main_node ->
if opt.Lv6MainArgs.compile_all_items then
LicTab.compile_all lic_tab
else
LicTab.compile_node lic_tab main_node
in
info "Converting to lic_prg...\n";
let zelic = LicTab.to_lic_prg lic_tab in
info "Compiling into lic...\n";
let lic_tab = match main_node with
| None -> LicTab.compile_all lic_tab
| Some main_node ->
if opt.Lv6MainArgs.compile_all_items then
LicTab.compile_all lic_tab
else
LicTab.compile_node lic_tab main_node
in
info "Converting to lic_prg...\n";
let zelic = LicTab.to_lic_prg lic_tab in
if opt.Lv6MainArgs.print_interface then zelic else (
info "Check safety and memory declarations...\n";
if Lv6MainArgs.global_opt.Lv6MainArgs.kcg then
L2lCheckKcgKeyWord.doit zelic
else
L2lCheckMemSafe.doit zelic;
L2lCheckKcgKeyWord.doit zelic
else
L2lCheckMemSafe.doit zelic;
let zelic =
if not opt.Lv6MainArgs.optim_ite then zelic else (
info "Optimizing if/then/else...\n";
L2lOptimIte.doit zelic)
in
let zelic =
(* limination polymorphisme surcharge *)
(* limination polymorphisme surcharge *)
info "Removing polymorphism...\n";
L2lRmPoly.doit zelic
in
let zelic = if not opt.Lv6MainArgs.inline_iterator then zelic else (
info "Inlining iterators...\n";
(* to be done before array expansion otherwise they won't be expanded *)
L2lExpandMetaOp.doit zelic
)
info "Inlining iterators...\n";
(* to be done before array expansion otherwise they won't be expanded *)
L2lExpandMetaOp.doit zelic
)
in
let zelic =
if Lv6MainArgs.global_opt.Lv6MainArgs.kcg && not opt.Lv6MainArgs.inline_iterator then
L2lExpandMetaOp.doit_boolred zelic
L2lExpandMetaOp.doit_boolred zelic
else
zelic
zelic
in
let zelic =
if
......@@ -85,12 +86,12 @@ let (doit : Lv6MainArgs.t -> AstV6.pack_or_model list -> Lv6Id.idref option -> L
if opt.Lv6MainArgs.expand_node_call <> [] || opt.Lv6MainArgs.expand_nodes then (
let mn:Lv6Id.idref =
match main_node with
| None ->
(match LicPrg.choose_node zelic with
| None -> assert false
| Some(nk,_) -> Lv6Id.idref_of_long (fst nk)
)
| Some mn -> mn
| None ->
(match LicPrg.choose_node zelic with
| None -> assert false
| Some(nk,_) -> Lv6Id.idref_of_long (fst nk)
)
| Some mn -> mn
in
let ids_to_expand = (List.map Lv6Id.idref_of_string opt.Lv6MainArgs.expand_node_call) in
let long_match_idref (p,n) idref =
......@@ -101,14 +102,14 @@ let (doit : Lv6MainArgs.t -> AstV6.pack_or_model list -> Lv6Id.idref option -> L
let nodes_to_keep: Lic.node_key list =
LicPrg.fold_nodes
(fun (long,sargs) _ acc ->
if opt.Lv6MainArgs.expand_nodes then
(if long_match_idref long mn then (long,sargs)::acc else acc)
else if
List.exists (long_match_idref long) ids_to_expand
then
acc
else
(long,sargs)::acc
if opt.Lv6MainArgs.expand_nodes then
(if long_match_idref long mn then (long,sargs)::acc else acc)
else if
List.exists (long_match_idref long) ids_to_expand
then
acc
else
(long,sargs)::acc
)
zelic
[]
......@@ -124,8 +125,8 @@ let (doit : Lv6MainArgs.t -> AstV6.pack_or_model list -> Lv6Id.idref option -> L
(* Array and struct expansion: to do after polymorphism elimination
and after node expansion *)
let zelic = if not opt.Lv6MainArgs.expand_arrays then zelic else (
info "Expanding arrays...\n";
L2lExpandArrays.doit zelic)
info "Expanding arrays...\n";
L2lExpandArrays.doit zelic)
in
(* alias des types array XXX fait partir lic2soc en boucle
cause des soc key qui ne sont plus cohrentes entre elles
......@@ -134,7 +135,7 @@ let (doit : Lv6MainArgs.t -> AstV6.pack_or_model list -> Lv6Id.idref option -> L
info "Aliasing arrays...\n";
let zelic = L2lAliasType.doit zelic in
*)
*)
(* Currently only works in this mode *)
if Lv6MainArgs.global_opt.Lv6MainArgs.ec then (
info "Check loops...\n";
......@@ -144,7 +145,7 @@ let (doit : Lv6MainArgs.t -> AstV6.pack_or_model list -> Lv6Id.idref option -> L
L2lCheckOutputs.doit zelic;
info "Lic Compilation done!\n";
zelic
)
let test_lex ( lexbuf ) = (
let tk = ref (Lv6lexer.lexer lexbuf) in
......
(** Time-stamp: <modified the 15/01/2015 (at 13:38) by Erwan Jahier> *)
(** Time-stamp: <modified the 09/09/2015 (at 11:23) by Erwan Jahier> *)
val f: LicPrg.t -> Lic.node_key -> Soc.key * Soc.tbl
......@@ -9,3 +9,5 @@ exception Polymorphic
(* raises the Polymorphic exception if Lic.type_ is polymorphic *)
val lic_to_data_type: Lic.type_ -> Data.t
val soc_profile_of_node: Lic.node_exp -> Soc.var list * Soc.var list
(* Time-stamp: <modified the 20/08/2015 (at 10:10) by Erwan Jahier> *)
(* Time-stamp: <modified the 18/09/2015 (at 15:49) by Erwan Jahier> *)
open Verbose
open AstV6
......@@ -12,11 +12,13 @@ open Lv6MainArgs
let my_exit opt i =
if opt.rif then
output_string opt.oc "\nq\n"
else if opt.print_interface then () else
else if opt.print_interface then
output_string opt.oc "\n"
else
output_string opt.oc "\nbye\n";
flush opt.oc;
close_out opt.oc;
if Sys.file_exists opt.outfile then Sys.remove opt.outfile;
if i>0 && Sys.file_exists opt.outfile then Sys.remove opt.outfile;
exit i
let rec first_pack_in =
......@@ -39,42 +41,37 @@ let find_a_node opt =
let (gen_rif_interface : LicPrg.t -> Lv6Id.idref option -> Lv6MainArgs.t -> unit) =
fun lic_prg main_node opt ->
let msk, zesoc, main_node =
match main_node with
| None -> (
let name = find_a_node opt in
let main_node = Lv6Id.to_idref name in
let nk = (Lic.node_key_of_idref main_node) in
if LicPrg.node_exists lic_prg nk then (
output_string stdout ("WARNING: No main node is specified. I'll try with "
^ name ^"\n");
flush stdout;
let msk, zesoc = Lic2soc.f lic_prg nk in
msk, zesoc, main_node
) else (
print_string ("Error: no node is specified.\nbye\n");
flush stdout;
my_exit opt 2
)
)
| Some main_node ->
let msk, zesoc = Lic2soc.f lic_prg (Lic.node_key_of_idref main_node) in
msk, zesoc, main_node
in
let my_type_to_string t =
let str = Data.type_to_string t in
let idref = Lv6Id.idref_of_string str in
(idref.Lv6Id.id_id)
in
let soc = try Soc.SocMap.find msk zesoc with Not_found -> assert false in
let invars,outvars=soc.Soc.profile in
let invars = SocVar.expand_profile false false invars in
let outvars = SocVar.expand_profile true false outvars in
let invars_str = List.map (fun (n,t) -> n^":"^(my_type_to_string t)) invars in
let outvars_str = List.map (fun (n,t) -> n^":"^(my_type_to_string t)) outvars in
print_string ("#inputs "^ (String.concat " " invars_str) ^"\n");
print_string ("#outputs "^ (String.concat " " outvars_str) ^"\n");
flush stdout
let nk =
match main_node with
| None -> (
let name = find_a_node opt in
let main_node = Lv6Id.to_idref name in
let nk = (Lic.node_key_of_idref main_node) in
if LicPrg.node_exists lic_prg nk then nk else (
output_string opt.oc ("Error: no node is specified.\nbye\n");
flush opt.oc;
my_exit opt 2
)
)
| Some main_node -> Lic.node_key_of_idref main_node
in
let invars,outvars =
match LicPrg.find_node lic_prg nk with
| None -> assert false
| Some node_def -> Lic2soc.soc_profile_of_node node_def
in
let my_type_to_string t =
let str = Data.type_to_string t in
let idref = Lv6Id.idref_of_string str in
(idref.Lv6Id.id_id)
in
let invars = SocVar.expand_profile true false invars in
let outvars = SocVar.expand_profile true false outvars in
let invars_str = List.map (fun (n,t) -> n^":"^(my_type_to_string t)) invars in
let outvars_str = List.map (fun (n,t) -> n^":"^(my_type_to_string t)) outvars in
output_string opt.oc ("#inputs "^ (String.concat " " invars_str) ^"\n");
output_string opt.oc ("#outputs "^ (String.concat " " outvars_str) ^"\n");
flush opt.oc
(* Generates a lutin env and a lustre oracle for the node *)
......
(* Time-stamp: <modified the 11/09/2015 (at 11:22) by Erwan Jahier> *)
(* Time-stamp: <modified the 23/09/2015 (at 10:04) by Erwan Jahier> *)
(* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *)
......@@ -431,9 +431,8 @@ int main(){" ^ (
close_out oc
let (gen_loop_file : Soc.t -> out_channel -> Soc.tbl -> unit) =
fun soc oc stbl ->
let base = (string_of_soc_key soc.key) in
let (gen_loop_file : Soc.t -> string -> out_channel -> Soc.tbl -> unit) =
fun soc base oc stbl ->
let putc s = output_string oc s in
let ctx = get_ctx_name soc.key in
let step = Soc2cDep.step_name soc.key "step" in
......@@ -636,9 +635,8 @@ int main(){
"
let (gen_loop_file4ogensim : Soc.t -> out_channel -> Soc.tbl -> unit) =
fun soc oc stbl ->
let base = (string_of_soc_key soc.key) in
let (gen_loop_file4ogensim : Soc.t -> string -> out_channel -> Soc.tbl -> unit) =
fun soc base oc stbl ->
let putc s = output_string oc s in
let ctx = get_ctx_name soc.key in
let step = Soc2cDep.step_name soc.key "step" in
......@@ -767,9 +765,9 @@ let (f : Lv6MainArgs.t -> Soc.key -> Soc.tbl -> LicPrg.t -> unit) =
Lv6util.entete occ "/*" "*/" ;
Lv6util.entete och "/*" "*/";
if args.Lv6MainArgs.gen_wcet then
gen_loop_file4ogensim main_soc ocl stbl
gen_loop_file4ogensim main_soc base ocl stbl
else
gen_loop_file main_soc ocl stbl;
gen_loop_file main_soc base ocl stbl;
if args.Lv6MainArgs.gen_wcet then gen_main_wcet_file main_soc base stbl;
output_string och "
......
==> lus2lic0.sum <==
Test Run By jahier on Mon Sep 21 11:20:45
Test Run By jahier on Wed Sep 23 15:47:24
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic0 tests ===
......@@ -64,7 +64,7 @@ XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/lecte
XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/s.lus
==> lus2lic1.sum <==
Test Run By jahier on Mon Sep 21 11:20:49
Test Run By jahier on Wed Sep 23 15:47:24
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic1 tests ===
......@@ -396,7 +396,7 @@ PASS: gcc -o multipar.exec multipar_multipar.c multipar_multipar_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus {}
==> lus2lic2.sum <==
Test Run By jahier on Mon Sep 21 11:20:47
Test Run By jahier on Wed Sep 23 15:47:39
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic2 tests ===
......@@ -741,7 +741,7 @@ PASS: gcc -o zzz2.exec zzz2_zzz2.c zzz2_zzz2_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus {}
==> lus2lic3.sum <==
Test Run By jahier on Mon Sep 21 11:20:49
Test Run By jahier on Wed Sep 23 15:48:25
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic3 tests ===
......@@ -1243,7 +1243,7 @@ PASS: ./myec2c {-o multipar.c multipar.ec}
PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {}
==> lus2lic4.sum <==
Test Run By jahier on Mon Sep 21 11:20:51
Test Run By jahier on Wed Sep 23 15:48:38
Native configuration is x86_64-unknown-linux-gnu
=== lus2lic4 tests ===
......@@ -1764,14 +1764,14 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {}
# of unexpected failures 4
===============================
# Total number of failures: 23
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 23 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 50 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 19 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 53 seconds
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 0 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 15 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 46 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 13 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 49 seconds
* Ref time:
0.03user 0.04system 2:04.05elapsed 0%CPU (0avgtext+0avgdata 5100maxresident)k
0inputs+0outputs (0major+5545minor)pagefaults 0swaps
0.06user 0.01system 2:03.56elapsed 0%CPU (0avgtext+0avgdata 5100maxresident)k
0inputs+0outputs (0major+5541minor)pagefaults 0swaps
* Quick time (-j 4):
0.04user 0.01system 0:58.69elapsed 0%CPU (0avgtext+0avgdata 5100maxresident)k
0inputs+0outputs (0major+5583minor)pagefaults 0swaps
0.04user 0.02system 0:52.88elapsed 0%CPU (0avgtext+0avgdata 5104maxresident)k
32inputs+0outputs (0major+5550minor)pagefaults 0swaps
# Time-stamp: <modified the 08/07/2015 (at 17:52) by Erwan Jahier>
# Time-stamp: <modified the 18/09/2015 (at 16:41) by Erwan Jahier>
#
# (nonreg-)test harness main file
......@@ -6,6 +6,7 @@ set testdir [pwd]
set lus2lic "./lus2lic"
set ec2c "./ec2c"
set ec2c "./myec2c"
set test_lus2lic_no_node "$testdir/../utils/test_lus2lic_no_node_rdbg"
set test_lus2lic_no_node "$testdir/../utils/test_lus2lic_no_node"
set compare_exec_and_2c "$testdir/../utils/compare_exec_and_2c"
......
......@@ -47,9 +47,10 @@ fi
export PATH=/usr/local/tools/lustre/v4/bin/:$PATH
if
./lurettetop -p 6 -seed 42 \
PRECISION=4
./lurettetop -p $PRECISION \
-rp "sut:socket:127.0.0.1:$PORT" \
-rp "env:lutin:$env" \
-rp "env:lutin:$env:-p:$PRECISION" \
-rp "oracle:v6:$_oracle:$oracle:$OPT" \
-go -l 10 -ns2c --stop-on-oracle-error;
then
......
......@@ -8,7 +8,8 @@
ec=$1
node=$2
#set -x verbose #echo on
#set -e # stop at the first error!
./lus2lic -interface $ec -n $node
ecexe -rif -r $ec
./lus2lic -interface $ec -n $node | grep -v Warning | grep -v "no memory"
./ecexe -r $ec
......@@ -58,10 +58,10 @@ export PATH=/usr/local/tools/lustre/v4/bin/:$PATH
if
# -rp "sut:v4:$lv4:$lv4_node" \
./lurettetop -p 6 -seed 42 \
PRECISION=4
./lurettetop -p $PRECISION \
-rp "sut:ec:$ec:$lv4_node" \
-rp "env:lutin:$env" \
-rp "env:lutin:$env:-p:$PRECISION" \
-rp "oracle:v6:$_oracle:$oracle:$OPT" \
-go -l 10 -ns2c --stop-on-oracle-error;
then
......
......@@ -74,12 +74,15 @@ echo "Generating oracle.cmxs"
$ocamlopt -shared -o oracle.cmxs -I +rdbg-plugin -I +lustre-v6 lustre-v6.cmxa oracle.ml
echo "Generating env.cmxs"
./lutin -seed 42 -ocaml -o env.ml $env
PRECISION=4
./lutin -p $PRECISION -ocaml -o env.ml $env
$ocamlopt -shared -o env.cmxs -I +rdbg-plugin -I +lutin $CMXA env.ml
echo "oracle.cmxs and env.cmxs are generated."
# $RDBG_PATH/rdbgbatch.native
eval "./rdbg-batch -lurette -l 10 -p 6 --stop-on-oracle-error --sut-stdio \"./patch_ecexe $ec $lv4_node\" --env env.cmxs --oracle oracle.cmxs "
eval "./rdbg-batch -lurette -l 10 -p $PRECISION --stop-on-oracle-error --sut-stdio \"./patch_ecexe $ec $lv4_node\" --env env.cmxs --oracle oracle.cmxs "
# echo " $RDBG_PATH/rdbgbatch.native -lurette --seed 42 -l 100 -p 6 --stop-on-oracle-error \
# --sut-stdio \"./patch_ecexe $ec $lv4_node\" \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment