From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 30242BC88 for ; Tue, 8 Feb 2005 17:02:19 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j18G2I36005830 for ; Tue, 8 Feb 2005 17:02:18 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA27096 for ; Tue, 8 Feb 2005 17:02:18 +0100 (MET) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j18G2Gc5005824 for ; Tue, 8 Feb 2005 17:02:17 +0100 Received: from [192.168.1.200] (ppp212-197.lns2.syd3.internode.on.net [203.122.212.197]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id j18G23YV047317; Wed, 9 Feb 2005 02:32:14 +1030 (CST) Subject: Re: [Caml-list] Re: paralell assignment problem From: skaller Reply-To: skaller@users.sourceforge.net To: Stefan Monnier Cc: caml-list In-Reply-To: <87y8dzi0ns.fsf-monnier+gmane.comp.lang.caml.inria@gnu.org> References: <1107832025.13571.260.camel@pelican.wigram> <87y8dzi0ns.fsf-monnier+gmane.comp.lang.caml.inria@gnu.org> Content-Type: text/plain Message-Id: <1107878522.5022.78.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 09 Feb 2005 03:02:02 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4208E28A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4208E288.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 compilers:01 recursive:01 glebe:01 061:98 nsw:01 dependency:01 graph:01 graph:01 functions:01 algorithm:01 algorithm:01 snail:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Wed, 2005-02-09 at 01:34, Stefan Monnier wrote: > > Does anyone know how to solve the parallel assignment problem? > > Name invented by me to describe this problem: > > > x1,x2,x3..xn = e1,e2,e3 .. en > > > where ei might contain the variables xj. (Note = here is assignment). > > > The solution is a sequence of assignments involving > > only xi, ei, and ti, where ti are temporaries introduced > > to save the values of the expressions. For example, > > Most ML compilers do this sort of thing to break big blocks of mutually > recursive functions into smaller such blocks. The algorithm used is > generally to extract the "strongly connected components" of the graph. > Google for it and you'll surely find an algorithm. I'm not sure the problem is quite the same though. Call graphs are transitive: if A calls B, and B calls C, then A calls C. However, 'depends on' is not transitive. Here x,y = y,x x and y are mutually dependent, but in the solution: t = x; x = y; y = t t depends on x, x depends on y, and y depends on t. If the dependency were transitive, y would then depend on x, but it doesn't. That is: the graph of the solution seems strongly connected: T -> X -> Y --+ ^ | +-------------+ however, these are *sequential* and not parallel assignments. A solution using digraph decomposition may well be the right answer, perhaps changing the relation to 'depends on the old value of'. This would break the cycle above (since t has no old value, y now doesn't depend on anything). See another post for an algorithm.. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net