mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-07-05 10:55:50 +02:00
24 lines
764 B
OCaml
24 lines
764 B
OCaml
|
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
|
||
|
|