X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/673a25c682fbdedbdefbc513160b2710a5b545fb..73fc9f6b6089d7cb8a76dcf5a015e105943c1df5:/src/instr/instr_msg_task.c diff --git a/src/instr/instr_msg_task.c b/src/instr/instr_msg_task.c index bd35dabd50..a2d8f6c4e3 100644 --- a/src/instr/instr_msg_task.c +++ b/src/instr/instr_msg_task.c @@ -8,6 +8,8 @@ #ifdef HAVE_TRACING +XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg, instr, "MSG"); + static xbt_dict_t task_containers = NULL; static char *TRACE_task_alias_container(m_task_t task, m_process_t process, @@ -59,7 +61,7 @@ static void TRACE_task_location(m_task_t task) char *val_one = NULL; m_process_t process = NULL; m_host_t host = NULL; - if (!IS_TRACING_TASKS) + if (!TRACE_msg_task_is_enabled()) return; process = MSG_process_self(); host = MSG_process_get_host(process); @@ -82,7 +84,7 @@ static void TRACE_task_location_present(m_task_t task) char alias[200]; m_process_t process = NULL; m_host_t host = NULL; - if (!IS_TRACING_TASKS) + if (!TRACE_msg_task_is_enabled()) return; //updating presence state of this task location process = MSG_process_self(); @@ -97,7 +99,7 @@ static void TRACE_task_location_not_present(m_task_t task) char alias[200]; m_process_t process = NULL; m_host_t host = NULL; - if (!IS_TRACING_TASKS) + if (!TRACE_msg_task_is_enabled()) return; //updating presence state of this task location process = MSG_process_self(); @@ -116,9 +118,12 @@ void TRACE_msg_set_task_category(m_task_t task, const char *category) if (!TRACE_is_active()) return; + xbt_assert3(task->category == NULL, "Task %p(%s) already has a category (%s).", + task, task->name, task->category); + //set task category - task->category = xbt_new(char, strlen(category) + 1); - strncpy(task->category, category, strlen(category) + 1); + task->category = xbt_strdup (category); + DEBUG3("MSG task %p(%s), category %s", task, task->name, task->category); //tracing task location based on host TRACE_task_location(task); @@ -126,9 +131,9 @@ void TRACE_msg_set_task_category(m_task_t task, const char *category) TRACE_task_container(task, name, 200); //create container of type "task" to indicate behavior - if (IS_TRACING_TASKS) + if (TRACE_msg_task_is_enabled()) pajeCreateContainer(MSG_get_clock(), name, "task", category, name); - if (IS_TRACING_TASKS) + if (TRACE_msg_task_is_enabled()) pajePushState(MSG_get_clock(), "task-state", name, "created"); } @@ -138,49 +143,61 @@ void TRACE_msg_task_create(m_task_t task) static long long counter = 0; task->counter = counter++; task->category = NULL; + DEBUG2("CREATE %p, %lld", task, task->counter); } /* MSG_task_execute related functions */ void TRACE_msg_task_execute_start(m_task_t task) { char name[200]; - if (!TRACE_is_active() || !IS_TRACED(task)) + if (!TRACE_is_active()) return; + if (!task->category) + return; + + DEBUG3("EXEC,in %p, %lld, %s", task, task->counter, task->category); + TRACE_task_container(task, name, 200); - if (IS_TRACING_TASKS) + if (TRACE_msg_task_is_enabled()) pajePushState(MSG_get_clock(), "task-state", name, "execute"); - - TRACE_msg_category_set(SIMIX_process_self(), task); } void TRACE_msg_task_execute_end(m_task_t task) { char name[200]; - if (!TRACE_is_active() || !IS_TRACED(task)) + if (!TRACE_is_active()) + return; + + if (!task->category) return; TRACE_task_container(task, name, 200); - if (IS_TRACING_TASKS) + if (TRACE_msg_task_is_enabled()) pajePopState(MSG_get_clock(), "task-state", name); - TRACE_category_unset(SIMIX_process_self()); + DEBUG3("EXEC,out %p, %lld, %s", task, task->counter, task->category); } /* MSG_task_destroy related functions */ void TRACE_msg_task_destroy(m_task_t task) { char name[200]; - if (!TRACE_is_active() || !IS_TRACED(task)) + if (!TRACE_is_active()) + return; + + if (!task->category) return; TRACE_task_container(task, name, 200); - if (IS_TRACING_TASKS) + if (TRACE_msg_task_is_enabled()) pajeDestroyContainer(MSG_get_clock(), "task", name); //finish the location of this task TRACE_task_location_not_present(task); + DEBUG3("DESTROY %p, %lld, %s", task, task->counter, task->category); + //free category xbt_free(task->category); return; @@ -191,44 +208,53 @@ void TRACE_msg_task_get_start(void) { if (!TRACE_is_active()) return; + + DEBUG0("GET,in"); } void TRACE_msg_task_get_end(double start_time, m_task_t task) { char name[200]; - if (!TRACE_is_active() || !IS_TRACED(task)) + if (!TRACE_is_active()) + return; + + if (!task->category) return; TRACE_task_container(task, name, 200); - if (IS_TRACING_TASKS) + if (TRACE_msg_task_is_enabled()) pajePopState(MSG_get_clock(), "task-state", name); TRACE_msg_volume_finish(task); TRACE_task_location(task); TRACE_task_location_present(task); + + DEBUG3("GET,out %p, %lld, %s", task, task->counter, task->category); } /* MSG_task_put related functions */ int TRACE_msg_task_put_start(m_task_t task) { char name[200]; - if (!TRACE_is_active() || !IS_TRACED(task)) + if (!TRACE_is_active()) + return 0; + + if (!task->category) return 0; + DEBUG3("PUT,in %p, %lld, %s", task, task->counter, task->category); + TRACE_task_container(task, name, 200); - if (IS_TRACING_TASKS) + if (TRACE_msg_task_is_enabled()) pajePopState(MSG_get_clock(), "task-state", name); - if (IS_TRACING_TASKS) + if (TRACE_msg_task_is_enabled()) pajePushState(MSG_get_clock(), "task-state", name, "communicate"); TRACE_msg_volume_start(task); //trace task location grouped by host TRACE_task_location_not_present(task); - - //set current category - TRACE_msg_category_set(SIMIX_process_self(), task); return 1; } @@ -236,8 +262,7 @@ void TRACE_msg_task_put_end(void) { if (!TRACE_is_active()) return; - - TRACE_category_unset(SIMIX_process_self()); + DEBUG0("PUT,in"); } #endif /* HAVE_TRACING */