mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-21 11:53:31 +01:00
Working on broadcasts
This commit is contained in:
parent
0baf509285
commit
ee52c024e4
@ -15,12 +15,41 @@ let rank =
|
||||
assert (result >= 0);
|
||||
result
|
||||
|
||||
|
||||
let master = rank = 0
|
||||
|
||||
|
||||
let barrier () =
|
||||
Mpi.barrier Mpi.comm_world
|
||||
|
||||
|
||||
let broadcast x =
|
||||
Mpi.broadcast x 0 Mpi.comm_world
|
||||
|
||||
|
||||
let broadcast_int x =
|
||||
Mpi.broadcast_int x 0 Mpi.comm_world
|
||||
|
||||
|
||||
let broadcast_int_array x =
|
||||
Mpi.broadcast_int_array x 0 Mpi.comm_world
|
||||
|
||||
|
||||
let broadcast_float x =
|
||||
Mpi.broadcast_float x 0 Mpi.comm_world
|
||||
|
||||
|
||||
let broadcast_float_array x =
|
||||
Mpi.broadcast_float_array x 0 Mpi.comm_world
|
||||
|
||||
|
||||
let broadcast_vec x =
|
||||
let a = Lacaml.D.Vec.to_array x in
|
||||
let a = broadcast_float_array a in
|
||||
Lacaml.D.Vec.of_array a
|
||||
|
||||
|
||||
|
||||
module Vec = struct
|
||||
|
||||
type t =
|
||||
|
@ -12,6 +12,25 @@ val master : bool
|
||||
val barrier : unit -> unit
|
||||
(** Wait for all processes to reach this point. *)
|
||||
|
||||
val broadcast : 'a -> 'a
|
||||
(** Broadcasts data to all processes. *)
|
||||
|
||||
val broadcast_int : int -> int
|
||||
(** Broadcasts an [int] to all processes. *)
|
||||
|
||||
val broadcast_float : float -> float
|
||||
(** Broadcasts a [float] to all processes. *)
|
||||
|
||||
val broadcast_int_array : int array -> int array
|
||||
(** Broadcasts an [int array] to all processes. *)
|
||||
|
||||
val broadcast_float_array : float array -> float array
|
||||
(** Broadcasts a [float array] to all processes. *)
|
||||
|
||||
val broadcast_vec : Lacaml.D.vec -> Lacaml.D.vec
|
||||
(** Broadcasts a Lacaml vector to all processes. *)
|
||||
|
||||
|
||||
(** {5 Vector operations} *)
|
||||
module Vec : sig
|
||||
|
||||
|
@ -9,7 +9,7 @@ let v = Parallel.Vec.init 47 (fun i -> float_of_int i) 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
|
||||
let d1 = Parallel.dot v1 v2 in
|
||||
let d1 = Parallel.dot v1 v2 |> Parallel.broadcast_float in
|
||||
let d2 = Lacaml.D.dot a b in
|
||||
(*
|
||||
let w = Parallel.Vec.to_vec v in
|
||||
|
Loading…
Reference in New Issue
Block a user