Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] use of xbt functions inside instr
[simgrid.git] / src / instr / instr_smx.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/instr_private.h"
8
9 #ifdef HAVE_TRACING
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_simix, instr, "Tracing Simix");
12
13 static long long int counter = 0;       /* to uniquely identify simix actions */
14
15 void TRACE_smx_host_execute(smx_action_t act)
16 {
17   if (!TRACE_is_active())
18     return;
19
20   act->counter = counter++;
21   char *category = TRACE_category_get(SIMIX_process_self());
22   if (category) {
23     act->category = xbt_strdup(category);
24     DEBUG2("Create Execute SMX action %p, category %s", act, act->category);
25   }
26   TRACE_surf_resource_utilization_start(act);
27 }
28
29 void TRACE_smx_action_communicate(smx_action_t act, smx_process_t proc)
30 {
31   if (!TRACE_is_active())
32     return;
33
34   act->counter = counter++;
35   char *category = TRACE_category_get(proc);
36   if (category) {
37     act->category = xbt_strdup(category);
38     DEBUG2("Create Communicate SMX action %p, category %s", act, act->category);
39   }
40   TRACE_surf_resource_utilization_start(act);
41 }
42
43 void TRACE_smx_action_destroy(smx_action_t act)
44 {
45   if (!TRACE_is_active())
46     return;
47
48   if (act->category) {
49     DEBUG2("Destroy SMX action %p, category %s", act, act->category);
50     xbt_free(act->category);
51   }
52   TRACE_surf_resource_utilization_end(act);
53 }
54
55 #endif /* HAVE_TRACING */