From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA24367 for caml-redistribution; Thu, 14 Nov 1996 10:28:40 +0100 (MET) 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 OAA08379 for ; Wed, 13 Nov 1996 14:36:06 +0100 (MET) Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.7.6/8.7.1) with ESMTP id OAA07037 for ; Wed, 13 Nov 1996 14:36:06 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.7.6/8.7.3) with ESMTP id OAA10939 for ; Wed, 13 Nov 1996 14:36:05 +0100 (MET) Received: from cherub.hd.ibm.de (cherub.hd.ibm.de [192.101.197.10]) by concorde.inria.fr (8.7.6/8.7.1) with SMTP id OAA06974 for ; Wed, 13 Nov 1996 14:32:54 +0100 (MET) Received: from kaa.heidelbg.ibm.com by cherub.hd.ibm.de (AIX 3.2/UCB 5.64/4.03/chkV1.0) id AA38608; Wed, 13 Nov 1996 14:31:34 +0100 Received: from idse.heidelbg.ibm.com by kaa.heidelbg.ibm.com (AIX 3.2/UCB 5.64/4.03) id AA47974; Wed, 13 Nov 1996 14:31:41 +0100 Received: by idse.heidelbg.ibm.com (AIX 3.2/UCB 5.64/4.03) id AA10561; Wed, 13 Nov 1996 14:31:35 +0100 Message-Id: <9611131331.AA10561@idse.heidelbg.ibm.com> To: Thorsten Ohl Cc: caml-list@margaux.inria.fr Subject: Re: partial evaluation anyone? In-Reply-To: (Your message of Tue, 12 Nov 96 15:37:45 N.) <9611121437.AA13126@crunch> Date: Wed, 13 Nov 96 14:31:35 +0100 From: Wolfgang Lux Sender: weis Thorsten Ohl wrote: > [ Sorry, no french version .... ] > > Continuing the thread on optimizations for numerical code: > > Is it possible to find out (at run-time) whether some components of a > function's return value are discarded by the caller? > > Example (pseudo code, in real life this is an interface to LAPACK): > > let diagonalize matrix = > (* Compute real and imaginary parts of the eigenvalues and > the left and right eigenvectors of MATRIX. *) > (wr,wi,vl,vr) > > Sometimes, one wants the eigenvalues only > > let (wr,wi,_,_) = diagonalize some_really_big_matrix > > but since diagonalize doesn't know that the eigenvectors will be > thrown away, it will calculate them anyway, which can be substantial > overhead for large matrices. Hmmm, it's probably time for you to switch to Haskell. Due to its lazy evaluation semantics it won't evaluate any arguments the caller discards. And it even has the advantage, that you do not have to check any runtime information in the function body yourself. > One way out would be to clutter the namespace with many different > functions, one for each (likely) combination of return values, or to > pass this information as a seperate argument (like LAPACK does in > Fortran). > > IMHO, both approaches are ugly kludges and it would be much nicer, if > a function could find out which parts of its return value are being > thrown away instantly. (Note that I'm not asking for a complete > dependency analysis. One level of function invocation would be > sufficient to allow the programmers to give the proper hints.) IMHO, this is no better kludge than the other two you mentioned. Actually having a (perfomance) optimized version of a function (i.e., the one which does not compute the eigenvectors at all) under a different name seems cleaner to me (at least in a language with strict semantics). > Is there a trick to do this now? Or is there a chance to get the > implementors interestet? Cheers Wolfgang ---- Wolfgang Lux WZH Heidelberg, IBM Germany Internet: lux@heidelbg.ibm.com +49-6221-59-4546 VNET: LUX at HEIDELBG +49-6221-59-3500 (fax) EARN: LUX at DHDIBMIP