From: Christophe ThiƩry Date: Fri, 9 Dec 2011 13:22:07 +0000 (+0100) Subject: Parmap: process the whole dynar, don't force workers to fetch work X-Git-Tag: exp_20120216~237^2~41 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/bc07ec1b28653016934209a9e84e249eebf703f0 Parmap: process the whole dynar, don't force workers to fetch work --- 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");