Skip to content
Snippets Groups Projects
Commit b207aa9d authored by erwan's avatar erwan
Browse files

soc2c: the c code was wrong in presence of user type defined using extern types.

Also, the simulation via the _loop.c file was failing in extern types were present
as O/I of the main (simulated) node.
parent d4fdee06
No related branches found
No related tags found
No related merge requests found
OASISFormat: 0.4 OASISFormat: 0.4
Name: lustre-v6 Name: lustre-v6
Version: 1.688 Version: 1.689
Synopsis: The Lustre V6 Verimag compiler Synopsis: The Lustre V6 Verimag compiler
Description: This package contains: Description: This package contains:
(1) lus2lic: the (current) name of the compiler (and interpreter via -exec). (1) lus2lic: the (current) name of the compiler (and interpreter via -exec).
......
(** Automatically generated from Makefile *) (** Automatically generated from Makefile *)
let tool = "lus2lic" let tool = "lus2lic"
let branch = "master" let branch = "master"
let commit = "688" let commit = "689"
let sha_1 = "60e6de1051197066a96927dee9e5c0c5222aa6ee" let sha_1 = "d4fdee068416fe85a1809b1b47b93284d06bba32"
let str = (branch ^ "." ^ commit ^ " (" ^ sha_1 ^ ")") let str = (branch ^ "." ^ commit ^ " (" ^ sha_1 ^ ")")
let maintainer = "jahier@imag.fr" let maintainer = "jahier@imag.fr"
(* Time-stamp: <modified the 31/01/2017 (at 16:05) by Erwan Jahier> *) (* Time-stamp: <modified the 05/05/2017 (at 14:16) by Erwan Jahier> *)
(* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *) (* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *)
...@@ -290,7 +290,7 @@ let (type_to_format_string : Data.t -> string) = ...@@ -290,7 +290,7 @@ let (type_to_format_string : Data.t -> string) =
| Bool -> "%d" | Bool -> "%d"
| Int -> "%d" | Int -> "%d"
| Real-> "%f" | Real-> "%f"
| Extern s -> "%s" | Extern s -> "%d"
| Enum (s, sl) -> "%d" | Enum (s, sl) -> "%d"
| Struct (sid,_) -> "%s" | Struct (sid,_) -> "%s"
| Array (ty, sz) -> "%s" | Array (ty, sz) -> "%s"
...@@ -582,8 +582,8 @@ int main(){" ^ (gen_main_loop_body inputs outputs soc ctx)); ...@@ -582,8 +582,8 @@ int main(){" ^ (gen_main_loop_body inputs outputs soc ctx));
close_out oc close_out oc
let (gen_loop_file : Soc.t -> string -> out_channel -> Soc.tbl -> unit) = let (gen_loop_file : LicPrg.t -> Soc.t -> string -> out_channel -> Soc.tbl -> unit) =
fun soc base oc stbl -> fun licprg soc base oc stbl ->
let putc s = output_string oc s in let putc s = output_string oc s in
let ctx = get_ctx_name soc.key in let ctx = get_ctx_name soc.key in
let step = Soc2cDep.step_name soc.key "step" in let step = Soc2cDep.step_name soc.key "step" in
...@@ -687,7 +687,7 @@ void _put_real(char* n, _real _V){ ...@@ -687,7 +687,7 @@ void _put_real(char* n, _real _V){
if(ISATTY) printf(\"%s = \", n); if(ISATTY) printf(\"%s = \", n);
printf(\"%f \", _V); printf(\"%f \", _V);
if(ISATTY) printf(\"\\n\"); if(ISATTY) printf(\"\\n\");
} }"^(Soc2cExtern.gen_getters licprg)^"
/* Output procedures **********************/ /* Output procedures **********************/
#ifdef CKCHECK #ifdef CKCHECK
void %s_BOT_n(void* cdata){ void %s_BOT_n(void* cdata){
...@@ -738,13 +738,19 @@ int main(){ ...@@ -738,13 +738,19 @@ int main(){
if io_transmit_mode () = Lv6MainArgs.Stack if io_transmit_mode () = Lv6MainArgs.Stack
then then
let i = fst (List.split inputs) in let i = fst (List.split inputs) in
let o = List.map (fun (n,t) -> match t with Data.Array(_,_) -> n | _ ->"&"^n) outputs in let o = List.map
(fun (n,t) -> match t with Data.Array(_,_) -> n | _ ->"&"^n)
outputs
in
let io = String.concat "," (i@o) in let io = String.concat "," (i@o) in
let io = if SocUtils.is_memory_less soc then io else if io = "" then "ctx" else io^",ctx" in let io = if SocUtils.is_memory_less soc then io
else if io = "" then "ctx" else io^",ctx"
in
putc (" " ^ step^"("^io^"); putc (" " ^ step^"("^io^");
// printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^ // printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^
(String.concat " " outputs_fmt)^ "\\n\"," ^ (String.concat " " outputs_fmt)^ "\\n\"," ^
(String.concat "," (List.map (fun (id,_) -> ""^id ) (inputs_exp@outputs_exp)))^ (String.concat "," (List.map (fun (id,_) -> ""^id )
(inputs_exp@outputs_exp)))^
"); ");
printf(\"" ^ printf(\"" ^
(String.concat " " outputs_fmt)^ "\\n\"," ^ (String.concat " " outputs_fmt)^ "\\n\"," ^
...@@ -755,7 +761,8 @@ int main(){ ...@@ -755,7 +761,8 @@ int main(){
putc (" " ^ step^"(ctx); putc (" " ^ step^"(ctx);
// printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^ // printf(\"" ^ (String.concat " " inputs_fmt)^ " #outs " ^
(String.concat " " outputs_fmt)^ "\\n\"," ^ (String.concat " " outputs_fmt)^ "\\n\"," ^
(String.concat "," (List.map (fun (id,_) -> "ctx->"^id ) (inputs_exp@outputs_exp)))^ (String.concat "," (List.map (fun (id,_) -> "ctx->"^id )
(inputs_exp@outputs_exp)))^
"); ");
printf(\"" ^ printf(\"" ^
(String.concat " " outputs_fmt)^ "\\n\"," ^ (String.concat " " outputs_fmt)^ "\\n\"," ^
...@@ -908,7 +915,7 @@ typedef float _float; ...@@ -908,7 +915,7 @@ typedef float _float;
gen_main_wcet_file main_soc base stbl gen_main_wcet_file main_soc base stbl
) )
else else
gen_loop_file main_soc base ocl stbl; gen_loop_file licprg main_soc base ocl stbl;
output_string och " output_string och "
#include <stdlib.h> #include <stdlib.h>
......
(* Time-stamp: <modified the 06/09/2016 (at 10:39) by Erwan Jahier> *) (* Time-stamp: <modified the 05/05/2017 (at 14:14) by Erwan Jahier> *)
open Soc2cIdent open Soc2cIdent
...@@ -94,6 +94,23 @@ let (const_declaration : LicPrg.t -> string) = ...@@ -94,6 +94,23 @@ let (const_declaration : LicPrg.t -> string) =
let str = LicPrg.fold_consts const_to_string prg "" in let str = LicPrg.fold_consts const_to_string prg "" in
if str = "" then "" else (preambule^str^"\n") if str = "" then "" else (preambule^str^"\n")
let (gen_getters : LicPrg.t -> string) =
fun prg ->
let type_to_string k t acc =
if is_extern_type t then
Printf.sprintf "%s
_integer _get_%s(char* n) {
_integer r;
r = _get_int(n);
return r;
}" acc (long2s k)
else acc
in
let preambule = "\n/* XXX FIXME: The getters may need to be fixed too */" in
let str = LicPrg.fold_types type_to_string prg "" in
if str = "" then "" else (preambule^""^str^"\n")
open Soc open Soc
let (gen_files : Soc.t -> Soc.tbl -> LicPrg.t -> string -> string -> string -> let (gen_files : Soc.t -> Soc.tbl -> LicPrg.t -> string -> string -> string ->
......
(* Time-stamp: <modified the 03/10/2014 (at 17:42) by Erwan Jahier> *) (* Time-stamp: <modified the 05/05/2017 (at 11:31) by Erwan Jahier> *)
(* [gen_files main_soc licprg cfile hfile] returns a pair of bool that (* [gen_files main_soc licprg cfile hfile] returns a pair of bool that
...@@ -22,3 +22,5 @@ val gen_files : Soc.t -> Soc.tbl -> LicPrg.t -> string -> string -> string -> bo ...@@ -22,3 +22,5 @@ val gen_files : Soc.t -> Soc.tbl -> LicPrg.t -> string -> string -> string -> bo
(* val cpy_declaration : LicPrg.t -> string *) (* val cpy_declaration : LicPrg.t -> string *)
val const_declaration : LicPrg.t -> string val const_declaration : LicPrg.t -> string
(* ext type getters for the _loop.c file *)
val gen_getters : LicPrg.t -> string
(* Time-stamp: <modified the 10/01/2017 (at 17:04) by Erwan Jahier> *) (* Time-stamp: <modified the 05/05/2017 (at 15:00) by Erwan Jahier> *)
open Data open Data
open Lic open Lic
...@@ -52,12 +52,29 @@ let (f: Data.t -> string) = ...@@ -52,12 +52,29 @@ let (f: Data.t -> string) =
fun t -> fun t ->
let t_str = Soc2cIdent.type_to_short_string t in let t_str = Soc2cIdent.type_to_short_string t in
let t_def = let t_def =
match t with
| Bool | Int | Real | Enum _->
Printf.sprintf "
#ifndef _assign_%s
#define _assign_%s(dest, source, size) dest = source
#endif
" t_str t_str
| Extern _ ->
Printf.sprintf "
#ifndef _assign_%s
#define _assign_%s(dest, source, size) dest = source // XXX fixme if not a basic type
#endif
" t_str t_str
| Struct _
| Array _
| Alpha _
| Alias _ ->
Printf.sprintf " Printf.sprintf "
#ifndef _assign_%s #ifndef _assign_%s
#define _assign_%s(dest, source, size) memcpy(dest, source, size) #define _assign_%s(dest, source, size) memcpy(dest, source, size)
#endif #endif
" " t_str t_str
t_str t_str
in in
t_def t_def
......
==> lus2lic0.sum <== ==> lus2lic0.sum <==
Test Run By jahier on Wed May 3 11:10:48 Test Run By jahier on Fri May 5 14:48:31
Native configuration is x86_64-unknown-linux-gnu Native configuration is x86_64-unknown-linux-gnu
=== lus2lic0 tests === === lus2lic0 tests ===
...@@ -64,7 +64,7 @@ XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/lecte ...@@ -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 XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/s.lus
==> lus2lic1.sum <== ==> lus2lic1.sum <==
Test Run By jahier on Wed May 3 11:10:49 Test Run By jahier on Fri May 5 14:48:32
Native configuration is x86_64-unknown-linux-gnu Native configuration is x86_64-unknown-linux-gnu
=== lus2lic1 tests === === lus2lic1 tests ===
...@@ -398,7 +398,7 @@ PASS: sh multipar.sh ...@@ -398,7 +398,7 @@ PASS: sh multipar.sh
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus {} PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus {}
==> lus2lic2.sum <== ==> lus2lic2.sum <==
Test Run By jahier on Wed May 3 11:11:42 Test Run By jahier on Fri May 5 14:49:40
Native configuration is x86_64-unknown-linux-gnu Native configuration is x86_64-unknown-linux-gnu
=== lus2lic2 tests === === lus2lic2 tests ===
...@@ -738,7 +738,7 @@ PASS: sh zzz2.sh ...@@ -738,7 +738,7 @@ PASS: sh zzz2.sh
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus {} PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus {}
==> lus2lic3.sum <== ==> lus2lic3.sum <==
Test Run By jahier on Wed May 3 11:12:38 Test Run By jahier on Fri May 5 14:50:52
Native configuration is x86_64-unknown-linux-gnu Native configuration is x86_64-unknown-linux-gnu
=== lus2lic3 tests === === lus2lic3 tests ===
...@@ -1243,7 +1243,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {} ...@@ -1243,7 +1243,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {}
==> lus2lic4.sum <== ==> lus2lic4.sum <==
Test Run By jahier on Wed May 3 11:14:21 Test Run By jahier on Fri May 5 14:52:50
Native configuration is x86_64-unknown-linux-gnu Native configuration is x86_64-unknown-linux-gnu
=== lus2lic4 tests === === lus2lic4 tests ===
...@@ -1761,13 +1761,13 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {} ...@@ -1761,13 +1761,13 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {}
=============================== ===============================
# Total number of failures: 23 # Total number of failures: 23
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 53 seconds lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 67 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 56 seconds lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 72 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 103 seconds lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 117 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 51 seconds lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 63 seconds
* Ref time: * Ref time:
0.04user 0.03system 4:24.42elapsed 0%CPU (0avgtext+0avgdata 5608maxresident)k 0.06user 0.01system 5:22.26elapsed 0%CPU (0avgtext+0avgdata 5584maxresident)k
64inputs+0outputs (0major+6167minor)pagefaults 0swaps 96inputs+0outputs (0major+6151minor)pagefaults 0swaps
* Quick time (-j 4): * Quick time (-j 4):
0.04user 0.03system 2:23.84elapsed 0%CPU (0avgtext+0avgdata 5680maxresident)k 0.07user 0.00system 2:03.28elapsed 0%CPU (0avgtext+0avgdata 5572maxresident)k
64inputs+0outputs (0major+6173minor)pagefaults 0swaps 160inputs+0outputs (0major+6170minor)pagefaults 0swaps
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