From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Google summer of Code proposal
Date: Sat, 21 Mar 2009 13:38:32 +0000 [thread overview]
Message-ID: <200903211338.32805.jon@ffconsultancy.com> (raw)
In-Reply-To: <200903211439.47107.cdome@bk.ru>
On Saturday 21 March 2009 12:39:45 Andrey Riabushenko wrote:
> Hi OCaml hackers,
>
> It is not mistake, in spite of ocaml does not take part in GSoC 2009, but
> ocaml community still can benefit from it.
>
> I would like to develop LLVM frontend to Ocaml language. LLVM does
> participate in GSoC. LLVM do not mind to developed a ocaml frontend as LLVM
> GSoC project. I want to discuss details with you before I will make an
> official proposal to LLVM.
I recommend you peruse the LLVM and HLVM mailing lists for information about
current work along similar lines:
http://hlvm.forge.ocamlcore.org
> 1. What is the best way to make ocaml frontend on your opinion?
The impedance mismatch between the current OCaml compilers and LLVM is high:
. The OCaml compilers remove type information in the early stages of
compilation but LLVM is a typed assembler and needs that information to be
conveyed all the way through to the back end.
. The OCaml compilers make no attempt to provide reusable intermediate
representations.
So you will probably end up hacking extensively on ocamlopt's internals and,
consequently, your code will be bound by the QPL license even though you will
probably not salvage much. This is why I started from scratch.
> I think the best would to way to develop ocaml llvm front end as a part of
> ocaml distribution. I don't not want to develop yet another a separate
> project, which is half-done llvm frontend that nobody uses. There are
> plenty of those for other languages lying around. I propose to forget about
> JIT capabilities of LLVM and concentrate on AOT compilation for now.
JIT is the single most important benefit of LLVM in the context of OCaml. With
JIT:
. You can instantiate polymorphic definitions for each combination of type
parameters that they are used with, providing substantial performance
improvements.
. You can generate code that is optimized for the current machine.
. You can provide a performant top-level.
Forgetting about JIT would certainly be a mistake.
> Ocamlopt currently generates native assembler for the following platforms:
> i386, AMD64, ia64, arm, hppa, alpha, m68k, mips, powerpc, sparc assembler.
> I propose to add LLVM assembler generation as another platform to ocamlopt.
> It requires the least modification of ocaml source and easy to maintain.
There are many problems with this:
. You will succumb to ocamlopt's current run-time representation which is
objectively inefficient (e.g. boxing floats, tuples, records) and was only
chosen because the compiler lacks capabilities that LLVM already provides for
you (primarily JIT compilation).
. LLVM's optimization passes will not optimize the representations and,
consequently, performance will not be improved.
. You will inherit ocamlopt's most serious flaws: its run-time and its FFI.
. If you inherit ocamlopt's run-time then you will need to be able to generate
compliant code from LLVM which is extremely difficult, error prone and almost
entirely untested.
> LLVM will give ocaml an aggressive whole program optimizer...
I doubt you could even match the performance of OCaml's existing compiler with
that approach, much less beat it. There are two reasons for this:
. Building upon ocamlopt's internal run-time representation (e.g. boxed
tuples) ties LLVM's hands behind its back when it comes to optimization. LLVM
could do very little to optimize such code.
. LLVM's existing optimization passes work great on naively-generated C or C++
code but they know nothing about parametric polymorphism, closures and
pattern matching. These high-level language features are where the most
beneficial optimizations lie.
For example, applying LLVM's optimization passes to HLVM generated code only
give ~15% performance improvements.
> Question to the Ocaml creators and maintainers.
>
> 2. Will you merge LLVM platform to the ocaml trunk assuming that it works
> as it should?
Collaboration with the existing HLVM effort would probably be far more
productive.
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e
next prev parent reply other threads:[~2009-03-21 13:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-21 12:39 Andrey Riabushenko
2009-03-21 13:01 ` [Caml-list] " Seo Sanghyeon
2009-03-21 13:47 ` Andrey Riabushenko
2009-03-21 14:51 ` Jon Harrop
2009-03-21 20:49 ` Joel Reymont
2009-03-21 21:35 ` Jon Harrop
2009-03-21 13:38 ` Jon Harrop [this message]
2009-03-21 20:43 ` Joel Reymont
2009-03-21 21:28 ` Michael Ekstrand
2009-03-23 17:23 ` [Caml-list] " Kuba Ober
2009-03-21 22:21 ` [Caml-list] " Jon Harrop
2009-03-22 0:12 ` Fermin Reig
2009-03-23 14:19 ` Xavier Leroy
2009-03-23 19:38 ` Jon Harrop
2009-03-24 15:39 ` Xavier Leroy
2009-03-30 15:42 ` Nicolas Cannasse
2009-03-30 15:56 ` Joel Reymont
2009-03-30 21:21 ` Jon Harrop
2009-03-31 0:36 ` Jon Harrop
[not found] <20090321204943.E2ACCBBFA@yquem.inria.fr>
2009-03-21 21:45 ` Andrey Riabushenko
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=200903211338.32805.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