mirror of
https://gitlab.com/scemama/qmcchem.git
synced 2024-08-31 23:33:42 +02:00
Merge branch 'master' of gitlab.com:scemama/qmcchem
This commit is contained in:
commit
2ddd386ca8
@ -110,32 +110,13 @@ let read_bytes b idx =
|
|||||||
Bytes.get_int64_ne b idx
|
Bytes.get_int64_ne b idx
|
||||||
|> Int64.to_int
|
|> Int64.to_int
|
||||||
in
|
in
|
||||||
Some (Bytes.sub b (idx+8) m, idx+8+m)
|
try
|
||||||
|
Some (Bytes.sub b (idx+8) m, idx+8+m)
|
||||||
|
with Invalid_argument _ -> None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let of_bytes b =
|
let of_bytes ?(idx=0) b =
|
||||||
(*
|
|
||||||
let rec loop accu s =
|
|
||||||
match read_bytes s with
|
|
||||||
| None -> []
|
|
||||||
| Some (data, None) -> (data :: accu)
|
|
||||||
| Some (data, (Some rest)) -> loop (data :: accu) rest
|
|
||||||
in
|
|
||||||
let result =
|
|
||||||
match loop [] b with
|
|
||||||
| compute_node :: block_id :: pid :: weight :: value :: property :: [] ->
|
|
||||||
Some
|
|
||||||
{ property = Property.of_bytes property;
|
|
||||||
value = Sample.of_bytes value;
|
|
||||||
weight = Weight.of_bytes weight;
|
|
||||||
pid = int_of_bytes pid;
|
|
||||||
block_id = Block_id.of_bytes block_id;
|
|
||||||
compute_node = Compute_node.of_bytes compute_node;
|
|
||||||
}
|
|
||||||
| _ -> None
|
|
||||||
in
|
|
||||||
*)
|
|
||||||
let get_x s idx =
|
let get_x s idx =
|
||||||
match read_bytes s idx with
|
match read_bytes s idx with
|
||||||
| Some ( data, i1) -> data, i1
|
| Some ( data, i1) -> data, i1
|
||||||
@ -144,7 +125,6 @@ let of_bytes b =
|
|||||||
|
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
let idx=0 in
|
|
||||||
try
|
try
|
||||||
let property, idx = get_x b idx in
|
let property, idx = get_x b idx in
|
||||||
let value , idx = get_x b idx in
|
let value , idx = get_x b idx in
|
||||||
|
@ -11,7 +11,7 @@ type t =
|
|||||||
| Error of string
|
| Error of string
|
||||||
|
|
||||||
|
|
||||||
let create m =
|
let of_string_list m =
|
||||||
try
|
try
|
||||||
match m with
|
match m with
|
||||||
| [ "cpu" ; c ; pid ; b ; "1" ; v ] ->
|
| [ "cpu" ; c ; pid ; b ; "1" ; v ] ->
|
||||||
@ -80,7 +80,19 @@ let create m =
|
|||||||
| [ "unregister" ; c ; pid ] -> Unregister (Compute_node.of_string c, int_of_string pid)
|
| [ "unregister" ; c ; pid ] -> Unregister (Compute_node.of_string c, int_of_string pid)
|
||||||
| [ "Test" ] -> Test
|
| [ "Test" ] -> Test
|
||||||
| [ "Ezfio" ; ezfio_msg ] -> Ezfio ezfio_msg
|
| [ "Ezfio" ; ezfio_msg ] -> Ezfio ezfio_msg
|
||||||
|
| prop :: c :: pid :: b :: d :: w :: "bin" :: block :: [] ->
|
||||||
|
(* Block in binary format *)
|
||||||
|
let property =
|
||||||
|
Property.of_string prop
|
||||||
|
in
|
||||||
|
begin
|
||||||
|
assert (not (Property.is_scalar property));
|
||||||
|
match Block.of_bytes ~idx:8 (Bytes.unsafe_of_string block) with
|
||||||
|
| Some block -> Property block
|
||||||
|
| None -> failwith "Invalid block"
|
||||||
|
end
|
||||||
| prop :: c :: pid :: b :: d :: w :: l ->
|
| prop :: c :: pid :: b :: d :: w :: l ->
|
||||||
|
(* Bock in text format *)
|
||||||
let property =
|
let property =
|
||||||
Property.of_string prop
|
Property.of_string prop
|
||||||
in
|
in
|
||||||
@ -109,6 +121,7 @@ let create m =
|
|||||||
| _ -> Error "Unknown error"
|
| _ -> Error "Unknown error"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let to_string = function
|
let to_string = function
|
||||||
| Property b -> "Property : "^(Block.to_string b)
|
| Property b -> "Property : "^(Block.to_string b)
|
||||||
| Walkers (h,p,w) -> Printf.sprintf "Walkers : %s %d : %d walkers"
|
| Walkers (h,p,w) -> Printf.sprintf "Walkers : %s %d : %d walkers"
|
||||||
@ -123,3 +136,6 @@ let to_string = function
|
|||||||
| Error msg -> "Error "^msg
|
| Error msg -> "Error "^msg
|
||||||
|
|
||||||
|
|
||||||
|
let create m =
|
||||||
|
of_string_list m
|
||||||
|
|
||||||
|
@ -117,6 +117,7 @@ let ip_address = lazy (
|
|||||||
|
|
||||||
let binary_io =
|
let binary_io =
|
||||||
try
|
try
|
||||||
Sys.getenv "QMCCHEM_IO" = "B"
|
let qmcchem_io = Sys.getenv "QMCCHEM_IO" in
|
||||||
|
qmcchem_io = "B" || qmcchem_io = "b"
|
||||||
with Not_found -> false
|
with Not_found -> false
|
||||||
|
|
||||||
|
@ -721,13 +721,17 @@ let run ?(daemon=true) ezfio_filename =
|
|||||||
Unix.gettimeofday ()
|
Unix.gettimeofday ()
|
||||||
in
|
in
|
||||||
let msg =
|
let msg =
|
||||||
|
(*
|
||||||
List.rev_map String.trim raw_msg
|
List.rev_map String.trim raw_msg
|
||||||
|> List.rev
|
|> List.rev
|
||||||
|> Message.create
|
|> Message.create
|
||||||
and msg_size =
|
*)
|
||||||
List.fold_left (fun accu x -> accu + (String.length x)) 0 raw_msg
|
Message.create raw_msg
|
||||||
in
|
in
|
||||||
let recv_log =
|
let recv_log =
|
||||||
|
let msg_size =
|
||||||
|
List.fold_left (fun accu x -> accu + (String.length x)) 0 raw_msg
|
||||||
|
in
|
||||||
send_log "pull" msg_size t0
|
send_log "pull" msg_size t0
|
||||||
in
|
in
|
||||||
|
|
||||||
|
@ -474,6 +474,16 @@ let run ezfio_filename dataserver =
|
|||||||
else
|
else
|
||||||
List.concat [ [ "elec_coord" ; hostname ; pid ; id ;
|
List.concat [ [ "elec_coord" ; hostname ; pid ; id ;
|
||||||
string_of_int (5*len)] ; ( select_n_of ~n:5 ~len rest ) ]
|
string_of_int (5*len)] ; ( select_n_of ~n:5 ~len rest ) ]
|
||||||
|
| prop :: c :: pid :: b :: d :: w :: [] -> message
|
||||||
|
| prop :: c :: pid :: b :: d :: w :: l ->
|
||||||
|
if Qmcchem_config.binary_io then
|
||||||
|
match Message.create message with
|
||||||
|
| Message.Property block ->
|
||||||
|
prop :: c :: pid :: b :: d :: w :: "bin" ::
|
||||||
|
(Block.to_bytes block |> Bytes.unsafe_to_string ) :: []
|
||||||
|
| _ -> failwith "Inconsistent message"
|
||||||
|
else
|
||||||
|
message
|
||||||
| _ -> message
|
| _ -> message
|
||||||
in
|
in
|
||||||
Zmq.Socket.send_all push_socket new_message
|
Zmq.Socket.send_all push_socket new_message
|
||||||
|
Loading…
Reference in New Issue
Block a user