10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-22 12:23:31 +01:00

Parallel debugging

This commit is contained in:
Anthony Scemama 2020-02-03 17:35:59 +01:00
parent 8f496ddb44
commit 774d977d99
4 changed files with 35 additions and 36 deletions

View File

@ -68,7 +68,7 @@ let make ~simulation ?(threshold=1.e-12) ~frozen_core ~mo_basis ~aux_basis_filen
let ci = CI.make ~n_states:state det_space in
let hf12_integrals =
HF12.make ~simulation ~mo_basis ~aux_basis_filename ()
HF12.make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename ()
in
let ci_coef, ci_energy =
@ -174,14 +174,6 @@ Format.printf "%a@." Matrix.pp_matrix @@ Matrix.dense_of_mat psi;
Printf.printf "F12 Convergence : %e %f\n" conv (eigenvalues.{state}
+. Simulation.nuclear_repulsion simulation);
(*
let cabs_singles =
let f =
Fock.make_rhf ~density ~ao_basis:large_ao_basis
in
in
*)
if conv > threshold then
iteration ~state eigenvectors
else

View File

@ -56,7 +56,6 @@ let array_4_init d1 d2 d3 d4 fx =
let x =
Bigarray.(Array2.create Float64 fortran_layout d1 d2)
in
Printf.printf "Array 4: %d %d %d\n%!" Parallel.rank k l;
for j=1 to d2 do
for i=1 to d1 do
x.{i,j} <- fx i j k l
@ -75,7 +74,6 @@ let array_4_init d1 d2 d3 d4 fx =
|> Stream.of_list
|> Farm.run ~f ~ordered:false
|> Stream.iter (fun (k,l,x) ->
Printf.printf "Array 4: %d %d %d\n%!" Parallel.rank k l;
for j=1 to d2 do
for i=1 to d1 do
result.{i,j,k,l} <- x.{i,j}
@ -122,7 +120,6 @@ let array_5_init d1 d2 d3 d4 d5 fx =
let x =
Bigarray.(Array3.create Float64 fortran_layout d1 d2 d3)
in
Printf.printf "Array 5: %d %d %d\n%!" Parallel.rank l m;
for k=1 to d3 do
for j=1 to d2 do
for i=1 to d1 do
@ -143,7 +140,6 @@ let array_5_init d1 d2 d3 d4 d5 fx =
|> Stream.of_list
|> Farm.run ~f ~ordered:false
|> Stream.iter (fun (l,m,x) ->
Printf.printf "Array 5: %d %d\n%!" l m;
for k=1 to d3 do
for j=1 to d2 do
for i=1 to d1 do
@ -193,7 +189,7 @@ let array_5_init d1 d2 d3 d4 d5 fx =
end
let make ~simulation ~mo_basis ~aux_basis_filename () =
let make ~frozen_core ~simulation ~mo_basis ~aux_basis_filename () =
let f12 = Util.of_some @@ Simulation.f12 simulation in
let mo_num = MOBasis.size mo_basis in
@ -231,18 +227,26 @@ let make ~simulation ~mo_basis ~aux_basis_filename () =
Util.list_range (mo_num+1) aux_num
in
let n_core =
if frozen_core then
(Nuclei.small_core @@ Simulation.nuclei @@ MOBasis.simulation mo_basis) / 2
else 0
in
let mos_in =
Util.list_range 1 mo_num
Util.list_range (n_core+1) mo_num
in
let mos_a k =
Determinant.alfa k
|> Spindeterminant.to_list
|> List.filter (fun i -> i > n_core)
in
let mos_b k =
Determinant.beta k
|> Spindeterminant.to_list
|> List.filter (fun i -> i > n_core)
in
let h_one =

View File

@ -59,17 +59,18 @@ module Node = struct
let name = Unix.gethostname ()
let world_rank = rank
let comm =
let _, color =
Mpi.allgather (name, rank) Mpi.comm_world
Mpi.allgather (name, world_rank) Mpi.comm_world
|> Array.to_list
|> List.sort compare
|> List.find (fun (n, r) -> n = name)
in
Mpi.(comm_split comm_world color 0)
Mpi.(comm_split comm_world color world_rank)
let rank =
Printf.printf "Node: %d %d\n%!" rank (Mpi.comm_rank comm);
Mpi.comm_rank comm
let master = rank = 0
@ -87,12 +88,15 @@ module Node = struct
let barrier () = Mpi.barrier comm
let _ = barrier ()
end
module InterNode = struct
let world_rank = rank
let comm =
let ranks =
@ -105,7 +109,7 @@ module InterNode = struct
| (new_name, r) :: rest -> aux accu new_name rest
in
Mpi.allgather (name, rank) Mpi.comm_world
Mpi.allgather (name, world_rank) Mpi.comm_world
|> Array.to_list
|> List.sort compare
|> aux [] ""
@ -120,22 +124,17 @@ module InterNode = struct
in
let result =
let g =
Mpi.comm_create Mpi.comm_world new_group
in
try
ignore @@ List.find (fun x -> x = rank) @@ Array.to_list ranks;
Some g
with Not_found -> None
Some (Mpi.comm_create Mpi.comm_world new_group)
in
result
try
ignore @@ List.find (fun x -> x = world_rank) @@ Array.to_list ranks;
result
with Not_found -> None
let rank =
match comm with
| Some comm ->
Printf.printf "InterNode: %d %d\n%!" rank (Mpi.comm_rank comm);
Mpi.comm_rank comm
| Some c-> Mpi.comm_rank c
| None -> -1
let master = rank = 0
@ -161,8 +160,9 @@ module InterNode = struct
| Some comm -> Mpi.barrier comm
| None -> ()
end
let _ = barrier ()
end
module Vec = struct

View File

@ -96,8 +96,9 @@ let () =
Simulation.of_filenames ~f12 ~charge ~multiplicity ~nuclei:nuclei_file basis_file
in
let hf = HartreeFock.make simulation in
Format.fprintf ppf "@[%a@]@." HartreeFock.pp hf;
let hf = HartreeFock.make ~guess:`Huckel simulation in
if Parallel.master then
Format.fprintf ppf "@[%a@]@." HartreeFock.pp hf;
let mo_basis =
MOBasis.of_hartree_fock hf
@ -112,14 +113,16 @@ let () =
in
let ci = F12CI.ci fcif12 in
Format.fprintf ppf "FCI energy : ";
if Parallel.master then
Format.fprintf ppf "FCI energy : ";
Vec.iteri (fun i x -> if i <= state then
Format.fprintf ppf "%20.16f@; " (x +. Simulation.nuclear_repulsion simulation) )
(CI.eigenvalues ci);
Format.fprintf ppf "@.";
let _, e_cif12 = F12CI.eigensystem fcif12 in
Format.fprintf ppf "FCI-F12 energy : ";
if Parallel.master then
Format.fprintf ppf "FCI-F12 energy : ";
Vec.iteri (fun i x -> if i <= state then
Format.fprintf ppf "%20.16f@; " (x +. Simulation.nuclear_repulsion simulation) )
e_cif12;