--- /dev/null
+#ifndef SIMDAG_DATATYPES_H
+#define SIMDAG_DATATYPES_H
+
+/* Link */
+typedef struct SG_link {
+ void *data;
+ char *name;
+ 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;
+ /* TODO: route */
+} s_SG_workstation_t, *SG_workstation_t;
+
+/* Task state */
+typedef enum {
+ SG_SCHEDULED,
+ SG_RUNNING,
+ SG_DONE,
+ SG_FAILED
+} SG_task_state_t;
+
+/* Task */
+typedef struct SG_task {
+ void *data;
+ char *name;
+ double amount;
+ double remaining_amount;
+ SG_task_state_t state;
+ /* TODO: dependencies + watch */
+} s_SG_task_t, *SG_task_t;
+
+#endif
--- /dev/null
+#ifndef SIMDAG_H
+#define SIMDAG_H
+
+#include "simdag/datatypes.h"
+#include "xbt/misc.h"
+
+SG_BEGIN_DECL()
+
+/************************** Link handling ***********************************/
+
+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);
+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);
+void SG_link_destroy(SG_link_t link);
+
+/************************** Workstation handling ****************************/
+
+SG_workstation_t SG_workstation_create(void *data, const char *name, double 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);
+void SG_workstation_destroy(SG_workstation_t workstation);
+
+/************************** 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,
+ 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 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.
+ 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);
+
+/************************** Global *******************************************/
+
+SG_task_t *SG_simulate(double how_long); /* returns a NULL-terminated array of SG_task_t whose state has changed */
+
+SG_END_DECL()
+
+#endif
--- /dev/null
+#include "simdag/simdag.h"
+#include "xbt/sysdep.h" /* xbt_new0 */
+
+/* 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 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;
+
+ return link;
+}
+
+/* Returns the user data of a link. The user data can be NULL.
+ */
+void* SG_link_get_data(SG_link_t link) {
+ xbt_assert0(link, "Invalid parameter");
+ return link->data;
+}
+
+/* Sets the user data of a link. The data can be NULL.
+ */
+void SG_link_set_data(SG_link_t link, void *data) {
+ 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) {
+ xbt_assert0(link, "Invalid parameter");
+ return link->name;
+}
+
+/* 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;
+}
+
+/* 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;
+}
+
+/* Destroys a link. The user data (if any) should have been destroyed first.
+ */
+void SG_link_destroy(SG_link_t link) {
+ xbt_assert0(link, "Invalid parameter");
+
+ if (link->name)
+ free(link->name);
+
+ free(link);
+}
--- /dev/null
+#include "simdag/simdag.h"
+#include "xbt/sysdep.h"
+
+/* Creates a task.
+ */
+SG_task_t SG_task_create(const char *name, void *data, double amount) {
+
+ xbt_assert0(amount >= 0, "Invalid parameter"); /* or amount > 0 ? */
+
+ SG_task_t task = xbt_new0(s_SG_task_t, 1);
+
+ 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? */
+ /* TODO: dependencies + watch */
+
+ return task;
+}
+
+/* Schedules a task.
+ */
+int SG_task_schedule(SG_task_t task, int workstation_nb,
+ SG_workstation_t **workstation_list, double *computation_amount,
+ double *communication_amount, double rate) {
+ xbt_assert0(task, "Invalid parameter");
+ /* TODO */
+
+ return 0;
+}
+
+/* Returns the data of a task.
+ */
+void* SG_task_get_data(SG_task_t 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) {
+ xbt_assert0(task, "Invalid parameter");
+ task->data = data;
+}
+
+/* Returns the name of a task.
+ */
+const char* SG_task_get_name(SG_task_t 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) {
+ xbt_assert0(task, "Invalid parameter");
+ 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;
+}
+
+/* Adds a dependency between two tasks.
+ */
+void SG_task_dependency_add(const char *name, void *data, SG_task_t src, SG_task_t dst) {
+ 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) {
+ xbt_assert0(src != NULL && dst != NULL, "Invalid parameter");
+ /* TODO */
+}
+
+/* Returns the state of a task: SG_SCHEDULED, SG_RUNNING, SG_DONE or SG_FAILED.
+ */
+SG_task_state_t SG_task_get_state(SG_task_t 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.
+ Watch point is then automatically removed.
+ */
+void SG_task_watch(SG_task_t task, SG_task_state_t state) {
+ 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) {
+ xbt_assert0(task, "Invalid parameter");
+ /* TODO */
+}
+
+/* Unschedules a task.
+ Change state and rerun
+ */
+void SG_task_unschedule(SG_task_t task) {
+ 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) {
+ if (task->name)
+ free(task->name);
+
+ /* TODO: dependencies + watch */
+ free(task);
+}
--- /dev/null
+#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 */
+
+/* Creates a workstation.
+ */
+SG_workstation_t SG_workstation_create(void *data, const char *name, double power,
+ double available_power) {
+ xbt_assert0(power >= 0 && available_power >= 0, "Invalid parameter"); /* or > 0 ? */
+
+ SG_workstation_t workstation = xbt_new0(s_SG_workstation_t, 1);
+
+ workstation->data = data;
+ workstation->name = xbt_strdup(name);
+ 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");
+
+ return xbt_dict_get_or_null(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_dict_cursor_t cursor;
+ char *key;
+ void *data;
+ int i=0;
+
+ xbt_dict_foreach(workstations,cursor,key,data) {
+ array[i++] = (SG_workstation_t) data;
+ }
+ array[i] = NULL;
+
+ return array;
+}
+
+/* Returns the number or workstations.
+ */
+int SG_workstation_get_number(void) {
+ return workstation_count;
+}
+
+/* Sets the data of a workstation.
+ */
+void SG_workstation_set_data(SG_workstation_t workstation, void *data) {
+ xbt_assert0(workstation, "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");
+ return workstation->data;
+}
+
+/* Returns the name of a workstation.
+ */
+const char* SG_workstation_get_name(SG_workstation_t workstation) {
+ xbt_assert0(workstation, "Invalid parameter");
+ return workstation->name;
+}
+
+SG_link_t* SG_workstation_route_get_list(SG_workstation_t src, SG_workstation_t dst) {
+ /* TODO */
+ return NULL;
+}
+
+int SG_workstation_route_get_size(SG_workstation_t src, SG_workstation_t dst) {
+ /* TODO */
+ return 0;
+}
+
+/* Returns the total power of a workstation.
+ */
+double SG_workstation_get_power(SG_workstation_t workstation) {
+ xbt_assert0(workstation, "Invalid parameter");
+ 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;
+}
+
+/* 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");
+
+ if (workstation->name)
+ free(workstation->name);
+
+ /* TODO: route */
+
+ free(workstation);
+}