From: thiery Date: Wed, 14 Jun 2006 12:23:48 +0000 (+0000) Subject: Working on SimDag. X-Git-Tag: v3.3~2979 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f3af8b430269d158689ad7cdef5b5e54df8360a1?hp=cfc534f877804bee49c17b392d6c1c54a82257ae;ds=inline Working on SimDag. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2379 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/include/simdag/datatypes.h b/include/simdag/datatypes.h index 8b7b4ddc29..f21af30453 100644 --- a/include/simdag/datatypes.h +++ b/include/simdag/datatypes.h @@ -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; diff --git a/include/simdag/simdag.h b/include/simdag/simdag.h index d37795459b..90ed019f48 100644 --- a/include/simdag/simdag.h +++ b/include/simdag/simdag.h @@ -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 index 0000000000..e032bdca32 --- /dev/null +++ b/src/simdag/private.h @@ -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 index 0000000000..961aa25d27 --- /dev/null +++ b/src/simdag/sd_global.c @@ -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; +} diff --git a/src/simdag/sd_link.c b/src/simdag/sd_link.c index 7d59ae0c40..272ceba542 100644 --- a/src/simdag/sd_link.c +++ b/src/simdag/sd_link.c @@ -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. diff --git a/src/simdag/sd_task.c b/src/simdag/sd_task.c index 5d2131111e..d4a81dd79e 100644 --- a/src/simdag/sd_task.c +++ b/src/simdag/sd_task.c @@ -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. diff --git a/src/simdag/sd_workstation.c b/src/simdag/sd_workstation.c index 65c8032b39..38ffb85d70 100644 --- a/src/simdag/sd_workstation.c +++ b/src/simdag/sd_workstation.c @@ -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);