caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: Jan Kybic <kybic@fel.cvut.cz>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] HLVM numerical performance
Date: Mon, 9 Mar 2009 11:37:52 +0000	[thread overview]
Message-ID: <200903091137.53084.jon@ffconsultancy.com> (raw)
In-Reply-To: <87ab7v3w3q.fsf_-_@fel.cvut.cz>

On Monday 09 March 2009 09:04:57 Jan Kybic wrote:
> > The OCaml Forge has kindly accepted to host the HLVM project:
> >
> >   http://hlvm.forge.ocamlcore.org
>
> Hello. Just out of curiosity:
>
> I recall reading that one of your priorities for HLVM is performance of
> numerical code. 

HLVM aspires to provide the following benefits over OCaml:

. High performance numerics (often 2-4x faster than OCaml on x86).

. High performance polymorphism: polymorphic definitions are instantiated for 
different types.

. More numeric types (float32, complexes, low-dimensional vectors and 
matrices).

. More optimizations for the benefit of numerical computing: common 
subexpression elimination, hoisting of loop invariants, inlining of function 
arguments to higher-order functions.

. Faster and easier FFI for external libraries like FFTW and LAPACK.

. Dynamic capabilities such as generic printing, hashing, comparison, 
serialization and run-time type information.

. Community led development: you can contribute to the open source HLVM code 
base.

. Commerce friendly design so it will be viable for you to buy and sell 
libraries written for HLVM.

. A common language run-time so you can safely consume and produce libraries 
written in any languages with implementations that target HLVM.

> Does it mean that you expect numerical code to run faster than natively
> compiled (with ocamlopt) Ocaml? 

Absolutely. Most numerical code already runs a lot faster in HLVM than it does 
in ocamlopt if you disable GC in any inner loops that act upon arrays. In the 
future, I expect HLVM to be a lot faster still because it will generate SSE 
instructions (using LLVM's vector intrinsics) and perform many optimizations 
of its own (such as hoisting the GC code automatically).

> Do you have any experiments so far to support this?

Yes. The "test.ml" file from the HLVM subversion repository contains over 500 
lines of test code that includes a few simple benchmarks. Here is a 
comparison of the performance of ordinary OCaml with the best performance I 
have been able to obtain using HLVM:

Float Fibonacci (recursive floating point functions)
OCaml: 6.10s
HLVM:  1.74s  3.5x faster than ocamlopt

Mandelbrot (complex arithmetic)
OCaml: 4.39s
HLVM:  1.89s  2.3x faster than ocamlopt

Sieve of Eratosthenes (int arrays)
OCaml: 14.9s  (had to use big arrays)
HLVM:  7.05s  2.1x faster than ocamlopt

As you can see HLVM is already generating much faster code than ocamlopt. Note 
that the OCaml code can be improved (e.g. by avoiding OCaml's complex number 
type) but the point is that idiomatic code is much faster with HLVM.

> I am doing large scale numerical calculations in Ocaml and performance
> is always an issue for me.

A lot of people have adopted OCaml for number crunching and string munging 
(bioinformatics). Although ocamlopt is an excellent compiler, HLVM has shown 
that it is possible to do much better still. I hope HLVM will form the 
backbone of an OCaml variant designed specifically for technical computing.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


  reply	other threads:[~2009-03-09 11:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-08  1:19 HLVM is now garbage collected! Jon Harrop
2009-03-08  2:45 ` [Caml-list] " Jon Harrop
2009-03-08  9:35   ` Richard Jones
2009-03-09  4:13     ` Jon Harrop
2009-03-09  9:04       ` HLVM numerical performance Jan Kybic
2009-03-09 11:37         ` Jon Harrop [this message]
2009-03-09 11:53           ` [Caml-list] " Jon Harrop
2009-03-09 12:55       ` [Caml-list] HLVM is now garbage collected! Richard Jones
2009-03-08  9:43   ` Joel Reymont
2009-03-08 10:21     ` Sylvain Le Gall
2009-03-08 10:54       ` Sylvain Le Gall
2009-03-09  4:11     ` [Caml-list] " Jon Harrop
2009-03-13 13:49 ` Jon Harrop
2009-03-13 20:40   ` Mikkel Fahnøe Jørgensen
2009-03-20  2:20     ` Jon Harrop

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=200903091137.53084.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=kybic@fel.cvut.cz \
    /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).