#include <lauxlib.h>
}
-#include <simgrid/host.h>
#include "src/surf/surf_private.h"
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <simgrid/host.h>
+#include <string>
+#include <vector>
XBT_LOG_NEW_DEFAULT_CATEGORY(lua_platf, "Lua bindings (platform module)");
lua_ensure(type == LUA_TSTRING,
"Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces.");
route.link_list = new std::vector<simgrid::surf::LinkImpl*>();
- xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
- if (xbt_dynar_is_empty(names)) {
+ std::vector<std::string> names;
+ boost::split(names, lua_tostring(L, -1), boost::is_any_of(", \t\r\n"));
+ if (names.empty()) {
/* unique name */
route.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
} else {
// Several names separated by , \t\r\n
- unsigned int cpt;
- char *name;
- xbt_dynar_foreach(names, cpt, name) {
- if (strlen(name)>0) {
- simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
+ for (auto name : names) {
+ if (name.length() > 0) {
+ simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name.c_str());
route.link_list->push_back(link);
}
}
}
- xbt_dynar_free(&names);
lua_pop(L,1);
/* We are relying on the XML bypassing mechanism since the corresponding sg_platf does not exist yet.
lua_pushstring(L,"links");
lua_gettable(L,-2);
ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
- xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
- if (xbt_dynar_is_empty(names)) {
+ std::vector<std::string> names;
+ boost::split(names, lua_tostring(L, -1), boost::is_any_of(", \t\r\n"));
+ if (names.empty()) {
/* unique name with no comma */
ASroute.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
} else {
// Several names separated by , \t\r\n
- unsigned int cpt;
- char *name;
- xbt_dynar_foreach(names, cpt, name) {
- if (strlen(name)>0) {
- simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
+ for (auto name : names) {
+ if (name.length() > 0) {
+ simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name.c_str());
ASroute.link_list->push_back(link);
}
}
#include "src/kernel/routing/TorusZone.hpp"
#include "src/kernel/routing/NetPoint.hpp"
#include "src/surf/network_interface.hpp"
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <string>
+#include <vector>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster_torus, surf_route_cluster, "Torus Routing part of surf");
void TorusZone::parse_specific_arguments(sg_platf_cluster_cbarg_t cluster)
{
+ std::vector<std::string> dimensions;
+ boost::split(dimensions, cluster->topo_parameters, boost::is_any_of(","));
- unsigned int iter;
- char* groups;
- xbt_dynar_t dimensions = xbt_str_split(cluster->topo_parameters, ",");
-
- if (!xbt_dynar_is_empty(dimensions)) {
+ if (!dimensions.empty()) {
/* We are in a torus cluster
* Parse attribute dimensions="dim1,dim2,dim3,...,dimN" and safe it in a vector.
* Additionally, we need to know how many ranks we have in total
*/
- xbt_dynar_foreach (dimensions, iter, groups) {
- dimensions_.push_back(surf_parse_get_int(groups));
+ for (auto group : dimensions) {
+ dimensions_.push_back(surf_parse_get_int(group.c_str()));
}
linkCountPerNode_ = dimensions_.size();
}
- xbt_dynar_free(&dimensions);
}
void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t route, double* lat)
#include "src/surf/maxmin_private.hpp"
#include "src/surf/network_ib.hpp"
#include "src/surf/xml/platf.hpp"
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
active_nodes=nullptr;
const char* IB_factors_string=xbt_cfg_get_string("smpi/IB-penalty-factors");
- xbt_dynar_t radical_elements = xbt_str_split(IB_factors_string, ";");
-
- surf_parse_assert(xbt_dynar_length(radical_elements)==3,
- "smpi/IB-penalty-factors should be provided and contain 3 elements, semi-colon separated. Example: 0.965;0.925;1.35");
-
- Be = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 0, char *), "First part of smpi/IB-penalty-factors is not numerical: %s");
- Bs = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 1, char *), "Second part of smpi/IB-penalty-factors is not numerical: %s");
- ys = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 2, char *), "Third part of smpi/IB-penalty-factors is not numerical: %s");
-
- xbt_dynar_free(&radical_elements);
+ std::vector<std::string> radical_elements;
+ boost::split(radical_elements, IB_factors_string, boost::is_any_of(";"));
+
+ surf_parse_assert(radical_elements.size() == 3, "smpi/IB-penalty-factors should be provided and contain 3 "
+ "elements, semi-colon separated. Example: 0.965;0.925;1.35");
+
+ Be = xbt_str_parse_double(radical_elements.front().c_str(),
+ "First part of smpi/IB-penalty-factors is not numerical: %s");
+ Bs = xbt_str_parse_double((radical_elements.at(1)).c_str(),
+ "Second part of smpi/IB-penalty-factors is not numerical: %s");
+ ys = xbt_str_parse_double(radical_elements.back().c_str(),
+ "Third part of smpi/IB-penalty-factors is not numerical: %s");
}
NetworkIBModel::~NetworkIBModel()
#include "simgrid/simix.hpp"
#include "src/plugins/vm/VirtualMachineImpl.hpp"
#include "src/surf/cpu_interface.hpp"
+
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
#include <simgrid/s4u/engine.hpp>
+#include <string>
#include <utility>
+#include <vector>
/** @addtogroup SURF_plugin_energy
if (all_power_values_str == nullptr)
return;
- xbt_dynar_t all_power_values = xbt_str_split(all_power_values_str, ",");
- int pstate_nb = xbt_dynar_length(all_power_values);
+ std::vector<std::string> all_power_values;
+ boost::split(all_power_values, all_power_values_str, boost::is_any_of(","));
- for (int i = 0; i < pstate_nb; i++) {
+ int i = 0;
+ for (auto current_power_values_str : all_power_values) {
/* retrieve the power values associated with the current pstate */
- xbt_dynar_t current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
- xbt_assert(xbt_dynar_length(current_power_values) == 3,
- "Power properties incorrectly defined - could not retrieve idle, min and max power values for host %s",
+ std::vector<std::string> current_power_values;
+ boost::split(current_power_values, current_power_values_str, boost::is_any_of(":"));
+ xbt_assert(current_power_values.size() == 3, "Power properties incorrectly defined - "
+ "could not retrieve idle, min and max power values for host %s",
host->cname());
/* min_power corresponds to the idle power (cpu load = 0) */
char* msg_idle = bprintf("Invalid idle value for pstate %d on host %s: %%s", i, host->cname());
char* msg_min = bprintf("Invalid min value for pstate %d on host %s: %%s", i, host->cname());
char* msg_max = bprintf("Invalid max value for pstate %d on host %s: %%s", i, host->cname());
- PowerRange range(xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 0, char*), msg_idle),
- xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 1, char*), msg_min),
- xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 2, char*), msg_max));
+ PowerRange range(xbt_str_parse_double((current_power_values.at(0)).c_str(), msg_idle),
+ xbt_str_parse_double((current_power_values.at(1)).c_str(), msg_min),
+ xbt_str_parse_double((current_power_values.at(2)).c_str(), msg_max));
power_range_watts_list.push_back(range);
xbt_free(msg_idle);
xbt_free(msg_min);
xbt_free(msg_max);
-
- xbt_dynar_free(¤t_power_values);
+ i++;
}
- xbt_dynar_free(&all_power_values);
}
}
}
#include "xbt/log.h"
#include "xbt/misc.h"
#include "xbt/str.h"
-#include <string>
#include "src/surf/xml/platf_private.hpp"
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <string>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, "Logging specific to the SURF parsing module");
static std::vector<int>* explodesRadical(const char* radicals)
{
std::vector<int>* exploded = new std::vector<int>();
- char* groups;
- unsigned int iter;
// Make all hosts
- xbt_dynar_t radical_elements = xbt_str_split(radicals, ",");
- xbt_dynar_foreach (radical_elements, iter, groups) {
-
- xbt_dynar_t radical_ends = xbt_str_split(groups, "-");
- int start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char*));
+ std::vector<std::string> radical_elements;
+ boost::split(radical_elements, radicals, boost::is_any_of(","));
+ for (auto group : radical_elements) {
+ std::vector<std::string> radical_ends;
+ boost::split(radical_ends, group, boost::is_any_of("-"));
+ int start = surf_parse_get_int((radical_ends.front()).c_str());
int end = 0;
- switch (xbt_dynar_length(radical_ends)) {
+ switch (radical_ends.size()) {
case 1:
end = start;
break;
case 2:
- end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char*));
+ end = surf_parse_get_int((radical_ends.back()).c_str());
break;
default:
- surf_parse_error("Malformed radical: %s", groups);
+ surf_parse_error("Malformed radical: %s", group.c_str());
break;
}
-
for (int i = start; i <= end; i++)
exploded->push_back(i);
-
- xbt_dynar_free(&radical_ends);
}
- xbt_dynar_free(&radical_elements);
return exploded;
}
double speed = surf_parse_get_speed(speeds, entity_kind, id);
speed_per_pstate.push_back(speed);
} else {
- xbt_dynar_t pstate_list = xbt_str_split(speeds, ",");
- unsigned int i;
- char* speed_str;
- xbt_dynar_foreach(pstate_list, i, speed_str) {
- xbt_str_trim(speed_str, nullptr);
- double speed = surf_parse_get_speed(speed_str,entity_kind, id);
+ std::vector<std::string> pstate_list;
+ boost::split(pstate_list, speeds, boost::is_any_of(","));
+ for (auto speed_str : pstate_list) {
+ boost::trim(speed_str);
+ double speed = surf_parse_get_speed(speed_str.c_str(), entity_kind, id);
speed_per_pstate.push_back(speed);
XBT_DEBUG("Speed value: %f", speed);
}
- xbt_dynar_free(&pstate_list);
}
return speed_per_pstate;
}