10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-07 06:33:39 +01:00

Share memory for f12 arrays

This commit is contained in:
Anthony Scemama 2020-01-13 10:54:08 +01:00
parent a20ec08125
commit e493eb28cd
2 changed files with 32 additions and 74 deletions

View File

@ -58,52 +58,6 @@ let dressing_vector ~frozen_core hf12_integrals f12_amplitudes ci =
let sum l f = List.fold_left (fun accu i -> accu +. f i) 0. l let sum l f = List.fold_left (fun accu i -> accu +. f i) 0. l
let array_3_init d1 d2 d3 f =
let result =
Bigarray.(Array3.create Float64 fortran_layout) d1 d2 d3
in
for k=1 to d3 do
for j=1 to d2 do
for i=1 to d1 do
result.{i,j,k} <- f i j k
done
done
done;
result
let array_4_init d1 d2 d3 d4 f =
let result =
Bigarray.(Genarray.create Float64 fortran_layout) [| d1;d2;d3;d4 |]
in
for l=1 to d4 do
for k=1 to d3 do
for j=1 to d2 do
for i=1 to d1 do
result.{i,j,k,l} <- f i j k l
done
done
done
done;
result
let array_5_init d1 d2 d3 d4 d5 f =
let result =
Bigarray.(Genarray.create Float64 fortran_layout) [| d1;d2;d3;d4;d5 |]
in
for m=1 to d5 do
for l=1 to d4 do
for k=1 to d3 do
for j=1 to d2 do
for i=1 to d1 do
result.{i,j,k,l,m} <- f i j k l m
done
done
done
done
done;
result
let make ~simulation ?(threshold=1.e-12) ~frozen_core ~mo_basis ~aux_basis_filename ?(state=1) () = let make ~simulation ?(threshold=1.e-12) ~frozen_core ~mo_basis ~aux_basis_filename ?(state=1) () =

View File

@ -21,47 +21,51 @@ let sum l f = List.fold_left (fun accu i -> accu +. f i) 0. l
let array_3_init d1 d2 d3 f = let array_3_init d1 d2 d3 f =
let result = let result =
Bigarray.(Array3.create Float64 fortran_layout) d1 d2 d3 SharedMemory.create Bigarray.Float64 [| d1 ; d2 ; d3 |]
|> Bigarray.array3_of_genarray
in in
for k=1 to d3 do if Parallel.master then
for j=1 to d2 do for k=1 to d3 do
for i=1 to d1 do for j=1 to d2 do
result.{i,j,k} <- f i j k for i=1 to d1 do
done result.{i,j,k} <- f i j k
done done
done; done
done;
result result
let array_4_init d1 d2 d3 d4 f = let array_4_init d1 d2 d3 d4 f =
let result = let result =
Bigarray.(Genarray.create Float64 fortran_layout) [| d1;d2;d3;d4 |] SharedMemory.create Bigarray.Float64 [| d1;d2;d3;d4 |]
in in
for l=1 to d4 do if Parallel.master then
for k=1 to d3 do
for j=1 to d2 do
for i=1 to d1 do
result.{i,j,k,l} <- f i j k l
done
done
done
done;
result
let array_5_init d1 d2 d3 d4 d5 f =
let result =
Bigarray.(Genarray.create Float64 fortran_layout) [| d1;d2;d3;d4;d5 |]
in
for m=1 to d5 do
for l=1 to d4 do for l=1 to d4 do
for k=1 to d3 do for k=1 to d3 do
for j=1 to d2 do for j=1 to d2 do
for i=1 to d1 do for i=1 to d1 do
result.{i,j,k,l,m} <- f i j k l m result.{i,j,k,l} <- f i j k l
done done
done done
done done
done done;
done; result
let array_5_init d1 d2 d3 d4 d5 f =
let result =
SharedMemory.create Bigarray.Float64 [| d1;d2;d3;d4;d5 |]
in
if Parallel.master then
for m=1 to d5 do
for l=1 to d4 do
for k=1 to d3 do
for j=1 to d2 do
for i=1 to d1 do
result.{i,j,k,l,m} <- f i j k l m
done
done
done
done
done;
result result