Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b80f238c7ccdd126a3edf73e1c6c03320943478d
[simgrid.git] / src / simix / smx_environment.c
1 /*      $Id$     */
2
3 /* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
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 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix,
13                                 "Logging specific to SIMIX (environment)");
14
15 /********************************* SIMIX **************************************/
16
17 /** 
18  * \brief A platform constructor.
19  *
20  * Creates a new platform, including hosts, links and the
21  * routing_table. 
22  * \param file a filename of a xml description of a platform. This file 
23  * follows this DTD :
24  *
25  *     \include surfxml.dtd
26  *
27  * Here is a small example of such a platform 
28  *
29  *     \include small_platform.xml
30  *
31  */
32 void SIMIX_create_environment(const char *file) 
33 {
34   xbt_dict_cursor_t cursor = NULL;
35   char *name = NULL;
36   void *workstation = NULL;
37   char *workstation_model_name;
38
39   simix_config_init(); /* make sure that our configuration set is created */
40   surf_timer_resource_init(file);
41
42   /* which model do you want today? */
43   workstation_model_name = xbt_cfg_get_string (_simix_cfg_set, "workstation_model");
44
45   DEBUG1("Model : %s", workstation_model_name);
46   if (!strcmp(workstation_model_name,"KCCFLN05")) {
47     surf_workstation_resource_init_KCCFLN05(file);
48 #ifdef HAVE_SDP
49   } else if (!strcmp(workstation_model_name,"SDP")) {
50     surf_workstation_resource_init_KCCFLN05_proportional(file);
51 #endif
52   } else if (!strcmp(workstation_model_name,"Vegas")) {
53     surf_workstation_resource_init_KCCFLN05_Vegas(file);
54   } else if (!strcmp(workstation_model_name,"Reno")) {
55     surf_workstation_resource_init_KCCFLN05_Reno(file);
56   } else if (!strcmp(workstation_model_name,"CLM03")) {
57     surf_workstation_resource_init_CLM03(file);
58 #ifdef HAVE_GTNETS
59   } else if (!strcmp(workstation_model_name,"GTNets")) {
60     surf_workstation_resource_init_GTNETS(file);
61 #endif
62   } else if (!strcmp(workstation_model_name,"compound")) {
63     char *network_model_name = xbt_cfg_get_string (_simix_cfg_set, "network_model");
64     char *cpu_model_name = xbt_cfg_get_string (_simix_cfg_set, "cpu_model");
65     
66     if(!strcmp(cpu_model_name,"Cas01")) {
67       surf_cpu_resource_init_Cas01(file);
68     } else DIE_IMPOSSIBLE;
69
70     if(!strcmp(network_model_name,"CM02")) {
71       surf_network_resource_init_CM02(file);
72 #ifdef HAVE_GTNETS
73     } else if(!strcmp(network_model_name,"GTNets")) {
74       surf_network_resource_init_GTNETS(file);
75 #endif
76     } else if(!strcmp(network_model_name,"Reno")) {
77       surf_network_resource_init_Reno(file);
78     } else if(!strcmp(network_model_name,"Vegas")) {
79       surf_network_resource_init_Vegas(file);
80 #ifdef HAVE_SDP
81     } else if(!strcmp(network_model_name,"SDP")) {
82       surf_network_resource_init_SDP(file);
83 #endif
84     } else
85       DIE_IMPOSSIBLE;
86     
87     surf_workstation_resource_init_compound(file);
88   } else {
89     DIE_IMPOSSIBLE;
90   }
91   _simix_init_status = 2; /* inited; don't change settings now */
92
93   xbt_dict_foreach(workstation_set, cursor, name, workstation) {
94     __SIMIX_host_create(name, workstation, NULL);
95   }
96
97   return;
98 }
99