X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a6071d1660902b3e0634c8ee6b7508e7f965c787..5f5a10db6fc4552782638abb4817041223e17775:/src/smpi/internals/smpi_host.cpp diff --git a/src/smpi/internals/smpi_host.cpp b/src/smpi/internals/smpi_host.cpp index a206de910e..8704fbeb08 100644 --- a/src/smpi/internals/smpi_host.cpp +++ b/src/smpi/internals/smpi_host.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2017-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -33,54 +33,31 @@ namespace simgrid::smpi { xbt::Extension Host::EXTENSION_ID; -static double factor_use(std::vector& factors, const char* name, size_t size) -{ - /* fallback to smpi/or config */ - double current = factors.empty() ? 0.0 : factors.front().values[0] + factors.front().values[1] * size; - - // Iterate over all the sections that were specified and find the right value. (fact.factor represents the interval - // sizes; we want to find the section that has fact.factor <= size and no other such fact.factor <= size) - // Note: parse_factor() (used before) already sorts the vector we iterate over! - for (auto const& fact : factors) { - if (size <= fact.factor) { // Values already too large, use the previously computed value of current! - XBT_DEBUG("%s: %zu <= %zu return %.10f", name, size, fact.factor, current); - return current; - } else { - // If the next section is too large, the current section must be used. - // Hence, save the cost, as we might have to use it. - current=fact.values[0]+fact.values[1]*size; - } - } - XBT_DEBUG("%s: %zu is larger than largest boundary, return %.10f", name, size, current); - - return current; -} - -double Host::orecv(size_t size, s4u::Host* src, s4u::Host* dst) +double Host::orecv(size_t size, s4u::Host* src, s4u::Host* dst) const { /* return user's callback if available */ if (auto it = cost_cbs.find(SmpiOperation::RECV); it != cost_cbs.end()) return it->second(size, src, dst); - return factor_use(orecv_parsed_values, "smpi/or", size); + return orecv_(size); } -double Host::osend(size_t size, s4u::Host* src, s4u::Host* dst) +double Host::osend(size_t size, s4u::Host* src, s4u::Host* dst) const { /* return user's callback if available */ if (auto it = cost_cbs.find(SmpiOperation::SEND); it != cost_cbs.end()) return it->second(size, src, dst); - return factor_use(osend_parsed_values, "smpi/os", size); + return osend_(size); } -double Host::oisend(size_t size, s4u::Host* src, s4u::Host* dst) +double Host::oisend(size_t size, s4u::Host* src, s4u::Host* dst) const { /* return user's callback if available */ if (auto it = cost_cbs.find(SmpiOperation::ISEND); it != cost_cbs.end()) return it->second(size, src, dst); - return factor_use(oisend_parsed_values, "smpi/ois", size); + return oisend_(size); } void Host::check_factor_configs(const std::string& op) const @@ -100,25 +77,22 @@ Host::Host(s4u::Host* ptr) : host(ptr) smpi::Host::EXTENSION_ID = s4u::Host::extension_create(); check_factor_configs("smpi/or"); - if (const char* orecv_string = host->get_property("smpi/or")) { - orecv_parsed_values = simgrid::smpi::utils::parse_factor(orecv_string); - } else { - orecv_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value("smpi/or")); - } + if (const char* orecv_string = host->get_property("smpi/or")) + orecv_.parse(orecv_string); + else + orecv_.parse(config::get_value("smpi/or")); check_factor_configs("smpi/os"); - if (const char* osend_string = host->get_property("smpi/os")) { - osend_parsed_values = simgrid::smpi::utils::parse_factor(osend_string); - } else { - osend_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value("smpi/os")); - } + if (const char* osend_string = host->get_property("smpi/os")) + osend_.parse(osend_string); + else + osend_.parse(config::get_value("smpi/os")); check_factor_configs("smpi/ois"); - if (const char* oisend_string = host->get_property("smpi/ois")) { - oisend_parsed_values = simgrid::smpi::utils::parse_factor(oisend_string); - } else { - oisend_parsed_values = simgrid::smpi::utils::parse_factor(config::get_value("smpi/ois")); - } + if (const char* oisend_string = host->get_property("smpi/ois")) + oisend_.parse(oisend_string); + else + oisend_.parse(config::get_value("smpi/ois")); } } // namespace simgrid::smpi