X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d9601b8ae97f9ef29cc571b71fa4a41ab9133a2b..a7dc4456f42a853a6294c774ccc9397304732c6e:/src/instr/instr_msg_task.c diff --git a/src/instr/instr_msg_task.c b/src/instr/instr_msg_task.c index 9796fbcd20..d190e9a32c 100644 --- a/src/instr/instr_msg_task.c +++ b/src/instr/instr_msg_task.c @@ -10,59 +10,22 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg, instr, "MSG"); -xbt_dict_t tasks_created = NULL; - -/* - * TRACE_msg_set_task_category: tracing interface function - */ void TRACE_msg_set_task_category(m_task_t task, const char *category) { - if (!tasks_created) tasks_created = xbt_dict_new(); - if (!TRACE_is_active()) - return; - - xbt_assert3(task->category == NULL, "Task %p(%s) already has a category (%s).", + xbt_assert(task->category == NULL, "Task %p(%s) already has a category (%s).", task, task->name, task->category); - if (TRACE_msg_task_is_enabled()){ - xbt_assert2(task->name != NULL, - "Task %p(%s) must have a unique name in order to be traced, if --cfg=tracing/msg/task:1 is used.", - task, task->name); - xbt_assert3(getContainer(task->name)==NULL, - "Task %p(%s). Tracing already knows a task with name %s." - "The name of each task must be unique, if --cfg=tracing/msg/task:1 is used.", task, task->name, task->name); - } + //if user provides a NULL category, task is no longer traced if (category == NULL) { - //if user provides a NULL category, task is no longer traced xbt_free (task->category); task->category = NULL; + XBT_DEBUG("MSG task %p(%s), category removed", task, task->name); return; } //set task category task->category = xbt_strdup (category); - DEBUG3("MSG task %p(%s), category %s", task, task->name, task->category); - - if (TRACE_msg_task_is_enabled()){ - m_host_t host = MSG_host_self(); - container_t host_container = getContainer(host->name); - //check to see if there is a container with the task->name - container_t msg = getContainer(task->name); - xbt_assert3(xbt_dict_get_or_null (tasks_created, task->name) == NULL, - "Task %p(%s). Tracing already knows a task with name %s." - "The name of each task must be unique, if --cfg=tracing/msg/task:1 is used.", task, task->name, task->name); - msg = newContainer(task->name, INSTR_MSG_TASK, host_container); - type_t type = getType (task->category); - if (!type){ - type = newVariableType(task->category, TYPE_VARIABLE, NULL, msg->type); - } - pajeSetVariable(SIMIX_get_clock(), type->id, msg->id, "1"); - - type = getType ("MSG_TASK_STATE"); - pajePushState (MSG_get_clock(), type->id, msg->id, "created"); - - xbt_dict_set (tasks_created, task->name, xbt_strdup("1"), xbt_free); - } + XBT_DEBUG("MSG task %p(%s), category %s", task, task->name, task->category); } /* MSG_task_create related function*/ @@ -71,128 +34,120 @@ 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); + XBT_DEBUG("CREATE %p, %lld", task, task->counter); } /* MSG_task_execute related functions */ void TRACE_msg_task_execute_start(m_task_t task) { - if (!(TRACE_is_enabled() && - TRACE_msg_task_is_enabled() && - task->category)) return; + XBT_DEBUG("EXEC,in %p, %lld, %s", task, task->counter, task->category); - DEBUG3("EXEC,in %p, %lld, %s", task, task->counter, task->category); + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - container_t task_container = getContainer (task->name); - type_t type = getType ("MSG_TASK_STATE"); - pajePushState (MSG_get_clock(), type->id, task_container->id, "MSG_task_execute"); + container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); + type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); + val_t value = PJ_value_get ("task_execute", type); + new_pajePushState (MSG_get_clock(), process_container, type, value); + } } void TRACE_msg_task_execute_end(m_task_t task) { - if (!(TRACE_is_enabled() && - TRACE_msg_task_is_enabled() && - task->category)) return; + XBT_DEBUG("EXEC,out %p, %lld, %s", task, task->counter, task->category); - DEBUG3("EXEC,out %p, %lld, %s", task, task->counter, task->category); + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - container_t task_container = getContainer (task->name); - type_t type = getType ("MSG_TASK_STATE"); - pajePopState (MSG_get_clock(), type->id, task_container->id); + container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); + type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); + new_pajePopState (MSG_get_clock(), process_container, type); + } } /* MSG_task_destroy related functions */ void TRACE_msg_task_destroy(m_task_t task) { - if (!tasks_created) tasks_created = xbt_dict_new(); - if (!(TRACE_is_enabled() && - TRACE_msg_task_is_enabled() && - task->category)) return; - - //that's the end, let's destroy it - destroyContainer (getContainer(task->name)); - - DEBUG3("DESTROY %p, %lld, %s", task, task->counter, task->category); + XBT_DEBUG("DESTROY %p, %lld, %s", task, task->counter, task->category); //free category xbt_free(task->category); task->category = NULL; - - xbt_dict_remove (tasks_created, task->name); return; } /* MSG_task_get related functions */ void TRACE_msg_task_get_start(void) { - if (!(TRACE_is_enabled() && - TRACE_msg_task_is_enabled())) return; + XBT_DEBUG("GET,in"); + + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - DEBUG0("GET,in"); + container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); + type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); + val_t value = PJ_value_get ("receive", type); + new_pajePushState (MSG_get_clock(), process_container, type, value); + } } void TRACE_msg_task_get_end(double start_time, m_task_t task) { - if (!(TRACE_is_enabled() && - TRACE_msg_task_is_enabled() && - task->category)) return; - - DEBUG3("GET,out %p, %lld, %s", task, task->counter, task->category); - - //FIXME - //if (TRACE_msg_volume_is_enabled()){ - // TRACE_msg_volume_end(task); - //} - - m_host_t host = MSG_host_self(); - container_t host_container = getContainer(host->name); - container_t msg = newContainer(task->name, INSTR_MSG_TASK, host_container); - type_t type = getType (task->category); - pajeSetVariable(SIMIX_get_clock(), type->id, msg->id, "1"); - - type = getType ("MSG_TASK_STATE"); - pajePushState (MSG_get_clock(), type->id, msg->id, "created"); - - type = getType ("MSG_TASK_LINK"); - char key[INSTR_DEFAULT_STR_SIZE]; - snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", task->counter); - pajeEndLink(MSG_get_clock(), type->id, "0", "SR", msg->id, key); + XBT_DEBUG("GET,out %p, %lld, %s", task, task->counter, task->category); + + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); + type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); + new_pajePopState (MSG_get_clock(), process_container, type); + + char key[INSTR_DEFAULT_STR_SIZE]; + snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter); + type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root()); + new_pajeEndLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key); + } } /* MSG_task_put related functions */ int TRACE_msg_task_put_start(m_task_t task) { - if (!(TRACE_is_enabled() && - TRACE_msg_task_is_enabled() && - task->category)) return 0; + XBT_DEBUG("PUT,in %p, %lld, %s", task, task->counter, task->category); - DEBUG3("PUT,in %p, %lld, %s", task, task->counter, task->category); + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - container_t msg = getContainer (task->name); - type_t type = getType ("MSG_TASK_STATE"); - pajePopState (MSG_get_clock(), type->id, msg->id); + container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); + type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); + val_t value = PJ_value_get ("send", type); + new_pajePushState (MSG_get_clock(), process_container, type, value); - type = getType ("MSG_TASK_LINK"); - char key[INSTR_DEFAULT_STR_SIZE]; - snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", task->counter); - pajeStartLink(MSG_get_clock(), type->id, "0", "SR", msg->id, key); - - destroyContainer (msg); - - //FIXME - //if (TRACE_msg_volume_is_enabled()){ - // TRACE_msg_volume_start(task); - //} + char key[INSTR_DEFAULT_STR_SIZE]; + snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter); + type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root()); + new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key); + } return 1; } void TRACE_msg_task_put_end(void) { - if (!(TRACE_is_enabled() && - TRACE_msg_task_is_enabled())) return; + XBT_DEBUG("PUT,out"); - DEBUG0("PUT,out"); + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); + type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); + new_pajePopState (MSG_get_clock(), process_container, type); + } } #endif /* HAVE_TRACING */