From 913c6a415bb94569081a13769ed15d521d3a0e4e Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Thu, 26 Oct 2017 19:14:46 +0200 Subject: [PATCH] get rid of kind field in instr Type use derived classes and some casts instead --- src/instr/instr_interface.cpp | 9 +- src/instr/instr_paje_trace.cpp | 91 ----------- src/instr/instr_paje_types.cpp | 166 ++++++++++++--------- src/instr/instr_private.hpp | 72 ++++++--- src/msg/instr_msg_process.cpp | 8 +- src/msg/instr_msg_task.cpp | 18 ++- src/msg/msg_vm.cpp | 6 +- src/smpi/colls/smpi_automatic_selector.cpp | 3 +- src/smpi/internals/instr_smpi.cpp | 26 ++-- src/surf/instr_routing.cpp | 15 +- 10 files changed, 196 insertions(+), 218 deletions(-) diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index 3cea149dd1..9ca67ce5e7 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -186,7 +186,7 @@ void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mar mark_color = "1.0 1.0 1.0" /*white*/; XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color); - type->addEntityValue(mark_value, mark_color); + static_cast(type)->addEntityValue(mark_value, mark_color); } } @@ -233,7 +233,8 @@ void TRACE_mark(const char *mark_type, const char *mark_value) THROWF (tracing_error, 1, "mark_value is nullptr"); //check if mark_type is already declared - simgrid::instr::Type* type = simgrid::instr::Type::getRootType()->byName(mark_type); + simgrid::instr::EventType* type = + static_cast(simgrid::instr::Type::getRootType()->byName(mark_type)); if (not type) { THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type); } else { @@ -940,7 +941,7 @@ void TRACE_host_state_declare_value (const char *state, const char *value, const void TRACE_host_set_state(const char* host, const char* state_name, const char* value_name) { container_t container = simgrid::instr::Container::byName(host); - simgrid::instr::Type* state = container->type_->byName(state_name); + simgrid::instr::StateType* state = static_cast(container->type_->byName(state_name)); state->addEntityValue(value_name); new simgrid::instr::SetStateEvent(MSG_get_clock(), container, state, state->getEntityValue(value_name)); } @@ -959,7 +960,7 @@ void TRACE_host_set_state(const char* host, const char* state_name, const char* void TRACE_host_push_state(const char* host, const char* state_name, const char* value_name) { container_t container = simgrid::instr::Container::byName(host); - simgrid::instr::Type* state = container->type_->byName(state_name); + simgrid::instr::StateType* state = static_cast(container->type_->byName(state_name)); state->addEntityValue(value_name); new simgrid::instr::PushStateEvent(MSG_get_clock(), container, state, state->getEntityValue(value_name)); } diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index 973f6d0db3..24d64506a5 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -178,97 +178,6 @@ void TRACE_paje_end() { XBT_DEBUG("Filename %s is closed", filename); } -void simgrid::instr::Type::logContainerTypeDefinition() -{ - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType); - //print it - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType, - TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << simgrid::instr::PAJE_DefineContainerType; - stream << " " << id_ << " " << father_->getId() << " " << name_; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - -void simgrid::instr::Type::logVariableTypeDefinition() -{ - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType); - - //print it - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType, - TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << simgrid::instr::PAJE_DefineVariableType; - stream << " " << id_ << " " << father_->getId() << " " << name_; - if (isColored()) - stream << " \"" << color_ << "\""; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - -void simgrid::instr::Type::logStateTypeDefinition() -{ - //print it - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType, - TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << simgrid::instr::PAJE_DefineStateType; - stream << " " << id_ << " " << father_->getId() << " " << name_; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - -void simgrid::instr::Type::logDefineEventType() -{ - //print it - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineEventType, - TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << simgrid::instr::PAJE_DefineEventType; - stream << " " << id_ << " " << father_->getId() << " " << name_; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - -void simgrid::instr::Type::logLinkTypeDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest) -{ - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType); - //print it - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(), - 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << simgrid::instr::PAJE_DefineLinkType; - stream << " " << id_ << " " << father_->getId() << " " << source->getId() << " " << dest->getId() << " " << name_; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - void simgrid::instr::Value::print() { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue); diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index a6e5a95a25..2cbd8d8dfb 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -8,19 +8,17 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_types, instr, "Paje tracing event system (types)"); -static simgrid::instr::Type* rootType = nullptr; /* the root type */ +static simgrid::instr::ContainerType* rootType = nullptr; /* the root type */ +extern FILE* tracing_file; namespace simgrid { namespace instr { -Type::Type(std::string name, std::string alias, std::string color, e_entity_types kind, Type* father) - : name_(name), color_(color), kind_(kind), father_(father) +Type::Type(std::string name, std::string alias, std::string color, Type* father) + : id_(instr_new_paje_id()), name_(name), color_(color), father_(father) { - if (name.empty() || alias.empty()) { + if (name.empty() || alias.empty()) THROWF(tracing_error, 0, "can't create a new type with no name or alias"); - } - - id_ = std::to_string(instr_new_paje_id()); if (father != nullptr){ father->children_.insert({alias, this}); @@ -30,12 +28,72 @@ Type::Type(std::string name, std::string alias, std::string color, e_entity_type Type::~Type() { - for (auto elm : values_) - delete elm.second; for (auto elm : children_) delete elm.second; } +ValueType::~ValueType() +{ + for (auto elm : values_) + delete elm.second; +} + +ContainerType::ContainerType(std::string name, Type* father) : Type(name, name, "", father) +{ + XBT_DEBUG("ContainerType %s(%lld), child of %s(%lld)", getCname(), getId(), father->getCname(), father->getId()); + logDefinition(PAJE_DefineContainerType); +} + +EventType::EventType(std::string name, Type* father) : ValueType(name, father) +{ + XBT_DEBUG("EventType %s(%lld), child of %s(%lld)", getCname(), getId(), father->getCname(), father->getId()); + logDefinition(PAJE_DefineEventType); +} + +StateType::StateType(std::string name, Type* father) : ValueType(name, father) +{ + XBT_DEBUG("StateType %s(%lld), child of %s(%lld)", getCname(), getId(), father->getCname(), father->getId()); + logDefinition(PAJE_DefineStateType); +} + +VariableType::VariableType(std::string name, std::string color, Type* father) : Type(name, name, color, father) +{ + XBT_DEBUG("VariableType %s(%lld), child of %s(%lld)", getCname(), getId(), father->getCname(), father->getId()); + logDefinition(PAJE_DefineVariableType); +} + +LinkType::LinkType(std::string name, std::string alias, Type* father) : ValueType(name, alias, father) +{ +} + +void Type::logDefinition(e_event_type event_type) +{ + if (instr_fmt_type != instr_fmt_paje) + return; + std::stringstream stream; + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, event_type, TRACE_precision(), 0.); + stream << std::fixed << std::setprecision(TRACE_precision()) << event_type << " " << getId(); + stream << " " << father_->getId() << " " << getName(); + if (isColored()) + stream << " \"" << color_ << "\""; + XBT_DEBUG("Dump %s", stream.str().c_str()); + stream << std::endl; + fprintf(tracing_file, "%s", stream.str().c_str()); +} + +void Type::logDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest) +{ + if (instr_fmt_type != instr_fmt_paje) + return; + std::stringstream stream; + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineLinkType, TRACE_precision(), 0.); + stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_DefineLinkType << " " << getId(); + stream << " " << father_->getId() << " " << source->getId() << " " << dest->getId() << " " << getName(); + XBT_DEBUG("Dump %s", stream.str().c_str()); + stream << std::endl; + fprintf(tracing_file, "%s", stream.str().c_str()); +} + Type* Type::byName(std::string name) { Type* ret = nullptr; @@ -53,29 +111,26 @@ Type* Type::byName(std::string name) return ret; } -void Type::addEntityValue(std::string name) +void ValueType::addEntityValue(std::string name) { addEntityValue(name, ""); } -void Type::addEntityValue(std::string name, std::string color) +void ValueType::addEntityValue(std::string name, std::string color) { - if (name.empty()) { + if (name.empty()) THROWF(tracing_error, 0, "can't get a value with no name"); - } - if (kind_ == TYPE_VARIABLE) - THROWF(tracing_error, 0, "variables can't have different values (%s)", getCname()); auto it = values_.find(name); if (it == values_.end()) { Value* new_val = new Value(name, color, this); values_.insert({name, new_val}); - XBT_DEBUG("new value %s, child of %s", name_.c_str(), getCname()); + XBT_DEBUG("new value %s, child of %s", name.c_str(), getCname()); new_val->print(); } } -Value* Type::getEntityValue(std::string name) +Value* ValueType::getEntityValue(std::string name) { auto ret = values_.find(name); if (ret == values_.end()) { @@ -84,81 +139,54 @@ Value* Type::getEntityValue(std::string name) return ret->second; } -Type* Type::createRootType() +ContainerType* Type::createRootType() { - simgrid::instr::Type* ret = new simgrid::instr::Type("0", "0", "", TYPE_CONTAINER, nullptr); - rootType = ret; - return ret; + rootType = static_cast(new simgrid::instr::Type("0", "0", "", nullptr)); + return rootType; } -Type* Type::getRootType() +ContainerType* Type::getRootType() { return rootType; } -Type* Type::getOrCreateContainerType(std::string name) +ContainerType* Type::getOrCreateContainerType(std::string name) { - auto it = children_.find(name); - if (it == children_.end()) { - Type* ret = new simgrid::instr::Type(name, name, "", TYPE_CONTAINER, this); - XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), getCname(), getId()); - ret->logContainerTypeDefinition(); - return ret; - } else - return it->second; + auto cont = children_.find(name); + return cont == children_.end() ? new ContainerType(name, this) : static_cast(cont->second); } -Type* Type::getOrCreateEventType(std::string name) +EventType* Type::getOrCreateEventType(std::string name) { - auto it = children_.find(name); - if (it == children_.end()) { - Type* ret = new Type(name, name, "", TYPE_EVENT, this); - XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), getCname(), getId()); - ret->logDefineEventType(); - return ret; - } else { - return it->second; - } + auto cont = children_.find(name); + return cont == children_.end() ? new EventType(name, this) : static_cast(cont->second); } -Type* Type::getOrCreateVariableType(std::string name, std::string color) +StateType* Type::getOrCreateStateType(std::string name) { - auto it = children_.find(name); - if (it == children_.end()) { - Type* ret = new Type(name, name, color.empty() ? "1 1 1" : color, TYPE_VARIABLE, this); - - XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), getCname(), getId()); - ret->logVariableTypeDefinition(); - - return ret; - } else - return it->second; + auto cont = children_.find(name); + return cont == children_.end() ? new StateType(name, this) : static_cast(cont->second); } -Type* Type::getOrCreateLinkType(std::string name, Type* source, Type* dest) +VariableType* Type::getOrCreateVariableType(std::string name, std::string color) { - std::string alias = name + "-" + source->id_ + "-" + dest->id_; - auto it = children_.find(alias); - if (it == children_.end()) { - Type* ret = new Type(name, alias, "", TYPE_LINK, this); - XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->getCname(), ret->getId(), getCname(), getId(), - source->getCname(), source->getId(), dest->getCname(), dest->getId()); - ret->logLinkTypeDefinition(source, dest); - return ret; - } else - return it->second; + auto cont = children_.find(name); + return cont == children_.end() ? new VariableType(name, color.empty() ? "1 1 1" : color, this) + : static_cast(cont->second); } -Type* Type::getOrCreateStateType(std::string name) +LinkType* Type::getOrCreateLinkType(std::string name, Type* source, Type* dest) { - auto it = children_.find(name); + std::string alias = name + "-" + std::to_string(source->id_) + "-" + std::to_string(dest->id_); + auto it = children_.find(alias); if (it == children_.end()) { - Type* ret = new Type(name, name, "", TYPE_STATE, this); - XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), getCname(), getId()); - ret->logStateTypeDefinition(); + LinkType* ret = new LinkType(name, alias, this); + XBT_DEBUG("LinkType %s(%lld), child of %s(%lld) %s(%lld)->%s(%lld)", ret->getCname(), ret->getId(), getCname(), + getId(), source->getCname(), source->getId(), dest->getCname(), dest->getId()); + ret->logDefinition(source, dest); return ret; } else - return it->second; + return static_cast(it->second); } } } diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index 4eb5eee1ab..60bffc650e 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -30,6 +30,11 @@ namespace simgrid { namespace instr { class Value; +class ContainerType; +class EventType; +class LinkType; +class StateType; +class VariableType; enum e_event_type { PAJE_DefineContainerType, @@ -52,49 +57,74 @@ enum e_event_type { PAJE_NewEvent }; -//-------------------------------------------------- -enum e_entity_types { TYPE_VARIABLE, TYPE_LINK, TYPE_CONTAINER, TYPE_STATE, TYPE_EVENT }; - class Type { - std::string id_; + long long int id_; std::string name_; std::string color_; - e_entity_types kind_; + +protected: Type* father_; public: std::map children_; - std::map values_; // valid for all types except variable and container - Type(std::string name, std::string alias, std::string color, e_entity_types kind, Type* father); + Type(std::string name, std::string alias, std::string color, Type* father); ~Type(); std::string getName() { return name_; } const char* getCname() { return name_.c_str(); } - const char* getId() { return id_.c_str(); } - e_entity_types getKind() { return kind_; } + long long int getId() { return id_; } bool isColored() { return not color_.empty(); } Type* byName(std::string name); - Type* getOrCreateContainerType(std::string name); - Type* getOrCreateEventType(std::string name); - Type* getOrCreateLinkType(std::string name, Type* source, Type* dest); - Type* getOrCreateStateType(std::string name); - Type* getOrCreateVariableType(std::string name, std::string color); + ContainerType* getOrCreateContainerType(std::string name); + EventType* getOrCreateEventType(std::string name); + LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest); + StateType* getOrCreateStateType(std::string name); + VariableType* getOrCreateVariableType(std::string name, std::string color); + + void logDefinition(e_event_type event_type); + void logDefinition(Type* source, Type* dest); + + static ContainerType* createRootType(); + static ContainerType* getRootType(); +}; +class ContainerType : public Type { +public: + ContainerType(std::string name, Type* father); +}; + +class VariableType : public Type { +public: + VariableType(std::string name, std::string color, Type* father); +}; + +class ValueType : public Type { +public: + std::map values_; + ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){}; + ValueType(std::string name, Type* father) : Type(name, name, "", father){}; + ~ValueType(); void addEntityValue(std::string name, std::string color); void addEntityValue(std::string name); Value* getEntityValue(std::string name); +}; - void logContainerTypeDefinition(); - void logVariableTypeDefinition(); - void logStateTypeDefinition(); - void logLinkTypeDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest); - void logDefineEventType(); +class LinkType : public ValueType { +public: + LinkType(std::string name, std::string alias, Type* father); +}; + +class EventType : public ValueType { +public: + EventType(std::string name, Type* father); +}; - static Type* createRootType(); - static Type* getRootType(); +class StateType : public ValueType { +public: + StateType(std::string name, Type* father); }; class Value { diff --git a/src/msg/instr_msg_process.cpp b/src/msg/instr_msg_process.cpp index 2d0d43dc79..bdda78afa2 100644 --- a/src/msg/instr_msg_process.cpp +++ b/src/msg/instr_msg_process.cpp @@ -75,8 +75,9 @@ void TRACE_msg_process_suspend(msg_process_t process) { if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(process)); - simgrid::instr::Type* state = process_container->type_->byName("MSG_PROCESS_STATE"); - simgrid::instr::Value* val = state->getEntityValue("suspend"); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); + simgrid::instr::Value* val = state->getEntityValue("suspend"); new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); } } @@ -94,7 +95,8 @@ void TRACE_msg_process_sleep_in(msg_process_t process) { if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(process)); - simgrid::instr::Type* state = process_container->type_->byName("MSG_PROCESS_STATE"); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); simgrid::instr::Value* val = state->getEntityValue("sleep"); new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); } diff --git a/src/msg/instr_msg_task.cpp b/src/msg/instr_msg_task.cpp index 39f0254631..2b2b425a58 100644 --- a/src/msg/instr_msg_task.cpp +++ b/src/msg/instr_msg_task.cpp @@ -50,8 +50,9 @@ void TRACE_msg_task_execute_start(msg_task_t task) if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); - simgrid::instr::Type* state = process_container->type_->byName("MSG_PROCESS_STATE"); - simgrid::instr::Value* val = state->getEntityValue("task_execute"); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); + simgrid::instr::Value* val = state->getEntityValue("task_execute"); new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); } } @@ -84,7 +85,8 @@ void TRACE_msg_task_get_start() if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); - simgrid::instr::Type* state = process_container->type_->byName("MSG_PROCESS_STATE"); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); simgrid::instr::Value* val = state->getEntityValue("receive"); new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); } @@ -113,12 +115,14 @@ int TRACE_msg_task_put_start(msg_task_t task) if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); - simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE"); - simgrid::instr::Value* val = type->getEntityValue("send"); - new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); + simgrid::instr::Value* val = state->getEntityValue("send"); + new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); std::string key = std::string("p") + std::to_string(task->counter); - type = simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK"); + simgrid::instr::LinkType* type = + static_cast(simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK")); new simgrid::instr::StartLinkEvent(MSG_get_clock(), simgrid::instr::Container::getRootContainer(), type, process_container, "SR", key); } diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index a18f43c7d5..bbbfb1a5a4 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -186,7 +186,8 @@ void MSG_vm_start(msg_vm_t vm) vm->start(); if (TRACE_msg_vm_is_enabled()) { container_t vm_container = simgrid::instr::Container::byName(vm->getName()); - simgrid::instr::Type* state = vm_container->type_->byName("MSG_VM_STATE"); + simgrid::instr::StateType* state = + static_cast(vm_container->type_->byName("MSG_VM_STATE")); state->addEntityValue("start", "0 0 1"); // start is blue new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, state, state->getEntityValue("start")); } @@ -769,7 +770,8 @@ void MSG_vm_suspend(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t vm_container = simgrid::instr::Container::byName(vm->getName()); - simgrid::instr::Type* state = vm_container->type_->byName("MSG_VM_STATE"); + simgrid::instr::StateType* state = + static_cast(vm_container->type_->byName("MSG_VM_STATE")); state->addEntityValue("suspend", "1 0 0"); // suspend is red new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, state, state->getEntityValue("suspend")); } diff --git a/src/smpi/colls/smpi_automatic_selector.cpp b/src/smpi/colls/smpi_automatic_selector.cpp index 31ca8a976f..3447878f9d 100644 --- a/src/smpi/colls/smpi_automatic_selector.cpp +++ b/src/smpi/colls/smpi_automatic_selector.cpp @@ -16,7 +16,8 @@ #define TRACE_AUTO_COLL(cat) \ if (TRACE_is_enabled()) { \ - simgrid::instr::Type* type = simgrid::instr::Type::getRootType()->getOrCreateEventType(#cat); \ + simgrid::instr::EventType* type = \ + static_cast(simgrid::instr::Type::getRootType()->getOrCreateEventType(#cat)); \ \ char cont_name[25]; \ snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \ diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index 648be990e6..5985693348 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -198,10 +198,10 @@ void TRACE_smpi_collective_in(int rank, const char *operation, instr_extra_data } container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* type = container->type_->byName("MPI_STATE"); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); const char *color = instr_find_color (operation); - type->addEntityValue(operation, color); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, type->getEntityValue(operation), + state->addEntityValue(operation, color); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue(operation), static_cast(extra)); } @@ -223,9 +223,9 @@ void TRACE_smpi_computing_init(int rank) return; container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* type = container->type_->byName("MPI_STATE"); - type->addEntityValue("computing", instr_find_color("computing")); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, type->getEntityValue("computing")); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); + state->addEntityValue("computing", instr_find_color("computing")); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("computing")); } void TRACE_smpi_computing_in(int rank, instr_extra_data extra) @@ -237,9 +237,9 @@ void TRACE_smpi_computing_in(int rank, instr_extra_data extra) } container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* type = container->type_->byName("MPI_STATE"); - type->addEntityValue("computing"); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, type->getEntityValue("computing"), + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); + state->addEntityValue("computing"); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("computing"), static_cast(extra)); } @@ -260,7 +260,7 @@ void TRACE_smpi_sleeping_init(int rank) return; container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* state = container->type_->byName("MPI_STATE"); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue("sleeping", instr_find_color("sleeping")); new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("sleeping")); } @@ -274,7 +274,7 @@ void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra) } container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* state = container->type_->byName("MPI_STATE"); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue("sleeping"); new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("sleeping"), static_cast(extra)); @@ -299,7 +299,7 @@ void TRACE_smpi_testing_in(int rank, instr_extra_data extra) } container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* state = container->type_->byName("MPI_STATE"); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue("test"); new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("test"), static_cast(extra)); @@ -323,7 +323,7 @@ void TRACE_smpi_ptp_in(int rank, const char *operation, instr_extra_data extra) } container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* state = container->type_->byName("MPI_STATE"); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue(operation, instr_find_color(operation)); new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue(operation), static_cast(extra)); diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index 6d6e8199f3..32a7294a77 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -96,8 +96,9 @@ static void linkContainers(container_t src, container_t dst, std::setinsert(aux2); //declare type - std::string link_typename = father->type_->getName() + "-" + src->type_->getName() + src->type_->getId() + "-" + - dst->type_->getName() + dst->type_->getId(); + std::string link_typename = father->type_->getName() + "-" + src->type_->getName() + + std::to_string(src->type_->getId()) + "-" + dst->type_->getName() + + std::to_string(dst->type_->getId()); simgrid::instr::Type* link_type = father->type_->getOrCreateLinkType(link_typename, src->type_, dst->type_); //register EDGE types for triva configuration @@ -218,8 +219,8 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) container->type_->getOrCreateContainerType("MPI")->getOrCreateStateType("MPI_STATE"); if (TRACE_msg_process_is_enabled()) { - simgrid::instr::Type* msg_process = container->type_->getOrCreateContainerType("MSG_PROCESS"); - simgrid::instr::Type* state = msg_process->getOrCreateStateType("MSG_PROCESS_STATE"); + simgrid::instr::ContainerType* msg_process = container->type_->getOrCreateContainerType("MSG_PROCESS"); + simgrid::instr::StateType* state = msg_process->getOrCreateStateType("MSG_PROCESS_STATE"); state->addEntityValue("suspend", "1 0 1"); state->addEntityValue("sleep", "1 1 0"); state->addEntityValue("receive", "1 0 0"); @@ -230,8 +231,8 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) } if (TRACE_msg_vm_is_enabled()) { - simgrid::instr::Type* msg_vm = container->type_->getOrCreateContainerType("MSG_VM"); - simgrid::instr::Type* state = msg_vm->getOrCreateStateType("MSG_VM_STATE"); + simgrid::instr::ContainerType* msg_vm = container->type_->getOrCreateContainerType("MSG_VM"); + simgrid::instr::StateType* state = msg_vm->getOrCreateStateType("MSG_VM_STATE"); state->addEntityValue("suspend", "1 0 1"); state->addEntityValue("sleep", "1 1 0"); state->addEntityValue("receive", "1 0 0"); @@ -329,7 +330,7 @@ static void recursiveNewValueForUserStateType(std::string type_name, const char* simgrid::instr::Type* root) { if (root->getName() == type_name) - root->addEntityValue(val, color); + static_cast(root)->addEntityValue(val, color); for (auto elm : root->children_) recursiveNewValueForUserStateType(type_name, val, color, elm.second); -- 2.20.1