3 /* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
4 All rights reserved. */
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. */
10 #include "xbt/sysdep.h"
12 #include "xbt/xbt_os_time.h"
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix,
15 "Logging specific to SIMIX (environment)");
17 /********************************* SIMIX **************************************/
20 * \brief A platform constructor.
22 * Creates a new platform, including hosts, links and the
24 * \param file a filename of a xml description of a platform. This file
27 * \include surfxml.dtd
29 * Here is a small example of such a platform
31 * \include small_platform.xml
34 void SIMIX_create_environment(const char *file)
36 xbt_dict_cursor_t cursor = NULL;
38 void *workstation = NULL;
39 char *workstation_model_name;
40 int workstation_id = -1;
43 simix_config_init(); /* make sure that our configuration set is created */
44 surf_timer_model_init(file);
46 /* which model do you want today? */
47 workstation_model_name =
48 xbt_cfg_get_string(_simix_cfg_set, "workstation_model");
50 DEBUG1("Model : %s", workstation_model_name);
52 find_model_description(surf_workstation_model_description,
53 workstation_model_name);
54 if (!strcmp(workstation_model_name, "compound")) {
56 char *network_model_name = NULL;
57 char *cpu_model_name = NULL;
62 cpu_model_name = xbt_cfg_get_string(_simix_cfg_set, "cpu_model");
64 if (e.category == bound_error) {
66 "Set a cpu model to use with the 'compound' workstation model");
75 xbt_cfg_get_string(_simix_cfg_set, "network_model");
78 if (e.category == bound_error) {
80 "Set a network model to use with the 'compound' workstation model");
88 find_model_description(surf_network_model_description,
91 find_model_description(surf_cpu_model_description,
94 surf_cpu_model_description[cpu_id].model_init(file);
95 surf_network_model_description[network_id].model_init(file);
99 surf_workstation_model_description[workstation_id].
102 start = xbt_os_time();
103 parse_platform_file(file);
105 if (surf_workstation_model_description[workstation_id].create_ws != NULL)
106 surf_workstation_model_description[workstation_id].create_ws();
108 DEBUG1("PARSE TIME: %lg", (end-start));
110 _simix_init_status = 2; /* inited; don't change settings now */
112 xbt_dict_foreach(workstation_set, cursor, name, workstation) {
113 __SIMIX_host_create(name, workstation, NULL);