]> matita.cs.unibo.it Git - helm.git/commitdiff
- we now use a streaming architecture (run time gain: 11 secs)
authorFerruccio Guidi <ferruccio.guidi@unibo.it>
Tue, 11 Nov 2008 17:05:12 +0000 (17:05 +0000)
committerFerruccio Guidi <ferruccio.guidi@unibo.it>
Tue, 11 Nov 2008 17:05:12 +0000 (17:05 +0000)
- we added some time stamp support

18 files changed:
helm/software/lambda-delta/.depend.opt
helm/software/lambda-delta/Makefile
helm/software/lambda-delta/Makefile.common
helm/software/lambda-delta/automath/aut.ml
helm/software/lambda-delta/automath/autOutput.ml
helm/software/lambda-delta/automath/autOutput.mli
helm/software/lambda-delta/automath/autParser.mly
helm/software/lambda-delta/cps/Make [deleted file]
helm/software/lambda-delta/cps/cps.ml [deleted file]
helm/software/lambda-delta/lib/Make [new file with mode: 0644]
helm/software/lambda-delta/lib/cps.ml [new file with mode: 0644]
helm/software/lambda-delta/lib/time.ml [new file with mode: 0644]
helm/software/lambda-delta/toplevel/meta.ml
helm/software/lambda-delta/toplevel/metaAut.ml
helm/software/lambda-delta/toplevel/metaAut.mli
helm/software/lambda-delta/toplevel/metaOutput.ml
helm/software/lambda-delta/toplevel/metaOutput.mli
helm/software/lambda-delta/toplevel/top.ml

index 144dab5e639ab2185833ff468946eb72872f91ab..f5f529ef70ec8db3f3549e989e227af15506b37c 100644 (file)
@@ -1,6 +1,6 @@
 automath/autOutput.cmi: automath/aut.cmx 
-automath/autOutput.cmo: cps/cps.cmx automath/aut.cmx automath/autOutput.cmi 
-automath/autOutput.cmx: cps/cps.cmx automath/aut.cmx automath/autOutput.cmi 
+automath/autOutput.cmo: lib/cps.cmx automath/aut.cmx automath/autOutput.cmi 
+automath/autOutput.cmx: lib/cps.cmx automath/aut.cmx automath/autOutput.cmi 
 automath/autParser.cmi: automath/aut.cmx 
 automath/autParser.cmo: automath/aut.cmx automath/autParser.cmi 
 automath/autParser.cmx: automath/aut.cmx automath/autParser.cmi 
@@ -9,16 +9,18 @@ automath/autLexer.cmx: automath/autParser.cmx
 toplevel/meta.cmo: automath/aut.cmx 
 toplevel/meta.cmx: automath/aut.cmx 
 toplevel/metaOutput.cmi: toplevel/meta.cmx 
-toplevel/metaOutput.cmo: toplevel/meta.cmx cps/cps.cmx \
+toplevel/metaOutput.cmo: toplevel/meta.cmx lib/cps.cmx \
     toplevel/metaOutput.cmi 
-toplevel/metaOutput.cmx: toplevel/meta.cmx cps/cps.cmx \
+toplevel/metaOutput.cmx: toplevel/meta.cmx lib/cps.cmx \
     toplevel/metaOutput.cmi 
 toplevel/metaAut.cmi: toplevel/meta.cmx automath/aut.cmx 
-toplevel/metaAut.cmo: toplevel/meta.cmx cps/cps.cmx automath/aut.cmx \
+toplevel/metaAut.cmo: toplevel/meta.cmx lib/cps.cmx automath/aut.cmx \
     toplevel/metaAut.cmi 
-toplevel/metaAut.cmx: toplevel/meta.cmx cps/cps.cmx automath/aut.cmx \
+toplevel/metaAut.cmx: toplevel/meta.cmx lib/cps.cmx automath/aut.cmx \
     toplevel/metaAut.cmi 
-toplevel/top.cmo: toplevel/metaOutput.cmi toplevel/metaAut.cmi cps/cps.cmx \
-    automath/autParser.cmi automath/autOutput.cmi automath/autLexer.cmx 
-toplevel/top.cmx: toplevel/metaOutput.cmx toplevel/metaAut.cmx cps/cps.cmx \
-    automath/autParser.cmx automath/autOutput.cmx automath/autLexer.cmx 
+toplevel/top.cmo: lib/time.cmx toplevel/metaOutput.cmi toplevel/metaAut.cmi \
+    lib/cps.cmx automath/autParser.cmi automath/autOutput.cmi \
+    automath/autLexer.cmx 
+toplevel/top.cmx: lib/time.cmx toplevel/metaOutput.cmx toplevel/metaAut.cmx \
+    lib/cps.cmx automath/autParser.cmx automath/autOutput.cmx \
+    automath/autLexer.cmx 
index e62fb5dfcec5d5a6879ec66279cacb9105e2893a..50f1a83b69a100c7c8ca14138cece736e1f93f23 100644 (file)
@@ -1,8 +1,8 @@
 MAIN = helena
 
-DIRECTORIES = cps automath toplevel
+DIRECTORIES = lib automath toplevel
 
-REQUIRES =
+REQUIRES = unix
 
 KEEP = README automath/*.aut
 
@@ -12,4 +12,4 @@ include Makefile.common
 
 test: opt
        @echo "  HELENA automath/*.aut"
-       $(H)./$(MAIN).opt -S 2 automath/*.aut > log.txt
+       $(H)./$(MAIN).opt -S 3 automath/*.aut > log.txt
index b6e08f89ea86b0e8975fb2687629ed0b2f3f3b18..0adedde842b7d0a8c60e1db26cf312cae2d7aff6 100644 (file)
@@ -3,7 +3,7 @@ H=@
 INCLUDES = $(DIRECTORIES:%=-I %) 
 
 OCAMLDEP  = ocamlfind ocamldep -native $(INCLUDES)
-OCAMLOPT  = ocamlfind opt -package "$(REQUIRES)" $(INCLUDES)
+OCAMLOPT  = ocamlfind opt -linkpkg -package "$(REQUIRES)" $(INCLUDES)
 OCAMLLEX  = ocamllex
 OCAMLYACC = ocamlyacc -v
 TAR       = tar -czf $(MAIN:%=%.tgz)
index c95d20a7ec82989f4d39e9c018e1c481608a85a3..66c252d5ec91e6e536d3b6aa5769db017f2e7dda 100644 (file)
@@ -37,5 +37,3 @@ type item = Section of id option           (* section: Some = open/reopen, None
          | Block of id * term             (* block opener: name, type *)
          | Decl of id * term              (* declaration: name, type *)
          | Def of id * term * bool * term (* definition: name, type, transparent?, body *)
-         
-type book = item list (* book *)
index 1acb075b2b99ae3cf9b25784140d3c64cc68ecee..4ccb74b5c3650531e906c6cfbe4b69d8d5373e8d 100644 (file)
@@ -75,9 +75,6 @@ let count_item f c = function
       let f c = count_term f c t in
       count_term f c w
 
-let count f c b =
-   Cps.list_fold_left f count_item c b
-
 let print_counters f c =
    let terms = c.sorts + c.grefs + c.appls + c.absts in
    let items = c.sections + c.contexts + c.blocks + c.decls + c.defs in
index 6ff94387b67164b9d7a0ff34a0a0817e2b1abafa..a7369741864084eeb32d96b049433a0ea92ff43a 100644 (file)
@@ -27,6 +27,6 @@ type counters
 
 val initial_counters: counters
 
-val count: (counters -> 'a) -> counters -> Aut.book -> 'a
+val count_item: (counters -> 'a) -> counters -> Aut.item -> 'a
 
 val print_counters: (unit -> 'a) -> counters -> 'a
index 2f7c06349a6589aba8b9789e170a9b198483430a..3bf5f3d00127802e6761ffe1bd34f1dfc74f6078 100644 (file)
@@ -32,7 +32,7 @@
    %token TYPE PROP DEF EB E PN EXIT
     
    %start book
-   %type <Aut.book> book   
+   %type <Aut.item list> book   
 %%
    path: MINUS {} | FS {} ;
    oftype: CN {} | CM {} ;
diff --git a/helm/software/lambda-delta/cps/Make b/helm/software/lambda-delta/cps/Make
deleted file mode 100644 (file)
index 0e12099..0000000
+++ /dev/null
@@ -1 +0,0 @@
-cps
diff --git a/helm/software/lambda-delta/cps/cps.ml b/helm/software/lambda-delta/cps/cps.ml
deleted file mode 100644 (file)
index 83570aa..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-(* Copyright (C) 2000, HELM Team.
- * 
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- * 
- * HELM is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * HELM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA  02111-1307, USA.
- * 
- * For details, see the HELM World-Wide-Web page,
- * http://cs.unibo.it/helm/.
- *)
-
-let id _ = ()
-
-let rec list_sub_strict f l1 l2 = match l1, l2 with
-   | _, []              -> f l1
-   | _ :: tl1, _ :: tl2 -> list_sub_strict f tl1 tl2
-   | _                  -> assert false
-
-let rec list_fold_left f map a = function
-   | []       -> f a
-   | hd :: tl -> 
-      let f a = list_fold_left f map a tl in
-      map f a hd
-
-let rec list_rev_map_append f map ~tail = function
-      | []       -> f tail        
-      | hd :: tl ->
-         let f hd = list_rev_map_append f map ~tail:(hd :: tail) tl in
-         map f hd
-
-let list_rev_append f =
-   list_rev_map_append f (fun f t -> f t)
-
-let list_rev_map =
-   list_rev_map_append ~tail:[]
-
-let list_rev =
-   list_rev_append ~tail:[]
-
-let list_map f =
-   list_rev_map (list_rev f)
-   
diff --git a/helm/software/lambda-delta/lib/Make b/helm/software/lambda-delta/lib/Make
new file mode 100644 (file)
index 0000000..60114a8
--- /dev/null
@@ -0,0 +1 @@
+cps time
diff --git a/helm/software/lambda-delta/lib/cps.ml b/helm/software/lambda-delta/lib/cps.ml
new file mode 100644 (file)
index 0000000..199a786
--- /dev/null
@@ -0,0 +1,56 @@
+(* Copyright (C) 2000, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+let id x = x
+
+let rec list_sub_strict f l1 l2 = match l1, l2 with
+   | _, []              -> f l1
+   | _ :: tl1, _ :: tl2 -> list_sub_strict f tl1 tl2
+   | _                  -> assert false
+
+let rec list_fold_left f map a = function
+   | []       -> f a
+   | hd :: tl -> 
+      let f a = list_fold_left f map a tl in
+      map f a hd
+
+let rec list_rev_map_append f map ~tail = function
+      | []       -> f tail        
+      | hd :: tl ->
+         let f hd = list_rev_map_append f map ~tail:(hd :: tail) tl in
+         map f hd
+
+let list_rev_append f =
+   list_rev_map_append f (fun f t -> f t)
+
+let list_rev_map =
+   list_rev_map_append ~tail:[]
+
+let list_rev =
+   list_rev_append ~tail:[]
+
+let list_map f =
+   list_rev_map (list_rev f)
+   
diff --git a/helm/software/lambda-delta/lib/time.ml b/helm/software/lambda-delta/lib/time.ml
new file mode 100644 (file)
index 0000000..2ea295a
--- /dev/null
@@ -0,0 +1,20 @@
+let utime_stamp =
+   let old = ref 0.0 in
+   fun msg -> 
+      let times = Unix.times () in
+      let stamp = times.Unix.tms_utime in
+      let lap = stamp -. !old in
+      Printf.printf "UTIME STAMP (%s): %f (%f)\n" msg stamp lap; flush stdout;
+      old := stamp
+
+let gmtime msg =
+   let gmt = Unix.gmtime (Unix.time ()) in
+   let yy = gmt.Unix.tm_year + 1900 in
+   let mm = gmt.Unix.tm_mon in
+   let dd = gmt.Unix.tm_mday in
+   let h = gmt.Unix.tm_hour in
+   let m = gmt.Unix.tm_min in
+   let s = gmt.Unix.tm_sec in
+   Printf.printf "UTC TIME STAMP (%s): %u/%u/%u %u:%u:%u\n" 
+      msg yy mm dd h m s;
+   flush stdout
index 23f8f52f5b5135d41f5509620183d75ca1af7991..4b04e3af89a7b2faffc9f80a9cfea47b62df264a 100644 (file)
@@ -35,5 +35,7 @@ type term = Sort of bool                  (* sorts: true = TYPE, false = PROP *)
 
 type pars = (qid * term) list (* parameter declarations: name, type *)
 
-(* environment: line number, parameters, name, type, (transparent?, body) *)
-type environment = (int * pars * qid * term * (bool * term) option) list
+(* entry: line number, parameters, name, type, (transparent?, body) *)
+type entry = int * pars * qid * term * (bool * term) option
+
+type item = entry option
index 5b85e46cbea703dd21fafe6f53b7242c6b5025b5..031e74cf2a731b17b7c5dc113c1e0b67b6266d01 100644 (file)
@@ -33,7 +33,6 @@ type environment = (M.qid, M.pars) H.t
 type context_node = M.qid option (* context node: None = root *)
 
 type status = {
-   genv: M.environment;      (* global environment *)
    henv: environment;        (* optimized global environment *)
    path: M.id list;          (* current section path *) 
    hcnt: environment;        (* optimized context *)   
@@ -48,8 +47,10 @@ type resolver = Local of int
 
 let hsize = 11 (* hash tables initial size *)
 
+(* Internal functions *******************************************************)
+
 let initial_status size = {
-   genv = []; path = []; node = None; nodes = []; line = 1; explicit = true;
+   path = []; node = None; nodes = []; line = 1; explicit = true;
    henv = H.create size; hcnt = H.create size
 }
 
@@ -149,24 +150,24 @@ let rec xlate_term f st lenv = function
 
 let xlate_item f st = function
    | A.Section (Some name)     ->
-      f {st with path = name :: st.path; nodes = st.node :: st.nodes}
+      f {st with path = name :: st.path; nodes = st.node :: st.nodes} None
    | A.Section None            ->
       begin match st.path, st.nodes with
         | _ :: ptl, nhd :: ntl -> 
-           f {st with path = ptl; node = nhd; nodes = ntl}
+           f {st with path = ptl; node = nhd; nodes = ntl} None
          | _                    -> assert false
       end
    | A.Context None            ->
-      f {st with node = None}
+      f {st with node = None} None
    | A.Context (Some name)     ->
-      let f name = f {st with node = Some name} in
-      complete_qid f st name
+      let f name = f {st with node = Some name} None in
+      complete_qid f st name 
    | A.Block (name, w)         ->
       let f name = 
          let f pars =
            let f ww = 
               H.add st.hcnt name ((name, ww) :: pars);
-              f {st with node = Some name}
+              f {st with node = Some name} None
            in
             xlate_term f st pars w
         in
@@ -179,7 +180,7 @@ let xlate_item f st = function
             let f ww =
               let entry = (st.line, pars, name, ww, None) in
               H.add st.henv name pars;
-              f {st with genv = entry :: st.genv; line = succ st.line}
+              f {st with line = succ st.line} (Some entry)
            in
            xlate_term f st pars w
         in
@@ -192,7 +193,7 @@ let xlate_item f st = function
             let f ww vv = 
               let entry = (st.line, pars, name, ww, Some (trans, vv)) in
               H.add st.henv name pars;
-              f {st with genv = entry :: st.genv; line = succ st.line}
+              f {st with line = succ st.line} (Some entry)
            in
            let f ww = xlate_term (f ww) st pars v in
            xlate_term f st pars w
@@ -201,6 +202,8 @@ let xlate_item f st = function
       in
       get_pars_relaxed f st
 
-let meta_of_aut f book =
-   let f st = f st.genv in
-   Cps.list_fold_left f xlate_item (initial_status hsize) book
+(* Interface functions ******************************************************)
+
+let initial_status = initial_status hsize
+
+let meta_of_aut = xlate_item
index 1172424c7a61bfac83e7fab702249b508d442b33..128215cc4d07a32943e94d785e2aff6180c90d23 100644 (file)
@@ -23,4 +23,8 @@
  * http://cs.unibo.it/helm/.
  *)
 
-val meta_of_aut: (Meta.environment -> 'a) -> Aut.book -> 'a
+type status
+
+val initial_status: status 
+
+val meta_of_aut: (status -> Meta.item -> 'a) -> status -> Aut.item -> 'a
index 4efee4a6833e511ba53428c3670cc2aec2e79082..7a15d07c250c5fa844958d63beeaab9a5b104384 100644 (file)
@@ -63,7 +63,7 @@ let rec count_term f c = function
 
 let count_par f c (_, w) = count_term f c w
 
-let count_item f c = function
+let count_entry f c = function
    | _, pars, _, w, None        ->
       let c = {c with eabsts = succ c.eabsts} in
       let c = {c with pabsts = c.pabsts + List.length pars} in
@@ -76,8 +76,9 @@ let count_item f c = function
       let f c = count_term f c w in
       Cps.list_fold_left f count_par c pars
 
-let count f c b =
-   Cps.list_fold_left f count_item c b
+let count_item f c = function
+   | Some e -> count_entry f c e
+   | None   -> f c
 
 let print_counters f c =
    let terms = c.tsorts + c.tgrefs + c.tgrefs + c.tappls + c.tabsts in
@@ -142,9 +143,10 @@ let pp_body frm = function
    | Some (trans, t) ->
       F.fprintf frm "%s%a" (string_of_transparent trans) pp_term t
 
-let pp_item frm (l, pars, qid, u, body) =
+let pp_entry frm (l, pars, qid, u, body) =
    F.fprintf frm "@[%u@@%s%a%a:%a@]@\n%!" 
       l (string_of_qid qid) pp_pars pars pp_body body pp_term u
 
-let pp_environment f frm genv =
-   List.iter (pp_item frm) genv; f ()
+let pp_item f frm = function 
+   | Some entry -> pp_entry frm entry; f ()
+   | None       -> f ()
index 83da0591e33af9348b75d75ab677a288c6ec2573..2095e2677da4eea4cdfb6575d9cc9b5e1f518ad1 100644 (file)
@@ -27,8 +27,8 @@ type counters
 
 val initial_counters: counters
 
-val count: (counters -> 'a) -> counters -> Meta.environment -> 'a
+val count_item: (counters -> 'a) -> counters -> Meta.item -> 'a
 
 val print_counters: (unit -> 'a) -> counters -> 'a
 
-val pp_environment: (unit -> 'a) -> Format.formatter -> Meta.environment -> 'a
+val pp_item: (unit -> 'a) -> Format.formatter -> Meta.item -> 'a
index dc2bfee9334bc4966ed8f2661e22dbcbb05af290..bb6dcd8433a5536377c26e41a64d82f9f4dafafd 100644 (file)
@@ -28,36 +28,65 @@ module MA = MetaAut
 module MO = MetaOutput
 
 let main =
-   let version_string = "Helena Checker 0.8.0 M (June 2008)" in
+   let version_string = "Helena Checker 0.8.0 M - November 2008" in
    let summary = ref 0 in
    let stage = ref 1 in
+   let meta_file = ref None in
    let set_summary i = summary := i in
    let print_version () = print_endline version_string; exit 0 in
    let set_stage i = stage := i in
+   let close = function
+      | None          -> ()
+      | Some (och, _) -> close_out och
+   in
+   let set_meta_file name =
+      close !meta_file;
+      let och = open_out name in
+      let frm = Format.formatter_of_out_channel och in
+      Format.pp_set_margin frm max_int;
+      meta_file := Some (och, frm)
+   in
    let read_file name =
-      if !summary > 0 then
+      if !summary > 0 then Time.gmtime version_string;      
+      if !summary > 1 then
          Printf.printf "Processing file: %s\n" name; flush stdout;
+      if !summary > 0 then Time.utime_stamp "started";
       let ich = open_in name in
       let lexbuf = Lexing.from_channel ich in
       let book = AutParser.book AutLexer.token lexbuf in
       close_in ich;
-      if !summary > 1 then
-        AO.count (AO.print_counters Cps.id) AO.initial_counters book;
-      let f env =
-        if !summary > 1 then
-           MO.count (MO.print_counters Cps.id) MO.initial_counters env;
-         let frm = Format.err_formatter in
-         Format.pp_set_margin frm max_int;
-         MO.pp_environment Cps.id frm (List.rev env)
+      if !summary > 0 then Time.utime_stamp "parsed";
+      let rec aux ac mc st = function
+         | []         -> ac, mc, st
+        | item :: tl -> 
+            let ac = if !summary > 2 then AO.count_item Cps.id ac item else ac in
+           let f st item = 
+              let mc = if !summary > 2 then MO.count_item Cps.id mc item else mc in
+              begin match !meta_file with
+                 | None          -> ()
+                 | Some (_, frm) -> MO.pp_item Cps.id frm item
+              end;
+              st, mc
+           in
+           let st, mc = if !stage > 0 then MA.meta_of_aut f st item else st, mc in
+           aux ac mc st tl
+      in 
+      let ac, mc, _st = 
+         aux AO.initial_counters MO.initial_counters MA.initial_status book
       in
-      if !stage > 0 then MA.meta_of_aut f book
+      if !summary > 0 then Time.utime_stamp "processed";
+      if !summary > 2 then AO.print_counters Cps.id ac;
+      if !summary > 2 && !stage > 0 then MO.print_counters Cps.id mc;
    in
-   let help = "Usage: helena [ -V | -Ss <number> ] <file> ..." in
+   let help = "Usage: helena [ -V | -Ss <number> | -m <file> ] <file> ..." in
    let help_S = "<number>  Set summary level" in
    let help_V = " Show version information" in   
+   let help_m = "<file>  output intermediate representation" in
    let help_s = "<number>  Set translation stage" in
    Arg.parse [
       ("-S", Arg.Int set_summary, help_S);
       ("-V", Arg.Unit print_version, help_V);
+      ("-m", Arg.String set_meta_file, help_m); 
       ("-s", Arg.Int set_stage, help_s);
-   ] read_file help
+   ] read_file help;
+   if !summary > 0 then Time.utime_stamp "at exit"