Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Working on SimDag.
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 14 Jun 2006 12:23:48 +0000 (12:23 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 14 Jun 2006 12:23:48 +0000 (12:23 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2379 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/simdag/datatypes.h
include/simdag/simdag.h
src/simdag/private.h [new file with mode: 0644]
src/simdag/sd_global.c [new file with mode: 0644]
src/simdag/sd_link.c
src/simdag/sd_task.c
src/simdag/sd_workstation.c

index 8b7b4dd..f21af30 100644 (file)
@@ -5,17 +5,17 @@
 typedef struct SG_link {
   void *data;
   char *name;
-  double capacity;
-  double current_bandwidth;
-  double current_latency;
+  /*double capacity;*/
+  /*double current_bandwidth;
+    double current_latency;*/
 } s_SG_link_t, *SG_link_t;
 
 /* Workstation */
 typedef struct SG_workstation {
   void *data;
   char *name;
-  double power;
-  double available_power;
+  /*double power;
+    double available_power;*/
   /* TODO: route */
 } s_SG_workstation_t, *SG_workstation_t;
 
@@ -31,8 +31,8 @@ typedef enum {
 typedef struct SG_task {
   void *data;
   char *name;
-  double amount;
-  double remaining_amount;
+  /*double amount;
+    double remaining_amount;*/
   SG_task_state_t state;
   /* TODO: dependencies + watch */
 } s_SG_task_t, *SG_task_t;
index d377954..90ed019 100644 (file)
@@ -8,8 +8,8 @@ SG_BEGIN_DECL()
 
 /************************** Link handling ***********************************/
 
-SG_link_t    SG_link_create(void *data, const char *name,
-                         double capacity, double bandwidth, double latency);
+SG_link_t    SG_link_create(void *data, const char *name,/* double capacity,*/
+                           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);
@@ -61,7 +61,8 @@ void              SG_task_destroy(SG_task_t task);
 
 /************************** Global *******************************************/
 
-SG_task_t        *SG_simulate(double how_long); /* returns a NULL-terminated array of SG_task_t whose state has changed */
+void              SG_init(int *argc, char **argv);
+SG_task_t         *SG_simulate(double how_long); /* returns a NULL-terminated array of SG_task_t whose state has changed */
 
 SG_END_DECL()
 
diff --git a/src/simdag/private.h b/src/simdag/private.h
new file mode 100644 (file)
index 0000000..e032bdc
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef SIMDAG_PRIVATE_H
+#define SIMDAG_PRIVATE_H
+
+#include "xbt/dict.h"
+
+typedef struct SG_global {
+  xbt_dict_t workstations; /* workstation list */
+  int workstation_count; /* number of workstations */
+} s_SG_global_t, *SG_global_t;
+
+extern SG_global_t sg_global;
+
+#endif
diff --git a/src/simdag/sd_global.c b/src/simdag/sd_global.c
new file mode 100644 (file)
index 0000000..961aa25
--- /dev/null
@@ -0,0 +1,44 @@
+#include "simdag/simdag.h"
+#include "private.h"
+#include "xbt/asserts.h"
+#include "xbt/sysdep.h"
+#include "surf/surf.h"
+
+static int init_done = 0;
+
+/* Initialises SG internal data. This function should be called before any other SG function.
+ */
+void SG_init(int *argc, char **argv) {
+  xbt_assert0(!init_done, "SG_init already called");
+
+  sg_global = xbt_new0(s_SG_global_t, 1);
+  sg_global->workstations = xbt_dict_new();
+  sg_global->workstation_count = 0;
+
+  surf_init(argc, argv);
+
+  init_done = 1;
+}
+
+/* Checks that SG_init has been called.
+ */
+void check_init_done() {
+  xbt_assert0(init_done, "SG_init not called yet");
+}
+
+/* Creates the environnement described in a xml file of a platform descriptions.
+ */
+void SG_create_environnement(const char *platform_file) {
+  check_init_done();
+  surf_timer_resource_init(file);
+  surf_workstation_resource_init_KCCFLN05(file); /* tell Surf to create the environnement */
+}
+
+
+/* Launches the simulation. Returns a NULL-terminated array of SG_task_t whose state has changed.
+ */
+SG_task_t* SG_simulate(double how_long)
+{
+  /* TODO */
+  return NULL;
+}
index 7d59ae0..272ceba 100644 (file)
@@ -3,16 +3,16 @@
 
 /* Creates a link.
  */
-SG_link_t SG_link_create(void *data, const char *name, double capacity, double bandwidth, double latency) {
-  xbt_assert0(capacity >= 0, "Invalid parameter"); /* or capacity > 0 ? */
+SG_link_t SG_link_create(void *data, const char *name,/* double capacity,*/ double bandwidth, double latency) {
+  /*  xbt_assert0(capacity >= 0, "Invalid parameter");*/ /* or capacity > 0 ? */
 
   SG_link_t link = xbt_new0(s_SG_link_t, 1);
 
   link->data = data;
   link->name = xbt_strdup(name);
-  link->capacity = capacity;
-  link->current_bandwidth = bandwidth;
-  link->current_latency = latency;
+  /*link->capacity = capacity;*/
+  /* link->current_bandwidth = bandwidth;
+     link->current_latency = latency;*/
 
   return link;
 }
@@ -40,23 +40,30 @@ const char* SG_link_get_name(SG_link_t link) {
 
 /* Returns the capacity of a link.
  */
+/*
 double SG_link_get_capacity(SG_link_t 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) {
   xbt_assert0(link, "Invalid parameter");
-  return link->current_bandwidth;
+
+  /* TODO */
+  return 0;
+  /*  return link->current_bandwidth;*/
 }
 
 /* Return the current latency of a link.
  */
 double SG_link_get_current_latency(SG_link_t link) {
   xbt_assert0(link, "Invalid parameter");
-  return link->current_latency;
+
+  /* TODO */
+  return 0;
+  /*  return link->current_latency;*/
 }
 
 /* Destroys a link. The user data (if any) should have been destroyed first.
index 5d21311..d4a81dd 100644 (file)
@@ -11,8 +11,8 @@ SG_task_t SG_task_create(const char *name, void *data, double amount) {
   
   task->data = data;
   task->name = xbt_strdup(name);
-  task->amount = amount;
-  task->remaining_amount = amount;
+  /*task->amount = amount;
+    task->remaining_amount = amount;*/
   task->state = SG_SCHEDULED; /* not sure... should we add a state SG_NOT_SCHEDULED? */
   /* TODO: dependencies + watch */
 
@@ -55,14 +55,19 @@ const char* SG_task_get_name(SG_task_t task) {
  */
 double SG_task_get_amount(SG_task_t task) {
   xbt_assert0(task, "Invalid parameter");
-  return task->amount;
+
+  /* TODO */
+  return 0;
+  /*return task->amount;*/
 }
 
 /* Returns the remaining computing amount of a task.
  */
 double SG_task_get_remaining_amount(SG_task_t task) {
-  xbt_assert0(task, "Invalid parameter");
-  return task->remaining_amount;
+  xbt_assert0(task, "Invalid parameter")
+
+  /* TODO (surf encapsulation) */;
+  return 0;
 }
 
 /* Adds a dependency between two tasks.
index 65c8032..38ffb85 100644 (file)
@@ -1,16 +1,7 @@
 #include "simdag/simdag.h"
 #include "xbt/dict.h"
 #include "xbt/sysdep.h"
-/*#include "private.h"*/
-
-static xbt_dict_t workstations;  /* workstation list */
-static int workstation_count; /* number of workstations */
-
-  void *data;
-  char *name;
-  double power;
-  double available_power;
-  /* TODO: route */
+#include "private.h"
 
 /* Creates a workstation.
  */
@@ -22,8 +13,8 @@ SG_workstation_t SG_workstation_create(void *data, const char *name, double powe
   
   workstation->data = data;
   workstation->name = xbt_strdup(name);
-  workstation->power = power;
-  workstation->available_power = power;
+  /*workstation->power = power;
+  workstation->available_power = power;*/
   /* TODO: route */
 
   return workstation;
@@ -32,22 +23,24 @@ SG_workstation_t SG_workstation_create(void *data, const char *name, double powe
 /* 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(name, "Invalid parameter");
+  xbt_assert0(sg_global != NULL, "SG_init not called yet");
+  xbt_assert0(name != NULL, "Invalid parameter");
 
-  return xbt_dict_get_or_null(workstations, name);
+  return xbt_dict_get_or_null(sg_global->workstations, name);
 }
 
 /* Returns a NULL-terminated array of existing workstations.
  */
 SG_workstation_t*  SG_workstation_get_list(void) {
-  SG_workstation_t* array = xbt_new0(SG_workstation_t, workstation_count + 1);
+  xbt_assert0(sg_global != NULL, "SG_init not called yet");
+  SG_workstation_t* array = xbt_new0(SG_workstation_t, sg_global->workstation_count + 1);
   
   xbt_dict_cursor_t cursor;
   char *key;
   void *data;
   int i=0;
 
-  xbt_dict_foreach(workstations,cursor,key,data) {
+  xbt_dict_foreach(sg_global->workstations,cursor,key,data) {
     array[i++] = (SG_workstation_t) data;
   }
   array[i] = NULL;
@@ -58,27 +51,28 @@ SG_workstation_t*  SG_workstation_get_list(void) {
 /* Returns the number or workstations.
  */
 int SG_workstation_get_number(void) {
-  return workstation_count;
+  xbt_assert0(sg_global != NULL, "SG_init not called yet");
+  return sg_global->workstation_count;
 }
 
 /* Sets the data of a workstation.
  */
 void SG_workstation_set_data(SG_workstation_t workstation, void *data) {
-  xbt_assert0(workstation, "Invalid parameter");
+  xbt_assert0(workstation != NULL, "Invalid parameter");
   workstation->data = data;
 }
 
 /* Returns the data of a workstation.
  */
 void* SG_workstation_get_data(SG_workstation_t workstation) {
-  xbt_assert0(workstation, "Invalid parameter");
+  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) {
-  xbt_assert0(workstation, "Invalid parameter");
+  xbt_assert0(workstation != NULL, "Invalid parameter");
   return workstation->name;
 }
 
@@ -95,21 +89,25 @@ int SG_workstation_route_get_size(SG_workstation_t src, SG_workstation_t dst) {
 /* Returns the total power of a workstation.
  */
 double SG_workstation_get_power(SG_workstation_t workstation) {
-  xbt_assert0(workstation, "Invalid parameter");
-  return workstation->power;
+  xbt_assert0(workstation != NULL, "Invalid parameter");
+  /* TODO */
+  return 0;
+  /*  return workstation->power;*/
 }
 
 /* Return the available power of a workstation.
  */
 double SG_workstation_get_available_power(SG_workstation_t workstation) {
-  xbt_assert0(workstation, "Invalid parameter");
-  return workstation->available_power;
+  xbt_assert0(workstation != NULL, "Invalid parameter");
+  /* TODO */
+  return 0;
+  /*return workstation->available_power;*/
 }
 
 /* Destroys a workstation. The user data (if any) should have been destroyed first.
  */
 void SG_workstation_destroy(SG_workstation_t workstation) {
-  xbt_assert0(workstation, "Invalid parameter");
+  xbt_assert0(workstation != NULL, "Invalid parameter");
 
   if (workstation->name)
     free(workstation->name);