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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id D8DF6BBAF for ; Sat, 26 Sep 2009 23:59:07 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApYBAFYrvkrUnwdkkWdsb2JhbACCH5hjAQEBAQkLCgcTBLhKhB4FgVg X-IronPort-AV: E=Sophos;i="4.44,457,1249250400"; d="scan'208";a="33605966" Received: from relay.pcl-ipout02.plus.net ([212.159.7.100]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 26 Sep 2009 23:59:07 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al0GAI0rvkrUnw6R/2dsb2JhbACCH9FshB4FgVg Received: from ptb-relay01.plus.net ([212.159.14.145]) by relay.pcl-ipout02.plus.net with ESMTP; 26 Sep 2009 22:59:07 +0100 Received: from [87.114.87.187] (helo=leper.local) by ptb-relay01.plus.net with esmtp (Exim) id 1MrfIJ-0008Is-5C for caml-list@yquem.inria.fr; Sat, 26 Sep 2009 22:59:07 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: HLVM? Date: Sat, 26 Sep 2009 22:59:32 +0100 User-Agent: KMail/1.9.9 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200909262259.32970.jon@ffconsultancy.com> X-Plusnet-Relay: bdd009944c43160dac5224bfa06ef5b8 X-Spam: no; 0.00; compiler:01 compiler:01 transitions:01 ocaml:01 2009:98 gratis:98 10,:98 frog:98 wrote:01 wrote:01 rec:01 rec:01 compile:01 compile:01 compiles:01 On Saturday 26 September 2009 21:23:32 Sylvain Le Gall wrote: > On 26-09-2009, David McClain wrote: > > Can you provide some gratis information about what makes HLVM so well > > suited to scientific computing? Something that might prompt one to > > actually subscribe to your journal? > > If I am not wrong, you can access source code of HLVM from here: > http://hlvm.forge.ocamlcore.org That is correct. > There is some source code that compiles and allows to run something (I > have not tested myself). I just checked in a second version of the compiler. If you compile it in hlvm/examples/compiler2 and run ./repl then you get a REPL: $ svn checkout svn://svn.forge.ocamlcore.org/svnroot/hlvm ... $ cd hlvm $ ./compile.sh $ cd examples/compiler2 $ ./compile.sh 57 states, 473 transitions, table size 2234 bytes $ ./repl # 1+2*3+4;; - : `Int = 11 Live: 0 Took 0.076751s # create(10, 3);; - : `Array(`Int) = [|3; 3; 3; 3; 3; 3; 3; 3; 3; 3|] Live: 1 Took 0.029611s It can run OCaml programs like the following FFT implementation (from bench.ml): let rec zadd(((r1, i1), (r2, i2)) : (float * float) * (float * float)) : float * float = r1 +. r2, i1 +. i2;; let rec zmul(((r1, i1), (r2, i2)) : (float * float) * (float * float)) : float * float = r1 *. r2 -. i1 *. i2, r1 *. i2 +. i1 *. r2;; let rec aux1((i, n, a, a1, a2) : int * int * (float * float) array * (float * float) array * (float * float) array) : unit = if i < n/2 then begin a1.(i) <- a.(2*i); a2.(i) <- a.(2*i+1); aux1(i+1, n, a, a1, a2) end;; let rec aux2((k, n, a, a1, a2) : int * int * (float * float) array * (float * float) array * (float * float) array) : unit = if k < n/2 then begin let t = 4. *. pi *. float_of_int k /. float_of_int n in a.(k) <- zadd(a1.(k), zmul(a2.(k), (cos t, -.sin t))); aux2(k+1, n, a, a1, a2) end;; let rec aux3((k, n, a, a1, a2) : int * int * (float * float) array * (float * float) array * (float * float) array) : unit = if k < n then begin let t = 4. *. pi *. float_of_int k /. float_of_int n in a.(k) <- zadd(a1.(k-n/2), zmul(a2.(k-n/2), (cos t, -.sin t))); aux3(k+1, n, a, a1, a2) end;; let rec fft(a: (float * float) array) : (float * float) array = if length a = 1 then create(1, a.(0)) else begin let n = length a in let a1 = create(n/2, (0., 0.)) in let a2 = create(n/2, (0., 0.)) in aux1(0, n, a, a1, a2); let a1 = fft a1 in let a2 = fft a2 in aux2(0, n, a, a1, a2); aux3(n/2, n, a, a1, a2); a end;; let rec test(n: int) : (float * float) array = let a = create(n, (0., 0.)) in a.(1) <- 1.0, 0.0; fft a;; test 8;; let rec ignore(a: (float * float) array) : unit = ();; ignore(fft(create(1048576, (0.0, 0.0))));; -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e