1 /* Copyright (c) 2012-2022. 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"
9 #include "src/surf/surf_interface.hpp"
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_events, instr, "Paje tracing event system (events)");
17 PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType)
18 : container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
24 PajeEvent::~PajeEvent()
26 on_destruction(*this);
29 StateEvent::StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra)
30 : PajeEvent::PajeEvent(container, type, simgrid_get_clock(), event_type), value(value), extra_(extra)
33 if (smpi_cfg_trace_call_location()) {
34 const smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
35 filename = loc->filename;
36 linenumber = loc->linenumber;
41 void NewEvent::print()
43 stream_ << " " << value->get_id();
46 void LinkEvent::print()
48 stream_ << " " << value_ << " " << endpoint_->get_id() << " " << key_;
50 if (TRACE_display_sizes() && size_ != static_cast<size_t>(-1))
51 stream_ << " " << size_;
54 void StateEvent::print()
56 if (trace_format == TraceFormat::Paje) {
57 if (value != nullptr) // PajeEventType::PopState Event does not need to have a value
58 stream_ << " " << value->get_id();
60 if (TRACE_display_sizes())
61 stream_ << " " << ((extra_ != nullptr) ? extra_->display_size() : "");
64 if (smpi_cfg_trace_call_location())
65 stream_ << " \"" << filename << "\" " << linenumber;
67 } else if (trace_format == TraceFormat::Ti) {
68 if (extra_ == nullptr)
71 /* Unimplemented calls are: WAITANY, SENDRECV, SCAN, EXSCAN, SSEND, and ISSEND. */
72 std::string container_name(get_container()->get_name());
73 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
74 if (get_container()->get_name().find("rank-") == 0) {
75 /* Subtract -1 because this is the process id and we transform it to the rank id */
76 container_name=std::to_string(stoi(container_name.erase(0, 5)) - 1);
79 if (smpi_cfg_trace_call_location())
80 stream_ << container_name << " location " << filename << " " << linenumber << std::endl ;
82 stream_ << container_name << " " << extra_->print();
88 } // namespace simgrid