1 /* Copyright (c) 2010-2017. 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 #ifndef INSTR_PRIVATE_HPP
7 #define INSTR_PRIVATE_HPP
11 #include "instr/instr_interface.h"
12 #include "simgrid/instr.h"
13 #include "simgrid_config.h"
14 #include "src/instr/instr_paje_containers.hpp"
15 #include "src/instr/instr_paje_types.hpp"
16 #include "src/internal_config.h"
17 #include "xbt/graph.h"
18 #include <iomanip> /** std::setprecision **/
25 #include <direct.h> // _mkdir
26 /* Need to define function drand48 for Windows */
27 /* FIXME: use _drand48() defined in src/surf/random_mgr.c instead */
28 #define drand48() (rand() / (RAND_MAX + 1.0))
43 enum e_event_type : unsigned int {
44 PAJE_DefineContainerType,
45 PAJE_DefineVariableType,
49 PAJE_DefineEntityValue,
51 PAJE_DestroyContainer,
71 explicit EntityValue(std::string name, std::string color, Type* father);
72 ~EntityValue() = default;
73 const char* getCname() { return name_.c_str(); }
74 long long int getId() { return id_; }
85 e_event_type eventType_;
86 PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType)
87 : container(container), type(type), timestamp_(timestamp), eventType_(eventType){};
89 virtual void print() = 0;
90 void insertIntoBuffer();
93 class VariableEvent : public PajeEvent {
97 VariableEvent(double timestamp, Container* container, Type* type, e_event_type event_type, double value);
98 void print() override;
101 class StateEvent : public PajeEvent {
103 std::string filename;
105 void* extra_ = nullptr;
108 StateEvent(double timestamp, Container* container, Type* type, e_event_type event_type, EntityValue* value);
109 StateEvent(double timestamp, Container* container, Type* type, e_event_type event_type, EntityValue* value,
111 void print() override;
114 class StartLinkEvent : public PajeEvent {
115 Container* sourceContainer_;
121 StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, std::string value,
123 StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, std::string value,
124 std::string key, int size);
125 void print() override;
128 class EndLinkEvent : public PajeEvent {
129 Container* destContainer;
134 EndLinkEvent(double timestamp, Container* container, Type* type, Container* destContainer, std::string value,
136 ~EndLinkEvent() = default;
137 void print() override;
140 class NewEvent : public PajeEvent {
144 NewEvent(double timestamp, Container* container, Type* type, EntityValue* val);
145 void print() override;
148 } // namespace simgrid::instr
149 typedef simgrid::instr::Container* container_t;
153 extern XBT_PRIVATE std::set<std::string> created_categories;
154 extern XBT_PRIVATE std::set<std::string> declared_marks;
155 extern XBT_PRIVATE std::set<std::string> user_host_variables;
156 extern XBT_PRIVATE std::set<std::string> user_vm_variables;
157 extern XBT_PRIVATE std::set<std::string> user_link_variables;
158 extern XBT_PRIVATE double TRACE_last_timestamp_to_dump;
160 /* instr_paje_header.c */
161 XBT_PRIVATE void TRACE_header(bool basic, int size);
164 XBT_PRIVATE void TRACE_paje_start();
165 XBT_PRIVATE void TRACE_paje_end();
167 /* from instr_config.c */
168 XBT_PRIVATE bool TRACE_needs_platform();
169 XBT_PRIVATE bool TRACE_is_enabled();
170 XBT_PRIVATE bool TRACE_platform();
171 XBT_PRIVATE bool TRACE_platform_topology();
172 XBT_PRIVATE bool TRACE_is_configured();
173 XBT_PRIVATE bool TRACE_categorized();
174 XBT_PRIVATE bool TRACE_uncategorized();
175 XBT_PRIVATE bool TRACE_msg_process_is_enabled();
176 XBT_PRIVATE bool TRACE_msg_vm_is_enabled();
177 XBT_PRIVATE bool TRACE_buffer();
178 XBT_PRIVATE bool TRACE_disable_link();
179 XBT_PRIVATE bool TRACE_disable_speed();
180 XBT_PRIVATE bool TRACE_onelink_only();
181 XBT_PRIVATE bool TRACE_disable_destroy();
182 XBT_PRIVATE bool TRACE_basic();
183 XBT_PRIVATE bool TRACE_display_sizes();
184 XBT_PRIVATE char* TRACE_get_comment();
185 XBT_PRIVATE char* TRACE_get_comment_file();
186 XBT_PRIVATE int TRACE_precision();
187 XBT_PRIVATE char* TRACE_get_filename();
188 XBT_PRIVATE char* TRACE_get_viva_uncat_conf();
189 XBT_PRIVATE char* TRACE_get_viva_cat_conf();
190 XBT_PRIVATE void TRACE_generate_viva_uncat_conf();
191 XBT_PRIVATE void TRACE_generate_viva_cat_conf();
192 XBT_PRIVATE void instr_pause_tracing();
193 XBT_PRIVATE void instr_resume_tracing();
195 /* Public functions used in SMPI */
196 XBT_PUBLIC(bool) TRACE_smpi_is_enabled();
197 XBT_PUBLIC(bool) TRACE_smpi_is_grouped();
198 XBT_PUBLIC(bool) TRACE_smpi_is_computing();
199 XBT_PUBLIC(bool) TRACE_smpi_is_sleeping();
200 XBT_PUBLIC(bool) TRACE_smpi_view_internals();
202 /* from resource_utilization.c */
203 XBT_PRIVATE void TRACE_surf_host_set_utilization(const char* resource, const char* category, double value, double now,
205 XBT_PRIVATE void TRACE_surf_link_set_utilization(const char* resource, const char* category, double value, double now,
207 XBT_PUBLIC(void) TRACE_surf_resource_utilization_alloc();
210 extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
211 extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
212 XBT_PRIVATE long long int instr_new_paje_id();
213 void instr_new_variable_type(std::string new_typename, std::string color);
214 void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color);
215 void instr_new_user_state_type(std::string father_type, std::string new_typename);
216 void instr_new_value_for_user_state_type(std::string new_typename, const char* value, std::string color);
219 XBT_PRIVATE void TRACE_TI_start();
220 XBT_PRIVATE void TRACE_TI_end();
222 XBT_PRIVATE void TRACE_paje_dump_buffer(bool force);
223 XBT_PRIVATE void dump_comment_file(std::string filename);
224 XBT_PRIVATE void dump_comment(std::string comment);
255 TRACING_REDUCE_SCATTER,
262 struct s_instr_extra_data_t {
267 double sleep_duration;
271 const char* datatype1;
272 const char* datatype2;
277 typedef s_instr_extra_data_t* instr_extra_data;
279 /* Format of TRACING output.
280 * - paje is the regular format, that we all know
281 * - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such
282 * trace can easily be replayed with smpi_replay afterward. This trick should be removed and replaced by some code
283 * using the signal that we will create to cleanup the TRACING
285 enum instr_fmt_type_t { instr_fmt_paje, instr_fmt_TI };
286 extern instr_fmt_type_t instr_fmt_type;