static bool trace_configured = false;
static bool trace_active = false;
-static simgrid::instr::Type* rootType = nullptr; /* the root type */
-
instr_fmt_type_t instr_fmt_type = instr_fmt_paje;
static void TRACE_getopts()
TRACE_last_timestamp_to_dump = surf_get_clock();
TRACE_paje_dump_buffer(true);
+ container_t root = simgrid::instr::Container::getRootContainer();
/* destroy all data structures of tracing (and free) */
- delete simgrid::instr::Container::getRootContainer();
- delete simgrid::instr::Type::getRootType();
- rootType = nullptr;
+ delete root;
+ delete root->type_;
/* close the trace files */
const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT);
}
XBT_DEBUG("MARK,declare %s", mark_type);
- simgrid::instr::Type::getRootType()->getOrCreateEventType(mark_type);
+ simgrid::instr::Container::getRootContainer()->type_->getOrCreateEventType(mark_type);
declared_marks.insert(mark_type);
}
THROWF (tracing_error, 1, "mark_value is nullptr");
simgrid::instr::EventType* type =
- static_cast<simgrid::instr::EventType*>(simgrid::instr::Type::getRootType()->byName(mark_type));
+ static_cast<simgrid::instr::EventType*>(simgrid::instr::Container::getRootContainer()->type_->byName(mark_type));
if (not type) {
THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
} else {
//check if mark_type is already declared
simgrid::instr::EventType* type =
- static_cast<simgrid::instr::EventType*>(simgrid::instr::Type::getRootType()->byName(mark_type));
+ static_cast<simgrid::instr::EventType*>(simgrid::instr::Container::getRootContainer()->type_->byName(mark_type));
if (not type) {
THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
} else {
}
}else{
if (created != filter->end()) { // declared, let's work
- char valuestr[100];
- snprintf(valuestr, 100, "%g", value);
- container_t container = simgrid::instr::Container::byName(resource);
- simgrid::instr::VariableType* variable =
- static_cast<simgrid::instr::VariableType*>(container->type_->byName(variable_name));
+ simgrid::instr::VariableType* variable = simgrid::instr::Container::byName(resource)->getVariable(variable_name);
switch (what){
case INSTR_US_SET:
- variable->setEvent(time, container, value);
+ variable->setEvent(time, value);
break;
case INSTR_US_ADD:
- variable->addEvent(time, container, value);
+ variable->addEvent(time, value);
break;
case INSTR_US_SUB:
- variable->subEvent(time, container, value);
+ variable->subEvent(time, value);
break;
default:
THROW_IMPOSSIBLE;
father_->children_.insert({getName(), this});
logCreation();
} else {
- type_ = Type::createRootType();
+ type_ = new ContainerType("0");
rootContainer = this;
}
}
ret->setCallingContainer(this);
return ret;
}
+
+LinkType* Container::getLink(std::string name)
+{
+ return dynamic_cast<LinkType*>(type_->byName(name));
+}
+
+VariableType* Container::getVariable(std::string name)
+{
+ VariableType* ret = dynamic_cast<VariableType*>(type_->byName(name));
+ ret->setCallingContainer(this);
+ return ret;
+}
}
}
namespace simgrid {
namespace instr {
class Type;
+class LinkType;
class StateType;
+class VariableType;
class Container {
long long int id_;
void logDestruction();
StateType* getState(std::string name);
+ LinkType* getLink(std::string name);
+ VariableType* getVariable(std::string name);
+
static Container* getRootContainer();
};
XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_types, instr, "Paje tracing event system (types)");
-static simgrid::instr::ContainerType* rootType = nullptr; /* the root type */
extern FILE* tracing_file;
namespace simgrid {
events_.clear();
}
-void VariableType::setEvent(double timestamp, Container* container, double value)
+void VariableType::setEvent(double timestamp, double value)
{
- events_.push_back(new VariableEvent(timestamp, container, this, PAJE_SetVariable, value));
+ events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_SetVariable, value));
}
-void VariableType::addEvent(double timestamp, Container* container, double value)
+void VariableType::addEvent(double timestamp, double value)
{
- events_.push_back(new VariableEvent(timestamp, container, this, PAJE_AddVariable, value));
+ events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_AddVariable, value));
}
-void VariableType::subEvent(double timestamp, Container* container, double value)
+void VariableType::subEvent(double timestamp, double value)
{
- events_.push_back(new VariableEvent(timestamp, container, this, PAJE_SubVariable, value));
+ events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_SubVariable, value));
}
LinkType::LinkType(std::string name, std::string alias, Type* father) : ValueType(name, alias, father)
return ret->second;
}
-ContainerType* Type::createRootType()
-{
- rootType = new ContainerType("0");
- return rootType;
-}
-
-ContainerType* Type::getRootType()
-{
- return rootType;
-}
-
ContainerType* Type::getOrCreateContainerType(std::string name)
{
auto cont = children_.find(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);
- StateType* getState(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 {
class VariableType : public Type {
std::vector<VariableEvent*> events_;
+ Container* issuer_ = nullptr;
public:
VariableType(std::string name, std::string color, Type* father);
~VariableType();
- void setEvent(double timestamp, Container* container, double value);
- void addEvent(double timestamp, Container* container, double value);
- void subEvent(double timestamp, Container* container, double value);
+ void setCallingContainer(Container* container) { issuer_ = container; }
+ void setEvent(double timestamp, double value);
+ void addEvent(double timestamp, double value);
+ void subEvent(double timestamp, double value);
};
class ValueType : public Type {
// 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()) {
- variable->setEvent(now, resource, 0);
+ variable->setEvent(now, 0);
platform_variables.insert(key);
}
- variable->addEvent(now, resource, value);
- variable->subEvent(now + delta, resource, value);
+ variable->addEvent(now, value);
+ variable->subEvent(now + delta, value);
}
/* TRACE_surf_link_set_utilization: entry point from SimGrid */
//trace uncategorized link utilization
if (TRACE_uncategorized()){
XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now + delta, resource, value);
- simgrid::instr::VariableType* variable =
- static_cast<simgrid::instr::VariableType*>(container->type_->byName("bandwidth_used"));
+ simgrid::instr::VariableType* variable = container->getVariable("bandwidth_used");
instr_event(now, delta, variable, container, value);
}
//variable of this category starts by 'b', because we have a link here
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::VariableType* variable =
- static_cast<simgrid::instr::VariableType*>(container->type_->byName(category_type));
+ simgrid::instr::VariableType* variable = container->getVariable(category_type);
instr_event(now, delta, variable, container, value);
}
}
//trace uncategorized host utilization
if (TRACE_uncategorized()){
XBT_DEBUG("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value);
- simgrid::instr::VariableType* variable =
- static_cast<simgrid::instr::VariableType*>(container->type_->byName("power_used"));
+ simgrid::instr::VariableType* variable = container->getVariable("power_used");
instr_event(now, delta, variable, container, value);
}
//variable of this category starts by 'p', because we have a host here
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::VariableType* variable =
- static_cast<simgrid::instr::VariableType*>(container->type_->byName(category_type));
+ simgrid::instr::VariableType* variable = container->getVariable(category_type);
instr_event(now, delta, variable, container, value);
}
}
std::string key = std::to_string(counter++);
//start link
- container_t msg = simgrid::instr::Container::byName(instr_pid(process));
- simgrid::instr::LinkType* link =
- static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_LINK"));
- link->startEvent(simgrid::instr::Container::getRootContainer(), msg, "M", key);
+ container_t msg = simgrid::instr::Container::byName(instr_pid(process));
+ container_t root = simgrid::instr::Container::getRootContainer();
+ simgrid::instr::LinkType* link = root->getLink("MSG_PROCESS_LINK");
+ link->startEvent(root, msg, "M", key);
//destroy existing container of this process
TRACE_msg_process_destroy (MSG_process_get_name (process), MSG_process_get_PID (process));
//end link
msg = simgrid::instr::Container::byName(instr_pid(process));
- link->endEvent(simgrid::instr::Container::getRootContainer(), msg, "M", key);
+ link->endEvent(root, msg, "M", key);
}
}
process_container->getState("MSG_PROCESS_STATE")->popEvent();
std::string key = std::string("p") + std::to_string(task->counter);
- simgrid::instr::LinkType* link =
- static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK"));
- link->endEvent(simgrid::instr::Container::getRootContainer(), process_container, "SR", key);
+ container_t root = simgrid::instr::Container::getRootContainer();
+ simgrid::instr::LinkType* link = root->getLink("MSG_PROCESS_TASK_LINK");
+ link->endEvent(root, process_container, "SR", key);
}
}
process_container->getState("MSG_PROCESS_STATE")->pushEvent("send");
std::string key = std::string("p") + std::to_string(task->counter);
- simgrid::instr::LinkType* link =
- static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK"));
- link->startEvent(simgrid::instr::Container::getRootContainer(), process_container, "SR", key);
+ container_t root = simgrid::instr::Container::getRootContainer();
+ simgrid::instr::LinkType* link = root->getLink("MSG_PROCESS_TASK_LINK");
+ link->startEvent(root, process_container, "SR", key);
}
return 1;
// start link
container_t msg = simgrid::instr::Container::byName(vm->getName());
- simgrid::instr::LinkType* link =
- static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MSG_VM_LINK"));
+ simgrid::instr::LinkType* link = simgrid::instr::Container::getRootContainer()->getLink("MSG_VM_LINK");
link->startEvent(simgrid::instr::Container::getRootContainer(), msg, "M", key);
// destroy existing container of this vm
#define TRACE_AUTO_COLL(cat) \
if (TRACE_is_enabled()) { \
simgrid::instr::EventType* type = \
- static_cast<simgrid::instr::EventType*>(simgrid::instr::Type::getRootType()->getOrCreateEventType(#cat)); \
+ simgrid::instr::Container::getRootContainer()->type_->getOrCreateEventType(#cat); \
\
char cont_name[25]; \
snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \
std::string key = TRACE_smpi_get_key(src, dst, tag, 1);
container_t container = simgrid::instr::Container::byName(smpi_container(rank));
- simgrid::instr::LinkType* link =
- static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MPI_LINK"));
+ simgrid::instr::LinkType* link = simgrid::instr::Container::getRootContainer()->getLink("MPI_LINK");
XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key.c_str());
link->startEvent(simgrid::instr::Container::getRootContainer(), container, "PTP", key, size);
}
std::string key = TRACE_smpi_get_key(src, dst, tag, 0);
container_t container = simgrid::instr::Container::byName(smpi_container(dst));
- simgrid::instr::LinkType* link =
- static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MPI_LINK"));
+ simgrid::instr::LinkType* link = simgrid::instr::Container::getRootContainer()->getLink("MPI_LINK");
XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key.c_str());
link->endEvent(simgrid::instr::Container::getRootContainer(), container, "PTP", key);
}
simgrid::instr::Type* mpi = root->type_->getOrCreateContainerType("MPI");
if (not TRACE_smpi_is_grouped())
mpi->getOrCreateStateType("MPI_STATE");
- simgrid::instr::Type::getRootType()->getOrCreateLinkType("MPI_LINK", mpi, mpi);
+ root->type_->getOrCreateLinkType("MPI_LINK", mpi, mpi);
}
if (TRACE_needs_platform()){
container_t container = new simgrid::instr::Container(link.getName(), "LINK", father);
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
- container->type_->getOrCreateVariableType("bandwidth", "")->setEvent(0, container, link.bandwidth());
- container->type_->getOrCreateVariableType("latency", "")->setEvent(0, container, link.latency());
+ simgrid::instr::VariableType* bandwidth = container->type_->getOrCreateVariableType("bandwidth", "");
+ bandwidth->setCallingContainer(container);
+ bandwidth->setEvent(0, link.bandwidth());
+ simgrid::instr::VariableType* latency = container->type_->getOrCreateVariableType("latency", "");
+ latency->setCallingContainer(container);
+ latency->setEvent(0, 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 container = new simgrid::instr::HostContainer(host, currentContainer.back());
+ container_t root = simgrid::instr::Container::getRootContainer();
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
- container->type_->getOrCreateVariableType("power", "")->setEvent(0, container, host.getSpeed());
+ simgrid::instr::VariableType* power = container->type_->getOrCreateVariableType("power", "");
+ power->setCallingContainer(container);
+ power->setEvent(0, host.getSpeed());
}
if (TRACE_uncategorized())
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);
+ root->type_->getOrCreateLinkType("MSG_PROCESS_LINK", msg_process, msg_process);
+ root->type_->getOrCreateLinkType("MSG_PROCESS_TASK_LINK", msg_process, msg_process);
}
if (TRACE_msg_vm_is_enabled()) {
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);
+ root->type_->getOrCreateLinkType("MSG_VM_LINK", msg_vm, msg_vm);
+ root->type_->getOrCreateLinkType("MSG_VM_PROCESS_LINK", msg_vm, msg_vm);
}
}
void instr_new_variable_type(std::string new_typename, std::string color)
{
- recursiveNewVariableType(new_typename, color, simgrid::instr::Type::getRootType());
+ recursiveNewVariableType(new_typename, color, simgrid::instr::Container::getRootContainer()->type_);
}
static void recursiveNewUserVariableType(std::string father_type, std::string new_typename, std::string color,
void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color)
{
- recursiveNewUserVariableType(father_type, new_typename, color, simgrid::instr::Type::getRootType());
+ recursiveNewUserVariableType(father_type, new_typename, color, simgrid::instr::Container::getRootContainer()->type_);
}
static void recursiveNewUserStateType(std::string father_type, std::string new_typename, simgrid::instr::Type* root)
void instr_new_user_state_type(std::string father_type, std::string new_typename)
{
- recursiveNewUserStateType(father_type, new_typename, simgrid::instr::Type::getRootType());
+ recursiveNewUserStateType(father_type, new_typename, simgrid::instr::Container::getRootContainer()->type_);
}
static void recursiveNewValueForUserStateType(std::string type_name, const char* val, std::string color,
void instr_new_value_for_user_state_type(std::string type_name, const char* value, std::string color)
{
- recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Type::getRootType());
+ recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Container::getRootContainer()->type_);
}
int instr_platform_traced ()
void TRACE_surf_host_set_speed(double date, const char *resource, double speed)
{
if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
- container_t container = simgrid::instr::Container::byName(resource);
- simgrid::instr::VariableType* variable =
- static_cast<simgrid::instr::VariableType*>(container->type_->byName("power"));
- variable->setEvent(date, container, speed);
+ simgrid::instr::Container::byName(resource)->getVariable("power")->setEvent(date, speed);
}
}
void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth)
{
if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
- container_t container = simgrid::instr::Container::byName(resource);
- simgrid::instr::VariableType* variable =
- static_cast<simgrid::instr::VariableType*>(container->type_->byName("bandwidth"));
- variable->setEvent(date, container, bandwidth);
+ simgrid::instr::Container::byName(resource)->getVariable("bandwidth")->setEvent(date, bandwidth);
}
}
void TRACE_surf_action(surf_action_t surf_action, const char *category)
{
- if (not TRACE_is_enabled())
- return;
- if (not TRACE_categorized())
- return;
- if (not category)
+ if (not TRACE_is_enabled() || not TRACE_categorized() || not category)
return;
surf_action->setCategory(category);