git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9833
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
/* Global variables */
typedef struct SD_global {
/* Global variables */
typedef struct SD_global {
- xbt_dict_t workstations; /* workstation dictionary */
- int workstation_count; /* number of workstations */
SD_workstation_t *workstation_list; /* array of workstations, created only if
necessary in SD_workstation_get_list */
SD_workstation_t *workstation_list; /* array of workstations, created only if
necessary in SD_workstation_get_list */
SD_link_t *link_list; /* array of links, created only if
necessary in SD_link_get_list */
SD_link_t *recyclable_route; /* array returned by SD_route_get_list
SD_link_t *link_list; /* array of links, created only if
necessary in SD_link_get_list */
SD_link_t *recyclable_route; /* array returned by SD_route_get_list
computer = xbt_dynar_new(sizeof(SD_task_t), NULL);
xbt_dict_set(computers, char_performer, computer, NULL);
}
computer = xbt_dynar_new(sizeof(SD_task_t), NULL);
xbt_dict_set(computers, char_performer, computer, NULL);
}
- if(performer < sd_global->workstation_count){
+ if(performer < host_lib->count){
// the wanted computer is available
SD_task_t *task_test = NULL;
if(order < computer->used)
// the wanted computer is available
SD_task_t *task_test = NULL;
if(order < computer->used)
sd_global = xbt_new(s_SD_global_t, 1);
sd_global = xbt_new(s_SD_global_t, 1);
- sd_global->workstations = xbt_dict_new();
- sd_global->workstation_count = 0;
sd_global->workstation_list = NULL;
sd_global->link_list = NULL;
sd_global->recyclable_route = NULL;
sd_global->workstation_list = NULL;
sd_global->link_list = NULL;
sd_global->recyclable_route = NULL;
*/
void SD_create_environment(const char *platform_file)
{
*/
void SD_create_environment(const char *platform_file)
{
- xbt_dict_cursor_t cursor = NULL;
+ xbt_lib_cursor_t cursor = NULL;
- void *surf_workstation = NULL;
- void *surf_link = NULL;
+ void **surf_workstation = NULL;
+ void **surf_link = NULL;
platform_filename = bprintf("%s",platform_file);
platform_filename = bprintf("%s",platform_file);
surf_config_models_create_elms();
/* now let's create the SD wrappers for workstations and links */
surf_config_models_create_elms();
/* now let's create the SD wrappers for workstations and links */
- xbt_dict_foreach(surf_model_resource_set(surf_workstation_model), cursor,
- name, surf_workstation) {
- __SD_workstation_create(surf_workstation, NULL);
+ xbt_lib_foreach(host_lib, cursor, name, surf_workstation){
+ if(surf_workstation[SURF_WKS_LEVEL])
+ __SD_workstation_create(surf_workstation[SURF_WKS_LEVEL], NULL);
- xbt_dict_foreach(surf_model_resource_set(surf_network_model), cursor,
- name, surf_link) {
- __SD_link_create(surf_link, NULL);
+ xbt_lib_foreach(link_lib, cursor, name, surf_link) {
+ __SD_link_create(surf_link[SURF_LINK_LEVEL], NULL);
}
XBT_DEBUG("Workstation number: %d, link number: %d",
}
XBT_DEBUG("Workstation number: %d, link number: %d",
#endif
if (SD_INITIALISED()) {
XBT_DEBUG("Destroying workstation and link dictionaries...");
#endif
if (SD_INITIALISED()) {
XBT_DEBUG("Destroying workstation and link dictionaries...");
- xbt_dict_free(&sd_global->workstations);
XBT_DEBUG("Destroying workstation and link arrays if necessary...");
if (sd_global->workstation_list != NULL)
XBT_DEBUG("Destroying workstation and link arrays if necessary...");
if (sd_global->workstation_list != NULL)
workstation->current_task = NULL;
name = SD_workstation_get_name(workstation);
workstation->current_task = NULL;
name = SD_workstation_get_name(workstation);
- xbt_dict_set(sd_global->workstations, name, workstation, __SD_workstation_destroy); /* add the workstation to the dictionary */
- sd_global->workstation_count++;
-
+ xbt_lib_set(host_lib,name,SD_HOST_LEVEL,workstation);
xbt_assert0(name != NULL, "Invalid parameter");
xbt_assert0(name != NULL, "Invalid parameter");
- return xbt_dict_get_or_null(sd_global->workstations, name);
+ return xbt_lib_get_or_null(host_lib, name, SD_HOST_LEVEL);
const SD_workstation_t *SD_workstation_get_list(void)
{
const SD_workstation_t *SD_workstation_get_list(void)
{
- xbt_dict_cursor_t cursor;
+ xbt_lib_cursor_t cursor;
int i;
SD_CHECK_INIT_DONE();
int i;
SD_CHECK_INIT_DONE();
if (sd_global->workstation_list == NULL) { /* this is the first time the function is called */
sd_global->workstation_list =
if (sd_global->workstation_list == NULL) { /* this is the first time the function is called */
sd_global->workstation_list =
- xbt_new(SD_workstation_t, sd_global->workstation_count);
+ xbt_new(SD_workstation_t, host_lib->count);
- xbt_dict_foreach(sd_global->workstations, cursor, key, data) {
- sd_global->workstation_list[i++] = (SD_workstation_t) data;
+ xbt_lib_foreach(host_lib, cursor, key, data) {
+ if(data[SD_HOST_LEVEL])
+ sd_global->workstation_list[i++] = (SD_workstation_t) data[SD_HOST_LEVEL];
}
}
return sd_global->workstation_list;
}
}
return sd_global->workstation_list;
int SD_workstation_get_number(void)
{
SD_CHECK_INIT_DONE();
int SD_workstation_get_number(void)
{
SD_CHECK_INIT_DONE();
- return sd_global->workstation_count;
+ return host_lib->count;
*/
void SIMIX_create_environment(const char *file)
{
*/
void SIMIX_create_environment(const char *file)
{
- xbt_dict_cursor_t cursor = NULL;
+ xbt_lib_cursor_t cursor = NULL;
- void *workstation = NULL;
+ void **workstation = NULL;
end = xbt_os_time();
XBT_DEBUG("PARSE TIME: %lg", (end - start));
end = xbt_os_time();
XBT_DEBUG("PARSE TIME: %lg", (end - start));
- xbt_dict_foreach(surf_model_resource_set(surf_workstation_model), cursor,
- name, workstation) {
- SIMIX_host_create(name, workstation, NULL);
+ xbt_lib_foreach(host_lib, cursor, name, workstation) {
+ if(workstation[SURF_WKS_LEVEL])
+ SIMIX_host_create(name, workstation[SURF_WKS_LEVEL], NULL);
lmm_constraint_new(cpu_maxmin_system, cpu,
cpu->core * cpu->power_scale * cpu->power_peak);
lmm_constraint_new(cpu_maxmin_system, cpu,
cpu->core * cpu->power_scale * cpu->power_peak);
- xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
- surf_resource_free);
+ xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
lmm_constraint_new(cpu_im_maxmin_system, cpu,
cpu->core * cpu->power_scale * cpu->power_peak);
lmm_constraint_new(cpu_im_maxmin_system, cpu,
cpu->core * cpu->power_scale * cpu->power_peak);
- xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
- surf_resource_free);
+ xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
cpu->action_set = xbt_swag_new(xbt_swag_offset(action, cpu_list_hookup));
return cpu;
cpu->action_set = xbt_swag_new(xbt_swag_offset(action, cpu_list_hookup));
return cpu;
{
//defining the last timestamp that we can safely dump to trace file
//without losing the event ascending order (considering all CPU's)
{
//defining the last timestamp that we can safely dump to trace file
//without losing the event ascending order (considering all CPU's)
cpu_Cas01_im_t cpu;
xbt_dict_cursor_t cursor;
char *key;
double smaller = -1;
cpu_Cas01_im_t cpu;
xbt_dict_cursor_t cursor;
char *key;
double smaller = -1;
- xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key, cpu){
- if (smaller < 0){
- smaller = cpu->last_update;
- continue;
- }
- if (cpu->last_update < smaller){
- smaller = cpu->last_update;
- }
- }
+ xbt_lib_foreach(host_lib, cursor, key, data){
+ if(data[SURF_CPU_LEVEL]){
+ cpu = data[SURF_CPU_LEVEL];
+ if (smaller < 0){
+ smaller = cpu->last_update;
+ continue;
+ }
+ if (cpu->last_update < smaller){
+ smaller = cpu->last_update;
+ }
+ }
+ }
if (smaller > 0) {
TRACE_last_timestamp_to_dump = smaller;
}
if (smaller > 0) {
TRACE_last_timestamp_to_dump = smaller;
}
static void cpu_im_finalize(void)
{
static void cpu_im_finalize(void)
{
- void *cpu;
- xbt_dict_cursor_t cursor;
+ void **cpu;
+ xbt_lib_cursor_t cursor;
- xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key,
- cpu) {
- cpu_Cas01_im_t CPU = cpu;
- xbt_swag_free(CPU->action_set);
+
+ xbt_lib_foreach(host_lib, cursor, key, cpu){
+ if(cpu[SURF_CPU_LEVEL])
+ {
+ cpu_Cas01_im_t CPU = cpu[SURF_CPU_LEVEL];
+ xbt_swag_free(CPU->action_set);
+ }
}
lmm_system_free(cpu_im_maxmin_system);
}
lmm_system_free(cpu_im_maxmin_system);
cpu->avail_trace->last_time, 0, cpu);
}
}
cpu->avail_trace->last_time, 0, cpu);
}
}
- xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
- surf_resource_free);
+ xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
static void cpu_ti_finalize(void)
{
static void cpu_ti_finalize(void)
{
- void *cpu;
- xbt_dict_cursor_t cursor;
+ void **cpu;
+ xbt_lib_cursor_t cursor;
- xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key,
- cpu) {
- cpu_ti_t CPU = cpu;
- xbt_swag_free(CPU->action_set);
- surf_cpu_ti_free_tmgr(CPU->avail_trace);
+
+ xbt_lib_foreach(host_lib, cursor, key, cpu){
+ if(cpu[SURF_CPU_LEVEL])
+ {
+ cpu_ti_t CPU = cpu[SURF_CPU_LEVEL];
+ xbt_swag_free(CPU->action_set);
+ surf_cpu_ti_free_tmgr(CPU->avail_trace);
+ }
}
surf_model_exit(surf_cpu_model);
}
surf_model_exit(surf_cpu_model);
workstation->generic_resource.name = xbt_strdup(name);
workstation->cpu = cpu;
workstation->generic_resource.name = xbt_strdup(name);
workstation->cpu = cpu;
- xbt_dict_set(surf_model_resource_set(surf_workstation_model), name,
- workstation, surf_resource_free);
+ xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, workstation);
return workstation;
}
void create_workstations(void)
{
return workstation;
}
void create_workstations(void)
{
- xbt_dict_cursor_t cursor = NULL;
+ xbt_lib_cursor_t cursor = NULL;
- xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, name,
- cpu) {
- workstation_new(name, cpu);
+ xbt_lib_foreach(host_lib, cursor, name, cpu) {
+ if(cpu[SURF_CPU_LEVEL])
+ workstation_new(name, cpu[SURF_CPU_LEVEL]);
lmm_constraint_new(ptask_maxmin_system, cpu,
cpu->power_current * cpu->power_scale);
lmm_constraint_new(ptask_maxmin_system, cpu,
cpu->power_current * cpu->power_scale);
- xbt_dict_set(surf_model_resource_set(surf_workstation_model), name, cpu,
- surf_resource_free);
+ xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, cpu);