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 char* TRACE_get_comment();
69 XBT_PRIVATE char* TRACE_get_comment_file();
70 XBT_PRIVATE int TRACE_precision();
71 XBT_PRIVATE char* TRACE_get_filename();
72 XBT_PRIVATE char* TRACE_get_viva_uncat_conf();
73 XBT_PRIVATE char* TRACE_get_viva_cat_conf();
74 XBT_PRIVATE void TRACE_generate_viva_uncat_conf();
75 XBT_PRIVATE void TRACE_generate_viva_cat_conf();
76 XBT_PRIVATE void instr_pause_tracing();
77 XBT_PRIVATE void instr_resume_tracing();
79 /* Public functions used in SMPI */
80 XBT_PUBLIC(bool) TRACE_smpi_is_enabled();
81 XBT_PUBLIC(bool) TRACE_smpi_is_grouped();
82 XBT_PUBLIC(bool) TRACE_smpi_is_computing();
83 XBT_PUBLIC(bool) TRACE_smpi_is_sleeping();
84 XBT_PUBLIC(bool) TRACE_smpi_view_internals();
86 /* from resource_utilization.c */
87 XBT_PRIVATE void TRACE_surf_host_set_utilization(const char* resource, const char* category, double value, double now,
89 XBT_PRIVATE void TRACE_surf_link_set_utilization(const char* resource, const char* category, double value, double now,
91 XBT_PUBLIC(void) TRACE_surf_resource_utilization_alloc();
94 extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
95 extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
96 XBT_PRIVATE long long int instr_new_paje_id();
97 void instr_new_variable_type(std::string new_typename, std::string color);
98 void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color);
99 void instr_new_user_state_type(std::string father_type, std::string new_typename);
100 void instr_new_value_for_user_state_type(std::string new_typename, const char* value, std::string color);
103 XBT_PRIVATE void TRACE_TI_start();
104 XBT_PRIVATE void TRACE_TI_end();
106 XBT_PRIVATE void TRACE_paje_dump_buffer(bool force);
107 XBT_PRIVATE void dump_comment_file(std::string filename);
108 XBT_PRIVATE void dump_comment(std::string comment);
139 TRACING_REDUCE_SCATTER,
146 struct s_instr_extra_data_t {
151 double sleep_duration;
155 const char* datatype1;
156 const char* datatype2;
161 typedef s_instr_extra_data_t* instr_extra_data;
163 /* Format of TRACING output.
164 * - paje is the regular format, that we all know
165 * - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such
166 * trace can easily be replayed with smpi_replay afterward. This trick should be removed and replaced by some code
167 * using the signal that we will create to cleanup the TRACING
169 enum instr_fmt_type_t { instr_fmt_paje, instr_fmt_TI };
170 extern instr_fmt_type_t instr_fmt_type;