caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Native compiler for oCaml on System Z
@ 2015-07-09 20:35 Bull Durham
  2015-07-09 21:58 ` Basile Starynkevitch
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Bull Durham @ 2015-07-09 20:35 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

Hello. I'm with the IBM Linux on Z Open Source Ecosystem Center of
Competency in Toronto. I would like to provide (and maintain) a port of the
OCaml native compiler for Linux on System Z (a.k.a IBM 390 or s390x). Can
someone advise me on whom to contact to begin discussions on how to make
the port available to the wider OCaml community? Ideally it would be great
if it could ultimately become part of the standard OCaml distribution.
Thanks for any advice you can give.

...Bill O'Farrell

[-- Attachment #2: Type: text/html, Size: 542 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Native compiler for oCaml on System Z
  2015-07-09 20:35 [Caml-list] Native compiler for oCaml on System Z Bull Durham
@ 2015-07-09 21:58 ` Basile Starynkevitch
       [not found]   ` <CAGyVGgNf543Jp4thTQbN5O7xvGDJphrUWY2w_G0YtAm0LTExYQ@mail.gmail.com>
  2015-07-10 17:39   ` Xavier Leroy
  2015-07-10 15:30 ` Mark Shinwell
  2015-07-14 13:39 ` Richard W.M. Jones
  2 siblings, 2 replies; 8+ messages in thread
From: Basile Starynkevitch @ 2015-07-09 21:58 UTC (permalink / raw)
  To: caml-list

On 07/09/2015 10:35 PM, Bull Durham wrote:
> Hello. I'm with the IBM Linux on Z Open Source Ecosystem Center of 
> Competency in Toronto. I would like to provide (and maintain) a port 
> of the OCaml native compiler for Linux on System Z (a.k.a IBM 390 or 
> s390x). Can someone advise me on whom to contact to begin discussions 
> on how to make the port available to the wider OCaml community? 
> Ideally it would be great if it could ultimately become part of the 
> standard OCaml distribution. Thanks for any advice you can give.


A possible way might be to not directly target SystemZ but to leverage 
on some of the efforts which
either have translated the Ocaml bytecode to C, or to consider writing 
some JIT backend for Ocaml;
I'm thinking of patching the Ocaml native compiler to use LLVM or more 
probably the very new
GCCJIT https://gcc.gnu.org/onlinedocs/jit to leverage on the 
optimization abilities of GCC middle-end & back-end etc.

There are indeed some issues, in particular compatibility between the 
garbage collector and what such JIT libraries are able to generate (tail 
recursion is less of an issue at least in GCCJIT).

Regards.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Native compiler for oCaml on System Z
       [not found]   ` <CAGyVGgNf543Jp4thTQbN5O7xvGDJphrUWY2w_G0YtAm0LTExYQ@mail.gmail.com>
@ 2015-07-09 23:03     ` Basile Starynkevitch
  0 siblings, 0 replies; 8+ messages in thread
From: Basile Starynkevitch @ 2015-07-09 23:03 UTC (permalink / raw)
  To: Bull Durham; +Cc: caml-list

On 07/10/2015 12:17 AM, Bull Durham wrote:
> Hi. Yes I've thought of those. However I think a direct port is the 
> most straightforward way to achieve the best performance results.

Perhaps; on the other hand I believe that a GCCJIT approach might 
produce better code (e.g. because of
GCC complex register allocation & instruction scheduling abilities).

Maybe before doing a direct port, writing & publishing some wikipage 
about what you are understanding of ocamlopt would be worthwhile.

IIRC there have been such efforts in the past, but such information is 
stalling quickly. So any grey documentation about Ocaml is welcome.


Regards.


-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Native compiler for oCaml on System Z
  2015-07-09 20:35 [Caml-list] Native compiler for oCaml on System Z Bull Durham
  2015-07-09 21:58 ` Basile Starynkevitch
@ 2015-07-10 15:30 ` Mark Shinwell
  2015-07-14 13:39 ` Richard W.M. Jones
  2 siblings, 0 replies; 8+ messages in thread
From: Mark Shinwell @ 2015-07-10 15:30 UTC (permalink / raw)
  To: Bull Durham; +Cc: caml-list

Do you have the port already written and tested?  It wasn't clear from
your mail.

Mark

On 9 July 2015 at 21:35, Bull Durham <billotosyr@gmail.com> wrote:
> Hello. I'm with the IBM Linux on Z Open Source Ecosystem Center of
> Competency in Toronto. I would like to provide (and maintain) a port of the
> OCaml native compiler for Linux on System Z (a.k.a IBM 390 or s390x). Can
> someone advise me on whom to contact to begin discussions on how to make the
> port available to the wider OCaml community? Ideally it would be great if it
> could ultimately become part of the standard OCaml distribution. Thanks for
> any advice you can give.
>
> ...Bill O'Farrell

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Native compiler for oCaml on System Z
  2015-07-09 21:58 ` Basile Starynkevitch
       [not found]   ` <CAGyVGgNf543Jp4thTQbN5O7xvGDJphrUWY2w_G0YtAm0LTExYQ@mail.gmail.com>
@ 2015-07-10 17:39   ` Xavier Leroy
  2015-07-10 17:47     ` Raoul Duke
  1 sibling, 1 reply; 8+ messages in thread
From: Xavier Leroy @ 2015-07-10 17:39 UTC (permalink / raw)
  To: caml-list

On 09/07/15 23:58, Basile Starynkevitch wrote:
> A possible way might be to not directly target SystemZ but to
> leverage on some of the efforts which either have translated the
> Ocaml bytecode to C, or to consider writing some JIT backend for
> Ocaml; I'm thinking of patching the Ocaml native compiler to use
> LLVM or more probably the very new GCCJIT
> https://gcc.gnu.org/onlinedocs/jit to leverage on the optimization
> abilities of GCC middle-end & back-end etc.

Targeting LLVM or GCCJIT is an interesting but separate project.
At least one attempt were made in the past to target LLVM, running into
problems with the (exact) GC interface of OCaml.  Maybe LLVM improved
recently in this department, and maybe GCCJIT can handle it too.  If
not, I think it's a dead end.

- Xavier Leroy

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Native compiler for oCaml on System Z
  2015-07-10 17:39   ` Xavier Leroy
@ 2015-07-10 17:47     ` Raoul Duke
  2015-07-10 22:15       ` Gabriel Scherer
  0 siblings, 1 reply; 8+ messages in thread
From: Raoul Duke @ 2015-07-10 17:47 UTC (permalink / raw)
  To: OCaml

> Targeting LLVM or GCCJIT is an interesting but separate project.
> At least one attempt were made in the past to target LLVM, running into
> problems with the (exact) GC interface of OCaml.  Maybe LLVM improved
> recently in this department, and maybe GCCJIT can handle it too.  If
> not, I think it's a dead end.


For posterity, and for the sake of curiosity, might someone in the
know succinctly explain what the (exact) GC interface road blocks
were? Thank you!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Native compiler for oCaml on System Z
  2015-07-10 17:47     ` Raoul Duke
@ 2015-07-10 22:15       ` Gabriel Scherer
  0 siblings, 0 replies; 8+ messages in thread
From: Gabriel Scherer @ 2015-07-10 22:15 UTC (permalink / raw)
  To: Raoul Duke; +Cc: OCaml

[-- Attachment #1: Type: text/plain, Size: 2474 bytes --]

There were in fact at least two serious attempts at a LLVM port:
- one by Colin Benner,
  https://github.com/colinbenner/ocamlllvm
  http://oud.ocaml.org/2012/abstracts/oud2012-paper7.pdf
  (the paper above briefly discusses GC issues)
- one by Raphaël Amiard,
  https://github.com/raph-amiard/CamllVM
  https://www.irill.org/blog/camllvm-a-llvm-based-runtime-for-ocaml
  (in the spirit of University Pierre et Marie Curie, this compiler goes
from
   OCaml bytecode to LLVM programs, instead of being a harder-to-deploy
   native-code compiler backend)

Both cited the GC interface and the slowness of exceptions (relative to the
exceptionnally fast OCaml runtime exception handling on which many programs
rely). These difficulties had been correctly foreplanned by Xavier Leroy in
his 2009 caml-list message

http://caml.inria.fr/pub/ml-archives/caml-list/2009/03/3a77bfcca0f90b763d127d1581d6a2f1.en.html

There has been recent developments on the GC support front in the LLVM
community, notably the work of Philip Reames on "statepoints" as an
alternative approach to GC support (that should support eg. passing roots
in registers):
http://www.philipreames.com/Blog/2014/10/21/statepoints-vs-gcroot-for-representing-call-safepoints/

Regarding exceptions, I would guess a necessary evil would be to do more
static analyses inside the OCaml backend to detect when exception usage can
be refined to less generic constructs (eg. the experiments of Alain Frisch
on "static raise": https://www.lexifi.com/blog/static-exceptions ).
Degraded exceptions are also a source of performance issues on other
backends such as js_of_ocaml.


On Sat, Jul 11, 2015 at 2:47 AM, Raoul Duke <raould@gmail.com> wrote:

> > Targeting LLVM or GCCJIT is an interesting but separate project.
> > At least one attempt were made in the past to target LLVM, running into
> > problems with the (exact) GC interface of OCaml.  Maybe LLVM improved
> > recently in this department, and maybe GCCJIT can handle it too.  If
> > not, I think it's a dead end.
>
>
> For posterity, and for the sake of curiosity, might someone in the
> know succinctly explain what the (exact) GC interface road blocks
> were? Thank you!
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 3874 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Native compiler for oCaml on System Z
  2015-07-09 20:35 [Caml-list] Native compiler for oCaml on System Z Bull Durham
  2015-07-09 21:58 ` Basile Starynkevitch
  2015-07-10 15:30 ` Mark Shinwell
@ 2015-07-14 13:39 ` Richard W.M. Jones
  2 siblings, 0 replies; 8+ messages in thread
From: Richard W.M. Jones @ 2015-07-14 13:39 UTC (permalink / raw)
  To: Bull Durham; +Cc: caml-list, rjones

On Thu, Jul 09, 2015 at 04:35:53PM -0400, Bull Durham wrote:
> Hello. I'm with the IBM Linux on Z Open Source Ecosystem Center of
> Competency in Toronto. I would like to provide (and maintain) a port
> of the OCaml native compiler for Linux on System Z (a.k.a IBM 390 or
> s390x). Can someone advise me on whom to contact to begin
> discussions on how to make the port available to the wider OCaml
> community? Ideally it would be great if it could ultimately become
> part of the standard OCaml distribution.  Thanks for any advice you
> can give.

Could it be my wishes have come true .. :-?

While I'm not really in a position to help you with the actual port, I
can help you in another way: We would include an s/390x backend in
Fedora (initially) and RHEL (if it proved stable enough), and this
would give you a fair bit of real world testing.

We already include downstream backends for ppc64 & ppc64le, the latter
provided by IBM.

In order to actually do this, what you'd have to do is develop against
the upstream OCaml git repository: https://github.com/ocaml/ocaml
(fork it somewhere), and when you have a working backend, let me know
where that is by emailing my redhat.com address and I'll pull it into
Fedora.

Rich.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-14 13:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-09 20:35 [Caml-list] Native compiler for oCaml on System Z Bull Durham
2015-07-09 21:58 ` Basile Starynkevitch
     [not found]   ` <CAGyVGgNf543Jp4thTQbN5O7xvGDJphrUWY2w_G0YtAm0LTExYQ@mail.gmail.com>
2015-07-09 23:03     ` Basile Starynkevitch
2015-07-10 17:39   ` Xavier Leroy
2015-07-10 17:47     ` Raoul Duke
2015-07-10 22:15       ` Gabriel Scherer
2015-07-10 15:30 ` Mark Shinwell
2015-07-14 13:39 ` Richard W.M. Jones

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).