From: Martin Quinson Date: Sun, 25 Dec 2011 23:36:48 +0000 (+0100) Subject: document simix-related config options X-Git-Tag: exp_20120216~222 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4d05fc1b1a56f02a164f9926051996a9e7166f3a document simix-related config options --- diff --git a/ChangeLog b/ChangeLog index fe8de61b34..5107163926 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,7 +20,15 @@ SimGrid (3.7) NOT RELEASED; urgency=low * Use now crosstraffic keyword instead of the terribly missleading fullduplex keyword. Use --cfg=network/crosstraffic:1. This is activated by default now in the current default model. - + + Simix: + * Stabilize the parallel execution mode of user contexts + * Introduce configuration variables to control parallel execution: + - contexts/synchro: Synchronization mode to use when running + contexts in parallel (either futex, posix or busy_wait) + - contexts/parallel_threshold: Minimal number of user contexts + to be run in parallel (raw contexts only) + SimDag: * Performance boost by using a swag internally to compute the set of tasks that are finished and should constitute the return value of diff --git a/doc/options.doc b/doc/options.doc index f16fd1b225..d8e6b85c63 100644 --- a/doc/options.doc +++ b/doc/options.doc @@ -233,6 +233,91 @@ Properties are expressed as assertions using the function void MC_assert(int prop); \endverbatim +\section options_virt User process virtualization options + +\subsection options_virt_factory Selecting the virtualization factory + +In SimGrid, the user code is virtualized in a specific mecanism +allowing the simulation kernel to control its execution: when a user +process requires a blocking action (such as sending a message), it is +interrupted, and only gets released when the simulated clock reaches +the point where the blocking operation is done. + +In SimGrid, the containers in which user processes are virtualized are +called contexts. Several context factory are provided, and you can +select the one you want to use with the \b contexts/factory +configuration variable. Some of the following may not exist on your +machine because of portability issues. In any case, the default one +should be the most effcient one (please report bugs if the +auto-detection fails for you). They are sorted here from the slowest +to the most effient: + - \b thread: very slow factory using full featured threads (either + ptheads or windows native threads) + - \b ucontext: fast factory using System V contexts (or a portability + layer of our own on top of Windows fibers) + - \b raw: amazingly fast factory using a context switching mecanism + of our own, directly implemented in assembly (only available for x86 + and amd64 platforms for now) + +The only reason to change this setting is when the debuging tools get +fooled by the optimized context factories. Threads are the most +debugging-friendly contextes. + +\subsection options_virt_stacksize Adapting the used stack size + +(this only works if you use ucontexts or raw context factories) + +Each virtualized used process is executed using a specific system +stack. The size of this stack has a huge impact on the simulation +scalability, but its default value is rather large. This is because +the error messages that you get when the stack size is too small are +rather disturbing: this leads to stack overflow (overwriting other +stacks), leading to segfaults with corrupted stack traces. + +If you want to push the scalability limits of your code, you really +want to reduce the \b contexts/stack_size variable. Its default value +is 128 (in Kib), while our Chord simulation works with stacks as small +as 16 Kib, for example. + +\subsection options_virt_parallel Running user code in parallel + +Parallel execution of the user code is only considered stable in +SimGrid v3.7 and higher. It is described in +INRIA RR-7653. + +If you are using the \c ucontext or \c raw context factories, you can +request to execute the user code in parallel. Several threads are +launched, each of them handling as much user contexts at each run. To +actiave this, set the \b contexts/nthreads variable to the amount of +core that you have in your computer. + +Even if you asked several worker threads using the previous option, +you can request to start the parallel execution (and pay the +associated synchronization costs) only if the potential parallelism is +large enough. For that, set the \b contexts/parallel_threshold +variable to the minimal amount of user contexts needed to start the +parallel execution. In any given simulation round, if that amount is +not reached, the contexts will be run sequentially directly by the +main thread (thus saving the synchronization costs). Note that this +option is mainly useful when the grain of the user code is very fine, +because our synchronization is now very efficient. + +When parallel execution is activated, you can choose the +synchronization schema used with the \b contexts/synchro variable, +which value is either: + - \b futex: ultra optimized synchronisation schema, based on futexes + (fast user-mode mutexes), and thus only available on Linux systems. + This is the default mode when available. + - \b posix: slow but portable synchronisation using only POSIX + primitives. + - \b busy_wait: not really a synchronisation: the worker threads + constantly request new contexts to execute. It should be the most + efficient synchronisation schema, but it loads all the cores of your + machine for no good reason. You probably prefer the other less + eager schemas. + + + \section options_generic Various generic configuration variables \section options_generic_path XML file inclusion path @@ -254,6 +339,13 @@ when \b verbose-exit is set to 0 (it is to 1 by default). \section options_index Index of all existing variables +- \c contexts/factory: \ref options_virt_factory +- \c contexts/nthreads: \ref options_virt_parallel +- \c contexts/parallel_threshold: \ref options_virt_parallel +- \c contexts/stack_size: \ref options_virt_stacksize +- \c contexts/synchro: \ref options_virt_parallel + + - \c cpu/maxmin_selective_update: \ref options_model_optim - \c cpu/model: \ref options_model_select - \c cpu/optim: \ref options_model_optim diff --git a/src/simix/smx_context.c b/src/simix/smx_context.c index 6423cd6146..c3632ff5b4 100644 --- a/src/simix/smx_context.c +++ b/src/simix/smx_context.c @@ -1,6 +1,6 @@ /* a fast and simple context switching library */ -/* Copyright (c) 2009, 2010. The SimGrid Team. +/* Copyright (c) 2009 - 2011. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -143,7 +143,7 @@ XBT_INLINE void SIMIX_context_set_nthreads(int nb_threads) { if (nb_threads > 1) { #ifndef CONTEXT_THREADS - THROWF(arg_error, 0, "No thread support for parallel context execution"); + THROWF(arg_error, 0, "The thread factory cannot be run in parallel"); #endif } diff --git a/src/surf/surf_config.c b/src/surf/surf_config.c index c2373a6b5d..78fa62bff4 100644 --- a/src/surf/surf_config.c +++ b/src/surf/surf_config.c @@ -310,8 +310,7 @@ void surf_config_init(int *argc, char **argv) sprintf(p, ".\n (use 'help' as a value to see the long description of each model)"); default_value = xbt_strdup("Cas01"); - xbt_cfg_register(&_surf_cfg_set, - "cpu/model", description, xbt_cfgelm_string, + xbt_cfg_register(&_surf_cfg_set, "cpu/model", description, xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL); sprintf(description, @@ -324,8 +323,7 @@ void surf_config_init(int *argc, char **argv) sprintf(p, ".\n (use 'help' as a value to see the long description of each optimization mode)"); default_value = xbt_strdup("Lazy"); - xbt_cfg_register(&_surf_cfg_set, - "cpu/optim", description, xbt_cfgelm_string, + xbt_cfg_register(&_surf_cfg_set, "cpu/optim", description, xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL); sprintf(description, @@ -338,8 +336,7 @@ void surf_config_init(int *argc, char **argv) sprintf(p, ".\n (use 'help' as a value to see the long description of each model)"); default_value = xbt_strdup("LV08"); - xbt_cfg_register(&_surf_cfg_set, - "network/model", description, xbt_cfgelm_string, + xbt_cfg_register(&_surf_cfg_set, "network/model", description, xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__network_model, NULL); @@ -353,8 +350,7 @@ void surf_config_init(int *argc, char **argv) sprintf(p, ".\n (use 'help' as a value to see the long description of each optimization mode)"); default_value = xbt_strdup("Lazy"); - xbt_cfg_register(&_surf_cfg_set, - "network/optim", description, xbt_cfgelm_string, + xbt_cfg_register(&_surf_cfg_set, "network/optim", description, xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL); sprintf(description, @@ -367,8 +363,7 @@ void surf_config_init(int *argc, char **argv) sprintf(p, ".\n (use 'help' as a value to see the long description of each model)"); default_value = xbt_strdup("default"); - xbt_cfg_register(&_surf_cfg_set, - "workstation/model", description, xbt_cfgelm_string, + xbt_cfg_register(&_surf_cfg_set, "workstation/model", description, xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__workstation_model, NULL); @@ -456,19 +451,19 @@ void surf_config_init(int *argc, char **argv) /* stack size of contexts in Ko */ default_value_int = 128; xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size", - "Stack size of contexts in Ko (ucontext or raw only)", + "Stack size of contexts in Kib (ucontext or raw only)", xbt_cfgelm_int, &default_value_int, 1, 1, _surf_cfg_cb_context_stack_size, NULL); /* number of parallel threads for user processes */ default_value_int = 1; xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads", - "Number of parallel threads for user contexts (EXPERIMENTAL)", + "Number of parallel threads used to execute user contexts", xbt_cfgelm_int, &default_value_int, 1, 1, _surf_cfg_cb_contexts_nthreads, NULL); /* minimal number of user contexts to be run in parallel */ - default_value_int = 1; + default_value_int = 2; xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold", "Minimal number of user contexts to be run in parallel (raw contexts only)", xbt_cfgelm_int, &default_value_int, 1, 1, @@ -476,8 +471,8 @@ void surf_config_init(int *argc, char **argv) /* minimal number of user contexts to be run in parallel */ default_value = xbt_strdup("futex"); - xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_mode", - "Synchronization mode to use when running contexts in parallel", + xbt_cfg_register(&_surf_cfg_set, "contexts/synchro", + "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)", xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_contexts_parallel_mode, NULL);