/* parallelism */
XBT_INLINE int SIMIX_context_is_parallel(void);
XBT_INLINE int SIMIX_context_get_nthreads(void);
-XBT_INLINE void SIMIX_context_set_nthreads(int nb_threads);
+XBT_INLINE void SIMIX_context_set_nthreads(char* str_nb_threads);
XBT_INLINE int SIMIX_context_get_parallel_threshold(void);
XBT_INLINE void SIMIX_context_set_parallel_threshold(int threshold);
XBT_INLINE e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode(void);
*
* \param nb_threads the number of threads to use
*/
-XBT_INLINE void SIMIX_context_set_nthreads(int nb_threads) {
+XBT_INLINE void SIMIX_context_set_nthreads(char* str_nb_threads) {
+
+ int nb_threads;
+
+ if(!strcmp(str_nb_threads,"auto")){
+ nb_threads = PROCESSOR_COUNT;
+ XBT_DEBUG("Auto-setting threads to %d",nb_threads);
+ }
+ else
+ nb_threads = atoi(str_nb_threads);
xbt_assert(nb_threads > 0, "Invalid number of parallel threads: %d", nb_threads);
static void _surf_cfg_cb_contexts_nthreads(const char *name, int pos)
{
- SIMIX_context_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
+ SIMIX_context_set_nthreads(xbt_cfg_get_string(_surf_cfg_set, name));
}
static void _surf_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
_surf_cfg_cb_context_stack_size, NULL);
/* number of parallel threads for user processes */
- default_value_int = 1;
+ default_value = xbt_strdup("1");
xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
"Number of parallel threads used to execute user contexts",
- xbt_cfgelm_int, &default_value_int, 1, 1,
+ xbt_cfgelm_string, &default_value, 1, 1,
_surf_cfg_cb_contexts_nthreads, NULL);
/* minimal number of user contexts to be run in parallel */