From: Arnaud Giersch Date: Thu, 17 Jan 2013 13:03:10 +0000 (+0100) Subject: Merge branch 'master' into vmtrace X-Git-Tag: v3_9_rc1~86 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0c13871d73e933c1847faf8debea7b7745a3ff44 Merge branch 'master' into vmtrace Conflicts: buildtools/Cmake/DefinePackages.cmake include/surf/simgrid_dtd.h include/xbt/graphxml.h src/instr/instr_config.c src/instr/instr_private.h src/simdag/dax_dtd.c src/simdag/dax_dtd.h src/surf/simgrid_dtd.c src/xbt/graphxml.c --- 0c13871d73e933c1847faf8debea7b7745a3ff44 diff --cc buildtools/Cmake/DefinePackages.cmake index 0f5e390168,cf125c02d8..56fd828081 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@@ -226,9 -234,14 +234,15 @@@ set(SIMIX_SR src/simix/smx_user.c ) + set(SIMGRID_SRC + src/simgrid/sg_config.c + ) + set(MSG_SRC + src/msg/instr_msg_process.c + src/msg/instr_msg_task.c ++ src/msg/instr_msg_vm.c src/msg/msg_actions.c - src/msg/msg_config.c src/msg/msg_deployment.c src/msg/msg_environment.c src/msg/msg_global.c diff --cc src/instr/instr_config.c index 268c643e38,3797373038..3737cf7e7b --- a/src/instr/instr_config.c +++ b/src/instr/instr_config.c @@@ -50,22 -49,31 +51,32 @@@ static int trace_basic static int trace_configured = 0; static int trace_active = 0; + + static void TRACE_getopts(void) { - trace_enabled = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING); - trace_platform = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_PLATFORM); - trace_platform_topology = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_TOPOLOGY); - trace_smpi_enabled = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI); - trace_smpi_grouped = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI_GROUP); - trace_smpi_computing = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI_COMPUTING); - trace_categorized = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_CATEGORIZED); - trace_uncategorized = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_UNCATEGORIZED); - trace_msg_process_enabled = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_PROCESS); - trace_msg_vm_enabled = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_VM); - trace_buffer = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_BUFFER); - trace_onelink_only = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_ONELINK_ONLY); - trace_disable_destroy = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_DISABLE_DESTROY); - trace_basic = xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_BASIC); + trace_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING); + trace_platform = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_PLATFORM); + trace_platform_topology = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_TOPOLOGY); + trace_smpi_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI); + trace_smpi_grouped = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI_GROUP); + trace_smpi_computing = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI_COMPUTING); + trace_categorized = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_CATEGORIZED); + trace_uncategorized = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_UNCATEGORIZED); + trace_msg_process_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_MSG_PROCESS); ++ trace_msg_vm_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_MSG_VM); + trace_buffer = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_BUFFER); + trace_onelink_only = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_ONELINK_ONLY); + trace_disable_destroy = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY); + trace_basic = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_BASIC); + } + + xbt_dynar_t TRACE_start_functions = NULL; + void TRACE_add_start_function(void (*func) ()) + { + if (TRACE_start_functions == NULL) + TRACE_start_functions = xbt_dynar_new(sizeof(void (*)()), NULL); + xbt_dynar_push(TRACE_start_functions, &func); } int TRACE_start() @@@ -75,67 -83,89 +86,91 @@@ // tracing system must be: // - enabled (with --cfg=tracing:1) // - already configured (TRACE_global_init already called) - if (!(TRACE_is_enabled() && TRACE_is_configured())){ - return 0; + if (TRACE_is_enabled() && TRACE_is_configured()) { + XBT_DEBUG("Tracing starts"); + + /* open the trace file */ + TRACE_paje_start(); + + /* activate trace */ + if (trace_active == 1) { + THROWF(tracing_error, 0, "Tracing is already active"); + } + trace_active = 1; + XBT_DEBUG("Tracing is on"); + + /* other trace initialization */ + created_categories = xbt_dict_new_homogeneous(xbt_free); + declared_marks = xbt_dict_new_homogeneous(xbt_free); + user_host_variables = xbt_dict_new_homogeneous(xbt_free); ++ user_vm_variables = xbt_dict_new_homogeneous (xbt_free); + user_link_variables = xbt_dict_new_homogeneous(xbt_free); + + if (TRACE_start_functions != NULL) { + void (*func) (); + unsigned int iter = xbt_dynar_length(TRACE_start_functions); + xbt_dynar_foreach(TRACE_start_functions, iter, func) { + func(); + } + } } - - XBT_DEBUG("Tracing starts"); - - /* open the trace file */ - TRACE_paje_start(); - - /* activate trace */ - if (trace_active == 1){ - THROWF (tracing_error, 0, "Tracing is already active"); - } - trace_active = 1; - XBT_DEBUG ("Tracing is on"); - - /* other trace initialization */ - created_categories = xbt_dict_new_homogeneous(xbt_free); - declared_marks = xbt_dict_new_homogeneous (xbt_free); - user_host_variables = xbt_dict_new_homogeneous (xbt_free); - user_vm_variables = xbt_dict_new_homogeneous (xbt_free); - user_link_variables = xbt_dict_new_homogeneous (xbt_free); - TRACE_surf_alloc(); - TRACE_smpi_alloc(); + xbt_dynar_free(&TRACE_start_functions); return 0; } + xbt_dynar_t TRACE_end_functions = NULL; + void TRACE_add_end_function(void (*func) (void)) + { + if (TRACE_end_functions == NULL) + TRACE_end_functions = xbt_dynar_new(sizeof(void (*)(void)), NULL); + xbt_dynar_push(TRACE_end_functions, &func); + } + int TRACE_end() { - if (!trace_active) - return 1; - - TRACE_generate_viva_uncat_conf(); - TRACE_generate_viva_cat_conf(); - - /* dump trace buffer */ - TRACE_last_timestamp_to_dump = surf_get_clock(); - TRACE_paje_dump_buffer(1); - - /* destroy all data structures of tracing (and free) */ - PJ_container_free_all(); - PJ_type_free_all(); - PJ_container_release(); - PJ_type_release(); - TRACE_smpi_release(); - TRACE_surf_release(); - xbt_dict_free(&user_link_variables); - xbt_dict_free(&user_host_variables); - xbt_dict_free(&user_vm_variables); - - xbt_dict_free(&declared_marks); - xbt_dict_free(&created_categories); - - /* close the trace file */ - TRACE_paje_end(); - - /* de-activate trace */ - trace_active = 0; - XBT_DEBUG ("Tracing is off"); - XBT_DEBUG("Tracing system is shutdown"); - return 0; + int retval; + if (!trace_active) { + retval = 1; + } else { + retval = 0; + + TRACE_generate_viva_uncat_conf(); + TRACE_generate_viva_cat_conf(); + + /* dump trace buffer */ + TRACE_last_timestamp_to_dump = surf_get_clock(); + TRACE_paje_dump_buffer(1); + + /* destroy all data structures of tracing (and free) */ + PJ_container_free_all(); + PJ_type_free_all(); + PJ_container_release(); + PJ_type_release(); + + if (TRACE_end_functions != NULL) { + void (*func) (void); + unsigned int iter; + xbt_dynar_foreach(TRACE_end_functions, iter, func) { + func(); + } + } + + xbt_dict_free(&user_link_variables); + xbt_dict_free(&user_host_variables); ++ xbt_dict_free(&user_vm_variables); + xbt_dict_free(&declared_marks); + xbt_dict_free(&created_categories); + + /* close the trace file */ + TRACE_paje_end(); + + /* de-activate trace */ + trace_active = 0; + XBT_DEBUG("Tracing is off"); + XBT_DEBUG("Tracing system is shutdown"); + } + xbt_dynar_free(&TRACE_end_functions); + return retval; } int TRACE_needs_platform (void) @@@ -323,16 -346,9 +358,16 @@@ void TRACE_global_init(int *argc, char xbt_cfgelm_int, &default_tracing_msg_process, 0, 1, NULL, NULL); + /* msg process */ + int default_tracing_msg_vm = 0; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_MSG_VM, ++ xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_MSG_VM, + "Tracing of MSG process behavior.", + xbt_cfgelm_int, &default_tracing_msg_vm, 0, 1, + NULL, NULL); + /* tracing buffer */ int default_buffer = 1; - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_BUFFER, + xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_BUFFER, "Buffer trace events to put them in temporal order.", xbt_cfgelm_int, &default_buffer, 0, 1, NULL, NULL); diff --cc src/msg/instr_msg_vm.c index afbd5287bf,0000000000..73581c5e83 mode 100644,000000..100644 --- a/src/msg/instr_msg_vm.c +++ b/src/msg/instr_msg_vm.c @@@ -1,144 -1,0 +1,144 @@@ +/* Copyright (c) 2012. 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 "msg_private.h" + +#ifdef HAVE_TRACING + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_vm, instr, "MSG VM"); + + +char *instr_vm_id (msg_vm_t vm, char *str, int len) +{ + return instr_vm_id_2 (vm->name, str, len); +} + +char *instr_vm_id_2 (const char *vm_name, char *str, int len) +{ + snprintf (str, len, "%s", vm_name); + return str; +} + +/* + * Instrumentation functions to trace MSG VMs (msg_vm_t) + */ +void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host, msg_host_t new_host) +{ + if (TRACE_msg_vm_is_enabled()){ + static long long int counter = 0; + char key[INSTR_DEFAULT_STR_SIZE]; + snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++); + + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + //start link + container_t msg = PJ_container_get (instr_vm_id(vm, str, len)); + type_t type = PJ_type_get ("MSG_VM_LINK", PJ_type_get_root()); + new_pajeStartLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); + + //destroy existing container of this vm + container_t existing_container = PJ_container_get(instr_vm_id(vm, str, len)); + PJ_container_remove_from_parent (existing_container); + PJ_container_free(existing_container); + + //create new container on the new_host location + msg = PJ_container_new(instr_vm_id(vm, str, len), INSTR_MSG_VM, PJ_container_get(SIMIX_host_get_name(new_host->smx_host))); + + //end link + msg = PJ_container_get(instr_vm_id(vm, str, len)); + type = PJ_type_get ("MSG_VM_LINK", PJ_type_get_root()); + new_pajeEndLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); + } +} + +void TRACE_msg_vm_create (const char *vm_name, msg_host_t host) +{ + if (TRACE_msg_vm_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t host_container = PJ_container_get (SIMIX_host_get_name(host->smx_host)); + PJ_container_new(instr_vm_id_2(vm_name, str, len), INSTR_MSG_VM, host_container); + } +} + +void TRACE_msg_vm_kill(msg_vm_t vm) { + if (TRACE_msg_vm_is_enabled()) { + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + //kill means that this vm no longer exists, let's destroy it + container_t process = PJ_container_get (instr_vm_id(vm, str, len)); + PJ_container_remove_from_parent (process); + PJ_container_free (process); + } +} + +void TRACE_msg_vm_suspend(msg_vm_t vm) +{ + if (TRACE_msg_vm_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len)); + type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type); + val_t value = PJ_value_get ("suspend", type); + new_pajePushState (MSG_get_clock(), vm_container, type, value); + } +} + +void TRACE_msg_vm_resume(msg_vm_t vm) +{ + if (TRACE_msg_vm_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len)); + type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type); + new_pajePopState (MSG_get_clock(), vm_container, type); + } +} + +void TRACE_msg_vm_sleep_in(msg_vm_t vm) +{ + if (TRACE_msg_vm_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len)); + type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type); + val_t value = PJ_value_get ("sleep", type); + new_pajePushState (MSG_get_clock(), vm_container, type, value); + } +} + +void TRACE_msg_vm_sleep_out(msg_vm_t vm) +{ + if (TRACE_msg_vm_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len)); + type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type); + new_pajePopState (MSG_get_clock(), vm_container, type); + } +} + +void TRACE_msg_vm_end(msg_vm_t vm) +{ + if (TRACE_msg_vm_is_enabled()) { + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + //that's the end, let's destroy it + container_t container = PJ_container_get (instr_vm_id(vm, str, len)); + PJ_container_remove_from_parent (container); + PJ_container_free (container); + } +} + +#endif /* HAVE_TRACING */ diff --cc src/msg/msg_private.h index 165371c6f4,6899c15b7b..7edcb02124 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@@ -155,5 -154,31 +155,44 @@@ void _MSG_action_exit(void) void MSG_post_create_environment(void); + /********** Tracing **********/ + /* declaration of instrumentation functions from msg_task_instr.c */ + void TRACE_msg_set_task_category(msg_task_t task, const char *category); + void TRACE_msg_task_create(msg_task_t task); + void TRACE_msg_task_execute_start(msg_task_t task); + void TRACE_msg_task_execute_end(msg_task_t task); + void TRACE_msg_task_destroy(msg_task_t task); + void TRACE_msg_task_get_start(void); + void TRACE_msg_task_get_end(double start_time, msg_task_t task); + int TRACE_msg_task_put_start(msg_task_t task); //returns TRUE if the task_put_end must be called + void TRACE_msg_task_put_end(void); + + /* declaration of instrumentation functions from msg_process_instr.c */ + char *instr_process_id (msg_process_t proc, char *str, int len); + char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len); + void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host, + msg_host_t new_host); + void TRACE_msg_process_create (const char *process_name, int process_pid, msg_host_t host); + void TRACE_msg_process_destroy (const char *process_name, int process_pid, msg_host_t host); + void TRACE_msg_process_kill(msg_process_t process); + void TRACE_msg_process_suspend(msg_process_t process); + void TRACE_msg_process_resume(msg_process_t process); + void TRACE_msg_process_sleep_in(msg_process_t process); //called from msg/gos.c + void TRACE_msg_process_sleep_out(msg_process_t process); + void TRACE_msg_process_end(msg_process_t process); + ++/* declaration of instrumentation functions from instr_msg_vm.c */ ++char *instr_vm_id (msg_vm_t vm, char *str, int len); ++char *instr_vm_id_2 (const char *vm_name, char *str, int len); ++void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host, ++ msg_host_t new_host); ++void TRACE_msg_vm_create (const char *vm_name, msg_host_t host); ++void TRACE_msg_vm_kill(msg_vm_t process); ++void TRACE_msg_vm_suspend(msg_vm_t vm); ++void TRACE_msg_vm_resume(msg_vm_t vm); ++void TRACE_msg_vm_sleep_in(msg_vm_t vm); ++void TRACE_msg_vm_sleep_out(msg_vm_t vm); ++void TRACE_msg_vm_end(msg_vm_t vm); ++ SG_END_DECL() #endif