Logo AND Algorithmique Numérique Distribuée

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