unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: guile-devel@gnu.org
Subject: Re: Delimited continuations to the rescue of futures
Date: Sat, 17 Nov 2012 14:43:54 +0100	[thread overview]
Message-ID: <87haootkdh.fsf@gnu.org> (raw)
In-Reply-To: <87wqxkrggv.fsf@tines.lan> (Mark H. Weaver's message of "Fri, 16 Nov 2012 23:38:56 -0500")

Hi Mark,

Mark H Weaver <mhw@netris.org> skribis:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> As was reported recently by Mark and others, ‘par-map’ would only use
>> ncores - 1, because the main thread was stuck in a
>> ‘wait-condition-variable’ while touching one of the futures.
>>
>> The obvious fix is to write ‘par-map’ like this (as can be seen from
>> Chapter 2 of Marc Feeley’s PhD thesis):
>>
>>   (define (par-mapper mapper cons)
>>     (lambda (proc . lists)
>>       (let loop ((lists lists))
>>         (match lists
>>           (((heads tails ...) ...)
>>            (let ((tail (future (loop tails)))
>>                  (head (apply proc heads)))
>>              (cons head (touch tail))))
>>           (_
>>            '())))))
>
> Am I correct in believing that the above code would use the main thread
> only for applying 'proc' to the first element of each list?

Yes.

> In other words, if you have 4 cores and call 'par-map' on a list of 1000
> elements, the main thread will only be used to process 1 out of 1000
> elements, and only 3 cores will be used to process the other 999.
> Is that right?

No.  :-)

That’s what would happen with current stable-2.0.  But in
‘wip-nested-futures’, the main thread behaves as a worker while waiting
for the tail future to complete (which addresses your main concern, I
think, as we had discussed on IRC.)  Thus, all cores are always used.

Thanks,
Ludo’.



  reply	other threads:[~2012-11-17 13:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16 23:36 Delimited continuations to the rescue of futures Ludovic Courtès
2012-11-17  4:38 ` Mark H Weaver
2012-11-17 13:43   ` Ludovic Courtès [this message]
2012-11-17 16:56     ` Mark H Weaver
2012-11-17 22:00       ` Ludovic Courtès
2012-11-18 22:19         ` Mark H Weaver
2012-11-20 19:20           ` Ludovic Courtès
2012-11-21 12:18             ` Peter TB Brett
2012-11-21 13:36               ` Ludovic Courtès
2012-11-21 16:45                 ` Peter TB Brett
2012-11-21 21:19                   ` Ludovic Courtès
2012-11-21 23:28         ` Ludovic Courtès
2013-01-14  2:34 ` Nala Ginrut
2013-01-14 10:37   ` Ludovic Courtès

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=87haootkdh.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=mhw@netris.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).