l...@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?

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