/* 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. */
-#include "src/instr/instr_private.h"
+#include "src/instr/instr_private.hpp"
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
static void linkContainers(container_t src, container_t dst, std::set<std::string>* filter)
{
//ignore loopback
- if (strcmp(src->name_, "__loopback__") == 0 || strcmp(dst->name_, "__loopback__") == 0) {
+ if (src->name_ == "__loopback__" || dst->name_ == "__loopback__") {
XBT_DEBUG (" linkContainers: ignoring loopback link");
return;
}
}
// check if we already register this pair (we only need one direction)
- std::string aux1 = std::string(src->name_) + dst->name_;
- std::string aux2 = std::string(dst->name_) + src->name_;
+ std::string aux1 = src->name_ + dst->name_;
+ std::string aux2 = dst->name_ + src->name_;
if (filter->find(aux1) != filter->end()) {
- XBT_DEBUG(" linkContainers: already registered %s <-> %s (1)", src->name_, dst->name_);
+ XBT_DEBUG(" linkContainers: already registered %s <-> %s (1)", src->name_.c_str(), dst->name_.c_str());
return;
}
if (filter->find(aux2) != filter->end()) {
- XBT_DEBUG(" linkContainers: already registered %s <-> %s (2)", dst->name_, src->name_);
+ XBT_DEBUG(" linkContainers: already registered %s <-> %s (2)", dst->name_.c_str(), src->name_.c_str());
return;
}
new simgrid::instr::StartLinkEvent(SIMIX_get_clock(), father, link_type, src, "topology", key);
new simgrid::instr::EndLinkEvent(SIMIX_get_clock(), father, link_type, dst, "topology", key);
- XBT_DEBUG(" linkContainers %s <-> %s", src->name_, dst->name_);
+ XBT_DEBUG(" linkContainers %s <-> %s", src->name_.c_str(), dst->name_.c_str());
}
static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t container,
if (not netzone->getChildren()->empty()) {
//bottom-up recursion
for (auto const& nz_son : *netzone->getChildren()) {
- container_t child_container = static_cast<container_t>(xbt_dict_get(container->children_, nz_son->getCname()));
+ container_t child_container = container->children_.at(nz_son->getCname());
recursiveGraphExtraction(nz_son, child_container, filter);
}
}
static_cast<simgrid::kernel::routing::NetZoneImpl*>(netzone)->getGraph(graph, nodes, edges);
xbt_dict_foreach(edges,cursor,edge_name,edge) {
- linkContainers(
- PJ_container_get(static_cast<const char*>(edge->src->data)),
- PJ_container_get(static_cast<const char*>(edge->dst->data)), filter);
+ linkContainers(simgrid::instr::Container::byName(static_cast<const char*>(edge->src->data)),
+ simgrid::instr::Container::byName(static_cast<const char*>(edge->dst->data)), filter);
}
xbt_dict_free (&nodes);
xbt_dict_free (&edges);
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
simgrid::instr::Type* bandwidth = container->type_->getChildOrNull("bandwidth");
if (bandwidth == nullptr)
- bandwidth = simgrid::instr::Type::variableNew("bandwidth", nullptr, container->type_);
+ bandwidth = simgrid::instr::Type::variableNew("bandwidth", "", container->type_);
simgrid::instr::Type* latency = container->type_->getChildOrNull("latency");
if (latency == nullptr)
- latency = simgrid::instr::Type::variableNew("latency", nullptr, container->type_);
+ latency = simgrid::instr::Type::variableNew("latency", "", container->type_);
new simgrid::instr::SetVariableEvent(0, container, bandwidth, bandwidth_value);
new simgrid::instr::SetVariableEvent(0, container, latency, latency_value);
}
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
simgrid::instr::Type* speed = container->type_->getChildOrNull("power");
if (speed == nullptr){
- speed = simgrid::instr::Type::variableNew("power", nullptr, container->type_);
+ speed = simgrid::instr::Type::variableNew("power", "", container->type_);
}
double current_speed_state = host.getSpeed();
if (msg_process == nullptr){
msg_process = simgrid::instr::Type::containerNew("MSG_PROCESS", container->type_);
simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_PROCESS_STATE", msg_process);
- new simgrid::instr::Value("suspend", "1 0 1", state);
- simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
- simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
- simgrid::instr::Value::get_or_new("send", "0 0 1", state);
- simgrid::instr::Value::get_or_new("task_execute", "0 1 1", state);
+ simgrid::instr::Value::byNameOrCreate("suspend", "1 0 1", state);
+ simgrid::instr::Value::byNameOrCreate("sleep", "1 1 0", state);
+ simgrid::instr::Value::byNameOrCreate("receive", "1 0 0", state);
+ simgrid::instr::Value::byNameOrCreate("send", "0 0 1", state);
+ simgrid::instr::Value::byNameOrCreate("task_execute", "0 1 1", state);
simgrid::instr::Type::linkNew("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process);
simgrid::instr::Type::linkNew("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process);
}
if (msg_vm == nullptr){
msg_vm = simgrid::instr::Type::containerNew("MSG_VM", container->type_);
simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_VM_STATE", msg_vm);
- new simgrid::instr::Value("suspend", "1 0 1", state);
- simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
- simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
- simgrid::instr::Value::get_or_new("send", "0 0 1", state);
- simgrid::instr::Value::get_or_new("task_execute", "0 1 1", state);
+ simgrid::instr::Value::byNameOrCreate("suspend", "1 0 1", state);
+ simgrid::instr::Value::byNameOrCreate("sleep", "1 1 0", state);
+ simgrid::instr::Value::byNameOrCreate("receive", "1 0 0", state);
+ simgrid::instr::Value::byNameOrCreate("send", "0 0 1", state);
+ simgrid::instr::Value::byNameOrCreate("task_execute", "0 1 1", state);
simgrid::instr::Type::linkNew("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm);
simgrid::instr::Type::linkNew("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm);
}
}
-
}
static void sg_instr_new_router(simgrid::kernel::routing::NetPoint * netpoint)
*/
static void recursiveNewVariableType(const char* new_typename, const char* color, simgrid::instr::Type* root)
{
+
if (not strcmp(root->name_, "HOST")) {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
- simgrid::instr::Type::variableNew(tnstr, color, root);
+ simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
}
if (not strcmp(root->name_, "MSG_VM")) {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
- simgrid::instr::Type::variableNew(tnstr, color, root);
+ simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
}
if (not strcmp(root->name_, "LINK")) {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "b%s", new_typename);
- simgrid::instr::Type::variableNew(tnstr, color, root);
+ simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
}
xbt_dict_cursor_t cursor = nullptr;
simgrid::instr::Type* child_type;
char *name;
xbt_dict_foreach (root->children_, cursor, name, child_type) {
- recursiveNewVariableType (new_typename, color, child_type);
+ recursiveNewVariableType(new_typename, color == nullptr ? "" : color, child_type);
}
}
simgrid::instr::Type* root)
{
if (not strcmp(root->name_, father_type)) {
- simgrid::instr::Type::variableNew(new_typename, color, root);
+ simgrid::instr::Type::variableNew(new_typename, color == nullptr ? "" : color, root);
}
xbt_dict_cursor_t cursor = nullptr;
simgrid::instr::Type* child_type;
simgrid::instr::Type* root)
{
if (not strcmp(root->name_, type_name)) {
- new simgrid::instr::Value(val, color, root);
+ simgrid::instr::Value::byNameOrCreate(val, color, root);
}
xbt_dict_cursor_t cursor = nullptr;
simgrid::instr::Type* child_type;
if (not netzone->getChildren()->empty()) {
//bottom-up recursion
for (auto const& netzone_child : *netzone->getChildren()) {
- container_t child_container =
- static_cast<container_t>(xbt_dict_get(container->children_, netzone_child->getCname()));
+ container_t child_container = container->children_.at(netzone_child->getCname());
recursiveXBTGraphExtraction(graph, nodes, edges, netzone_child, child_container);
}
}