From 8461d5fbbf4d4f12a92d4a1f3924cf2f8e040e4c Mon Sep 17 00:00:00 2001 From: Navarrop Date: Mon, 12 Dec 2011 12:35:00 +0100 Subject: [PATCH] Cleanup to allow separation of model specification and of optimization mode for each model. Clean some cruft in the comments. --- src/include/surf/surf.h | 61 ++++++++++++++++++++--------------------- src/surf/cpu_im.c | 23 +++++++++++++--- src/surf/surf.c | 42 +++++++++++++++++++--------- src/surf/surf_config.c | 47 +++++++++++++++++++++++++++++++ src/surf/workstation.c | 14 ++++++++-- 5 files changed, 136 insertions(+), 51 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index e50dd478e7..bc8b8626eb 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -338,6 +338,11 @@ XBT_PUBLIC_DATA(surf_model_t) surf_cpu_model; /** \brief Initializes the CPU model with the model Cas01 * \ingroup SURF_models * + * By default, this model uses the lazy optimization mechanism that + * relies on partial invalidation in LMM and a heap for lazy action update. + * You can change this behavior by setting the cpu/optim configuration + * variable to a different value. + * * This function is called by surf_workstation_model_init_CLM03 * so you shouldn't have to call it by yourself. * @@ -345,21 +350,13 @@ XBT_PUBLIC_DATA(surf_model_t) surf_cpu_model; */ XBT_PUBLIC(void) surf_cpu_model_init_Cas01(void); -/** \brief Initializes the CPU model with trace integration - * \ingroup SURF_models - * - */ -XBT_PUBLIC(void) surf_cpu_model_init_ti(void); - -/** \brief Initializes the CPU model with the model Cas01 Improved. This model uses a heap to order the events, decreasing the time complexity to get the minimum next event. +/** \brief Initializes the CPU model with trace integration [Deprecated] * \ingroup SURF_models * - * This function is called by surf_workstation_model_init_CLM03 - * so you shouldn't have to call it by yourself. - * + * You shouldn't have to call it by yourself. * \see surf_workstation_model_init_CLM03() */ -XBT_PUBLIC(void) surf_cpu_model_init_Cas01_im(void); +XBT_PUBLIC(void) surf_cpu_model_init_ti(void); /** \brief This function call the share resources function needed * @@ -370,6 +367,13 @@ XBT_PUBLIC(double) generic_share_resources(double now); * */ XBT_PUBLIC(void) generic_update_actions_state(double now, double delta); + +/** \brief The list of all available optimization modes (both for cpu and networks). + * \ingroup SURF_models + * These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:... + */ +XBT_PUBLIC_DATA(s_surf_model_description_t) surf_optimization_mode_description[]; + /** \brief The list of all available cpu model models * \ingroup SURF_models */ @@ -566,7 +570,6 @@ XBT_PUBLIC_DATA(surf_model_t) surf_workstation_model; /** \brief Initializes the platform with a compound workstation model * \ingroup SURF_models - * \param filename XML platform file name * * This function should be called after a cpu_model and a * network_model have been set up. @@ -574,9 +577,20 @@ XBT_PUBLIC_DATA(surf_model_t) surf_workstation_model; */ XBT_PUBLIC(void) surf_workstation_model_init_compound(void); +/** \brief Initializes the platform with the current best network and cpu models at hand + * \ingroup SURF_models + * + * This platform model seperates the workstation model and the network model. + * The workstation model will be initialized with the model compound, the network + * model with the model LV08 (with cross traffic support) and the CPU model with + * the model Cas01. + * Such model is subject to modification with warning in the ChangeLog so monitor it! + * + */ +XBT_PUBLIC(void) surf_workstation_model_init_current_default(void); + /** \brief Initializes the platform with the workstation model CLM03 * \ingroup SURF_models - * \param filename XML platform file name * * This platform model seperates the workstation model and the network model. * The workstation model will be initialized with the model CLM03, the network @@ -584,26 +598,11 @@ XBT_PUBLIC(void) surf_workstation_model_init_compound(void); * In future releases, some other network models will be implemented and will be * combined with the workstation model CLM03. * - * \see surf_workstation_model_init_KCCFLN05() */ XBT_PUBLIC(void) surf_workstation_model_init_CLM03(void); /** \brief Initializes the platform with the model KCCFLN05 * \ingroup SURF_models - * \param filename XML platform file name - * - * With this model, the workstations and the network are handled - * together. The network model is roughly the same as in CM02 but - * interference between computations and communications can be taken - * into account. This platform model is the default one for MSG and - * SimDag. - * - */ -XBT_PUBLIC(void) surf_workstation_model_init_KCCFLN05(void); - -/** \brief Initializes the platform with the model KCCFLN05 - * \ingroup SURF_models - * \param filename XML platform file name * * With this model, only parallel tasks can be used. Resource sharing * is done by identifying bottlenecks and giving an equal share of @@ -636,11 +635,9 @@ XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set; * This function has to be called to initialize the common * structures. Then you will have to create the environment by * calling - * e.g. surf_workstation_model_init_CLM03() or - * surf_workstation_model_init_KCCFLN05(). + * e.g. surf_workstation_model_init_CLM03() * - * \see surf_workstation_model_init_CLM03(), - * surf_workstation_model_init_KCCFLN05(), surf_workstation_model_init_compound(), surf_exit() + * \see surf_workstation_model_init_CLM03(), surf_workstation_model_init_compound(), surf_exit() */ XBT_PUBLIC(void) surf_init(int *argc, char **argv); /* initialize common structures */ diff --git a/src/surf/cpu_im.c b/src/surf/cpu_im.c index 89ec8af7e5..74815e37a9 100644 --- a/src/surf/cpu_im.c +++ b/src/surf/cpu_im.c @@ -677,12 +677,27 @@ static void surf_cpu_im_model_init_internal(const char* name) /* \url{http://grail.sdsc.edu/papers/simgrid_ccgrid01.ps.gz}." */ /* } */ -void surf_cpu_model_init_Cas01_im() +void surf_cpu_model_init_Cas01() { - if( strcmp(xbt_cfg_get_string(_surf_cfg_set, "cpu/model"),"Cas01")) - cpu_update_mechanism = UM_LAZY; - else + char *optim = xbt_cfg_get_string(_surf_cfg_set, "cpu/optim"); + char *model = xbt_cfg_get_string(_surf_cfg_set, "cpu/model"); + + if(!strcmp(model,"Cas01_fullupdate")) { + XBT_WARN("[*Deprecated*. Use --cfg=cpu/model:Cas01 with option --cfg=cpu/optim:Full instead.]"); + } else if(!strcmp(model,"CpuTI")) { + XBT_WARN("[*Deprecated*. Use --cfg=cpu/model:Cas01 with option --cfg=cpu/optim:TI instead.]"); + } + + if(!strcmp(optim,"Full")) { cpu_update_mechanism = UM_FULL; + } else if (strcmp(optim,"Lazy")) { + cpu_update_mechanism = UM_LAZY; + } else if (strcmp(optim,"TI")) { + surf_cpu_model_init_ti(); + return; + } else { + xbt_die("Unsupported optimization (%s) for this model",optim); + } if (surf_cpu_model) return; diff --git a/src/surf/surf.c b/src/surf/surf.c index 77c0fed961..d995e2038b 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -117,16 +117,16 @@ s_surf_model_description_t surf_network_model_description[] = { "Simplistic network model where all communication take a constant time (one second)", surf_network_model_init_Constant}, {"CM02", - "Realistic network model with lmm_solve and no correction factors", + "Legacy network model with lmm_solve (slow-start and bottleneck sharing with small bandwidth poorly modeled).", surf_network_model_init_CM02}, {"LV08", - "Realistic network model with lmm_solve, adequate correction factors (latency*=10.4, bandwidth*=.92, S=8775) and partial invalidation optimization", + "Realistic network model (slow-start modeled by multiplying latency by 10.4, bandwidth by .92 and bottleneck sharing uses a payload of S=8775 for evaluating RTT). Uses partial invalidation optimization of lmm system and a heap for action management by default (option --cfg=network/optim:Lazy)", im_surf_network_model_init_LegrandVelho}, {"LV08_fullupdate", - "Realistic network model wit lmm_solve, adequate correction factors (latency*=10.4, bandwidth*=.92, S=8775) but no further optimization. Should produce the same results as LV08, only slower.", + "Realistic network model (see LV08) [Deprecated. Use LV08 with option --cfg=network/optim:Full. The Full option updates all actions at every step, which may be useful for debug.]", im_surf_network_model_init_LegrandVelho}, {"SMPI", - "Realistic network model with lmm_solve and correction factors on three intervals (< 1KiB, < 64 KiB, >= 64 KiB)", + "Realistic network model with lmm_solve specifically tailored for HPC setting (accurate modeling of slow start with correction factors on three intervals (< 1KiB, < 64 KiB, >= 64 KiB))", surf_network_model_init_SMPI}, #ifdef HAVE_GTNETS {"GTNets", @@ -139,32 +139,35 @@ s_surf_model_description_t surf_network_model_description[] = { surf_network_model_init_NS3}, #endif {"Reno", - "Model using lagrange_solve instead of lmm_solve (experts only)", + "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info)", surf_network_model_init_Reno}, {"Reno2", - "Model using lagrange_solve instead of lmm_solve (experts only)", + "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info)", surf_network_model_init_Reno2}, {"Vegas", - "Model using lagrange_solve instead of lmm_solve (experts only)", + "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info)", surf_network_model_init_Vegas}, {NULL, NULL, NULL} /* this array must be NULL terminated */ }; s_surf_model_description_t surf_cpu_model_description[] = { - {"Cas01_fullupdate", "CPU classical model time=size/power", - surf_cpu_model_init_Cas01_im}, + {"Cas01_fullupdate", "CPU classical model time=size/power (Cas01). [Deprecated. Use Cas01 with option --cfg=cpu/optim:Full. The Full option updates all actions at every step, which may be useful for debug.]", + surf_cpu_model_init_Cas01}, {"Cas01", - "Variation of Cas01_fullupdate with partial invalidation optimization of lmm system. Should produce the same values, only faster", - surf_cpu_model_init_Cas01_im}, + "CPU classical model time=size/power. Default version uses partial invalidation optimization of lmm system and a heap for action management (default option is --cfg=cpu/optim:Lazy)", + surf_cpu_model_init_Cas01}, {"CpuTI", - "Variation of Cas01 with also trace integration. Should produce the same values, only faster if you use availability traces", + "CPU classical model time=size/power (Cas01). [Deprecated. Use Cas01 with option --cfg=cpu/optim:TI. The TI optimization is highly optimized when using traces]", surf_cpu_model_init_ti}, {NULL, NULL, NULL} /* this array must be NULL terminated */ }; s_surf_model_description_t surf_workstation_model_description[] = { + {"current_default", + "Curent default workstation model (may change with versions of SimGrid). Currently Cas01 and LV08 (with full duplex support) as CPU and Network", + surf_workstation_model_init_current_default}, {"CLM03", - "Default workstation model, using LV08 and CM02 as network and CPU", + "Default workstation model, using Cas01 and CM02 as CPU and Network", surf_workstation_model_init_CLM03}, {"compound", "Workstation model allowing you to use other network and CPU models", @@ -174,6 +177,19 @@ s_surf_model_description_t surf_workstation_model_description[] = { {NULL, NULL, NULL} /* this array must be NULL terminated */ }; +s_surf_model_description_t surf_optimization_mode_description[] = { + {"Lazy", + "Lazy action management (partial invalidation in lmm + heap in action remaining).", + NULL}, + {"TI", + "Trace integration. Highly optimized mode for the Cas01 model when using availability traces.", + NULL}, + {"Full", + "Full update of remaining and variables. Slow but may be useful when debugging.", + NULL}, + {NULL, NULL, NULL} /* this array must be NULL terminated */ +}; + /** Displays the long description of all registered models, and quit */ void model_help(const char *category, s_surf_model_description_t * table) { diff --git a/src/surf/surf_config.c b/src/surf/surf_config.c index 7b25a55143..dc156cb08d 100644 --- a/src/surf/surf_config.c +++ b/src/surf/surf_config.c @@ -108,6 +108,25 @@ static void _surf_cfg_cb__cpu_model(const char *name, int pos) find_model_description(surf_cpu_model_description, val); } +/* callback of the cpu/model variable */ +static void _surf_cfg_cb__optimization_mode(const char *name, int pos) +{ + char *val; + + xbt_assert(_surf_init_status < 2, + "Cannot change the model after the initialization"); + + val = xbt_cfg_get_string(_surf_cfg_set, name); + + if (!strcmp(val, "help")) { + model_help("optimization", surf_optimization_mode_description); + exit(0); + } + + /* New Module missing */ + find_model_description(surf_optimization_mode_description, val); +} + /* callback of the workstation_model variable */ static void _surf_cfg_cb__network_model(const char *name, int pos) { @@ -295,6 +314,20 @@ void surf_config_init(int *argc, char **argv) "cpu/model", description, xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL); + sprintf(description, + "The optimization modes to use for the CPU. Possible values: "); + p = description; + while (*(++p) != '\0'); + for (i = 0; surf_optimization_mode_description[i].name; i++) + p += sprintf(p, "%s%s", (i == 0 ? "" : ", "), + surf_optimization_mode_description[i].name); + sprintf(p, + ".\n (use 'help' as a value to see the long description of each optimization mode)"); + default_value = xbt_strdup("Lazy"); + xbt_cfg_register(&_surf_cfg_set, + "cpu/optim", description, xbt_cfgelm_string, + &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL); + sprintf(description, "The model to use for the network. Possible values: "); p = description; @@ -310,6 +343,20 @@ void surf_config_init(int *argc, char **argv) &default_value, 1, 1, &_surf_cfg_cb__network_model, NULL); + sprintf(description, + "The optimization modes to use for the network. Possible values: "); + p = description; + while (*(++p) != '\0'); + for (i = 0; surf_optimization_mode_description[i].name; i++) + p += sprintf(p, "%s%s", (i == 0 ? "" : ", "), + surf_optimization_mode_description[i].name); + sprintf(p, + ".\n (use 'help' as a value to see the long description of each optimization mode)"); + default_value = xbt_strdup("Lazy"); + xbt_cfg_register(&_surf_cfg_set, + "network/optim", description, xbt_cfgelm_string, + &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL); + sprintf(description, "The model to use for the workstation. Possible values: "); p = description; diff --git a/src/surf/workstation.c b/src/surf/workstation.c index c1ca40f6fa..843ea3b868 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -339,6 +339,16 @@ static void surf_workstation_model_init_internal(void) } +void surf_workstation_model_init_current_default(void) +{ + surf_workstation_model_init_internal(); + surf_cpu_model_init_Cas01(); + im_surf_network_model_init_LegrandVelho(); + + xbt_dynar_push(model_list, &surf_workstation_model); + sg_platf_postparse_add_cb(create_workstations); +} + /********************************************************************/ /* The model used in MSG and presented at CCGrid03 */ /********************************************************************/ @@ -353,8 +363,8 @@ static void surf_workstation_model_init_internal(void) void surf_workstation_model_init_CLM03(void) { surf_workstation_model_init_internal(); - surf_cpu_model_init_Cas01_im(); - im_surf_network_model_init_LegrandVelho(); + surf_cpu_model_init_Cas01(); + surf_network_model_init_CM02(); xbt_dynar_push(model_list, &surf_workstation_model); sg_platf_postparse_add_cb(create_workstations); -- 2.20.1