X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d0ffc37686edcc803601f76ab51fdfed5fc2f241..0917b3d40163b247c05fe33f60eb71c00a7c6854:/src/xbt/parmap.c diff --git a/src/xbt/parmap.c b/src/xbt/parmap.c index 3e56435315..b5d9025ff2 100644 --- a/src/xbt/parmap.c +++ b/src/xbt/parmap.c @@ -1,8 +1,9 @@ -/* Copyright (c) 2004-2005, 2007, 2009-2013. The SimGrid Team. +/* Copyright (c) 2004-2005, 2007, 2009-2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ + #include "internal_config.h" #include @@ -127,12 +128,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; } @@ -271,14 +283,14 @@ static void xbt_parmap_set_mode(xbt_parmap_t parmap, e_xbt_parmap_mode_t mode) */ void xbt_parmap_apply(xbt_parmap_t parmap, void_f_pvoid_t fun, xbt_dynar_t data) { - /* Assign resources to worker threads */ + /* Assign resources to worker threads (we are maestro here)*/ parmap->fun = fun; parmap->data = data; parmap->index = 0; - parmap->master_signal_f(parmap); - xbt_parmap_work(parmap); - parmap->master_wait_f(parmap); - XBT_DEBUG("Job done"); + parmap->master_signal_f(parmap); // maestro runs futex_wait to wake all the minions (the working threads) + xbt_parmap_work(parmap); // maestro works with its minions + parmap->master_wait_f(parmap); // When there is no more work to do, then maestro waits for the last minion to stop + XBT_DEBUG("Job done"); // ... and proceeds } /**