From: schnorr Date: Mon, 13 Dec 2010 16:45:28 +0000 (+0000) Subject: [trace] update on --cfg=tracing/msg/task:1, now works with new tracing system X-Git-Tag: v3.6_beta2~708 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5c5188a9c5ba63ce034b32a51c941f195de8849f?ds=sidebyside [trace] update on --cfg=tracing/msg/task:1, now works with new tracing system details: - tasks are grouped by processes - updating tasks.c on example/msg/tracing each task must have a unique name in order to --cfg=tracing/msg/task:1 work git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9215 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/msg/tracing/tasks.c b/examples/msg/tracing/tasks.c index 0caac72baf..4d01940f93 100644 --- a/examples/msg/tracing/tasks.c +++ b/examples/msg/tracing/tasks.c @@ -32,8 +32,10 @@ int master(int argc, char *argv[]) int i; for (i = 0; i < number_of_tasks; i++) { + char task_name[100]; + snprintf (task_name, 100, "task-%d", i); m_task_t task = NULL; - task = MSG_task_create("task", task_comp_size, task_comm_size, NULL); + task = MSG_task_create(task_name, task_comp_size, task_comm_size, NULL); //setting the category of task to "compute" //the category of a task must be defined before it is sent or executed @@ -42,7 +44,9 @@ int master(int argc, char *argv[]) } for (i = 0; i < slaves_count; i++) { - m_task_t finalize = MSG_task_create("finalize", 0, 0, 0); + char task_name[100]; + snprintf (task_name, 100, "task-%d", i); + m_task_t finalize = MSG_task_create(task_name, 0, 0, xbt_strdup("finalize")); TRACE_msg_set_task_category(finalize, "finalize"); MSG_task_send(finalize, "master_mailbox"); } @@ -63,7 +67,8 @@ int slave(int argc, char *argv[]) break; } - if (!strcmp(MSG_task_get_name(task), "finalize")) { + char *data = MSG_task_get_data(task); + if (data && !strcmp(data, "finalize")) { MSG_task_destroy(task); break; } diff --git a/src/instr/instr_config.c b/src/instr/instr_config.c index 3b3168724f..fd3ce0098b 100644 --- a/src/instr/instr_config.c +++ b/src/instr/instr_config.c @@ -87,7 +87,6 @@ int TRACE_start() } /* other trace initialization */ created_categories = xbt_dict_new(); - TRACE_msg_task_alloc(); TRACE_surf_alloc(); TRACE_smpi_alloc(); return 0; diff --git a/src/instr/instr_msg_task.c b/src/instr/instr_msg_task.c index 8e5a23d267..8aabfcf2a1 100644 --- a/src/instr/instr_msg_task.c +++ b/src/instr/instr_msg_task.c @@ -10,131 +10,58 @@ 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, - m_host_t host, char *output, int len) -{ - if (output) { - snprintf(output, len, "%p-%lld-%p-%p", task, task->counter, process, - host); - return output; - } else { - return NULL; - } -} - -static char *TRACE_host_container(m_host_t host, char *output, int len) -{ - if (output) { - snprintf(output, len, "%s", MSG_host_get_name(host)); - return output; - } else { - return NULL; - } -} - -char *TRACE_task_container(m_task_t task, char *output, int len) -{ - if (output) { - snprintf(output, len, "%p-%lld", task, task->counter); - return output; - } else { - return NULL; - } -} - -void TRACE_msg_task_alloc(void) -{ - task_containers = xbt_dict_new(); -} - -void TRACE_msg_task_release(void) -{ - xbt_dict_free(&task_containers); -} - -static void TRACE_task_location(m_task_t task) -{ - char container[200]; - char name[200], alias[200]; - char *val_one = NULL; - m_process_t process = NULL; - m_host_t host = NULL; - if (!TRACE_msg_task_is_enabled()) - return; - process = MSG_process_self(); - host = MSG_process_get_host(process); - - //tasks are grouped by host - TRACE_host_container(host, container, 200); - TRACE_task_container(task, name, 200); - TRACE_task_alias_container(task, process, host, alias, 200); - //check if task container is already created - if (!xbt_dict_get_or_null(task_containers, alias)) { - pajeCreateContainer(MSG_get_clock(), alias, "TASK", container, name); - pajeSetState(MSG_get_clock(), "category", alias, task->category); - val_one = xbt_strdup("1"); - xbt_dict_set(task_containers, alias, val_one, xbt_free); - } -} - -static void TRACE_task_location_present(m_task_t task) -{ - char alias[200]; - m_process_t process = NULL; - m_host_t host = NULL; - if (!TRACE_msg_task_is_enabled()) - return; - //updating presence state of this task location - process = MSG_process_self(); - host = MSG_process_get_host(process); - - TRACE_task_alias_container(task, process, host, alias, 200); - pajePushState(MSG_get_clock(), "presence", alias, "presence"); -} - -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 (!TRACE_msg_task_is_enabled()) - return; - //updating presence state of this task location - process = MSG_process_self(); - host = MSG_process_get_host(process); - - TRACE_task_alias_container(task, process, host, alias, 200); - pajePopState(MSG_get_clock(), "presence", alias); -} +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) { - char name[200]; + 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).", 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 (category == NULL) { + //if user provides a NULL category, task is no longer traced + xbt_free (task->category); + task->category = NULL; + return; + } //set task category 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); - TRACE_task_location_present(task); - - TRACE_task_container(task, name, 200); - //create container of type "task" to indicate behavior - if (TRACE_msg_task_is_enabled()) - pajeCreateContainer(MSG_get_clock(), name, "task", category, name); - if (TRACE_msg_task_is_enabled()) - pajePushState(MSG_get_clock(), "task-state", name, "created"); + 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"); + + //FIXME + //pajePushState(MSG_get_clock(), "task-state", name, "created"); + xbt_dict_set (tasks_created, task->name, xbt_strdup("1"), xbt_free); + } } /* MSG_task_create related function*/ @@ -149,123 +76,109 @@ void TRACE_msg_task_create(m_task_t task) /* MSG_task_execute related functions */ void TRACE_msg_task_execute_start(m_task_t task) { - char name[200]; - if (!TRACE_is_active()) - return; - - if (!task->category) - return; + if (!(TRACE_is_enabled() && + TRACE_msg_task_is_enabled() && + task->category)) return; DEBUG3("EXEC,in %p, %lld, %s", task, task->counter, task->category); - TRACE_task_container(task, name, 200); - if (TRACE_msg_task_is_enabled()) - pajePushState(MSG_get_clock(), "task-state", name, "execute"); + //FIXME + //pajePushState(MSG_get_clock(), "task-state", name, "execute"); } void TRACE_msg_task_execute_end(m_task_t task) { - char name[200]; - if (!TRACE_is_active()) - return; - - if (!task->category) - return; - - TRACE_task_container(task, name, 200); - if (TRACE_msg_task_is_enabled()) - pajePopState(MSG_get_clock(), "task-state", name); + if (!(TRACE_is_enabled() && + TRACE_msg_task_is_enabled() && + task->category)) return; DEBUG3("EXEC,out %p, %lld, %s", task, task->counter, task->category); + + //FIXME + //pajePopState(MSG_get_clock(), "task-state", name); } /* MSG_task_destroy related functions */ void TRACE_msg_task_destroy(m_task_t task) { - char name[200]; - if (!TRACE_is_active()) - return; - - if (!task->category) - return; - - TRACE_task_container(task, name, 200); - if (TRACE_msg_task_is_enabled()) - pajeDestroyContainer(MSG_get_clock(), "task", name); + if (!tasks_created) tasks_created = xbt_dict_new(); + if (!(TRACE_is_enabled() && + TRACE_msg_task_is_enabled() && + task->category)) return; - //finish the location of this task - TRACE_task_location_not_present(task); + //that's the end, let's destroy it + destroyContainer (getContainer(task->name)); DEBUG3("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_active()) - return; + if (!(TRACE_is_enabled() && + TRACE_msg_task_is_enabled())) return; DEBUG0("GET,in"); } void TRACE_msg_task_get_end(double start_time, m_task_t task) { - char name[200]; - if (!TRACE_is_active()) - return; - - if (!task->category) - return; + if (!(TRACE_is_enabled() && + TRACE_msg_task_is_enabled() && + task->category)) return; - TRACE_task_container(task, name, 200); - if (TRACE_msg_task_is_enabled()) - pajePopState(MSG_get_clock(), "task-state", name); + DEBUG3("GET,out %p, %lld, %s", task, task->counter, task->category); - if (TRACE_msg_volume_is_enabled()){ - TRACE_msg_volume_finish(task); - } + //FIXME + //pajePopState(MSG_get_clock(), "task-state", name); - TRACE_task_location(task); - TRACE_task_location_present(task); + //FIXME + //if (TRACE_msg_volume_is_enabled()){ + // TRACE_msg_volume_end(task); + //} - DEBUG3("GET,out %p, %lld, %s", task, task->counter, task->category); + 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"); } /* MSG_task_put related functions */ int TRACE_msg_task_put_start(m_task_t task) { - char name[200]; - if (!TRACE_is_active()) - return 0; - - if (!task->category) - return 0; + if (!(TRACE_is_enabled() && + TRACE_msg_task_is_enabled() && + task->category)) return 0; DEBUG3("PUT,in %p, %lld, %s", task, task->counter, task->category); - TRACE_task_container(task, name, 200); - if (TRACE_msg_task_is_enabled()) - pajePopState(MSG_get_clock(), "task-state", name); - if (TRACE_msg_task_is_enabled()) - pajePushState(MSG_get_clock(), "task-state", name, "communicate"); + destroyContainer (getContainer(task->name)); - if (TRACE_msg_volume_is_enabled()){ - TRACE_msg_volume_start(task); - } + //FIXME + //pajePopState(MSG_get_clock(), "task-state", name); + //pajePushState(MSG_get_clock(), "task-state", name, "communicate"); + + //FIXME + //if (TRACE_msg_volume_is_enabled()){ + // TRACE_msg_volume_start(task); + //} - //trace task location grouped by host - TRACE_task_location_not_present(task); return 1; } void TRACE_msg_task_put_end(void) { - if (!TRACE_is_active()) - return; + if (!(TRACE_is_enabled() && + TRACE_msg_task_is_enabled())) return; + DEBUG0("PUT,out"); } diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 18c41d5330..63ce9902e2 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -42,6 +42,7 @@ typedef enum { INSTR_AS, INSTR_SMPI, INSTR_MSG_PROCESS, + INSTR_MSG_TASK, } e_container_types; typedef struct s_container *container_t; @@ -107,8 +108,6 @@ void pajeNewEvent(double time, const char *entityType, /* declaration of instrumentation functions from msg_task_instr.c */ char *TRACE_task_container(m_task_t task, char *output, int len); -void TRACE_msg_task_alloc(void); -void TRACE_msg_task_release(void); void TRACE_msg_task_create(m_task_t task); void TRACE_msg_task_execute_start(m_task_t task); void TRACE_msg_task_execute_end(m_task_t task); @@ -122,8 +121,6 @@ void TRACE_msg_task_put_end(void); char *TRACE_process_alias_container(m_process_t process, m_host_t host, char *output, int len); char *TRACE_process_container(m_process_t process, char *output, int len); -void TRACE_msg_process_alloc(void); -void TRACE_msg_process_release(void); void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_host_t new_host); void TRACE_msg_process_kill(m_process_t process); diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index c65dabf137..06c2898d25 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -213,6 +213,7 @@ container_t newContainer (const char *name, e_container_types kind, container_t case INSTR_ROUTER: new->type = getContainerType ("ROUTER", new->father->type); break; case INSTR_SMPI: new->type = getContainerType ("MPI", new->father->type); break; case INSTR_MSG_PROCESS: new->type = getContainerType ("MSG_PROCESS", new->father->type); break; + case INSTR_MSG_TASK: new->type = getContainerType ("MSG_TASK", new->father->type); break; default: xbt_die ("Congratulations, you have found a bug on newContainer function of instr_routing.c"); break; } } @@ -514,6 +515,10 @@ static void instr_routing_parse_start_host () if (TRACE_msg_process_is_enabled()) { getContainerType("MSG_PROCESS", new->type); } + + if (TRACE_msg_task_is_enabled()) { + getContainerType ("MSG_TASK", new->type); + } } static void instr_routing_parse_end_host ()