1 /* Copyright (c) 2010-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 "simgrid/version.h"
7 #include "src/instr/instr_private.hpp"
8 #include "src/smpi/include/private.hpp"
9 #include <simgrid/Exception.hpp>
10 #include <simgrid/s4u/Engine.hpp>
12 extern std::ofstream tracing_file;
13 namespace simgrid::instr::paje {
15 void dump_generator_version()
17 tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
18 << "." << SIMGRID_VERSION_PATCH << '\n';
20 for (auto const& str : simgrid::s4u::Engine::get_instance()->get_cmdline()) {
21 tracing_file << str << " ";
23 tracing_file << "]\n";
26 void dump_comment_file(const std::string& filename)
30 std::ifstream fs(filename.c_str(), std::ifstream::in);
33 throw TracingError(XBT_THROW_POINT,
34 xbt::string_printf("Comment file %s could not be opened for reading.", filename.c_str()));
37 while (std::getline(fs, line))
38 tracing_file << "# " << line;
42 void dump_header(bool basic, bool display_sizes)
45 tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << '\n';
46 tracing_file << "% Alias string\n";
48 tracing_file << "% ContainerType string\n";
50 tracing_file << "% Type string\n";
52 tracing_file << "% Name string\n";
53 tracing_file << "%EndEventDef\n";
55 tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << '\n';
56 tracing_file << "% Alias string\n";
57 tracing_file << "% " << (basic ? "Container" : "") << "Type string\n";
58 tracing_file << "% Name string\n";
59 tracing_file << "% Color color\n";
60 tracing_file << "%EndEventDef\n";
62 tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << '\n';
63 tracing_file << "% Alias string\n";
64 tracing_file << "% " << (basic ? "Container" : "") << "Type string\n";
65 tracing_file << "% Name string\n";
66 tracing_file << "%EndEventDef\n";
68 tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << '\n';
69 tracing_file << "% Alias string\n";
70 tracing_file << "% " << (basic ? "Container" : "") << "Type string\n";
71 tracing_file << "% Name string\n";
72 tracing_file << "%EndEventDef\n";
74 tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << '\n';
75 tracing_file << "% Alias string\n";
76 tracing_file << "% " << (basic ? "Container" : "") << "Type string\n";
77 tracing_file << "% " << (basic ? "Source" : "Start") << "ContainerType string\n";
78 tracing_file << "% " << (basic ? "Dest" : "End") << "ContainerType string\n";
79 tracing_file << "% Name string\n";
80 tracing_file << "%EndEventDef\n";
83 tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << '\n';
84 tracing_file << "% Alias string\n";
85 tracing_file << "% " << (basic ? "Entity" : "") << "Type string\n";
86 tracing_file << "% Name string\n";
87 tracing_file << "% Color color\n";
88 tracing_file << "%EndEventDef\n";
91 tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << '\n';
92 tracing_file << "% Time date\n";
93 tracing_file << "% Alias string\n";
94 tracing_file << "% Type string\n";
95 tracing_file << "% Container string\n";
96 tracing_file << "% Name string\n";
97 tracing_file << "%EndEventDef\n";
99 tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << '\n';
100 tracing_file << "% Time date\n";
101 tracing_file << "% Type string\n";
102 tracing_file << "% Name string\n";
103 tracing_file << "%EndEventDef\n";
106 tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << '\n';
107 tracing_file << "% Time date\n";
108 tracing_file << "% Type string\n";
109 tracing_file << "% Container string\n";
110 tracing_file << "% Value double\n";
111 tracing_file << "%EndEventDef\n";
113 tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << '\n';
114 tracing_file << "% Time date\n";
115 tracing_file << "% Type string\n";
116 tracing_file << "% Container string\n";
117 tracing_file << "% Value double\n";
118 tracing_file << "%EndEventDef\n";
120 tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << '\n';
121 tracing_file << "% Time date\n";
122 tracing_file << "% Type string\n";
123 tracing_file << "% Container string\n";
124 tracing_file << "% Value double\n";
125 tracing_file << "%EndEventDef\n";
128 tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << '\n';
129 tracing_file << "% Time date\n";
130 tracing_file << "% Type string\n";
131 tracing_file << "% Container string\n";
132 tracing_file << "% Value string\n";
133 tracing_file << "%EndEventDef\n";
135 tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << '\n';
136 tracing_file << "% Time date\n";
137 tracing_file << "% Type string\n";
138 tracing_file << "% Container string\n";
139 tracing_file << "% Value string\n";
141 tracing_file << "% Size int\n";
143 if (smpi_cfg_trace_call_location()) {
144 /* paje currently (May 2016) uses "Filename" and "Linenumber" as reserved words. We cannot use them... */
145 tracing_file << "% Fname string\n";
146 tracing_file << "% Lnumber int\n";
149 tracing_file << "%EndEventDef\n";
151 tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << '\n';
152 tracing_file << "% Time date\n";
153 tracing_file << "% Type string\n";
154 tracing_file << "% Container string\n";
155 tracing_file << "%EndEventDef\n";
158 tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << '\n';
159 tracing_file << "% Time date\n";
160 tracing_file << "% Type string\n";
161 tracing_file << "% Container string\n";
162 tracing_file << "%EndEventDef\n";
166 tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << '\n';
167 tracing_file << "% Time date\n";
168 tracing_file << "% Type string\n";
169 tracing_file << "% Container string\n";
170 tracing_file << "% Value string\n";
171 tracing_file << "% " << (basic ? "Source" : "Start") << "Container string\n";
172 tracing_file << "% Key string\n";
174 tracing_file << "% Size int\n";
175 tracing_file << "%EndEventDef\n";
177 tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << '\n';
178 tracing_file << "% Time date\n";
179 tracing_file << "% Type string\n";
180 tracing_file << "% Container string\n";
181 tracing_file << "% Value string\n";
182 tracing_file << "% " << (basic ? "Dest" : "End") << "Container string\n";
183 tracing_file << "% Key string\n";
184 tracing_file << "%EndEventDef\n";
187 tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << '\n';
188 tracing_file << "% Time date\n";
189 tracing_file << "% Type string\n";
190 tracing_file << "% Container string\n";
191 tracing_file << "% Value string\n";
192 tracing_file << "%EndEventDef\n";
194 } // namespace simgrid::instr::paje