guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delimited continuations to the rescue of futures


From: Mark H Weaver
Subject: Re: Delimited continuations to the rescue of futures
Date: Fri, 16 Nov 2012 23:38:56 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

address@hidden (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?

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?

    Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]