From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id F3FD4BBAF for ; Mon, 9 Mar 2009 12:32:31 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArwCANSatEnUnwckk2dsb2JhbACCHZMPAQEBAQkJCgkRBLsJhAUG X-IronPort-AV: E=Sophos;i="4.38,329,1233529200"; d="scan'208";a="36282264" Received: from relay.ptn-ipout02.plus.net ([212.159.7.36]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 Mar 2009 12:32:31 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnIGAMObtEnUnw4R/2dsb2JhbACCHc5LhAUG Received: from pih-relay04.plus.net ([212.159.14.17]) by relay.ptn-ipout02.plus.net with ESMTP; 09 Mar 2009 11:32:22 +0000 Received: from [87.112.234.120] (helo=leper.local) by pih-relay04.plus.net with esmtp (Exim) id 1LgdiX-0001Ls-6A; Mon, 09 Mar 2009 11:32:21 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: Jan Kybic , caml-list@yquem.inria.fr Subject: Re: [Caml-list] HLVM numerical performance Date: Mon, 9 Mar 2009 11:37:52 +0000 User-Agent: KMail/1.9.9 References: <200903080119.20330.jon@ffconsultancy.com> <200903090413.11954.jon@ffconsultancy.com> <87ab7v3w3q.fsf_-_@fel.cvut.cz> In-Reply-To: <87ab7v3w3q.fsf_-_@fel.cvut.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903091137.53084.jon@ffconsultancy.com> X-Plusnet-Relay: 44594d7731bce2846fa8d8bedbfcd566 X-Spam: no; 0.00; ocaml:01 ocaml:01 polymorphism:01 vectors:01 matrices:01 invariants:01 inlining:01 higher-order:01 ffi:01 lapack:01 hashing:01 run-time:01 run-time:01 ocamlopt:01 ocamlopt:01 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