Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
106e9ec45e61add865448492f1a758375b16d66f
[simgrid.git] / src / simix / smx_config.c
1 /* $Id$ */
2
3 /* simix_config.c - support for SIMIX user configuration                      */
4
5 /* Copyright (c) 2005 Martin Quinson.                                       */
6 /* All rights reserved.                                                     */
7
8 /* This program is free software; you can redistribute it and/or modify it
9  * under the terms of the license (GNU LGPL) which comes with this package. */
10
11 #include "private.h"
12 #include "xbt/sysdep.h"
13 #include "xbt/log.h"
14
15 int _simix_init_status = 0; /* 0: beginning of time; 
16                              1: pre-inited (cfg_set created); 
17                              2: inited (running) */
18 xbt_cfg_t _simix_cfg_set = NULL;
19
20 /* callback of the surf_workstation_model variable */
21 static void _simix_cfg_cb__surf_workstation_model(const char *name, int pos) 
22 {
23   char *val;
24
25   xbt_assert0(_simix_init_status<2, "Cannot change the model after the initialization");
26   
27   val = xbt_cfg_get_string (_simix_cfg_set, name);
28   /* New Module missing */
29   xbt_assert1(!strcmp(val, "CLM03") ||
30               !strcmp(val, "KCCFLN05") ||
31               !strcmp(val, "KCCFLN05_proportionnal"),
32               "Unknown workstation model: %s (either 'CLM03' or 'KCCFLN05'",val);
33 }
34
35 /* create the config set and register what should be */
36 void simix_config_init(void) 
37 {
38
39   if (_simix_init_status) 
40     return; /* Already inited, nothing to do */
41
42   _simix_init_status = 1;
43   _simix_cfg_set = xbt_cfg_new();
44   
45   xbt_cfg_register (_simix_cfg_set, 
46                     "surf_workstation_model", xbt_cfgelm_string, 1,1,
47                     &_simix_cfg_cb__surf_workstation_model,NULL);
48                     
49   xbt_cfg_set_string(_simix_cfg_set,"surf_workstation_model", "KCCFLN05");
50 }
51
52 void simix_config_finalize(void) 
53 {
54
55   if (!_simix_init_status) 
56     return; /* Not initialized yet. Nothing to do */
57
58   xbt_cfg_free(&_simix_cfg_set);
59   _simix_init_status = 0;
60 }
61
62 /** \brief set a configuration variable
63  * 
64  * Currently existing configuation variable:
65  *   - surf_workstation_model (string): Model of workstation to use.  
66  *     Possible values (defaults to "KCCFLN05"):
67  *     - "CLM03": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + support for parallel tasks
68  *     - "KCCFLN05": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file.
69  * 
70  * Example:
71  * MSG_config("surf_workstation_model","KCCFLN05");
72  */
73 void SIMIX_config(const char *name, ...) 
74 {
75   va_list pa;
76     
77   if (!_simix_init_status) {
78     simix_config_init();
79   }
80
81   va_start(pa,name);
82   xbt_cfg_set_vargs(_simix_cfg_set,name,pa);
83   va_end(pa);
84
85 }