Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
added codes for the GTNetS model.
[simgrid.git] / src / msg / msg_config.c
1 /* $Id$ */
2
3 /* msg_config.c - support for MSG 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 _msg_init_status = 0; /* 0: beginning of time; 
16                              1: pre-inited (cfg_set created); 
17                              2: inited (running) */
18 xbt_cfg_t _msg_cfg_set = NULL;
19
20 /* callback of the surf_workstation_model variable */
21 static void _msg_cfg_cb__surf_workstation_model(const char *name, int pos) {
22   char *val;
23
24   xbt_assert0(_msg_init_status<2, "Cannot change the model after the initialization");
25   
26   val = xbt_cfg_get_string (_msg_cfg_set, name);
27
28 #ifdef USE_GTNETS
29   xbt_assert1(!strcmp(val, "CLM03") ||
30               !strcmp(val, "KCCFLN05") ||
31               !strcmp(val, "GTNETS"),
32               "Unknown workstation model: %s (either 'CLM03', 'KCCFLN05', or 'GTNETS'",val);
33 #else
34   xbt_assert1(!strcmp(val, "CLM03") ||
35               !strcmp(val, "KCCFLN05"),
36               "Unknown workstation model: %s (either 'CLM03' or 'KCCFLN05'",val);
37 #endif
38
39 }
40
41 /* create the config set and register what should be */
42 void msg_config_init(void) {
43
44   if (_msg_init_status) 
45     return; /* Already inited, nothing to do */
46
47   _msg_init_status = 1;
48   _msg_cfg_set = xbt_cfg_new();
49   
50   xbt_cfg_register (_msg_cfg_set, 
51                     "surf_workstation_model", xbt_cfgelm_string, 1,1,
52                     &_msg_cfg_cb__surf_workstation_model,NULL);
53                     
54   xbt_cfg_set_string(_msg_cfg_set,"surf_workstation_model", "KCCFLN05");
55 }
56
57 void msg_config_finalize(void) {
58
59   if (!_msg_init_status) 
60     return; /* Not initialized yet. Nothing to do */
61
62   xbt_cfg_free(&_msg_cfg_set);
63   _msg_init_status = 0;
64 }
65
66 /** \brief set a configuration variable
67  * 
68  * Currently existing configuation variable:
69  *   - surf_workstation_model (string): Model of workstation to use.  
70  *     Possible values (defaults to "KCCFLN05"):
71  *     - "CLM03": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + support for parallel tasks
72  *     - "KCCFLN05": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03]) + failure handling + interference between communications and computations if precised in the platform file.
73  * 
74  * Example:
75  * MSG_config("surf_workstation_model","KCCFLN05");
76  */
77 void
78 MSG_config(const char *name, ...) {
79   va_list pa;
80     
81   if (!_msg_init_status) {
82     msg_config_init();
83   }
84   /*  xbt_cfg_dump("msg_cfg_set","",_msg_cfg_set);*/
85   va_start(pa,name);
86   xbt_cfg_set_vargs(_msg_cfg_set,name,pa);
87   va_end(pa);
88
89 }