char* process_id = nullptr;
// FIXME: dirty extract "rank-" from the name, as we want the bare process id here
- if (strstr(container->name_.c_str(), "rank-") == nullptr)
- process_id = xbt_strdup(container->name_.c_str());
+ if (container->getName().find("rank-") != 0)
+ process_id = xbt_strdup(container->getCname());
else
- process_id = xbt_strdup(container->name_.c_str() + 5);
+ process_id = xbt_strdup(container->getCname() + 5);
FILE* trace_file = tracing_files.at(container);
class Container {
e_container_types kind_; /* This container is of what kind */
+ std::string name_; /* Unique name of this container */
int level_ = 0; /* Level in the hierarchy, root level is 0 */
sg_netpoint_t netpoint_ = nullptr;
Container(std::string name, simgrid::instr::e_container_types kind, Container* father);
virtual ~Container();
- std::string name_; /* Unique name of this container */
std::string id_; /* Unique id of this container */
Type* type_; /* Type of this container */
Container* father_;
std::map<std::string, Container*> children_;
static Container* byNameOrNull(std::string name);
static Container* byName(std::string name);
+ std::string getName() { return name_; }
+ const char* getCname() { return name_.c_str(); }
void removeFromParent();
void logCreation();
void logDestruction();
//to check if variables were previously set to 0, otherwise paje won't simulate them
static std::unordered_map<std::string, std::string> platform_variables;
-//used by all methods
-static void __TRACE_surf_check_variable_set_to_zero(double now, const char* variable, std::string resource)
+static void instr_event(double now, double delta, simgrid::instr::Type* variable, container_t resource, double value)
{
- /* To trace resource utilization, we use pajeAddVariable and pajeSubVariable only.
- * The Paje simulator needs a pajeSetVariable in the first place so it knows the initial value of all variables for
- * subsequent adds/subs. If we don't do so, the first pajeAddVariable is added to a non-determined value within
- * the Paje simulator, causing analysis problems.
+ /* To trace resource utilization, we use AddVariableEvent and SubVariableEvent only. This implies to add a
+ * SetVariableEvent first to set the initial value of all variables for subsequent adds/subs. If we don't do so,
+ * the first AddVariableEvent would be added to a non-determined value, hence causing analysis problems.
*/
// create a key considering the resource and variable
- std::string key = resource + variable;
+ std::string key = resource->getName() + variable->getName();
- // check if key exists: if it doesn't, set the variable to zero and mark this in the dict
+ // check if key exists: if it doesn't, set the variable to zero and mark this in the global map.
if (platform_variables.find(key) == platform_variables.end()) {
- container_t container = simgrid::instr::Container::byName(resource);
- simgrid::instr::Type* type = container->type_->byName(variable);
- new simgrid::instr::SetVariableEvent(now, container, type, 0);
+ new simgrid::instr::SetVariableEvent(now, resource, variable, 0);
platform_variables[key] = std::string("");
}
-}
-static void instr_event(double now, double delta, simgrid::instr::Type* variable, container_t resource, double value)
-{
- __TRACE_surf_check_variable_set_to_zero(now, variable->getCname(), resource->name_);
new simgrid::instr::AddVariableEvent(now, resource, variable, value);
new simgrid::instr::SubVariableEvent(now + delta, resource, variable, value);
}
void TRACE_surf_link_set_utilization(const char *resource, const char *category, double value, double now, double delta)
{
//only trace link utilization if link is known by tracing mechanism
- if (not simgrid::instr::Container::byNameOrNull(resource))
- return;
- if (not value)
+ container_t container = simgrid::instr::Container::byNameOrNull(resource);
+ if (not container || not value)
return;
//trace uncategorized link utilization
if (TRACE_uncategorized()){
- XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value);
- container_t container = simgrid::instr::Container::byName(resource);
+ XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now + delta, resource, value);
simgrid::instr::Type* type = container->type_->byName("bandwidth_used");
instr_event (now, delta, type, container, value);
}
if (not category)
return;
//variable of this category starts by 'b', because we have a link here
- char category_type[INSTR_DEFAULT_STR_SIZE];
- snprintf (category_type, INSTR_DEFAULT_STR_SIZE, "b%s", category);
- XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, category_type, value);
- container_t container = simgrid::instr::Container::byName(resource);
+ std::string category_type = std::string("b") + category;
+ XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now + delta, resource, category_type.c_str(), value);
simgrid::instr::Type* type = container->type_->byName(category_type);
instr_event (now, delta, type, container, value);
}
if (not category)
return;
//variable of this category starts by 'p', because we have a host here
- char category_type[INSTR_DEFAULT_STR_SIZE];
- snprintf (category_type, INSTR_DEFAULT_STR_SIZE, "p%s", category);
- XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now+delta, resource, category_type, value);
+ std::string category_type = std::string("p") + category;
+ XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now + delta, resource, category_type.c_str(), value);
simgrid::instr::Type* type = container->type_->byName(category_type);
instr_event (now, delta, type, container, value);
}
static void linkContainers(container_t src, container_t dst, std::set<std::string>* filter)
{
//ignore loopback
- if (src->name_ == "__loopback__" || dst->name_ == "__loopback__") {
+ if (src->getName() == "__loopback__" || dst->getName() == "__loopback__") {
XBT_DEBUG (" linkContainers: ignoring loopback link");
return;
}
}
// check if we already register this pair (we only need one direction)
- std::string aux1 = src->name_ + dst->name_;
- std::string aux2 = dst->name_ + src->name_;
+ std::string aux1 = src->getName() + dst->getName();
+ std::string aux2 = dst->getName() + src->getName();
if (filter->find(aux1) != filter->end()) {
- XBT_DEBUG(" linkContainers: already registered %s <-> %s (1)", src->name_.c_str(), dst->name_.c_str());
+ XBT_DEBUG(" linkContainers: already registered %s <-> %s (1)", src->getCname(), dst->getCname());
return;
}
if (filter->find(aux2) != filter->end()) {
- XBT_DEBUG(" linkContainers: already registered %s <-> %s (2)", dst->name_.c_str(), src->name_.c_str());
+ XBT_DEBUG(" linkContainers: already registered %s <-> %s (2)", dst->getCname(), src->getCname());
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_.c_str(), dst->name_.c_str());
+ XBT_DEBUG(" linkContainers %s <-> %s", src->getCname(), dst->getCname());
}
static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t container,
{
if (currentContainer.empty()) // No ongoing parsing. Are you creating the loopback?
return;
- container_t father = currentContainer.back();
-
- double bandwidth_value = link.bandwidth();
- double latency_value = link.latency();
- container_t container = new simgrid::instr::Container(link.getCname(), simgrid::instr::INSTR_LINK, father);
+ container_t father = currentContainer.back();
+ container_t container = new simgrid::instr::Container(link.getName(), simgrid::instr::INSTR_LINK, father);
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
simgrid::instr::Type* bandwidth = container->type_->getOrCreateVariableType("bandwidth", "");
simgrid::instr::Type* latency = container->type_->getOrCreateVariableType("latency", "");
- new simgrid::instr::SetVariableEvent(0, container, bandwidth, bandwidth_value);
- new simgrid::instr::SetVariableEvent(0, container, latency, latency_value);
+ new simgrid::instr::SetVariableEvent(0, container, bandwidth, link.bandwidth());
+ new simgrid::instr::SetVariableEvent(0, container, latency, link.latency());
}
if (TRACE_uncategorized()) {
container->type_->getOrCreateVariableType("bandwidth_used", "0.5 0.5 0.5");
static void sg_instr_new_host(simgrid::s4u::Host& host)
{
container_t father = currentContainer.back();
- container_t container = new simgrid::instr::Container(host.getCname(), simgrid::instr::INSTR_HOST, father);
+ container_t container = new simgrid::instr::Container(host.getName(), simgrid::instr::INSTR_HOST, father);
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
simgrid::instr::Type* speed = container->type_->getOrCreateVariableType("power", "");
-
- double current_speed_state = host.getSpeed();
- new simgrid::instr::SetVariableEvent(0, container, speed, current_speed_state);
+ new simgrid::instr::SetVariableEvent(0, container, speed, host.getSpeed());
}
+
if (TRACE_uncategorized())
container->type_->getOrCreateVariableType("power_used", "0.5 0.5 0.5");
{
if (not netpoint->isRouter())
return;
- if (TRACE_is_enabled() && TRACE_needs_platform()) {
- container_t father = currentContainer.back();
- new simgrid::instr::Container(netpoint->getCname(), simgrid::instr::INSTR_ROUTER, father);
- }
+ if (TRACE_is_enabled() && TRACE_needs_platform())
+ new simgrid::instr::Container(netpoint->getCname(), simgrid::instr::INSTR_ROUTER, currentContainer.back());
}
static void instr_routing_parse_end_platform ()
}
simgrid::s4u::NetZone::onCreation.connect(sg_instr_AS_begin);
simgrid::s4u::NetZone::onSeal.connect(sg_instr_AS_end);
- simgrid::kernel::routing::NetPoint::onCreation.connect(&sg_instr_new_router);
+ simgrid::kernel::routing::NetPoint::onCreation.connect(sg_instr_new_router);
}
/*
* user categories support