caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Basile STARYNKEVITCH <basile@starynkevitch.net>
To: Eray Ozkural <examachine@gmail.com>
Cc: caml-list@inria.fr, Emmanuel Chailloux <Emmanuel.Chailloux@lip6.fr>
Subject: Re: [Caml-list] How to write a CUDA kernel in ocaml?
Date: Tue, 15 Dec 2009 17:29:53 +0100	[thread overview]
Message-ID: <4B27B981.80700@starynkevitch.net> (raw)
In-Reply-To: <320e992a0912150820l4d36e4e0s24dc7cc084c9fc29@mail.gmail.com>

Eray Ozkural wrote:
>>> I've looked at the CUDA bindings for ocaml, but it seems the kernels
>>> were in C, am I right? How can I write the kernel in ocaml? 

> At any rate, the obvious question from a compiler standpoint is,
> cannot we compile ocaml to C, is there a way to translate to C first
> and then to whatever works for kernel? I know little about the ocaml
> compiler so please forgive my naive questions.

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. Some C compilers 
are able to generate (in the machine) a teil call for a limited kind of C functions, which are not compatible with 
Ocaml's runtime system (& garbage collector).

You could perhaps translate (in a dummy & inefficient way) the full Ocaml bytecode of an entire Ocaml application into a 
C program (for example, as a huge monolithic single C function, which would make gcc very unhappy to compile it). Of 
course, you could do much better, but it is not a trivial task.

Another issue is that Ocaml might not box (or unbox) your floating point values as CUDA (or OpenCL) expects them.

But I am not an expert on these things.

Good luck.

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 mines, sont seulement les miennes} ***


  reply	other threads:[~2009-12-15 16:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-15 15:37 Eray Ozkural
2009-12-15 16:07 ` [Caml-list] " Basile STARYNKEVITCH
2009-12-15 16:20   ` Eray Ozkural
2009-12-15 16:29     ` Basile STARYNKEVITCH [this message]
2009-12-15 17:46       ` Eray Ozkural
2009-12-15 23:18       ` David Allsopp
2009-12-16  0:39         ` Jon Harrop
2009-12-16 13:41           ` Mattias Engdegård
2009-12-16 13:47             ` Eray Ozkural
2009-12-17  0:34               ` Philippe Wang
2009-12-17  6:45                 ` Eray Ozkural
2009-12-17 10:59                   ` Philippe Wang
2010-01-12  6:15             ` Eray Ozkural
2009-12-16  6:26         ` Basile STARYNKEVITCH

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=4B27B981.80700@starynkevitch.net \
    --to=basile@starynkevitch.net \
    --cc=Emmanuel.Chailloux@lip6.fr \
    --cc=caml-list@inria.fr \
    --cc=examachine@gmail.com \
    /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).