mirror of
https://gitlab.com/scemama/qmcchem.git
synced 2025-01-02 17:45:39 +01:00
Removing core
This commit is contained in:
parent
4c870cb62b
commit
a719c694ce
@ -147,11 +147,12 @@ let raw_data ?(locked=true) () =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
module StringSet = Set.Make(String)
|
|
||||||
|
|
||||||
let properties = lazy (
|
let properties = lazy (
|
||||||
List.fold_left (fun s x -> StringSet.add (Property.to_string x.property) s) StringSet.empty (raw_data ())
|
let h = Hashtbl.create 63 in
|
||||||
|> StringSet.elements
|
List.iter (fun x ->
|
||||||
|
Hashtbl.add h (Property.to_string x.property) x.property)
|
||||||
|
(raw_data ());
|
||||||
|
Hashtbl.fold (fun k v a -> v :: a) h []
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ let compress =
|
|||||||
|
|
||||||
(** Last value on each compute node (for wall_time) *)
|
(** Last value on each compute node (for wall_time) *)
|
||||||
let max_value_per_compute_node t =
|
let max_value_per_compute_node t =
|
||||||
let table = String.Table.create ()
|
let table = Hashtbl.create 63
|
||||||
in
|
in
|
||||||
let create_key block =
|
let create_key block =
|
||||||
Printf.sprintf "%s %10.10d"
|
Printf.sprintf "%s %10.10d"
|
||||||
@ -603,8 +603,8 @@ let max_value_per_compute_node t =
|
|||||||
(** String representation *)
|
(** String representation *)
|
||||||
let to_string p =
|
let to_string p =
|
||||||
match p.property with
|
match p.property with
|
||||||
| Property.Cpu -> Printf.sprintf "%s" (Time.Span.to_string (Time.Span.of_sec (sum p)))
|
| Property.Cpu -> Printf.sprintf "%s" (Time.string_of_sec (sum p))
|
||||||
| Property.Wall -> Printf.sprintf "%s" (Time.Span.to_string (Time.Span.of_sec (sum (max_value_per_compute_node p))))
|
| Property.Wall -> Printf.sprintf "%s" (Time.string_of_sec (sum (max_value_per_compute_node p)))
|
||||||
| Property.Accep -> Printf.sprintf "%16.10f" (average p |> Average.to_float)
|
| Property.Accep -> Printf.sprintf "%16.10f" (average p |> Average.to_float)
|
||||||
| _ ->
|
| _ ->
|
||||||
begin
|
begin
|
||||||
@ -667,17 +667,28 @@ let compress_files () =
|
|||||||
Lazy.force dir_name
|
Lazy.force dir_name
|
||||||
in
|
in
|
||||||
let files =
|
let files =
|
||||||
Sys.ls_dir dir_name
|
Sys.readdir dir_name
|
||||||
|
|> Array.to_list
|
||||||
|> List.filter (fun x ->
|
|> List.filter (fun x ->
|
||||||
match String.substr_index ~pattern:"locked" x with
|
try
|
||||||
| Some x -> false
|
Str.search_backward (Str.regexp "locked") x (String.length x) >= 0
|
||||||
| None -> true
|
with
|
||||||
|
| Not_found -> true
|
||||||
)
|
)
|
||||||
|> List.map (fun x -> dir_name^x)
|
|> List.map (fun x -> dir_name^x)
|
||||||
in
|
in
|
||||||
|
|
||||||
let out_channel_dir =
|
let out_channel_dir =
|
||||||
Filename.temp_dir ~in_dir:(!Ezfio.ezfio_filename ^ "/blocks/") "qmc" ""
|
let rand_num = Random.int 1000000 |> string_of_int in
|
||||||
|
let tmp_dir =
|
||||||
|
Filename.concat "!Ezfio.ezfio_filename" @@
|
||||||
|
Filename.concat "blocks" @@
|
||||||
|
Filename.concat "qmc" rand_num
|
||||||
|
in
|
||||||
|
try
|
||||||
|
Unix.mkdir tmp_dir 0o600;
|
||||||
|
tmp_dir
|
||||||
|
with _ -> raise (Sys_error "Cannot create temp dir")
|
||||||
in
|
in
|
||||||
|
|
||||||
let out_channel_name =
|
let out_channel_name =
|
||||||
@ -687,11 +698,12 @@ let compress_files () =
|
|||||||
Unix.getpid ()
|
Unix.getpid ()
|
||||||
|> string_of_int
|
|> string_of_int
|
||||||
in
|
in
|
||||||
String.concat [ hostname ; "." ; suffix ]
|
String.concat "." [ hostname ; suffix ]
|
||||||
in
|
in
|
||||||
|
|
||||||
let block_channel =
|
let block_channel =
|
||||||
Out_channel.create (out_channel_dir ^ out_channel_name)
|
Filename.concat out_channel_dir out_channel_name
|
||||||
|
|> open_out
|
||||||
in
|
in
|
||||||
|
|
||||||
List.iter (fun p ->
|
List.iter (fun p ->
|
||||||
@ -709,14 +721,15 @@ let compress_files () =
|
|||||||
|> merge_per_compute_node_and_block_id
|
|> merge_per_compute_node_and_block_id
|
||||||
in
|
in
|
||||||
List.iter (fun x ->
|
List.iter (fun x ->
|
||||||
Out_channel.output_string block_channel (Block.to_string x);
|
output_string block_channel (Block.to_string x);
|
||||||
Out_channel.output_char block_channel '\n';
|
output_char block_channel '\n';
|
||||||
) l.data
|
) l.data
|
||||||
) properties ;
|
) properties ;
|
||||||
Out_channel.close block_channel;
|
close_out block_channel;
|
||||||
|
|
||||||
List.iter Unix.remove files ;
|
List.iter Unix.unlink files ;
|
||||||
Unix.rename ~src:(out_channel_dir^out_channel_name) ~dst:(dir_name^out_channel_name);
|
Unix.rename (Filename.concat out_channel_dir out_channel_name)
|
||||||
|
(Filename.concat dir_name out_channel_name);
|
||||||
Unix.rmdir out_channel_dir
|
Unix.rmdir out_channel_dir
|
||||||
|
|
||||||
|
|
||||||
@ -738,7 +751,7 @@ let autocovariance { property ; data } =
|
|||||||
if (i > 1) then (float_of_int i) else 1.
|
if (i > 1) then (float_of_int i) else 1.
|
||||||
in
|
in
|
||||||
let r =
|
let r =
|
||||||
Array.sub 0 i x_t
|
Array.sub x_t 0 i
|
||||||
|> Array.fold_left (fun accu x ->
|
|> Array.fold_left (fun accu x ->
|
||||||
accu +. x *. x_t.(i)) 0.
|
accu +. x *. x_t.(i)) 0.
|
||||||
in
|
in
|
||||||
@ -756,7 +769,7 @@ let centered_cumulants { property ; data } =
|
|||||||
|> Average.to_float
|
|> Average.to_float
|
||||||
in
|
in
|
||||||
let centered_data =
|
let centered_data =
|
||||||
List.map ~f:(fun x ->
|
List.map (fun x ->
|
||||||
( (Weight.to_float x.Block.weight),
|
( (Weight.to_float x.Block.weight),
|
||||||
(Sample.to_float x.Block.value) -. ave )
|
(Sample.to_float x.Block.value) -. ave )
|
||||||
)
|
)
|
||||||
@ -764,20 +777,20 @@ let centered_cumulants { property ; data } =
|
|||||||
in
|
in
|
||||||
let var =
|
let var =
|
||||||
let (num, denom) =
|
let (num, denom) =
|
||||||
List.fold_left ~init:(0., 0.) ~f:(fun (a2, ad) (w,x) ->
|
List.fold_left (fun (a2, ad) (w,x) ->
|
||||||
let x2 = x *. x
|
let x2 = x *. x
|
||||||
in
|
in
|
||||||
let var = w *. x2
|
let var = w *. x2
|
||||||
and den = w
|
and den = w
|
||||||
in (a2 +. var, ad +. den)
|
in (a2 +. var, ad +. den)
|
||||||
) centered_data
|
) (0., 0.) centered_data
|
||||||
in num /. denom
|
in num /. denom
|
||||||
in
|
in
|
||||||
let centered_data =
|
let centered_data =
|
||||||
let sigma_inv =
|
let sigma_inv =
|
||||||
1. /. (sqrt var)
|
1. /. (sqrt var)
|
||||||
in
|
in
|
||||||
List.map ~f:(fun x ->
|
List.map (fun x ->
|
||||||
( (Weight.to_float x.Block.weight),
|
( (Weight.to_float x.Block.weight),
|
||||||
( (Sample.to_float x.Block.value) -. ave ) *. sigma_inv )
|
( (Sample.to_float x.Block.value) -. ave ) *. sigma_inv )
|
||||||
)
|
)
|
||||||
@ -785,14 +798,14 @@ let centered_cumulants { property ; data } =
|
|||||||
in
|
in
|
||||||
let (cum3,cum4) =
|
let (cum3,cum4) =
|
||||||
let (cum3, cum4, denom) =
|
let (cum3, cum4, denom) =
|
||||||
List.fold_left ~init:(0., 0., 0.) ~f:(fun (a3, a4, ad) (w,x) ->
|
List.fold_left (fun (a3, a4, ad) (w,x) ->
|
||||||
let x2 = x *. x
|
let x2 = x *. x
|
||||||
in
|
in
|
||||||
let cum3 = w *. x2 *. x
|
let cum3 = w *. x2 *. x
|
||||||
and cum4 = w *. x2 *. x2
|
and cum4 = w *. x2 *. x2
|
||||||
and den = w
|
and den = w
|
||||||
in (a3 +. cum3, a4 +. cum4, ad +. den)
|
in (a3 +. cum3, a4 +. cum4, ad +. den)
|
||||||
) centered_data
|
) (0., 0., 0.) centered_data
|
||||||
in
|
in
|
||||||
( cum3 /. denom, cum4 /. denom -. 3. )
|
( cum3 /. denom, cum4 /. denom -. 3. )
|
||||||
in
|
in
|
||||||
@ -817,9 +830,9 @@ let histogram { property ; data } =
|
|||||||
let delta_x =
|
let delta_x =
|
||||||
length /. (n-.1.)
|
length /. (n-.1.)
|
||||||
and result =
|
and result =
|
||||||
Array.init ~f:(fun _ -> 0.) (int_of_float (n +. 1.))
|
Array.init (int_of_float n + 1) (fun _ -> 0.)
|
||||||
in
|
in
|
||||||
List.iter ~f:(fun x ->
|
List.iter (fun x ->
|
||||||
let w =
|
let w =
|
||||||
(Weight.to_float x.Block.weight)
|
(Weight.to_float x.Block.weight)
|
||||||
and x =
|
and x =
|
||||||
@ -834,10 +847,10 @@ let histogram { property ; data } =
|
|||||||
;
|
;
|
||||||
let norm =
|
let norm =
|
||||||
1. /. ( delta_x *. (
|
1. /. ( delta_x *. (
|
||||||
Array.fold_left ~init:0. ~f:(fun accu x -> accu +. x) result
|
Array.fold_left (fun accu x -> accu +. x) 0. result
|
||||||
) )
|
) )
|
||||||
in
|
in
|
||||||
Array.mapi ~f:(fun i x -> (min +. (float_of_int i)*.delta_x, x *. norm) ) result
|
Array.mapi (fun i x -> (min +. (float_of_int i)*.delta_x, x *. norm) ) result
|
||||||
|> Array.to_list
|
|> Array.to_list
|
||||||
|
|
||||||
|
|
||||||
|
26
ocaml/Time.ml
Normal file
26
ocaml/Time.ml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
let of_sec s =
|
||||||
|
Unix.gmtime s
|
||||||
|
|
||||||
|
let to_sec t =
|
||||||
|
let sec = t.Unix.tm_sec
|
||||||
|
and min = t.Unix.tm_min
|
||||||
|
and hour = t.Unix.tm_hour
|
||||||
|
and mday = t.Unix.tm_mday
|
||||||
|
in
|
||||||
|
sec +
|
||||||
|
min * 60 +
|
||||||
|
hour * 60 * 60 +
|
||||||
|
mday * 60 * 60 * 24
|
||||||
|
|
||||||
|
let string_of_t t =
|
||||||
|
let mday = t.Unix.tm_mday in
|
||||||
|
let sec = t.Unix.tm_sec
|
||||||
|
and min = t.Unix.tm_min
|
||||||
|
and hour = t.Unix.tm_hour + 24*mday
|
||||||
|
in
|
||||||
|
Printf.sprintf "%2d:%2d:%2d" hour min sec
|
||||||
|
|
||||||
|
let string_of_sec s =
|
||||||
|
of_sec s
|
||||||
|
|> string_of_t
|
||||||
|
|
Loading…
Reference in New Issue
Block a user