X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/125ba3dea38f9b31330b322f9bc59fdd428821ae..c836edd2518e98d7666b73277ced612cc526f3f4:/src/simix/smx_context_raw.c diff --git a/src/simix/smx_context_raw.c b/src/simix/smx_context_raw.c index f4a22c8817..e829551d13 100644 --- a/src/simix/smx_context_raw.c +++ b/src/simix/smx_context_raw.c @@ -280,7 +280,7 @@ static int smx_ctx_raw_get_thread_id(){ static void smx_ctx_raw_runall(xbt_dynar_t processes) { - if (xbt_dynar_length(processes) > SIMIX_context_get_parallel_threshold()) { + if (xbt_dynar_length(processes) >= SIMIX_context_get_parallel_threshold()) { DEBUG1("Runall // %lu", xbt_dynar_length(processes)); raw_factory->self = smx_ctx_raw_self_parallel; raw_factory->get_thread_id = smx_ctx_raw_get_thread_id; @@ -306,16 +306,24 @@ void SIMIX_ctx_raw_factory_init(smx_context_factory_t *factory) (*factory)->suspend = smx_ctx_raw_suspend; (*factory)->name = "smx_raw_context_factory"; + parmap = xbt_parmap_new(2); + if (SIMIX_context_is_parallel()) { -#ifdef CONTEXT_THREADS /* To use parallel ucontexts a thread pool is needed */ - parmap = xbt_parmap_new(2); - (*factory)->self = smx_ctx_raw_self_parallel; - (*factory)->get_thread_id = smx_ctx_raw_get_thread_id; - (*factory)->runall = smx_ctx_raw_runall; -#else - THROW0(arg_error, 0, "No thread support for parallel context execution"); -#endif - } else { + if (SIMIX_context_get_parallel_threshold() > 1) { + /* choose dynamically */ + (*factory)->runall = smx_ctx_raw_runall; + } + else { + /* always parallel */ + (*factory)->self = smx_ctx_raw_self_parallel; + (*factory)->get_thread_id = smx_ctx_raw_get_thread_id; + (*factory)->runall = smx_ctx_raw_runall_parallel; + } + } + else { + /* always serial */ + (*factory)->self = smx_ctx_base_self; + (*factory)->get_thread_id = smx_ctx_base_get_thread_id; (*factory)->runall = smx_ctx_raw_runall_serial; }