caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christopher Kauffman <kauffman@cs.umn.edu>
To: OCaml <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Garbage collection and caml_adjust_gc_speed
Date: Tue, 29 Aug 2006 13:37:20 -0500	[thread overview]
Message-ID: <44F48960.6080908@cs.umn.edu> (raw)
In-Reply-To: <8B65BEE5-D101-4B39-98DD-3B68608702AC@inria.fr>

> 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 machine-tuned 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
re-used. 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 pseudo-functional 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.


  reply	other threads:[~2006-08-29 18:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-29  4:16 Christopher Kauffman
2006-08-29 15:20 ` [Caml-list] " Damien Doligez
2006-08-29 18:37   ` Christopher Kauffman [this message]
2006-08-31 15:34     ` Christopher Kauffman
2006-08-31 21:08       ` [Caml-list] Garbage collection and caml_adjust_gc_speed - Problem in Bigarray Christopher Kauffman
2006-09-01 17:06         ` David MENTRE

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44F48960.6080908@cs.umn.edu \
    --to=kauffman@cs.umn.edu \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).