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;
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;
/************************** 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);
/************************** 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()
--- /dev/null
+#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
--- /dev/null
+#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;
+}
/* 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;
}
/* 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.
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 */
*/
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.
#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.
*/
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;
/* 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;
/* 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;
}
/* 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);