English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: [Caml-list] How to write a CUDA kernel in ocaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-12-15 (23:25)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] How to write a CUDA kernel in ocaml?
On Tuesday 15 December 2009 23:18:57 David Allsopp wrote:
> Basile Starynkevitch wrote:
> > Eray Ozkural wrote:
> >
> > Compiling Ocaml to efficient C is not easy and probably impossible (or
> > extremely difficult) in the general case. In
> > particular, tail recursive calls are essential in Ocaml, and are not
> > available in C in most compilers.
> What's this based on (out of interest)? Most C compilers don't necessarily
> identify tail recursion in *C* code but if you're emitting C as an OCaml
> backend then there's no reason not to convert tail recursive *OCaml*
> functions to C code based on goto or similar looping constructs (yes, you'd
> almost-always-virtually-never use goto in a hand-crafted C program without
> apologising profusely at Dijkstra's grave but if you're using C as an
> intermediate language then that's a different matter). If I recall
> correctly from an old post on this list, this is how Felix handles tail
> recursion when translating Felix to C++

And trampolines to eliminate tail calls that cannot be eliminated using goto. 
However, trampolines are ~10x slower than TCO in the code gen.

Dr Jon Harrop, Flying Frog Consultancy Ltd.