Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a specific file to manage tracing in SimDag
authorsuter <frederic.suter@cc.in2p3.fr>
Thu, 31 Jan 2013 09:48:44 +0000 (10:48 +0100)
committersuter <frederic.suter@cc.in2p3.fr>
Thu, 31 Jan 2013 14:53:24 +0000 (15:53 +0100)
buildtools/Cmake/DefinePackages.cmake
src/simdag/instr_sd_task.c [new file with mode: 0644]

index a14a301..21d74f8 100644 (file)
@@ -286,6 +286,7 @@ set(EXTRA_DIST
 #* ****************************************************************************************** *#
 
 set(SIMDAG_SRC
+  src/simdag/instr_sd_task.c
   src/simdag/sd_daxloader.c
   src/simdag/sd_global.c
   src/simdag/sd_link.c
diff --git a/src/simdag/instr_sd_task.c b/src/simdag/instr_sd_task.c
new file mode 100644 (file)
index 0000000..c4da12e
--- /dev/null
@@ -0,0 +1,80 @@
+/* Copyright (c) 2013. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "instr/instr_private.h"
+#include "private.h"
+#include "simdag/datatypes.h"
+
+#ifdef HAVE_TRACING
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_sd, instr, "SD");
+
+void TRACE_sd_set_task_category(SD_task_t task, const char *category){
+
+  //if user provides a NULL category, task is no longer traced
+  if (category == NULL) {
+    xbt_free (task->category);
+    task->category = NULL;
+    XBT_DEBUG("SD task %p(%s), category removed", task, task->name);
+    return;
+  }
+
+  //set task category
+  task->category = xbt_strdup (category);
+  XBT_DEBUG("SD task %p(%s), category %s", task, task->name, task->category);
+}
+
+void TRACE_sd_task_create(SD_task_t task)
+{
+  static long long counter = 0;
+  task->counter = counter++;
+  task->category = NULL;
+
+  XBT_DEBUG("CREATE %p, %lld", task, task->counter);
+}
+
+void TRACE_sd_task_execute_start(SD_task_t task)
+{
+  if (task->kind == SD_TASK_COMP_PAR_AMDAHL || task->kind == SD_TASK_COMP_SEQ){
+    XBT_DEBUG("EXEC,in %p, %lld, %s", task, task->counter, task->category);
+//    int i;
+//    for (i = 0; i < task->workstation_nb; i++){
+//      container_t workstation_container =
+//          PJ_container_get (SD_workstation_get_name(task->workstation_list[i]));
+//      char name[1024];
+//      type_t type = PJ_type_get ("power_used", workstation_container->type);
+//      sprintf(name, "%s_ws_%d", SD_task_get_name(task), i);
+//      val_t value = PJ_value_new(name, "1 0 1", type);
+//      new_pajePushState (SD_get_clock(), workstation_container, type, value);
+//    }
+  }
+}
+
+void TRACE_sd_task_execute_end(SD_task_t task)
+{
+  if (task->kind == SD_TASK_COMP_PAR_AMDAHL || task->kind == SD_TASK_COMP_SEQ){
+    XBT_DEBUG("EXEC,out %p, %lld, %s", task, task->counter, task->category);
+//    int i;
+//    for (i = 0; i < task->workstation_nb; i++){
+//      container_t workstation_container =
+//          PJ_container_get (SD_workstation_get_name(task->workstation_list[i]));
+//      type_t type = PJ_type_get ("power_used", workstation_container->type);
+//      new_pajePopState (SD_get_clock(), workstation_container, type);
+//    }
+  }
+}
+
+void TRACE_sd_task_destroy(SD_task_t task)
+{
+  XBT_DEBUG("DESTROY %p, %lld, %s", task, task->counter, task->category);
+
+  //free category
+  xbt_free(task->category);
+  task->category = NULL;
+  return;
+}
+
+#endif /* HAVE_TRACING */