#define SIMDAG_DATATYPES_H
/* Link */
-typedef struct SD_link_data *SD_link_data_t;
-
-typedef struct SD_link {
- SD_link_data_t sd_data; /* SD internal data */
- void *data; /* user data */
-} s_SD_link_t, *SD_link_t;
+typedef struct SD_link *SD_link_t;
/* Workstation */
-typedef struct SD_workstation_data *SD_workstation_data_t;
+typedef struct SD_workstation *SD_workstation_t;
-typedef struct SD_workstation {
- SD_workstation_data_t sd_data; /* SD internal data */
- void *data; /* user data */
-} s_SD_workstation_t, *SD_workstation_t;
+/* Task */
+typedef struct SD_task *SD_task_t;
/* Task state */
typedef enum {
SD_FAILED = 0x0008
} e_SD_task_state_t;
-/* Task */
-typedef struct SD_task *SD_task_t;
-
#endif
extern SD_global_t sd_global;
-/* Link private data */
-typedef struct SD_link_data {
+/* Link */
+typedef struct SD_link {
void *surf_link; /* surf object */
-} s_SD_link_data_t;
+ void *data; /* user data */
+} s_SD_link_t;
-/* Workstation private data */
-typedef struct SD_workstation_data {
+/* Workstation */
+typedef struct SD_workstation {
void *surf_workstation; /* surf object */
-} s_SD_workstation_data_t;
-
-/* Task dependencies */
-typedef struct SD_dependency {
- char *name;
- void *data;
- SD_task_t src;
- SD_task_t dst;
- /* src must be finished before dst can start */
-} s_SD_dependency_t, *SD_dependency_t;
+ void *data; /* user data */
+} s_SD_workstation_t;
/* Task */
typedef struct SD_task {
double rate;
} s_SD_task_t;
+/* Task dependencies */
+typedef struct SD_dependency {
+ char *name;
+ void *data;
+ SD_task_t src;
+ SD_task_t dst;
+ /* src must be finished before dst can start */
+} s_SD_dependency_t, *SD_dependency_t;
+
/* SimDag private functions */
SD_link_t __SD_link_create(void *surf_link, void *data);
SD_CHECK_INIT_DONE();
xbt_assert0(surf_link != NULL, "surf_link is NULL !");
- SD_link_data_t sd_data = xbt_new0(s_SD_link_data_t, 1); /* link private data */
- sd_data->surf_link = surf_link;
SD_link_t link = xbt_new0(s_SD_link_t, 1);
- link->sd_data = sd_data; /* private data */
+ link->surf_link = surf_link;
link->data = data; /* user data */
const char *name = SD_link_get_name(link);
const char* SD_link_get_name(SD_link_t link) {
SD_CHECK_INIT_DONE();
xbt_assert0(link != NULL, "Invalid parameter");
- return surf_workstation_resource->extension_public->get_link_name(link->sd_data->surf_link);
+ return surf_workstation_resource->extension_public->get_link_name(link->surf_link);
}
/* Returns the capacity of a link.
double SD_link_get_current_bandwidth(SD_link_t link) {
SD_CHECK_INIT_DONE();
xbt_assert0(link != NULL, "Invalid parameter");
- return surf_workstation_resource->extension_public->get_link_bandwidth(link->sd_data->surf_link);
+ return surf_workstation_resource->extension_public->get_link_bandwidth(link->surf_link);
}
/* Return the current latency of a link.
double SD_link_get_current_latency(SD_link_t link) {
SD_CHECK_INIT_DONE();
xbt_assert0(link != NULL, "Invalid parameter");
- return surf_workstation_resource->extension_public->get_link_latency(link->sd_data->surf_link);
+ return surf_workstation_resource->extension_public->get_link_latency(link->surf_link);
}
/* Destroys a link. The user data (if any) should have been destroyed first.
void __SD_link_destroy(void *link) {
SD_CHECK_INIT_DONE();
xbt_assert0(link != NULL, "Invalid parameter");
-
- SD_link_data_t sd_data = ((SD_link_t) link)->data;
- if (sd_data != NULL) {
- xbt_free(sd_data);
- }
-
+ /* link->surf_link is freed by surf_exit and link->data is freed by the user */
xbt_free(link);
}
task->workstation_list = xbt_new0(void*, workstation_nb);
int i;
for (i = 0; i < workstation_nb; i++) {
- task->workstation_list[i] = workstation_list[i]->sd_data->surf_workstation;
+ task->workstation_list[i] = workstation_list[i]->surf_workstation;
}
__SD_task_set_state(task, SD_SCHEDULED);
SD_CHECK_INIT_DONE();
xbt_assert0(surf_workstation != NULL, "surf_workstation is NULL !");
- SD_workstation_data_t sd_data = xbt_new0(s_SD_workstation_data_t, 1); /* workstation private data */
- sd_data->surf_workstation = surf_workstation;
-
SD_workstation_t workstation = xbt_new0(s_SD_workstation_t, 1);
+ workstation->surf_workstation = surf_workstation;
workstation->data = data; /* user data */
- workstation->sd_data = sd_data; /* private data */
const char *name = SD_workstation_get_name(workstation);
xbt_dict_set(sd_global->workstations, name, workstation, __SD_workstation_destroy); /* add the workstation to the dictionary */
void *data;
int i=0;
- xbt_dict_foreach(sd_global->workstations,cursor,key,data) {
+ xbt_dict_foreach(sd_global->workstations, cursor, key, data) {
array[i++] = (SD_workstation_t) data;
}
array[i] = NULL;
const char* SD_workstation_get_name(SD_workstation_t workstation) {
SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
- return surf_workstation_resource->common_public->get_resource_name(workstation->sd_data->surf_workstation);
+ return surf_workstation_resource->common_public->get_resource_name(workstation->surf_workstation);
}
/* Returns an new array of links representating the route between two workstations.
SD_link_t* SD_workstation_route_get_list(SD_workstation_t src, SD_workstation_t dst) {
SD_CHECK_INIT_DONE();
- void *surf_src = src->sd_data->surf_workstation;
- void *surf_dst = dst->sd_data->surf_workstation;
+ void *surf_src = src->surf_workstation;
+ void *surf_dst = dst->surf_workstation;
const void **surf_route = surf_workstation_resource->extension_public->get_route(surf_src, surf_dst);
int route_size = surf_workstation_resource->extension_public->get_route_size(surf_src, surf_dst);
int SD_workstation_route_get_size(SD_workstation_t src, SD_workstation_t dst) {
SD_CHECK_INIT_DONE();
return surf_workstation_resource->extension_public->
- get_route_size(src->sd_data->surf_workstation, dst->sd_data->surf_workstation);
+ get_route_size(src->surf_workstation, dst->surf_workstation);
}
/* Returns the total power of a workstation.
double SD_workstation_get_power(SD_workstation_t workstation) {
SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
- return surf_workstation_resource->extension_public->get_speed(workstation->sd_data->surf_workstation, 1.0);
+ return surf_workstation_resource->extension_public->get_speed(workstation->surf_workstation, 1.0);
}
/* Returns the proportion of available power in a workstation (normally a number between 0 and 1).
double SD_workstation_get_available_power(SD_workstation_t workstation) {
SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
- return surf_workstation_resource->extension_public->get_available_speed(workstation->sd_data->surf_workstation);
+ return surf_workstation_resource->extension_public->get_available_speed(workstation->surf_workstation);
}
/* Destroys a workstation. The user data (if any) should have been destroyed first.
void __SD_workstation_destroy(void *workstation) {
SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
-
- if (((SD_workstation_t) workstation)->sd_data != NULL) {
- xbt_free(((SD_workstation_t) workstation)->sd_data);
- }
-
+ /* workstation->surf_workstation is freed by surf_exit and workstation->data is freed by the user */
xbt_free(workstation);
}