X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/908f43d575e3b19014f39ba209da997ab6e3fa2c..a1688a8f4d3a06b7dfd59fdcf06c7a198b235fbb:/src/surf/workstation.c diff --git a/src/surf/workstation.c b/src/surf/workstation.c index 3b3b9df090..ed841dce8c 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -227,12 +227,51 @@ static double ws_get_speed(void *workstation, double load) get_speed(workstation, load); } +static int ws_get_core(void *workstation) +{ + return surf_cpu_model->extension.cpu. + get_core(workstation); +} + + + static double ws_get_available_speed(void *workstation) { return surf_cpu_model->extension.cpu. get_available_speed(workstation); } +static double ws_get_current_power_peak(void *workstation) +{ + return surf_cpu_model->extension.cpu. + get_current_power_peak(workstation); +} + +static double ws_get_power_peak_at(void *workstation, int pstate_index) +{ + return surf_cpu_model->extension.cpu. + get_power_peak_at(workstation, pstate_index); +} + +static int ws_get_nb_pstates(void *workstation) +{ + return surf_cpu_model->extension.cpu. + get_nb_pstates(workstation); +} + +static void ws_set_power_peak_at(void *workstation, int pstate_index) +{ + surf_cpu_model->extension.cpu. + set_power_peak_at(workstation, pstate_index); +} + +static double ws_get_consumed_energy(void *workstation) +{ + return surf_cpu_model->extension.cpu. + get_consumed_energy(workstation); +} + + static surf_action_t ws_execute_parallel_task(int workstation_nb, void **workstation_list, double *computation_amount, @@ -305,7 +344,7 @@ static xbt_dict_t ws_get_properties(const void *ws) return surf_resource_properties(surf_cpu_resource_priv(ws)); } -static storage_t find_storage_on_mount_list(void *workstation,const char* storage) +static storage_t find_storage_on_mount_list(void *workstation,const char* mount) { storage_t st = NULL; s_mount_t mnt; @@ -313,16 +352,16 @@ static storage_t find_storage_on_mount_list(void *workstation,const char* storag workstation_CLM03_t ws = (workstation_CLM03_t) surf_workstation_resource_priv(workstation); xbt_dynar_t storage_list = ws->storage; - XBT_DEBUG("Search for storage name '%s' on '%s'",storage,ws->generic_resource.name); + XBT_DEBUG("Search for storage name '%s' on '%s'",mount,ws->generic_resource.name); xbt_dynar_foreach(storage_list,cursor,mnt) { XBT_DEBUG("See '%s'",mnt.name); - if(!strcmp(storage,mnt.name)){ - st = mnt.id; + if(!strcmp(mount,mnt.name)){ + st = mnt.storage; break; } } - if(!st) xbt_die("Can't find mount '%s' for '%s'",storage,ws->generic_resource.name); + if(!st) xbt_die("Can't find mount '%s' for '%s'",mount,ws->generic_resource.name); return st; } @@ -337,28 +376,28 @@ static surf_action_t ws_action_open(void *workstation, const char* mount, static surf_action_t ws_action_close(void *workstation, surf_file_t fd) { - storage_t st = find_storage_on_mount_list(workstation, fd->storage); + storage_t st = find_storage_on_mount_list(workstation, fd->mount); XBT_DEBUG("CLOSE on disk '%s'",st->generic_resource.name); surf_model_t model = st->generic_resource.model; return model->extension.storage.close(st, fd); } -static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size, +static surf_action_t ws_action_read(void *workstation, size_t size, surf_file_t fd) { - storage_t st = find_storage_on_mount_list(workstation, fd->storage); + storage_t st = find_storage_on_mount_list(workstation, fd->mount); XBT_DEBUG("READ on disk '%s'",st->generic_resource.name); surf_model_t model = st->generic_resource.model; - return model->extension.storage.read(st, ptr, size, fd); + return model->extension.storage.read(st, size, fd); } -static surf_action_t ws_action_write(void *workstation, const void* ptr, - size_t size, surf_file_t fd) +static surf_action_t ws_action_write(void *workstation, size_t size, + surf_file_t fd) { - storage_t st = find_storage_on_mount_list(workstation, fd->storage); + storage_t st = find_storage_on_mount_list(workstation, fd->mount); XBT_DEBUG("WRITE on disk '%s'",st->generic_resource.name); surf_model_t model = st->generic_resource.model; - return model->extension.storage.write(st, ptr, size, fd); + return model->extension.storage.write(st, size, fd); } static int ws_file_unlink(void *workstation, surf_file_t fd) @@ -368,7 +407,7 @@ static int ws_file_unlink(void *workstation, surf_file_t fd) return 0; } else { // XBT_INFO("%s %zu", fd->storage, fd->size); - storage_t st = find_storage_on_mount_list(workstation, fd->storage); + storage_t st = find_storage_on_mount_list(workstation, fd->mount); xbt_dict_t content_dict = (st)->content; /* Check if the file is on this storage */ if (!xbt_dict_get_or_null(content_dict, fd->name)){ @@ -383,7 +422,7 @@ static int ws_file_unlink(void *workstation, surf_file_t fd) xbt_dict_remove(content_dict,fd->name); free(fd->name); - free(fd->storage); + free(fd->mount); xbt_free(fd); return 1; } @@ -438,9 +477,15 @@ static void surf_workstation_model_init_internal(void) surf_workstation_model->extension.workstation.execute = ws_execute; surf_workstation_model->extension.workstation.sleep = ws_action_sleep; surf_workstation_model->extension.workstation.get_state = ws_get_state; + surf_workstation_model->extension.workstation.get_core = ws_get_core; surf_workstation_model->extension.workstation.get_speed = ws_get_speed; surf_workstation_model->extension.workstation.get_available_speed = ws_get_available_speed; + surf_workstation_model->extension.workstation.get_current_power_peak = ws_get_current_power_peak; + surf_workstation_model->extension.workstation.get_power_peak_at = ws_get_power_peak_at; + surf_workstation_model->extension.workstation.get_nb_pstates = ws_get_nb_pstates; + surf_workstation_model->extension.workstation.set_power_peak_at = ws_set_power_peak_at; + surf_workstation_model->extension.workstation.get_consumed_energy = ws_get_consumed_energy; surf_workstation_model->extension.workstation.communicate = ws_communicate;