Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Parmap: process the whole dynar, don't force workers to fetch work
authorChristophe Thiéry <christopho128@gmail.com>
Fri, 9 Dec 2011 13:22:07 +0000 (14:22 +0100)
committerChristophe Thiéry <christopho128@gmail.com>
Fri, 9 Dec 2011 13:22:07 +0000 (14:22 +0100)
include/xbt/parmap.h
src/xbt/parmap.c

index 172ef6b..7bf69c0 100644 (file)
@@ -18,12 +18,13 @@ SG_BEGIN_DECL()
 /** \addtogroup XBT_parmap
   * \brief Parallel map.
   *
 /** \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.
   *
   * \{
   */
   *
   * \{
   */
index 4e79b71..8a86b36 100644 (file)
@@ -143,8 +143,9 @@ static void *xbt_parmap_worker_main(void *arg)
       XBT_DEBUG("Worker got a job");
 
       void* work = xbt_parmap_next(parmap);
       XBT_DEBUG("Worker got a job");
 
       void* work = xbt_parmap_next(parmap);
-      if (work != NULL) {
+      while (work != NULL) {
         parmap->fun(work);
         parmap->fun(work);
+        work = xbt_parmap_next(parmap);
       }
 
       XBT_DEBUG("Worker has finished");
       }
 
       XBT_DEBUG("Worker has finished");