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 ()
|
|
|
|
|
|
|
|
|
|
|
|
let () =
|
|
|
|
let f (a,b) = (Parallel.rank, a+b) in
|
|
|
|
let input = Stream.of_list
|
|
|
|
[ (1,2) ; (3,4) ; (5,6) ; (7,8) ; (9,10) ]
|
|
|
|
in
|
2018-10-22 17:53:13 +02:00
|
|
|
let stream =
|
|
|
|
Farm.run f input
|
|
|
|
in
|
|
|
|
Stream.iter (fun (x,y) -> Printf.printf "%d %d\n%!" x y) stream
|
2018-10-16 00:27:58 +02:00
|
|
|
|