10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-19 04:22:21 +01:00

Accelerated FCI

This commit is contained in:
Anthony Scemama 2019-04-03 18:46:59 +02:00
parent 4de337619f
commit 43ee562711
2 changed files with 11 additions and 5 deletions

View File

@ -490,7 +490,7 @@ let make ?(n_states=1) ?(algo=`Direct) det_space =
in in
let matrix_prod psi = let matrix_prod psi =
let result = let result =
Matrix.parallel_mm ~transa:`T psi m_H Matrix.parallel_mm ~transa:`T ~transb:`T psi m_H
|> Matrix.transpose |> Matrix.transpose
in in
Parallel.broadcast (lazy result) Parallel.broadcast (lazy result)

View File

@ -201,7 +201,8 @@ let rec mm ?(transa=`N) ?(transb=`N) ?(threshold=epsilon) a b =
| `N, `T -> dim2, dim2 | `N, `T -> dim2, dim2
in in
if f a <> f' b then if f a <> f' b then
invalid_arg "Inconsistent dimensions"; Printf.sprintf "%d %d : Inconsistent dimensions" (f a) (f' b)
|> invalid_arg;
(* Dense x sparse *) (* Dense x sparse *)
let mmsp transa transb a b = let mmsp transa transb a b =
@ -560,16 +561,21 @@ let parallel_mm ?(transa=`N) ?(transb=`N) ?(threshold=epsilon) a b =
| `N -> dim2 a | `N -> dim2 a
| `T -> dim1 a | `T -> dim1 a
in in
let n = n / (Parallel.size * 4) in let n = n / (Parallel.size * 7) in
let b =
match transb with
| `T -> transpose b
| `N -> b
in
split_cols n b split_cols n b
|> Stream.of_list |> Stream.of_list
|> Farm.run ~ordered:true ~f:(fun b -> |> Farm.run ~ordered:true ~f:(fun b ->
match a, b with match a, b with
| Computed _, Computed _ -> | Computed _, Computed _ ->
mm ~transa ~transb ~threshold a b mm ~transa ~threshold a b
|> sparse_of_computed ~threshold |> sparse_of_computed ~threshold
| _ -> | _ ->
mm ~transa ~transb ~threshold a b mm ~transa ~threshold a b
) )
|> Util.stream_to_list |> Util.stream_to_list
|> join_cols |> join_cols