Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e6cc7becf8ec12ebcc805684bc63946ee3eb017a
[simgrid.git] / src / simix / smx_config.c
1 /* $Id$ */
2
3 /* Copyright (c) 2007 Arnaud Legrand, Bruno Donassolo.
4    All rights reserved.                                          */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include "private.h"
10 #include "xbt/sysdep.h"
11 #include "xbt/log.h"
12
13 int _simix_init_status = 0; /* 0: beginning of time; 
14                              1: pre-inited (cfg_set created); 
15                              2: inited (running) */
16 xbt_cfg_t _simix_cfg_set = NULL;
17
18 /* callback of the workstation_model variable */
19 static void _simix_cfg_cb__workstation_model(const char *name, int pos) 
20 {
21   char *val;
22
23   xbt_assert0(_simix_init_status<2, "Cannot change the model after the initialization");
24   
25   val = xbt_cfg_get_string (_simix_cfg_set, name);
26   /* New Module missing */
27   
28   find_resource_description(surf_workstation_resource_description,
29                             surf_workstation_resource_description_size,
30                             val);
31 }
32
33 /* callback of the cpu_model variable */
34 static void _simix_cfg_cb__cpu_model(const char *name, int pos) 
35 {
36   char *val;
37
38   xbt_assert0(_simix_init_status<2, "Cannot change the model after the initialization");
39   
40   val = xbt_cfg_get_string (_simix_cfg_set, name);
41   /* New Module missing */
42   find_resource_description(surf_cpu_resource_description,
43                             surf_cpu_resource_description_size,
44                             val);
45 }
46 /* callback of the workstation_model variable */
47 static void _simix_cfg_cb__network_model(const char *name, int pos) 
48 {
49   char *val;
50
51   xbt_assert0(_simix_init_status<2, "Cannot change the model after the initialization");
52   
53   val = xbt_cfg_get_string (_simix_cfg_set, name);
54   /* New Module missing */
55   find_resource_description(surf_network_resource_description,
56                             surf_network_resource_description_size,
57                             val);
58 }
59
60 /* create the config set and register what should be */
61 void simix_config_init(void) 
62 {
63
64   if (_simix_init_status) 
65     return; /* Already inited, nothing to do */
66
67   _simix_init_status = 1;
68   _simix_cfg_set = xbt_cfg_new();
69   
70   xbt_cfg_register (_simix_cfg_set, 
71                     "workstation_model", xbt_cfgelm_string, 1,1,
72                     &_simix_cfg_cb__workstation_model,NULL);
73
74   xbt_cfg_register (_simix_cfg_set, 
75                     "cpu_model", xbt_cfgelm_string, 1,1,
76                     &_simix_cfg_cb__cpu_model,NULL); 
77   xbt_cfg_register (_simix_cfg_set, 
78                     "network_model", xbt_cfgelm_string, 1,1,
79                     &_simix_cfg_cb__network_model,NULL);
80                    
81   xbt_cfg_set_string(_simix_cfg_set,"workstation_model", "KCCFLN05");
82 }
83
84 void simix_config_finalize(void) 
85 {
86
87   if (!_simix_init_status) 
88     return; /* Not initialized yet. Nothing to do */
89
90   xbt_cfg_free(&_simix_cfg_set);
91   _simix_init_status = 0;
92 }
93
94 /** \brief Set a configuration variable
95  * 
96  * FIXME
97
98  * Currently existing configuration variable:
99  *   - workstation_model (string): Model of workstation to use.  
100  *     Possible values (defaults to "KCCFLN05"):
101  *     - "CLM03": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + support for parallel tasks
102  *     - "KCCFLN05": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file.
103  *     - compound 
104  *      \param name Configuration variable name that will change.
105  *      \param pa A va_list with the others parameters
106  */
107 void SIMIX_config(const char *name, va_list pa) 
108 {
109   if (!_simix_init_status) {
110     simix_config_init();
111   }
112   xbt_cfg_set_vargs(_simix_cfg_set,name,pa);
113 }