mark_color = "1.0 1.0 1.0" /*white*/;
XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color);
- simgrid::instr::Value::byNameOrCreate(mark_value, mark_color, type);
+ type->addEntityValue(mark_value, mark_color);
}
/** \ingroup TRACE_mark
}
XBT_DEBUG("MARK %s %s", mark_type, mark_value);
- new simgrid::instr::NewEvent(MSG_get_clock(), PJ_container_get_root(), type,
- simgrid::instr::Value::byName(mark_value, type));
+ new simgrid::instr::NewEvent(MSG_get_clock(), PJ_container_get_root(), type, type->getEntityValue(mark_value));
}
/** \ingroup TRACE_mark
*
* \see TRACE_host_state_declare, TRACE_host_push_state, TRACE_host_pop_state, TRACE_host_reset_state
*/
-void TRACE_host_set_state(const char* host, const char* state, const char* value_str)
+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* type = container->type_->byName(state);
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate(value_str, "", type);
- new simgrid::instr::SetStateEvent(MSG_get_clock(), container, type, val);
+ container_t container = simgrid::instr::Container::byName(host);
+ simgrid::instr::Type* state = container->type_->byName(state_name);
+ state->addEntityValue(value_name);
+ new simgrid::instr::SetStateEvent(MSG_get_clock(), container, state, state->getEntityValue(value_name));
}
/** \ingroup TRACE_user_variables
*
* \see TRACE_host_state_declare, TRACE_host_set_state, TRACE_host_pop_state, TRACE_host_reset_state
*/
-void TRACE_host_push_state(const char* host, const char* state, const char* value_str)
+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* type = container->type_->byName(state);
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate(value_str, "", type);
- new simgrid::instr::PushStateEvent(MSG_get_clock(), container, type, val);
+ simgrid::instr::Type* state = container->type_->byName(state_name);
+ state->addEntityValue(value_name);
+ new simgrid::instr::PushStateEvent(MSG_get_clock(), container, state, state->getEntityValue(value_name));
}
/** \ingroup TRACE_user_variables
return ret;
}
+void Type::addEntityValue(std::string name)
+{
+ addEntityValue(name, "");
+}
+
+void Type::addEntityValue(std::string name, std::string color)
+{
+ 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());
+ new_val->print();
+ }
+}
+
+Value* Type::getEntityValue(std::string name)
+{
+ auto ret = values_.find(name);
+ if (ret == values_.end()) {
+ THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name.c_str(), getCname());
+ }
+ return ret->second;
+}
+
Type* Type::createRootType()
{
simgrid::instr::Type* ret = new simgrid::instr::Type("0", "0", "", TYPE_CONTAINER, nullptr);
Value::Value(std::string name, std::string color, Type* father) : name_(name), color_(color), father_(father)
{
- if (name.empty() || father == nullptr) {
- THROWF(tracing_error, 0, "can't create a value with no name (or a nullptr father)");
- }
this->id_ = std::to_string(instr_new_paje_id());
-
- father->values_.insert({name, this});
- XBT_DEBUG("new value %s, child of %s", name_.c_str(), father_->getCname());
- print();
};
Value::~Value()
XBT_DEBUG("free value %s, child of %s", getCname(), father_->getCname());
}
-Value* Value::byNameOrCreate(std::string name, std::string color, Type* father)
-{
- Value* ret = nullptr;
- try {
- ret = Value::byName(name, father);
- } catch (xbt_ex& e) {
- ret = new Value(name, color, father);
- }
- return ret;
-}
-
-Value* Value::byName(std::string name, Type* father)
-{
- if (name.empty() || father == nullptr) {
- THROWF(tracing_error, 0, "can't get a value with no name (or a nullptr father)");
- }
-
- if (father->getKind() == TYPE_VARIABLE)
- THROWF(tracing_error, 0, "variables can't have different values (%s)", father->getCname());
- auto ret = father->values_.find(name);
- if (ret == father->values_.end()) {
- THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name.c_str(), father->getCname());
- }
- return ret->second;
-}
}
}
Type* getOrCreateStateType(std::string name);
Type* getOrCreateVariableType(std::string name, std::string color);
+ void addEntityValue(std::string name, std::string color);
+ void addEntityValue(std::string name);
+ Value* getEntityValue(std::string name);
+
void logContainerTypeDefinition();
void logVariableTypeDefinition();
void logStateTypeDefinition();
std::string color_;
Type* father_;
- explicit Value(std::string name, std::string color, Type* father);
-
public:
+ explicit Value(std::string name, std::string color, Type* father);
~Value();
- static Value* byNameOrCreate(std::string name, std::string color, Type* father);
- static Value* byName(std::string name, Type* father);
const char* getCname() { return name_.c_str(); }
const char* getId() { return id_.c_str(); }
bool isColored() { return not color_.empty(); }
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = simgrid::instr::Container::byName(instr_process_id(process, str, len));
- simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byName("suspend", type);
- new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
+ simgrid::instr::Type* state = 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);
}
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = simgrid::instr::Container::byName(instr_process_id(process, str, len));
- simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byName("sleep", type);
- new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
+ simgrid::instr::Type* state = 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);
}
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self(), str, len));
- simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byName("task_execute", type);
- new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
+ simgrid::instr::Type* state = 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);
}
}
char str[INSTR_DEFAULT_STR_SIZE];
container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self(), str, len));
- simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byName("receive", type);
- new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
+ simgrid::instr::Type* state = 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);
}
}
container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self(), str, len));
simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byName("send", type);
+ simgrid::instr::Value* val = type->getEntityValue("send");
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
char key[INSTR_DEFAULT_STR_SIZE];
{
vm->start();
if (TRACE_msg_vm_is_enabled()) {
- container_t vm_container = simgrid::instr::Container::byName(vm->getName());
- simgrid::instr::Type* type = vm_container->type_->byName("MSG_VM_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("start", "0 0 1", type); // start is blue
- new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, type, val);
+ container_t vm_container = simgrid::instr::Container::byName(vm->getName());
+ simgrid::instr::Type* state = 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"));
}
}
XBT_DEBUG("vm_suspend done");
if (TRACE_msg_vm_is_enabled()) {
- container_t vm_container = simgrid::instr::Container::byName(vm->getName());
- simgrid::instr::Type* type = vm_container->type_->byName("MSG_VM_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("suspend", "1 0 0", type); // suspend is red
- new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, type, val);
+ container_t vm_container = simgrid::instr::Container::byName(vm->getName());
+ simgrid::instr::Type* state = 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"));
}
}
\
char cont_name[25]; \
snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \
- simgrid::instr::Value* val = \
- simgrid::instr::Value::byNameOrCreate(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0", type); \
- new simgrid::instr::NewEvent(SIMIX_get_clock(), simgrid::instr::Container::byName(cont_name), type, val); \
+ type->addEntityValue(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0"); \
+ new simgrid::instr::NewEvent(SIMIX_get_clock(), simgrid::instr::Container::byName(cont_name), type, \
+ type->getEntityValue(Colls::mpi_coll_##cat##_description[i].name)); \
}
#define AUTOMATIC_COLL_BENCH(cat, ret, args, args2) \
container_t container = simgrid::instr::Container::byName(str);
simgrid::instr::Type* type = container->type_->byName("MPI_STATE");
const char *color = instr_find_color (operation);
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate(operation, color, type);
- new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
+ type->addEntityValue(operation, color);
+ new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, type->getEntityValue(operation),
+ static_cast<void*>(extra));
}
void TRACE_smpi_collective_out(int rank, const char *operation)
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = simgrid::instr::Container::byName(str);
simgrid::instr::Type* type = container->type_->byName("MPI_STATE");
- const char* color = instr_find_color("computing");
- new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type,
- simgrid::instr::Value::byNameOrCreate("computing", color, type));
+ type->addEntityValue("computing", instr_find_color("computing"));
+ new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, type->getEntityValue("computing"));
}
void TRACE_smpi_computing_in(int rank, instr_extra_data extra)
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = simgrid::instr::Container::byName(str);
simgrid::instr::Type* type = container->type_->byName("MPI_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("computing", "", type);
- new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
+ type->addEntityValue("computing");
+ new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, type->getEntityValue("computing"),
+ static_cast<void*>(extra));
}
void TRACE_smpi_computing_out(int rank)
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = simgrid::instr::Container::byName(str);
- simgrid::instr::Type* type = container->type_->byName("MPI_STATE");
- const char *color = instr_find_color ("sleeping");
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("sleeping", color, type);
- new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val);
+ simgrid::instr::Type* state = container->type_->byName("MPI_STATE");
+ state->addEntityValue("sleeping", instr_find_color("sleeping"));
+ new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("sleeping"));
}
void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra)
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = simgrid::instr::Container::byName(str);
- simgrid::instr::Type* type = container->type_->byName("MPI_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("sleeping", "", type);
- new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
+ simgrid::instr::Type* state = container->type_->byName("MPI_STATE");
+ state->addEntityValue("sleeping");
+ new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("sleeping"),
+ static_cast<void*>(extra));
}
void TRACE_smpi_sleeping_out(int rank)
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = simgrid::instr::Container::byName(str);
- simgrid::instr::Type* type = container->type_->byName("MPI_STATE");
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate("test", "", type);
- new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
+ simgrid::instr::Type* state = container->type_->byName("MPI_STATE");
+ state->addEntityValue("test");
+ new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("test"),
+ static_cast<void*>(extra));
}
void TRACE_smpi_testing_out(int rank)
char str[INSTR_DEFAULT_STR_SIZE];
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = simgrid::instr::Container::byName(str);
- simgrid::instr::Type* type = container->type_->byName("MPI_STATE");
- const char *color = instr_find_color (operation);
- simgrid::instr::Value* val = simgrid::instr::Value::byNameOrCreate(operation, color, type);
- new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast<void*>(extra));
+ simgrid::instr::Type* state = 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<void*>(extra));
}
void TRACE_smpi_ptp_out(int rank, int dst, const char *operation)
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::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);
+ state->addEntityValue("suspend", "1 0 1");
+ state->addEntityValue("sleep", "1 1 0");
+ state->addEntityValue("receive", "1 0 0");
+ state->addEntityValue("send", "0 0 1");
+ state->addEntityValue("task_execute", "0 1 1");
simgrid::instr::Type::getRootType()->getOrCreateLinkType("MSG_PROCESS_LINK", msg_process, msg_process);
simgrid::instr::Type::getRootType()->getOrCreateLinkType("MSG_PROCESS_TASK_LINK", msg_process, msg_process);
}
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::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);
+ state->addEntityValue("suspend", "1 0 1");
+ state->addEntityValue("sleep", "1 1 0");
+ state->addEntityValue("receive", "1 0 0");
+ state->addEntityValue("send", "0 0 1");
+ state->addEntityValue("task_execute", "0 1 1");
simgrid::instr::Type::getRootType()->getOrCreateLinkType("MSG_VM_LINK", msg_vm, msg_vm);
simgrid::instr::Type::getRootType()->getOrCreateLinkType("MSG_VM_PROCESS_LINK", msg_vm, msg_vm);
}
simgrid::instr::Type* root)
{
if (root->getName() == type_name)
- simgrid::instr::Value::byNameOrCreate(val, color, root);
+ root->addEntityValue(val, color);
for (auto elm : root->children_)
recursiveNewValueForUserStateType(type_name, val, color, elm.second);