From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 4A4C0BBAF for ; Wed, 16 Dec 2009 00:19:05 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArsBAPenJ0tRZ90vkWdsb2JhbACbRgEBAQEJCwoHEwO8FIIsgX8E X-IronPort-AV: E=Sophos;i="4.47,402,1257116400"; d="scan'208";a="42085546" Received: from mtaout01-winn.ispmail.ntl.com ([81.103.221.47]) by mail1-smtp-roc.national.inria.fr with ESMTP; 16 Dec 2009 00:19:04 +0100 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20091215231904.KVQW17029.mtaout01-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com>; Tue, 15 Dec 2009 23:19:04 +0000 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout01-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20091215231904.TCGV13254.aamtaout01-winn.ispmail.ntl.com@romulus.metastack.com>; Tue, 15 Dec 2009 23:19:04 +0000 Received: from COUNTERTENOR (hotelastra-58.rev.fibrelac.com [83.137.80.58] (may be forged)) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id nBFNIxwi031158 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 15 Dec 2009 23:19:01 GMT From: "David Allsopp" To: "'Basile STARYNKEVITCH'" , "'Eray Ozkural'" Cc: References: <320e992a0912150737t483a5946x9cad351fc344691f@mail.gmail.com> <4B27B442.9030300@starynkevitch.net> <320e992a0912150820l4d36e4e0s24dc7cc084c9fc29@mail.gmail.com> <4B27B981.80700@starynkevitch.net> In-Reply-To: <4B27B981.80700@starynkevitch.net> Subject: RE: [Caml-list] How to write a CUDA kernel in ocaml? Date: Wed, 16 Dec 2009 00:18:57 +0100 Message-ID: <017101ca7ddc$fb936b20$f2ba4160$@allsopp@metastack.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acp9o9YuT6tCiOjMQOmG3DL95pMq8AAN0NLg Content-Language: en-gb Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.1 cv=1ggfb5FlKZQUfF3vzm9UBYZ2uTfLsbs/8dSljwg5+mE= c=1 sm=0 a=wVx31X6HEHgA:10 a=MaO8X6cfgU8lbptdfSoA:9 a=__PLCE4FlJUtL6CUXAsA:7 a=19FB-OZLQaXC1-vvll74MZWcmzMA:4 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Spam: no; 0.00; ocaml:01 basile:01 eray:01 ozkural:01 ocaml:01 recursive:01 recursion:01 recursive:01 recursion:01 translating:01 wrote:01 wrote:01 compilers:01 compilers:01 caml-list:01 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++ David