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;
26 extern xbt_dict_t trivaNodeTypes;
27 extern xbt_dict_t trivaEdgeTypes;
29 static xbt_dynar_t instr_dict_to_dynar (xbt_dict_t filter)
31 if (!TRACE_is_enabled()) return NULL;
32 if (!TRACE_needs_platform()) return NULL;
34 xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
35 xbt_dict_cursor_t cursor = NULL;
37 xbt_dict_foreach(filter, cursor, name, value) {
38 xbt_dynar_push_as (ret, char*, xbt_strdup(name));
43 /** \ingroup TRACE_category
44 * \brief Declare a new category with a random color.
46 * This function should be used to define a user category. The
47 * category can be used to differentiate the tasks that are created
48 * during the simulation (for example, tasks from server1, server2,
49 * or request tasks, computation tasks, communication tasks). All
50 * resource utilization (host power and link bandwidth) will be
51 * classified according to the task category. Tasks that do not
52 * belong to a category are not traced. The color for the category
53 * that is being declared is random. This function has no effect
54 * if a category with the same name has been already declared.
56 * See \ref tracing_tracing for details on how to trace
57 * the (categorized) resource utilization.
59 * \param category The name of the new tracing category to be created.
61 * \see TRACE_category_with_color, MSG_task_set_category, SD_task_set_category
63 void TRACE_category(const char *category)
65 TRACE_category_with_color (category, NULL);
68 /** \ingroup TRACE_category
69 * \brief Declare a new category with a color.
71 * Same as #TRACE_category, but let user specify a color encoded as a
72 * RGB-like string with three floats from 0 to 1. So, to specify a
73 * red color, pass "1 0 0" as color parameter. A light-gray color
74 * can be specified using "0.7 0.7 0.7" as color. This function has
75 * no effect if a category with the same name has been already declared.
77 * See \ref tracing_tracing for details on how to trace
78 * the (categorized) resource utilization.
80 * \param category The name of the new tracing category to be created.
81 * \param color The color of the category (see \ref tracing_tracing to
82 * know how to correctly specify the color)
84 * \see MSG_task_set_category, SD_task_set_category
86 void TRACE_category_with_color (const char *category, const char *color)
89 if (!TRACE_is_enabled()) return;
91 if (!(TRACE_categorized() && category != NULL)) return;
93 /* if platform is not traced, we can't deal with categories */
94 if (!TRACE_needs_platform()) return;
96 //check if category is already created
97 char *created = xbt_dict_get_or_null(created_categories, category);
99 xbt_dict_set (created_categories, category, xbt_strdup("1"), NULL);
102 char final_color[INSTR_DEFAULT_STR_SIZE];
104 //generate a random color
105 double red = drand48();
106 double green = drand48();
107 double blue = drand48();
108 snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%f %f %f", red, green, blue);
110 snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
113 XBT_DEBUG("CAT,declare %s, %s", category, final_color);
115 //define the type of this category on top of hosts and links
116 instr_new_variable_type (category, final_color);
120 /** \ingroup TRACE_category
121 * \brief Get declared categories
123 * This function should be used to get categories that were already
124 * declared with #TRACE_category or with #TRACE_category_with_color.
126 * See \ref tracing_tracing for details on how to trace
127 * the (categorized) resource utilization.
129 * \return A dynar with the declared categories, must be freed with xbt_dynar_free.
131 * \see MSG_task_set_category, SD_task_set_category
133 xbt_dynar_t TRACE_get_categories (void)
135 if (!TRACE_is_enabled()) return NULL;
136 if (!TRACE_categorized()) return NULL;
138 return instr_dict_to_dynar (created_categories);
141 /** \ingroup TRACE_mark
142 * \brief Declare a new type for tracing mark.
144 * This function declares a new Paje event
145 * type in the trace file that can be used by
146 * simulators to declare application-level
147 * marks. This function is independent of
148 * which API is used in SimGrid.
150 * \param mark_type The name of the new type.
154 void TRACE_declare_mark(const char *mark_type)
157 if (!TRACE_is_enabled()) return;
159 if (!mark_type) return;
161 //check if mark_type is already declared
162 char *created = xbt_dict_get_or_null(declared_marks, mark_type);
164 xbt_dict_set (declared_marks, mark_type, xbt_strdup("1"), NULL);
166 XBT_DEBUG("MARK,declare %s", mark_type);
167 PJ_type_event_new(mark_type, NULL, PJ_type_get_root());
171 * \ingroup TRACE_mark
172 * \brief Create a new instance of a tracing mark type.
174 * This function creates a mark in the trace file. The
175 * first parameter had to be previously declared using
176 * #TRACE_declare_mark, the second is the identifier
177 * for this mark instance. We recommend that the
178 * mark_value is a unique value for the whole simulation.
179 * Nevertheless, this is not a strong requirement: the
180 * trace will be valid even if there are multiple mark
181 * identifiers for the same trace.
183 * \param mark_type The name of the type for which the new instance will belong.
184 * \param mark_value The name of the new instance mark.
186 * \see TRACE_declare_mark
188 void TRACE_mark(const char *mark_type, const char *mark_value)
191 if (!TRACE_is_enabled()) return;
193 if (!mark_type || !mark_value) return;
195 //check if mark_type is already declared
196 char *created = xbt_dict_get_or_null(declared_marks, mark_type);
199 XBT_DEBUG("MARK %s %s", mark_type, mark_value);
200 type_t type = PJ_type_get (mark_type, PJ_type_get_root());
202 THROWF (tracing_error, 1, "mark_type with name (%s) not declared before", mark_type);
204 val_t value = PJ_value_get (mark_value, type);
206 value = PJ_value_new (mark_value, NULL, type);
208 new_pajeNewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
211 /** \ingroup TRACE_mark
212 * \brief Get declared marks
214 * This function should be used to get marks that were already
215 * declared with #TRACE_declare_mark.
217 * \return A dynar with the declared marks, must be freed with xbt_dynar_free.
220 xbt_dynar_t TRACE_get_marks (void)
222 if (!TRACE_is_enabled()) return NULL;
224 return instr_dict_to_dynar (declared_marks);
227 static void instr_user_variable(double time,
228 const char *resource,
229 const char *variable,
230 const char *father_type,
232 InstrUserVariable what,
237 if (!TRACE_is_enabled()) return;
239 /* if platform is not traced, we don't allow user variables */
240 if (!TRACE_needs_platform()) return;
242 //check if variable is already declared
243 char *created = xbt_dict_get_or_null(filter, variable);
244 if (what == INSTR_US_DECLARE){
249 xbt_dict_set (filter, variable, xbt_strdup("1"), NULL);
253 //not declared, ignore
259 snprintf(valuestr, 100, "%g", value);
262 case INSTR_US_DECLARE:
263 instr_new_user_variable_type (father_type, variable, color);
267 container_t container = PJ_container_get(resource);
268 type_t type = PJ_type_get (variable, container->type);
269 new_pajeSetVariable(time, container, type, value);
274 container_t container = PJ_container_get(resource);
275 type_t type = PJ_type_get (variable, container->type);
276 new_pajeAddVariable(time, container, type, value);
281 container_t container = PJ_container_get(resource);
282 type_t type = PJ_type_get (variable, container->type);
283 new_pajeSubVariable(time, container, type, value);
287 //TODO: launch exception
292 static void instr_user_srcdst_variable(double time,
295 const char *variable,
296 const char *father_type,
298 InstrUserVariable what)
300 xbt_dynar_t route=NULL;
301 network_element_t src_elm = xbt_lib_get_or_null(host_lib,src,ROUTING_HOST_LEVEL);
302 if(!src_elm) src_elm = xbt_lib_get_or_null(as_router_lib,src,ROUTING_ASR_LEVEL);
303 if(!src_elm) xbt_die("Element '%s' not found!",src);
305 network_element_t dst_elm = xbt_lib_get_or_null(host_lib,dst,ROUTING_HOST_LEVEL);
306 if(!dst_elm) dst_elm = xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL);
307 if(!dst_elm) xbt_die("Element '%s' not found!",dst);
309 routing_get_route_and_latency (src_elm, dst_elm, &route,NULL);
312 xbt_dynar_foreach (route, i, link) {
313 char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
314 instr_user_variable (time, link_name, variable, father_type, value, what, NULL, user_link_variables);
318 /** \ingroup TRACE_API
319 * \brief Creates a file with the topology of the platform file used for the simulator.
321 * The graph topology will have the following properties: all hosts, links and routers
322 * of the platform file are mapped to graph nodes; routes are mapped to edges.
323 * The platform's AS are not represented in the output.
325 * \param filename The name of the file that will hold the graph.
327 * \return 1 of successful, 0 otherwise.
329 int TRACE_platform_graph_export_graphviz (const char *filename)
331 /* returns 1 if successful, 0 otherwise */
332 if (!TRACE_is_enabled()) return 0;
333 xbt_graph_t g = instr_routing_platform_graph();
334 if (g == NULL) return 0;
335 instr_routing_platform_graph_export_graphviz (g, filename);
336 xbt_graph_free_graph (g, xbt_free, xbt_free, NULL);
341 * Derived functions that use instr_user_variable and TRACE_user_srcdst_variable.
342 * They were previously defined as pre-processors directives, but were transformed
343 * into functions so the user can track them using gdb.
346 /* for host variables */
347 /** \ingroup TRACE_user_variables
348 * \brief Declare a new user variable associated to hosts.
350 * Declare a user variable that will be associated to hosts.
351 * A user host variable can be used to trace user variables
352 * such as the number of tasks in a server, the number of
353 * clients in an application (for hosts), and so on. The color
354 * associated to this new variable will be random.
356 * \param variable The name of the new variable to be declared.
358 * \see TRACE_host_variable_declare_with_color
360 void TRACE_host_variable_declare (const char *variable)
362 instr_user_variable(0, NULL, variable, "HOST", 0, INSTR_US_DECLARE, NULL, user_host_variables);
365 /** \ingroup TRACE_user_variables
366 * \brief Declare a new user variable associated to hosts with a color.
368 * Same as #TRACE_host_variable_declare, but associated a color
369 * to the newly created user host variable. The color needs to be
370 * a string with three numbers separated by spaces in the range [0,1].
371 * A light-gray color can be specified using "0.7 0.7 0.7" as color.
373 * \param variable The name of the new variable to be declared.
374 * \param color The color for the new variable.
377 void TRACE_host_variable_declare_with_color (const char *variable, const char *color)
379 instr_user_variable(0, NULL, variable, "HOST", 0, INSTR_US_DECLARE, color, user_host_variables);
382 /** \ingroup TRACE_user_variables
383 * \brief Set the value of a variable of a host.
385 * \param host The name of the host to be considered.
386 * \param variable The name of the variable to be considered.
387 * \param value The new value of the variable.
389 * \see TRACE_host_variable_declare, TRACE_host_variable_add, TRACE_host_variable_sub
391 void TRACE_host_variable_set (const char *host, const char *variable, double value)
393 TRACE_host_variable_set_with_time (MSG_get_clock(), host, variable, value);
396 /** \ingroup TRACE_user_variables
397 * \brief Add a value to a variable of a host.
399 * \param host The name of the host to be considered.
400 * \param variable The name of the variable to be considered.
401 * \param value The value to be added to the variable.
403 * \see TRACE_host_variable_declare, TRACE_host_variable_set, TRACE_host_variable_sub
405 void TRACE_host_variable_add (const char *host, const char *variable, double value)
407 TRACE_host_variable_add_with_time (MSG_get_clock(), host, variable, value);
410 /** \ingroup TRACE_user_variables
411 * \brief Subtract a value from a variable of a host.
413 * \param host The name of the host to be considered.
414 * \param variable The name of the variable to be considered.
415 * \param value The value to be subtracted from the variable.
417 * \see TRACE_host_variable_declare, TRACE_host_variable_set, TRACE_host_variable_add
419 void TRACE_host_variable_sub (const char *host, const char *variable, double value)
421 TRACE_host_variable_sub_with_time (MSG_get_clock(), host, variable, value);
424 /** \ingroup TRACE_user_variables
425 * \brief Set the value of a variable of a host at a given timestamp.
427 * Same as #TRACE_host_variable_set, but let user specify
428 * the time used to trace it. Users can specify a time that
429 * is not the simulated clock time as defined by the core
430 * simulator. This allows a fine-grain control of time
431 * definition, but should be used with caution since the trace
432 * can be inconsistent if resource utilization traces are also traced.
434 * \param time The timestamp to be used to tag this change of value.
435 * \param host The name of the host to be considered.
436 * \param variable The name of the variable to be considered.
437 * \param value The new value of the variable.
439 * \see TRACE_host_variable_declare, TRACE_host_variable_add_with_time, TRACE_host_variable_sub_with_time
441 void TRACE_host_variable_set_with_time (double time, const char *host, const char *variable, double value)
443 instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SET, NULL, user_host_variables);
446 /** \ingroup TRACE_user_variables
447 * \brief Add a value to a variable of a host at a given timestamp.
449 * Same as #TRACE_host_variable_add, but let user specify
450 * the time used to trace it. Users can specify a time that
451 * is not the simulated clock time as defined by the core
452 * simulator. This allows a fine-grain control of time
453 * definition, but should be used with caution since the trace
454 * can be inconsistent if resource utilization traces are also traced.
456 * \param time The timestamp to be used to tag this change of value.
457 * \param host The name of the host to be considered.
458 * \param variable The name of the variable to be considered.
459 * \param value The value to be added to the variable.
461 * \see TRACE_host_variable_declare, TRACE_host_variable_set_with_time, TRACE_host_variable_sub_with_time
463 void TRACE_host_variable_add_with_time (double time, const char *host, const char *variable, double value)
465 instr_user_variable(time, host, variable, "HOST", value, INSTR_US_ADD, NULL, user_host_variables);
468 /** \ingroup TRACE_user_variables
469 * \brief Subtract a value from a variable of a host at a given timestamp.
471 * Same as #TRACE_host_variable_sub, but let user specify
472 * the time used to trace it. Users can specify a time that
473 * is not the simulated clock time as defined by the core
474 * simulator. This allows a fine-grain control of time
475 * definition, but should be used with caution since the trace
476 * can be inconsistent if resource utilization traces are also traced.
478 * \param time The timestamp to be used to tag this change of value.
479 * \param host The name of the host to be considered.
480 * \param variable The name of the variable to be considered.
481 * \param value The value to be subtracted from the variable.
483 * \see TRACE_host_variable_declare, TRACE_host_variable_set_with_time, TRACE_host_variable_add_with_time
485 void TRACE_host_variable_sub_with_time (double time, const char *host, const char *variable, double value)
487 instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SUB, NULL, user_host_variables);
490 /** \ingroup TRACE_user_variables
491 * \brief Get declared user host variables
493 * This function should be used to get host variables that were already
494 * declared with #TRACE_host_variable_declare or with #TRACE_host_variable_declare_with_color.
496 * \return A dynar with the declared host variables, must be freed with xbt_dynar_free.
498 xbt_dynar_t TRACE_get_host_variables (void)
500 return instr_dict_to_dynar (user_host_variables);
503 /* for link variables */
504 /** \ingroup TRACE_user_variables
505 * \brief Declare a new user variable associated to links.
507 * Declare a user variable that will be associated to links.
508 * A user link variable can be used, for example, to trace
509 * user variables such as the number of messages being
510 * transferred through network links. The color
511 * associated to this new variable will be random.
513 * \param variable The name of the new variable to be declared.
515 * \see TRACE_link_variable_declare_with_color
517 void TRACE_link_variable_declare (const char *variable)
519 instr_user_variable (0, NULL, variable, "LINK", 0, INSTR_US_DECLARE, NULL, user_link_variables);
522 /** \ingroup TRACE_user_variables
523 * \brief Declare a new user variable associated to links with a color.
525 * Same as #TRACE_link_variable_declare, but associated a color
526 * to the newly created user link variable. The color needs to be
527 * a string with three numbers separated by spaces in the range [0,1].
528 * A light-gray color can be specified using "0.7 0.7 0.7" as color.
530 * \param variable The name of the new variable to be declared.
531 * \param color The color for the new variable.
534 void TRACE_link_variable_declare_with_color (const char *variable, const char *color)
536 instr_user_variable (0, NULL, variable, "LINK", 0, INSTR_US_DECLARE, color, user_link_variables);
539 /** \ingroup TRACE_user_variables
540 * \brief Set the value of a variable of a link.
542 * \param link The name of the link to be considered.
543 * \param variable The name of the variable to be considered.
544 * \param value The new value of the variable.
546 * \see TRACE_link_variable_declare, TRACE_link_variable_add, TRACE_link_variable_sub
548 void TRACE_link_variable_set (const char *link, const char *variable, double value)
550 TRACE_link_variable_set_with_time (MSG_get_clock(), link, variable, value);
553 /** \ingroup TRACE_user_variables
554 * \brief Add a value to a variable of a link.
556 * \param link The name of the link to be considered.
557 * \param variable The name of the variable to be considered.
558 * \param value The value to be added to the variable.
560 * \see TRACE_link_variable_declare, TRACE_link_variable_set, TRACE_link_variable_sub
562 void TRACE_link_variable_add (const char *link, const char *variable, double value)
564 TRACE_link_variable_add_with_time (MSG_get_clock(), link, variable, value);
567 /** \ingroup TRACE_user_variables
568 * \brief Subtract a value from a variable of a link.
570 * \param link The name of the link to be considered.
571 * \param variable The name of the variable to be considered.
572 * \param value The value to be subtracted from the variable.
574 * \see TRACE_link_variable_declare, TRACE_link_variable_set, TRACE_link_variable_add
576 void TRACE_link_variable_sub (const char *link, const char *variable, double value)
578 TRACE_link_variable_sub_with_time (MSG_get_clock(), link, variable, value);
581 /** \ingroup TRACE_user_variables
582 * \brief Set the value of a variable of a link at a given timestamp.
584 * Same as #TRACE_link_variable_set, but let user specify
585 * the time used to trace it. Users can specify a time that
586 * is not the simulated clock time as defined by the core
587 * simulator. This allows a fine-grain control of time
588 * definition, but should be used with caution since the trace
589 * can be inconsistent if resource utilization traces are also traced.
591 * \param time The timestamp to be used to tag this change of value.
592 * \param link The name of the link to be considered.
593 * \param variable The name of the variable to be considered.
594 * \param value The new value of the variable.
596 * \see TRACE_link_variable_declare, TRACE_link_variable_add_with_time, TRACE_link_variable_sub_with_time
598 void TRACE_link_variable_set_with_time (double time, const char *link, const char *variable, double value)
600 instr_user_variable (time, link, variable, "LINK", value, INSTR_US_SET, NULL, user_link_variables);
603 /** \ingroup TRACE_user_variables
604 * \brief Add a value to a variable of a link at a given timestamp.
606 * Same as #TRACE_link_variable_add, but let user specify
607 * the time used to trace it. Users can specify a time that
608 * is not the simulated clock time as defined by the core
609 * simulator. This allows a fine-grain control of time
610 * definition, but should be used with caution since the trace
611 * can be inconsistent if resource utilization traces are also traced.
613 * \param time The timestamp to be used to tag this change of value.
614 * \param link The name of the link to be considered.
615 * \param variable The name of the variable to be considered.
616 * \param value The value to be added to the variable.
618 * \see TRACE_link_variable_declare, TRACE_link_variable_set_with_time, TRACE_link_variable_sub_with_time
620 void TRACE_link_variable_add_with_time (double time, const char *link, const char *variable, double value)
622 instr_user_variable (time, link, variable, "LINK", value, INSTR_US_ADD, NULL, user_link_variables);
625 /** \ingroup TRACE_user_variables
626 * \brief Subtract a value from a variable of a link at a given timestamp.
628 * Same as #TRACE_link_variable_sub, but let user specify
629 * the time used to trace it. Users can specify a time that
630 * is not the simulated clock time as defined by the core
631 * simulator. This allows a fine-grain control of time
632 * definition, but should be used with caution since the trace
633 * can be inconsistent if resource utilization traces are also traced.
635 * \param time The timestamp to be used to tag this change of value.
636 * \param link The name of the link to be considered.
637 * \param variable The name of the variable to be considered.
638 * \param value The value to be subtracted from the variable.
640 * \see TRACE_link_variable_declare, TRACE_link_variable_set_with_time, TRACE_link_variable_add_with_time
642 void TRACE_link_variable_sub_with_time (double time, const char *link, const char *variable, double value)
644 instr_user_variable (time, link, variable, "LINK", value, INSTR_US_SUB, NULL, user_link_variables);
647 /* for link variables, but with src and dst used for get_route */
648 /** \ingroup TRACE_user_variables
649 * \brief Set the value of the variable present in the links connecting source and destination.
651 * Same as #TRACE_link_variable_set, but instead of providing the
652 * name of link to be considered, provide the source and destination
653 * hosts. All links that are part of the route between source and
654 * destination will have the variable set to the provided value.
656 * \param src The name of the source host for get route.
657 * \param dst The name of the destination host for get route.
658 * \param variable The name of the variable to be considered.
659 * \param value The new value of the variable.
661 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_add, TRACE_link_srcdst_variable_sub
663 void TRACE_link_srcdst_variable_set (const char *src, const char *dst, const char *variable, double value)
665 TRACE_link_srcdst_variable_set_with_time (MSG_get_clock(), src, dst, variable, value);
668 /** \ingroup TRACE_user_variables
669 * \brief Add a value to the variable present in the links connecting source and destination.
671 * Same as #TRACE_link_variable_add, but instead of providing the
672 * name of link to be considered, provide the source and destination
673 * hosts. All links that are part of the route between source and
674 * destination will have the value passed as parameter added to
675 * the current value of the variable name to be considered.
677 * \param src The name of the source host for get route.
678 * \param dst The name of the destination host for get route.
679 * \param variable The name of the variable to be considered.
680 * \param value The value to be added to the variable.
682 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set, TRACE_link_srcdst_variable_sub
684 void TRACE_link_srcdst_variable_add (const char *src, const char *dst, const char *variable, double value)
686 TRACE_link_srcdst_variable_add_with_time (MSG_get_clock(), src, dst, variable, value);
689 /** \ingroup TRACE_user_variables
690 * \brief Subtract a value from the variable present in the links connecting source and destination.
692 * Same as #TRACE_link_variable_sub, but instead of providing the
693 * name of link to be considered, provide the source and destination
694 * hosts. All links that are part of the route between source and
695 * destination will have the value passed as parameter subtracted from
696 * the current value of the variable name to be considered.
698 * \param src The name of the source host for get route.
699 * \param dst The name of the destination host for get route.
700 * \param variable The name of the variable to be considered.
701 * \param value The value to be subtracted from the variable.
703 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set, TRACE_link_srcdst_variable_add
705 void TRACE_link_srcdst_variable_sub (const char *src, const char *dst, const char *variable, double value)
707 TRACE_link_srcdst_variable_sub_with_time (MSG_get_clock(), src, dst, variable, value);
710 /** \ingroup TRACE_user_variables
711 * \brief Set the value of the variable present in the links connecting source and destination at a given timestamp.
713 * Same as #TRACE_link_srcdst_variable_set, but let user specify
714 * the time used to trace it. Users can specify a time that
715 * is not the simulated clock time as defined by the core
716 * simulator. This allows a fine-grain control of time
717 * definition, but should be used with caution since the trace
718 * can be inconsistent if resource utilization traces are also traced.
720 * \param time The timestamp to be used to tag this change of value.
721 * \param src The name of the source host for get route.
722 * \param dst The name of the destination host for get route.
723 * \param variable The name of the variable to be considered.
724 * \param value The new value of the variable.
726 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_add_with_time, TRACE_link_srcdst_variable_sub_with_time
728 void TRACE_link_srcdst_variable_set_with_time (double time, const char *src, const char *dst, const char *variable, double value)
730 instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_SET);
733 /** \ingroup TRACE_user_variables
734 * \brief Add a value to the variable present in the links connecting source and destination at a given timestamp.
736 * Same as #TRACE_link_srcdst_variable_add, but let user specify
737 * the time used to trace it. Users can specify a time that
738 * is not the simulated clock time as defined by the core
739 * simulator. This allows a fine-grain control of time
740 * definition, but should be used with caution since the trace
741 * can be inconsistent if resource utilization traces are also traced.
743 * \param time The timestamp to be used to tag this change of value.
744 * \param src The name of the source host for get route.
745 * \param dst The name of the destination host for get route.
746 * \param variable The name of the variable to be considered.
747 * \param value The value to be added to the variable.
749 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set_with_time, TRACE_link_srcdst_variable_sub_with_time
751 void TRACE_link_srcdst_variable_add_with_time (double time, const char *src, const char *dst, const char *variable, double value)
753 instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_ADD);
756 /** \ingroup TRACE_user_variables
757 * \brief Subtract a value from the variable present in the links connecting source and destination at a given timestamp.
759 * Same as #TRACE_link_srcdst_variable_sub, but let user specify
760 * the time used to trace it. Users can specify a time that
761 * is not the simulated clock time as defined by the core
762 * simulator. This allows a fine-grain control of time
763 * definition, but should be used with caution since the trace
764 * can be inconsistent if resource utilization traces are also traced.
766 * \param time The timestamp to be used to tag this change of value.
767 * \param src The name of the source host for get route.
768 * \param dst The name of the destination host for get route.
769 * \param variable The name of the variable to be considered.
770 * \param value The value to be subtracted from the variable.
772 * \see TRACE_link_variable_declare, TRACE_link_srcdst_variable_set_with_time, TRACE_link_srcdst_variable_add_with_time
774 void TRACE_link_srcdst_variable_sub_with_time (double time, const char *src, const char *dst, const char *variable, double value)
776 instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_SUB);
779 /** \ingroup TRACE_user_variables
780 * \brief Get declared user link variables
782 * This function should be used to get link variables that were already
783 * declared with #TRACE_link_variable_declare or with #TRACE_link_variable_declare_with_color.
785 * \return A dynar with the declared link variables, must be freed with xbt_dynar_free.
787 xbt_dynar_t TRACE_get_link_variables (void)
789 return instr_dict_to_dynar (user_link_variables);
792 /** \ingroup TRACE_API
793 * \brief Get Paje container types that can be mapped to the nodes of a graph.
795 * This function can be used to create a user made
796 * graph configuration file for Triva. Normally, it is
797 * used with the functions defined in \ref TRACE_user_variables.
799 * \return A dynar with the types, must be freed with xbt_dynar_free.
801 xbt_dynar_t TRACE_get_node_types (void)
803 return instr_dict_to_dynar (trivaNodeTypes);
806 /** \ingroup TRACE_API
807 * \brief Get Paje container types that can be mapped to the edges of a graph.
809 * This function can be used to create a user made
810 * graph configuration file for Triva. Normally, it is
811 * used with the functions defined in \ref TRACE_user_variables.
813 * \return A dynar with the types, must be freed with xbt_dynar_free.
815 xbt_dynar_t TRACE_get_edge_types (void)
817 return instr_dict_to_dynar (trivaEdgeTypes);
820 #endif /* HAVE_TRACING */