Garbage collection and caml_adjust_gc_speed

Christopher Kauffman

Damien Doligez
 Christopher Kauffman

Damien Doligez
[
Home
]
[ Index:
by date

by threads
]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
Date:   (:) 
From:  Christopher Kauffman <kauffman@c...> 
Subject:  Re: [Camllist] Garbage collection and caml_adjust_gc_speed 
> What I find surprising is that this simple function would dominate the run > time of your program. I suspect some problem with gprof. Could you give us > more details about the computations performed by your program? The program is in the area of computational biology. It is intended to be used to study approximations to protein folding. The main operations involve altering N by 3 matrices representing the coordinates of atoms of the protein. I have used Bigarrays for the data structures for efficiency and the Lacaml package for most of these operations (multiply, add, etc.) as it leverages BLAS and LAPACK library calls which are machinetuned matrix operations. Lacaml uses fortran_layout double arrays as the matrices on which it operates. The style of Lacaml is to use optional label arguments so that space may be reused. For instance the following creates two N by 3 matrices for multiplication and a 3 by 3 matrix to store the results. The two large matrices are multiplied and the result is stored in the 3 by 3 matrix: open Lacaml.D (* Use double precision matrix elements *) let n = 100 in let a = Mat.random n 3 in (* Create n by 3 matrix  Bigarray *) let b = Mat.random n 3 in (* Create n by 3 matrix  Bigarray *) let corr = Mat.make 3 3 in (* Create 3 by 3 matrix  Bigarray *) let new_corr = gemm ~c:corr ~transa:`T a b in (* matrix multiply *) ... This snippet multiplies 'a' and 'b' and stores the result in 'corr'. The final line creates a new name for 'corr', 'new_corr' which should point to the same space as the original 'corr'. This allows a pseudofunctional style of writing the program while avoiding the need to create many new matrices. As an alternative, the final line could be changed to ignore(gemm ~c:corr ~transa:`T acpy bcpy); and the name 'corr' used later. For convenience I have followed the style of the first version in my program. I suppose it is possible that creating the aliased name could affect the garbage collector (it might look like the allocation of another Bigarray so I will experiment with the second style.