Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
added "#include "gras_config.h"" for USE_GTNETS
[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  *    \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Platforms and Applications" --> \endhtmlonly
20  * 
21  */
22
23 /********************************* MSG **************************************/
24
25 /** \ingroup msg_easier_life
26  * \brief A name directory service...
27  *
28  * Finds a m_host_t using its name.
29  * \param name the name of an host.
30  * \return the corresponding host
31  */
32 m_host_t MSG_get_host_by_name(const char *name)
33 {
34   xbt_fifo_item_t i = NULL;
35   m_host_t host = NULL;
36
37   xbt_assert0(((msg_global != NULL)
38           && (msg_global->host != NULL)), "Environment not set yet");
39
40   xbt_fifo_foreach(msg_global->host,i,host,m_host_t) {
41     if(strcmp(host->name, name) == 0) return host;
42   }
43   return NULL;
44 }
45
46 /** \ingroup msg_easier_life
47  * \brief A platform constructor.
48  *
49  * Creates a new platform, including hosts, links and the
50  * routing_table. 
51  * \param file a filename of a xml description of a platform. This file 
52  * follows this DTD :
53  *
54  *     \include surfxml.dtd
55  *
56  * Here is a small example of such a platform 
57  *
58  *     \include small_platform.xml
59  *
60  * Have a look in the directory examples/msg/ to have a big example.
61  */
62 void MSG_create_environment(const char *file) {
63   xbt_dict_cursor_t cursor = NULL;
64   char *name = NULL;
65   void *workstation = NULL;
66   char *workstation_model_name;
67
68   msg_config_init(); /* make sure that our configuration set is created */
69   surf_timer_resource_init(file);
70
71   /* which model do you want today? */
72   workstation_model_name = xbt_cfg_get_string (_msg_cfg_set, "surf_workstation_model");
73
74   DEBUG1("Model : %s", workstation_model_name);
75   if (!strcmp(workstation_model_name,"KCCFLN05")) {
76     surf_workstation_resource_init_KCCFLN05(file);
77   }else if (!strcmp(workstation_model_name,"KCCFLN05_proportional")) {
78     surf_workstation_resource_init_KCCFLN05_proportionnal(file);
79   } else if (!strcmp(workstation_model_name,"CLM03")) {
80     surf_workstation_resource_init_CLM03(file);
81 #ifdef USE_GTNETS
82   } else if (!strcmp(workstation_model_name,"GTNETS")) {
83     surf_workstation_resource_init_GTNETS(file);
84 #endif
85   } else {
86     xbt_assert0(0,"The impossible happened (once again)");
87   }
88   _msg_init_status = 2; /* inited; don't change settings now */
89
90   xbt_dict_foreach(workstation_set, cursor, name, workstation) {
91     __MSG_host_create(name, workstation, NULL);
92   }
93
94   return;
95 }
96