From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA06861; Wed, 4 Feb 2004 11:27:05 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA05934 for ; Wed, 4 Feb 2004 11:27:04 +0100 (MET) Received: from front1.mail.megapathdsl.net (front1.mail.megapathdsl.net [66.80.60.31]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id i14AR2P25264 for ; Wed, 4 Feb 2004 11:27:03 +0100 (MET) Received: from [82.41.201.177] (account bkavanagh@megapathdsl.net HELO Archimedes) by front1.mail.megapathdsl.net (CommuniGate Pro SMTP 4.1.3) with ESMTP id 143895116; Wed, 04 Feb 2004 02:26:48 -0800 From: "Ben Kavanagh" To: "'Walid Taha'" Cc: Subject: RE: [Caml-list] partial eval question Date: Wed, 4 Feb 2004 10:26:14 -0000 Message-ID: <000a01c3eb09$5bf8c950$b1c92952@Archimedes> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: Importance: Normal X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ml's:01 leone:99 cfm:99 cfm:99 leone:99 metaocaml:01 inspector:01 anti-spam:99 2004:99 caml-list:01 metaocaml:01 staged:01 timings:01 timings:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Walid, Thanks for your response. I was aware of MetaOCaml's ability to stage this computation and I have downloaded/run many of your benchmarks. My question was if anyone had an implementation where normal partial application (normal in ML's syntax) led to partial evaluation. It turns out that there was an implementation of this, namely Mark Leone/Peter Lee's Fabius compiler, which, unfortunately, has never been made available publicly. http://portal.acm.org/citation.cfm?id=231407&dl=ACM&coll=portal&CFID=111 11111&CFTOKEN=2222222 http://portal.acm.org/citation.cfm?id=289144&dl=ACM&coll=portal I concur that such an undiscriminating approach to partial evaluation in a program is not ideal, a point you touch on in a later mail to the Caml list. It does seem, though, that a useful syntax shortcut that made this direct partial-application -> partial-eval mapping available in the manner of Lee/Leone could be useful in MetaOCaml. Do you agree? Ben ------------------------------------------------------------------------ -------------- FIGHT BACK AGAINST SPAM! Download Spam Inspector, the Award Winning Anti-Spam Filter http://mail.giantcompany.com -----Original Message----- From: Walid Taha [mailto:taha@cs.rice.edu] Sent: Wednesday, February 04, 2004 2:51 AM To: Ben Kavanagh Cc: caml-list@inria.fr Subject: Re: [Caml-list] partial eval question Hi Ben, Below is a MetaOCaml (www.metaocaml.org) program that does what you were asking for. ----- begin ben.ml Trx.init_times (* Initialize MetaOCaml timer library *) (* Here's Ben's original code *) let pow n x = let rec pow_iter (n1, x1, p1) = if (n1 = 0) then p1 else if (n1 mod 2 = 0) then pow_iter(n1/2, x1*x1, p1) else pow_iter(n1-1, x1, p1*x1) in pow_iter(n, x, 1);; let pow2 = pow 2 (* Here's a staged version of Ben's code *) let pow' n x = let rec pow_iter (n1, x1, p1) = if (n1 = 0) then p1 else if (n1 mod 2 = 0) then pow_iter(n1/2, .<.~x1 * .~x1>., p1) else pow_iter(n1-1, x1, .<.~p1 * .~x1>.) in pow_iter(n, x, .<1>.);; let pow2 = pow' 2 (* Here's some code to get some timings *) let unstagedRunning = Trx.timenew "unstaged running"(fun () -> pow 5 3) let stage1Running = Trx.timenew "stage 1 running" (fun () -> . .~(pow' 5 ..)>.) let compiling = Trx.timenew "compiling" (fun () -> .! stage1Running) let stage2Running = Trx.timenew "stage 2 running" (fun () -> (compiling 3)) let baseline = Trx.timenew "baseline" (fun () -> ()) (* Print all the timings *) let _ = Trx.print_times () (* Outpout of timer: __ unstaged running ______ 2097152x avg= 7.929525E-04 msec __ stage 1 running ________ 262144x avg= 7.248323E-03 msec __ compiling ________________ 8192x avg= 2.320860E-01 msec __ stage 2 running ______ 16777216x avg= 1.123075E-04 msec __ baseline _____________ 33554432x avg= 3.921819E-05 msec *) --- end ben.ml Walid. On Mon, 27 Oct 2003, Ben Kavanagh wrote: | |Say I have a function such as pow defined as | |let pow n x = | let rec pow_iter (n1, x1, p1) = | if (n1 = 0) then p1 | else if (n1 mod 2 = 0) | then pow_iter(n1/2, x1*x1, p1) | else pow_iter(n1-1, x1, p1*x1) | in pow_iter(n, x, 1);; | |and I say | |let pow2 = pow 2 | |Are there any ML implementations that would automatically perform |partial evaluation to create pow2 instead of using closures, possibly |unfolding the pow_iter call? Would Caml ever have this capability? | |Ben | | |------------------- |To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr |Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ |Beginner's list: http://groups.yahoo.com/group/ocaml_beginners | -- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners