Logo AND Algorithmique Numérique Distribuée

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