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 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix,
13 "Logging specific to SIMIX (environment)");
15 /********************************* SIMIX **************************************/
18 * \brief A platform constructor.
20 * Creates a new platform, including hosts, links and the
22 * \param file a filename of a xml description of a platform. This file
25 * \include surfxml.dtd
27 * Here is a small example of such a platform
29 * \include small_platform.xml
32 void SIMIX_create_environment(const char *file)
34 xbt_dict_cursor_t cursor = NULL;
36 void *workstation = NULL;
37 char *workstation_model_name;
38 int workstation_id = -1;
40 simix_config_init(); /* make sure that our configuration set is created */
41 surf_timer_resource_init(file);
43 /* which model do you want today? */
44 workstation_model_name = xbt_cfg_get_string (_simix_cfg_set, "workstation_model");
46 DEBUG1("Model : %s", workstation_model_name);
47 workstation_id = find_resource_description(surf_workstation_resource_description,
48 surf_workstation_resource_description_size,
49 workstation_model_name);
50 if(!strcmp(workstation_model_name,"compound")) {
52 char *network_model_name = NULL;
53 char *cpu_model_name = NULL;
58 cpu_model_name = xbt_cfg_get_string (_simix_cfg_set, "cpu_model");
60 if (e.category == bound_error) {
61 xbt_assert0(0,"Set a cpu model to use with the 'compound' workstation model");
69 network_model_name=xbt_cfg_get_string (_simix_cfg_set, "network_model");
71 if (e.category == bound_error) {
72 xbt_assert0(0,"Set a network model to use with the 'compound' workstation model");
79 network_id = find_resource_description(surf_network_resource_description,
80 surf_network_resource_description_size,
82 cpu_id = find_resource_description(surf_cpu_resource_description,
83 surf_cpu_resource_description_size,
86 surf_cpu_resource_description[cpu_id].resource_init(file);
87 surf_network_resource_description[network_id].resource_init(file);
90 surf_workstation_resource_description[workstation_id].resource_init(file);
92 _simix_init_status = 2; /* inited; don't change settings now */
94 xbt_dict_foreach(workstation_set, cursor, name, workstation) {
95 __SIMIX_host_create(name, workstation, NULL);