caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jonathandeanharrop@googlemail.com>
To: "'Benedikt Meurer'" <benedikt.meurer@googlemail.com>,
	<caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] OCamlJIT2 vs. OCamlJIT
Date: Wed, 1 Dec 2010 22:03:16 -0000	[thread overview]
Message-ID: <0b9301cb91a3$8f42fd60$adc8f820$@com> (raw)
In-Reply-To: <B965CE04-4059-421F-A8CD-EB178BF32D40@googlemail.com>

Benedikt wrote:
> On Dec 1, 2010, at 15:11 , Jon Harrop wrote:
> > If you're asking what the advantages of using LLVM over generating C
> code
> > are, I'd say functionality like more numeric types, tail calls and
> JIT
> > compilation come top but also the fact that LLVM bundles nice OCaml
> bindings
> > and makes it easy to generate fast code. Also, I have other examples
> (e.g.
> > the random number generator from the SciMark2 benchmark) where LLVM
> can
> > generate code that runs 2x faster than anything I've been able to get
> out of
> > GCC.
> 
> LLVM sure does better as an intermediate language than C does, no
> question. But that wasn't my point in this example.

I think we are talking at cross purposes. My post was to explain some of the
many benefits of LLVM in response to Yoann's statement:

  "I don't understand why there is so much hype around LLVM. Why would you
think something written in C++ would be far better than the ocaml code we
have in the ocamlopt compiler?"

I was not just talking about porting ocamlopt to LLVM but more generally
about the advantages of using LLVM from OCaml in any way.

> >> So this is about data representation not code generation (using LLVM
> >> with boxed floats would result in same/lower performance);
> >
> > Yes. LLVM lets you choose your own data representation and
> applications like
> > numerics can benefit enormously from that. All the more reason to use
> LLVM.
> 
> As does assembler, so even more reasons to emit assembler?

LLVM makes it a *lot* easier to generate efficient code, of course.

> >> The literature
> >> includes various solutions to implement stuff like ML polymorphism:
> >> tagged integers/boxed floats/objects is just one solution, not
> >> necessarily the best; but examples that simply ignore the complex
> >> stuff, and therefore deliver better performance don't really help to
> >> make progress.
> >
> > Right. Reified generics can be a much better solution for performance,
> > particularly when combined with value types, and something else that
> > ocamlopt cannot express but HLVM can.
> 
> So this is an area to work on within ocamlopt.

If you can add value types and reified generics to ocamlopt and get them
accepted that would be great.

> > You are saying is that LLVM might not be faster if it were also
> afflicted
> > with ocamlopt's design, which is unproductive speculation. The point
> is that
> > LLVM and HLVM are not constrained by those design decisions as OCaml
> is, so
> > you can use them to generate much faster code.
> 
> We are talking about using LLVM within the OCaml compiler, so we have
> to talk about OCaml, not HLVM or anything else.

I was talking more generally about the benefits of LLVM in response to
Yoann's statement about the hype surrounding LLVM. HLVM demonstrates some of
the things a next-generation ocamlopt might be capable of.

> Don't get me wrong, I'm curious to see an LLVM backend for ocamlopt,
> especially since that way we would get a native top-level for free (at
> least for the JIT capable LLVM targets). But I doubt that LLVM will
> make a noticeable difference (except for probably reduced number of
> target specific code), since it will be faced with the same data
> representation used right now and LLVM will not be able to optimize
> much (assuming the ocamlopt higher level optimizations were already
> applied).

Absolutely. 

> What you are talking about is replacing several design decisions within
> OCaml (which have nothing to do with the low-level code generator);

Except that those design decisions have a huge effect on the optimizations
LLVM will do (if it is your code gen).

> this might be a good idea, and may indeed improve generated code.

HLVM's benchmark results would certainly seem to indicate that, yes.

> I don't know the opinion of the OCaml core developers, but from my POV,
> this sounds like an interesting challenge; however getting beyond a
> simplified proof-of-concept requires a lot of hard work.

Yes. At the end of the day, the performance gains that can be obtained by
bringing the GC up to date already dwarf all of these other effects so a new
GC is surely the highest priority. 

This begs a couple of questions:

* How dependent is OCaml bytecode on the data representation and GC?

* Could you write an OCaml bytecode interpreter in OCaml?

Perhaps we could write a multicore friendly OCamlJIT3. :-)

Cheers,
Jon.



  reply	other threads:[~2010-12-01 22:03 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30  8:36 Benedikt Meurer
2010-11-30 10:48 ` [Caml-list] " Török Edwin
2010-11-30 10:55   ` Benedikt Meurer
2010-11-30 17:01     ` bluestorm
2010-11-30 17:26       ` Török Edwin
2010-11-30 18:27         ` Basile Starynkevitch
2010-11-30 17:29       ` Benedikt Meurer
2010-11-30 17:32       ` Yoann Padioleau
2010-11-30 22:06         ` Jon Harrop
2010-11-30 22:48           ` Benedikt Meurer
2010-12-01 14:11             ` Jon Harrop
2010-12-01 15:00               ` Benedikt Meurer
2010-12-01 22:03                 ` Jon Harrop [this message]
2010-12-02  1:17                   ` Eray Ozkural
2010-12-03 10:03                   ` ocamlopt LLVM support (Was: [Caml-list] OCamlJIT2 vs. OCamlJIT) Benedikt Meurer
2010-12-03 13:34                     ` Till Varoquaux
2010-12-03 13:41                       ` Eray Ozkural
2010-12-03 14:06                         ` Török Edwin
2010-12-03 21:16                       ` Jon Harrop
2010-12-05 16:44                       ` Benedikt Meurer
2010-12-03 14:32                     ` Philippe Strauss
2010-12-03 21:22                       ` Jon Harrop
2010-12-03 21:45                         ` Philippe Strauss
2010-12-03 15:32                     ` Michael Ekstrand
2010-12-03 21:34                       ` Jon Harrop
2010-12-03 20:07                     ` Jon Harrop
2010-12-05 16:37                       ` Benedikt Meurer
2010-12-05 16:57                         ` Török Edwin
2010-12-05 20:54                           ` Benedikt Meurer
2010-12-05 20:12                         ` Jon Harrop
2010-12-05 21:21                           ` Benedikt Meurer
2010-12-05 21:44                             ` Benedikt Meurer
2010-12-06 22:38                             ` Jon Harrop
2010-12-05 22:41                           ` Erik de Castro Lopo
2010-12-05 22:34                         ` Erik de Castro Lopo
2010-12-06  8:27                           ` Benedikt Meurer
2010-12-06  9:28                             ` David Rajchenbach-Teller
2010-12-06 11:08                         ` Richard Jones
2010-12-06 20:18                           ` Jon Harrop
2010-12-01  0:16           ` [Caml-list] OCamlJIT2 vs. OCamlJIT Erik de Castro Lopo
2010-12-01  1:34             ` Yoann Padioleau
2010-12-01 12:58             ` Jon Harrop
2010-12-01 13:55               ` ivan chollet
2010-11-30 21:19       ` 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='0b9301cb91a3$8f42fd60$adc8f820$@com' \
    --to=jonathandeanharrop@googlemail.com \
    --cc=benedikt.meurer@googlemail.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;
as well as URLs for NNTP newsgroup(s).