X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/100e0c5e64302595c3c0be525f1d8e5913277e13..97f3dfe883909ad3f75c9fab7aaaf1ddde0cd7f5:/src/surf/surf.c diff --git a/src/surf/surf.c b/src/surf/surf.c index bacb60f513..a4ef05aa17 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -10,6 +10,7 @@ #include "xbt/module.h" #include "mc/mc.h" #include "surf/surf_resource.h" +#include "xbt/xbt_os_thread.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (kernel)"); @@ -179,6 +180,13 @@ s_surf_model_description_t surf_optimization_mode_description[] = { {NULL, NULL, NULL} /* this array must be NULL terminated */ }; +s_surf_model_description_t surf_storage_model_description[] = { + {"default", + "Simplistic storage model.", + surf_storage_model_init_default}, + {NULL, NULL, NULL} /* this array must be NULL terminated */ +}; + #ifdef CONTEXT_THREADS static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */ #endif @@ -299,19 +307,25 @@ XBT_LOG_EXTERNAL_CATEGORY(surf_network_gtnets); void surf_init(int *argc, char **argv) { - XBT_DEBUG("Create all Libs"); - host_lib = xbt_lib_new(); - link_lib = xbt_lib_new(); - as_router_lib = xbt_lib_new(); - - XBT_DEBUG("ADD ROUTING LEVEL"); - ROUTING_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_free); - ROUTING_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_free); - - XBT_DEBUG("ADD SURF LEVELS"); - SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free); - SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free); - SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_resource_free); + XBT_DEBUG("Create all Libs"); + host_lib = xbt_lib_new(); + link_lib = xbt_lib_new(); + as_router_lib = xbt_lib_new(); + storage_lib = xbt_lib_new(); + storage_type_lib = xbt_lib_new(); + + XBT_DEBUG("ADD ROUTING LEVEL"); + ROUTING_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_free); + ROUTING_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_free); + ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free); + ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib,routing_storage_host_free); + ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib,routing_storage_type_free); + + XBT_DEBUG("ADD SURF LEVELS"); + SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free); + SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free); + SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_resource_free); + SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_resource_free); /* Connect our log channels: that must be done manually under windows */ XBT_LOG_CONNECT(surf_cpu, surf); @@ -398,6 +412,7 @@ void surf_exit(void) #ifdef CONTEXT_THREADS xbt_parmap_destroy(surf_parmap); xbt_free(surf_mins); + surf_mins = NULL; #endif xbt_dynar_free(&surf_path); @@ -405,7 +420,8 @@ void surf_exit(void) xbt_lib_free(&host_lib); xbt_lib_free(&link_lib); xbt_lib_free(&as_router_lib); - + xbt_lib_free(&storage_lib); + xbt_lib_free(&storage_type_lib); tmgr_finalize(); surf_parse_lex_destroy(); @@ -463,9 +479,12 @@ double surf_solve(double max_date) } surf_min_index = 0; + if (surf_get_nthreads() > 1) { /* parallel version */ +#ifdef CONTEXT_THREADS xbt_parmap_apply(surf_parmap, (void_f_pvoid_t) surf_share_resources, model_list); +#endif } else { /* sequential version */ @@ -549,7 +568,9 @@ double surf_solve(double max_date) if (surf_get_nthreads() > 1) { /* parallel version */ +#ifdef CONTEXT_THREADS xbt_parmap_apply(surf_parmap, (void_f_pvoid_t) surf_update_actions_state, model_list); +#endif } else { /* sequential version */ @@ -604,7 +625,10 @@ int surf_get_nthreads(void) { */ void surf_set_nthreads(int nthreads) { - xbt_assert(nthreads > 0, "Invalid number of parallel threads: %d", nthreads); + if (nthreads<=0) { + nthreads = xbt_os_get_numcores(); + XBT_INFO("Auto-setting surf/nthreads to %d",nthreads); + } #ifdef CONTEXT_THREADS xbt_parmap_destroy(surf_parmap);