Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update workstation handling in SimDag. Change the prefix of SimDag functions with...
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 16 Jun 2006 13:32:52 +0000 (13:32 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 16 Jun 2006 13:32:52 +0000 (13:32 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2384 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/simdag/datatypes.h
include/simdag/simdag.h
src/simdag/private.h
src/simdag/sd_global.c
src/simdag/sd_link.c
src/simdag/sd_task.c
src/simdag/sd_workstation.c

index 1b1ad0b..78b64b6 100644 (file)
@@ -2,46 +2,42 @@
 #define SIMDAG_DATATYPES_H
 
 /* Link */
 #define SIMDAG_DATATYPES_H
 
 /* Link */
-typedef struct SG_link_data *SG_link_data_t;
+typedef struct SD_link_data *SD_link_data_t;
 
 
-typedef struct SG_link {
-  SG_link_data_t sgdata; /* SG internal data */
+typedef struct SD_link {
+  SD_link_data_t sd_data; /* SD internal data */
   void *data; /* user data */
   char *name;
 
   /*double capacity;*/
   /*double current_bandwidth;
     double current_latency;*/
   void *data; /* user data */
   char *name;
 
   /*double capacity;*/
   /*double current_bandwidth;
     double current_latency;*/
-} s_SG_link_t, *SG_link_t;
+} s_SD_link_t, *SD_link_t;
 
 /* Workstation */
 
 /* Workstation */
-typedef struct SG_workstation_data *SG_workstation_data_t;
+typedef struct SD_workstation_data *SD_workstation_data_t;
 
 
-typedef struct SG_workstation {
-  SG_workstation_data_t sgdata; /* SG internal data */
+typedef struct SD_workstation {
+  SD_workstation_data_t sd_data; /* SD internal data */
   void *data; /* user data */
   void *data; /* user data */
-  char *name;
-
-  /*  double power;
-    double available_power;*/
-} s_SG_workstation_t, *SG_workstation_t;
+} s_SD_workstation_t, *SD_workstation_t;
 
 /* Task state */
 typedef enum {
 
 /* Task state */
 typedef enum {
-  SG_SCHEDULED,
-  SG_RUNNING,
-  SG_DONE,
-  SG_FAILED
-} SG_task_state_t;
+  SD_SCHEDULED,
+  SD_RUNNING,
+  SD_DONE,
+  SD_FAILED
+} SD_task_state_t;
 
 /* Task */
 
 /* Task */
-typedef struct SG_task {
+typedef struct SD_task {
   void *data;
   char *name;
   /*double amount;
     double remaining_amount;*/
   void *data;
   char *name;
   /*double amount;
     double remaining_amount;*/
-  SG_task_state_t state;
+  SD_task_state_t state;
   /* TODO: dependencies + watch */
   /* TODO: dependencies + watch */
-} s_SG_task_t, *SG_task_t;
+} s_SD_task_t, *SD_task_t;
 
 #endif
 
 #endif
index 609f689..f32f330 100644 (file)
@@ -8,69 +8,69 @@ SG_BEGIN_DECL()
 
 /************************** Link handling ***********************************/
 
 
 /************************** Link handling ***********************************/
 
-/* private (called by SG_environment_create)
-SG_link_t    SG_link_create(void *data, const char *name,
+/* private (called by SD_environment_create)
+SD_link_t    SD_link_create(void *data, const char *name,
 double bandwidth, double latency);*/
 double bandwidth, double latency);*/
-void*        SG_link_get_data(SG_link_t link);
-void         SG_link_set_data(SG_link_t link, void *data);
-const char*  SG_link_get_name(SG_link_t link);
-double       SG_link_get_capacity(SG_link_t link);
-double       SG_link_get_current_bandwidth(SG_link_t link);
-double       SG_link_get_current_latency(SG_link_t link);
-/* private (called by SG_clean)
-void         SG_link_destroy(SG_link_t link);
+void*        SD_link_get_data(SD_link_t link);
+void         SD_link_set_data(SD_link_t link, void *data);
+const char*  SD_link_get_name(SD_link_t link);
+double       SD_link_get_capacity(SD_link_t link);
+double       SD_link_get_current_bandwidth(SD_link_t link);
+double       SD_link_get_current_latency(SD_link_t link);
+/* private (called by SD_clean)
+void         SD_link_destroy(SD_link_t link);
 */
 
 /************************** Workstation handling ****************************/
 
 */
 
 /************************** Workstation handling ****************************/
 
-/* private (called by SG_environment_create)
-SG_workstation_t   SG_workstation_create(void *data, const char *name, double power,
+/* private (called by SD_environment_create)
+SD_workstation_t   SD_workstation_create(void *data, const char *name, double power,
   double available_power);*/
   double available_power);*/
-SG_workstation_t   SG_workstation_get_by_name(const char *name);
-SG_workstation_t*  SG_workstation_get_list(void);
-int                SG_workstation_get_number(void);
-void               SG_workstation_set_data(SG_workstation_t workstation, void *data);
-void*              SG_workstation_get_data(SG_workstation_t workstation);
-const char*        SG_workstation_get_name(SG_workstation_t workstation);
-SG_link_t*         SG_workstation_route_get_list(SG_workstation_t src, SG_workstation_t dst);
-int                SG_workstation_route_get_size(SG_workstation_t src, SG_workstation_t dst);
-double             SG_workstation_get_power(SG_workstation_t workstation);
-double             SG_workstation_get_available_power(SG_workstation_t workstation);
-/* private (called by SG_clean)
-void               SG_workstation_destroy(SG_workstation_t workstation);
+SD_workstation_t   SD_workstation_get_by_name(const char *name);
+SD_workstation_t*  SD_workstation_get_list(void);
+int                SD_workstation_get_number(void);
+void               SD_workstation_set_data(SD_workstation_t workstation, void *data);
+void*              SD_workstation_get_data(SD_workstation_t workstation);
+const char*        SD_workstation_get_name(SD_workstation_t workstation);
+SD_link_t*         SD_workstation_route_get_list(SD_workstation_t src, SD_workstation_t dst);
+int                SD_workstation_route_get_size(SD_workstation_t src, SD_workstation_t dst);
+double             SD_workstation_get_power(SD_workstation_t workstation);
+double             SD_workstation_get_available_power(SD_workstation_t workstation);
+/* private (called by SD_clean)
+void               SD_workstation_destroy(SD_workstation_t workstation);
 */
 
 /************************** Task handling ************************************/
 
 */
 
 /************************** Task handling ************************************/
 
-SG_task_t         SG_task_create(const char *name, void *data, double amount);
-int               SG_task_schedule(SG_task_t task, int workstation_nb,
-                                  SG_workstation_t **workstation_list, double *computation_amount,
+SD_task_t         SD_task_create(const char *name, void *data, double amount);
+int               SD_task_schedule(SD_task_t task, int workstation_nb,
+                                  SD_workstation_t **workstation_list, double *computation_amount,
                                   double *communication_amount, double rate);
 
                                   double *communication_amount, double rate);
 
-void*             SG_task_get_data(SG_task_t task);
-void              SG_task_set_data(SG_task_t task, void *data);
-const char*       SG_task_get_name(SG_task_t task);
-double            SG_task_get_amount(SG_task_t task);
-double            SG_task_get_remaining_amount(SG_task_t task);
-void              SG_task_dependency_add(const char *name, void *data, SG_task_t src, SG_task_t dst);
-void              SG_task_dependency_remove(SG_task_t src, SG_task_t dst); 
-SG_task_state_t   SG_task_get_state(SG_task_t task);
-/* SG_task_state_t can be either SG_SCHEDULED, SG_RUNNING, SG_DONE, or SG_FAILED */
+void*             SD_task_get_data(SD_task_t task);
+void              SD_task_set_data(SD_task_t task, void *data);
+const char*       SD_task_get_name(SD_task_t task);
+double            SD_task_get_amount(SD_task_t task);
+double            SD_task_get_remaining_amount(SD_task_t task);
+void              SD_task_dependency_add(const char *name, void *data, SD_task_t src, SD_task_t dst);
+void              SD_task_dependency_remove(SD_task_t src, SD_task_t dst); 
+SD_task_state_t   SD_task_get_state(SD_task_t task);
+/* SD_task_state_t can be either SD_SCHEDULED, SD_RUNNING, SD_DONE, or SD_FAILED */
 
 
-void              SG_task_watch(SG_task_t task, SG_task_state_t state);
-/* SG_simulate will stop as soon as the state of this task is the one given in argument.
+void              SD_task_watch(SD_task_t task, SD_task_state_t state);
+/* SD_simulate will stop as soon as the state of this task is the one given in argument.
    Watch-point is then automatically removed */
 
    Watch-point is then automatically removed */
 
-void              SG_task_unwatch(SG_task_t task, SG_task_state_t state);
-void              SG_task_unschedule(SG_task_t task); /* change state and rerun */
-void              SG_task_destroy(SG_task_t task);
+void              SD_task_unwatch(SD_task_t task, SD_task_state_t state);
+void              SD_task_unschedule(SD_task_t task); /* change state and rerun */
+void              SD_task_destroy(SD_task_t task);
 
 /************************** Global *******************************************/
 
 
 /************************** Global *******************************************/
 
-void              SG_init(int *argc, char **argv);
-void              SG_create_environment(const char *platform_file);
-SG_task_t         *SG_simulate(double how_long); /* returns a NULL-terminated array of SG_task_t whose state has changed */
-void              SG_clean(); /* cleans everything */
+void              SD_init(int *argc, char **argv);
+void              SD_create_environment(const char *platform_file);
+SD_task_t         *SD_simulate(double how_long); /* returns a NULL-terminated array of SD_task_t whose state has changed */
+void              SD_clean(); /* cleans everything */
 
 SG_END_DECL()
 
 
 SG_END_DECL()
 
index c86ff69..cd71a5a 100644 (file)
@@ -5,33 +5,35 @@
 #include "simdag/simdag.h"
 #include "simdag/datatypes.h"
 
 #include "simdag/simdag.h"
 #include "simdag/datatypes.h"
 
+#define CHECK_INIT_DONE() xbt_assert0(sd_global != NULL, "SD_init not called yet")
+
 /* Global variables */
 
 /* Global variables */
 
-typedef struct SG_global {
+typedef struct SD_global {
   xbt_dict_t workstations; /* workstation list */
   int workstation_count; /* number of workstations */
   xbt_dict_t workstations; /* workstation list */
   int workstation_count; /* number of workstations */
-} s_SG_global_t, *SG_global_t;
+} s_SD_global_t, *SD_global_t;
 
 
-extern SG_global_t sg_global;
+extern SD_global_t sd_global;
 
 /* Link private data */
 
 /* Link private data */
-typedef struct SG_link_data {
+typedef struct SD_link_data {
   void* surf_link; /* surf object */
 
   void* surf_link; /* surf object */
 
-} s_SG_link_data_t;
+} s_SD_link_data_t;
 
 /* Workstation private data */
 
 /* Workstation private data */
-typedef struct SG_workstation_data {
+typedef struct SD_workstation_data {
   void* surf_workstation; /* surf object */
   /* TODO: route */
   void* surf_workstation; /* surf object */
   /* TODO: route */
-} s_SG_workstation_data_t;
+} s_SD_workstation_data_t;
 
 /* Private functions */
 
 
 /* Private functions */
 
-SG_link_t __SG_link_create(const char *name, void *surf_link, void *data);
-void __SG_link_destroy(SG_link_t link);
+SD_link_t __SD_link_create(const char *name, void *surf_link, void *data);
+void __SD_link_destroy(SD_link_t link);
 
 
-SG_workstation_t __SG_workstation_create(const char *name, void *surf_workstation, void *data);
-void __SG_workstation_destroy(SG_workstation_t workstation);
+SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data);
+void __SD_workstation_destroy(SD_workstation_t workstation);
 
 #endif
 
 #endif
index 89edfed..afc5da5 100644 (file)
@@ -4,71 +4,64 @@
 #include "xbt/sysdep.h"
 #include "surf/surf.h"
 
 #include "xbt/sysdep.h"
 #include "surf/surf.h"
 
-#define CHECK_INIT_DONE() xbt_assert0(init_done, "SG_init not called yet")
+SD_global_t sd_global = NULL;
 
 
-SG_global_t sg_global = NULL;
-
-static int init_done = 0;
-
-/* Initialises SG internal data. This function should be called before any other SG function.
+/* Initialises SD internal data. This function should be called before any other SD function.
  */
  */
-void SG_init(int *argc, char **argv) {
-  xbt_assert0(!init_done, "SG_init already called");
+void SD_init(int *argc, char **argv) {
+  xbt_assert0(sd_global == NULL, "SD_init already called");
 
 
-  sg_global = xbt_new0(s_SG_global_t, 1);
-  sg_global->workstations = xbt_dict_new();
-  sg_global->workstation_count = 0;
+  sd_global = xbt_new0(s_SD_global_t, 1);
+  sd_global->workstations = xbt_dict_new();
+  sd_global->workstation_count = 0;
 
   surf_init(argc, argv);
 
   surf_init(argc, argv);
-
-  init_done = 1;
 }
 
 /* Creates the environnement described in a xml file of a platform descriptions.
  */
 }
 
 /* Creates the environnement described in a xml file of a platform descriptions.
  */
-void SG_create_environment(const char *platform_file) {
+void SD_create_environment(const char *platform_file) {
   xbt_dict_cursor_t cursor = NULL;
   char *name = NULL;
   xbt_dict_cursor_t cursor = NULL;
   char *name = NULL;
-  void *workstation = NULL;
+  void *surf_workstation = NULL;
 
   CHECK_INIT_DONE();
   surf_timer_resource_init(platform_file);
   surf_workstation_resource_init_KCCFLN05(platform_file); /* tell Surf to create the environnement */
 
 
   CHECK_INIT_DONE();
   surf_timer_resource_init(platform_file);
   surf_workstation_resource_init_KCCFLN05(platform_file); /* tell Surf to create the environnement */
 
-  /* now let's create the SG wrappers */
-  xbt_dict_foreach(workstation_set, cursor, name, workstation) {
-    __SG_workstation_create(name, workstation, NULL);
+  /* now let's create the SD wrappers */
+  xbt_dict_foreach(workstation_set, cursor, name, surf_workstation) {
+    __SD_workstation_create(surf_workstation, NULL);
   }
 }
 
   }
 }
 
-/* Launches the simulation. Returns a NULL-terminated array of SG_task_t whose state has changed.
+/* Launches the simulation. Returns a NULL-terminated array of SD_task_t whose state has changed.
  */
  */
-SG_task_t* SG_simulate(double how_long)
+SD_task_t* SD_simulate(double how_long)
 {
   /* TODO */
 
 {
   /* TODO */
 
-  /* temporary test to access to the surf workstation structure */
+  /* temporary test to explore the workstations */
   xbt_dict_cursor_t cursor = NULL;
   char *name = NULL;
   xbt_dict_cursor_t cursor = NULL;
   char *name = NULL;
-  void *workstation = NULL;
-  const char *surf_name;
-  int speed;
+  SD_workstation_t workstation = NULL;
+  double power;
 
 
-  xbt_dict_foreach(workstation_set, cursor, name, workstation) {
-    surf_name = surf_workstation_resource->common_public->get_resource_name(workstation);
-    speed = surf_workstation_resource->extension_public->get_speed(workstation, 1.0);
-    printf("Workstation name: %s, Surf name: %s, speed: %d\n", name, surf_name, speed);
+  xbt_dict_foreach(sd_global->workstations, cursor, name, workstation) {
+    power = SD_workstation_get_power(workstation);
+    printf("Workstation name: %s, power: %f Mflop/s\n", name, power);
   }
   }
+  /* TODO: remove name from SD workstation structure */
 
   return NULL;
 }
 
 
   return NULL;
 }
 
-/* Destroys all SG data. This function should be called when the simulation is over.
+/* Destroys all SD data. This function should be called when the simulation is over.
  */
  */
-void SG_clean() {
-  if (init_done) {
-    xbt_dict_free(&sg_global->workstations);
-    xbt_free(sg_global);
+void SD_clean() {
+  if (sd_global != NULL) {
+    xbt_dict_free(&sd_global->workstations);
+    xbt_free(sd_global);
     surf_exit();
     /* TODO: destroy the workstations, the links and the tasks */
   }
     surf_exit();
     /* TODO: destroy the workstations, the links and the tasks */
   }
index e130213..424ebc3 100644 (file)
@@ -4,15 +4,15 @@
 
 /* Creates a link.
  */
 
 /* Creates a link.
  */
-SG_link_t __SG_link_create(const char *name, void *surf_link, void *data) {
+SD_link_t __SD_link_create(const char *name, void *surf_link, void *data) {
   xbt_assert0(surf_link != NULL, "surf_link is NULL !");
   xbt_assert0(surf_link != NULL, "surf_link is NULL !");
-  SG_link_data_t sgdata = xbt_new0(s_SG_link_data_t, 1); /* link private data */
-  sgdata->surf_link = surf_link;
+  SD_link_data_t sd_data = xbt_new0(s_SD_link_data_t, 1); /* link private data */
+  sd_data->surf_link = surf_link;
 
 
-  SG_link_t link = xbt_new0(s_SG_link_t, 1);
+  SD_link_t link = xbt_new0(s_SD_link_t, 1);
   link->name = xbt_strdup(name);
   link->data = data;
   link->name = xbt_strdup(name);
   link->data = data;
-  link->sgdata = sgdata;
+  link->sd_data = sd_data;
 
   /*link->capacity = capacity;*/
   /* link->current_bandwidth = bandwidth;
 
   /*link->capacity = capacity;*/
   /* link->current_bandwidth = bandwidth;
@@ -23,21 +23,21 @@ SG_link_t __SG_link_create(const char *name, void *surf_link, void *data) {
 
 /* Returns the user data of a link. The user data can be NULL.
  */
 
 /* Returns the user data of a link. The user data can be NULL.
  */
-void* SG_link_get_data(SG_link_t link) {
+void* SD_link_get_data(SD_link_t link) {
   xbt_assert0(link, "Invalid parameter");
   return link->data;
 }
 
 /* Sets the user data of a link. The new data can be NULL. The old data should have been freed first if it was not NULL.
  */
   xbt_assert0(link, "Invalid parameter");
   return link->data;
 }
 
 /* Sets the user data of a link. The new data can be NULL. The old data should have been freed first if it was not NULL.
  */
-void SG_link_set_data(SG_link_t link, void *data) {
+void SD_link_set_data(SD_link_t link, void *data) {
   xbt_assert0(link, "Invalid parameter");
   link->data = data;
 }
 
 /* Returns the name of a link. The name can be NULL.
  */
   xbt_assert0(link, "Invalid parameter");
   link->data = data;
 }
 
 /* Returns the name of a link. The name can be NULL.
  */
-const char* SG_link_get_name(SG_link_t link) {
+const char* SD_link_get_name(SD_link_t link) {
   xbt_assert0(link, "Invalid parameter");
   return link->name;
 }
   xbt_assert0(link, "Invalid parameter");
   return link->name;
 }
@@ -45,14 +45,14 @@ const char* SG_link_get_name(SG_link_t link) {
 /* Returns the capacity of a link.
  */
 /*
 /* Returns the capacity of a link.
  */
 /*
-double SG_link_get_capacity(SG_link_t link) {
+double SD_link_get_capacity(SD_link_t link) {
   xbt_assert0(link, "Invalid parameter");
   return link->capacity;
 }*/
 
 /* Return the current bandwidth of a link.
  */
   xbt_assert0(link, "Invalid parameter");
   return link->capacity;
 }*/
 
 /* Return the current bandwidth of a link.
  */
-double SG_link_get_current_bandwidth(SG_link_t link) {
+double SD_link_get_current_bandwidth(SD_link_t link) {
   xbt_assert0(link, "Invalid parameter");
 
   /* TODO */
   xbt_assert0(link, "Invalid parameter");
 
   /* TODO */
@@ -62,7 +62,7 @@ double SG_link_get_current_bandwidth(SG_link_t link) {
 
 /* Return the current latency of a link.
  */
 
 /* Return the current latency of a link.
  */
-double SG_link_get_current_latency(SG_link_t link) {
+double SD_link_get_current_latency(SD_link_t link) {
   xbt_assert0(link, "Invalid parameter");
 
   /* TODO */
   xbt_assert0(link, "Invalid parameter");
 
   /* TODO */
@@ -72,11 +72,11 @@ double SG_link_get_current_latency(SG_link_t link) {
 
 /* Destroys a link. The user data (if any) should have been destroyed first.
  */
 
 /* Destroys a link. The user data (if any) should have been destroyed first.
  */
-void __SG_link_destroy(SG_link_t link) {
+void __SD_link_destroy(SD_link_t link) {
   xbt_assert0(link, "Invalid parameter");
 
   xbt_assert0(link, "Invalid parameter");
 
-  if (link->sgdata != NULL)
-    xbt_free(link->sgdata);
+  if (link->sd_data != NULL)
+    xbt_free(link->sd_data);
   
   if (link->name != NULL)
     xbt_free(link->name);
   
   if (link->name != NULL)
     xbt_free(link->name);
index 3a22af5..2a8dac0 100644 (file)
@@ -3,17 +3,17 @@
 
 /* Creates a task.
  */
 
 /* Creates a task.
  */
-SG_task_t SG_task_create(const char *name, void *data, double amount) {
+SD_task_t SD_task_create(const char *name, void *data, double amount) {
 
   xbt_assert0(amount >= 0, "Invalid parameter"); /* or amount > 0 ? */
 
 
   xbt_assert0(amount >= 0, "Invalid parameter"); /* or amount > 0 ? */
 
-  SG_task_t task = xbt_new0(s_SG_task_t, 1);
+  SD_task_t task = xbt_new0(s_SD_task_t, 1);
   
   task->data = data;
   task->name = xbt_strdup(name);
   /*task->amount = amount;
     task->remaining_amount = amount;*/
   
   task->data = data;
   task->name = xbt_strdup(name);
   /*task->amount = amount;
     task->remaining_amount = amount;*/
-  task->state = SG_SCHEDULED; /* not sure... should we add a state SG_NOT_SCHEDULED? */
+  task->state = SD_SCHEDULED; /* not sure... should we add a state SD_NOT_SCHEDULED? */
   /* TODO: dependencies + watch */
 
   return task;
   /* TODO: dependencies + watch */
 
   return task;
@@ -21,8 +21,8 @@ SG_task_t SG_task_create(const char *name, void *data, double amount) {
 
 /* Schedules a task.
  */
 
 /* Schedules a task.
  */
-int SG_task_schedule(SG_task_t task, int workstation_nb,
-                    SG_workstation_t **workstation_list, double *computation_amount,
+int SD_task_schedule(SD_task_t task, int workstation_nb,
+                    SD_workstation_t **workstation_list, double *computation_amount,
                     double *communication_amount, double rate) {
   xbt_assert0(task, "Invalid parameter");
   /* TODO */
                     double *communication_amount, double rate) {
   xbt_assert0(task, "Invalid parameter");
   /* TODO */
@@ -32,28 +32,28 @@ int SG_task_schedule(SG_task_t task, int workstation_nb,
 
 /* Returns the data of a task.
  */
 
 /* Returns the data of a task.
  */
-void* SG_task_get_data(SG_task_t task) {
+void* SD_task_get_data(SD_task_t task) {
   xbt_assert0(task, "Invalid parameter");
   return task->data;
 }
 
 /* Sets the data of a task.
  */
   xbt_assert0(task, "Invalid parameter");
   return task->data;
 }
 
 /* Sets the data of a task.
  */
-void SG_task_set_data(SG_task_t task, void *data) {
+void SD_task_set_data(SD_task_t task, void *data) {
   xbt_assert0(task, "Invalid parameter");
   task->data = data;
 }
 
 /* Returns the name of a task.
  */
   xbt_assert0(task, "Invalid parameter");
   task->data = data;
 }
 
 /* Returns the name of a task.
  */
-const char* SG_task_get_name(SG_task_t task) {
+const char* SD_task_get_name(SD_task_t task) {
   xbt_assert0(task, "Invalid parameter");
   return task->name;
 }
 
 /* Returns the computing amount of a task.
  */
   xbt_assert0(task, "Invalid parameter");
   return task->name;
 }
 
 /* Returns the computing amount of a task.
  */
-double SG_task_get_amount(SG_task_t task) {
+double SD_task_get_amount(SD_task_t task) {
   xbt_assert0(task, "Invalid parameter");
 
   /* TODO */
   xbt_assert0(task, "Invalid parameter");
 
   /* TODO */
@@ -63,7 +63,7 @@ double SG_task_get_amount(SG_task_t task) {
 
 /* Returns the remaining computing amount of a task.
  */
 
 /* Returns the remaining computing amount of a task.
  */
-double SG_task_get_remaining_amount(SG_task_t task) {
+double SD_task_get_remaining_amount(SD_task_t task) {
   xbt_assert0(task, "Invalid parameter")
 
   /* TODO (surf encapsulation) */;
   xbt_assert0(task, "Invalid parameter")
 
   /* TODO (surf encapsulation) */;
@@ -72,37 +72,37 @@ double SG_task_get_remaining_amount(SG_task_t task) {
 
 /* Adds a dependency between two tasks.
  */
 
 /* Adds a dependency between two tasks.
  */
-void SG_task_dependency_add(const char *name, void *data, SG_task_t src, SG_task_t dst) {
+void SD_task_dependency_add(const char *name, void *data, SD_task_t src, SD_task_t dst) {
   xbt_assert0(src != NULL && dst != NULL, "Invalid parameter");
   /* TODO */
 }
 
 /* Removes a dependency between two tasks.
  */
   xbt_assert0(src != NULL && dst != NULL, "Invalid parameter");
   /* TODO */
 }
 
 /* Removes a dependency between two tasks.
  */
-void SG_task_dependency_remove(SG_task_t src, SG_task_t dst) {
+void SD_task_dependency_remove(SD_task_t src, SD_task_t dst) {
   xbt_assert0(src != NULL && dst != NULL, "Invalid parameter");
   /* TODO */
 }
 
   xbt_assert0(src != NULL && dst != NULL, "Invalid parameter");
   /* TODO */
 }
 
-/* Returns the state of a task: SG_SCHEDULED, SG_RUNNING, SG_DONE or SG_FAILED.
+/* Returns the state of a task: SD_SCHEDULED, SD_RUNNING, SD_DONE or SD_FAILED.
  */
  */
-SG_task_state_t SG_task_get_state(SG_task_t task) {
+SD_task_state_t SD_task_get_state(SD_task_t task) {
   xbt_assert0(task, "Invalid parameter");
   return task->state;
 }
 
 /* Adds a watch point to a task.
   xbt_assert0(task, "Invalid parameter");
   return task->state;
 }
 
 /* Adds a watch point to a task.
-   SG_simulate will stop as soon as the state of this task is the one given in argument.
+   SD_simulate will stop as soon as the state of this task is the one given in argument.
    Watch point is then automatically removed.
  */
    Watch point is then automatically removed.
  */
-void  SG_task_watch(SG_task_t task, SG_task_state_t state) {
+void  SD_task_watch(SD_task_t task, SD_task_state_t state) {
   xbt_assert0(task, "Invalid parameter");
   /* TODO */
 }
 
 /* Removes a watch point from a task.
  */
   xbt_assert0(task, "Invalid parameter");
   /* TODO */
 }
 
 /* Removes a watch point from a task.
  */
-void SG_task_unwatch(SG_task_t task, SG_task_state_t state) {
+void SD_task_unwatch(SD_task_t task, SD_task_state_t state) {
   xbt_assert0(task, "Invalid parameter");
   /* TODO */
 }
   xbt_assert0(task, "Invalid parameter");
   /* TODO */
 }
@@ -110,14 +110,14 @@ void SG_task_unwatch(SG_task_t task, SG_task_state_t state) {
 /* Unschedules a task.
    Change state and rerun
  */
 /* Unschedules a task.
    Change state and rerun
  */
-void SG_task_unschedule(SG_task_t task) {
+void SD_task_unschedule(SD_task_t task) {
   xbt_assert0(task, "Invalid parameter");
   /* TODO */
 }
 
 /* Destroys a task. The user data (if any) should have been destroyed first.
  */
   xbt_assert0(task, "Invalid parameter");
   /* TODO */
 }
 
 /* Destroys a task. The user data (if any) should have been destroyed first.
  */
-void SG_task_destroy(SG_task_t task) {
+void SD_task_destroy(SD_task_t task) {
   if (task->name)
     xbt_free(task->name);
 
   if (task->name)
     xbt_free(task->name);
 
index 0c3ab6e..f2c7afe 100644 (file)
@@ -2,47 +2,51 @@
 #include "simdag/simdag.h"
 #include "xbt/dict.h"
 #include "xbt/sysdep.h"
 #include "simdag/simdag.h"
 #include "xbt/dict.h"
 #include "xbt/sysdep.h"
+#include "surf/surf.h"
 
 
-/* Creates a workstation and registers it in SG.
+/* Creates a workstation and registers it in SD.
  */
  */
-SG_workstation_t __SG_workstation_create(const char *name, void *surf_workstation, void *data) {
-  SG_workstation_data_t sgdata = xbt_new0(s_SG_workstation_data_t, 1); /* workstation private data */
-  sgdata->surf_workstation = surf_workstation;
+SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data) {
+  CHECK_INIT_DONE();
+
+  SD_workstation_data_t sd_data = xbt_new0(s_SD_workstation_data_t, 1); /* workstation private data */
+  sd_data->surf_workstation = surf_workstation;
   
   
-  SG_workstation_t workstation = xbt_new0(s_SG_workstation_t, 1);
-  workstation->name = xbt_strdup(name);
+  SD_workstation_t workstation = xbt_new0(s_SD_workstation_t, 1);
   workstation->data = data; /* user data */
   workstation->data = data; /* user data */
-  workstation->sgdata = sgdata; /* private data */
+  workstation->sd_data = sd_data; /* private data */
   
   
-  xbt_dict_set(sg_global->workstations, name, workstation, free); /* add the workstation to the dictionary */
+  const char *name = SD_workstation_get_name(workstation);
+  xbt_dict_set(sd_global->workstations, name, workstation, free); /* add the workstation to the dictionary */
 
   /* TODO: route */
 
   /* TODO: route */
-
   return workstation;
 }
 
 /* Returns a workstation given its name, or NULL if there is no such workstation.
  */
   return workstation;
 }
 
 /* Returns a workstation given its name, or NULL if there is no such workstation.
  */
-SG_workstation_t SG_workstation_get_by_name(const char *name) {
-  xbt_assert0(sg_global != NULL, "SG_init not called yet");
+SD_workstation_t SD_workstation_get_by_name(const char *name) {
+  CHECK_INIT_DONE();
+
   xbt_assert0(name != NULL, "Invalid parameter");
 
   xbt_assert0(name != NULL, "Invalid parameter");
 
-  return xbt_dict_get_or_null(sg_global->workstations, name);
+  return xbt_dict_get_or_null(sd_global->workstations, name);
 }
 
 /* Returns a NULL-terminated array of existing workstations.
  */
 }
 
 /* Returns a NULL-terminated array of existing workstations.
  */
-SG_workstation_t*  SG_workstation_get_list(void) {
-  xbt_assert0(sg_global != NULL, "SG_init not called yet");
-  SG_workstation_t* array = xbt_new0(SG_workstation_t, sg_global->workstation_count + 1);
+SD_workstation_t*  SD_workstation_get_list(void) {
+  CHECK_INIT_DONE();
+
+  SD_workstation_t* array = xbt_new0(SD_workstation_t, sd_global->workstation_count + 1);
   
   xbt_dict_cursor_t cursor;
   char *key;
   void *data;
   int i=0;
 
   
   xbt_dict_cursor_t cursor;
   char *key;
   void *data;
   int i=0;
 
-  xbt_dict_foreach(sg_global->workstations,cursor,key,data) {
-    array[i++] = (SG_workstation_t) data;
+  xbt_dict_foreach(sd_global->workstations,cursor,key,data) {
+    array[i++] = (SD_workstation_t) data;
   }
   array[i] = NULL;
 
   }
   array[i] = NULL;
 
@@ -51,54 +55,59 @@ SG_workstation_t*  SG_workstation_get_list(void) {
 
 /* Returns the number or workstations.
  */
 
 /* Returns the number or workstations.
  */
-int SG_workstation_get_number(void) {
-  xbt_assert0(sg_global != NULL, "SG_init not called yet");
-  return sg_global->workstation_count;
+int SD_workstation_get_number(void) {
+  CHECK_INIT_DONE();
+  return sd_global->workstation_count;
 }
 
 /* Sets the data of a workstation. The new data can be NULL. The old data should have been freed first if it was not NULL.
  */
 }
 
 /* Sets the data of a workstation. The new data can be NULL. The old data should have been freed first if it was not NULL.
  */
-void SG_workstation_set_data(SG_workstation_t workstation, void *data) {
+void SD_workstation_set_data(SD_workstation_t workstation, void *data) {
+  CHECK_INIT_DONE();
   xbt_assert0(workstation != NULL, "Invalid parameter");
   workstation->data = data;
 }
 
 /* Returns the data of a workstation. The user data can be NULL.
  */
   xbt_assert0(workstation != NULL, "Invalid parameter");
   workstation->data = data;
 }
 
 /* Returns the data of a workstation. The user data can be NULL.
  */
-void* SG_workstation_get_data(SG_workstation_t workstation) {
+void* SD_workstation_get_data(SD_workstation_t workstation) {
+  CHECK_INIT_DONE();
   xbt_assert0(workstation != NULL, "Invalid parameter");
   return workstation->data;
 }
 
 /* Returns the name of a workstation.
  */
   xbt_assert0(workstation != NULL, "Invalid parameter");
   return workstation->data;
 }
 
 /* Returns the name of a workstation.
  */
-const char* SG_workstation_get_name(SG_workstation_t workstation) {
+const char* SD_workstation_get_name(SD_workstation_t workstation) {
+  CHECK_INIT_DONE();
   xbt_assert0(workstation != NULL, "Invalid parameter");
   xbt_assert0(workstation != NULL, "Invalid parameter");
-  return workstation->name;
+  return surf_workstation_resource->common_public->get_resource_name(workstation->sd_data->surf_workstation);
 }
 
 }
 
-SG_link_t* SG_workstation_route_get_list(SG_workstation_t src, SG_workstation_t dst) {
+SD_link_t* SD_workstation_route_get_list(SD_workstation_t src, SD_workstation_t dst) {
+  CHECK_INIT_DONE();
   /* TODO */
   return NULL;
 }
 
   /* TODO */
   return NULL;
 }
 
-int SG_workstation_route_get_size(SG_workstation_t src, SG_workstation_t dst) {
+int SD_workstation_route_get_size(SD_workstation_t src, SD_workstation_t dst) {
+  CHECK_INIT_DONE();
   /* TODO */
   return 0;
 }
 
 /* Returns the total power of a workstation.
  */
   /* TODO */
   return 0;
 }
 
 /* Returns the total power of a workstation.
  */
-double SG_workstation_get_power(SG_workstation_t workstation) {
+double SD_workstation_get_power(SD_workstation_t workstation) {
+  CHECK_INIT_DONE();
   xbt_assert0(workstation != NULL, "Invalid parameter");
   xbt_assert0(workstation != NULL, "Invalid parameter");
-  /* TODO */
-  return 0;
-  /*  return workstation->power;*/
+  return surf_workstation_resource->extension_public->get_speed(workstation->sd_data->surf_workstation, 1.0);
 }
 
 }
 
-/* Return the available power of a workstation.
+/* Returns the proportion of available power in a workstation (normally a number between 0 and 1).
  */
  */
-double SG_workstation_get_available_power(SG_workstation_t workstation) {
+double SD_workstation_get_available_power(SD_workstation_t workstation) {
+  CHECK_INIT_DONE();
   xbt_assert0(workstation != NULL, "Invalid parameter");
   /* TODO */
   return 0;
   xbt_assert0(workstation != NULL, "Invalid parameter");
   /* TODO */
   return 0;
@@ -107,15 +116,12 @@ double SG_workstation_get_available_power(SG_workstation_t workstation) {
 
 /* Destroys a workstation. The user data (if any) should have been destroyed first.
  */
 
 /* Destroys a workstation. The user data (if any) should have been destroyed first.
  */
-void __SG_workstation_destroy(SG_workstation_t workstation) {
+void __SD_workstation_destroy(SD_workstation_t workstation) {
+  CHECK_INIT_DONE();
   xbt_assert0(workstation != NULL, "Invalid parameter");
 
   xbt_assert0(workstation != NULL, "Invalid parameter");
 
-  if (workstation->sgdata != NULL) {
-    xbt_free(workstation->sgdata);
-  }
-  
-  if (workstation->name != NULL) {
-    xbt_free(workstation->name);
+  if (workstation->sd_data != NULL) {
+    xbt_free(workstation->sd_data);
   }
   
   /* TODO: route */
   }
   
   /* TODO: route */