Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fbc75cedb026254185495eb5b073fe975c71762c
[simgrid.git] / src / msg / environment.c
1 /*      $Id$     */
2
3 /* Copyright (c) 2002,2003,2004 Arnaud Legrand. All rights reserved.        */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include "private.h"
9 #include "xbt/sysdep.h"
10 #include "xbt/log.h"
11 #include "gras_config.h"
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_environment, msg,
13                                 "Logging specific to MSG (environment)");
14
15 /** \defgroup msg_easier_life      Platform and Application management
16  *  \brief This section describes functions to manage the platform creation
17  *  and the application deployment. You should also have a look at 
18  *  \ref MSG_examples  to have an overview of their usage.
19  */
20 /** @addtogroup msg_easier_life
21  *    \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Platforms and Applications" --> \endhtmlonly
22  * 
23  */
24
25 /********************************* MSG **************************************/
26
27 /** \ingroup msg_easier_life
28  * \brief A name directory service...
29  *
30  * Finds a m_host_t using its name.
31  * \param name the name of an host.
32  * \return the corresponding host
33  */
34 m_host_t MSG_get_host_by_name(const char *name)
35 {
36   xbt_fifo_item_t i = NULL;
37   m_host_t host = NULL;
38
39   xbt_assert0(((msg_global != NULL)
40           && (msg_global->host != NULL)), "Environment not set yet");
41
42   xbt_fifo_foreach(msg_global->host,i,host,m_host_t) {
43     if(strcmp(host->name, name) == 0) return host;
44   }
45   return NULL;
46 }
47
48 /** \ingroup msg_easier_life
49  * \brief A platform constructor.
50  *
51  * Creates a new platform, including hosts, links and the
52  * routing_table. 
53  * \param file a filename of a xml description of a platform. This file 
54  * follows this DTD :
55  *
56  *     \include surfxml.dtd
57  *
58  * Here is a small example of such a platform 
59  *
60  *     \include small_platform.xml
61  *
62  * Have a look in the directory examples/msg/ to have a big example.
63  */
64 void MSG_create_environment(const char *file) {
65   xbt_dict_cursor_t cursor = NULL;
66   char *name = NULL;
67   void *workstation = NULL;
68   char *workstation_model_name;
69
70   msg_config_init(); /* make sure that our configuration set is created */
71   surf_timer_resource_init(file);
72
73   /* which model do you want today? */
74   workstation_model_name = xbt_cfg_get_string (_msg_cfg_set, "surf_workstation_model");
75
76   DEBUG1("Model : %s", workstation_model_name);
77   if (!strcmp(workstation_model_name,"KCCFLN05")) {
78     surf_workstation_resource_init_KCCFLN05(file);
79   }else if (!strcmp(workstation_model_name,"KCCFLN05_proportional")) {
80     surf_workstation_resource_init_KCCFLN05_proportionnal(file);
81   } else if (!strcmp(workstation_model_name,"CLM03")) {
82     surf_workstation_resource_init_CLM03(file);
83 #ifdef USE_GTNETS
84   } else if (!strcmp(workstation_model_name,"GTNETS")) {
85     surf_workstation_resource_init_GTNETS(file);
86 #endif
87   } else {
88     xbt_assert0(0,"The impossible happened (once again)");
89   }
90   _msg_init_status = 2; /* inited; don't change settings now */
91
92   xbt_dict_foreach(workstation_set, cursor, name, workstation) {
93     __MSG_host_create(name, workstation, NULL);
94   }
95
96   return;
97 }
98