From e56e01197d70e8dd64c83f9176b3297509841ea0 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 4 Apr 2019 13:14:01 +0200 Subject: [PATCH] Minor changes --- Parallel_mpi/Farm.mli | 2 ++ Parallel_mpi/Parallel.mli | 4 ++++ Utils/Davidson.ml | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Parallel_mpi/Farm.mli b/Parallel_mpi/Farm.mli index 5dc93c6..3226f5c 100644 --- a/Parallel_mpi/Farm.mli +++ b/Parallel_mpi/Farm.mli @@ -4,6 +4,8 @@ The input is a stream of input data, and the output is a stream of data. *) +val run_sequential : ('a -> 'b) -> 'a Stream.t -> 'b Stream.t + val run : ?ordered:bool -> ?comm:Mpi.communicator -> f:('a -> 'b) -> 'a Stream.t -> 'b Stream.t (** Run the [f] function on every process by popping elements from the diff --git a/Parallel_mpi/Parallel.mli b/Parallel_mpi/Parallel.mli index 1634b6e..7856314 100644 --- a/Parallel_mpi/Parallel.mli +++ b/Parallel_mpi/Parallel.mli @@ -33,6 +33,10 @@ val broadcast_vec : Lacaml.D.vec -> Lacaml.D.vec (** {5 Intra-node operations} *) module Node : sig + (** This module contains parallel primitives among processes + within the same compute node. + *) + val name : string (** Name of the current host *) diff --git a/Utils/Davidson.ml b/Utils/Davidson.ml index 64e4083..bd52d7f 100644 --- a/Utils/Davidson.ml +++ b/Utils/Davidson.ml @@ -103,11 +103,6 @@ let make Mat.init_cols n m (fun i k -> (lambda.{k} *. m_new_U.{i,k} -. m_new_W.{i,k}) /. (max (diagonal.{i} -. lambda.{k}) 0.01) ) - in - let maxu = lange u_proposed ~norm:`M in - let thr = maxu *. 0.001 in - let u_proposed = - Mat.map (fun x -> if abs_float x < thr then 0. else x) u_proposed |> Mat.to_col_vecs_list in @@ -118,6 +113,18 @@ let make if Parallel.master then Printf.printf "%3d %16.10f %16.8e%!\n" iter lambda.{1} residual_norm; + (* Make new vectors sparse *) + let u_proposed = + Mat.of_col_vecs_list u_proposed + in + let maxu = lange u_proposed ~norm:`M in + let thr = maxu *. 0.01 in + let u_proposed = + Mat.map (fun x -> if abs_float x < thr then 0. else x) u_proposed + |> Mat.to_col_vecs_list + in + + if residual_norm > threshold then let u_next, w_next, iter = if iter = n_iter then