Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
409b3d9da27c17e53a06c3451e190bd8ed6901bf
[simgrid.git] / src / simdag / instr_sd_task.c
1 /* Copyright (c) 2013. 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 #include "private.h"
9 #include "simdag/datatypes.h"
10
11 #ifdef HAVE_TRACING
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_sd, instr, "SD");
14
15 void TRACE_sd_set_task_category(SD_task_t task, const char *category){
16
17   //if user provides a NULL category, task is no longer traced
18   if (category == NULL) {
19     xbt_free (task->category);
20     task->category = NULL;
21     XBT_DEBUG("SD task %p(%s), category removed", task, task->name);
22     return;
23   }
24
25   //set task category
26   if (task->category)
27     xbt_free(task->category);
28   task->category = xbt_strdup (category);
29   XBT_DEBUG("SD task %p(%s), category %s", task, task->name, task->category);
30 }
31
32 void TRACE_sd_task_create(SD_task_t task)
33 {
34   static long long counter = 0;
35   task->counter = counter++;
36   task->category = NULL;
37
38   XBT_DEBUG("CREATE %p, %lld", task, task->counter);
39 }
40
41 void TRACE_sd_task_execute_start(SD_task_t task)
42 {
43   if (task->kind == SD_TASK_COMP_PAR_AMDAHL || task->kind == SD_TASK_COMP_SEQ){
44     XBT_DEBUG("EXEC,in %p, %lld, %s", task, task->counter, task->category);
45 //    int i;
46 //    for (i = 0; i < task->workstation_nb; i++){
47 //      container_t workstation_container =
48 //          PJ_container_get (SD_workstation_get_name(task->workstation_list[i]));
49 //      char name[1024];
50 //      type_t type = PJ_type_get ("power_used", workstation_container->type);
51 //      sprintf(name, "%s_ws_%d", SD_task_get_name(task), i);
52 //      val_t value = PJ_value_new(name, "1 0 1", type);
53 //      new_pajePushState (SD_get_clock(), workstation_container, type, value);
54 //    }
55   }
56 }
57
58 void TRACE_sd_task_execute_end(SD_task_t task)
59 {
60   if (task->kind == SD_TASK_COMP_PAR_AMDAHL || task->kind == SD_TASK_COMP_SEQ){
61     XBT_DEBUG("EXEC,out %p, %lld, %s", task, task->counter, task->category);
62 //    int i;
63 //    for (i = 0; i < task->workstation_nb; i++){
64 //      container_t workstation_container =
65 //          PJ_container_get (SD_workstation_get_name(task->workstation_list[i]));
66 //      type_t type = PJ_type_get ("power_used", workstation_container->type);
67 //      new_pajePopState (SD_get_clock(), workstation_container, type);
68 //    }
69   }
70 }
71
72 void TRACE_sd_task_destroy(SD_task_t task)
73 {
74   XBT_DEBUG("DESTROY %p, %lld, %s", task, task->counter, task->category);
75
76   //free category
77   xbt_free(task->category);
78   task->category = NULL;
79   return;
80 }
81
82 #endif /* HAVE_TRACING */