Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Wolfgang Lux <lux@heidelbg.ibm.com>
To: Thorsten Ohl <ohl@crunch.ikp.physik.th-darmstadt.de>
Cc: caml-list@margaux.inria.fr
Subject: Re: partial evaluation anyone?
Date: Wed, 13 Nov 96 14:31:35 +0100	[thread overview]
Message-ID: <9611131331.AA10561@idse.heidelbg.ibm.com> (raw)
In-Reply-To: (Your message of Tue, 12 Nov 96 15:37:45 N.) <9611121437.AA13126@crunch>

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





      reply	other threads:[~1996-11-14  9:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-12 14:37 Thorsten Ohl
1996-11-13 13:31 ` Wolfgang Lux [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9611131331.AA10561@idse.heidelbg.ibm.com \
    --to=lux@heidelbg.ibm.com \
    --cc=caml-list@margaux.inria.fr \
    --cc=ohl@crunch.ikp.physik.th-darmstadt.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox