Logo AND Algorithmique Numérique Distribuée

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