Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / xbt / parmap.c
index 1b0ab3d..a19ed04 100644 (file)
@@ -5,7 +5,9 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "internal_config.h"
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 
 #ifndef _XBT_WIN32
 #include <sys/syscall.h>
@@ -128,12 +130,23 @@ xbt_parmap_t xbt_parmap_new(unsigned int num_workers, e_xbt_parmap_mode_t mode)
   /* Create the pool of worker threads */
   xbt_parmap_thread_data_t data;
   parmap->workers[0] = NULL;
+#ifdef CORE_BINDING  
+  unsigned int core_bind = 0;
+#endif  
   for (i = 1; i < num_workers; i++) {
     data = xbt_new0(s_xbt_parmap_thread_data_t, 1);
     data->parmap = parmap;
     data->worker_id = i;
     parmap->workers[i] = xbt_os_thread_create(NULL, xbt_parmap_worker_main,
                                               data, NULL);
+#ifdef CORE_BINDING  
+    xbt_os_thread_bind(parmap->workers[i], core_bind); 
+    if(core_bind!=xbt_os_get_numcores()){
+      core_bind++;
+    } else {
+      core_bind = 0; 
+    }
+#endif    
   }
   return parmap;
 }