A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7c43893
)
Add configuration auto for contexts/nthreads and use the PROCESSOR_COUNT.
author
navarro
<navarro@caraja.(none)>
Wed, 25 Jan 2012 10:36:00 +0000
(11:36 +0100)
committer
navarro
<navarro@caraja.(none)>
Wed, 25 Jan 2012 10:36:00 +0000
(11:36 +0100)
Default number is 1.
buildtools/Cmake/Modules/FindNbCore.cmake
patch
|
blob
|
history
include/simix/context.h
patch
|
blob
|
history
src/simix/smx_context.c
patch
|
blob
|
history
src/surf/surf_config.c
patch
|
blob
|
history
diff --git
a/buildtools/Cmake/Modules/FindNbCore.cmake
b/buildtools/Cmake/Modules/FindNbCore.cmake
index
a3c1809
..
4b3c593
100644
(file)
--- a/
buildtools/Cmake/Modules/FindNbCore.cmake
+++ b/
buildtools/Cmake/Modules/FindNbCore.cmake
@@
-1,6
+1,6
@@
if(NOT DEFINED PROCESSOR_COUNT)
if(NOT DEFINED PROCESSOR_COUNT)
- #
Unknown
:
- set(PROCESSOR_COUNT
0
)
+ #
Default
:
+ set(PROCESSOR_COUNT
1
)
# Linux:
set(cpuinfo_file "/proc/cpuinfo")
# Linux:
set(cpuinfo_file "/proc/cpuinfo")
diff --git
a/include/simix/context.h
b/include/simix/context.h
index
137e374
..
ce4def0
100644
(file)
--- a/
include/simix/context.h
+++ b/
include/simix/context.h
@@
-101,7
+101,7
@@
XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID);
/* parallelism */
XBT_INLINE int SIMIX_context_is_parallel(void);
XBT_INLINE int SIMIX_context_get_nthreads(void);
/* 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);
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);
diff --git
a/src/simix/smx_context.c
b/src/simix/smx_context.c
index
fed8f7f
..
94746b7
100644
(file)
--- a/
src/simix/smx_context.c
+++ b/
src/simix/smx_context.c
@@
-136,7
+136,16
@@
XBT_INLINE int SIMIX_context_get_nthreads(void) {
*
* \param nb_threads the number of threads to use
*/
*
* \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);
xbt_assert(nb_threads > 0, "Invalid number of parallel threads: %d", nb_threads);
diff --git
a/src/surf/surf_config.c
b/src/surf/surf_config.c
index
ad2b55e
..
3f495f3
100644
(file)
--- a/
src/surf/surf_config.c
+++ b/
src/surf/surf_config.c
@@
-226,7
+226,7
@@
static void _surf_cfg_cb_context_stack_size(const char *name, int pos)
static void _surf_cfg_cb_contexts_nthreads(const char *name, int pos)
{
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)
}
static void _surf_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
@@
-461,10
+461,10
@@
void surf_config_init(int *argc, char **argv)
_surf_cfg_cb_context_stack_size, NULL);
/* number of parallel threads for user processes */
_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_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 */
_surf_cfg_cb_contexts_nthreads, NULL);
/* minimal number of user contexts to be run in parallel */