Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
487f6057928a09542f94fea14decdc27389b8547
[simgrid.git] / src / instr / instr_paje_header.cpp
1 /* Copyright (c) 2010-2023. 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   std::string line;
38   while (std::getline(fs, line))
39     tracing_file << "# " << line;
40   fs.close();
41 }
42
43 void dump_header(bool basic, bool display_sizes)
44 {
45   // Types
46   tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << '\n';
47   tracing_file << "%       Alias string\n";
48   if (basic)
49     tracing_file << "%       ContainerType string\n";
50   else
51     tracing_file << "%       Type string\n";
52
53   tracing_file << "%       Name string\n";
54   tracing_file << "%EndEventDef\n";
55
56   tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << '\n';
57   tracing_file << "%       Alias string\n";
58   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
59   tracing_file << "%       Name string\n";
60   tracing_file << "%       Color color\n";
61   tracing_file << "%EndEventDef\n";
62
63   tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << '\n';
64   tracing_file << "%       Alias string\n";
65   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
66   tracing_file << "%       Name string\n";
67   tracing_file << "%EndEventDef\n";
68
69   tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << '\n';
70   tracing_file << "%       Alias string\n";
71   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
72   tracing_file << "%       Name string\n";
73   tracing_file << "%EndEventDef\n";
74
75   tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << '\n';
76   tracing_file << "%       Alias string\n";
77   tracing_file << "%       " << (basic ? "Container" : "") << "Type string\n";
78   tracing_file << "%       " << (basic ? "Source" : "Start") << "ContainerType string\n";
79   tracing_file << "%       " << (basic ? "Dest" : "End") << "ContainerType string\n";
80   tracing_file << "%       Name string\n";
81   tracing_file << "%EndEventDef\n";
82
83   // EntityValue
84   tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << '\n';
85   tracing_file << "%       Alias string\n";
86   tracing_file << "%       " << (basic ? "Entity" : "") << "Type string\n";
87   tracing_file << "%       Name string\n";
88   tracing_file << "%       Color color\n";
89   tracing_file << "%EndEventDef\n";
90
91   // Container
92   tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << '\n';
93   tracing_file << "%       Time date\n";
94   tracing_file << "%       Alias string\n";
95   tracing_file << "%       Type string\n";
96   tracing_file << "%       Container string\n";
97   tracing_file << "%       Name string\n";
98   tracing_file << "%EndEventDef\n";
99
100   tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << '\n';
101   tracing_file << "%       Time date\n";
102   tracing_file << "%       Type string\n";
103   tracing_file << "%       Name string\n";
104   tracing_file << "%EndEventDef\n";
105
106   // Variable
107   tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << '\n';
108   tracing_file << "%       Time date\n";
109   tracing_file << "%       Type string\n";
110   tracing_file << "%       Container string\n";
111   tracing_file << "%       Value double\n";
112   tracing_file << "%EndEventDef\n";
113
114   tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << '\n';
115   tracing_file << "%       Time date\n";
116   tracing_file << "%       Type string\n";
117   tracing_file << "%       Container string\n";
118   tracing_file << "%       Value double\n";
119   tracing_file << "%EndEventDef\n";
120
121   tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << '\n';
122   tracing_file << "%       Time date\n";
123   tracing_file << "%       Type string\n";
124   tracing_file << "%       Container string\n";
125   tracing_file << "%       Value double\n";
126   tracing_file << "%EndEventDef\n";
127
128   // State
129   tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << '\n';
130   tracing_file << "%       Time date\n";
131   tracing_file << "%       Type string\n";
132   tracing_file << "%       Container string\n";
133   tracing_file << "%       Value string\n";
134   tracing_file << "%EndEventDef\n";
135
136   tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << '\n';
137   tracing_file << "%       Time date\n";
138   tracing_file << "%       Type string\n";
139   tracing_file << "%       Container string\n";
140   tracing_file << "%       Value string\n";
141   if (display_sizes)
142     tracing_file << "%       Size int\n";
143 #if HAVE_SMPI
144   if (smpi_cfg_trace_call_location()) {
145     /* paje currently (May 2016) uses "Filename" and "Linenumber" as reserved words. We cannot use them... */
146     tracing_file << "%       Fname string\n";
147     tracing_file << "%       Lnumber int\n";
148   }
149 #endif
150   tracing_file << "%EndEventDef\n";
151
152   tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << '\n';
153   tracing_file << "%       Time date\n";
154   tracing_file << "%       Type string\n";
155   tracing_file << "%       Container string\n";
156   tracing_file << "%EndEventDef\n";
157
158   if (not basic) {
159     tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << '\n';
160     tracing_file << "%       Time date\n";
161     tracing_file << "%       Type string\n";
162     tracing_file << "%       Container string\n";
163     tracing_file << "%EndEventDef\n";
164   }
165
166   // Link
167   tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << '\n';
168   tracing_file << "%       Time date\n";
169   tracing_file << "%       Type string\n";
170   tracing_file << "%       Container string\n";
171   tracing_file << "%       Value string\n";
172   tracing_file << "%       " << (basic ? "Source" : "Start") << "Container string\n";
173   tracing_file << "%       Key string\n";
174   if (display_sizes)
175     tracing_file << "%       Size int\n";
176   tracing_file << "%EndEventDef\n";
177
178   tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << '\n';
179   tracing_file << "%       Time date\n";
180   tracing_file << "%       Type string\n";
181   tracing_file << "%       Container string\n";
182   tracing_file << "%       Value string\n";
183   tracing_file << "%       " << (basic ? "Dest" : "End") << "Container string\n";
184   tracing_file << "%       Key string\n";
185   tracing_file << "%EndEventDef\n";
186
187   // Event
188   tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << '\n';
189   tracing_file << "%       Time date\n";
190   tracing_file << "%       Type string\n";
191   tracing_file << "%       Container string\n";
192   tracing_file << "%       Value string\n";
193   tracing_file << "%EndEventDef\n";
194 }
195 } // namespace simgrid::instr::paje