1 /* Copyright (c) 2012-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/instr/instr_private.hpp"
7 #include "src/instr/instr_smpi.hpp"
8 #include "src/smpi/include/private.hpp"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_events, instr, "Paje tracing event system (events)");
13 namespace simgrid::instr {
15 PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType)
16 : container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
22 PajeEvent::~PajeEvent()
24 on_destruction(*this);
27 StateEvent::StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra)
28 : PajeEvent::PajeEvent(container, type, simgrid_get_clock(), event_type), value(value), extra_(extra)
31 if (smpi_cfg_trace_call_location()) {
32 const smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
33 filename = loc->filename;
34 linenumber = loc->linenumber;
39 void NewEvent::print()
41 stream_ << " " << value->get_id();
44 void LinkEvent::print()
46 stream_ << " " << value_ << " " << endpoint_->get_id() << " " << key_;
48 if (TRACE_display_sizes() && size_ != static_cast<size_t>(-1))
49 stream_ << " " << size_;
52 void StateEvent::print()
54 if (trace_format == TraceFormat::Paje) {
55 if (value != nullptr) // PajeEventType::PopState Event does not need to have a value
56 stream_ << " " << value->get_id();
58 if (TRACE_display_sizes())
59 stream_ << " " << ((extra_ != nullptr) ? extra_->display_size() : "");
62 if (smpi_cfg_trace_call_location())
63 stream_ << " \"" << filename << "\" " << linenumber;
65 } else if (trace_format == TraceFormat::Ti) {
66 if (extra_ == nullptr)
69 /* Unimplemented calls are: WAITANY, SENDRECV, SCAN, EXSCAN, SSEND, and ISSEND. */
70 std::string container_name(get_container()->get_name());
71 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
72 if (get_container()->get_name().find("rank-") == 0) {
73 /* Subtract -1 because this is the process id and we transform it to the rank id */
74 container_name=std::to_string(stoi(container_name.erase(0, 5)) - 1);
77 if (smpi_cfg_trace_call_location())
78 stream_ << container_name << " location " << filename << " " << linenumber << '\n';
80 stream_ << container_name << " " << extra_->print();
85 } // namespace simgrid::instr