Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-23 Thread Erick Matsen
Hello Caml-community-- First of all, big thanks to Will Farr, Mike Lin, Martin Jambon, and Markus Mottl. So far, I rewrote things in a non-functional way to avoid unecessary memory allocation, and then used the float operations directly. This resulted in a 4 fold increase in speed. Second, I mov

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Mike Lin
These are good points. I tend to compulsively eliminate any kind of memory allocation from my numerical loops -- it's true the OCaml allocator is a lot faster than malloc, but you could end up repaying a lot of that back to the GC later! The silly library I sent out does operate on OCaml float arra

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Markus Mottl
Unless you want to interface C-calls into BLAS/LAPACK directly without bounds checking, releasing the OCaml-lock, and other "fru-fru", it seems unlikely that you will get much of an advantage using those libraries given the small size of your matrices. E.g. Lacaml is optimized for larger matrices

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Will M. Farr
Mike and Erick, In some of my work, I've got code which is constantly creating and multiplying 4x4 matrices (Lorentz transforms). I usually write in a functional style, so I do not generally overwrite old matrices with the multiplication results. I have discovered that, at these sizes, it's abou

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Mike Lin
Erick, we should compare notes sometime. I have a lot of code for doing this kind of stuff (I am working on empirical codon models with 61x61 rate matrices). The right way to speed up matrix-vector operations is to use BLAS via either Lacaml or ocamlgsl. But if, like me, you like to counterproducti

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Martin Jambon
Erick Matsen wrote: > Wow, once again I am amazed by the vitality of this list. Thank you > for your suggestions. > > Here is the context: we are interested in calculating the likelihood > of taxonomic placement of short "metagenomics" sequence fragments from > unknown organisms in the ocean. We s

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Will M. Farr
Erick, Sorry about the long email, but here is an explanation of what "boxing" means, how it slows you down in this case, and how you can (eventually) figure out whether it will slow you down in general. I'm not an expert, so I've probably made mistakes in the following, but I think the broad out

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Erick Matsen
Wow, once again I am amazed by the vitality of this list. Thank you for your suggestions. Here is the context: we are interested in calculating the likelihood of taxonomic placement of short "metagenomics" sequence fragments from unknown organisms in the ocean. We start by assuming a model of sequ

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Xavier Leroy
> I'm working on speeding up some code, and I wanted to check with > someone before implementation. > > As you can see below, the code primarily spends its time multiplying > relatively small matrices. Precision is of course important but not > an incredibly crucial issue, as the most important th

Re: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Jon Harrop
On Friday 20 February 2009 15:40:00 Erick Matsen wrote: > Hello Ocaml community--- > > I'm working on speeding up some code, and I wanted to check with > someone before implementation. > > As you can see below, the code primarily spends its time multiplying > relatively small matrices. Precision is

RE: [Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread RABIH.ELCHAAR
this helps Rabih -Message d'origine- De : caml-list-boun...@yquem.inria.fr [mailto:caml-list-boun...@yquem.inria.fr] De la part de Erick Matsen Envoyé : vendredi 20 février 2009 16:40 À : caml-l...@inria.fr Objet : [Caml-list] speeding up matrix multiplication (newbie question) H

[Caml-list] speeding up matrix multiplication (newbie question)

2009-02-20 Thread Erick Matsen
Hello Ocaml community--- I'm working on speeding up some code, and I wanted to check with someone before implementation. As you can see below, the code primarily spends its time multiplying relatively small matrices. Precision is of course important but not an incredibly crucial issue, as the mo