1 /* Copyright (c) 2012-2021. 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"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_events, instr, "Paje tracing event system (events)");
16 PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType)
17 : container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
23 PajeEvent::~PajeEvent()
25 on_destruction(*this);
28 StateEvent::StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra)
29 : PajeEvent::PajeEvent(container, type, SIMIX_get_clock(), event_type), value(value), extra_(extra)
32 if (smpi_cfg_trace_call_location()) {
33 const smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
34 filename = loc->filename;
35 linenumber = loc->linenumber;
40 void NewEvent::print()
42 stream_ << " " << value->get_id();
45 void LinkEvent::print()
47 stream_ << " " << value_ << " " << endpoint_->get_id() << " " << key_;
49 if (TRACE_display_sizes() && size_ != -1)
50 stream_ << " " << size_;
53 void StateEvent::print()
55 if (trace_format == TraceFormat::Paje) {
56 if (value != nullptr) // PajeEventType::PopState Event does not need to have a value
57 stream_ << " " << value->get_id();
59 if (TRACE_display_sizes())
60 stream_ << " " << ((extra_ != nullptr) ? extra_->display_size() : "");
63 if (smpi_cfg_trace_call_location())
64 stream_ << " \"" << filename << "\" " << linenumber;
66 } else if (trace_format == TraceFormat::Ti) {
67 if (extra_ == nullptr)
70 /* Unimplemented calls are: WAITANY, SENDRECV, SCAN, EXSCAN, SSEND, and ISSEND. */
71 std::string container_name(get_container()->get_name());
72 // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
73 if (get_container()->get_name().find("rank-") == 0) {
74 /* Subtract -1 because this is the process id and we transform it to the rank id */
75 container_name=std::to_string(stoi(container_name.erase(0, 5)) - 1);
78 if (smpi_cfg_trace_call_location())
79 stream_ << container_name << " location " << filename << " " << linenumber << std::endl ;
81 stream_ << container_name << " " << extra_->print();
87 } // namespace simgrid