From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 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 6FE2CBC6C for ; Wed, 6 Feb 2008 00:09:23 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAFt7qEfVJFBblmdsb2JhbACQLgEBAQEHBAYHChEHnTM X-IronPort-AV: E=Sophos;i="4.25,309,1199660400"; d="scan'208";a="22252384" Received: from mx-out.libertysurf.net (HELO mail.libertysurf.net) ([213.36.80.91]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Feb 2008 00:09:23 +0100 Received: from [192.168.1.2] (91.168.191.133) by mail.libertysurf.net (7.3.118.8) id 479F73A8001FA04A; Wed, 6 Feb 2008 01:08:19 +0100 From: Florent Monnier Organization: l'Association Linux-Nantes To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Using OCaml's run-time from LLVM-generated native code Date: Wed, 6 Feb 2008 00:08:08 +0100 User-Agent: KMail/1.8.2 References: <200802012124.56835.jon@ffconsultancy.com> <47A6F2E5.2000604@frisch.fr> <200802041336.22550.jon@ffconsultancy.com> In-Reply-To: <200802041336.22550.jon@ffconsultancy.com> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200802060008.08563.fmonnier@linux-nantes.fr.eu.org> Cc: Jon Harrop X-Face: -0"dKXwF0PiXr]fa$^)NJY7$;waqUckGcM7&q,VU?Xv\[=CiVM]g]pDs^xmfU9+Q=Z,OdfMHUR-7Ao%evJh.=aiq,#r0Ux0dm'!l|zeAXj||$>1_(Lv4Hc",&F}sbHeK0`SBA$_|XP Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml's:01 run-time:01 camlparam:01 camlreturn:01 val:01 computed:01 wrote:01 caml-list:01 int:01 int:01 fib:01 fib:01 caml:02 slower:02 native:03 Hi, Jon Harrop wrote: > int apply(int n) { > CAMLparam0(); > CAMLlocal2(nv, fibn); > nv = copy_int64(n); > fibn = fib(nv); > caml_gc_full_major(0); > CAMLreturn(Int64_val(fib(nv))); > } > > Is that correct? > > Next, this C code is 4x slower than the ocamlopt-generated equivalent. What > can be done to improve its performance without leaving C? I don't know if it is a typo from you, or if it is me that don't understand the code, but it seems that fib(nv) is computed twice. Shouldn't the second one be replaced by fibn, the result of the first one?