From bc07ec1b28653016934209a9e84e249eebf703f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christophe=20Thi=C3=A9ry?= Date: Fri, 9 Dec 2011 14:22:07 +0100 Subject: [PATCH] Parmap: process the whole dynar, don't force workers to fetch work --- include/xbt/parmap.h | 11 ++++++----- src/xbt/parmap.c | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/xbt/parmap.h b/include/xbt/parmap.h index 172ef6be61..7bf69c0208 100644 --- a/include/xbt/parmap.h +++ b/include/xbt/parmap.h @@ -18,12 +18,13 @@ SG_BEGIN_DECL() /** \addtogroup XBT_parmap * \brief Parallel map. * - * A function is applied to the n first elements of a dynar in parallel, - * where n is the number of threads. The threads are persistent until the - * destruction of the parmap object. + * A function is applied to all elements of a dynar in parallel with n worker + * threads. + * The worker threads are persistent until the destruction of the parmap. * - * If there are more than n elements in the dynar, the worker threads should - * fetch themselves remaining work with xbt_parmap_next() and execute it. + * If there are more than n elements in the dynar, the worker threads are + * allowed to fetch themselves remaining work with xbt_parmap_next() and + * execute it. * * \{ */ diff --git a/src/xbt/parmap.c b/src/xbt/parmap.c index 4e79b71bb1..8a86b36384 100644 --- a/src/xbt/parmap.c +++ b/src/xbt/parmap.c @@ -143,8 +143,9 @@ static void *xbt_parmap_worker_main(void *arg) XBT_DEBUG("Worker got a job"); void* work = xbt_parmap_next(parmap); - if (work != NULL) { + while (work != NULL) { parmap->fun(work); + work = xbt_parmap_next(parmap); } XBT_DEBUG("Worker has finished"); -- 2.20.1