return type_id++;
}
-
namespace simgrid {
namespace instr {
double timestamp = SIMIX_get_clock();
std::stringstream stream;
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_CreateContainer, timestamp);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_CreateContainer, timestamp);
if (instr_fmt_type == instr_fmt_paje) {
stream << std::fixed << std::setprecision(TRACE_precision());
std::stringstream stream;
double timestamp = SIMIX_get_clock();
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_DestroyContainer, timestamp);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_DestroyContainer, timestamp);
if (instr_fmt_type == instr_fmt_paje) {
stream << std::fixed << std::setprecision(TRACE_precision());
--- /dev/null
+/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. */
+
+/* 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. */
+
+#ifndef INSTR_PAJE_CONTAINERS_HPP
+#define INSTR_PAJE_CONTAINERS_HPP
+
+#include "src/instr/instr_private.hpp"
+
+namespace simgrid {
+namespace instr {
+class Type;
+
+class Container {
+ long long int id_;
+ std::string name_; /* Unique name of this container */
+public:
+ Container(std::string name, std::string type_name, Container* father);
+ virtual ~Container();
+
+ Type* type_; /* Type of this container */
+ Container* father_;
+ std::map<std::string, Container*> children_;
+ sg_netpoint_t netpoint_ = nullptr;
+
+ static Container* byNameOrNull(std::string name);
+ static Container* byName(std::string name);
+ std::string getName() { return name_; }
+ const char* getCname() { return name_.c_str(); }
+ long long int getId() { return id_; }
+ void removeFromParent();
+ void logCreation();
+ void logDestruction();
+
+ static Container* getRootContainer();
+};
+
+class NetZoneContainer : public Container {
+public:
+ NetZoneContainer(std::string name, unsigned int level, NetZoneContainer* father);
+};
+
+class RouterContainer : public Container {
+public:
+ RouterContainer(std::string name, Container* father);
+};
+
+class HostContainer : public Container {
+public:
+ HostContainer(simgrid::s4u::Host& host, NetZoneContainer* father);
+};
+}
+}
+#endif
static void TRACE_header_PajeDefineContainerType(bool basic)
{
- fprintf(tracing_file, "%%EventDef PajeDefineContainerType %d\n", simgrid::instr::PAJE_DefineContainerType);
+ fprintf(tracing_file, "%%EventDef PajeDefineContainerType %u\n", simgrid::instr::PAJE_DefineContainerType);
fprintf(tracing_file, "%% Alias string\n");
if (basic){
fprintf(tracing_file, "%% ContainerType string\n");
static void TRACE_header_PajeDefineVariableType(bool basic)
{
- fprintf(tracing_file, "%%EventDef PajeDefineVariableType %d\n", simgrid::instr::PAJE_DefineVariableType);
+ fprintf(tracing_file, "%%EventDef PajeDefineVariableType %u\n", simgrid::instr::PAJE_DefineVariableType);
fprintf(tracing_file, "%% Alias string\n");
if (basic){
fprintf(tracing_file, "%% ContainerType string\n");
static void TRACE_header_PajeDefineStateType(bool basic)
{
- fprintf(tracing_file, "%%EventDef PajeDefineStateType %d\n", simgrid::instr::PAJE_DefineStateType);
+ fprintf(tracing_file, "%%EventDef PajeDefineStateType %u\n", simgrid::instr::PAJE_DefineStateType);
fprintf(tracing_file, "%% Alias string\n");
if (basic){
fprintf(tracing_file, "%% ContainerType string\n");
static void TRACE_header_PajeDefineEventType(bool basic)
{
- fprintf(tracing_file, "%%EventDef PajeDefineEventType %d\n", simgrid::instr::PAJE_DefineEventType);
+ fprintf(tracing_file, "%%EventDef PajeDefineEventType %u\n", simgrid::instr::PAJE_DefineEventType);
fprintf(tracing_file, "%% Alias string\n");
if (basic){
fprintf(tracing_file, "%% ContainerType string\n");
static void TRACE_header_PajeDefineLinkType(bool basic)
{
- fprintf(tracing_file, "%%EventDef PajeDefineLinkType %d\n", simgrid::instr::PAJE_DefineLinkType);
+ fprintf(tracing_file, "%%EventDef PajeDefineLinkType %u\n", simgrid::instr::PAJE_DefineLinkType);
fprintf(tracing_file, "%% Alias string\n");
if (basic){
fprintf(tracing_file, "%% ContainerType string\n");
static void TRACE_header_PajeDefineEntityValue(bool basic)
{
- fprintf(tracing_file, "%%EventDef PajeDefineEntityValue %d\n", simgrid::instr::PAJE_DefineEntityValue);
+ fprintf(tracing_file, "%%EventDef PajeDefineEntityValue %u\n", simgrid::instr::PAJE_DefineEntityValue);
fprintf(tracing_file, "%% Alias string\n");
if (basic){
fprintf(tracing_file, "%% EntityType string\n");
static void TRACE_header_PajeCreateContainer()
{
- fprintf(tracing_file, "%%EventDef PajeCreateContainer %d\n", simgrid::instr::PAJE_CreateContainer);
+ fprintf(tracing_file, "%%EventDef PajeCreateContainer %u\n", simgrid::instr::PAJE_CreateContainer);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Alias string\n");
fprintf(tracing_file, "%% Type string\n");
static void TRACE_header_PajeDestroyContainer()
{
- fprintf(tracing_file, "%%EventDef PajeDestroyContainer %d\n", simgrid::instr::PAJE_DestroyContainer);
+ fprintf(tracing_file, "%%EventDef PajeDestroyContainer %u\n", simgrid::instr::PAJE_DestroyContainer);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Name string\n");
static void TRACE_header_PajeSetVariable()
{
- fprintf(tracing_file, "%%EventDef PajeSetVariable %d\n", simgrid::instr::PAJE_SetVariable);
+ fprintf(tracing_file, "%%EventDef PajeSetVariable %u\n", simgrid::instr::PAJE_SetVariable);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
static void TRACE_header_PajeAddVariable()
{
- fprintf(tracing_file, "%%EventDef PajeAddVariable %d\n", simgrid::instr::PAJE_AddVariable);
+ fprintf(tracing_file, "%%EventDef PajeAddVariable %u\n", simgrid::instr::PAJE_AddVariable);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
static void TRACE_header_PajeSubVariable()
{
- fprintf(tracing_file, "%%EventDef PajeSubVariable %d\n", simgrid::instr::PAJE_SubVariable);
+ fprintf(tracing_file, "%%EventDef PajeSubVariable %u\n", simgrid::instr::PAJE_SubVariable);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
static void TRACE_header_PajeSetState()
{
- fprintf(tracing_file, "%%EventDef PajeSetState %d\n", simgrid::instr::PAJE_SetState);
+ fprintf(tracing_file, "%%EventDef PajeSetState %u\n", simgrid::instr::PAJE_SetState);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
static void TRACE_header_PajePushState(int size)
{
- fprintf(tracing_file, "%%EventDef PajePushState %d\n", simgrid::instr::PAJE_PushState);
+ fprintf(tracing_file, "%%EventDef PajePushState %u\n", simgrid::instr::PAJE_PushState);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
static void TRACE_header_PajePopState()
{
- fprintf(tracing_file, "%%EventDef PajePopState %d\n", simgrid::instr::PAJE_PopState);
+ fprintf(tracing_file, "%%EventDef PajePopState %u\n", simgrid::instr::PAJE_PopState);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
if (basic)
return;
- fprintf(tracing_file, "%%EventDef PajeResetState %d\n", simgrid::instr::PAJE_ResetState);
+ fprintf(tracing_file, "%%EventDef PajeResetState %u\n", simgrid::instr::PAJE_ResetState);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
static void TRACE_header_PajeStartLink(bool basic, int size)
{
- fprintf(tracing_file, "%%EventDef PajeStartLink %d\n", simgrid::instr::PAJE_StartLink);
+ fprintf(tracing_file, "%%EventDef PajeStartLink %u\n", simgrid::instr::PAJE_StartLink);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
static void TRACE_header_PajeEndLink(bool basic)
{
- fprintf(tracing_file, "%%EventDef PajeEndLink %d\n", simgrid::instr::PAJE_EndLink);
+ fprintf(tracing_file, "%%EventDef PajeEndLink %u\n", simgrid::instr::PAJE_EndLink);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
static void TRACE_header_PajeNewEvent()
{
- fprintf(tracing_file, "%%EventDef PajeNewEvent %d\n", simgrid::instr::PAJE_NewEvent);
+ fprintf(tracing_file, "%%EventDef PajeNewEvent %u\n", simgrid::instr::PAJE_NewEvent);
fprintf(tracing_file, "%% Time date\n");
fprintf(tracing_file, "%% Type string\n");
fprintf(tracing_file, "%% Container string\n");
}
buffer_debug(&buffer);
- XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)", __FUNCTION__, static_cast<int>(eventType_),
- timestamp_, buffer.size());
+ XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __FUNCTION__, eventType_, timestamp_,
+ buffer.size());
std::vector<simgrid::instr::PajeEvent*>::reverse_iterator i;
for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
simgrid::instr::PajeEvent* e1 = *i;
- XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1, static_cast<int>(e1->eventType_), e1->timestamp_);
+ XBT_DEBUG("compare to %p is of type %u; timestamp:%f", e1, e1->eventType_, e1->timestamp_);
if (e1->timestamp_ <= timestamp_)
break;
}
simgrid::instr::PajeEvent::~PajeEvent()
{
- XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__, this, (int)eventType_, timestamp_);
+ XBT_DEBUG("%s not implemented for %p: event_type=%u, timestamp=%f", __FUNCTION__, this, eventType_, timestamp_);
}
void TRACE_paje_start() {
XBT_DEBUG("Filename %s is closed", filename);
}
-void simgrid::instr::Value::print()
-{
- XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue);
- //print it
- if (instr_fmt_type == instr_fmt_paje) {
- stream << std::fixed << std::setprecision(TRACE_precision());
- stream << simgrid::instr::PAJE_DefineEntityValue;
- 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;
- }
-}
-
simgrid::instr::SetVariableEvent::SetVariableEvent(double timestamp, container_t container, Type* type, double value)
: simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetVariable), value(value)
{
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_);
insertIntoBuffer();
}
void simgrid::instr::SetVariableEvent::print()
{
if (instr_fmt_type == instr_fmt_paje) {
- XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
- stream << std::fixed << std::setprecision(TRACE_precision());
- stream << (int)this->eventType_;
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_);
+ stream << std::fixed << std::setprecision(TRACE_precision()) << this->eventType_;
print_timestamp(this);
stream << " " << type->getId() << " " << container->getId() << " " << value;
print_row();
double value)
: simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_AddVariable), value(value)
{
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_);
insertIntoBuffer();
}
void simgrid::instr::AddVariableEvent::print()
{
if (instr_fmt_type == instr_fmt_paje) {
- XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_);
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
simgrid::instr::SubVariableEvent::SubVariableEvent(double timestamp, container_t container, Type* type, double value)
: simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SubVariable), value(value)
{
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_);
insertIntoBuffer();
}
void simgrid::instr::SubVariableEvent::print()
{
if (instr_fmt_type == instr_fmt_paje) {
- XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_);
stream << std::fixed << std::setprecision(TRACE_precision());
- stream << (int)this->eventType_;
+ stream << this->eventType_;
print_timestamp(this);
stream << " " << type->getId() << " " << container->getId() << " " << value;
print_row();
}
}
-simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, Value* value)
+simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, EntityValue* value)
: simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetState), value(value)
{
#if HAVE_SMPI
}
#endif
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_);
insertIntoBuffer();
}
void simgrid::instr::SetStateEvent::print()
{
if (instr_fmt_type == instr_fmt_paje) {
- XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_);
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
}
}
-simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* value,
+simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, EntityValue* value,
void* extra)
: simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PushState), value(value), extra_(extra)
{
}
#endif
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_);
insertIntoBuffer();
}
-simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val)
+simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, EntityValue* val)
: PushStateEvent(timestamp, container, type, val, nullptr)
{}
simgrid::instr::PopStateEvent::PopStateEvent(double timestamp, container_t container, Type* type)
: simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PopState)
{
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_);
insertIntoBuffer();
}
void simgrid::instr::PopStateEvent::print()
{
if (instr_fmt_type == instr_fmt_paje) {
- XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_);
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
simgrid::instr::ResetStateEvent::ResetStateEvent(double timestamp, container_t container, Type* type)
: simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_ResetState)
{
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_);
insertIntoBuffer();
delete[] this;
}
}
}
-simgrid::instr::NewEvent::NewEvent(double timestamp, container_t container, Type* type, Value* val)
+simgrid::instr::NewEvent::NewEvent(double timestamp, container_t container, Type* type, EntityValue* val)
: simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent)
{
this->val = val;
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.);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, event_type, TRACE_precision(), 0.);
stream << std::fixed << std::setprecision(TRACE_precision()) << event_type << " " << getId();
stream << " " << father_->getId() << " " << getName();
if (isColored())
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.);
+ XBT_DEBUG("%s: event_type=%u, 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());
auto it = values_.find(name);
if (it == values_.end()) {
- Value* new_val = new Value(name, color, this);
+ EntityValue* new_val = new EntityValue(name, color, this);
values_.insert({name, new_val});
XBT_DEBUG("new value %s, child of %s", name.c_str(), getCname());
new_val->print();
}
}
-Value* ValueType::getEntityValue(std::string name)
+EntityValue* ValueType::getEntityValue(std::string name)
{
auto ret = values_.find(name);
if (ret == values_.end()) {
VariableType* Type::getOrCreateVariableType(std::string name, std::string color)
{
auto cont = children_.find(name);
- return cont == children_.end() ? new VariableType(name, color.empty() ? "1 1 1" : color, this)
- : static_cast<VariableType*>(cont->second);
+ std::string mycolor = color.empty() ? "1 1 1" : color;
+ return cont == children_.end() ? new VariableType(name, mycolor, this) : static_cast<VariableType*>(cont->second);
}
LinkType* Type::getOrCreateLinkType(std::string name, Type* source, Type* dest)
--- /dev/null
+/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. */
+
+/* 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. */
+
+#ifndef INSTR_PAJE_TYPES_HPP
+#define INSTR_PAJE_TYPES_HPP
+
+#include "src/instr/instr_private.hpp"
+namespace simgrid {
+namespace instr {
+enum e_event_type : unsigned int;
+class EntityValue;
+class ContainerType;
+class EventType;
+class LinkType;
+class StateType;
+class VariableType;
+
+class Type {
+ long long int id_;
+ std::string name_;
+ std::string color_;
+ Type* father_;
+
+public:
+ std::map<std::string, Type*> children_;
+
+ Type(std::string name, std::string alias, std::string color, Type* father);
+ virtual ~Type();
+
+ std::string getName() { return name_; }
+ const char* getCname() { return name_.c_str(); }
+ long long int getId() { return id_; }
+ bool isColored() { return not color_.empty(); }
+
+ Type* byName(std::string name);
+
+ 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<std::string, EntityValue*> values_;
+ ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
+ ValueType(std::string name, Type* father) : Type(name, name, "", father){};
+ virtual ~ValueType();
+ void addEntityValue(std::string name, std::string color);
+ void addEntityValue(std::string name);
+ EntityValue* getEntityValue(std::string name);
+};
+
+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);
+};
+
+class StateType : public ValueType {
+public:
+ StateType(std::string name, Type* father);
+};
+}
+}
+#endif
/* 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 <xbt/ex.hpp>
#include "src/instr/instr_private.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)");
+extern FILE* tracing_file;
namespace simgrid {
namespace instr {
-Value::Value(std::string name, std::string color, Type* father) : name_(name), color_(color), father_(father)
-{
- this->id_ = std::to_string(instr_new_paje_id());
-};
+EntityValue::EntityValue(std::string name, std::string color, Type* father)
+ : id_(instr_new_paje_id()), name_(name), color_(color), father_(father){};
-Value::~Value()
+void EntityValue::print()
{
- XBT_DEBUG("free value %s, child of %s", getCname(), father_->getCname());
+ if (instr_fmt_type != instr_fmt_paje)
+ return;
+ std::stringstream stream;
+ XBT_DEBUG("%s: event_type=%u", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << simgrid::instr::PAJE_DefineEntityValue;
+ stream << " " << id_ << " " << father_->getId() << " " << name_;
+ if (not color_.empty())
+ stream << " \"" << color_ << "\"";
+ XBT_DEBUG("Dump %s", stream.str().c_str());
+ stream << std::endl;
+ fprintf(tracing_file, "%s", stream.str().c_str());
}
}
#include "instr/instr_interface.h"
#include "simgrid/instr.h"
#include "simgrid_config.h"
+#include "src/instr/instr_paje_containers.hpp"
+#include "src/instr/instr_paje_types.hpp"
#include "src/internal_config.h"
#include "xbt/graph.h"
#include <iomanip> /** std::setprecision **/
namespace simgrid {
namespace instr {
-class Value;
+class Container;
+class Type;
+class EntityValue;
class ContainerType;
class EventType;
class LinkType;
class StateType;
class VariableType;
-enum e_event_type {
+enum e_event_type : unsigned int {
PAJE_DefineContainerType,
PAJE_DefineVariableType,
PAJE_DefineStateType,
PAJE_NewEvent
};
-class Type {
+class EntityValue {
long long int id_;
std::string name_;
std::string color_;
-
-protected:
Type* father_;
public:
- std::map<std::string, Type*> children_;
-
- Type(std::string name, std::string alias, std::string color, Type* father);
- virtual ~Type();
-
- std::string getName() { return name_; }
+ explicit EntityValue(std::string name, std::string color, Type* father);
+ ~EntityValue() = default;
const char* getCname() { return name_.c_str(); }
long long int getId() { return id_; }
- bool isColored() { return not color_.empty(); }
-
- Type* byName(std::string name);
-
- 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<std::string, Value*> values_;
- ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
- ValueType(std::string name, Type* father) : Type(name, name, "", father){};
- virtual ~ValueType();
- void addEntityValue(std::string name, std::string color);
- void addEntityValue(std::string name);
- Value* getEntityValue(std::string name);
-};
-
-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);
-};
-
-class StateType : public ValueType {
-public:
- StateType(std::string name, Type* father);
-};
-
-class Value {
- std::string name_;
- std::string id_;
- std::string color_;
- Type* father_;
-
-public:
- explicit Value(std::string name, std::string color, Type* father);
- ~Value();
- const char* getCname() { return name_.c_str(); }
- const char* getId() { return id_.c_str(); }
- bool isColored() { return not color_.empty(); }
void print();
};
-class Container {
- long long int id_;
- std::string name_; /* Unique name of this container */
-public:
- Container(std::string name, std::string type_name, Container* father);
- virtual ~Container();
-
- Type* type_; /* Type of this container */
- Container* father_;
- std::map<std::string, Container*> children_;
- sg_netpoint_t netpoint_ = nullptr;
-
- static Container* byNameOrNull(std::string name);
- static Container* byName(std::string name);
- std::string getName() { return name_; }
- const char* getCname() { return name_.c_str(); }
- long long int getId() { return id_; }
- void removeFromParent();
- void logCreation();
- void logDestruction();
-
- static Container* getRootContainer();
-};
-
-class NetZoneContainer : public Container {
-public:
- NetZoneContainer(std::string name, unsigned int level, NetZoneContainer* father);
-};
-
-class RouterContainer : public Container {
-public:
- RouterContainer(std::string name, Container* father);
-};
-
-class HostContainer : public Container {
-public:
- HostContainer(simgrid::s4u::Host& host, NetZoneContainer* father);
-};
-
class PajeEvent {
protected:
Container* container;
void insertIntoBuffer();
};
-//--------------------------------------------------
class SetVariableEvent : public PajeEvent {
double value;
AddVariableEvent(double timestamp, Container* container, Type* type, double value);
void print() override;
};
-//--------------------------------------------------
class SubVariableEvent : public PajeEvent {
double value;
SubVariableEvent(double timestamp, Container* container, Type* type, double value);
void print() override;
};
-//--------------------------------------------------
class SetStateEvent : public PajeEvent {
- Value* value;
+ EntityValue* value;
const char* filename;
int linenumber;
public:
- SetStateEvent(double timestamp, Container* container, Type* type, Value* val);
+ SetStateEvent(double timestamp, Container* container, Type* type, EntityValue* val);
void print() override;
};
class PushStateEvent : public PajeEvent {
- Value* value;
+ EntityValue* value;
const char* filename;
int linenumber;
void* extra_;
public:
- PushStateEvent(double timestamp, Container* container, Type* type, Value* val);
- PushStateEvent(double timestamp, Container* container, Type* type, Value* val, void* extra);
+ PushStateEvent(double timestamp, Container* container, Type* type, EntityValue* val);
+ PushStateEvent(double timestamp, Container* container, Type* type, EntityValue* val, void* extra);
void print() override;
};
};
class NewEvent : public PajeEvent {
- Value* val;
+ EntityValue* val;
public:
- NewEvent(double timestamp, Container* container, Type* type, Value* val);
+ NewEvent(double timestamp, Container* container, Type* type, EntityValue* val);
void print() override;
};
}
container_t process_container = simgrid::instr::Container::byName(instr_process_id(process));
simgrid::instr::StateType* state =
static_cast<simgrid::instr::StateType*>(process_container->type_->byName("MSG_PROCESS_STATE"));
- simgrid::instr::Value* val = state->getEntityValue("suspend");
+ simgrid::instr::EntityValue* val = state->getEntityValue("suspend");
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val);
}
}
container_t process_container = simgrid::instr::Container::byName(instr_process_id(process));
simgrid::instr::StateType* state =
static_cast<simgrid::instr::StateType*>(process_container->type_->byName("MSG_PROCESS_STATE"));
- simgrid::instr::Value* val = state->getEntityValue("sleep");
+ simgrid::instr::EntityValue* val = state->getEntityValue("sleep");
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()));
simgrid::instr::StateType* state =
static_cast<simgrid::instr::StateType*>(process_container->type_->byName("MSG_PROCESS_STATE"));
- simgrid::instr::Value* val = state->getEntityValue("task_execute");
+ simgrid::instr::EntityValue* val = state->getEntityValue("task_execute");
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()));
simgrid::instr::StateType* state =
static_cast<simgrid::instr::StateType*>(process_container->type_->byName("MSG_PROCESS_STATE"));
- simgrid::instr::Value* val = state->getEntityValue("receive");
+ simgrid::instr::EntityValue* 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()));
simgrid::instr::StateType* state =
static_cast<simgrid::instr::StateType*>(process_container->type_->byName("MSG_PROCESS_STATE"));
- simgrid::instr::Value* val = state->getEntityValue("send");
+ simgrid::instr::EntityValue* 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);
static void recursiveNewUserStateType(std::string father_type, std::string new_typename, simgrid::instr::Type* root)
{
- if (root->getName() == father_type) {
+ if (root->getName() == father_type)
root->getOrCreateStateType(new_typename);
- }
+
for (auto elm : root->children_)
recursiveNewUserStateType(father_type, new_typename, elm.second);
}
set(TRACING_SRC
src/instr/instr_config.cpp
src/instr/instr_interface.cpp
+ src/instr/instr_paje_containers.hpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_header.cpp
src/instr/instr_paje_trace.cpp
+ src/instr/instr_paje_types.hpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_values.cpp
src/instr/instr_private.hpp