mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 12:23:31 +01:00
Added SharedMemory
This commit is contained in:
parent
4a6f23dcdd
commit
dce6e3fb66
23
Parallel_mpi/SharedMemory.ml
Normal file
23
Parallel_mpi/SharedMemory.ml
Normal file
@ -0,0 +1,23 @@
|
||||
let create ?(temp_dir="/dev/shm") data_type size_array =
|
||||
let filename =
|
||||
Parallel.Node.broadcast (lazy (Filename.temp_file ~temp_dir "4idx." ".tmp"))
|
||||
in
|
||||
at_exit (fun () -> try Sys.remove filename with _ -> ());
|
||||
|
||||
if Parallel.Node.master then
|
||||
begin
|
||||
let fd = Unix.openfile filename [Unix.O_RDWR] 0o600 in
|
||||
let result =
|
||||
Unix.map_file fd data_type Bigarray.fortran_layout true size_array
|
||||
in
|
||||
Bigarray.Genarray.fill result 0.;
|
||||
Parallel.Node.barrier ();
|
||||
result
|
||||
end
|
||||
else
|
||||
begin
|
||||
Parallel.Node.barrier ();
|
||||
let fd = Unix.openfile filename [Unix.O_RDONLY] 0o600 in
|
||||
Unix.map_file fd data_type Bigarray.fortran_layout false size_array
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user