Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Continue to reorganize instr
[simgrid.git] / src / instr / instr_private.hpp
1 /* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef INSTR_PRIVATE_HPP
7 #define INSTR_PRIVATE_HPP
8
9 #include <xbt/base.h>
10
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 **/
21 #include <map>
22 #include <set>
23 #include <sstream>
24 #include <string>
25 #include <sys/stat.h>
26 #ifdef WIN32
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))
31 #endif
32
33 typedef simgrid::instr::Container* container_t;
34
35 extern "C" {
36
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;
43
44 /* instr_paje_header.c */
45 XBT_PRIVATE void TRACE_header(bool basic, int size);
46
47 /* from paje.c */
48 XBT_PRIVATE void TRACE_paje_start();
49 XBT_PRIVATE void TRACE_paje_end();
50
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();
78
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();
85
86 /* from resource_utilization.c */
87 XBT_PRIVATE void TRACE_surf_host_set_utilization(const char* resource, const char* category, double value, double now,
88                                                  double delta);
89 XBT_PRIVATE void TRACE_surf_link_set_utilization(const char* resource, const char* category, double value, double now,
90                                                  double delta);
91 XBT_PUBLIC(void) TRACE_surf_resource_utilization_alloc();
92
93 /* instr_paje.c */
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);
101
102 /* instr_config.c */
103 XBT_PRIVATE void TRACE_TI_start();
104 XBT_PRIVATE void TRACE_TI_end();
105
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);
109
110 enum e_caller_type {
111   TRACING_INIT,
112   TRACING_FINALIZE,
113   TRACING_COMM_SIZE,
114   TRACING_COMM_SPLIT,
115   TRACING_COMM_DUP,
116   TRACING_SEND,
117   TRACING_ISEND,
118   TRACING_SSEND,
119   TRACING_ISSEND,
120   TRACING_RECV,
121   TRACING_IRECV,
122   TRACING_SENDRECV,
123   TRACING_TEST,
124   TRACING_WAIT,
125   TRACING_WAITALL,
126   TRACING_WAITANY,
127   TRACING_BARRIER,
128   TRACING_BCAST,
129   TRACING_REDUCE,
130   TRACING_ALLREDUCE,
131   TRACING_ALLTOALL,
132   TRACING_ALLTOALLV,
133   TRACING_GATHER,
134   TRACING_GATHERV,
135   TRACING_SCATTER,
136   TRACING_SCATTERV,
137   TRACING_ALLGATHER,
138   TRACING_ALLGATHERV,
139   TRACING_REDUCE_SCATTER,
140   TRACING_COMPUTING,
141   TRACING_SLEEPING,
142   TRACING_SCAN,
143   TRACING_EXSCAN
144 };
145
146 struct s_instr_extra_data_t {
147   e_caller_type type;
148   int send_size;
149   int recv_size;
150   double comp_size;
151   double sleep_duration;
152   int src;
153   int dst;
154   int root;
155   const char* datatype1;
156   const char* datatype2;
157   int* sendcounts;
158   int* recvcounts;
159   int num_processes;
160 };
161 typedef s_instr_extra_data_t* instr_extra_data;
162
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
168  */
169 enum instr_fmt_type_t { instr_fmt_paje, instr_fmt_TI };
170 extern instr_fmt_type_t instr_fmt_type;
171 }
172
173 #endif