10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-14 18:13:40 +01:00
QCaml/run_parallel.ml

45 lines
1.4 KiB
OCaml
Raw Normal View History

2018-10-16 00:27:58 +02:00
2018-10-21 23:52:41 +02:00
let pouet () =
2018-10-16 19:09:00 +02:00
Printf.printf "Hello from rank %d of %d.\n" Parallel.rank Parallel.size;
let () = Parallel.barrier () in
2018-10-17 00:56:14 +02:00
(*
let v = Parallel.Vec.init 47 (fun i -> float_of_int i) in
*)
2018-10-17 11:44:28 +02:00
let a = Array.init 41 (fun i -> float_of_int (i+1)) |> Lacaml.D.Vec.of_array in
let b = Array.init 41 (fun i -> float_of_int (3*i+1)) |> Lacaml.D.Vec.of_array in
let v1 = Parallel.Vec.of_vec a in
let v2 = Parallel.Vec.of_vec b in
2018-10-17 11:58:13 +02:00
let d1 = Parallel.dot v1 v2 |> Parallel.broadcast_float in
2018-10-17 11:44:28 +02:00
let d2 = Lacaml.D.dot a b in
(*
2018-10-17 10:38:07 +02:00
let w = Parallel.Vec.to_vec v in
2018-10-17 11:44:28 +02:00
Format.printf "%a" Parallel.Vec.pp v;
2018-10-17 10:38:07 +02:00
if Parallel.master then
Format.printf "@[%a@]@;" (Lacaml.Io.pp_lfvec ()) w;
2018-10-17 11:44:28 +02:00
*)
Printf.printf "%f %f\n" d1 d2;
2018-10-21 23:52:41 +02:00
print_newline ()
2019-03-29 23:39:47 +01:00
let pouet2 () =
2018-10-21 23:52:41 +02:00
let f (a,b) = (Parallel.rank, a+b) in
let input = Stream.of_list
2018-10-22 19:10:38 +02:00
[ (1,2) ; (3,4) ; (5,6) ; (7,8) ; (9,10)
; (1,2) ; (3,4) ; (5,6) ; (7,8) ; (9,10)
; (1,2) ; (3,4) ; (5,6) ; (7,8) ; (9,10)
; (1,2) ; (3,4) ; (5,6) ; (7,8) ; (9,10) ]
2018-10-21 23:52:41 +02:00
in
2018-10-22 17:53:13 +02:00
let stream =
2018-10-22 19:10:38 +02:00
Farm.run ~f input
2018-10-22 17:53:13 +02:00
in
Stream.iter (fun (x,y) -> Printf.printf "%d %d\n%!" x y) stream
2018-10-16 00:27:58 +02:00
2019-03-29 23:39:47 +01:00
open Printf
let () =
printf "%d : %s\n" Parallel.rank Parallel.Node.name;
let value = Parallel.broadcast (lazy Parallel.rank) in
printf "%d : %d\n" Parallel.rank value;
let value = Parallel.Node.broadcast (lazy Parallel.rank) in
printf "%d : %d\n" Parallel.rank value