From 6270ece7967b322385bbff766ee5f882ba1ef2a2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 29 Nov 2015 17:58:37 +0100 Subject: [PATCH] rename some symbols around Link::isShared to make their purpose clear --- src/include/surf/maxmin.h | 2 +- src/surf/fair_bottleneck.cpp | 6 +++--- src/surf/host_ptask_L07.cpp | 4 ++-- src/surf/host_ptask_L07.hpp | 2 +- src/surf/maxmin.cpp | 29 +++++++++++++++-------------- src/surf/maxmin_private.hpp | 2 +- src/surf/network_interface.cpp | 6 +++--- src/surf/network_interface.hpp | 8 ++------ 8 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/include/surf/maxmin.h b/src/include/surf/maxmin.h index 3b102b7f62..18dcef51c5 100644 --- a/src/include/surf/maxmin.h +++ b/src/include/surf/maxmin.h @@ -157,7 +157,7 @@ XBT_PUBLIC(void) lmm_constraint_shared(lmm_constraint_t cnst); * @param cnst The constraint to share * @return 1 if shared, 0 otherwise */ -XBT_PUBLIC(int) lmm_constraint_is_shared(lmm_constraint_t cnst); +XBT_PUBLIC(int) lmm_constraint_sharing_policy(lmm_constraint_t cnst); /** * @brief Free a constraint diff --git a/src/surf/fair_bottleneck.cpp b/src/surf/fair_bottleneck.cpp index 2affd8dcd4..a0cd4c108e 100644 --- a/src/surf/fair_bottleneck.cpp +++ b/src/surf/fair_bottleneck.cpp @@ -102,7 +102,7 @@ void bottleneck_solve(lmm_system_t sys) nb++; } XBT_DEBUG("\tThere are %d variables", nb); - if (nb > 0 && !cnst->shared) + if (nb > 0 && !cnst->sharing_policy) nb = 1; if (!nb) { cnst->remaining = 0.0; @@ -141,7 +141,7 @@ void bottleneck_solve(lmm_system_t sys) elem = (lmm_element_t)_elem; if (elem->variable->weight <= 0) break; - if (cnst->shared) { + if (cnst->sharing_policy) { XBT_DEBUG("\tUpdate constraint %p (%g) with variable %p by %g", cnst, cnst->remaining, elem->variable, elem->variable->mu); @@ -154,7 +154,7 @@ void bottleneck_solve(lmm_system_t sys) cnst->usage = MIN(cnst->usage, elem->value * elem->variable->mu); } } - if (!cnst->shared) { + if (!cnst->sharing_policy) { XBT_DEBUG("\tUpdate constraint %p (%g) by %g", cnst, cnst->remaining, cnst->usage); diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index 717e89a12d..ec97d10308 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -566,9 +566,9 @@ void LinkL07::updateLatency(double value, double date) } -bool LinkL07::isShared() +int LinkL07::sharingPolicy() { - return lmm_constraint_is_shared(getConstraint()); + return lmm_constraint_sharing_policy(getConstraint()); } /********** diff --git a/src/surf/host_ptask_L07.hpp b/src/surf/host_ptask_L07.hpp index 6092bfa21e..86acc7d266 100644 --- a/src/surf/host_ptask_L07.hpp +++ b/src/surf/host_ptask_L07.hpp @@ -138,7 +138,7 @@ public: void updateState(tmgr_trace_event_t event_type, double value, double date); double getBandwidth(); double getLatency(); - bool isShared(); + int sharingPolicy(); void updateBandwidth(double value, double date=surf_get_clock()); void updateLatency(double value, double date=surf_get_clock()); diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index a060d6b7f2..57507b9b97 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -157,7 +157,7 @@ lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, cnst->bound = bound_value; cnst->usage = 0; - cnst->shared = 1; + cnst->sharing_policy = 1; /* FIXME: don't hardcode the value */ insert_constraint(sys, cnst); return cnst; @@ -165,12 +165,13 @@ lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, void lmm_constraint_shared(lmm_constraint_t cnst) { - cnst->shared = 0; + cnst->sharing_policy = 0; } -int lmm_constraint_is_shared(lmm_constraint_t cnst) +/** Return true if the constraint is shared, and false if it's FATPIPE */ +int lmm_constraint_sharing_policy(lmm_constraint_t cnst) { - return (cnst->shared); + return (cnst->sharing_policy); } XBT_INLINE void lmm_constraint_free(lmm_system_t sys, @@ -382,7 +383,7 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, break; if (i < var->cnsts_number) { - if (cnst->shared) + if (cnst->sharing_policy) var->cnsts[i].value += value; else var->cnsts[i].value = MAX(var->cnsts[i].value, value); @@ -556,7 +557,7 @@ void lmm_print(lmm_system_t sys) trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); - sprintf(print_buf, "%s(",(cnst->shared)?"":"max"); + sprintf(print_buf, "%s(",(cnst->sharing_policy)?"":"max"); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); @@ -564,22 +565,22 @@ void lmm_print(lmm_system_t sys) xbt_swag_foreach(_elem, elem_list) { elem = (lmm_element_t)_elem; sprintf(print_buf, "%f.'%d'(%f) %s ", elem->value, - elem->variable->id_int, elem->variable->value,(cnst->shared)?"+":","); + elem->variable->id_int, elem->variable->value,(cnst->sharing_policy)?"+":","); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); - if(cnst->shared) - sum += elem->value * elem->variable->value; + if(cnst->sharing_policy) + sum += elem->value * elem->variable->value; else - sum = MAX(sum,elem->value * elem->variable->value); + sum = MAX(sum,elem->value * elem->variable->value); } sprintf(print_buf, "0) <= %f ('%d')", cnst->bound, cnst->id_int); trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); - if (!cnst->shared) { + if (!cnst->sharing_policy) { sprintf(print_buf, " [MAX-Constraint]"); trace_buf = (char*) xbt_realloc(trace_buf, @@ -670,7 +671,7 @@ void lmm_solve(lmm_system_t sys) if (elem->variable->weight <= 0) break; if ((elem->value > 0)) { - if (cnst->shared) + if (cnst->sharing_policy) cnst->usage += elem->value / elem->variable->weight; else if (cnst->usage < elem->value / elem->variable->weight) cnst->usage = elem->value / elem->variable->weight; @@ -753,7 +754,7 @@ void lmm_solve(lmm_system_t sys) for (i = 0; i < var->cnsts_number; i++) { elem = &var->cnsts[i]; cnst = elem->constraint; - if (cnst->shared) { + if (cnst->sharing_policy) { //Remember: shared constraints require that sum(elem->value * var->value) < cnst->bound double_update(&(cnst->remaining), elem->value * var->value, cnst->bound*sg_maxmin_precision); double_update(&(cnst->usage), elem->value / var->weight, sg_maxmin_precision); @@ -1028,7 +1029,7 @@ double lmm_constraint_get_usage(lmm_constraint_t cnst) { if (elem->variable->weight <= 0) break; if ((elem->value > 0)) { - if (cnst->shared) + if (cnst->sharing_policy) usage += elem->value * elem->variable->value; else if (usage < elem->value * elem->variable->value) usage = elem->value * elem->variable->value; diff --git a/src/surf/maxmin_private.hpp b/src/surf/maxmin_private.hpp index 48479c8ddd..b08682769c 100644 --- a/src/surf/maxmin_private.hpp +++ b/src/surf/maxmin_private.hpp @@ -49,7 +49,7 @@ typedef struct lmm_constraint { double remaining; double usage; double bound; - int shared; + int sharing_policy; /* see @e_surf_link_sharing_policy_t (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */ void *id; int id_int; double lambda; diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 380332f276..3daac06b85 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -25,7 +25,7 @@ Link * sg_link_by_name(const char* name) { } int sg_link_is_shared(Link *link){ - return link->isShared(); + return link->sharingPolicy(); } double sg_link_bandwidth(Link *link){ return link->getBandwidth(); @@ -221,9 +221,9 @@ double Link::getBandwidth() return p_power.peak * p_power.scale; } -bool Link::isShared() +int Link::sharingPolicy() { - return lmm_constraint_is_shared(getConstraint()); + return lmm_constraint_sharing_policy(getConstraint()); } void Link::setState(e_surf_resource_state_t state){ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index bfd51b0b50..c89b7ff507 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -217,12 +217,8 @@ public: /** @brief Update the latency in seconds of current Link */ virtual void updateLatency(double value, double date=surf_get_clock())=0; - /** - * @brief Check if the Link is shared - * - * @return true if the current NetwokrLink is shared, false otherwise - */ - virtual bool isShared(); + /** @brief The sharing policy is a @e_surf_link_sharing_policy_t (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */ + virtual int sharingPolicy(); /** @brief Check if the Link is used */ bool isUsed(); -- 2.20.1