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_events.hpp"
16 #include "src/instr/instr_paje_types.hpp"
17 #include "src/instr/instr_paje_values.hpp"
18 #include "src/internal_config.h"
19 #include "xbt/graph.h"
20 #include <iomanip> /** std::setprecision **/
27 #include <direct.h> // _mkdir
28 /* Need to define function drand48 for Windows */
29 /* FIXME: use _drand48() defined in src/surf/random_mgr.c instead */
30 #define drand48() (rand() / (RAND_MAX + 1.0))
33 typedef simgrid::instr::Container* container_t;
37 extern XBT_PRIVATE std::set<std::string> created_categories;
38 extern XBT_PRIVATE std::set<std::string> declared_marks;
39 extern XBT_PRIVATE std::set<std::string> user_host_variables;
40 extern XBT_PRIVATE std::set<std::string> user_vm_variables;
41 extern XBT_PRIVATE std::set<std::string> user_link_variables;
42 extern XBT_PRIVATE double TRACE_last_timestamp_to_dump;
44 /* instr_paje_header.c */
45 XBT_PRIVATE void TRACE_header(bool basic, int size);
48 XBT_PRIVATE void TRACE_paje_start();
49 XBT_PRIVATE void TRACE_paje_end();
51 /* from instr_config.c */
52 XBT_PRIVATE bool TRACE_needs_platform();
53 XBT_PRIVATE bool TRACE_is_enabled();
54 XBT_PRIVATE bool TRACE_platform();
55 XBT_PRIVATE bool TRACE_platform_topology();
56 XBT_PRIVATE bool TRACE_is_configured();
57 XBT_PRIVATE bool TRACE_categorized();
58 XBT_PRIVATE bool TRACE_uncategorized();
59 XBT_PRIVATE bool TRACE_msg_process_is_enabled();
60 XBT_PRIVATE bool TRACE_msg_vm_is_enabled();
61 XBT_PRIVATE bool TRACE_buffer();
62 XBT_PRIVATE bool TRACE_disable_link();
63 XBT_PRIVATE bool TRACE_disable_speed();
64 XBT_PRIVATE bool TRACE_onelink_only();
65 XBT_PRIVATE bool TRACE_disable_destroy();
66 XBT_PRIVATE bool TRACE_basic();
67 XBT_PRIVATE bool TRACE_display_sizes();
68 XBT_PRIVATE int TRACE_precision();
69 XBT_PRIVATE void TRACE_generate_viva_uncat_conf();
70 XBT_PRIVATE void TRACE_generate_viva_cat_conf();
71 XBT_PRIVATE void instr_pause_tracing();
72 XBT_PRIVATE void instr_resume_tracing();
74 /* Public functions used in SMPI */
75 XBT_PUBLIC(bool) TRACE_smpi_is_enabled();
76 XBT_PUBLIC(bool) TRACE_smpi_is_grouped();
77 XBT_PUBLIC(bool) TRACE_smpi_is_computing();
78 XBT_PUBLIC(bool) TRACE_smpi_is_sleeping();
79 XBT_PUBLIC(bool) TRACE_smpi_view_internals();
81 /* from resource_utilization.c */
82 XBT_PRIVATE void TRACE_surf_host_set_utilization(const char* resource, const char* category, double value, double now,
84 XBT_PRIVATE void TRACE_surf_link_set_utilization(const char* resource, const char* category, double value, double now,
86 XBT_PUBLIC(void) TRACE_surf_resource_utilization_alloc();
89 extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
90 extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
91 XBT_PRIVATE long long int instr_new_paje_id();
92 void instr_new_variable_type(std::string new_typename, std::string color);
93 void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color);
94 void instr_new_user_state_type(std::string father_type, std::string new_typename);
95 void instr_new_value_for_user_state_type(std::string new_typename, const char* value, std::string color);
98 XBT_PRIVATE void TRACE_TI_start();
99 XBT_PRIVATE void TRACE_TI_end();
101 XBT_PRIVATE void TRACE_paje_dump_buffer(bool force);
102 XBT_PRIVATE void dump_comment_file(std::string filename);
103 XBT_PRIVATE void dump_comment(std::string comment);
134 TRACING_REDUCE_SCATTER,
141 struct s_instr_extra_data_t {
146 double sleep_duration;
150 const char* datatype1;
151 const char* datatype2;
157 typedef s_instr_extra_data_t* instr_extra_data;
159 /* Format of TRACING output.
160 * - paje is the regular format, that we all know
161 * - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such
162 * trace can easily be replayed with smpi_replay afterward. This trick should be removed and replaced by some code
163 * using the signal that we will create to cleanup the TRACING
165 enum instr_fmt_type_t { instr_fmt_paje, instr_fmt_TI };
166 extern instr_fmt_type_t instr_fmt_type;
168 XBT_PRIVATE std::string TRACE_get_comment();
169 XBT_PRIVATE std::string TRACE_get_comment_file();
170 XBT_PRIVATE std::string TRACE_get_filename();
171 XBT_PRIVATE std::string TRACE_get_viva_uncat_conf();
172 XBT_PRIVATE std::string TRACE_get_viva_cat_conf();