1 /* Copyright (c) 2010. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "simgrid_config.h"
10 #include "instr/instr_private.h"
11 #include "surf/network_private.h"
20 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_api, instr, "API");
22 xbt_dict_t created_categories = NULL;
23 xbt_dict_t declared_marks = NULL;
24 xbt_dict_t user_host_variables = NULL;
25 xbt_dict_t user_link_variables = NULL;
27 /** \ingroup TRACE_category
28 * \brief Declare a new category with a random color.
30 * This function should be used to define a user category. The
31 * category can be used to differentiate the tasks that are created
32 * during the simulation (for example, tasks from server1, server2,
33 * or request tasks, computation tasks, communication tasks). All
34 * resource utilization (host power and link bandwidth) will be
35 * classified according to the task category. Tasks that do not
36 * belong to a category are not traced. The color for the category
37 * that is being declared is random. This function has no effect
38 * if a category with the same name has been already declared.
40 * See \ref tracing_tracing for details on how to trace
41 * the (categorized) resource utilization.
43 * \param category The name of the new tracing category to be created.
45 * \see TRACE_category_with_color, MSG_task_set_category, SD_task_set_category
47 void TRACE_category(const char *category)
49 TRACE_category_with_color (category, NULL);
52 /** \ingroup TRACE_category
53 * \brief Declare a new category with a color.
55 * Same as #TRACE_category, but let user specify a color encoded as a
56 * RGB-like string with three floats from 0 to 1. So, to specify a
57 * red color, pass "1 0 0" as color parameter. A light-gray color
58 * can be specified using "0.7 0.7 0.7" as color. This function has
59 * no effect if a category with the same name has been already declared.
61 * See \ref tracing_tracing for details on how to trace
62 * the (categorized) resource utilization.
64 * \param category The name of the new tracing category to be created.
65 * \param color The color of the category (see \ref tracing_tracing to
66 * know how to correctly specify the color)
68 * \see MSG_task_set_category, SD_task_set_category
70 void TRACE_category_with_color (const char *category, const char *color)
73 if (!TRACE_is_enabled()) return;
75 if (!(TRACE_categorized() && category != NULL)) return;
77 /* if platform is not traced, we can't deal with categories */
78 if (!TRACE_needs_platform()) return;
80 //check if category is already created
81 char *created = xbt_dict_get_or_null(created_categories, category);
83 xbt_dict_set (created_categories, category, xbt_strdup("1"), NULL);
86 char final_color[INSTR_DEFAULT_STR_SIZE];
88 //generate a random color
89 double red = drand48();
90 double green = drand48();
91 double blue = drand48();
92 snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%f %f %f", red, green, blue);
94 snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
97 XBT_DEBUG("CAT,declare %s, %s", category, final_color);
99 //define the type of this category on top of hosts and links
100 instr_new_variable_type (category, final_color);
104 /** \ingroup TRACE_category
105 * \brief Get declared categories
107 * This function should be used to get categories that were already
108 * declared with #TRACE_category or with #TRACE_category_with_color.
110 * See \ref tracing_tracing for details on how to trace
111 * the (categorized) resource utilization.
113 * \return A dynar with the declared categories, must be freed with xbt_dynar_free.
115 * \see MSG_task_set_category, SD_task_set_category
117 xbt_dynar_t TRACE_get_categories (void)
119 if (!TRACE_is_enabled()) return NULL;
120 if (!TRACE_categorized()) return NULL;
122 xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
123 xbt_dict_cursor_t cursor = NULL;
125 xbt_dict_foreach(created_categories, cursor, name, value) {
126 xbt_dynar_push_as (ret, char*, xbt_strdup(name));
131 /** \ingroup TRACE_mark
132 * \brief Declare a new type for tracing mark.
134 * This function declares a new Paje event
135 * type in the trace file that can be used by
136 * simulators to declare application-level
137 * marks. This function is independent of
138 * which API is used in SimGrid.
140 * \param mark_type The name of the new type.
144 void TRACE_declare_mark(const char *mark_type)
147 if (!TRACE_is_enabled()) return;
149 if (!mark_type) return;
151 //check if mark_type is already declared
152 char *created = xbt_dict_get_or_null(declared_marks, mark_type);
154 xbt_dict_set (declared_marks, mark_type, xbt_strdup("1"), NULL);
156 XBT_DEBUG("MARK,declare %s", mark_type);
157 PJ_type_event_new(mark_type, NULL, PJ_type_get_root());
161 * \ingroup TRACE_mark
162 * \brief Create a new instance of a tracing mark type.
164 * This function creates a mark in the trace file. The
165 * first parameter had to be previously declared using
166 * #TRACE_declare_mark, the second is the identifier
167 * for this mark instance. We recommend that the
168 * mark_value is a unique value for the whole simulation.
169 * Nevertheless, this is not a strong requirement: the
170 * trace will be valid even if there are multiple mark
171 * identifiers for the same trace.
173 * \param mark_type The name of the type for which the new instance will belong.
174 * \param mark_value The name of the new instance mark.
176 * \see TRACE_declare_mark
178 void TRACE_mark(const char *mark_type, const char *mark_value)
181 if (!TRACE_is_enabled()) return;
183 if (!mark_type || !mark_value) return;
185 //check if mark_type is already declared
186 char *created = xbt_dict_get_or_null(declared_marks, mark_type);
189 XBT_DEBUG("MARK %s %s", mark_type, mark_value);
190 type_t type = PJ_type_get (mark_type, PJ_type_get_root());
192 THROWF (tracing_error, 1, "mark_type with name (%s) not declared before", mark_type);
194 val_t value = PJ_value_get (mark_value, type);
196 value = PJ_value_new (mark_value, NULL, type);
198 new_pajeNewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
201 /** \ingroup TRACE_mark
202 * \brief Get declared marks
204 * This function should be used to get marks that were already
205 * declared with #TRACE_declare_mark.
207 * \return A dynar with the declared marks, must be freed with xbt_dynar_free.
210 xbt_dynar_t TRACE_get_marks (void)
212 if (!TRACE_is_enabled()) return NULL;
214 xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
215 xbt_dict_cursor_t cursor = NULL;
217 xbt_dict_foreach(declared_marks, cursor, name, value) {
218 xbt_dynar_push_as (ret, char*, xbt_strdup(name));
223 static void instr_user_variable(double time,
224 const char *resource,
225 const char *variable,
226 const char *father_type,
228 InstrUserVariable what,
233 if (!TRACE_is_enabled()) return;
235 /* if platform is not traced, we don't allow user variables */
236 if (!TRACE_needs_platform()) return;
238 //check if variable is already declared
239 char *created = xbt_dict_get_or_null(declared_marks, variable);
240 if (what == INSTR_US_DECLARE){
245 xbt_dict_set (filter, variable, xbt_strdup("1"), NULL);
249 //not declared, ignore
255 snprintf(valuestr, 100, "%g", value);
258 case INSTR_US_DECLARE:
259 instr_new_user_variable_type (father_type, variable, color);
263 container_t container = PJ_container_get(resource);
264 type_t type = PJ_type_get (variable, container->type);
265 new_pajeSetVariable(time, container, type, value);
270 container_t container = PJ_container_get(resource);
271 type_t type = PJ_type_get (variable, container->type);
272 new_pajeAddVariable(time, container, type, value);
277 container_t container = PJ_container_get(resource);
278 type_t type = PJ_type_get (variable, container->type);
279 new_pajeSubVariable(time, container, type, value);
283 //TODO: launch exception
288 static void instr_user_srcdst_variable(double time,
291 const char *variable,
292 const char *father_type,
294 InstrUserVariable what)
296 xbt_dynar_t route=NULL;
297 network_element_t src_elm = xbt_lib_get_or_null(host_lib,src,ROUTING_HOST_LEVEL);
298 if(!src_elm) src_elm = xbt_lib_get_or_null(as_router_lib,src,ROUTING_ASR_LEVEL);
299 if(!src_elm) xbt_die("Element '%s' not found!",src);
301 network_element_t dst_elm = xbt_lib_get_or_null(host_lib,dst,ROUTING_HOST_LEVEL);
302 if(!dst_elm) dst_elm = xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
303 if(!dst_elm) xbt_die("Element '%s' not found!",dst);
305 routing_get_route_and_latency (src_elm, dst_elm, &route,NULL);
308 xbt_dynar_foreach (route, i, link) {
309 char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
310 instr_user_variable (time, link_name, variable, father_type, value, what, NULL, user_link_variables);
314 /** \ingroup TRACE_API
315 * \brief Creates a file with the topology of the platform file used for the simulator.
317 * The graph topology will have the following properties: all hosts, links and routers
318 * of the platform file are mapped to graph nodes; routes are mapped to edges.
319 * The platform's AS are not represented in the output.
321 * \param filename The name of the file that will hold the graph.
323 * \return 1 of successful, 0 otherwise.
325 int TRACE_platform_graph_export_graphviz (const char *filename)
327 /* returns 1 if successful, 0 otherwise */
328 if (!TRACE_is_enabled()) return 0;
329 xbt_graph_t g = instr_routing_platform_graph();
330 if (g == NULL) return 0;
331 instr_routing_platform_graph_export_graphviz (g, filename);
332 xbt_graph_free_graph (g, xbt_free, xbt_free, NULL);
337 * Derived functions that use instr_user_variable and TRACE_user_srcdst_variable.
338 * They were previously defined as pre-processors directives, but were transformed
339 * into functions so the user can track them using gdb.
342 /* for host variables */
343 /** \ingroup TRACE_user_variables
344 * \brief Declare a new user variable associated to hosts.
346 * Declare a user variable that will be associated to hosts.
347 * A user host variable can be used to trace user variables
348 * such as the number of tasks in a server, the number of
349 * clients in an application (for hosts), and so on. The color
350 * associated to this new variable will be random.
352 * \param variable The name of the new variable to be declared.
354 * \see TRACE_host_variable_declare_with_color
356 void TRACE_host_variable_declare (const char *variable)
358 instr_user_variable(0, NULL, variable, "HOST", 0, INSTR_US_DECLARE, NULL, user_host_variables);
361 /** \ingroup TRACE_user_variables
362 * \brief Declare a new user variable associated to hosts with a color.
364 * Same as #TRACE_host_variable_declare, but associated a color
365 * to the newly created user host variable. The color needs to be
366 * a string with three numbers separated by spaces in the range [0,1].
367 * A light-gray color can be specified using "0.7 0.7 0.7" as color.
369 * \param variable The name of the new variable to be declared.
370 * \param color The color for the new variable.
373 void TRACE_host_variable_declare_with_color (const char *variable, const char *color)
375 instr_user_variable(0, NULL, variable, "HOST", 0, INSTR_US_DECLARE, color, user_host_variables);
378 /** \ingroup TRACE_user_variables
379 * \brief Set the value of a variable of a host.
381 * \param host The name of the host to be considered.
382 * \param variable The name of the variable to be considered.
383 * \param value The new value of the variable.
385 * \see TRACE_host_variable_declare, TRACE_host_variable_add, TRACE_host_variable_sub
387 void TRACE_host_variable_set (const char *host, const char *variable, double value)
389 TRACE_host_variable_set_with_time (MSG_get_clock(), host, variable, value);
392 /** \ingroup TRACE_user_variables
393 * \brief Add a value to a variable of a host.
395 * \param host The name of the host to be considered.
396 * \param variable The name of the variable to be considered.
397 * \param value The value to be added to the variable.
399 * \see TRACE_host_variable_declare, TRACE_host_variable_set, TRACE_host_variable_sub
401 void TRACE_host_variable_add (const char *host, const char *variable, double value)
403 TRACE_host_variable_add_with_time (MSG_get_clock(), host, variable, value);
406 /** \ingroup TRACE_user_variables
407 * \brief Subtract a value from a variable of a host.
409 * \param host The name of the host to be considered.
410 * \param variable The name of the variable to be considered.
411 * \param value The value to be subtracted from the variable.
413 * \see TRACE_host_variable_declare, TRACE_host_variable_set, TRACE_host_variable_add
415 void TRACE_host_variable_sub (const char *host, const char *variable, double value)
417 TRACE_host_variable_sub_with_time (MSG_get_clock(), host, variable, value);
420 /** \ingroup TRACE_user_variables
421 * \brief Set the value of a variable of a host at a given timestamp.
423 * Same as #TRACE_host_variable_set, but let user specify
424 * the time used to trace it. Users can specify a time that
425 * is not the simulated clock time as defined by the core
426 * simulator. This allows a fine-grain control of time
427 * definition, but should be used with caution since the trace
428 * can be inconsistent if resource utilization traces are also traced.
430 * \param time The timestamp to be used to tag this change of value.
431 * \param host The name of the host to be considered.
432 * \param variable The name of the variable to be considered.
433 * \param value The new value of the variable.
435 * \see TRACE_host_variable_declare, TRACE_host_variable_add_with_time, TRACE_host_variable_sub_with_time
437 void TRACE_host_variable_set_with_time (double time, const char *host, const char *variable, double value)
439 instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SET, NULL, user_host_variables);
442 /** \ingroup TRACE_user_variables
443 * \brief Add a value to a variable of a host at a given timestamp.
445 * Same as #TRACE_host_variable_add, but let user specify
446 * the time used to trace it. Users can specify a time that
447 * is not the simulated clock time as defined by the core
448 * simulator. This allows a fine-grain control of time
449 * definition, but should be used with caution since the trace
450 * can be inconsistent if resource utilization traces are also traced.
452 * \param time The timestamp to be used to tag this change of value.
453 * \param host The name of the host to be considered.
454 * \param variable The name of the variable to be considered.
455 * \param value The value to be added to the variable.
457 * \see TRACE_host_variable_declare, TRACE_host_variable_set_with_time, TRACE_host_variable_sub_with_time
459 void TRACE_host_variable_add_with_time (double time, const char *host, const char *variable, double value)
461 instr_user_variable(time, host, variable, "HOST", value, INSTR_US_ADD, NULL, user_host_variables);
464 /** \ingroup TRACE_user_variables
465 * \brief Subtract a value from a variable of a host at a given timestamp.
467 * Same as #TRACE_host_variable_sub, but let user specify
468 * the time used to trace it. Users can specify a time that
469 * is not the simulated clock time as defined by the core
470 * simulator. This allows a fine-grain control of time
471 * definition, but should be used with caution since the trace
472 * can be inconsistent if resource utilization traces are also traced.
474 * \param time The timestamp to be used to tag this change of value.
475 * \param host The name of the host to be considered.
476 * \param variable The name of the variable to be considered.
477 * \param value The value to be subtracted from the variable.
479 * \see TRACE_host_variable_declare, TRACE_host_variable_set_with_time, TRACE_host_variable_add_with_time
481 void TRACE_host_variable_sub_with_time (double time, const char *host, const char *variable, double value)
483 instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SUB, NULL, user_host_variables);
486 static xbt_dynar_t instr_get_user_variables (xbt_dict_t filter)
488 if (!TRACE_is_enabled()) return NULL;
489 if (!TRACE_needs_platform()) return NULL;
491 xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
492 xbt_dict_cursor_t cursor = NULL;
494 xbt_dict_foreach(filter, cursor, name, value) {
495 xbt_dynar_push_as (ret, char*, xbt_strdup(name));
500 /** \ingroup TRACE_user_variables
501 * \brief Get declared user host variables
503 * This function should be used to get host variables that were already
504 * declared with #TRACE_host_variable_declare or with #TRACE_host_variable_declare_with_color.
506 * \return A dynar with the declared host variables, must be freed with xbt_dynar_free.
508 xbt_dynar_t TRACE_get_host_variables (void)
510 return instr_get_user_variables (user_host_variables);
513 /* for link variables */
514 /** \ingroup TRACE_user_variables
515 * \brief Declare a new user variable associated to links.
517 * Declare a user variable that will be associated to links.
518 * A user link variable can be used, for example, to trace
519 * user variables such as the number of messages being
520 * transferred through network links. The color
521 * associated to this new variable will be random.
523 * \param variable The name of the new variable to be declared.
525 * \see TRACE_link_variable_declare_with_color
527 void TRACE_link_variable_declare (const char *variable)
529 instr_user_variable (0, NULL, variable, "LINK", 0, INSTR_US_DECLARE, NULL, user_link_variables);
532 /** \ingroup TRACE_user_variables
533 * \brief Declare a new user variable associated to links with a color.
535 * Same as #TRACE_link_variable_declare, but associated a color
536 * to the newly created user link variable. The color needs to be
537 * a string with three numbers separated by spaces in the range [0,1].
538 * A light-gray color can be specified using "0.7 0.7 0.7" as color.
540 * \param variable The name of the new variable to be declared.
541 * \param color The color for the new variable.
544 void TRACE_link_variable_declare_with_color (const char *variable, const char *color)
546 instr_user_variable (0, NULL, variable, "LINK", 0, INSTR_US_DECLARE, color, user_link_variables);
549 /** \ingroup TRACE_user_variables
550 * \brief Set the value of a variable of a link.
552 * \param link The name of the link to be considered.
553 * \param variable The name of the variable to be considered.
554 * \param value The new value of the variable.
556 * \see TRACE_link_variable_declare, TRACE_link_variable_add, TRACE_link_variable_sub
558 void TRACE_link_variable_set (const char *link, const char *variable, double value)
560 TRACE_link_variable_set_with_time (MSG_get_clock(), link, variable, value);
563 /** \ingroup TRACE_user_variables
564 * \brief Add a value to a variable of a link.
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 added to the variable.
570 * \see TRACE_link_variable_declare, TRACE_link_variable_set, TRACE_link_variable_sub
572 void TRACE_link_variable_add (const char *link, const char *variable, double value)
574 TRACE_link_variable_add_with_time (MSG_get_clock(), link, variable, value);
577 /** \ingroup TRACE_user_variables
578 * \brief Subtract a value from a variable of a link.
580 * \param link The name of the link to be considered.
581 * \param variable The name of the variable to be considered.
582 * \param value The value to be subtracted from the variable.
584 * \see TRACE_link_variable_declare, TRACE_link_variable_set, TRACE_link_variable_add
586 void TRACE_link_variable_sub (const char *link, const char *variable, double value)
588 TRACE_link_variable_sub_with_time (MSG_get_clock(), link, variable, value);
591 /** \ingroup TRACE_user_variables
592 * \brief Set the value of a variable of a link at a given timestamp.
594 * Same as #TRACE_link_variable_set, but let user specify
595 * the time used to trace it. Users can specify a time that
596 * is not the simulated clock time as defined by the core
597 * simulator. This allows a fine-grain control of time
598 * definition, but should be used with caution since the trace
599 * can be inconsistent if resource utilization traces are also traced.
601 * \param time The timestamp to be used to tag this change of value.
602 * \param link The name of the link to be considered.
603 * \param variable The name of the variable to be considered.
604 * \param value The new value of the variable.
606 * \see TRACE_link_variable_declare, TRACE_link_variable_add_with_time, TRACE_link_variable_sub_with_time
608 void TRACE_link_variable_set_with_time (double time, const char *link, const char *variable, double value)
610 instr_user_variable (time, link, variable, "LINK", value, INSTR_US_SET, NULL, user_link_variables);
613 /** \ingroup TRACE_user_variables
614 * \brief Add a value to a variable of a link at a given timestamp.
616 * Same as #TRACE_link_variable_add, but let user specify
617 * the time used to trace it. Users can specify a time that
618 * is not the simulated clock time as defined by the core
619 * simulator. This allows a fine-grain control of time
620 * definition, but should be used with caution since the trace
621 * can be inconsistent if resource utilization traces are also traced.
623 * \param time The timestamp to be used to tag this change of value.
624 * \param link The name of the link to be considered.
625 * \param variable The name of the variable to be considered.
626 * \param value The value to be added to the variable.
628 * \see TRACE_link_variable_declare, TRACE_link_variable_set_with_time, TRACE_link_variable_sub_with_time
630 void TRACE_link_variable_add_with_time (double time, const char *link, const char *variable, double value)
632 instr_user_variable (time, link, variable, "LINK", value, INSTR_US_ADD, NULL, user_link_variables);
635 /** \ingroup TRACE_user_variables
636 * \brief Subtract a value from a variable of a link at a given timestamp.
638 * Same as #TRACE_link_variable_sub, 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.
645 * \param time The timestamp to be used to tag this change of value.
646 * \param link The name of the link to be considered.
647 * \param variable The name of the variable to be considered.
648 * \param value The value to be subtracted from the variable.
650 * \see TRACE_link_variable_declare, TRACE_link_variable_set_with_time, TRACE_link_variable_add_with_time
652 void TRACE_link_variable_sub_with_time (double time, const char *link, const char *variable, double value)
654 instr_user_variable (time, link, variable, "LINK", value, INSTR_US_SUB, NULL, user_link_variables);
657 /* for link variables, but with src and dst used for get_route */
658 /** \ingroup TRACE_user_variables
659 * \brief Set the value of the variable present in the links connecting source and destination.
661 * Same as #TRACE_link_variable_set, but instead of providing the
662 * name of link to be considered, provide the source and destination
663 * hosts. All links that are part of the route between source and
664 * destination will have the variable set to the provided value.
666 * \param src The name of the source host for get route.
667 * \param dst The name of the destination host for get route.
668 * \param variable The name of the variable to be considered.
669 * \param value The new value of the variable.
671 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_add, TRACE_link_srcdst_variable_sub
673 void TRACE_link_srcdst_variable_set (const char *src, const char *dst, const char *variable, double value)
675 TRACE_link_srcdst_variable_set_with_time (MSG_get_clock(), src, dst, variable, value);
678 /** \ingroup TRACE_user_variables
679 * \brief Add a value to the variable present in the links connecting source and destination.
681 * Same as #TRACE_link_variable_add, but instead of providing the
682 * name of link to be considered, provide the source and destination
683 * hosts. All links that are part of the route between source and
684 * destination will have the value passed as parameter added to
685 * the current value of the variable name to be considered.
687 * \param src The name of the source host for get route.
688 * \param dst The name of the destination host for get route.
689 * \param variable The name of the variable to be considered.
690 * \param value The value to be added to the variable.
692 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set, TRACE_link_srcdst_variable_sub
694 void TRACE_link_srcdst_variable_add (const char *src, const char *dst, const char *variable, double value)
696 TRACE_link_srcdst_variable_add_with_time (MSG_get_clock(), src, dst, variable, value);
699 /** \ingroup TRACE_user_variables
700 * \brief Subtract a value from the variable present in the links connecting source and destination.
702 * Same as #TRACE_link_variable_sub, but instead of providing the
703 * name of link to be considered, provide the source and destination
704 * hosts. All links that are part of the route between source and
705 * destination will have the value passed as parameter subtracted from
706 * the current value of the variable name to be considered.
708 * \param src The name of the source host for get route.
709 * \param dst The name of the destination host for get route.
710 * \param variable The name of the variable to be considered.
711 * \param value The value to be subtracted from the variable.
713 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set, TRACE_link_srcdst_variable_add
715 void TRACE_link_srcdst_variable_sub (const char *src, const char *dst, const char *variable, double value)
717 TRACE_link_srcdst_variable_sub_with_time (MSG_get_clock(), src, dst, variable, value);
720 /** \ingroup TRACE_user_variables
721 * \brief Set the value of the variable present in the links connecting source and destination at a given timestamp.
723 * Same as #TRACE_link_srcdst_variable_set, but let user specify
724 * the time used to trace it. Users can specify a time that
725 * is not the simulated clock time as defined by the core
726 * simulator. This allows a fine-grain control of time
727 * definition, but should be used with caution since the trace
728 * can be inconsistent if resource utilization traces are also traced.
730 * \param time The timestamp to be used to tag this change of value.
731 * \param src The name of the source host for get route.
732 * \param dst The name of the destination host for get route.
733 * \param variable The name of the variable to be considered.
734 * \param value The new value of the variable.
736 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_add_with_time, TRACE_link_srcdst_variable_sub_with_time
738 void TRACE_link_srcdst_variable_set_with_time (double time, const char *src, const char *dst, const char *variable, double value)
740 instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_SET);
743 /** \ingroup TRACE_user_variables
744 * \brief Add a value to the variable present in the links connecting source and destination at a given timestamp.
746 * Same as #TRACE_link_srcdst_variable_add, but let user specify
747 * the time used to trace it. Users can specify a time that
748 * is not the simulated clock time as defined by the core
749 * simulator. This allows a fine-grain control of time
750 * definition, but should be used with caution since the trace
751 * can be inconsistent if resource utilization traces are also traced.
753 * \param time The timestamp to be used to tag this change of value.
754 * \param src The name of the source host for get route.
755 * \param dst The name of the destination host for get route.
756 * \param variable The name of the variable to be considered.
757 * \param value The value to be added to the variable.
759 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set_with_time, TRACE_link_srcdst_variable_sub_with_time
761 void TRACE_link_srcdst_variable_add_with_time (double time, const char *src, const char *dst, const char *variable, double value)
763 instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_ADD);
766 /** \ingroup TRACE_user_variables
767 * \brief Subtract a value from the variable present in the links connecting source and destination at a given timestamp.
769 * Same as #TRACE_link_srcdst_variable_sub, but let user specify
770 * the time used to trace it. Users can specify a time that
771 * is not the simulated clock time as defined by the core
772 * simulator. This allows a fine-grain control of time
773 * definition, but should be used with caution since the trace
774 * can be inconsistent if resource utilization traces are also traced.
776 * \param time The timestamp to be used to tag this change of value.
777 * \param src The name of the source host for get route.
778 * \param dst The name of the destination host for get route.
779 * \param variable The name of the variable to be considered.
780 * \param value The value to be subtracted from the variable.
782 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set_with_time, TRACE_link_srcdst_variable_add_with_time
784 void TRACE_link_srcdst_variable_sub_with_time (double time, const char *src, const char *dst, const char *variable, double value)
786 instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_SUB);
789 /** \ingroup TRACE_user_variables
790 * \brief Get declared user link variables
792 * This function should be used to get link variables that were already
793 * declared with #TRACE_link_variable_declare or with #TRACE_link_variable_declare_with_color.
795 * \return A dynar with the declared link variables, must be freed with xbt_dynar_free.
797 xbt_dynar_t TRACE_get_link_variables (void)
799 return instr_get_user_variables (user_link_variables);
802 #endif /* HAVE_TRACING */