diff --git a/src/socExec.ml b/src/socExec.ml index db7c4f31b32ec0f2a7b4a56a86614cb0c64ef2a9..6beda2ba84212e2d17a791ae385975482d975771 100644 --- a/src/socExec.ml +++ b/src/socExec.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 01/07/2014 (at 17:13) by Erwan Jahier> *) +(* Time-stamp: <modified the 07/08/2014 (at 15:17) by Erwan Jahier> *) open Soc open Data @@ -31,98 +31,98 @@ let rec (soc_step : Soc.step_method -> Soc.tbl -> Soc.t -> SocExecValue.ctx fun step soc_tbl soc ctx -> let soc_name,_,_ = soc.key in let ctx = - match step.impl with - | Extern -> assert false (* fixme !!! *) - | Predef -> ( - try - let ctx = SocExecEvalPredef.get soc.key ctx in - ctx - with Not_found -> (* Not a predef op *) print_string ( - "*** internal error in "^soc_name^". Is it defined in SocExecEvalPredef?\n"); - flush stdout; assert false - ) - | Gaol(vl,gaol) -> List.fold_left (do_gao step.lxm soc_tbl) ctx gaol - | Boolred(i,j,k) -> ( + match step.impl with + | Extern -> assert false (* fixme !!! *) + | Predef -> ( + try + let ctx = SocExecEvalPredef.get soc.key ctx in + ctx + with Not_found -> (* Not a predef op *) print_string ( + "*** internal error in "^soc_name^". Is it defined in SocExecEvalPredef?\n"); + flush stdout; assert false + ) + | Gaol(vl,gaol) -> List.fold_left (do_gao step.lxm soc_tbl) ctx gaol + | Boolred(i,j,k) -> ( (* XXX mettre ce code dans socPredef ? (ou socMetaopPredef)*) - let inputs, outputs = soc.profile in - let b_array = (List.hd inputs) in - let cpt = ref 0 in - for i = 0 to k-1 do - let a_i = array_index i b_array in - let v = SocExecValue.get_value ctx a_i in - if v = B true then incr cpt; - done; - let res = B (!cpt >= i && !cpt <= j) in - let res_var = fst (List.hd outputs) in - let s = sadd ctx.s (res_var::ctx.cpath) res in - { ctx with s = s } - ) - | Condact(node_sk, dft_cst) -> ( - let clk = SocExecValue.get_value ctx (Var ("i0",Bool)) in - let vel_in, vel_out = soc.profile in - let vel_in = List.map (fun x -> Var x) (List.tl vel_in) in - let vel_out = List.map (fun x -> Var x) vel_out in - let node_soc = SocUtils.find step.lxm node_sk soc_tbl in - let inst_name = - match soc.instances with - | [] -> let (proc_name,_,_) = node_soc.key in proc_name - | [inst] -> fst inst - | _ -> assert false - in - let path_saved = ctx.cpath in - let ctx = { ctx with cpath=inst_name::ctx.cpath } in - let ctx = - if clk = B true then - let node_step = match node_soc.step with [step] -> step | _ -> assert false in - let ctx = do_step inst_name node_step ctx soc_tbl node_soc vel_in vel_out in - { ctx with cpath=path_saved } - else - let first_step = Var ("_memory",Bool) in - let v = get_value ctx first_step in - if v = U || v = B true then + let inputs, outputs = soc.profile in + let b_array = (List.hd inputs) in + let cpt = ref 0 in + for i = 0 to k-1 do + let a_i = array_index i b_array in + let v = SocExecValue.get_value ctx a_i in + if v = B true then incr cpt; + done; + let res = B (!cpt >= i && !cpt <= j) in + let res_var = fst (List.hd outputs) in + let s = sadd ctx.s (res_var::ctx.cpath) res in + { ctx with s = s } + ) + | Condact(node_sk, dft_cst) -> ( + let clk = SocExecValue.get_value ctx (Var ("i0",Bool)) in + let vel_in, vel_out = soc.profile in + let vel_in = List.map (fun x -> Var x) (List.tl vel_in) in + let vel_out = List.map (fun x -> Var x) vel_out in + let node_soc = SocUtils.find step.lxm node_sk soc_tbl in + let inst_name = + match soc.instances with + | [] -> let (proc_name,_,_) = node_soc.key in proc_name + | [inst] -> fst inst + | _ -> assert false + in + let path_saved = ctx.cpath in + let ctx = { ctx with cpath=inst_name::ctx.cpath } in + let ctx = + if clk = B true then + let node_step = match node_soc.step with [step] -> step | _ -> assert false in + let ctx = do_step inst_name node_step ctx soc_tbl node_soc vel_in vel_out in + { ctx with cpath=path_saved } + else + let first_step = Var ("_memory",Bool) in + let ctx = { ctx with cpath=path_saved } in + let v = get_value ctx first_step in + if v = U || v = B true then (* We are on the first step of node_soc; - we assign the output var to the default values *) - let ctx = { ctx with cpath=path_saved } in - List.fold_left2 assign_expr ctx dft_cst vel_out - else - (* We are not on the first step of node_soc; hence we do nothing - and the output will keep their previous value. *) - { ctx with cpath=path_saved } - in - let ctx = { ctx with s = sadd ctx.s ("_memory"::ctx.cpath) (B false) } in - ctx - ) - | Iterator(iter, node_sk, n) -> - let node_soc = SocUtils.find step.lxm node_sk soc_tbl in - let node_step = match node_soc.step with [step] -> step | _ -> assert false in - let iter_inputs,iter_outputs = soc.profile in - let rctx = ref ctx in - let (proc_name,_,_) = node_soc.key in - let inst_name = - match soc.instances with - | [] -> Array.make n proc_name - | _ -> Array.of_list (List.map fst soc.instances) - in - for i = 0 to n-1 do - rctx := { !rctx with cpath = inst_name.(i)::ctx.cpath }; - let vel_in, vel_out = - match iter with - | "map" -> (List.map (array_index i) iter_inputs, - List.map (array_index i) iter_outputs) - | "fold" | "red" | "fill" | "fillred" -> - let a_in = Var (List.hd iter_inputs) in - ( a_in::(List.map (array_index i) (List.tl iter_inputs)), - a_in::(List.map (array_index i) (List.tl iter_outputs))) - | _ -> assert false (* should not occur *) + List.fold_left2 assign_expr ctx dft_cst vel_out + else + (* We are not on the first step of node_soc; hence we do nothing + and the output will keep their previous value. *) + ctx + in + let ctx = { ctx with s = sadd ctx.s ("_memory"::ctx.cpath) (B false) } in + ctx + ) + | Iterator(iter, node_sk, n) -> + let node_soc = SocUtils.find step.lxm node_sk soc_tbl in + let node_step = match node_soc.step with [step] -> step | _ -> assert false in + let iter_inputs,iter_outputs = soc.profile in + let rctx = ref ctx in + let (proc_name,_,_) = node_soc.key in + let inst_name = + match soc.instances with + | [] -> Array.make n proc_name + | _ -> Array.of_list (List.map fst soc.instances) in - rctx := do_step inst_name.(i) node_step !rctx soc_tbl node_soc vel_in vel_out; - rctx := { !rctx with cpath = List.tl !rctx.cpath }; - done; - if iter <> "map" then ( - let a_in = Var (List.hd iter_inputs) in - let a_out = Var (List.hd iter_outputs) in - rctx := assign_expr !rctx a_in a_out); (* a_out=a_n *) - !rctx; + for i = 0 to n-1 do + rctx := { !rctx with cpath = inst_name.(i)::ctx.cpath }; + let vel_in, vel_out = + match iter with + | "map" -> (List.map (array_index i) iter_inputs, + List.map (array_index i) iter_outputs) + | "fold" | "red" | "fill" | "fillred" -> + let a_in = Var (List.hd iter_inputs) in + ( a_in::(List.map (array_index i) (List.tl iter_inputs)), + a_in::(List.map (array_index i) (List.tl iter_outputs))) + | _ -> assert false (* should not occur *) + in + rctx := do_step inst_name.(i) node_step !rctx soc_tbl node_soc vel_in vel_out; + rctx := { !rctx with cpath = List.tl !rctx.cpath }; + done; + if iter <> "map" then ( + let a_in = Var (List.hd iter_inputs) in + let a_out = Var (List.hd iter_outputs) in + rctx := assign_expr !rctx a_in a_out); (* a_out=a_n *) + !rctx; in ctx diff --git a/src/socPredef.ml b/src/socPredef.ml index 9e15f4fd1251719bd25801cabbd60f40df3c24f3..c986afb967e0f89eb9bb64ab6d39f6965a4040c9 100644 --- a/src/socPredef.ml +++ b/src/socPredef.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 01/07/2014 (at 15:25) by Erwan Jahier> *) +(* Time-stamp: <modified the 07/08/2014 (at 14:09) by Erwan Jahier> *) (** Synchronous Object Code for Predefined operators. *) @@ -63,9 +63,6 @@ let make_soc key profile steps = { memory = No_mem; } - -let first_step = Var("$first_step", Bool) - let (get_mem_name : Soc.key -> Data.t -> string) = fun (k,tl,_) vt -> "_memory" diff --git a/test/lus2lic.sum b/test/lus2lic.sum index f97a4b7a11331140ff40eccf21f37598c35ba58b..e6476e7e43cf33e0c061b11001e2cdc66e51d1fb 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Thu Aug 7 11:48:30 2014 +Test Run By jahier on Thu Aug 7 16:06:31 2014 Native configuration is i686-pc-linux-gnu === lus2lic tests === @@ -439,7 +439,6 @@ PASS: gcc modes3x2_v2_modes3x2_v2.c modes3x2_v2_modes3x2_v2_loop.c PASS: ../utils/compare_exec_and_2c should_work/modes3x2_v2.lus FAIL: without any option: ./lus2lic {-o /tmp/X6.lic should_work/X6.lus} FAIL: Generate ec code : ./lus2lic {-ec -o /tmp/X6.ec should_work/X6.lus} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/X6.lus FAIL: Generate c code : ./lus2lic {-2c should_work/X6.lus -n X6} PASS: ./lus2lic {-o /tmp/zzz2.lic should_work/zzz2.lus} PASS: ./lus2lic {-ec -o /tmp/zzz2.ec should_work/zzz2.lus} @@ -899,10 +898,13 @@ PASS: ../utils/compare_exec_and_2c should_work/ts04.lus FAIL: without any option: ./lus2lic {-o /tmp/bug_map_fby.lic should_work/bug_map_fby.lus} FAIL: Generate ec code : ./lus2lic {-ec -o /tmp/bug_map_fby.ec should_work/bug_map_fby.lus} FAIL: Generate c code : ./lus2lic {-2c should_work/bug_map_fby.lus -n bug_map_fby} -FAIL: without any option: ./lus2lic {-o /tmp/multiclock.lic should_work/multiclock.lus} -FAIL: Generate ec code : ./lus2lic {-ec -o /tmp/multiclock.ec should_work/multiclock.lus} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/multiclock.lus -FAIL: Generate c code : ./lus2lic {-2c should_work/multiclock.lus -n multiclock} +PASS: ./lus2lic {-o /tmp/multiclock.lic should_work/multiclock.lus} +PASS: ./lus2lic {-ec -o /tmp/multiclock.ec should_work/multiclock.lus} +PASS: ./myec2c {-o /tmp/multiclock.c /tmp/multiclock.ec} +PASS: ../utils/test_lus2lic_no_node should_work/multiclock.lus +PASS: ./lus2lic {-2c should_work/multiclock.lus -n multiclock} +PASS: gcc multiclock_multiclock.c multiclock_multiclock_loop.c +FAIL: Try to compare lus2lic -exec and -2c: ../utils/compare_exec_and_2c should_work/multiclock.lus PASS: ./lus2lic {-o /tmp/nc2.lic should_work/nc2.lus} PASS: ./lus2lic {-ec -o /tmp/nc2.ec should_work/nc2.lus} PASS: ./myec2c {-o /tmp/nc2.c /tmp/nc2.ec} @@ -1066,7 +1068,7 @@ PASS: ./myec2c {-o /tmp/test_condact.c /tmp/test_condact.ec} FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/test_condact.lus PASS: ./lus2lic {-2c should_work/test_condact.lus -n test_condact} PASS: gcc test_condact_test_condact.c test_condact_test_condact_loop.c -FAIL: Try to compare lus2lic -exec and -2c: ../utils/compare_exec_and_2c should_work/test_condact.lus +PASS: ../utils/compare_exec_and_2c should_work/test_condact.lus PASS: ./lus2lic {-o /tmp/contractForElementSelectionInArray.lic should_work/contractForElementSelectionInArray.lus} PASS: ./lus2lic {-ec -o /tmp/contractForElementSelectionInArray.ec should_work/contractForElementSelectionInArray.lus} PASS: ./myec2c {-o /tmp/contractForElementSelectionInArray.c /tmp/contractForElementSelectionInArray.ec} @@ -1488,7 +1490,6 @@ PASS: gcc iterate_iterate.c iterate_iterate_loop.c PASS: ../utils/compare_exec_and_2c should_work/iterate.lus FAIL: without any option: ./lus2lic {-o /tmp/PCOND.lic should_work/PCOND.lus} FAIL: Generate ec code : ./lus2lic {-ec -o /tmp/PCOND.ec should_work/PCOND.lus} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/PCOND.lus FAIL: Generate c code : ./lus2lic {-2c should_work/PCOND.lus -n PCOND} PASS: ./lus2lic {-o /tmp/EDGE.lic should_work/EDGE.lus} PASS: ./lus2lic {-ec -o /tmp/EDGE.ec should_work/EDGE.lus} @@ -1669,10 +1670,8 @@ XPASS: Test bad programs (semantics): lus2lic {-o /tmp/bug.lic should_fail/seman === lus2lic Summary === -# of expected passes 1512 -# of unexpected failures 84 +# of expected passes 1519 +# of unexpected failures 78 # of unexpected successes 21 # of expected failures 37 # of unresolved testcases 3 -testcase ./lus2lic.tests/non-reg.exp completed in 259 seconds -testcase ./lus2lic.tests/progression.exp completed in 0 seconds diff --git a/test/lus2lic.tests/non-reg.exp b/test/lus2lic.tests/non-reg.exp index f8803db808f6fe8d33303c0a757ce8ab0223a145..97edea5a9b85b132effc47488233395d399b1de1 100644 --- a/test/lus2lic.tests/non-reg.exp +++ b/test/lus2lic.tests/non-reg.exp @@ -3,13 +3,18 @@ set timeout 20 set ok_files [glob should_work/*.lus] - set id [should_work "Unit tests" "$lus2lic" "-unit"] wait -i $id +set tmp /tmp/ +#set tmp /tmp/lus2lic-test/ +#eval spawn "rm -f $tmp" +#eval spawn "mkdir $tmp" +#eval spawn "echo '$tmp dir created'" + foreach f $ok_files { set basef [file rootname $f] - set bf /tmp/[file tail $basef] + set bf $tmp[file tail $basef] set basef [file tail $basef] set id1 [should_work "without any option" "$lus2lic" "-o $bf.lic $f"] @@ -62,12 +67,12 @@ foreach f $ok_files { # Programs that should fail proc iter_should_fail { fail_kind } { - global lus2lic test_lus2lic_no_node + global lus2lic test_lus2lic_no_node tmp set files [glob should_fail/$fail_kind/*.lus] foreach f $files { set bf [file rootname $f] - set bf /tmp/[file tail $bf] + set bf $tmp[file tail $bf] set id [should_fail "Test bad programs" "$fail_kind" "$test_lus2lic_no_node" "$f"] wait -i $id catch { exp_close -i $id } diff --git a/test/lus2lic.time b/test/lus2lic.time index 3d42a2c82dce505edf7474fa41d9c8a12e9419d0..fed70722e8c51fddfbc7a6d67ac405410332082a 100644 --- a/test/lus2lic.time +++ b/test/lus2lic.time @@ -1,2 +1,2 @@ -testcase ./lus2lic.tests/non-reg.exp completed in 259 seconds +testcase ./lus2lic.tests/non-reg.exp completed in 257 seconds testcase ./lus2lic.tests/progression.exp completed in 0 seconds diff --git a/test/should_work/decl.lus b/test/should_work/decl.lus index c02fdaf02ee33faaf3df47a24fe56950d0468453..bec87709bbaa4f8d56c91f5c34fa28da2bd7cd91 100644 --- a/test/should_work/decl.lus +++ b/test/should_work/decl.lus @@ -27,6 +27,7 @@ extern node decl(a1, b1, c1: t1) returns (d1: bool); extern node n2(a1, b1, c1: t4; d1: bool) returns (e1: t5); extern function f1(a1, b1, c1: couleur) returns (d1: bool^h) ; + node dummy(y: bool) returns(x: bool); let x=true; diff --git a/test/should_work/multiclock.lus b/test/should_work/multiclock.lus index 74416720769356c45fa89f0318f2b68d4a9e771a..814062a0a097f05a2582f314f0eb713980acf1e1 100644 --- a/test/should_work/multiclock.lus +++ b/test/should_work/multiclock.lus @@ -1,10 +1,8 @@ node multiclock ( x, y: int; c: bool; z: int ) returns ( s: int); -var - h: bool when c ; - u: int when h ; + let - s = current(multiclock_clk ( x, y; c; z when c )); + s = current(multiclock_clk ( x, y, c, z when c )); tel node multiclock_clk ( x, y: int; c: bool; z: int when c ) diff --git a/todo.org b/todo.org index 07b150f4c84c565698f83a86df8092f5a7ddf762..bea9953f84bf297f3ab0bb91e69bccc8b7e9a819 100644 --- a/todo.org +++ b/todo.org @@ -3,43 +3,11 @@ * lus2lic -exec -** TODO Lurette trouve un mismatch sur ce prog au step 1 - - State "TODO" from "" [2013-05-10 Fri 17:08] +** TODO Extern and ec -../utils/test_lus2lic_no_node should_work/pipeline.lus +lus2lic should_work/decl.lus -n decl -ec -file:test/should_work/pipeline.lus - -** TODO Lurette trouve un mismatch sur ce prog au step 6 - - State "TODO" from "" [2013-05-10 Fri 17:08] - -file:test/should_work/deSimone.lus - -../utils/test_lus2lic_no_node should_work/deSimone.lus - -** TODO Lurette trouve un mismatch sur ce prog au step 2 - - State "TODO" from "" [2013-05-10 Fri 17:08] -../utils/test_lus2lic_no_node should_work/test.lus - -file:test/should_work/test.lus - -** TODO Extern node not yet supported - -oops: lus2lic internal error - - State "TODO" from "" [2013-05-13 Mon 08:11] - -../utils/test_lus2lic_no_node should_work/decl.lus - File "objlinux/lic2soc.ml", line 870, column 14 - when compiling lustre program should_work/decl.lus - - -../utils/test_lus2lic_no_node should_work/simple.lus - File "objlinux/socExec.ml", line 202, column 22 - when compiling lustre program should_work/simple.lus - -** TODO le traitement du condact ne marche plus - - State "TODO" from "" [2014-06-27 Fri 15:26] -depuis le 2eme commit du 18-06-2014 +generates incorrect ec code instead of raising an error. * lus2lic -2C ** TODO lic2c : le jour ou on genere du code C, y'a peut-etre des trucs a recuperer diff --git a/todo.org_archive b/todo.org_archive index 9193c51c3c795daaf82c5a1d4a0373fed37cf924..dc1ac343c93280242dddaf44b03b990408b8dcf9 100644 --- a/todo.org_archive +++ b/todo.org_archive @@ -1021,6 +1021,68 @@ file:test/should_work/call07.lus lus2lic should_work/modes3x2_v4.lus -n modes3x2_v4 -esa -o xxx -2c +* TODO Lurette trouve un mismatch sur ce prog au step 1 + - State "TODO" from "" [2013-05-10 Fri 17:08] + :PROPERTIES: + :ARCHIVE_TIME: 2014-08-07 Thu 12:27 + :ARCHIVE_FILE: ~/lus2lic/todo.org + :ARCHIVE_OLPATH: lus2lic -exec + :ARCHIVE_CATEGORY: lv6 + :ARCHIVE_TODO: TODO + :END: + +../utils/test_lus2lic_no_node should_work/pipeline.lus + +file:test/should_work/pipeline.lus + +* TODO Lurette trouve un mismatch sur ce prog au step 6 + - State "TODO" from "" [2013-05-10 Fri 17:08] + :PROPERTIES: + :ARCHIVE_TIME: 2014-08-07 Thu 12:27 + :ARCHIVE_FILE: ~/lus2lic/todo.org + :ARCHIVE_OLPATH: lus2lic -exec + :ARCHIVE_CATEGORY: lv6 + :ARCHIVE_TODO: TODO + :END: + +file:test/should_work/deSimone.lus + +../utils/test_lus2lic_no_node should_work/deSimone.lus + +* TODO Lurette trouve un mismatch sur ce prog au step 2 + - State "TODO" from "" [2013-05-10 Fri 17:08] + :PROPERTIES: + :ARCHIVE_TIME: 2014-08-07 Thu 12:27 + :ARCHIVE_FILE: ~/lus2lic/todo.org + :ARCHIVE_OLPATH: lus2lic -exec + :ARCHIVE_CATEGORY: lv6 + :ARCHIVE_TODO: TODO + :END: +../utils/test_lus2lic_no_node should_work/test.lus + +file:test/should_work/test.lus + +* TODO le traitement du condact ne marche plus + - State "TODO" from "" [2014-06-27 Fri 15:26] + :PROPERTIES: + :ARCHIVE_TIME: 2014-08-07 Thu 16:15 + :ARCHIVE_FILE: ~/lus2lic/todo.org + :ARCHIVE_OLPATH: lus2lic -exec + :ARCHIVE_CATEGORY: lv6 + :ARCHIVE_TODO: TODO + :END: +depuis le 2eme commit du 18-06-2014 + + lus2lic should_work/test_condact.lus -n test_condact -exec + + +once the activation condition has been true, and when it is false it +returns the default value instead of the previous one. + + + + +