typedef struct SD_global {
xbt_dict_t workstations; /* workstation list */
int workstation_count; /* number of workstations */
+ xbt_dict_t links; /* link list */
} s_SD_global_t, *SD_global_t;
extern SD_global_t sd_global;
/* Link private data */
typedef struct SD_link_data {
- void* surf_link; /* surf object */
-
+ void *surf_link; /* surf object */
+ char *name;
} s_SD_link_data_t;
/* Workstation private data */
typedef struct SD_workstation_data {
- void* surf_workstation; /* surf object */
+ void *surf_workstation; /* surf object */
/* TODO: route */
} s_SD_workstation_data_t;
/* Private functions */
-SD_link_t __SD_link_create(const char *name, void *surf_link, void *data);
-void __SD_link_destroy(SD_link_t link);
+SD_link_t __SD_link_create(void *surf_link, char *name, void *data);
+void __SD_link_destroy(void *link);
SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data);
void __SD_workstation_destroy(void *workstation);
sd_global = xbt_new0(s_SD_global_t, 1);
sd_global->workstations = xbt_dict_new();
sd_global->workstation_count = 0;
+ /*sd_global->links = xbt_dynar_new(sizeof(s_SD_link_t), __SD_link_destroy);*/
+ sd_global->links = xbt_dict_new();
surf_init(argc, argv);
}
-/* Creates the environnement described in a xml file of a platform descriptions.
+/* Creates the environnement described in a xml file of a platform description.
*/
void SD_create_environment(const char *platform_file) {
xbt_dict_cursor_t cursor = NULL;
char *name = NULL;
void *surf_workstation = NULL;
+ void *surf_link = NULL;
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 SD wrappers */
+ surf_timer_resource_init(platform_file); /* tell Surf to create the environnement */
+
+
+ /*printf("surf_workstation_resource = %p, workstation_set = %p\n", surf_workstation_resource, workstation_set);
+ printf("surf_network_resource = %p, network_link_set = %p\n", surf_network_resource, network_link_set);*/
+
+ surf_workstation_resource_init_KCCFLN05(platform_file);
+ /* surf_workstation_resource_init_CLM03(platform_file);*/
+
+ /*printf("surf_workstation_resource = %p, workstation_set = %p\n", surf_workstation_resource, workstation_set);
+ printf("surf_network_resource = %p, network_link_set = %p\n", surf_network_resource, network_link_set);*/
+
+
+ /* now let's create the SD wrappers for workstations and links */
xbt_dict_foreach(workstation_set, cursor, name, surf_workstation) {
__SD_workstation_create(surf_workstation, NULL);
}
+
+ xbt_dict_foreach(network_link_set, cursor, name, surf_link) {
+ __SD_link_create(surf_link, name, NULL);
+ }
}
/* Launches the simulation. Returns a NULL-terminated array of SD_task_t whose state has changed.
{
/* TODO */
- /* temporary test to explore the workstations */
+ /* temporary test to explore the workstations and the links */
xbt_dict_cursor_t cursor = NULL;
char *name = NULL;
SD_workstation_t workstation = NULL;
double power, available_power;
+ SD_link_t link = NULL;
surf_solve();
available_power = SD_workstation_get_available_power(workstation);
printf("Workstation name: %s, power: %f Mflop/s, available power: %f%%\n", name, power, (available_power*100));
}
- /* TODO: remove name from SD workstation structure */
+
+ xbt_dict_foreach(sd_global->links, cursor, name, link) {
+ printf("Link name: %s\n", name);
+ }
return NULL;
}
void SD_clean() {
if (sd_global != NULL) {
xbt_dict_free(&sd_global->workstations);
+ xbt_dict_free(&sd_global->links);
xbt_free(sd_global);
surf_exit();
- /* TODO: destroy the workstations, the links and the tasks */
+ /* TODO: destroy the tasks */
}
}
#include "private.h"
#include "simdag/simdag.h"
+#include "surf/surf.h"
#include "xbt/sysdep.h" /* xbt_new0 */
/* Creates a link.
*/
-SD_link_t __SD_link_create(const char *name, void *surf_link, void *data) {
+SD_link_t __SD_link_create(void *surf_link, char *name, void *data) {
+ CHECK_INIT_DONE();
xbt_assert0(surf_link != NULL, "surf_link is NULL !");
+ xbt_assert0(name != NULL, "name 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_data->name = xbt_strdup(name);
SD_link_t link = xbt_new0(s_SD_link_t, 1);
- link->name = xbt_strdup(name);
- link->data = data;
- link->sd_data = sd_data;
+ link->sd_data = sd_data; /* private data */
+ link->data = data; /* user data */
/*link->capacity = capacity;*/
/* link->current_bandwidth = bandwidth;
link->current_latency = latency;*/
+ /*xbt_dynar_push(sd_global->links, link);*/
+ xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the workstation to the dictionary */
+
return link;
}
/* Returns the user data of a link. The user data can be NULL.
*/
void* SD_link_get_data(SD_link_t link) {
- xbt_assert0(link, "Invalid parameter");
+ CHECK_INIT_DONE();
+ xbt_assert0(link != NULL, "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 SD_link_set_data(SD_link_t link, void *data) {
- xbt_assert0(link, "Invalid parameter");
+ CHECK_INIT_DONE();
+ xbt_assert0(link != NULL, "Invalid parameter");
link->data = data;
}
/* Returns the name of a link. The name can be NULL.
*/
const char* SD_link_get_name(SD_link_t link) {
- xbt_assert0(link, "Invalid parameter");
- return link->name;
+ CHECK_INIT_DONE();
+ xbt_assert0(link != NULL, "Invalid parameter");
+ return link->sd_data->name;
+
+ /* return surf_network_resource->common_public->get_resource_name(link->sd_data->surf_link);*/
}
/* Returns the capacity of a link.
/* Return the current bandwidth of a link.
*/
double SD_link_get_current_bandwidth(SD_link_t link) {
- xbt_assert0(link, "Invalid parameter");
+ CHECK_INIT_DONE();
+ xbt_assert0(link != NULL, "Invalid parameter");
/* TODO */
return 0;
/* Return the current latency of a link.
*/
double SD_link_get_current_latency(SD_link_t link) {
- xbt_assert0(link, "Invalid parameter");
+ CHECK_INIT_DONE();
+ xbt_assert0(link != NULL, "Invalid parameter");
/* TODO */
return 0;
/* Destroys a link. The user data (if any) should have been destroyed first.
*/
-void __SD_link_destroy(SD_link_t link) {
- xbt_assert0(link, "Invalid parameter");
+void __SD_link_destroy(void *link) {
+ CHECK_INIT_DONE();
+ xbt_assert0(link != NULL, "Invalid parameter");
- if (link->sd_data != NULL)
- xbt_free(link->sd_data);
-
- if (link->name != NULL)
- xbt_free(link->name);
+ if (((SD_link_t) link)->sd_data != NULL)
+ xbt_free(((SD_link_t) link)->sd_data);
+ /* TODO: name */
+
xbt_free(link);
}
+
*/
SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data) {
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;