Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] fix SimDag tracing
[simgrid.git] / src / instr / instr_interface.c
1 /* Copyright (c) 2010. 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_config.h"
8
9 #ifdef HAVE_TRACING
10 #include "instr/instr_private.h"
11 #include "surf/network_private.h"
12
13 typedef enum {
14   INSTR_US_DECLARE,
15   INSTR_US_SET,
16   INSTR_US_ADD,
17   INSTR_US_SUB
18 } InstrUserVariable;
19
20 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_api, instr, "API");
21
22 /** \ingroup TRACE_category
23  *  \brief Declare a new category with a random color.
24  *
25  *  This function should be used to define a user category. The
26  *  category can be used to differentiate the tasks that are created
27  *  during the simulation (for example, tasks from server1, server2,
28  *  or request tasks, computation tasks, communication tasks). All
29  *  resource utilization (host power and link bandwidth) will be
30  *  classified according to the task category. Tasks that do not
31  *  belong to a category are not traced. The color for the category
32  *  that is being declared is random. This function has no effect
33  *  if a category with the same name has been already declared.
34  *
35  * See \ref tracing_tracing for details on how to trace
36  * the (categorized) resource utilization.
37  *
38  *  \param category The name of the new tracing category to be created.
39  *
40  *  \see TRACE_category_with_color, MSG_task_set_category, SD_task_set_category
41  */
42 void TRACE_category(const char *category)
43 {
44   TRACE_category_with_color (category, NULL);
45 }
46
47 /** \ingroup TRACE_category
48  *  \brief Declare a new category with a color.
49  *
50  *  Same as #TRACE_category, but let user specify a color encoded as a
51  *  RGB-like string with three floats from 0 to 1. So, to specify a
52  *  red color, pass "1 0 0" as color parameter. A light-gray color
53  *  can be specified using "0.7 0.7 0.7" as color. This function has
54  *  no effect if a category with the same name has been already declared.
55  *
56  * See \ref tracing_tracing for details on how to trace
57  * the (categorized) resource utilization.
58  *
59  *  \param category The name of the new tracing category to be created.
60  *  \param color The color of the category (see \ref tracing_tracing to
61  *  know how to correctly specify the color)
62  *
63  *  \see MSG_task_set_category, SD_task_set_category
64  */
65 void TRACE_category_with_color (const char *category, const char *color)
66 {
67   /* safe switch */
68   if (!TRACE_is_enabled()) return;
69
70   if (!(TRACE_categorized() && category != NULL)) return;
71
72   /* if platform is not traced, we can't deal with categories */
73   if (!TRACE_needs_platform()) return;
74
75   //check if category is already created
76   char *created = xbt_dict_get_or_null(created_categories, category);
77   if (created) return;
78   xbt_dict_set (created_categories, category, xbt_strdup("1"), NULL);
79
80   //define final_color
81   char final_color[INSTR_DEFAULT_STR_SIZE];
82   if (!color){
83     //generate a random color
84     double red = drand48();
85     double green = drand48();
86     double blue = drand48();
87     snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%f %f %f", red, green, blue);
88   }else{
89     snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
90   }
91
92   XBT_DEBUG("CAT,declare %s, %s", category, final_color);
93
94   //define the type of this category on top of hosts and links
95   instr_new_variable_type (category, final_color);
96 }
97
98 /** \ingroup TRACE_mark
99  * \brief Declare a new type for tracing mark.
100  *
101  * This function declares a new Paje event
102  * type in the trace file that can be used by
103  * simulators to declare application-level
104  * marks. This function is independent of
105  * which API is used in SimGrid.
106  *
107  * \param mark_type The name of the new type.
108  *
109  * \see TRACE_mark
110  */
111 void TRACE_declare_mark(const char *mark_type)
112 {
113   /* safe switch */
114   if (!TRACE_is_enabled()) return;
115
116   if (!mark_type) return;
117
118   XBT_DEBUG("MARK,declare %s", mark_type);
119   PJ_type_event_new(mark_type, NULL, PJ_type_get_root());
120 }
121
122 /**
123  * \ingroup TRACE_mark
124  * \brief Create a new instance of a tracing mark type.
125  *
126  * This function creates a mark in the trace file. The
127  * first parameter had to be previously declared using
128  * #TRACE_declare_mark, the second is the identifier
129  * for this mark instance. We recommend that the
130  * mark_value is a unique value for the whole simulation.
131  * Nevertheless, this is not a strong requirement: the
132  * trace will be valid even if there are multiple mark
133  * identifiers for the same trace.
134  *
135  * \param mark_type The name of the type for which the new instance will belong.
136  * \param mark_value The name of the new instance mark.
137  *
138  * \see TRACE_declare_mark
139  */
140 void TRACE_mark(const char *mark_type, const char *mark_value)
141 {
142   /* safe switch */
143   if (!TRACE_is_enabled()) return;
144
145   if (!mark_type || !mark_value) return;
146
147   XBT_DEBUG("MARK %s %s", mark_type, mark_value);
148   type_t type = PJ_type_get (mark_type, PJ_type_get_root());
149   if (type == NULL){
150     THROWF (tracing_error, 1, "mark_type with name (%s) not declared before", mark_type);
151   }
152   val_t value = PJ_value_get (mark_value, type);
153   if (value == NULL){
154     value = PJ_value_new (mark_value, NULL, type);
155   }
156   new_pajeNewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
157 }
158
159 static void instr_user_variable(double time,
160                          const char *resource,
161                          const char *variable,
162                          const char *father_type,
163                          double value,
164                          InstrUserVariable what,
165                          const char *color)
166 {
167   /* safe switch */
168   if (!TRACE_is_enabled()) return;
169
170   /* if platform is not traced, we can't deal user variables */
171   if (!TRACE_needs_platform()) return;
172
173   char valuestr[100];
174   snprintf(valuestr, 100, "%g", value);
175
176   switch (what){
177   case INSTR_US_DECLARE:
178     instr_new_user_variable_type (father_type, variable, color);
179     break;
180   case INSTR_US_SET:
181   {
182     container_t container = PJ_container_get(resource);
183     type_t type = PJ_type_get (variable, container->type);
184     new_pajeSetVariable(time, container, type, value);
185     break;
186   }
187   case INSTR_US_ADD:
188   {
189     container_t container = PJ_container_get(resource);
190     type_t type = PJ_type_get (variable, container->type);
191     new_pajeAddVariable(time, container, type, value);
192     break;
193   }
194   case INSTR_US_SUB:
195   {
196     container_t container = PJ_container_get(resource);
197     type_t type = PJ_type_get (variable, container->type);
198     new_pajeSubVariable(time, container, type, value);
199     break;
200   }
201   default:
202     //TODO: launch exception
203     break;
204   }
205 }
206
207 static void instr_user_srcdst_variable(double time,
208                               const char *src,
209                               const char *dst,
210                               const char *variable,
211                               const char *father_type,
212                               double value,
213                               InstrUserVariable what)
214 {
215   xbt_dynar_t route=NULL;
216   network_element_t src_elm = xbt_lib_get_or_null(host_lib,src,ROUTING_HOST_LEVEL);
217   if(!src_elm) src_elm = xbt_lib_get_or_null(as_router_lib,src,ROUTING_ASR_LEVEL);
218   if(!src_elm) xbt_die("Element '%s' not found!",src);
219
220   network_element_t dst_elm = xbt_lib_get_or_null(host_lib,dst,ROUTING_HOST_LEVEL);
221   if(!dst_elm) dst_elm = xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
222   if(!dst_elm) xbt_die("Element '%s' not found!",dst);
223
224   routing_get_route_and_latency (src_elm, dst_elm, &route,NULL);
225   unsigned int i;
226   void *link;
227   xbt_dynar_foreach (route, i, link) {
228     char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
229     instr_user_variable (time, link_name, variable, father_type, value, what, NULL);
230   }
231 }
232
233 /** \ingroup TRACE_API
234  *  \brief Creates a file with the topology of the platform file used for the simulator.
235  *
236  *  The graph topology will have the following properties: all hosts, links and routers
237  *  of the platform file are mapped to graph nodes; routes are mapped to edges.
238  *  The platform's AS are not represented in the output.
239  *
240  *  \param filename The name of the file that will hold the graph.
241  *
242  *  \return 1 of successful, 0 otherwise.
243  */
244 int TRACE_platform_graph_export_graphviz (const char *filename)
245 {
246   /* returns 1 if successful, 0 otherwise */
247   if (!TRACE_is_enabled()) return 0;
248   xbt_graph_t g = instr_routing_platform_graph();
249   if (g == NULL) return 0;
250   instr_routing_platform_graph_export_graphviz (g, filename);
251   xbt_graph_free_graph (g, xbt_free, xbt_free, NULL);
252   return 1;
253 }
254
255 /*
256  * Derived functions that use instr_user_variable and TRACE_user_srcdst_variable.
257  * They were previously defined as pre-processors directives, but were transformed
258  * into functions so the user can track them using gdb.
259  */
260
261 /* for host variables */
262 /** \ingroup TRACE_user_variables
263  *  \brief Declare a new user variable associated to hosts.
264  *
265  *  Declare a user variable that will be associated to hosts.
266  *  A user host variable can be used to trace user variables
267  *  such as the number of tasks in a server, the number of
268  *  clients in an application (for hosts), and so on. The color
269  *  associated to this new variable will be random.
270  *
271  *  \param variable The name of the new variable to be declared.
272  *
273  *  \see TRACE_host_variable_declare_with_color
274  */
275 void TRACE_host_variable_declare (const char *variable)
276 {
277   instr_user_variable(0, NULL, variable, "HOST", 0, INSTR_US_DECLARE, NULL);
278 }
279
280 /** \ingroup TRACE_user_variables
281  *  \brief Declare a new user variable associated to hosts with a color.
282  *
283  *  Same as #TRACE_host_variable_declare, but associated a color
284  *  to the newly created user host variable. The color needs to be
285  *  a string with three numbers separated by spaces in the range [0,1].
286  *  A light-gray color can be specified using "0.7 0.7 0.7" as color.
287  *
288  *  \param variable The name of the new variable to be declared.
289  *  \param color The color for the new variable.
290  *
291  */
292 void TRACE_host_variable_declare_with_color (const char *variable, const char *color)
293 {
294   instr_user_variable(0, NULL, variable, "HOST", 0, INSTR_US_DECLARE, color);
295 }
296
297 /** \ingroup TRACE_user_variables
298  *  \brief Set the value of a variable of a host.
299  *
300  *  \param host The name of the host to be considered.
301  *  \param variable The name of the variable to be considered.
302  *  \param value The new value of the variable.
303  *
304  *  \see TRACE_host_variable_declare, TRACE_host_variable_add, TRACE_host_variable_sub
305  */
306 void TRACE_host_variable_set (const char *host, const char *variable, double value)
307 {
308   TRACE_host_variable_set_with_time (MSG_get_clock(), host, variable, value);
309 }
310
311 /** \ingroup TRACE_user_variables
312  *  \brief Add a value to a variable of a host.
313  *
314  *  \param host The name of the host to be considered.
315  *  \param variable The name of the variable to be considered.
316  *  \param value The value to be added to the variable.
317  *
318  *  \see TRACE_host_variable_declare, TRACE_host_variable_set, TRACE_host_variable_sub
319  */
320 void TRACE_host_variable_add (const char *host, const char *variable, double value)
321 {
322   TRACE_host_variable_add_with_time (MSG_get_clock(), host, variable, value);
323 }
324
325 /** \ingroup TRACE_user_variables
326  *  \brief Subtract a value from a variable of a host.
327  *
328  *  \param host The name of the host to be considered.
329  *  \param variable The name of the variable to be considered.
330  *  \param value The value to be subtracted from the variable.
331  *
332  *  \see TRACE_host_variable_declare, TRACE_host_variable_set, TRACE_host_variable_add
333  */
334 void TRACE_host_variable_sub (const char *host, const char *variable, double value)
335 {
336   TRACE_host_variable_sub_with_time (MSG_get_clock(), host, variable, value);
337 }
338
339 /** \ingroup TRACE_user_variables
340  *  \brief Set the value of a variable of a host at a given timestamp.
341  *
342  *  Same as #TRACE_host_variable_set, but let user specify
343  *  the time used to trace it. Users can specify a time that
344  *  is not the simulated clock time as defined by the core
345  *  simulator. This allows a fine-grain control of time
346  *  definition, but should be used with caution since the trace
347  *  can be inconsistent if resource utilization traces are also traced.
348  *
349  *  \param time The timestamp to be used to tag this change of value.
350  *  \param host The name of the host to be considered.
351  *  \param variable The name of the variable to be considered.
352  *  \param value The new value of the variable.
353  *
354  *  \see TRACE_host_variable_declare, TRACE_host_variable_add_with_time, TRACE_host_variable_sub_with_time
355  */
356 void TRACE_host_variable_set_with_time (double time, const char *host, const char *variable, double value)
357 {
358   instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SET, NULL);
359 }
360
361 /** \ingroup TRACE_user_variables
362  *  \brief Add a value to a variable of a host at a given timestamp.
363  *
364  *  Same as #TRACE_host_variable_add, but let user specify
365  *  the time used to trace it. Users can specify a time that
366  *  is not the simulated clock time as defined by the core
367  *  simulator. This allows a fine-grain control of time
368  *  definition, but should be used with caution since the trace
369  *  can be inconsistent if resource utilization traces are also traced.
370  *
371  *  \param time The timestamp to be used to tag this change of value.
372  *  \param host The name of the host to be considered.
373  *  \param variable The name of the variable to be considered.
374  *  \param value The value to be added to the variable.
375  *
376  *  \see TRACE_host_variable_declare, TRACE_host_variable_set_with_time, TRACE_host_variable_sub_with_time
377  */
378 void TRACE_host_variable_add_with_time (double time, const char *host, const char *variable, double value)
379 {
380   instr_user_variable(time, host, variable, "HOST", value, INSTR_US_ADD, NULL);
381 }
382
383 /** \ingroup TRACE_user_variables
384  *  \brief Subtract a value from a variable of a host at a given timestamp.
385  *
386  *  Same as #TRACE_host_variable_sub, but let user specify
387  *  the time used to trace it. Users can specify a time that
388  *  is not the simulated clock time as defined by the core
389  *  simulator. This allows a fine-grain control of time
390  *  definition, but should be used with caution since the trace
391  *  can be inconsistent if resource utilization traces are also traced.
392  *
393  *  \param time The timestamp to be used to tag this change of value.
394  *  \param host The name of the host to be considered.
395  *  \param variable The name of the variable to be considered.
396  *  \param value The value to be subtracted from the variable.
397  *
398  *  \see TRACE_host_variable_declare, TRACE_host_variable_set_with_time, TRACE_host_variable_add_with_time
399  */
400 void TRACE_host_variable_sub_with_time (double time, const char *host, const char *variable, double value)
401 {
402   instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SUB, NULL);
403 }
404
405 /* for link variables */
406 /** \ingroup TRACE_user_variables
407  *  \brief Declare a new user variable associated to links.
408  *
409  *  Declare a user variable that will be associated to links.
410  *  A user link variable can be used, for example, to trace
411  *  user variables such as the number of messages being
412  *  transferred through network links. The color
413  *  associated to this new variable will be random.
414  *
415  *  \param variable The name of the new variable to be declared.
416  *
417  *  \see TRACE_link_variable_declare_with_color
418  */
419 void TRACE_link_variable_declare (const char *variable)
420 {
421   instr_user_variable (0, NULL, variable, "LINK", 0, INSTR_US_DECLARE, NULL);
422 }
423
424 /** \ingroup TRACE_user_variables
425  *  \brief Declare a new user variable associated to links with a color.
426  *
427  *  Same as #TRACE_link_variable_declare, but associated a color
428  *  to the newly created user link variable. The color needs to be
429  *  a string with three numbers separated by spaces in the range [0,1].
430  *  A light-gray color can be specified using "0.7 0.7 0.7" as color.
431  *
432  *  \param variable The name of the new variable to be declared.
433  *  \param color The color for the new variable.
434  *
435  */
436 void TRACE_link_variable_declare_with_color (const char *variable, const char *color)
437 {
438   instr_user_variable (0, NULL, variable, "LINK", 0, INSTR_US_DECLARE, color);
439 }
440
441 /** \ingroup TRACE_user_variables
442  *  \brief Set the value of a variable of a link.
443  *
444  *  \param link The name of the link to be considered.
445  *  \param variable The name of the variable to be considered.
446  *  \param value The new value of the variable.
447  *
448  *  \see TRACE_link_variable_declare, TRACE_link_variable_add, TRACE_link_variable_sub
449  */
450 void TRACE_link_variable_set (const char *link, const char *variable, double value)
451 {
452   TRACE_link_variable_set_with_time (MSG_get_clock(), link, variable, value);
453 }
454
455 /** \ingroup TRACE_user_variables
456  *  \brief Add a value to a variable of a link.
457  *
458  *  \param link The name of the link to be considered.
459  *  \param variable The name of the variable to be considered.
460  *  \param value The value to be added to the variable.
461  *
462  *  \see TRACE_link_variable_declare, TRACE_link_variable_set, TRACE_link_variable_sub
463  */
464 void TRACE_link_variable_add (const char *link, const char *variable, double value)
465 {
466   TRACE_link_variable_add_with_time (MSG_get_clock(), link, variable, value);
467 }
468
469 /** \ingroup TRACE_user_variables
470  *  \brief Subtract a value from a variable of a link.
471  *
472  *  \param link The name of the link to be considered.
473  *  \param variable The name of the variable to be considered.
474  *  \param value The value to be subtracted from the variable.
475  *
476  *  \see TRACE_link_variable_declare, TRACE_link_variable_set, TRACE_link_variable_add
477  */
478 void TRACE_link_variable_sub (const char *link, const char *variable, double value)
479 {
480   TRACE_link_variable_sub_with_time (MSG_get_clock(), link, variable, value);
481 }
482
483 /** \ingroup TRACE_user_variables
484  *  \brief Set the value of a variable of a link at a given timestamp.
485  *
486  *  Same as #TRACE_link_variable_set, but let user specify
487  *  the time used to trace it. Users can specify a time that
488  *  is not the simulated clock time as defined by the core
489  *  simulator. This allows a fine-grain control of time
490  *  definition, but should be used with caution since the trace
491  *  can be inconsistent if resource utilization traces are also traced.
492  *
493  *  \param time The timestamp to be used to tag this change of value.
494  *  \param link The name of the link to be considered.
495  *  \param variable The name of the variable to be considered.
496  *  \param value The new value of the variable.
497  *
498  *  \see TRACE_link_variable_declare, TRACE_link_variable_add_with_time, TRACE_link_variable_sub_with_time
499  */
500 void TRACE_link_variable_set_with_time (double time, const char *link, const char *variable, double value)
501 {
502   instr_user_variable (time, link, variable, "LINK", value, INSTR_US_SET, NULL);
503 }
504
505 /** \ingroup TRACE_user_variables
506  *  \brief Add a value to a variable of a link at a given timestamp.
507  *
508  *  Same as #TRACE_link_variable_add, but let user specify
509  *  the time used to trace it. Users can specify a time that
510  *  is not the simulated clock time as defined by the core
511  *  simulator. This allows a fine-grain control of time
512  *  definition, but should be used with caution since the trace
513  *  can be inconsistent if resource utilization traces are also traced.
514  *
515  *  \param time The timestamp to be used to tag this change of value.
516  *  \param link The name of the link to be considered.
517  *  \param variable The name of the variable to be considered.
518  *  \param value The value to be added to the variable.
519  *
520  *  \see TRACE_link_variable_declare, TRACE_link_variable_set_with_time, TRACE_link_variable_sub_with_time
521  */
522 void TRACE_link_variable_add_with_time (double time, const char *link, const char *variable, double value)
523 {
524   instr_user_variable (time, link, variable, "LINK", value, INSTR_US_ADD, NULL);
525 }
526
527 /** \ingroup TRACE_user_variables
528  *  \brief Subtract a value from a variable of a link at a given timestamp.
529  *
530  *  Same as #TRACE_link_variable_sub, but let user specify
531  *  the time used to trace it. Users can specify a time that
532  *  is not the simulated clock time as defined by the core
533  *  simulator. This allows a fine-grain control of time
534  *  definition, but should be used with caution since the trace
535  *  can be inconsistent if resource utilization traces are also traced.
536  *
537  *  \param time The timestamp to be used to tag this change of value.
538  *  \param link The name of the link to be considered.
539  *  \param variable The name of the variable to be considered.
540  *  \param value The value to be subtracted from the variable.
541  *
542  *  \see TRACE_link_variable_declare, TRACE_link_variable_set_with_time, TRACE_link_variable_add_with_time
543  */
544 void TRACE_link_variable_sub_with_time (double time, const char *link, const char *variable, double value)
545 {
546   instr_user_variable (time, link, variable, "LINK", value, INSTR_US_SUB, NULL);
547 }
548
549 /* for link variables, but with src and dst used for get_route */
550 /** \ingroup TRACE_user_variables
551  *  \brief Set the value of the variable present in the links connecting source and destination.
552  *
553  *  Same as #TRACE_link_variable_set, but instead of providing the
554  *  name of link to be considered, provide the source and destination
555  *  hosts. All links that are part of the route between source and
556  *  destination will have the variable set to the provided value.
557  *
558  *  \param src The name of the source host for get route.
559  *  \param dst The name of the destination host for get route.
560  *  \param variable The name of the variable to be considered.
561  *  \param value The new value of the variable.
562  *
563  *  \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_add, TRACE_link_srcdst_variable_sub
564  */
565 void TRACE_link_srcdst_variable_set (const char *src, const char *dst, const char *variable, double value)
566 {
567   TRACE_link_srcdst_variable_set_with_time (MSG_get_clock(), src, dst, variable, value);
568 }
569
570 /** \ingroup TRACE_user_variables
571  *  \brief Add a value to the variable present in the links connecting source and destination.
572  *
573  *  Same as #TRACE_link_variable_add, but instead of providing the
574  *  name of link to be considered, provide the source and destination
575  *  hosts. All links that are part of the route between source and
576  *  destination will have the value passed as parameter added to
577  *  the current value of the variable name to be considered.
578  *
579  *  \param src The name of the source host for get route.
580  *  \param dst The name of the destination host for get route.
581  *  \param variable The name of the variable to be considered.
582  *  \param value The value to be added to the variable.
583  *
584  *  \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set, TRACE_link_srcdst_variable_sub
585  */
586 void TRACE_link_srcdst_variable_add (const char *src, const char *dst, const char *variable, double value)
587 {
588   TRACE_link_srcdst_variable_add_with_time (MSG_get_clock(), src, dst, variable, value);
589 }
590
591 /** \ingroup TRACE_user_variables
592  *  \brief Subtract a value from the variable present in the links connecting source and destination.
593  *
594  *  Same as #TRACE_link_variable_sub, but instead of providing the
595  *  name of link to be considered, provide the source and destination
596  *  hosts. All links that are part of the route between source and
597  *  destination will have the value passed as parameter subtracted from
598  *  the current value of the variable name to be considered.
599  *
600  *  \param src The name of the source host for get route.
601  *  \param dst The name of the destination host for get route.
602  *  \param variable The name of the variable to be considered.
603  *  \param value The value to be subtracted from the variable.
604  *
605  *  \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set, TRACE_link_srcdst_variable_add
606  */
607 void TRACE_link_srcdst_variable_sub (const char *src, const char *dst, const char *variable, double value)
608 {
609   TRACE_link_srcdst_variable_sub_with_time (MSG_get_clock(), src, dst, variable, value);
610 }
611
612 /** \ingroup TRACE_user_variables
613  *  \brief Set the value of the variable present in the links connecting source and destination at a given timestamp.
614  *
615  *  Same as #TRACE_link_srcdst_variable_set, but let user specify
616  *  the time used to trace it. Users can specify a time that
617  *  is not the simulated clock time as defined by the core
618  *  simulator. This allows a fine-grain control of time
619  *  definition, but should be used with caution since the trace
620  *  can be inconsistent if resource utilization traces are also traced.
621  *
622  *  \param time The timestamp to be used to tag this change of value.
623  *  \param src The name of the source host for get route.
624  *  \param dst The name of the destination host for get route.
625  *  \param variable The name of the variable to be considered.
626  *  \param value The new value of the variable.
627  *
628  *  \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_add_with_time, TRACE_link_srcdst_variable_sub_with_time
629  */
630 void TRACE_link_srcdst_variable_set_with_time (double time, const char *src, const char *dst, const char *variable, double value)
631 {
632   instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_SET);
633 }
634
635 /** \ingroup TRACE_user_variables
636  *  \brief Add a value to the variable present in the links connecting source and destination at a given timestamp.
637  *
638  *  Same as #TRACE_link_srcdst_variable_add, but let user specify
639  *  the time used to trace it. Users can specify a time that
640  *  is not the simulated clock time as defined by the core
641  *  simulator. This allows a fine-grain control of time
642  *  definition, but should be used with caution since the trace
643  *  can be inconsistent if resource utilization traces are also traced.
644  *
645  *  \param time The timestamp to be used to tag this change of value.
646  *  \param src The name of the source host for get route.
647  *  \param dst The name of the destination host for get route.
648  *  \param variable The name of the variable to be considered.
649  *  \param value The value to be added to the variable.
650  *
651  *  \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set_with_time, TRACE_link_srcdst_variable_sub_with_time
652  */
653 void TRACE_link_srcdst_variable_add_with_time (double time, const char *src, const char *dst, const char *variable, double value)
654 {
655   instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_ADD);
656 }
657
658 /** \ingroup TRACE_user_variables
659  *  \brief Subtract a value from the variable present in the links connecting source and destination at a given timestamp.
660  *
661  *  Same as #TRACE_link_srcdst_variable_sub, but let user specify
662  *  the time used to trace it. Users can specify a time that
663  *  is not the simulated clock time as defined by the core
664  *  simulator. This allows a fine-grain control of time
665  *  definition, but should be used with caution since the trace
666  *  can be inconsistent if resource utilization traces are also traced.
667  *
668  *  \param time The timestamp to be used to tag this change of value.
669  *  \param src The name of the source host for get route.
670  *  \param dst The name of the destination host for get route.
671  *  \param variable The name of the variable to be considered.
672  *  \param value The value to be subtracted from the variable.
673  *
674  *  \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set_with_time, TRACE_link_srcdst_variable_add_with_time
675  */
676 void TRACE_link_srcdst_variable_sub_with_time (double time, const char *src, const char *dst, const char *variable, double value)
677 {
678   instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_SUB);
679 }
680
681 #endif /* HAVE_TRACING */