Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a59157040163ba03541e5ee1a060cf18c78cb7b0
[simgrid.git] / src / simix / smx_environment.c
1 /* Copyright (c) 2007-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "smx_private.h"
8 #include "xbt/sysdep.h"
9 #include "xbt/log.h"
10 #include "xbt/xbt_os_time.h"
11 #include "xbt/config.h"
12 #include "surf/surfxml_parse.h"
13
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix,
15                                 "Logging specific to SIMIX (environment)");
16
17 /********************************* SIMIX **************************************/
18
19 /**
20  * \brief A platform constructor.
21  *
22  * Creates a new platform, including hosts, links and the
23  * routing_table.
24  * \param file a filename of a xml description of a platform. This file
25  * follows this DTD :
26  *
27  *     \include surfxml.dtd
28  *
29  * Here is a small example of such a platform
30  *
31  *     \include small_platform.xml
32  *
33  */
34 void SIMIX_create_environment(const char *file)
35 {
36   double start = 0, end = 0;
37   if(XBT_LOG_ISENABLED(simix_environment, xbt_log_priority_debug))
38     start = xbt_os_time();
39   parse_platform_file(file);
40   if(XBT_LOG_ISENABLED(simix_environment, xbt_log_priority_debug))
41     end = xbt_os_time();
42   XBT_DEBUG("PARSE TIME: %g", (end - start));
43
44 }
45
46 void SIMIX_post_create_environment(void) {
47
48   void **host = NULL;
49   void **storage = NULL;
50   xbt_lib_cursor_t cursor = NULL;
51   char *name = NULL;
52
53   /* Create host at SIMIX level */
54   xbt_lib_foreach(host_lib, cursor, name, host) {
55     if(host[SURF_HOST_LEVEL])
56       SIMIX_host_create(name);
57   }
58
59   /* Create storage at SIMIX level */
60   xbt_lib_foreach(storage_lib, cursor, name, storage) {
61     if(storage[SURF_STORAGE_LEVEL])
62       SIMIX_storage_create(name, storage[SURF_STORAGE_LEVEL], NULL);
63   }
64
65   surf_presolve();
66 }