Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update workstation handling in SimDag. Change the prefix of SimDag functions with...
[simgrid.git] / src / simdag / sd_global.c
1 #include "simdag/simdag.h"
2 #include "private.h"
3 #include "xbt/asserts.h"
4 #include "xbt/sysdep.h"
5 #include "surf/surf.h"
6
7 SD_global_t sd_global = NULL;
8
9 /* Initialises SD internal data. This function should be called before any other SD function.
10  */
11 void SD_init(int *argc, char **argv) {
12   xbt_assert0(sd_global == NULL, "SD_init already called");
13
14   sd_global = xbt_new0(s_SD_global_t, 1);
15   sd_global->workstations = xbt_dict_new();
16   sd_global->workstation_count = 0;
17
18   surf_init(argc, argv);
19 }
20
21 /* Creates the environnement described in a xml file of a platform descriptions.
22  */
23 void SD_create_environment(const char *platform_file) {
24   xbt_dict_cursor_t cursor = NULL;
25   char *name = NULL;
26   void *surf_workstation = NULL;
27
28   CHECK_INIT_DONE();
29   surf_timer_resource_init(platform_file);
30   surf_workstation_resource_init_KCCFLN05(platform_file); /* tell Surf to create the environnement */
31
32   /* now let's create the SD wrappers */
33   xbt_dict_foreach(workstation_set, cursor, name, surf_workstation) {
34     __SD_workstation_create(surf_workstation, NULL);
35   }
36 }
37
38 /* Launches the simulation. Returns a NULL-terminated array of SD_task_t whose state has changed.
39  */
40 SD_task_t* SD_simulate(double how_long)
41 {
42   /* TODO */
43
44   /* temporary test to explore the workstations */
45   xbt_dict_cursor_t cursor = NULL;
46   char *name = NULL;
47   SD_workstation_t workstation = NULL;
48   double power;
49
50   xbt_dict_foreach(sd_global->workstations, cursor, name, workstation) {
51     power = SD_workstation_get_power(workstation);
52     printf("Workstation name: %s, power: %f Mflop/s\n", name, power);
53   }
54   /* TODO: remove name from SD workstation structure */
55
56   return NULL;
57 }
58
59 /* Destroys all SD data. This function should be called when the simulation is over.
60  */
61 void SD_clean() {
62   if (sd_global != NULL) {
63     xbt_dict_free(&sd_global->workstations);
64     xbt_free(sd_global);
65     surf_exit();
66     /* TODO: destroy the workstations, the links and the tasks */
67   }
68 }