mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-19 04:22:21 +01:00
Fixed SharedMemory
This commit is contained in:
parent
dce6e3fb66
commit
5bd2edde7b
@ -84,7 +84,7 @@ module Node = struct
|
|||||||
|
|
||||||
let broadcast x = broadcast_generic Mpi.broadcast x
|
let broadcast x = broadcast_generic Mpi.broadcast x
|
||||||
|
|
||||||
let barrier () = (* Mpi.barrier comm *) ()
|
let barrier () = Mpi.barrier comm
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,22 +2,24 @@ let create ?(temp_dir="/dev/shm") data_type size_array =
|
|||||||
let filename =
|
let filename =
|
||||||
Parallel.Node.broadcast (lazy (Filename.temp_file ~temp_dir "4idx." ".tmp"))
|
Parallel.Node.broadcast (lazy (Filename.temp_file ~temp_dir "4idx." ".tmp"))
|
||||||
in
|
in
|
||||||
at_exit (fun () -> try Sys.remove filename with _ -> ());
|
Printf.printf "File:%s\n%!" filename;
|
||||||
|
|
||||||
if Parallel.Node.master then
|
if Parallel.Node.master then
|
||||||
begin
|
begin
|
||||||
let fd = Unix.openfile filename [Unix.O_RDWR] 0o600 in
|
let fd = Unix.openfile filename Unix.[O_RDWR ; O_CREAT] 0o777 in
|
||||||
let result =
|
let result =
|
||||||
Unix.map_file fd data_type Bigarray.fortran_layout true size_array
|
Unix.map_file fd data_type Bigarray.fortran_layout true size_array
|
||||||
in
|
in
|
||||||
Bigarray.Genarray.fill result 0.;
|
Bigarray.Genarray.fill result 0.;
|
||||||
Parallel.Node.barrier ();
|
Parallel.Node.barrier ();
|
||||||
|
at_exit (fun () -> Unix.close fd ; try Sys.remove filename with _ -> ());
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Parallel.Node.barrier ();
|
Parallel.Node.barrier ();
|
||||||
let fd = Unix.openfile filename [Unix.O_RDONLY] 0o600 in
|
let fd = Unix.openfile filename [Unix.O_RDONLY] 0o777 in
|
||||||
|
at_exit (fun () -> Unix.close fd ; try Sys.remove filename with _ -> ());
|
||||||
Unix.map_file fd data_type Bigarray.fortran_layout false size_array
|
Unix.map_file fd data_type Bigarray.fortran_layout false size_array
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user