Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
trace: new interface function for tracing resource categorized utilization with SMPI
[simgrid.git] / src / instr / categories.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 "instr/private.h"
8
9 #ifdef HAVE_TRACING
10
11 static xbt_dict_t current_task_category = NULL;
12
13 void __TRACE_category_init ()
14 {
15   current_task_category = xbt_dict_new();
16 }
17
18 void __TRACE_category_set (smx_process_t proc, const char *category)
19 {
20   char processid[100];
21   char *var_cpy = NULL;
22   snprintf (processid, 100, "%p", proc);
23   var_cpy = xbt_strdup (category);
24   xbt_dict_set (current_task_category, processid, var_cpy, xbt_free);
25 }
26
27 char *__TRACE_category_get (smx_process_t proc)
28 {
29   char processid[100];
30   snprintf (processid, 100, "%p", proc);
31   return xbt_dict_get_or_null (current_task_category, processid);
32 }
33
34 void __TRACE_category_unset (smx_process_t proc)
35 {
36   char processid[100];
37   snprintf (processid, 100, "%p", proc);
38   xbt_dict_remove (current_task_category, processid);
39 }
40
41 void __TRACE_msg_category_set (smx_process_t proc, m_task_t task)
42 {
43   __TRACE_category_set (proc, task->category);
44 }
45
46
47 #endif