From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: HLVM?
Date: Sat, 26 Sep 2009 22:59:32 +0100 [thread overview]
Message-ID: <200909262259.32970.jon@ffconsultancy.com> (raw)
In-Reply-To: <slrnhbstt8.cs6.sylvain@gallu.homelinux.org>
On Saturday 26 September 2009 21:23:32 Sylvain Le Gall wrote:
> On 26-09-2009, David McClain <dbm@refined-audiometrics.com> 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
prev parent reply other threads:[~2009-09-26 21:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-26 16:33 HLVM? David McClain
2009-09-26 17:26 ` [Caml-list] HLVM? Jon Harrop
2009-09-26 20:23 ` HLVM? Sylvain Le Gall
2009-09-26 21:59 ` Jon Harrop [this message]
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=200909262259.32970.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--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