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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DA613BC58 for ; Tue, 14 Sep 2010 14:08:43 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuQBAIICj0zAbHMMmWdsb2JhbACDG5BjjVEVAQEBAQEICwoHESKwMZIFhEx0BI0k X-IronPort-AV: E=Sophos;i="4.56,363,1280700000"; d="vcf'?scan'208,217";a="57231378" Received: from coliposte.enst-bretagne.fr ([192.108.115.12]) by mail3-smtp-sop.national.inria.fr with ESMTP; 14 Sep 2010 14:08:43 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8EC8jXU021119 for ; Tue, 14 Sep 2010 14:08:45 +0200 Received: from courrier.enst-bretagne.fr (smtps.telecom-bretagne.eu [10.29.90.4]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8EC8XNs021060 for ; Tue, 14 Sep 2010 14:08:36 +0200 Received: from [10.66.144.72] (pc-salsa-elec-072.ext.enst-bretagne.fr [10.66.144.72]) (user=vgripon mech=PLAIN bits=0) by courrier.enst-bretagne.fr (8.13.8/8.13.8/2010.02.22) with ESMTP id o8EC8UV8008674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Sep 2010 14:08:30 +0200 Message-ID: <4C8F660B.4060901@telecom-bretagne.eu> Date: Tue, 14 Sep 2010 14:09:47 +0200 From: Vincent Gripon User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10pre) Gecko/20100911 Shredder/3.1.5pre MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Compiling Ocaml sources to c sources Content-Type: multipart/mixed; boundary="------------020201020709000603040500" X-Virus-Scanned: amavisd-new at enst-bretagne.fr X-Spam: no; 0.00; ocaml:01 planing:01 ocaml:01 compilable:01 pointer:01 -output-obj:01 compiler:01 planing:01 compilable:01 pointer:01 -output-obj:01 compiler:01 readable:01 readable:01 compile:01 X-Attachments: cset="utf-8" name="vincent_gripon.vcf" name="vincent_gripon.vcf" This is a multi-part message in MIME format. --------------020201020709000603040500 Content-Type: multipart/alternative; boundary="------------040504050506030508030907" --------------040504050506030508030907 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello, We are currently planing to participate to a programming contest. This contest allows the use of four languages (C/C#/C++/java) but not OCaml. We would like to use Ocaml as it is to us the language that fits the most the kind of exercises proposed. The organizers don't mind if we use OCaml as long as we provide an easily compilable C source to them, even if it is not readable. Is there any platform independent way to compile OCaml sources to C sources? And if not, do you have any pointer (we gave a try at compiling OCaml sources to C object files using the -output-obj option but couldn't compile then the resulting file with our C compiler)? Best, Vincent --------------040504050506030508030907 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello,

We are currently planing to participate to a programming contest. This contest allows the use of four languages (C/C#/C++/java) but not OCaml.

We would like to use Ocaml as it is to us the language that fits the most the kind of exercises proposed. The organizers don't mind if we use OCaml as long as we provide an easily compilable C source to them, even if it is not readable.

Is there any platform independent way to compile OCaml sources to C sources?  And if not, do you have any pointer (we gave a try at compiling OCaml sources to C object files using the -output-obj option but couldn't compile then the resulting file with our C compiler)?

Best,

Vincent
--------------040504050506030508030907-- --------------020201020709000603040500 Content-Type: text/x-vcard; charset=utf-8; name="vincent_gripon.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vincent_gripon.vcf" begin:vcard fn:Vincent Gripon n:Gripon;Vincent org:Telecom Bretagne;Computer Science and Telecommunications adr:;;Telecom Bretagne - Technopole Brest Iroise;Brest Cedex 3;;29238;France email;internet:vincent.gripon@ens-cachan.org title:PhD Student tel;work:+0033 2 29 00 1586 url:http://perso.eleves.bretagne.ens-cachan.fr/~gripon version:2.1 end:vcard --------------020201020709000603040500-- 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 25E59BC58; Tue, 14 Sep 2010 14:16:49 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIAANcEj0zPLfmwkWdsb2JhbACBRZIIjgIVAQEBAQkLCgcRBhyoIJoShUAE X-IronPort-AV: E=Sophos;i="4.56,364,1280700000"; d="scan'208,217";a="57231886" Received: from parmail05.sgcib.com ([207.45.249.176]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Sep 2010 14:16:38 +0200 X-IronPort-AV: E=Sophos;i="4.56,364,1280700000"; d="scan'208,217";a="99202097" In-Reply-To: <4C8F660B.4060901@telecom-bretagne.eu> To: Vincent Gripon Subject: Re: [Caml-list] Compiling Ocaml sources to c sources [NC] MIME-Version: 1.0 Cc: caml-list@yquem.inria.fr, caml-list-bounces@yquem.inria.fr Message-ID: From: Rabih CHAAR Date: Tue, 14 Sep 2010 14:16:30 +0200 Content-Type: multipart/alternative; boundary="=_alternative 00436E01C125779E_=" X-Spam: no; 0.00; ocaml:01 ocaml:01 bytecode:01 -output-obj:01 bytecode:01 planing:01 compilable:01 pointer:01 -output-obj:01 compiler:01 beginner's:01 bug:01 planing:01 compilable:01 pointer:01 This is a multipart message in MIME format. --=_alternative 00436E01C125779E_= Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii" Hello, when compiling ocaml to bytecode with the -output-obj flag, a c file is created containing essentially the produced bytecode in a c array, which will be fed to caml via caml-startup functions. This doesn't relate to generating C source with a translation for your functional code in Ocaml. I don't have any knowledge of a tool that covers your need, but i am not an expert on these issues. Sincerely, Rabih Chaar Vincent Gripon Sent by: caml-list-bounces@yquem.inria.fr 14/09/10 02:09 PM To caml-list@yquem.inria.fr cc Subject [Caml-list] Compiling Ocaml sources to c sources Hello, We are currently planing to participate to a programming contest. This contest allows the use of four languages (C/C#/C++/java) but not OCaml. We would like to use Ocaml as it is to us the language that fits the most the kind of exercises proposed. The organizers don't mind if we use OCaml as long as we provide an easily compilable C source to them, even if it is not readable. Is there any platform independent way to compile OCaml sources to C sources? And if not, do you have any pointer (we gave a try at compiling OCaml sources to C object files using the -output-obj option but couldn't compile then the resulting file with our C compiler)? Best, Vincent[attachment "vincent_gripon.vcf" deleted by Rabih CHAAR/fr/socgen] _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs ************************************************************************* This message and any attachments (the "message") are confidential, intended solely for the addressee(s), and may contain legally privileged information. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. ************ Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes par le secret professionnel. Ce message est etabli a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. La SOCIETE GENERALE et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. ************************************************************************* --=_alternative 00436E01C125779E_= Content-Transfer-Encoding: 7bit Content-Type: text/html; charset="us-ascii"
Hello,
when compiling ocaml to bytecode with the -output-obj flag, a c file is created containing essentially the produced bytecode in a c array, which will be fed to caml via caml-startup functions.

This doesn't relate to generating C source with a translation for your functional code in Ocaml.

I don't have any knowledge of a tool that covers your need, but i am not an expert on these issues.

Sincerely,

Rabih Chaar


Vincent Gripon <vincent.gripon@telecom-bretagne.eu>
Sent by: caml-list-bounces@yquem.inria.fr

14/09/10 02:09 PM

To
caml-list@yquem.inria.fr
cc
Subject
[Caml-list] Compiling Ocaml sources to c sources





Hello,

We are currently planing to participate to a programming contest. This contest allows the use of four languages (C/C#/C++/java) but not OCaml.

We would like to use Ocaml as it is to us the language that fits the most the kind of exercises proposed. The organizers don't mind if we use OCaml as long as we provide an easily compilable C source to them, even if it is not readable.

Is there any platform independent way to compile OCaml sources to C sources?  And if not, do you have any pointer (we gave a try at compiling OCaml sources to C object files using the -output-obj option but couldn't compile then the resulting file with our C compiler)?

Best,

Vincent
[attachment "vincent_gripon.vcf" deleted by Rabih CHAAR/fr/socgen] _______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

*************************************************************************
This message and any attachments (the "message") are confidential, intended solely for the addressee(s), and may contain legally privileged information.
Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration.   
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or
falsified.
                              ************
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes 
par le secret professionnel. 
Ce message est etabli a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration. 
La SOCIETE GENERALE et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.
*************************************************************************
--=_alternative 00436E01C125779E_=-- 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 8CBADBC58 for ; Tue, 14 Sep 2010 14:35:40 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArEBAJYIj0zRVda0kGdsb2JhbAChRwgVAQEBAQkJDAcRAx+nU4tFhkmIZwEBAwWFOwSKJ4h7 X-IronPort-AV: E=Sophos;i="4.56,364,1280700000"; d="scan'208";a="59249076" Received: from mail-iw0-f180.google.com ([209.85.214.180]) by mail2-smtp-roc.national.inria.fr with ESMTP; 14 Sep 2010 14:35:39 +0200 Received: by iwn8 with SMTP id 8so8051985iwn.39 for ; Tue, 14 Sep 2010 05:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:cc:content-type; bh=8eirsg9jdSaYNlvpF8dEFRyhVm+cP+++Y2U6m8x2I/Q=; b=dE2O0jQ49xvati67n1ppPXHde5CYs+MuiFaMZiAY+2+TpSy3Btb1XfqX4fXxx53Jcr pComi1YVR1NMYD9R3b1ap2GP/5o9O4DHY2Szace7sRGiEfG5396INkN0jbN0PQ9o+Dev 7VKIVhz2YGQZJb+RYyc9aiIRwuYDtl5S4DQlk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; b=iVTtFh4T/ACa48si5Lkr2zEs5nVpHNr+YqR3wI6m+2h8spJmLrnR2jVCUCL8A4G75k nPLaEBqooHeMO0kQeFg1KXTTlElFZAuHcno4EAZKYoO02BAU3GUqinEaXAy6GBaEZiBq 0oBKpXAY4CXbv/uW3pQeU9MO2ZnsAjxb3BwHM= Received: by 10.231.79.77 with SMTP id o13mr8098910ibk.36.1284467739230; Tue, 14 Sep 2010 05:35:39 -0700 (PDT) MIME-Version: 1.0 Sender: david.mentre@gmail.com Received: by 10.231.113.85 with HTTP; Tue, 14 Sep 2010 05:35:09 -0700 (PDT) In-Reply-To: <4C8F660B.4060901@telecom-bretagne.eu> References: <4C8F660B.4060901@telecom-bretagne.eu> From: David MENTRE Date: Tue, 14 Sep 2010 14:35:09 +0200 X-Google-Sender-Auth: bqCdGvFmbM3qO1YNsZYYr8wlZq0 Message-ID: Subject: Re: [Caml-list] Compiling Ocaml sources to c sources To: Vincent Gripon Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; ocaml:01 ocaml:01 byte:01 byte:01 compile:01 compile:01 caml-list:01 compiling:02 vincent:07 vincent:07 interpreter:07 probably:07 structure:07 embedded:08 source:12 Hello, 2010/9/14 Vincent Gripon : > Is there any platform independent way to compile OCaml sources to C sources? Probably stupid answer: compile to byte code and provide the source code of the C OCaml byte code interpreter with the program embedded as C structure? Sincerely yours, david 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 53D7BBC58 for ; Tue, 14 Sep 2010 14:43:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAHAHYKj0w+BBBmc2dsb2JhbAChZAEMCgsHEQMfwk2FQASFG4UM X-IronPort-AV: E=Sophos;i="4.56,364,1280700000"; d="scan'208";a="67562340" Received: from smtp-102-tuesday.nerim.net (HELO kraid.nerim.net) ([62.4.16.102]) by mail1-smtp-roc.national.inria.fr with ESMTP; 14 Sep 2010 14:43:42 +0200 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by kraid.nerim.net (Postfix) with ESMTP id C5460CFF49; Tue, 14 Sep 2010 14:43:41 +0200 (CEST) Received: from basile18 by hector.lesours with local (Exim 4.72) (envelope-from ) id 1OvUrN-00037K-GJ; Tue, 14 Sep 2010 14:43:41 +0200 Date: Tue, 14 Sep 2010 14:43:41 +0200 From: Basile Starynkevitch To: Vincent Gripon , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiling Ocaml sources to c sources Message-ID: <20100914124341.GA11500@hector.lesours> References: <4C8F660B.4060901@telecom-bretagne.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C8F660B.4060901@telecom-bretagne.eu> User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam: no; 0.00; basile:01 basile:01 ocaml:01 0200,:01 planing:01 ocaml:01 compilable:01 runtime:01 runtime:01 non-trivial:01 recursion:01 bytecode:01 translating:01 byte:01 compiler:01 On Tue, Sep 14, 2010 at 02:09:47PM +0200, Vincent Gripon wrote: > Hello, > > We are currently planing to participate to a programming contest. It would be interesting for us to know more about that contest. > This contest allows the use of four languages (C/C#/C++/java) but > not OCaml. That does not mean much. What about libraries you are calling from C? In particular: * can you use any library? This seems strange (because the organizers very probably won't have the same libraries or versions as you have). * do you have any restrictions on the libraries you are using? * at the extreme case, the competition might require you to provide all the sources of every non standard (in the sense of ISO C standard) libraries you are using, and a verified mean to build them. What about POSIX system calls? > > We would like to use Ocaml as it is to us the language that fits the > most the kind of exercises proposed. The organizers don't mind if we > use OCaml as long as we provide an easily compilable C source to > them, even if it is not readable. > > Is there any platform independent way to compile OCaml sources to C > sources? I don't see any easy way to do that. There are several issues * the Ocaml runtime environment, which not only includes its garbage collector but also all the ocaml runtime library. * Hacking a C generator inside Ocaml is non-trivial, because of the garbage collector, currified function calls, and tail recursion etc. * If you really insist on coding in Ocaml and if you don't care much about performance, you could take my bit-rotten Ocamljit work (I forgot where you can find it, and I don't have it anymore, but google should help finding it) and make something which transform the entire bytecode of an Ocaml program into a gigantic single C function (translating straightforwardly every byte code into a small chunk of C code). This is not easy to do, and it might not be fun neither. Very probably, a C compiler would have pain to optimize such a big function (by personal experience, the GCC compiler usually take O(n^2) time to optimize with -O2 a sufficiently large function of size n, and may also need O(n^2) memory). And such an approach might not produce portable code (perhaps there are some issues w.r.t. 32 vs 64 bits systems). Actually, portable C is a fiction: only ported C programs can exist. Did you also consider using Scheme, it has several implementations generating C code (Chicken & Stalin come to mind). But still, programming in C does not mean much! What about portability? building? external libraries? linking other stuff? target system? If you have complete freedom on what you link with your program, you could hack a libocamlrun to be linkable, and link the bytecode as an array, as suggested previously. I would imagine that preparing stuff to make you code in Ocaml and fit into the contest rules is a big lot of work. Cheers. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} *** 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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id E8B70BC58 for ; Tue, 14 Sep 2010 14:47:08 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.56,364,1280700000"; d="scan'208";a="69489073" Received: from saorge.inria.fr (HELO [138.96.248.57]) ([138.96.248.57]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-CAMELLIA256-SHA; 14 Sep 2010 14:47:08 +0200 Subject: Re: [Caml-list] Compiling Ocaml sources to c sources From: Thomas Gazagnaire To: Vincent Gripon Cc: caml-list@yquem.inria.fr In-Reply-To: <4C8F660B.4060901@telecom-bretagne.eu> References: <4C8F660B.4060901@telecom-bretagne.eu> Content-Type: text/plain; charset="UTF-8" Date: Tue, 14 Sep 2010 14:47:08 +0200 Message-ID: <1284468428.2252.400.camel@saorge.inria.fr> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 bigloo:01 compiler:01 ocaml:01 syntax:01 functors:01 variants:01 cheers:01 www-sop:01 0200,:01 planing:01 compilable:01 pointer:01 -output-obj:01 compiler:01 Hi Vincent! you can try camloo [1] which compiles (old-syntax) caml-light to bigloo, which is a scheme to C compiler. I reckon it would be quite easy to update it to parse the ocaml syntax if you don't use functors/objects/variants/labels/thread (ie. if you use only what is available in caml-light). Cheers, Thomas [1] http://www-sop.inria.fr/members/Thomas.Gazagnaire/ On Tue, 2010-09-14 at 14:09 +0200, Vincent Gripon wrote: > Hello, > > We are currently planing to participate to a programming contest. This > contest allows the use of four languages (C/C#/C++/java) but not > OCaml. > > We would like to use Ocaml as it is to us the language that fits the > most the kind of exercises proposed. The organizers don't mind if we > use OCaml as long as we provide an easily compilable C source to them, > even if it is not readable. > > Is there any platform independent way to compile OCaml sources to C > sources? And if not, do you have any pointer (we gave a try at > compiling OCaml sources to C object files using the -output-obj option > but couldn't compile then the resulting file with our C compiler)? > > Best, > > Vincent > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs 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 9B32FBC58 for ; Tue, 14 Sep 2010 14:48:32 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIBAKgLj0zRVdi0imdsb2JhbACTTY16CBUBAQEKCQwHDwUfp0GLRYZPiGcBAQMFhTsEhEmFXoh7 X-IronPort-AV: E=Sophos;i="4.56,364,1280700000"; d="scan'208";a="67562932" Received: from mail-qy0-f180.google.com ([209.85.216.180]) by mail1-smtp-roc.national.inria.fr with ESMTP; 14 Sep 2010 14:48:32 +0200 Received: by qyk31 with SMTP id 31so8139695qyk.18 for ; Tue, 14 Sep 2010 05:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=lHWNwwHqVeFMkKSkpPEPWzof4913q6R7fBOQ+yz6Cig=; b=Z3yBlmab+0f8nSEBe3+c0jwmWhsaEOiijrr87seHh++4Ltmob+LaHoSrL02KU9Huxp 00MM6bqsUZsPMXz4sdVyh5QJSd50QoXYPxaq4iihnyv7DIefi6iJlZXvZ6h8MAQk32Es Wb5wsTWrSQycwwXaP0gqFu6u1IWw/jo2YMXKE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=GCbFW7oxoU4jOYN5ynSwg3w2yfGr395mFEAJYMl2/ratGVYQ6X9uGhdPc8psQ/Szb9 t70cxnSSeihd1PwnlMH/7109smRdXS5eCaWb21jAvGR1tg178/tO6ZI4Hs4M1sASQYQ4 tSCejNmvCPlhH5ofmFjNZGNMCghZl5x8mRLhQ= MIME-Version: 1.0 Received: by 10.224.130.77 with SMTP id r13mr1179948qas.163.1284468511239; Tue, 14 Sep 2010 05:48:31 -0700 (PDT) Sender: grettke@gmail.com Received: by 10.229.220.211 with HTTP; Tue, 14 Sep 2010 05:48:31 -0700 (PDT) In-Reply-To: <1284468428.2252.400.camel@saorge.inria.fr> References: <4C8F660B.4060901@telecom-bretagne.eu> <1284468428.2252.400.camel@saorge.inria.fr> Date: Tue, 14 Sep 2010 07:48:31 -0500 X-Google-Sender-Auth: A3r1IXnjXADtVYYrsrfDBc7meTE Message-ID: Subject: Re: [Caml-list] Compiling Ocaml sources to c sources From: Grant Rettke To: Thomas Gazagnaire Cc: Vincent Gripon , caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocaml:01 ocaml:01 bigloo:01 compiler:01 syntax:01 functors:01 variants:01 cheers:01 www-sop:01 0200,:01 planing:01 compilable:01 pointer:01 -output-obj:01 compiler:01 OCaml compiled by F# called by C#? On Tue, Sep 14, 2010 at 7:47 AM, Thomas Gazagnaire wrote: > Hi Vincent! > > you can try camloo [1] which compiles (old-syntax) caml-light to bigloo, > which is a scheme to C compiler. I reckon it would be quite easy to > update it to parse the ocaml syntax if you don't use > functors/objects/variants/labels/thread (ie. if you use only what is > available in caml-light). > > Cheers, > Thomas > > [1] http://www-sop.inria.fr/members/Thomas.Gazagnaire/ > > > On Tue, 2010-09-14 at 14:09 +0200, Vincent Gripon wrote: >> Hello, >> >> We are currently planing to participate to a programming contest. This >> contest allows the use of four languages (C/C#/C++/java) but not >> OCaml. >> >> We would like to use Ocaml as it is to us the language that fits the >> most the kind of exercises proposed. The organizers don't mind if we >> use OCaml as long as we provide an easily compilable C source to them, >> even if it is not readable. >> >> Is there any platform independent way to compile OCaml sources to C >> sources? =A0And if not, do you have any pointer (we gave a try at >> compiling OCaml sources to C object files using the -output-obj option >> but couldn't compile then the resulting file with our C compiler)? >> >> Best, >> >> Vincent >> _______________________________________________ >> Caml-list mailing list. Subscription management: >> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list >> Archives: http://caml.inria.fr >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --=20 http://www.wisdomandwonder.com/ ACM, AMA, COG, IEEE 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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 02923BC58 for ; Wed, 15 Sep 2010 14:58:41 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvkAAHtfkEzAbHMMmWdsb2JhbACDG55YFQEBAQEBCAsKBxEisDGSEoRNdASNKg X-IronPort-AV: E=Sophos;i="4.56,371,1280700000"; d="vcf'?scan'208";a="69568164" Received: from coliposte.enst-bretagne.fr ([192.108.115.12]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Sep 2010 14:58:41 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8FCwhg7015617; Wed, 15 Sep 2010 14:58:43 +0200 Received: from courrier.enst-bretagne.fr (smtps.enst-bretagne.fr [10.29.90.4]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8FCwRJg015572; Wed, 15 Sep 2010 14:58:30 +0200 Received: from [10.66.144.72] (pc-salsa-elec-072.ext.enst-bretagne.fr [10.66.144.72]) (user=vgripon mech=PLAIN bits=0) by courrier.enst-bretagne.fr (8.13.8/8.13.8/2010.02.22) with ESMTP id o8FCwOGe002164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 15 Sep 2010 14:58:24 +0200 Message-ID: <4C90C33A.8060800@telecom-bretagne.eu> Date: Wed, 15 Sep 2010 14:59:38 +0200 From: Vincent Gripon User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10pre) Gecko/20100914 Shredder/3.1.5pre MIME-Version: 1.0 To: Basile Starynkevitch Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiling Ocaml sources to c sources References: <4C8F660B.4060901@telecom-bretagne.eu> <20100914124341.GA11500@hector.lesours> In-Reply-To: <20100914124341.GA11500@hector.lesours> Content-Type: multipart/mixed; boundary="------------000709070008050202070802" X-Virus-Scanned: amavisd-new at enst-bretagne.fr X-Spam: no; 0.00; ocaml:01 basile:01 0200,:01 planing:01 ocaml:01 gcc:01 compilable:01 runtime:01 runtime:01 non-trivial:01 recursion:01 bytecode:01 translating:01 byte:01 compiler:01 X-Attachments: cset="utf-8" name="vincent_gripon.vcf" name="vincent_gripon.vcf" This is a multi-part message in MIME format. --------------000709070008050202070802 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Thanks for your answer, On 09/14/2010 02:43 PM, Basile Starynkevitch wrote: > On Tue, Sep 14, 2010 at 02:09:47PM +0200, Vincent Gripon wrote: >> Hello, >> >> We are currently planing to participate to a programming contest. > It would be interesting for us to know more about that contest. We are entering the IEEEXtreme programming competition ( http://www.ieee.org/membership_services/membership/students/competitions/xtreme/index.html ). >> This contest allows the use of four languages (C/C#/C++/java) but >> not OCaml. > That does not mean much. What about libraries you are calling from C? > > In particular: > > * can you use any library? This seems strange (because the > organizers very probably won't have the same libraries or versions > as you have). > > * do you have any restrictions on the libraries you are using? > > * at the extreme case, the competition might require you to provide > all the sources of every non standard (in the sense of ISO C > standard) libraries you are using, and a verified mean to build > them. What about POSIX system calls? There is very little information on these aspects, it looks like only the basic gcc compilers are available. The proposed exercises will probably not require any library or complicated system call, as it is more an algorithmic contest than system one. > >> We would like to use Ocaml as it is to us the language that fits the >> most the kind of exercises proposed. The organizers don't mind if we >> use OCaml as long as we provide an easily compilable C source to >> them, even if it is not readable. >> >> Is there any platform independent way to compile OCaml sources to C >> sources? > I don't see any easy way to do that. There are several issues > > * the Ocaml runtime environment, which not only includes its garbage > collector but also all the ocaml runtime library. > > * Hacking a C generator inside Ocaml is non-trivial, because of the > garbage collector, currified function calls, and tail recursion > etc. > > * If you really insist on coding in Ocaml and if you don't care much > about performance, you could take my bit-rotten Ocamljit work (I > forgot where you can find it, and I don't have it anymore, but > google should help finding it) and make something which transform > the entire bytecode of an Ocaml program into a gigantic single C > function (translating straightforwardly every byte code into a > small chunk of C code). This is not easy to do, and it might not > be fun neither. Very probably, a C compiler would have pain to > optimize such a big function (by personal experience, the GCC > compiler usually take O(n^2) time to optimize with -O2 a > sufficiently large function of size n, and may also need O(n^2) > memory). And such an approach might not produce portable code > (perhaps there are some issues w.r.t. 32 vs 64 bits > systems). Actually, portable C is a fiction: only ported C > programs can exist. We downloaded your software and it works perfectly well (with ocaml 3.09). It seems perfectly suited for the contest rules and we are planing to use it in this regard if it does not bother you. > > Did you also consider using Scheme, it has several implementations > generating C code (Chicken & Stalin come to mind). > > But still, programming in C does not mean much! What about > portability? building? external libraries? linking other stuff? target > system? > > If you have complete freedom on what you link with your program, you > could hack a libocamlrun to be linkable, and link the bytecode as an > array, as suggested previously. > > I would imagine that preparing stuff to make you code in Ocaml and fit > into the contest rules is a big lot of work. Thanks to your software, it should not be =) Cheers. --------------000709070008050202070802 Content-Type: text/x-vcard; charset=utf-8; name="vincent_gripon.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vincent_gripon.vcf" begin:vcard fn:Vincent Gripon n:Gripon;Vincent org:Telecom Bretagne;Computer Science and Telecommunications adr:;;Telecom Bretagne - Technopole Brest Iroise;Brest Cedex 3;;29238;France email;internet:vincent.gripon@ens-cachan.org title:PhD Student tel;work:+0033 2 29 00 1586 url:http://perso.eleves.bretagne.ens-cachan.fr/~gripon version:2.1 end:vcard --------------000709070008050202070802-- 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id A7FD7BC58 for ; Wed, 15 Sep 2010 15:03:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvkAAB5hkEzAbHMMmWdsb2JhbACDG5BMjgwVAQEBAQEICwoHESKwQ5IShE10BI0q X-IronPort-AV: E=Sophos;i="4.56,371,1280700000"; d="vcf'?scan'208";a="57314417" Received: from coliposte.enst-bretagne.fr ([192.108.115.12]) by mail3-smtp-sop.national.inria.fr with ESMTP; 15 Sep 2010 15:03:23 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8FD3Qn9017125; Wed, 15 Sep 2010 15:03:26 +0200 Received: from courrier.enst-bretagne.fr (smtps.enst-bretagne.fr [10.29.90.4]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8FD3Jug017085; Wed, 15 Sep 2010 15:03:22 +0200 Received: from [10.66.144.72] (pc-salsa-elec-072.ext.enst-bretagne.fr [10.66.144.72]) (user=vgripon mech=PLAIN bits=0) by courrier.enst-bretagne.fr (8.13.8/8.13.8/2010.02.22) with ESMTP id o8FD3GKZ004389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 15 Sep 2010 15:03:16 +0200 Message-ID: <4C90C45E.70308@telecom-bretagne.eu> Date: Wed, 15 Sep 2010 15:04:30 +0200 From: Vincent Gripon User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10pre) Gecko/20100914 Shredder/3.1.5pre MIME-Version: 1.0 To: Thomas Gazagnaire Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiling Ocaml sources to c sources References: <4C8F660B.4060901@telecom-bretagne.eu> <1284468428.2252.400.camel@saorge.inria.fr> In-Reply-To: <1284468428.2252.400.camel@saorge.inria.fr> Content-Type: multipart/mixed; boundary="------------020200000302030307030201" X-Virus-Scanned: amavisd-new at enst-bretagne.fr X-Spam: no; 0.00; ocaml:01 ocaml:01 syntax:01 planing:01 cheers:01 bigloo:01 compiler:01 syntax:01 functors:01 variants:01 cheers:01 www-sop:01 0200,:01 planing:01 compilable:01 X-Attachments: cset="UTF-8" cset="utf-8" name="vincent_gripon.vcf" name="vincent_gripon.vcf" This is a multi-part message in MIME format. --------------020200000302030307030201 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Thomas, Basile's suggestion allows us to use the whole OCaml syntax with no real need for coding. That's why we are planing to use it. Thank you for your solution. Cheers! On 09/14/2010 02:47 PM, Thomas Gazagnaire wrote: > Hi Vincent! > > you can try camloo [1] which compiles (old-syntax) caml-light to bigloo, > which is a scheme to C compiler. I reckon it would be quite easy to > update it to parse the ocaml syntax if you don't use > functors/objects/variants/labels/thread (ie. if you use only what is > available in caml-light). > > Cheers, > Thomas > > [1] http://www-sop.inria.fr/members/Thomas.Gazagnaire/ > > > On Tue, 2010-09-14 at 14:09 +0200, Vincent Gripon wrote: >> Hello, >> >> We are currently planing to participate to a programming contest. This >> contest allows the use of four languages (C/C#/C++/java) but not >> OCaml. >> >> We would like to use Ocaml as it is to us the language that fits the >> most the kind of exercises proposed. The organizers don't mind if we >> use OCaml as long as we provide an easily compilable C source to them, >> even if it is not readable. >> >> Is there any platform independent way to compile OCaml sources to C >> sources? And if not, do you have any pointer (we gave a try at >> compiling OCaml sources to C object files using the -output-obj option >> but couldn't compile then the resulting file with our C compiler)? >> >> Best, >> >> Vincent >> _______________________________________________ >> Caml-list mailing list. Subscription management: >> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list >> Archives: http://caml.inria.fr >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs > --------------020200000302030307030201 Content-Type: text/x-vcard; charset=utf-8; name="vincent_gripon.vcf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="vincent_gripon.vcf" YmVnaW46dmNhcmQNCmZuOlZpbmNlbnQgR3JpcG9uDQpuOkdyaXBvbjtWaW5jZW50DQpvcmc6 VGVsZWNvbSBCcmV0YWduZTtDb21wdXRlciBTY2llbmNlIGFuZCBUZWxlY29tbXVuaWNhdGlv bnMNCmFkcjo7O1RlbGVjb20gQnJldGFnbmUgLSBUZWNobm9wb2xlIEJyZXN0IElyb2lzZTtC cmVzdCBDZWRleCAzOzsyOTIzODtGcmFuY2UNCmVtYWlsO2ludGVybmV0OnZpbmNlbnQuZ3Jp cG9uQGVucy1jYWNoYW4ub3JnDQp0aXRsZTpQaEQgU3R1ZGVudA0KdGVsO3dvcms6KzAwMzMg MiAyOSAwMCAxNTg2DQp1cmw6aHR0cDovL3BlcnNvLmVsZXZlcy5icmV0YWduZS5lbnMtY2Fj aGFuLmZyL35ncmlwb24NCnZlcnNpb246Mi4xDQplbmQ6dmNhcmQNCg0K --------------020200000302030307030201-- 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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 82D8CBC58 for ; Wed, 15 Sep 2010 15:17:44 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvkAADVkkEzAbHMMmWdsb2JhbACDG55YFQEBAQEBCAsKBxEisFeSD4RNdASNKg X-IronPort-AV: E=Sophos;i="4.56,371,1280700000"; d="vcf'?scan'208";a="69569478" Received: from coliposte.enst-bretagne.fr ([192.108.115.12]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Sep 2010 15:17:44 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8FDHfOk021487; Wed, 15 Sep 2010 15:17:41 +0200 Received: from courrier.enst-bretagne.fr (smtps.enst-bretagne.fr [10.29.90.4]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8FDHR5X021445; Wed, 15 Sep 2010 15:17:31 +0200 Received: from [10.66.144.72] (pc-salsa-elec-072.ext.enst-bretagne.fr [10.66.144.72]) (user=vgripon mech=PLAIN bits=0) by courrier.enst-bretagne.fr (8.13.8/8.13.8/2010.02.22) with ESMTP id o8FDHO9a010758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 15 Sep 2010 15:17:24 +0200 Message-ID: <4C90C7AF.2010902@telecom-bretagne.eu> Date: Wed, 15 Sep 2010 15:18:39 +0200 From: Vincent Gripon User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10pre) Gecko/20100914 Shredder/3.1.5pre MIME-Version: 1.0 To: David MENTRE Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiling Ocaml sources to c sources References: <4C8F660B.4060901@telecom-bretagne.eu> In-Reply-To: Content-Type: multipart/mixed; boundary="------------020802010400090504010805" X-Virus-Scanned: amavisd-new at enst-bretagne.fr X-Spam: no; 0.00; ocaml:01 basile:01 compilation:01 cheers:01 ocaml:01 byte:01 byte:01 wrote:01 compile:01 compile:01 caml-list:01 compiling:02 constraints:03 multi-part:94 preferable:06 X-Attachments: cset="utf-8" name="vincent_gripon.vcf" name="vincent_gripon.vcf" This is a multi-part message in MIME format. --------------020802010400090504010805 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello David, This is a good idea. Basile made a just in time implementation which is preferable to us as we do not know if the contest has time constraints on the compilation of submitted sources. Thank you for your answer. Cheers. On 09/14/2010 02:35 PM, David MENTRE wrote: > Hello, > > 2010/9/14 Vincent Gripon: >> Is there any platform independent way to compile OCaml sources to C sources? > Probably stupid answer: compile to byte code and provide the source > code of the C OCaml byte code interpreter with the program embedded as > C structure? > > Sincerely yours, > david > --------------020802010400090504010805 Content-Type: text/x-vcard; charset=utf-8; name="vincent_gripon.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vincent_gripon.vcf" begin:vcard fn:Vincent Gripon n:Gripon;Vincent org:Telecom Bretagne;Computer Science and Telecommunications adr:;;Telecom Bretagne - Technopole Brest Iroise;Brest Cedex 3;;29238;France email;internet:vincent.gripon@ens-cachan.org title:PhD Student tel;work:+0033 2 29 00 1586 url:http://perso.eleves.bretagne.ens-cachan.fr/~gripon version:2.1 end:vcard --------------020802010400090504010805-- 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 1D087BC58 for ; Wed, 15 Sep 2010 19:37:34 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYBAJKhkExKfVK0kGdsb2JhbACVLYwyCBUBAQEBCQkMBxEDH6sXi0YBBY9KAQSFQQ X-IronPort-AV: E=Sophos;i="4.56,371,1280700000"; d="scan'208";a="57330351" Received: from mail-wy0-f180.google.com ([74.125.82.180]) by mail3-smtp-sop.national.inria.fr with ESMTP; 15 Sep 2010 19:37:33 +0200 Received: by wyb40 with SMTP id 40so281817wyb.39 for ; Wed, 15 Sep 2010 10:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:references :in-reply-to:subject:date:organization:message-id:mime-version :content-type:content-transfer-encoding:x-mailer:thread-index :content-language; bh=pJV68UwRTU4HQ7/nr1CBMfi3hWNHVDvayDlgWYZddno=; b=F6r+k6g8E8coww8CK089hVD+GxeeiJB+9uTKm3ku/I6QERVMqWqZBe1pkFwRNldu3X HljuOlJFHw7VzVqPMmjZxTLtJgbIK/4zwLQbzRDbeM6lLrAjW5N8cSUhqgvb1DH2yN2s HFgRhpo8gNPA/VtTTNMGsk97Fsqx5404NP720= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:references:in-reply-to:subject:date:organization:message-id :mime-version:content-type:content-transfer-encoding:x-mailer :thread-index:content-language; b=bIK5UOuifsQKgsNj3qY2PNswwkEY4EeiRzFOGK5fx8KMgq4rSjv9MXNNR72P8mLEJJ DD3RFyVnhwmBAgF0rV2Lu13ib+vkMXtu1OzeygJouv8oN28zPFtKrVspxKYXx4Q/sVj6 h4dz1TN2vk+BGM7ggbLmpdfdnzs0usnvV6i3g= Received: by 10.216.186.207 with SMTP id w57mr5596851wem.19.1284572253590; Wed, 15 Sep 2010 10:37:33 -0700 (PDT) Received: from WinEight ([87.115.152.182]) by mx.google.com with ESMTPS id k83sm1162863weq.14.2010.09.15.10.37.30 (version=SSLv3 cipher=RC4-MD5); Wed, 15 Sep 2010 10:37:31 -0700 (PDT) From: Jon Harrop To: "'Basile Starynkevitch'" , "'Vincent Gripon'" , References: <4C8F660B.4060901@telecom-bretagne.eu> <20100914124341.GA11500@hector.lesours> In-Reply-To: <20100914124341.GA11500@hector.lesours> Subject: RE: [Caml-list] Compiling Ocaml sources to c sources Date: Wed, 15 Sep 2010 18:36:59 +0100 Organization: Flying Frog Consultancy Message-ID: <004b01cb54fc$9c435020$d4c9f060$@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: ActUCo/ZkV2w+/70TgmZJQIW1yqnXwA8cX0Q Content-Language: en-gb X-Spam: no; 0.00; ocaml:01 ocaml:01 non-trivial:01 recursion:01 bytecode:01 compiler:01 bytecode:01 compilation:01 cheers:01 garbage:01 caml-list:01 tail:01 compiling:02 native:03 btw:03 > * Hacking a C generator inside Ocaml is non-trivial, because of the > garbage collector, currified function calls, and tail recursion > etc. BTW, I was always surprised nobody had converted the bytecode interpreter into a via-C compiler by unwinding the C code the interpreter goes through to execute a specific OCaml bytecode program. You could even use this with something like Clang to get JIT compilation to native code. Not very efficient but surely much faster than interpreted bytecode... Cheers, Jon. 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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id C93AFBC59 for ; Wed, 15 Sep 2010 20:17:16 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnMBAHqqkEzRVda0kGdsb2JhbACTX4V9AYgGCBUBAQEBCQkMBxEDH6tFiTKCFIZQLYhUAQEDBYU8BIRFhWc X-IronPort-AV: E=Sophos;i="4.56,372,1280700000"; d="scan'208";a="69586159" Received: from mail-iw0-f180.google.com ([209.85.214.180]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Sep 2010 20:17:16 +0200 Received: by iwn8 with SMTP id 8so464943iwn.39 for ; Wed, 15 Sep 2010 11:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=WugLqQMSiad4xmt71bxN14CMScmW7wifonk4R/VGfkc=; b=Jjp/tlJih1zb8Nt/x24Er5OZg6HSynfmM8lQmPa0+fLiKe76jQOSxiyZaWP244+IaL 2b3s6pVJ1jLeaLJLc1Zjlrb49NQtb3EGXRWHA+f65qiT4Dhg1GTo3jFHu3svH3+fUpb1 naj4EgEdhyJkoW0YnZC3+irdhq/e2ekhezmCk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=G9tknz8jzHECVnmHJOf32xV4GMPDE/V7hjGGpNhJ35VG86Cpz+ldu7F68SF7d1hmpr UerKeKwDQnnfY+dP2nvFhn6EIwGXU1EzQL2XLprKYO4ryt9z/q0our0LUqTs04o7/huo qL9tck2thdjOKga9tLde9iBZ347ieQkpuyq9c= MIME-Version: 1.0 Received: by 10.231.182.204 with SMTP id cd12mr2133101ibb.101.1284574634766; Wed, 15 Sep 2010 11:17:14 -0700 (PDT) Received: by 10.231.159.131 with HTTP; Wed, 15 Sep 2010 11:17:14 -0700 (PDT) In-Reply-To: <004b01cb54fc$9c435020$d4c9f060$@com> References: <4C8F660B.4060901@telecom-bretagne.eu> <20100914124341.GA11500@hector.lesours> <004b01cb54fc$9c435020$d4c9f060$@com> Date: Wed, 15 Sep 2010 21:17:14 +0300 Message-ID: Subject: Re: [Caml-list] Compiling Ocaml sources to c sources From: Eray Ozkural To: Jon Harrop Cc: Basile Starynkevitch , Vincent Gripon , caml-list@yquem.inria.fr Content-Type: multipart/alternative; boundary=0016363b8f64cb0a140490505642 X-Spam: no; 0.00; ocaml:01 eray:01 ozkural:01 ocaml:01 non-trivial:01 recursion:01 bytecode:01 compiler:01 bytecode:01 compilation:01 real-world:01 speedup:01 compilation:01 eray:01 ozkural:01 --0016363b8f64cb0a140490505642 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Sep 15, 2010 at 8:36 PM, Jon Harrop < jonathandeanharrop@googlemail.com> wrote: > > * Hacking a C generator inside Ocaml is non-trivial, because of the > > garbage collector, currified function calls, and tail recursion > > etc. > > BTW, I was always surprised nobody had converted the bytecode interpreter > into a via-C compiler by unwinding the C code the interpreter goes through > to execute a specific OCaml bytecode program. You could even use this with > something like Clang to get JIT compilation to native code. Not very > efficient but surely much faster than interpreted bytecode... > Hmm, this would only optimize the bytecode fetch/decode step of the ocaml execution cycle. I am not sure that it will result in much real-world speedup. In fact, that seems to be the main problem with many of these so-called JIT interpreters, which in my opinion, do not seem to have learnt from the HAL architectures of IBM OS's etc. Was probably also the problem with Transmeta; cheap compilation entails cheap performance. Best, -- Eray Ozkural, PhD candidate. Comp. Sci. Dept., Bilkent University, Ankara http://groups.yahoo.com/group/ai-philosophy http://myspace.com/arizanesil http://myspace.com/malfunct --0016363b8f64cb0a140490505642 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Wed, Sep 15, 2010 at 8:36 PM, Jon Harrop <jona= thandeanharrop@googlemail.com> wrote:
> =A0 * Hacking a C generator inside Ocaml is non-triv= ial, because of the
> =A0 =A0 garbage collector, currified function calls, and tail recursio= n
> =A0 =A0 etc.

BTW, I was always surprised nobody had converted the bytecode interpr= eter
into a via-C compiler by unwinding the C code the interpreter goes through<= br> to execute a specific OCaml bytecode program. You could even use this with<= br> something like Clang to get JIT compilation to native code. Not very
efficient but surely much faster than interpreted bytecode...

Hmm, this would only optimize the bytecode fetch/dec= ode step of the ocaml execution cycle. I am not sure that it will result in= much real-world speedup.

In fact, that seems to be the main problem with many of= these so-called JIT interpreters, which in my opinion, do not seem to have= learnt from the HAL architectures of IBM OS's etc. Was probably also t= he problem with Transmeta; cheap compilation entails cheap performance.

Best,

--
Eray Ozkural, Ph= D candidate.=A0 Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/= ai-philosophy
http://myspace.com/arizanesil= http://myspace.com/malfunct
--0016363b8f64cb0a140490505642-- 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id EECCFBC58 for ; Wed, 15 Sep 2010 21:55:49 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhYBAHPBkEw+BBBnlGdsb2JhbACiAwEBAQEJCwgJEQMfx14NgnYIgjYEhRw X-IronPort-AV: E=Sophos;i="4.56,372,1280700000"; d="scan'208";a="59338939" Received: from smtp-103-wednesday.nerim.net (HELO kraid.nerim.net) ([62.4.16.103]) by mail2-smtp-roc.national.inria.fr with ESMTP; 15 Sep 2010 21:55:49 +0200 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by kraid.nerim.net (Postfix) with ESMTP id 2B3F0CF0C8; Wed, 15 Sep 2010 21:55:49 +0200 (CEST) Received: from glinka.lesours ([192.168.0.1] helo=glinka) by hector.lesours with smtp (Exim 4.72) (envelope-from ) id 1Ovy56-0001wy-SB; Wed, 15 Sep 2010 21:55:48 +0200 Date: Wed, 15 Sep 2010 21:57:03 +0200 From: Basile Starynkevitch To: Vincent Gripon Cc: Thomas Gazagnaire , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiling Ocaml sources to c sources Message-Id: <20100915215703.d52b3875.basile@starynkevitch.net> In-Reply-To: <4C90C45E.70308@telecom-bretagne.eu> References: <4C8F660B.4060901@telecom-bretagne.eu> <1284468428.2252.400.camel@saorge.inria.fr> <4C90C45E.70308@telecom-bretagne.eu> X-Mailer: Sylpheed 3.1.0beta2 (GTK+ 2.21.7; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; basile:01 basile:01 ocaml:01 ocaml:01 syntax:01 planing:01 interp:01 trivial:01 syntax:01 cheers:01 faiencerie:01 92340:01 reine:01 wrote:01 wrote:01 On Wed, 15 Sep 2010 15:04:30 +0200 Vincent Gripon wrote: > Hi Thomas, > > Basile's suggestion allows us to use the whole OCaml syntax with no real > need for coding. That's why we are planing to use it. > Thank you for your solution. I am not sure to follow what you call "Basile's suggestion" exactly. If it is ocamljitrun.c it is just a tiny improvement over interp.c from ocaml distribution. Of course you don't need my permission to use ocamljitrun.c provided you respect its licence and its copyright owner (which is INRIA, which was my employer at the time I wrote it). And after glancing quickly at http://www.ieee.org/membership_services/membership/students/competitions/xtreme/index.html I was not able to easily find mention of a fixed set of languages like C, C#, Java, C++. However, perhaps in reality, your question becomes: what is source code in the eyes of an expert (the human jury of your competition). This don't have any easy or trivial answer. Maybe your answer should take into account the preference of the jury. The definition I usually like the most is that source code is the form of code which is preferred by the programmer (I think it is a GNU definition, or perhaps an FSF one). But again, this could be subject to interpretation, and lawyers or programmers have different views on it. And different programmers have different preferences (just think about the role of comments; there are probably important in your competition, but they don't mean anything to Ocaml.). Source code is not necessarily even a textual file (but in Ocaml or C it usually is; however I could be very pedantic and claim that source code for me is the code picture with syntax hightlighting and colors -as provided by my favorite editor's setting.). Likewise, I am not able to give a precise definition of what a text is (are two different translations or editions of the Bible the same text?). There used to be systems where source code was not textual. Long long time ago, at IRIA (the predecessor of INRIA) there used to be systems like Centaur... I also remember having a read a paper about Galaxy and hypertext programming (forgot the references). Good luck for the competition. Cheers. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} *** 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 91E30BC58 for ; Wed, 15 Sep 2010 21:58:35 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AssAAKfCkEzCT4aZnGdsb2JhbACiAwEBAQEBCAsICREix2UNhTQEhRw X-IronPort-AV: E=Sophos;i="4.56,372,1280700000"; d="scan'208";a="59339096" Received: from smtp-153-wednesday.nerim.net (HELO maiev.nerim.net) ([194.79.134.153]) by mail2-smtp-roc.national.inria.fr with ESMTP; 15 Sep 2010 21:58:34 +0200 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by maiev.nerim.net (Postfix) with ESMTP id 3ABF52E012; Wed, 15 Sep 2010 21:58:34 +0200 (CEST) Received: from glinka.lesours ([192.168.0.1] helo=glinka) by hector.lesours with smtp (Exim 4.72) (envelope-from ) id 1Ovy7m-0001xv-1V; Wed, 15 Sep 2010 21:58:34 +0200 Date: Wed, 15 Sep 2010 21:59:48 +0200 From: Basile Starynkevitch To: Vincent Gripon Cc: David MENTRE , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiling Ocaml sources to c sources Message-Id: <20100915215948.9ad55a04.basile@starynkevitch.net> In-Reply-To: <4C90C7AF.2010902@telecom-bretagne.eu> References: <4C8F660B.4060901@telecom-bretagne.eu> <4C90C7AF.2010902@telecom-bretagne.eu> X-Mailer: Sylpheed 3.1.0beta2 (GTK+ 2.21.7; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; basile:01 basile:01 ocaml:01 compilation:01 ocaml:01 ocamlc:01 ocamlopt:01 gcc:01 cheers:01 faiencerie:01 92340:01 reine:01 wrote:01 compiles:01 caml-list:01 On Wed, 15 Sep 2010 15:18:39 +0200 Vincent Gripon wrote: > Hello David, > > This is a good idea. Basile made a just in time implementation which is > preferable to us as we do not know if the contest has time constraints > on the compilation of submitted sources. But my ocamljitrun.c still needs your ocaml sources to be compiled by ocamlc. And you could use ocaml instead. And ocamlopt compiles source code quite quickly in practice (faster that gcc is handling source code compiled with -O2). Did you ask the contest organizer if ocaml is a valid language? Cheers. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} *** 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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id A46EEBC58 for ; Wed, 15 Sep 2010 22:37:48 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYBAErLkExKfVK0kGdsb2JhbACVNIwyCBUBAQEBCQkMBxEDH6xai0YBBY9NAQSFQQ X-IronPort-AV: E=Sophos;i="4.56,372,1280700000"; d="scan'208";a="69589874" Received: from mail-wy0-f180.google.com ([74.125.82.180]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Sep 2010 22:37:48 +0200 Received: by wyb40 with SMTP id 40so552125wyb.39 for ; Wed, 15 Sep 2010 13:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:references :in-reply-to:subject:date:organization:message-id:mime-version :content-type:content-transfer-encoding:x-mailer:thread-index :content-language; bh=/d8KvGR+00pJiJud5OhJE4McWUPqZl5KOb0F3i1Ni6o=; b=iP9b4Dr2cydH0LSBVJZUoREoORs7lKQlwbFZz3CSpY7z6SQdu7ekZlg/bKxr3Hbxph vQ6mtqlgMyboir7bolnfIO6PRc9o/I1ISEMHk+R0lloDAdhCXZqR1AP9asjekoh+K7M8 euk1mHAo0cC1I+gX0cj+vfckoMVErWKFjShVU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:references:in-reply-to:subject:date:organization :message-id:mime-version:content-type:content-transfer-encoding :x-mailer:thread-index:content-language; b=XUq5+HliS6NhUN1GBuEPKaLbTp0t8gHEgeRW7GgUCICX+XcdKTBS/mGuyMHFZZnywZ udY8SrbKO2ERx/GI4jLdDd+dbO0otqHjOUxa1wa41/ZHg6bvQd/dhqnaq4TiJhBCIs0N wa3ezlCLsk19OdrtLnFGMcT701TtfdnIb2jz4= Received: by 10.227.69.134 with SMTP id z6mr1778751wbi.201.1284583067488; Wed, 15 Sep 2010 13:37:47 -0700 (PDT) Received: from WinEight ([87.115.152.182]) by mx.google.com with ESMTPS id b23sm1602790wbb.16.2010.09.15.13.37.44 (version=SSLv3 cipher=RC4-MD5); Wed, 15 Sep 2010 13:37:46 -0700 (PDT) From: Jon Harrop To: "'Eray Ozkural'" , "'Jon Harrop'" Cc: "'Basile Starynkevitch'" , "'Vincent Gripon'" , References: <4C8F660B.4060901@telecom-bretagne.eu> <20100914124341.GA11500@hector.lesours> <004b01cb54fc$9c435020$d4c9f060$@com> In-Reply-To: Subject: RE: [Caml-list] Compiling Ocaml sources to c sources Date: Wed, 15 Sep 2010 21:37:05 +0100 Organization: Flying Frog Consultancy Message-ID: <006a01cb5515$c9c42420$5d4c6c60$@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: ActVAjlPuIgFb/92QceJxAuxkEe8NwAD4SDQ Content-Language: en-gb X-Spam: no; 0.00; ocaml:01 bytecode:01 ocaml:01 real-world:01 speedup:01 compiler:01 compilation:01 cheers:01 caml-list:01 transmeta:01 data:02 compiling:02 seems:03 hmm:04 problem:05 > Hmm, this would only optimize the bytecode fetch/decode step of the ocaml execution cycle. I am not sure that it will result in much real-world speedup. Would be interesting to try. I suspect the C compiler would then optimize the sequences of operations on the data as well. For example, something like vector addition. > In fact, that seems to be the main problem with many of these so-called JIT interpreters, which in my opinion, do not seem to have learnt from the HAL architectures of IBM OS's etc. Was probably also the problem with Transmeta; cheap compilation entails cheap performance. Can you elaborate? Cheers, Jon. 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id EB74CBC59 for ; Thu, 16 Sep 2010 00:17:00 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al0BADPjkEzAbHMMmWdsb2JhbACDG55YFQEBAQEBCAsKBxEitQCSOIRNdASNKg X-IronPort-AV: E=Sophos;i="4.56,373,1280700000"; d="vcf'?scan'208";a="57337940" Received: from coliposte.enst-bretagne.fr ([192.108.115.12]) by mail3-smtp-sop.national.inria.fr with ESMTP; 16 Sep 2010 00:17:00 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8FMGx3v012610; Thu, 16 Sep 2010 00:16:59 +0200 Received: from courrier.enst-bretagne.fr (smtps.enst-bretagne.fr [10.29.90.4]) by coliposte.enst-bretagne.fr (8.13.7/8.13.7/2009.11.10) with ESMTP id o8FMGsOg012600; Thu, 16 Sep 2010 00:16:58 +0200 Received: from [192.168.0.26] (passerelle-interne.enst-bretagne.fr [192.108.117.210]) (user=vgripon mech=PLAIN bits=0) by courrier.enst-bretagne.fr (8.13.8/8.13.8/2010.02.22) with ESMTP id o8FMGiEq009108; Thu, 16 Sep 2010 00:16:49 +0200 Message-ID: <4C9145CC.4010809@telecom-bretagne.eu> Date: Thu, 16 Sep 2010 00:16:44 +0200 From: Vincent Gripon User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.10pre) Gecko/20100910 Shredder/3.1.4pre MIME-Version: 1.0 To: Basile Starynkevitch Cc: David MENTRE , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiling Ocaml sources to c sources References: <4C8F660B.4060901@telecom-bretagne.eu> <4C90C7AF.2010902@telecom-bretagne.eu> <20100915215948.9ad55a04.basile@starynkevitch.net> In-Reply-To: <20100915215948.9ad55a04.basile@starynkevitch.net> Content-Type: multipart/mixed; boundary="------------020403090307080607040805" X-Virus-Scanned: amavisd-new at enst-bretagne.fr X-Spam: no; 0.00; ocaml:01 ocaml:01 ocamlc:01 ocamlopt:01 gcc:01 compiler:01 cheers:01 compile:01 compile:01 compiles:01 caml-list:01 compiling:02 compiling:02 functional:02 classical:03 X-Attachments: cset="utf-8" name="vincent_gripon.vcf" name="vincent_gripon.vcf" This is a multi-part message in MIME format. --------------020403090307080607040805 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > But my ocamljitrun.c still needs your ocaml sources to be compiled by > ocamlc. And you could use ocaml instead. It appears to us simpler (but maybe it is not?) to compile and provide the ocamljit implementation than the ocaml classical interpreter. > And ocamlopt compiles source code quite quickly in practice (faster > that gcc is handling source code compiled with -O2). I was more concerned about the time to compile the compiler than the time for it to compile our sources. > Did you ask the contest organizer if ocaml is a valid language? It is hard to find this information on the website but only four languages are allowed: C/C++/C# and java. We emailed the organizers explaining that functional languages should also be proposed in the contest, and asked them whether it would be accepted to provide them with a C source code likely hard to read but compiling with minimal prerequisites and executing our program. As long as we accept to provide them with the original source code if they ask it, they find no objection to it. Hopefully if we manage to reach a high rank they will consider adding OCaml for next year contest ;) Cheers, Vincent. --------------020403090307080607040805 Content-Type: text/x-vcard; charset=utf-8; name="vincent_gripon.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vincent_gripon.vcf" begin:vcard fn:Vincent Gripon n:Gripon;Vincent org:Telecom Bretagne;Computer Science and Telecommunications adr:;;Telecom Bretagne - Technopole Brest Iroise;Brest Cedex 3;;29238;France email;internet:vincent.gripon@ens-cachan.org title:PhD Student tel;work:+0033 2 29 00 1586 url:http://perso.eleves.bretagne.ens-cachan.fr/~gripon version:2.1 end:vcard --------------020403090307080607040805-- 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 741F4BC58 for ; Thu, 16 Sep 2010 02:38:57 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEBAAIEkUzRVda0kGdsb2JhbACTZIV/AYgICBUBAQEBCQkMBxEDH6wkiTeCFIZ0LYhUAQEDBYU8BIRFhWc X-IronPort-AV: E=Sophos;i="4.56,373,1280700000"; d="scan'208";a="57340409" Received: from mail-iw0-f180.google.com ([209.85.214.180]) by mail3-smtp-sop.national.inria.fr with ESMTP; 16 Sep 2010 02:38:56 +0200 Received: by iwn8 with SMTP id 8so813818iwn.39 for ; Wed, 15 Sep 2010 17:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=hcl0/x4TG4QkEJ24+HAqku23/9+SJVTxVHc/3vCcWyY=; b=ZqRF2AFbfMTuPTJo9uymojsYbjFLy108H9uxPn9x9aWOYHIbpcXaS7vf96xtu1xGdZ EkRNS8RFzeuqbP5NiSAhSANd3n2J23kHxjeK59KAiT9iFXbUbffrfSys930cweYa6A4F tfNQQh5anTPTWgFE9/tcgxIR2hcB6QL2oO1DY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=mPlCYpNU01hBLml1iYBdWeaGL8RM/CZ9mArqtvOpbAuPE1+/imfk2Vu02sfkfDvhTg C9QEQmwWHi4ApazieW3gdubRevyvAobQlWmG23kun5Js4IY5LuuKxcpBSNhHMTN+ReHz W1/L09PLJgOWuOGAzCwKR8STfiradJgkfJ8ag= MIME-Version: 1.0 Received: by 10.231.193.135 with SMTP id du7mr1976089ibb.176.1284597535687; Wed, 15 Sep 2010 17:38:55 -0700 (PDT) Received: by 10.231.159.131 with HTTP; Wed, 15 Sep 2010 17:38:55 -0700 (PDT) In-Reply-To: <006a01cb5515$c9c42420$5d4c6c60$@com> References: <4C8F660B.4060901@telecom-bretagne.eu> <20100914124341.GA11500@hector.lesours> <004b01cb54fc$9c435020$d4c9f060$@com> <006a01cb5515$c9c42420$5d4c6c60$@com> Date: Thu, 16 Sep 2010 03:38:55 +0300 Message-ID: Subject: Re: [Caml-list] Compiling Ocaml sources to c sources From: Eray Ozkural To: Jon Harrop Cc: Basile Starynkevitch , Vincent Gripon , caml-list@yquem.inria.fr Content-Type: multipart/alternative; boundary=005045017519cb4a83049055ab3a X-Spam: no; 0.00; ocaml:01 eray:01 ozkural:01 bytecode:01 ocaml:01 real-world:01 speedup:01 compiler:01 compilation:01 compiler:01 abstraction:01 eray:01 ozkural:01 bilkent:01 bytecode:01 --005045017519cb4a83049055ab3a Content-Type: text/plain; charset=ISO-8859-1 On Wed, Sep 15, 2010 at 11:37 PM, Jon Harrop < jonathandeanharrop@googlemail.com> wrote: > > Hmm, this would only optimize the bytecode fetch/decode step of the ocaml > execution cycle. I am not sure that it will result in much real-world > speedup. > > Would be interesting to try. I suspect the C compiler would then optimize > the sequences of operations on the data as well. For example, something > like > vector addition. > > > In fact, that seems to be the main problem with many of these so-called > JIT interpreters, which in my opinion, do not seem to have learnt from the > HAL architectures of IBM OS's etc. Was probably also the problem with > Transmeta; cheap compilation entails cheap performance. > > Can you elaborate? > > Well, what I would do is to apply a fully optimizing compiler from a proper hardware abstraction layer, whether it is JIT is irrelevant, but I do not see why the system would not start doing this as soon as the code is loaded in some place (and not when it starts to run). What is certain is that some simple transformation will not speed things up much. The right way to do it is to determine hot blocks beforehand. Hot blocks can also be determined on the fly but I do not think that JIT is much needed. The time of the determination of hot blocks is most certainly not crucial to optimizations, although the more time compiler has, the better. Simple optimizations will not have much impact. It is not like you can undo the complexity of an optimizing compiler just because you have JIT. In Transmeta's case, you can't translate an obsolete RISC code to efficient VLIW in real-time. This seems to be putting too much strain on the translation. Which ought to be obvious given the complexity of VLIW compilers? Sometimes outsiders have a better view. Best, -- Eray Ozkural, PhD candidate. Comp. Sci. Dept., Bilkent University, Ankara http://groups.yahoo.com/group/ai-philosophy http://myspace.com/arizanesil http://myspace.com/malfunct --005045017519cb4a83049055ab3a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Wed, Sep 15, 2010 at 11:37 PM, Jon Harrop <jon= athandeanharrop@googlemail.com> wrote:
> Hmm, this would only optimize the bytecode fetch/dec= ode step of the ocaml
execution cycle. I am not sure that it will result in much real-world
speedup.

Would be interesting to try. I suspect the C compiler would then opti= mize
the sequences of operations on the data as well. For example, something lik= e
vector addition.

> In fact, that seems to be the main problem with many of these so-calle= d
JIT interpreters, which in my opinion, do not seem to have learnt from the<= br> HAL architectures of IBM OS's etc. Was probably also the problem with Transmeta; cheap compilation entails cheap performance.

Can you elaborate?


Well, what= I would do is to apply a fully optimizing compiler from a proper hardware = abstraction layer, whether it is JIT is irrelevant, but I do not see why th= e system would not start doing this as soon as the code is loaded in some p= lace (and not when it starts to run). What is certain is that some simple t= ransformation will not speed things up much.

The right way to do it is to determine hot blocks befor= ehand. Hot blocks can also be determined on the fly but I do not think that= JIT is much needed. The time of the determination of hot blocks is most ce= rtainly not crucial to optimizations, although the more time compiler has, = the better. Simple optimizations will not have much impact. It is not like = you can undo the complexity of an optimizing compiler just because you have= JIT.

In Transmeta's case, you can't translate an obs= olete RISC code to efficient VLIW in real-time. This seems to be putting to= o much strain on the translation. Which ought to be obvious given the compl= exity of VLIW compilers? Sometimes outsiders have a better view.

Best,
=A0
--
Eray Ozkural, PhD= candidate.=A0 Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/a= i-philosophy
http://myspace.com/arizanesil= http://myspace.com/malfunct
--005045017519cb4a83049055ab3a-- 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id AE09ABC58 for ; Thu, 16 Sep 2010 11:08:54 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.56,375,1280700000"; d="scan'208";a="57358508" Received: from peermanence.saclay.inria.fr (HELO [195.83.212.205]) ([195.83.212.205]) by mail3-relais-sop.national.inria.fr with ESMTP; 16 Sep 2010 11:08:54 +0200 Message-ID: <4C91DDE0.2040105@inria.fr> Date: Thu, 16 Sep 2010 11:05:36 +0200 From: Fabrice Le Fessant User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100826 Thunderbird/3.0.7 MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiling Ocaml sources to c sources References: <4C8F660B.4060901@telecom-bretagne.eu> <20100914124341.GA11500@hector.lesours> <004b01cb54fc$9c435020$d4c9f060$@com> <006a01cb5515$c9c42420$5d4c6c60$@com> In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 compiler:01 reimplement:01 ocaml:01 appending:01 bytecode:01 eray:01 ozkural:01 compiler:01 abstraction:01 garbage:01 wrote:01 caml-list:01 functions:01 compiling:02 The problem is still the same: even if the code is compiled by a C compiler, there is still the need for the garbage collector. If you don't provide your own conservative GC (for which you would have to reimplement all the native functions of OCaml), then you need to use OCaml GC, and you would have to disable most optimizations to be sure that the GC knows where to find live references. At the end, you would get almost no performance improvement, compared to just appending the assembly code for each bytecode instruction (see Piumarta's work in PLDI'98). --Fabrice Eray Ozkural wrote, On 09/16/2010 02:38 AM: > Well, what I would do is to apply a fully optimizing compiler from a > proper hardware abstraction layer, whether it is JIT is irrelevant, but > I do not see why the system would not start doing this as soon as the > code is loaded in some place (and not when it starts to run). What is > certain is that some simple transformation will not speed things up much. 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 8F6BBBC58 for ; Thu, 16 Sep 2010 12:46:18 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEBAM6RkUzRVda0kGdsb2JhbACTaIV/AYgICBUBAQEBCQkMBxEDH6UEiTeCFIZqLYhUAQEDBYU8BIFagmuFZw X-IronPort-AV: E=Sophos;i="4.56,376,1280700000"; d="scan'208";a="57365523" Received: from mail-iw0-f180.google.com ([209.85.214.180]) by mail3-smtp-sop.national.inria.fr with ESMTP; 16 Sep 2010 12:46:17 +0200 Received: by iwn8 with SMTP id 8so1399395iwn.39 for ; Thu, 16 Sep 2010 03:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=2KQ0Vhhei+4KHltN1bc1+g15lEMJvVKKKy2l1/A95QQ=; b=w0jjy042thruCtYLkhVNpq9DuFM6IrpGnsLvqB3yavuvKxQv/UPkymSRkbqmo8TG4B y8vXukDdbZLVDUgMWDccmAnhM64GNKe3HhChUCrfUwg/tRa3+OL9A0vGWkuBY68mqwaZ oxuKTTrN6UUq4UDkqc+cSvVKk+RuHg2TeUdQA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=VtLj9bR2rGjEs5Uhj5z1YnYjuNH/B/y8+asDnZKO7iGM8bm/JXpF7DwpjqKPnh3xkc 7fXbpebJ2cBRRTiB74lhmiHOPotNJ3e0vzrp/Ups8cgB8kTd8GHUmX/m5Fq5aZV7fAba 3kDqZgNx57PcPyr7DpX3myzHvRe2luroLLMAs= MIME-Version: 1.0 Received: by 10.231.159.203 with SMTP id k11mr3170149ibx.115.1284633975683; Thu, 16 Sep 2010 03:46:15 -0700 (PDT) Received: by 10.231.159.131 with HTTP; Thu, 16 Sep 2010 03:46:15 -0700 (PDT) In-Reply-To: <4C91DDE0.2040105@inria.fr> References: <4C8F660B.4060901@telecom-bretagne.eu> <20100914124341.GA11500@hector.lesours> <004b01cb54fc$9c435020$d4c9f060$@com> <006a01cb5515$c9c42420$5d4c6c60$@com> <4C91DDE0.2040105@inria.fr> Date: Thu, 16 Sep 2010 13:46:15 +0300 Message-ID: Subject: Re: [Caml-list] Compiling Ocaml sources to c sources From: Eray Ozkural To: Fabrice Le Fessant Cc: caml-list@yquem.inria.fr Content-Type: multipart/alternative; boundary=005045015627c9c85f04905e2710 X-Spam: no; 0.00; ocaml:01 eray:01 ozkural:01 ocaml:01 boehm:01 compiler:01 compiler:01 bytecode:01 hypothetical:01 reimplement:01 appending:01 bytecode:01 eray:01 ozkural:01 abstraction:01 --005045015627c9c85f04905e2710 Content-Type: text/plain; charset=ISO-8859-1 Yes, I've seen how wired the GC is in the ocaml sources. I had used the Boehm GC in a compiler project (not for the generated code but the compiler), do you mean that one would have to disable most optimizations in the ocaml bytecode compiler to make such a hypothetical bytecode-to-C compiler work with a C GC, or am I missing something crucial? It's great to be able to learn from actual ocaml compiler writers, BTW, your comments are much appreciated. Regards, On Thu, Sep 16, 2010 at 12:05 PM, Fabrice Le Fessant < fabrice.le_fessant@inria.fr> wrote: > The problem is still the same: even if the code is compiled by a C > compiler, there is still the need for the garbage collector. If you > don't provide your own conservative GC (for which you would have to > reimplement all the native functions of OCaml), then you need to use > OCaml GC, and you would have to disable most optimizations to be sure > that the GC knows where to find live references. At the end, you would > get almost no performance improvement, compared to just appending the > assembly code for each bytecode instruction (see Piumarta's work in > PLDI'98). > > --Fabrice > > Eray Ozkural wrote, On 09/16/2010 02:38 AM: > > Well, what I would do is to apply a fully optimizing compiler from a > > proper hardware abstraction layer, whether it is JIT is irrelevant, but > > I do not see why the system would not start doing this as soon as the > > code is loaded in some place (and not when it starts to run). What is > > certain is that some simple transformation will not speed things up much. > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- Eray Ozkural, PhD candidate. Comp. Sci. Dept., Bilkent University, Ankara http://groups.yahoo.com/group/ai-philosophy http://myspace.com/arizanesil http://myspace.com/malfunct --005045015627c9c85f04905e2710 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Yes, I've seen how wired the GC is in the ocaml sources. I had used the=
Boehm GC in a compiler project (not for the generated code but the com= piler),
do you mean that one would have to disable most optimizat= ions in the ocaml bytecode
compiler to make such a hypothetical bytecode-to-C compiler work with = a C
GC, or am I missing something crucial? It's great to be a= ble to learn from actual=A0
ocaml compiler writers, BTW, your com= ments are much appreciated.

Regards,




--
Eray Ozkura= l, PhD candidate.=A0 Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/g= roup/ai-philosophy
http://myspace.com/arizanesil= http://myspace.com/malfunct
--005045015627c9c85f04905e2710-- 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 799EABC58 for ; Thu, 16 Sep 2010 13:11:31 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAJuYkUzRVdg0kGdsb2JhbAChcQgVAQEBAQkJDAcRAx+kc4tLhmaJAQEBAwWFPASKLIVfgyE X-IronPort-AV: E=Sophos;i="4.56,376,1280700000"; d="scan'208";a="67690185" Received: from mail-qw0-f52.google.com ([209.85.216.52]) by mail1-smtp-roc.national.inria.fr with ESMTP; 16 Sep 2010 13:11:30 +0200 Received: by qwf6 with SMTP id 6so1197055qwf.39 for ; Thu, 16 Sep 2010 04:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; bh=A1F9FXQieenL5AJKDFoYM4pGxdo/6zjkqa3ngfJg8gA=; b=rGdGGHxkgQMbqCkv0dZTn4Ndz9VhHTDlxuvdwxGai6o0vGTuqKM7YjnCSodCWSlunG BhjKKBSgad10LixnW96HIoYQTJ5OZU0d0ptGviK2iu1XKBnH/udFe4r33KtjG4P1cmAk sQi4Y8Sy1MOT7nfU9QcUsa0At16ohmeRtY7AM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=TwHUCPuG5AO+BF7yfesNRav7KCXTBYvu3c/WNFWBsS1vko5c3QN5N4G1iEVnM1qufm HYatGa4LHGXKFtC4JBmt3NDJBDvdb6sPl5CIPfMuptm5XNOlK8kLSJqkMORqjx30MAmL FIZch1qqvq42dA8GoBWZkvOvNnFHjQwZrw/24= MIME-Version: 1.0 Received: by 10.229.250.193 with SMTP id mp1mr2143320qcb.129.1284635490351; Thu, 16 Sep 2010 04:11:30 -0700 (PDT) Sender: fabrissimo@gmail.com Received: by 10.229.48.85 with HTTP; Thu, 16 Sep 2010 04:11:29 -0700 (PDT) In-Reply-To: References: <4C8F660B.4060901@telecom-bretagne.eu> <20100914124341.GA11500@hector.lesours> <004b01cb54fc$9c435020$d4c9f060$@com> <006a01cb5515$c9c42420$5d4c6c60$@com> <4C91DDE0.2040105@inria.fr> Date: Thu, 16 Sep 2010 13:11:29 +0200 X-Google-Sender-Auth: VOt93bO7vqAG7tQXuCs4cpjemYA Message-ID: Subject: Re: [Caml-list] Compiling Ocaml sources to c sources From: Fabrice Le Fessant To: Eray Ozkural Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; ocaml:01 bigloo:01 compiler:01 ocaml's:01 ocaml's:01 pointer:01 ocaml:01 pointers:01 compiler:01 pointers:01 computations:01 dependencies:01 bytecode:01 bytecode:01 eray:01 You could use Boehm's garbage-collector for such a project, indeed, that's what is done in Bigloo, to compile Scheme programs to C. Since Boehm's GC is conservative, it would probably work well in such a system, with or without compiler optimizations, but the GC itself would probably be much slower than OCaml's GC on monothreaded code. On the contrary, OCaml's GC is not conservative, so it really needs to know what is a pointer to OCaml data, and also to be warned when pointers to OCaml data are erased (what caml_modify does). If you leave the C compiler perform all its optimizations, you might end up with pointers to OCaml data that are not where they should be (typically, it can duplicate a variable to parallelize some computations when there are no dependencies between them, and the GC will only scan one of them). So, you have to limit the C compiler to only "safe" optimizations from that point of view. By the way, there are almost no optimizations performed in the Ocaml compiler on bytecode, most of the interesting ones are only performed in the native compiler. I think the philosophy behind this choice is that you want to compile very fast to bytecode (so, no time for optimization), and only use the native code compiler at the end for efficient code. --Fabrice On Thu, Sep 16, 2010 at 12:46 PM, Eray Ozkural wrote: > Yes, I've seen how wired the GC is in the ocaml sources. I had used the > Boehm GC in a compiler project (not for the generated code but the > compiler), > do you mean that one would have to disable most optimizations in the ocaml > bytecode > compiler to make such a hypothetical bytecode-to-C compiler work with a C > GC, or am I missing something crucial? It's great to be able to learn from > actual > ocaml compiler writers, BTW, your comments are much appreciated. > Regards, > On Thu, Sep 16, 2010 at 12:05 PM, Fabrice Le Fessant > wrote: >> >> The problem is still the same: even if the code is compiled by a C >> compiler, there is still the need for the garbage collector. If you >> don't provide your own conservative GC (for which you would have to >> reimplement all the native functions of OCaml), then you need to use >> OCaml GC, and you would have to disable most optimizations to be sure >> that the GC knows where to find live references. At the end, you would >> get almost no performance improvement, compared to just appending the >> assembly code for each bytecode instruction (see Piumarta's work in >> PLDI'98). >> >> --Fabrice >> >> Eray Ozkural wrote, On 09/16/2010 02:38 AM: >> > Well, what I would do is to apply a fully optimizing compiler from a >> > proper hardware abstraction layer, whether it is JIT is irrelevant, but >> > I do not see why the system would not start doing this as soon as the >> > code is loaded in some place (and not when it starts to run). What is >> > certain is that some simple transformation will not speed things up >> > much. >>