Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Substitution of the word "resource" by "model" in every surf related identifier
[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,
24               "Cannot change the model after the initialization");
25
26   val = xbt_cfg_get_string(_simix_cfg_set, name);
27   /* New Module missing */
28
29   find_model_description(surf_workstation_model_description,
30                             surf_workstation_model_description_size,
31                             val);
32 }
33
34 /* callback of the cpu_model variable */
35 static void _simix_cfg_cb__cpu_model(const char *name, int pos)
36 {
37   char *val;
38
39   xbt_assert0(_simix_init_status < 2,
40               "Cannot change the model after the initialization");
41
42   val = xbt_cfg_get_string(_simix_cfg_set, name);
43   /* New Module missing */
44   find_model_description(surf_cpu_model_description,
45                             surf_cpu_model_description_size, val);
46 }
47
48 /* callback of the workstation_model variable */
49 static void _simix_cfg_cb__network_model(const char *name, int pos)
50 {
51   char *val;
52
53   xbt_assert0(_simix_init_status < 2,
54               "Cannot change the model after the initialization");
55
56   val = xbt_cfg_get_string(_simix_cfg_set, name);
57   /* New Module missing */
58   find_model_description(surf_network_model_description,
59                             surf_network_model_description_size, val);
60 }
61
62 /* create the config set and register what should be */
63 void simix_config_init(void)
64 {
65
66   if (_simix_init_status)
67     return;                     /* Already inited, nothing to do */
68
69   _simix_init_status = 1;
70   _simix_cfg_set = xbt_cfg_new();
71
72   xbt_cfg_register(_simix_cfg_set,
73                    "workstation_model", xbt_cfgelm_string, 1, 1,
74                    &_simix_cfg_cb__workstation_model, NULL);
75
76   xbt_cfg_register(_simix_cfg_set,
77                    "cpu_model", xbt_cfgelm_string, 1, 1,
78                    &_simix_cfg_cb__cpu_model, NULL);
79   xbt_cfg_register(_simix_cfg_set,
80                    "network_model", xbt_cfgelm_string, 1, 1,
81                    &_simix_cfg_cb__network_model, NULL);
82
83   xbt_cfg_set_string(_simix_cfg_set, "workstation_model", "KCCFLN05");
84 }
85
86 void simix_config_finalize(void)
87 {
88
89   if (!_simix_init_status)
90     return;                     /* Not initialized yet. Nothing to do */
91
92   xbt_cfg_free(&_simix_cfg_set);
93   _simix_init_status = 0;
94 }
95
96 /** \brief Set a configuration variable
97  * 
98  * FIXME
99
100  * Currently existing configuration variable:
101  *   - workstation_model (string): Model of workstation to use.  
102  *     Possible values (defaults to "KCCFLN05"):
103  *     - "CLM03": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + support for parallel tasks
104  *     - "KCCFLN05": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file.
105  *     - compound 
106  *      \param name Configuration variable name that will change.
107  *      \param pa A va_list with the others parameters
108  */
109 void SIMIX_config(const char *name, va_list pa)
110 {
111   if (!_simix_init_status) {
112     simix_config_init();
113   }
114   xbt_cfg_set_vargs(_simix_cfg_set, name, pa);
115 }