From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: Delimited continuations to the rescue of futures Date: Fri, 16 Nov 2012 23:38:56 -0500 Message-ID: <87wqxkrggv.fsf@tines.lan> References: <87ip95unl3.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1353127165 5917 80.91.229.3 (17 Nov 2012 04:39:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Nov 2012 04:39:25 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Nov 17 05:39:35 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TZaBn-000507-8P for guile-devel@m.gmane.org; Sat, 17 Nov 2012 05:39:31 +0100 Original-Received: from localhost ([::1]:59831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZaBd-00025d-56 for guile-devel@m.gmane.org; Fri, 16 Nov 2012 23:39:21 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZaBY-00025S-07 for guile-devel@gnu.org; Fri, 16 Nov 2012 23:39:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TZaBU-0002u7-Ty for guile-devel@gnu.org; Fri, 16 Nov 2012 23:39:15 -0500 Original-Received: from world.peace.net ([96.39.62.75]:42361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZaBU-0002u1-Lu; Fri, 16 Nov 2012 23:39:12 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1TZaBN-0006BT-Lx; Fri, 16 Nov 2012 23:39:06 -0500 In-Reply-To: <87ip95unl3.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sat, 17 Nov 2012 00:36:56 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15195 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) writes: > As was reported recently by Mark and others, =E2=80=98par-map=E2=80=99 wo= uld only use > ncores - 1, because the main thread was stuck in a > =E2=80=98wait-condition-variable=E2=80=99 while touching one of the futur= es. > > The obvious fix is to write =E2=80=98par-map=E2=80=99 like this (as can b= e seen from > Chapter 2 of Marc Feeley=E2=80=99s 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