diff --git a/guides/users/Makefile b/guides/users/Makefile index cee812155b05ab89201363d9d2a71c7e74cb921f..70239830e13814fca9ebcd943ec4902cb191703a 100644 --- a/guides/users/Makefile +++ b/guides/users/Makefile @@ -13,6 +13,10 @@ algo: emacs25 --batch --eval="(add-to-list 'load-path \".\") (add-to-list 'load-path \"./el\")" --eval="(require 'htmlize)" --load=emacs-org.el \ --visit=$*.org --funcall org-html-export-to-html +%.html3:%.org + emacs --batch --eval="(add-to-list 'load-path \".\") (add-to-list 'load-path \"./el\")" --eval="(require 'htmlize)" --load=emacs-org.el \ + --visit=$*.org --funcall org-html-export-to-html + EMACS=emacs25 \ --load=htmlize.el \ --load=el/ob-ocaml.el \ @@ -22,4 +26,4 @@ EMACS=emacs25 \ $(EMACS) --visit=$*.org --funcall org-html-export-to-html --eval "(kill-emacs)" -Q clean: - rm *.html + rm *.html rdbg-session*.ml diff --git a/guides/users/README.org b/guides/users/README.org index 4c2ea13917fc25f94f305a196758732cc5be6784..2da1c52cee4ac42218e459099add43edd70a167a 100644 --- a/guides/users/README.org +++ b/guides/users/README.org @@ -196,7 +196,7 @@ values. In order to enter such input more easily, one can use [[http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/lustre-v6/#outline-container-sec-8][=luciole-rif=]] #+BEGIN_SRC sh -luciole-rif sasa ring.dot --custom-daemon +# luciole-rif sasa ring.dot --custom-daemon #+END_SRC @@ -336,8 +336,8 @@ This make rule (defined in =Makefile= and =../Makefile.inc=) 2. launches =rdbg= with some arguments. =rdbg= then prompts the user to enter one of the folling commands: -#+BEGIN_SRC sh -rdbg -o ring.rif -sut "$(sasa) ring.dot --locally-central-daemon" +#+BEGIN_SRC sh :exports results +rdbg -o ring.rif -sut "sasa ring.dot --locally-central-daemon" [] create a fresh session [q] quit @@ -346,6 +346,8 @@ rdbg -o ring.rif -sut "$(sasa) ring.dot --locally-central-daemon" [/q/s]: #+END_SRC +#+RESULTS: + By default, the first in the list is executed; hence if you press =[Return]= without any command, a fresh session is created. More precisely it creates a =rdbg_session.ml= file, that loads all @@ -375,6 +377,8 @@ $ rdbg [/c/q/s]: #+END_SRC +#+RESULTS: + Typing =[Enter]= will therefore also load the =rdbg_session.ml= file we have just been using. diff --git a/lib/sasa/sasaRun.ml b/lib/sasa/sasaRun.ml index 093ff48aa197db34fc8c81f403aea02dcb38f0ce..a106cb3ce18360fea845330c056824da9974e163 100644 --- a/lib/sasa/sasaRun.ml +++ b/lib/sasa/sasaRun.ml @@ -164,6 +164,7 @@ let (make_do: string array -> SasArg.t -> step_dbg = step_dbg; save_state = (fun i -> let prgs = Random.get_state () in + (* Printf.eprintf "Save state %i from sasa\n%!" i; *) Hashtbl.replace ss_table i (prgs, !sasa_env, !pre_enable_processes_opt) ); @@ -171,6 +172,7 @@ let (make_do: string array -> SasArg.t -> match Hashtbl.find_opt ss_table i with | Some (prgs, e, pepo) -> Random.set_state prgs; + (* Printf.eprintf "Restore state %i from sasa\n%!" i; *) sasa_env := e; pre_enable_processes_opt := pepo | None -> Printf.eprintf "Cannot restore state %i from sasa\n" i; diff --git a/lib/sasacore/topology.mli b/lib/sasacore/topology.mli index f474da5e31d383c0eb864e9e88804742de7d6140..a27f0e6dde7311ded6171929042e486bf8465fb5 100644 --- a/lib/sasacore/topology.mli +++ b/lib/sasacore/topology.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 24/08/2020 (at 11:25) by Erwan Jahier> *) +(* Time-stamp: <modified the 31/08/2020 (at 16:45) by Erwan Jahier> *) (** {1 Topology: internal representation of Graphs } *) diff --git a/sasa.opam b/sasa.opam index 03f1d9453948546314d539b2ea104aa82d1a4fcc..911122630d200b21266d0175e1e5cf9ccfcd49ed 100644 --- a/sasa.opam +++ b/sasa.opam @@ -23,8 +23,10 @@ depends: [ "dune" { >= "1.11" } "ocamlgraph" "lutils" - "lustre-v6" - "lutin" "rdbg" { >= "1.184" } ] +depopts: [ + "lustre-v6" + "lutin" + ] post-messages: ["The last version can be obtained via (opam repo add) http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/opam-repository/ "] diff --git a/test/Makefile b/test/Makefile index c600bd0d02114af2603ae06233d335699536c976..ad9d30a7638ce14b3fa2fb3855335a6da3dfcd1f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -22,6 +22,9 @@ clean: cd async-unison/ && make clean cd coloring/ && make clean cd alea-coloring/ && make clean + cd alea-coloring-unif/ && make clean + cd alea-coloring-alt/ && make clean + cd alea-coloring/ && make clean cd bfs-spanning-tree/ && make clean cd dfs/ && make clean cd dfs-list/ && make clean diff --git a/test/rdbg-utils/dot.ml b/test/rdbg-utils/dot.ml index ce94125c4f7d046e6e2755755a7f996ee8067cbc..74d3bc2056bed6c378b06adef79ef56a4117954e 100644 --- a/test/rdbg-utils/dot.ml +++ b/test/rdbg-utils/dot.ml @@ -60,7 +60,8 @@ let (get_processes : RdbgEvent.t -> process list) = match List.find_opt (fun (_,n0, _) -> n=n0) acti_pid with | Some (_,_,activ) -> (n, enabv = Data.B true, activ = B true) - | None -> assert false + | None -> + (n, enabv = Data.B true, false) in let pid = { name = pid; diff --git a/test/sasa-rdbg-cmds.ml b/test/sasa-rdbg-cmds.ml index a9d332ef6c5520489de4fb2cd6d76ad934e94d4e..443d622472a149207f043930d35f18aaa0e447dc 100644 --- a/test/sasa-rdbg-cmds.ml +++ b/test/sasa-rdbg-cmds.ml @@ -10,7 +10,7 @@ Look at the sasa/test/*/my-rdbg-commands.ml files for examples (* Dealing with rounds *) let roundnb = ref 1 let roundtbl = Hashtbl.create 1;; - +let _ = Hashtbl.add roundtbl 1 (1,true);; (**********************************************************************) @@ -131,7 +131,7 @@ let (round : RdbgEvent.t -> bool) = let update_round_nb e = match Hashtbl.find_opt roundtbl e.nb with - | None -> roundnb := 1 + | None -> () | Some (n,_) -> roundnb := n (* go to next and previous rounds *) diff --git a/test/unison/Makefile b/test/unison/Makefile index e5f8ad86d2a066cbd49d929276c2af93a98e7cd8..f8bd5ed069678ede0dfb2b4933ebe40723b42a55 100644 --- a/test/unison/Makefile +++ b/test/unison/Makefile @@ -1,4 +1,4 @@ -# Time-stamp: <modified the 20/07/2020 (at 11:53) by Erwan Jahier> +# Time-stamp: <modified the 31/08/2020 (at 16:46) by Erwan Jahier> test: test1 test2 lurette0 lurette1 rdbg_test test3 @@ -52,6 +52,9 @@ lurette: lurette0 s g rdbg: ring.ml rdbg -o unison.rif -sut "$(sasa) ring.dot -sd -rif" +rdbg2: ring.ml + rdbg -o unison.rif -sut "sasa ring.dot -custd -rif" + rdbg_test: ring.ml echo "\nn\ns\nsi 4\nn\nni 3\nq\n" | rdbg -o unison.rif \ -sut "$(sasa) ring.dot -sd -rif" \ diff --git a/test/unison/my-rdbg-tuning.ml b/test/unison/my-rdbg-tuning.ml index dfa39adc88b880a708d08b24e4d5d7a421879caf..3733078c0048c7e3908bc4f699cab8c0af71ce75 100644 --- a/test/unison/my-rdbg-tuning.ml +++ b/test/unison/my-rdbg-tuning.ml @@ -1,13 +1,12 @@ (* *) - let sync sl = let sl = List.filter (fun (n,v) -> String.length n > 5 && String.sub n 0 5 = "Enab_") sl in Some (List.map (fun (n,v) -> String.sub n 5 ((String.length n)-5),v) sl) let _ = - rdbg_mv_hook := None; rdbg_mv_hook := Some sync; + rdbg_mv_hook := None; () ;; diff --git a/tools/gg-deco/ggDeco.ml b/tools/gg-deco/ggDeco.ml index d1a5841575d70a8b8cf37e25e11099ef03d057ad..8cdef468a4bf9e5ccc0179204f2c3a4bb1bc17ad 100644 --- a/tools/gg-deco/ggDeco.ml +++ b/tools/gg-deco/ggDeco.ml @@ -67,17 +67,18 @@ let to_dot_string : (t -> string -> string) = let nodes = String.concat "" (List.map node_to_node_string g.Topology.nodes) in let node_to_link_string n = let succ = g.succ n.id in + let link_kind = if g.directed then "->" else "--" in let links = List.map (fun (w,neighbour) -> (match w with | 1 -> - if n.id < neighbour then - Printf.sprintf (" %s -- %s") n.id neighbour + if n.id < neighbour || g.directed then + Printf.sprintf (" %s %s %s") n.id link_kind neighbour else - Printf.sprintf (" %s -- %s") neighbour n.id + Printf.sprintf (" %s %s %s") neighbour link_kind n.id | x -> - Printf.sprintf (" %s -- %s [weight=%d]") n.id neighbour x + Printf.sprintf (" %s %s %s [weight=%d]") n.id link_kind neighbour x ) ) succ @@ -87,7 +88,8 @@ let to_dot_string : (t -> string -> string) = let links = List.map node_to_link_string g.nodes in let links = List.sort_uniq compare (List.flatten links) in let links = String.concat "\n" links in - Printf.sprintf "graph %s {\n%s\n%s\n%s\n}\n" name attr nodes links + Printf.sprintf "%s %s {\n%s\n%s\n%s\n}\n" (if g.directed then "digraph" else "graph") + name attr nodes links let make_dot : (t -> string -> unit) = diff --git a/tools/gg/classicGraph.ml b/tools/gg/classicGraph.ml index 7e5c8001eadbe5dafe54ae55b07e8eba82f1c121..76d117d690152683fd9c9bca45464a2315cdf372 100644 --- a/tools/gg/classicGraph.ml +++ b/tools/gg/classicGraph.ml @@ -45,25 +45,11 @@ let (gen_star: bool -> int -> Topology.t) = attributes = [] } -let add_weight (li : node_id list) : (int * node_id) list = map (fun elem -> (1,elem)) li - let neighbours_ring : (node_id list -> (node_id -> (int * node_id) list)) = - fun li -> - let node_succ:node_succ_t = Hashtbl.create (length li) in - let ((_,last),ret) = fold_left (fun ((first,prev),accu) elem -> - if first = "" then - ((elem,elem),[[""; ""]]) - else - ( - match accu with - | [x;_]::tl -> ((first,elem),[prev;first]::([x;elem]::tl)) - | _ -> assert false - ) - ) (("",""),[]) li in let ret = rev ret in - let ret = (match ret with - | ["";x]::tail -> [last;x]::tail - | _ -> assert false) in - iter2 (fun neighbours elem -> Hashtbl.replace node_succ elem (add_weight neighbours)) ret li ; + fun nodes -> + let node_succ:node_succ_t = Hashtbl.create (length nodes) in + let nodes2 = (List.tl nodes)@[List.hd nodes] in + List.iter2 (fun n1 n2 -> Hashtbl.replace node_succ n1 [1,n2]) nodes nodes2; (fun n -> try Hashtbl.find node_succ n with Not_found -> []) let (gen_ring: bool -> int -> Topology.t) = diff --git a/tools/gg/graphGen.ml b/tools/gg/graphGen.ml index 39421ba00ca987338a859ed76fee4360f98e8e09..4e35fd346e77cff914a22d8c0dd412906f10de5a 100644 --- a/tools/gg/graphGen.ml +++ b/tools/gg/graphGen.ml @@ -157,21 +157,22 @@ let to_dot_string : (Topology.t -> string -> (string * string) list -> string) let node_to_link_string n = let succ = g.succ n.Topology.id in + let link_kind = if g.directed then "->" else "--" in let links = List.map (fun (w,neighbour) -> (match w with | 1 -> assert (n.Topology.id <> neighbour); - if n.Topology.id < neighbour then - Printf.sprintf (" %s -- %s") n.Topology.id neighbour + if n.Topology.id < neighbour || g.directed then + Printf.sprintf (" %s %s %s") n.Topology.id link_kind neighbour else - Printf.sprintf (" %s -- %s") neighbour n.Topology.id + Printf.sprintf (" %s %s %s") neighbour link_kind n.Topology.id | x -> - if n.Topology.id < neighbour then - Printf.sprintf (" %s -- %s [weight=%d]") n.Topology.id neighbour x + if n.Topology.id < neighbour || g.directed then + Printf.sprintf (" %s %s %s [weight=%d]") n.Topology.id link_kind neighbour x else - Printf.sprintf (" %s -- %s [weight=%d]") neighbour n.Topology.id x + Printf.sprintf (" %s %s %s [weight=%d]") neighbour link_kind n.Topology.id x ) ) succ diff --git a/tools/simca/Makefile b/tools/simca/Makefile index e69621ab974dd220eb24eabb87ba150c7dd6a874..6d5f075d9c0c7bed983c599b91d75b85a1d4c53f 100644 --- a/tools/simca/Makefile +++ b/tools/simca/Makefile @@ -19,4 +19,4 @@ clean: rm -rf *.log *.data *.pdf Makefile.expe-rules *~ *.png cmxs_done -.PRECIOUS: .sh +.PRECIOUS: .sh .dot.sh diff --git a/tools/simca/coloring_campaign.ml b/tools/simca/coloring_campaign.ml index c46381557b4384a630fb369d9b91b0929ae033fa..6902c24440915cf648ef8e5d1d98b34c5d5cad9e 100644 --- a/tools/simca/coloring_campaign.ml +++ b/tools/simca/coloring_campaign.ml @@ -14,30 +14,18 @@ let daemons = ["-sd";"-lcd";"-dd"] let rings = List.init 10 (fun n -> Ring (500*(n+1))) (* [500; 1000; ...; 5000] *) let cliques = List.init 10 (fun n -> Clique (30*(n+1))) (* [30; 60; ...; 300] *) let er = List.init 10 (fun n -> ER (30*(n+1), 0.4)) (* [30; 60; ...; 300] *) - -let gen_make_rules () = - let fn = "Makefile.expe-rules" in - let oc = open_out fn in - Printf.fprintf oc "# Generated by coloring_campaign.ml"; - let compare_neg x y = compare y x in - let l = List.sort_uniq compare_neg (cliques @ rings @ er) in - let targets,targets_cmxs = gen_makefile oc daemons algos l [] [] in - Printf.fprintf oc "\nCMXS=%s\n" (String.concat " " targets_cmxs); - Printf.fprintf oc "\nLOG=%s\n%!" (String.concat " " targets); - Printf.printf "%s has been generated\n%!" fn; - close_out oc -;; - +let networks = (cliques@rings@er) +let gen_make_rules () = gen_makefile "Makefile.expe-rules" daemons algos networks;; #use "parseLog.ml";; let gen_pdf () = let gl = ["clique"; "ring"; "er"] in List.iter (fun n -> sh ("rm -f "^n^".data")) gl; - parse_log ["Uniform When Activated","alea-coloring-unif"] gl daemons; - parse_log ["Smallest When Activated","alea-coloring"] gl daemons; - parse_log ["Always the Biggest","alea-coloring-alt"] gl daemons; - List.iter (fun n -> sh ("./gen_pdf_paper.r "^n^".data coloring")) gl; - () -;; + parse_log ["Col-a1","alea-coloring-unif"] gl daemons; + parse_log ["Col-a2","alea-coloring"] gl daemons; + parse_log ["Col-a3","alea-coloring-alt"] gl daemons; + List.iter (fun n -> sh ("./gen_pdf_paper.r "^n^".data coloring4zpaper")) gl; + List.iter (fun n -> sh ("./gen_pdf.r "^n^".data coloring")) gl + diff --git a/tools/simca/genExpeMakefiles.ml b/tools/simca/genExpeMakefiles.ml index a8c583a2a7b2b02febab60b288a03a5c7752fdfd..6ba5930b4d774fc599c28b171485b72cc7b7888d 100644 --- a/tools/simca/genExpeMakefiles.ml +++ b/tools/simca/genExpeMakefiles.ml @@ -42,6 +42,7 @@ let precision = ref 0.01 size of the 3 complexity numbers under estimation is smaller than 1% of their current estimation. *) +let directed = ref false (* *) let max_simu_nb = ref 10000 (* no more simulations are done once reached *) let timeout_in_sec = ref 10000 (* Ditto, once overtaken *) let regen_dot = ref true;; (* regenerate the graph before every simulation *) @@ -59,7 +60,23 @@ let regen_dot = ref true;; (* regenerate the graph before every simulation *) More precisely, it adds to the input list [targets_log] [targets_cmxs] the log and cmxs targets that were written on [oc]. *) -let (gen_makefile : out_channel -> daemon list -> dir list +let (gen_makefile : string -> daemon list -> dir list -> graph list -> unit ) = + fun fn dl dirl gl -> + let oc = open_out fn in + Printf.fprintf oc "# Generated by coloring_campaign.ml"; + let targets_log, targets_cmxs = List.fold_left (gen_makefile0 oc dl dirl) ([], []) gl in + Printf.fprintf oc "\n# ZZZ do not do 'make -j 20 $(CMXS)'! (p.cmxs is regenerated +# at each target, which causes failures)\n"; + Printf.fprintf oc "\n# But 'make -j 20 $(LOG)' is fine!\n%!"; + Printf.fprintf oc "\nCMXS=%s\n" (String.concat " " targets_cmxs); + Printf.fprintf oc "\nLOG=%s\n%!" (String.concat " " targets_log); + Printf.printf "%s has been generated\n%!" fn; + close_out oc + +(** Ditto, by building the list of deps incrementally. Requires the caller to print the +CMXS and LOG makefile files + *) +let (gen_makefile_incr : out_channel -> daemon list -> dir list -> graph list -> string list -> string list -> string list * string list) = fun oc dl dirl gl targets_log targets_cmxs -> let targets_log, targets_cmxs = diff --git a/tools/simca/genExpeMakefilesUtils.ml b/tools/simca/genExpeMakefilesUtils.ml index 1dccbbd95ca75940f54bcfede7bb2ab06bc2580f..7451088a3fcb277152a37bdb3d4932ebdc59e890 100644 --- a/tools/simca/genExpeMakefilesUtils.ml +++ b/tools/simca/genExpeMakefilesUtils.ml @@ -4,8 +4,8 @@ (** Generate a dot file with gg *) let gen_dot graph_kind dot dir = - let gg_cmd = Printf.sprintf "echo \"gg %s -o %s/%s.dot\" > %s/%s.dot.sh" - graph_kind dir dot dir dot in + let gg_cmd = Printf.sprintf "echo \"gg %s %s -o %s/%s.dot\" > %s/%s.dot.sh" + graph_kind (if !directed then "-dir" else "") dir dot dir dot in gg_cmd (** Decorate gg generated dot files with gg-deco *) diff --git a/tools/simca/gen_pdf.r b/tools/simca/gen_pdf.r index ae5ebbcda8ec17ecce64700e2ba2cb666693562e..5f2024ed0b22b518ec31ed6c8e2b1e6259ef7a87 100755 --- a/tools/simca/gen_pdf.r +++ b/tools/simca/gen_pdf.r @@ -26,6 +26,9 @@ data <- data.frame(val=read.table(datafilename)) # Give to columns a name names(data) <- c("n", "Daemons", "Algorithms", "complexity_kind", "min", "mean", "max") +# Ordering the grid manually +data$complexity_kind_f = factor(data$complexity_kind, levels=c('rounds','steps','moves')) + # Generate a pdf visualisation of the Data with ggplot2 library(ggplot2) library(dplyr) @@ -33,8 +36,8 @@ library(dplyr) gen_pdf <- function(pdffilename, x1, x2){ pdf(pdffilename,onefile=TRUE) mplot <- ggplot(data, aes_string(x="n",y="mean",colour=x1))+ geom_line() + - facet_grid(c(paste("complexity_kind"), paste(x2)) , scales='free') + - ylab("Move/Step/Round Numbers")+xlab(paste(abscissa,"Number"))+ + facet_grid(c(paste("complexity_kind_f"), paste(x2)) , scales='free') + + ylab("Round/Step/Move Numbers")+xlab(paste(abscissa,"Number"))+ ggtitle(paste("Compare", x1, "on various", x2, "Numbers on", stringr::str_to_title(graphname), sep = " "))+ theme(legend.position="bottom") diff --git a/tools/simca/nonreg_test_campaign.ml b/tools/simca/nonreg_test_campaign.ml index a9f279dcced63d20d5df998c038d64079f61323f..7d030796931971e39d553adc7454c4c5dee1508d 100644 --- a/tools/simca/nonreg_test_campaign.ml +++ b/tools/simca/nonreg_test_campaign.ml @@ -15,30 +15,17 @@ let daemons = ["-sd";"-lcd";"-dd"] let cliques = List.init 5 (fun n -> Clique (10*(n+1))) (* [10; 20; ...; 50] *) let rings = List.init 5 (fun n -> Ring (100*(n+1))) (* [100; 200; ...; 500] *) let er = List.init 5 (fun n -> ER (20*(n+1), 0.4)) (* [20; 40; ...; 100] *) - -let gen_make_rules () = - let fn = "Makefile.expe-rules" in - let oc = open_out fn in - Printf.fprintf oc "# Generated by nonreg_test_campaign.ml"; - (* 5 Cliques and 5 rings (not too big for the CI scripts) *) - let compare_neg x y = compare y x in - let l = List.sort_uniq compare_neg (cliques @ rings @ er) in - let targets,targets_cmxs = gen_makefile oc daemons algos l [] [] in - Printf.fprintf oc "\nCMXS=%s\n" (String.concat " " targets_cmxs); - Printf.fprintf oc "\nLOG=%s\n%!" (String.concat " " targets); - Printf.printf "%s has been generated\n%!" fn; - close_out oc -;; +let networks = (cliques@rings@er) + +let gen_make_rules () = gen_makefile "Makefile.expe-rules" daemons algos networks #use "parseLog.ml";; -open Printf let gen_pdf () = let gl = ["clique"; "ring"; "er"] in List.iter (fun n -> sh ("rm -f "^n^".data")) gl; (* because parse_log appends data *) parse_log ["Uniform When Activated", "alea-coloring-unif"] gl daemons; parse_log ["Smallest When Activated","alea-coloring"] gl daemons; parse_log ["Always the Biggest", "alea-coloring-alt"] gl daemons; - List.iter (fun n -> sh ("./gen_pdf.r "^n^".data nonreg")) gl; - () -;; + List.iter (fun n -> sh ("./gen_pdf.r "^n^".data nonreg")) gl + diff --git a/tools/simca/spanning_tree_campaign.ml b/tools/simca/spanning_tree_campaign.ml index a58268ba5c756a2a7a1f0e801bfe325a4a7cce91..8077a74d015565a790d32bd0214b1b0b498c00c5 100644 --- a/tools/simca/spanning_tree_campaign.ml +++ b/tools/simca/spanning_tree_campaign.ml @@ -17,7 +17,7 @@ let gen_make_rules () = Printf.fprintf oc "# Generated by spanning_tree_campaign.ml / gen_make_rules"; let compare_neg x y = compare y x in let l = List.sort_uniq compare_neg (cliques @ er) in - let targets,targets_cmxs = gen_makefile oc daemons algos l [] [] in + let targets,targets_cmxs = gen_makefile_incr oc daemons algos l [] [] in Printf.fprintf oc "\nCMXS=%s\n" (String.concat " " targets_cmxs); Printf.fprintf oc "\nLOG=%s\n%!" (String.concat " " targets); Printf.printf "%s has been generated\n%!" fn;