Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill a parameter that is always true
[simgrid.git] / src / instr / instr_paje_header.cpp
1 /* Copyright (c) 2010-2022. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "simgrid/Exception.hpp"
8 #include "simgrid/version.h"
9 #include "src/instr/instr_private.hpp"
10 #include "src/smpi/include/private.hpp"
11 #include "xbt/virtu.h" /* xbt::cmdline */
12
13 extern std::ofstream tracing_file;
14 namespace simgrid::instr::paje {
15
16 void dump_generator_version()
17 {
18   tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
19                << "." << SIMGRID_VERSION_PATCH << '\n';
20   tracing_file << "#[";
21   for (auto const& str : simgrid::xbt::cmdline) {
22     tracing_file << str << " ";
23   }
24   tracing_file << "]\n";
25 }
26
27 void dump_comment_file(const std::string& filename)
28 {
29   if (filename.empty())
30     return;
31   std::ifstream fs(filename.c_str(), std::ifstream::in);
32
33   if (fs.fail())
34     throw TracingError(XBT_THROW_POINT,
35                        xbt::string_printf("Comment file %s could not be opened for reading.", filename.c_str()));
36
37   while (not fs.eof()) {
38     std::string line;
39     std::getline(fs, line);
40     tracing_file << "# " << line;
41   }
42   fs.close();
43 }
44
45 void dump_header(bool basic, bool display_sizes)
46 {
47   // Types
48   tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << '\n';
49   tracing_file << "%       Alias string\n";
50   if (basic)
51     tracing_file << "%       ContainerType string\n";
52   else
53     tracing_file << "%       Type string\n";
54
55   tracing_file << "%       Name string\n";
56   tracing_file << "%EndEventDef\n";
57
58   tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << '\n';
59   tracing_file << "%       Alias string\n";
60   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
61   tracing_file << "%       Name string\n";
62   tracing_file << "%       Color color\n";
63   tracing_file << "%EndEventDef\n";
64
65   tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << '\n';
66   tracing_file << "%       Alias string\n";
67   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
68   tracing_file << "%       Name string\n";
69   tracing_file << "%EndEventDef\n";
70
71   tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << '\n';
72   tracing_file << "%       Alias string\n";
73   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
74   tracing_file << "%       Name string\n";
75   tracing_file << "%EndEventDef\n";
76
77   tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << '\n';
78   tracing_file << "%       Alias string\n";
79   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
80   tracing_file << "%       " << (basic ? "Source" : "Start") << "ContainerType string\n";
81   tracing_file << "%       " << (basic ? "Dest" : "End") << "ContainerType string\n";
82   tracing_file << "%       Name string\n";
83   tracing_file << "%EndEventDef\n";
84
85   // EntityValue
86   tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << '\n';
87   tracing_file << "%       Alias string\n";
88   tracing_file << "%       " << (basic ? "Entity" : "") << "Type string\n";
89   tracing_file << "%       Name string\n";
90   tracing_file << "%       Color color\n";
91   tracing_file << "%EndEventDef\n";
92
93   // Container
94   tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << '\n';
95   tracing_file << "%       Time date\n";
96   tracing_file << "%       Alias string\n";
97   tracing_file << "%       Type string\n";
98   tracing_file << "%       Container string\n";
99   tracing_file << "%       Name string\n";
100   tracing_file << "%EndEventDef\n";
101
102   tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << '\n';
103   tracing_file << "%       Time date\n";
104   tracing_file << "%       Type string\n";
105   tracing_file << "%       Name string\n";
106   tracing_file << "%EndEventDef\n";
107
108   // Variable
109   tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << '\n';
110   tracing_file << "%       Time date\n";
111   tracing_file << "%       Type string\n";
112   tracing_file << "%       Container string\n";
113   tracing_file << "%       Value double\n";
114   tracing_file << "%EndEventDef\n";
115
116   tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << '\n';
117   tracing_file << "%       Time date\n";
118   tracing_file << "%       Type string\n";
119   tracing_file << "%       Container string\n";
120   tracing_file << "%       Value double\n";
121   tracing_file << "%EndEventDef\n";
122
123   tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << '\n';
124   tracing_file << "%       Time date\n";
125   tracing_file << "%       Type string\n";
126   tracing_file << "%       Container string\n";
127   tracing_file << "%       Value double\n";
128   tracing_file << "%EndEventDef\n";
129
130   // State
131   tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << '\n';
132   tracing_file << "%       Time date\n";
133   tracing_file << "%       Type string\n";
134   tracing_file << "%       Container string\n";
135   tracing_file << "%       Value string\n";
136   tracing_file << "%EndEventDef\n";
137
138   tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << '\n';
139   tracing_file << "%       Time date\n";
140   tracing_file << "%       Type string\n";
141   tracing_file << "%       Container string\n";
142   tracing_file << "%       Value string\n";
143   if (display_sizes)
144     tracing_file << "%       Size int\n";
145 #if HAVE_SMPI
146   if (smpi_cfg_trace_call_location()) {
147     /* paje currently (May 2016) uses "Filename" and "Linenumber" as reserved words. We cannot use them... */
148     tracing_file << "%       Fname string\n";
149     tracing_file << "%       Lnumber int\n";
150   }
151 #endif
152   tracing_file << "%EndEventDef\n";
153
154   tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << '\n';
155   tracing_file << "%       Time date\n";
156   tracing_file << "%       Type string\n";
157   tracing_file << "%       Container string\n";
158   tracing_file << "%EndEventDef\n";
159
160   if (not basic) {
161     tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << '\n';
162     tracing_file << "%       Time date\n";
163     tracing_file << "%       Type string\n";
164     tracing_file << "%       Container string\n";
165     tracing_file << "%EndEventDef\n";
166   }
167
168   // Link
169   tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << '\n';
170   tracing_file << "%       Time date\n";
171   tracing_file << "%       Type string\n";
172   tracing_file << "%       Container string\n";
173   tracing_file << "%       Value string\n";
174   tracing_file << "%       " << (basic ? "Source" : "Start") << "Container string\n";
175   tracing_file << "%       Key string\n";
176   if (display_sizes)
177     tracing_file << "%       Size int\n";
178   tracing_file << "%EndEventDef\n";
179
180   tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << '\n';
181   tracing_file << "%       Time date\n";
182   tracing_file << "%       Type string\n";
183   tracing_file << "%       Container string\n";
184   tracing_file << "%       Value string\n";
185   tracing_file << "%       " << (basic ? "Dest" : "End") << "Container string\n";
186   tracing_file << "%       Key string\n";
187   tracing_file << "%EndEventDef\n";
188
189   // Event
190   tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << '\n';
191   tracing_file << "%       Time date\n";
192   tracing_file << "%       Type string\n";
193   tracing_file << "%       Container string\n";
194   tracing_file << "%       Value string\n";
195   tracing_file << "%EndEventDef\n";
196 }
197 } // namespace simgrid::instr::paje