caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Stephen Brackin <stephen.brackin@verizon.net>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Sharing time between two computations?
Date: Sun, 05 Feb 2006 23:45:06 +0100	[thread overview]
Message-ID: <1139179506.3912.9.camel@localhost.localdomain> (raw)
In-Reply-To: <0IU800JUPAJW2PB8@vms042.mailsrvcs.net>

Am Sonntag, den 05.02.2006, 14:09 -0500 schrieb Stephen Brackin:
> Xavier Leroy showed me how to set things up so that an OCaml
> computation is interrupted after a pre-set time limit to ask the user
> how long to continue. Now I’d like to do the same thing for two
> parallel computations that I’d like to have share the time available
> more-or-less evenly. (I’m writing OCaml code for automatically proving
> results in the HOL Light theorem prover, and I have a situation where
> the code needs to prove that a value is positive or prove that it’s
> negative, but the code doesn’t know which, if either, it will be able
> to prove.) Can this be done? If so, then what’s the easiest way to do
> it? As a special case of this question, for an expression of the form
> “let x,y = f(args1),g(args2)”, how does the system allocate time
> between the computation of x and y? (If it’s more-or-less equally,
> then that solves my problem; if one of x or y is computed first, then
> the other, then I’ve still got a problem.)

Yes, you have. O'Caml does not parallelize computations, it does just
one thing after the other (here in an unspecified order).

If your computations do not mutate any global value (i.e. are really
side-effect free), you can spawn two threads and let the operating
system schedule how the CPU is shared by the computations. However: I
said REALLY side-effect free, and that has to be valid not only for your
own code but also for all functions you call (e.g. consider functions
with hidden caches that pretend they are pure but actually aren't).

Otherwise I do not see any practical solution for your problem. 

Gerd

-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Telefon: 06151/153855                  Telefax: 06151/997714
------------------------------------------------------------


  reply	other threads:[~2006-02-05 22:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-05 19:09 Stephen Brackin
2006-02-05 22:45 ` Gerd Stolpmann [this message]
2006-02-08 17:21 [Caml-list] " Harrison, John R

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=1139179506.3912.9.camel@localhost.localdomain \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@yquem.inria.fr \
    --cc=stephen.brackin@verizon.net \
    /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;
as well as URLs for NNTP newsgroup(s).