From: jean-noel quintin Date: Tue, 21 Aug 2012 10:51:04 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/master' X-Git-Tag: v3_8~146^2~97 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6edd98218de9a7958d1f1a4396a2d460eac2593a?hp=b32b9b19e63ce9302c4d48657ac9d1aff0db041f Merge remote-tracking branch 'origin/master' --- diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 834000080e..a16e83ec90 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -356,6 +356,7 @@ set(TRACING_SRC src/instr/instr_msg_task.c src/instr/instr_paje_containers.c src/instr/instr_paje_trace.c + src/instr/instr_paje_header.c src/instr/instr_paje_types.c src/instr/instr_paje_values.c src/instr/instr_private.h diff --git a/examples/msg/bittorrent/CMakeLists.txt b/examples/msg/bittorrent/CMakeLists.txt index 2fdb8e0000..cada54a3c9 100644 --- a/examples/msg/bittorrent/CMakeLists.txt +++ b/examples/msg/bittorrent/CMakeLists.txt @@ -4,9 +4,12 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(bittorrent "bittorrent.c" "messages.c" "peer.c" "tracker.c" "connection.c") +add_executable(bittorrent_platfgen + "bittorrent_platfgen.c" "messages.c" "peer.c" "tracker.c" "connection.c") ### Add definitions for compile target_link_libraries(bittorrent simgrid ) +target_link_libraries(bittorrent_platfgen simgrid ) set(tesh_files ${tesh_files} @@ -21,6 +24,7 @@ set(xml_files set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/bittorrent.c + ${CMAKE_CURRENT_SOURCE_DIR}/bittorrent_platfgen.c ${CMAKE_CURRENT_SOURCE_DIR}/bittorrent.h ${CMAKE_CURRENT_SOURCE_DIR}/connection.c ${CMAKE_CURRENT_SOURCE_DIR}/connection.h diff --git a/examples/msg/bittorrent/bittorrent_platfgen.c b/examples/msg/bittorrent/bittorrent_platfgen.c new file mode 100644 index 0000000000..ff18530ff6 --- /dev/null +++ b/examples/msg/bittorrent/bittorrent_platfgen.c @@ -0,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 "bittorrent.h" +#include "peer.h" +#include "tracker.h" +#include +#include +/** + * Bittorrent example launcher, using a generated platform + */ + +static RngStream rng_stream; + +void promoter(context_node_t node); +void labeler(context_edge_t edge); +void create_environment(int node_count); +void dispatch_jobs(double tracker_deadline, double peer_deadline, double seed_percentage); + +void promoter(context_node_t node) { + s_sg_platf_host_cbarg_t host_parameters; + + if(node->degree == 1) { + //We promote only the leaf; as we use a star topology, all the nodes + //will be promoted except the first one, which will be a router with + //every hosts connected on. + host_parameters.id = NULL; + + //Power from 3,000,000 to 10,000,000 + host_parameters.power_peak = 7000000 * RngStream_RandU01(rng_stream) + 3000000; + host_parameters.core_amount = 1; + host_parameters.power_scale = 1; + host_parameters.power_trace = NULL; + host_parameters.initial_state = SURF_RESOURCE_ON; + host_parameters.state_trace = NULL; + host_parameters.coord = NULL; + host_parameters.properties = NULL; + + platf_graph_promote_to_host(node, &host_parameters); + } +} + +void labeler(context_edge_t edge) { + + s_sg_platf_link_cbarg_t link_parameters; + link_parameters.id = NULL; + + //bandwidth from 3,000,000 to 10,000,000 + link_parameters.bandwidth = 7000000 * RngStream_RandU01(rng_stream) + 3000000; + link_parameters.bandwidth_trace = NULL; + + //Latency from 0ms to 100ms + link_parameters.latency = RngStream_RandU01(rng_stream) / 10.0; + link_parameters.latency_trace = NULL; + link_parameters.state = SURF_RESOURCE_ON; + link_parameters.state_trace = NULL; + link_parameters.policy = SURF_LINK_SHARED; + link_parameters.properties = NULL; + + platf_graph_link_label(edge, &link_parameters); +} + +void create_environment(int node_count) { + + platf_graph_uniform(node_count); + + //every nodes are connected to the first one + platf_graph_interconnect_star(); + //No need to check if the graph is connected, the star topology implies it. + + //register promoter and labeler + platf_graph_promoter(promoter); + platf_graph_labeler(labeler); + + //promoting and labeling + platf_do_promote(); + platf_do_label(); + + //Put the platform into the simulator + platf_generate(); +} + +void dispatch_jobs(double tracker_deadline, double peer_deadline, double seed_percentage) { + + xbt_dynar_t available_nodes = MSG_hosts_as_dynar(); + msg_host_t host; + unsigned int i; + + char** arguments_tracker; + char** arguments_peer; + + unsigned int seed_count = (seed_percentage/100.0) * xbt_dynar_length(available_nodes); + + xbt_dynar_foreach(available_nodes, i, host) { + if(i==0) { + //The fisrt node is the tracker + arguments_tracker = xbt_malloc0(sizeof(char*) * 2); + arguments_tracker[0] = bprintf("tracker"); + arguments_tracker[1] = bprintf("%f", tracker_deadline); + MSG_process_create_with_arguments("tracker", tracker, NULL, host, 2, arguments_tracker); + } else { + //Other nodes are peers + int argument_size; + arguments_peer = xbt_malloc0(sizeof(char*) * 4); + arguments_peer[0] = bprintf("peer"); + arguments_peer[1] = bprintf("%d", i); + arguments_peer[2] = bprintf("%f", peer_deadline); + + //The first peers will be seeders + if(seed_count > 0) { + seed_count--; + arguments_peer[3] = bprintf("1"); + argument_size = 4; + } else { + //Other ars leechers + arguments_peer[3] = NULL; + argument_size = 3; + } + MSG_process_create_with_arguments("peer", peer, NULL, host, argument_size, arguments_peer); + } + } +} + +int main(int argc, char *argv[]) +{ + MSG_init(&argc, argv); + + rng_stream = RngStream_CreateStream(NULL); + + //Maybe these parameters should be set from the command line... + //create_environment() + create_environment(20); + + //dispatch_jobs(, , ) + dispatch_jobs(2000, 2000, 10); + + MSG_main(); + + MSG_clean(); + + return 0; +} diff --git a/examples/msg/masterslave/CMakeLists.txt b/examples/msg/masterslave/CMakeLists.txt index 44ed1b670f..e68e0da4c0 100644 --- a/examples/msg/masterslave/CMakeLists.txt +++ b/examples/msg/masterslave/CMakeLists.txt @@ -11,6 +11,7 @@ add_executable(masterslave_cluster "masterslave_cluster.c") add_executable(masterslave_kill "masterslave_kill.c") add_executable(masterslave_arg "masterslave_arg.c") add_executable(masterslave_platfgen "masterslave_platfgen.c") +add_executable(masterslave_failure_platfgen "masterslave_failure_platfgen.c") ### Add definitions for compile if(WIN32) @@ -22,6 +23,7 @@ if(WIN32) target_link_libraries(masterslave_kill simgrid ) target_link_libraries(masterslave_arg simgrid ) target_link_libraries(masterslave_platfgen simgrid ) + target_link_libraries(masterslave_failure_platfgen simgrid ) else(WIN32) target_link_libraries(masterslave_forwarder simgrid m ) target_link_libraries(masterslave_failure simgrid m ) @@ -31,6 +33,7 @@ else(WIN32) target_link_libraries(masterslave_kill simgrid m ) target_link_libraries(masterslave_arg simgrid m ) target_link_libraries(masterslave_platfgen simgrid m ) + target_link_libraries(masterslave_failure_platfgen simgrid m ) endif(WIN32) target_link_libraries(masterslave_cluster simgrid) @@ -77,6 +80,7 @@ set(examples_src ${CMAKE_CURRENT_SOURCE_DIR}/masterslave_kill.c ${CMAKE_CURRENT_SOURCE_DIR}/masterslave_mailbox.c ${CMAKE_CURRENT_SOURCE_DIR}/masterslave_platfgen.c + ${CMAKE_CURRENT_SOURCE_DIR}/masterslave_failure_platfgen.c PARENT_SCOPE ) set(bin_files diff --git a/examples/msg/masterslave/masterslave_failure_platfgen.c b/examples/msg/masterslave/masterslave_failure_platfgen.c new file mode 100644 index 0000000000..8194e32062 --- /dev/null +++ b/examples/msg/masterslave/masterslave_failure_platfgen.c @@ -0,0 +1,348 @@ +/* Copyright (c) 2007, 2008, 2009, 2010. 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 +#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */ +#include "xbt/sysdep.h" /* calloc, printf */ + +/* Create a log channel to have nice outputs. */ +#include "xbt/log.h" +#include "xbt/asserts.h" + +/* we are going to use a generated platform */ +#include "simgrid/platf_generator.h" +#include "simgrid/platf_interface.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, + "Messages specific for this msg example"); + +int master(int argc, char *argv[]); +int slave(int argc, char *argv[]); +void promoter_1(context_node_t node); +void labeler_1(context_edge_t edge); + +#define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */ + +#define TASK_COUNT_PER_HOST 5 /* Number of tasks each slave has to do */ +#define TASK_COMP_SIZE 15000000 /* computation cost of each task */ +#define TASK_COMM_SIZE 1200000 /* communication time of task */ + +/** Promoter function + * Just promote each node into a host, with fixed power + * Set one node as master + * Add a state trace on other nodes + */ +void promoter_1(context_node_t node) { + + s_sg_platf_host_cbarg_t host_parameters; + static int master_choosen = FALSE; + + host_parameters.id = NULL; + host_parameters.power_peak = 1000000; + + host_parameters.core_amount = 1; + host_parameters.power_scale = 1; + host_parameters.power_trace = NULL; + host_parameters.initial_state = SURF_RESOURCE_ON; + host_parameters.state_trace = NULL; + host_parameters.coord = NULL; + host_parameters.properties = NULL; + + if(!master_choosen) { + master_choosen = TRUE; + host_parameters.id = "host_master"; + } else { + /* + * The bug #14699 cannot allow us to set up an event trace which + * begin by SURF_RESOURCE_OFF, otherwise, the host will be down at startup + * and the associate process will fail to start. So, here, we generate a + * first useless event. + */ + //Set a availability trace for the node + char* generator_id = bprintf("state_host_%ld", node->id); + probabilist_event_generator_t date_generator = + tmgr_event_generator_new_weibull(generator_id, 80, 1.5); + host_parameters.state_trace = tmgr_trace_generator_state(generator_id, + date_generator, + SURF_RESOURCE_ON); + + //Set a power trace + char* pw_date_generator_id = bprintf("pw_date_host_%ld", node->id); + char* pw_value_generator_id = bprintf("pw_value_host_%ld", node->id); + probabilist_event_generator_t pw_date_generator = + tmgr_event_generator_new_uniform(pw_date_generator_id, 5, 10); + probabilist_event_generator_t pw_value_generator = + tmgr_event_generator_new_uniform(pw_value_generator_id, 0.6, 1.0); + host_parameters.power_trace = + tmgr_trace_generator_value(bprintf("pw_host_%ld", node->id), + pw_date_generator, + pw_value_generator); + } + + platf_graph_promote_to_host(node, &host_parameters); + +} + +/** Labeler function + * Set all links with the same bandwidth and latency + * Add a state trace to each link + */ +void labeler_1(context_edge_t edge) { + s_sg_platf_link_cbarg_t link_parameters; + link_parameters.id = NULL; + link_parameters.bandwidth = 100000000; + link_parameters.bandwidth_trace = NULL; + link_parameters.latency = 0.01; + link_parameters.latency_trace = NULL; + link_parameters.state = SURF_RESOURCE_ON; + link_parameters.state_trace = NULL; + link_parameters.policy = SURF_LINK_SHARED; + link_parameters.properties = NULL; + + char* avail_generator_id = bprintf("avail_link_%ld", edge->id); + char* unavail_generator_id = bprintf("unavail_link_%ld", edge->id); + + probabilist_event_generator_t avail_generator = + tmgr_event_generator_new_exponential(avail_generator_id, 0.0001); + probabilist_event_generator_t unavail_generator = + tmgr_event_generator_new_uniform(unavail_generator_id, 10, 20); + + link_parameters.state_trace = + tmgr_trace_generator_avail_unavail(bprintf("state_link_%ld", edge->id), + avail_generator, + unavail_generator, + SURF_RESOURCE_ON); + + + platf_graph_link_label(edge, &link_parameters); + +} + +/** Emitter function */ +int master(int argc, char *argv[]) +{ + int slaves_count = 0; + msg_host_t *slaves = NULL; + int number_of_tasks = 0; + double task_comp_size = 0; + double task_comm_size = 0; + int i; + _XBT_GNUC_UNUSED int read; + + number_of_tasks = TASK_COUNT_PER_HOST*argc; + task_comp_size = TASK_COMP_SIZE; + task_comm_size = TASK_COMM_SIZE; + + { /* Process organisation */ + slaves_count = argc; + slaves = xbt_new0(msg_host_t, slaves_count); + + for (i = 0; i < argc; i++) { + slaves[i] = MSG_get_host_by_name(argv[i]); + if (slaves[i] == NULL) { + XBT_INFO("Unknown host %s. Stopping Now! ", argv[i]); + abort(); + } + } + } + + XBT_INFO("Got %d slave(s) :", slaves_count); + for (i = 0; i < slaves_count; i++) + XBT_INFO("%s", MSG_host_get_name(slaves[i])); + + XBT_INFO("Got %d task to process :", number_of_tasks); + + for (i = 0; i < number_of_tasks; i++) { + msg_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, + xbt_new0(double, 1)); + int a; + *((double *) task->data) = MSG_get_clock(); + + a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i % slaves_count]),10.0); + + if (a == MSG_OK) { + XBT_INFO("Send completed"); + } else if (a == MSG_HOST_FAILURE) { + XBT_INFO + ("Gloups. The cpu on which I'm running just turned off!. See you!"); + free(task->data); + MSG_task_destroy(task); + free(slaves); + return 0; + } else if (a == MSG_TRANSFER_FAILURE) { + XBT_INFO + ("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", + MSG_host_get_name(slaves[i % slaves_count])); + free(task->data); + MSG_task_destroy(task); + } else if (a == MSG_TIMEOUT) { + XBT_INFO + ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", + MSG_host_get_name(slaves[i % slaves_count])); + free(task->data); + MSG_task_destroy(task); + } else { + XBT_INFO("Hey ?! What's up ? "); + xbt_die( "Unexpected behavior"); + } + } + + XBT_INFO + ("All tasks have been dispatched. Let's tell everybody the computation is over."); + for (i = 0; i < slaves_count; i++) { + msg_task_t task = MSG_task_create("finalize", 0, 0, FINALIZE); + int a = MSG_task_send_with_timeout(task,MSG_host_get_name(slaves[i]),1.0); + if (a == MSG_OK) + continue; + if (a == MSG_HOST_FAILURE) { + XBT_INFO + ("Gloups. The cpu on which I'm running just turned off!. See you!"); + MSG_task_destroy(task); + free(slaves); + return 0; + } else if (a == MSG_TRANSFER_FAILURE) { + XBT_INFO("Mmh. Can't reach '%s'! Nevermind. Let's keep going!", + MSG_host_get_name(slaves[i])); + MSG_task_destroy(task); + } else if (a == MSG_TIMEOUT) { + XBT_INFO + ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", + MSG_host_get_name(slaves[i % slaves_count])); + MSG_task_destroy(task); + } else { + XBT_INFO("Hey ?! What's up ? "); + xbt_die("Unexpected behavior with '%s': %d", MSG_host_get_name(slaves[i]), a); + } + } + + XBT_INFO("Goodbye now!"); + free(slaves); + return 0; +} /* end_of_master */ + +/** Receiver function */ +int slave(int argc, char *argv[]) +{ + while (1) { + msg_task_t task = NULL; + int a; + double time1, time2; + + time1 = MSG_get_clock(); + a = MSG_task_receive( &(task), MSG_host_get_name(MSG_host_self()) ); + time2 = MSG_get_clock(); + if (a == MSG_OK) { + XBT_INFO("Received \"%s\"", MSG_task_get_name(task)); + if (MSG_task_get_data(task) == FINALIZE) { + MSG_task_destroy(task); + break; + } + if (time1 < *((double *) task->data)) + time1 = *((double *) task->data); + XBT_INFO("Communication time : \"%f\"", time2 - time1); + XBT_INFO("Processing \"%s\"", MSG_task_get_name(task)); + a = MSG_task_execute(task); + if (a == MSG_OK) { + XBT_INFO("\"%s\" done", MSG_task_get_name(task)); + free(task->data); + MSG_task_destroy(task); + } else if (a == MSG_HOST_FAILURE) { + XBT_INFO + ("Gloups. The cpu on which I'm running just turned off!. See you!"); + return 0; + } else { + XBT_INFO("Hey ?! What's up ? "); + xbt_die("Unexpected behavior"); + } + } else if (a == MSG_HOST_FAILURE) { + XBT_INFO + ("Gloups. The cpu on which I'm running just turned off!. See you!"); + return 0; + } else if (a == MSG_TRANSFER_FAILURE) { + XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!"); + } else if (a == MSG_TIMEOUT) { + XBT_INFO("Mmh. Got a timeout. Nevermind. Let's keep going!"); + } else { + XBT_INFO("Hey ?! What's up ? "); + xbt_die("Unexpected behavior"); + } + } + XBT_INFO("I'm done. See you!"); + return 0; +} /* end_of_slave */ + +/** Main function */ +int main(int argc, char *argv[]) +{ + msg_error_t res = MSG_OK; + unsigned long seed_platf_gen[] = {134, 233445, 865, 2634, 424242, 876543}; + unsigned long seed_trace_gen[] = {8865244, 356772, 42, 77465, 2098754, 8725442}; + int connected; + int max_tries = 10; + + //MSG initialisation + MSG_init(&argc, argv); + + //Set up the seed for the platform generation + platf_random_seed(seed_platf_gen); + + //Set up the RngStream for trace generation + sg_platf_rng_stream_init(seed_trace_gen); + + XBT_INFO("creating nodes..."); + platf_graph_uniform(10); + + do { + max_tries--; + XBT_INFO("creating links..."); + platf_graph_clear_links(); + platf_graph_interconnect_waxman(0.9, 0.4); + XBT_INFO("done. Check connectedness..."); + connected = platf_graph_is_connected(); + XBT_INFO("Is it connected : %s", connected ? "yes" : (max_tries ? "no, retrying" : "no")); + } while(!connected && max_tries); + + if(!connected && !max_tries) { + xbt_die("Impossible to connect the graph, aborting."); + } + + XBT_INFO("registering callbacks..."); + platf_graph_promoter(promoter_1); + platf_graph_labeler(labeler_1); + + XBT_INFO("protmoting..."); + platf_do_promote(); + + XBT_INFO("labeling..."); + platf_do_label(); + + XBT_INFO("Putting it in surf..."); + platf_generate(); + + XBT_INFO("Let's get the available hosts and dispatch work:"); + + unsigned int i; + msg_host_t host = NULL; + msg_host_t host_master = NULL; + msg_process_t process = NULL; + xbt_dynar_t host_dynar = MSG_hosts_as_dynar(); + char** hostname_list = malloc(sizeof(char*) * xbt_dynar_length(host_dynar)); + + xbt_dynar_foreach(host_dynar, i, host) { + process = MSG_process_create("slave", slave, NULL, host); + MSG_process_auto_restart_set(process, TRUE); + hostname_list[i] = (char*) MSG_host_get_name(host); + } + host_master = MSG_get_host_by_name("host_master"); + MSG_process_create_with_arguments("master", master, NULL, host_master, xbt_dynar_length(host_dynar), hostname_list); + + res = MSG_main(); + + if (res == MSG_OK) + return 0; + else + return 1; +} /* end_of_main */ diff --git a/examples/msg/masterslave/masterslave_platfgen.c b/examples/msg/masterslave/masterslave_platfgen.c index f3a932cc0f..e26fb1d802 100644 --- a/examples/msg/masterslave/masterslave_platfgen.c +++ b/examples/msg/masterslave/masterslave_platfgen.c @@ -182,8 +182,8 @@ int main(int argc, char **argv) { max_tries--; XBT_INFO("creating links..."); platf_graph_clear_links(); - platf_graph_interconnect_uniform(0.15); //Unrealistic, but simple - XBT_INFO("done. Check connectivity..."); + platf_graph_interconnect_uniform(0.07); //Unrealistic, but simple + XBT_INFO("done. Check connectedness..."); connected = platf_graph_is_connected(); XBT_INFO("Is it connected : %s", connected ? "yes" : (max_tries ? "no, retrying" : "no")); } while(!connected && max_tries); diff --git a/examples/msg/tracing/trace_platform.tesh b/examples/msg/tracing/trace_platform.tesh index dd577e590f..a8cc29e977 100644 --- a/examples/msg/tracing/trace_platform.tesh +++ b/examples/msg/tracing/trace_platform.tesh @@ -6,113 +6,113 @@ $ $SG_TEST_EXENV ${bindir:=.}/tracing/trace_platform$EXEEXT --cfg=tracing:1 --cf > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to '1' $ cat simgrid.trace -> %EventDef PajeDefineContainerType 0 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineVariableType 1 -> % Alias string -> % Type string -> % Name string -> % Color color -> %EndEventDef -> %EventDef PajeDefineStateType 2 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineEventType 3 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineLinkType 4 -> % Alias string -> % Type string -> % StartContainerType string -> % EndContainerType string -> % Name string -> %EndEventDef -> %EventDef PajeDefineEntityValue 5 -> % Alias string -> % Type string -> % Name string -> % Color color -> %EndEventDef -> %EventDef PajeCreateContainer 6 -> % Time date -> % Alias string -> % Type string -> % Container string -> % Name string -> %EndEventDef -> %EventDef PajeDestroyContainer 7 -> % Time date -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeSetVariable 8 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeDefineContainerType 0 +> % Alias string +> % Type string +> % Name string > %EndEventDef -> %EventDef PajeAddVariable 9 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeDefineVariableType 1 +> % Alias string +> % Type string +> % Name string +> % Color string > %EndEventDef -> %EventDef PajeSubVariable 10 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeDefineStateType 2 +> % Alias string +> % Type string +> % Name string > %EndEventDef -> %EventDef PajeSetState 11 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajeDefineEventType 3 +> % Alias string +> % Type string +> % Name string > %EndEventDef -> %EventDef PajePushState 12 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajeDefineLinkType 4 +> % Alias string +> % Type string +> % StartContainerType string +> % EndContainerType string +> % Name string > %EndEventDef -> %EventDef PajePopState 13 -> % Time date -> % Type string -> % Container string +> %EventDef PajeDefineEntityValue 5 +> % Alias string +> % Type string +> % Name string +> % Color string > %EndEventDef -> %EventDef PajeResetState 14 -> % Time date -> % Type string -> % Container string +> %EventDef PajeCreateContainer 6 +> % Time date +> % Alias string +> % Type string +> % Container string +> % Name string > %EndEventDef -> %EventDef PajeStartLink 15 -> % Time date -> % Type string -> % Container string -> % Value string -> % StartContainer string -> % Key string +> %EventDef PajeDestroyContainer 7 +> % Time date +> % Type string +> % Name string > %EndEventDef -> %EventDef PajeEndLink 16 -> % Time date -> % Type string -> % Container string -> % Value string -> % EndContainer string -> % Key string +> %EventDef PajeSetVariable 8 +> % Time date +> % Type string +> % Container string +> % Value double > %EndEventDef -> %EventDef PajeNewEvent 17 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajeAddVariable 9 +> % Time date +> % Type string +> % Container string +> % Value double +> %EndEventDef +> %EventDef PajeSubVariable 10 +> % Time date +> % Type string +> % Container string +> % Value double +> %EndEventDef +> %EventDef PajeSetState 11 +> % Time date +> % Type string +> % Container string +> % Value string +> %EndEventDef +> %EventDef PajePushState 12 +> % Time date +> % Type string +> % Container string +> % Value string +> %EndEventDef +> %EventDef PajePopState 13 +> % Time date +> % Type string +> % Container string +> %EndEventDef +> %EventDef PajeResetState 14 +> % Time date +> % Type string +> % Container string +> %EndEventDef +> %EventDef PajeStartLink 15 +> % Time date +> % Type string +> % Container string +> % Value string +> % StartContainer string +> % Key string +> %EndEventDef +> %EventDef PajeEndLink 16 +> % Time date +> % Type string +> % Container string +> % Value string +> % EndContainer string +> % Key string +> %EndEventDef +> %EventDef PajeNewEvent 17 +> % Time date +> % Type string +> % Container string +> % Value string > %EndEventDef > 0 1 0 HOST > 6 0 1 1 0 "Tremblay" @@ -217,113 +217,113 @@ $ $SG_TEST_EXENV ${bindir:=.}/tracing/trace_platform$EXEEXT --cfg=tracing:1 --cf > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to '1' $ cat simgrid.trace -> %EventDef PajeDefineContainerType 0 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineVariableType 1 -> % Alias string -> % Type string -> % Name string -> % Color color -> %EndEventDef -> %EventDef PajeDefineStateType 2 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineEventType 3 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineLinkType 4 -> % Alias string -> % Type string -> % StartContainerType string -> % EndContainerType string -> % Name string -> %EndEventDef -> %EventDef PajeDefineEntityValue 5 -> % Alias string -> % Type string -> % Name string -> % Color color -> %EndEventDef -> %EventDef PajeCreateContainer 6 -> % Time date -> % Alias string -> % Type string -> % Container string -> % Name string -> %EndEventDef -> %EventDef PajeDestroyContainer 7 -> % Time date -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeSetVariable 8 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeDefineContainerType 0 +> % Alias string +> % Type string +> % Name string +> %EndEventDef +> %EventDef PajeDefineVariableType 1 +> % Alias string +> % Type string +> % Name string +> % Color string +> %EndEventDef +> %EventDef PajeDefineStateType 2 +> % Alias string +> % Type string +> % Name string +> %EndEventDef +> %EventDef PajeDefineEventType 3 +> % Alias string +> % Type string +> % Name string +> %EndEventDef +> %EventDef PajeDefineLinkType 4 +> % Alias string +> % Type string +> % StartContainerType string +> % EndContainerType string +> % Name string +> %EndEventDef +> %EventDef PajeDefineEntityValue 5 +> % Alias string +> % Type string +> % Name string +> % Color string +> %EndEventDef +> %EventDef PajeCreateContainer 6 +> % Time date +> % Alias string +> % Type string +> % Container string +> % Name string +> %EndEventDef +> %EventDef PajeDestroyContainer 7 +> % Time date +> % Type string +> % Name string +> %EndEventDef +> %EventDef PajeSetVariable 8 +> % Time date +> % Type string +> % Container string +> % Value double > %EndEventDef -> %EventDef PajeAddVariable 9 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeAddVariable 9 +> % Time date +> % Type string +> % Container string +> % Value double > %EndEventDef -> %EventDef PajeSubVariable 10 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeSubVariable 10 +> % Time date +> % Type string +> % Container string +> % Value double > %EndEventDef -> %EventDef PajeSetState 11 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajeSetState 11 +> % Time date +> % Type string +> % Container string +> % Value string > %EndEventDef -> %EventDef PajePushState 12 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajePushState 12 +> % Time date +> % Type string +> % Container string +> % Value string > %EndEventDef -> %EventDef PajePopState 13 -> % Time date -> % Type string -> % Container string +> %EventDef PajePopState 13 +> % Time date +> % Type string +> % Container string > %EndEventDef -> %EventDef PajeResetState 14 -> % Time date -> % Type string -> % Container string +> %EventDef PajeResetState 14 +> % Time date +> % Type string +> % Container string > %EndEventDef -> %EventDef PajeStartLink 15 -> % Time date -> % Type string -> % Container string -> % Value string -> % StartContainer string -> % Key string +> %EventDef PajeStartLink 15 +> % Time date +> % Type string +> % Container string +> % Value string +> % StartContainer string +> % Key string > %EndEventDef -> %EventDef PajeEndLink 16 -> % Time date -> % Type string -> % Container string -> % Value string -> % EndContainer string -> % Key string +> %EventDef PajeEndLink 16 +> % Time date +> % Type string +> % Container string +> % Value string +> % EndContainer string +> % Key string > %EndEventDef -> %EventDef PajeNewEvent 17 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajeNewEvent 17 +> % Time date +> % Type string +> % Container string +> % Value string > %EndEventDef > 0 1 0 L1 > 6 0 1 1 0 "AS_interne" diff --git a/examples/platforms/conf/gridpp_grid_2004.xml b/examples/platforms/conf/gridpp_grid_2004.xml index d8beea25f0..d7a79173fd 100644 --- a/examples/platforms/conf/gridpp_grid_2004.xml +++ b/examples/platforms/conf/gridpp_grid_2004.xml @@ -1,3 +1,14 @@ + + diff --git a/examples/simdag/test_simdag_tracing.tesh b/examples/simdag/test_simdag_tracing.tesh index 10042994cc..3b68a11f8d 100644 --- a/examples/simdag/test_simdag_tracing.tesh +++ b/examples/simdag/test_simdag_tracing.tesh @@ -18,113 +18,113 @@ $ $SG_TEST_EXENV ./simdag_tracing --cfg=tracing:1 --cfg=tracing/categorized:1 ${ > [30.800300] [sd_seq_access/INFO] There is no task running on C2-06 $ cat ./simgrid.trace -> %EventDef PajeDefineContainerType 0 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineVariableType 1 -> % Alias string -> % Type string -> % Name string -> % Color color -> %EndEventDef -> %EventDef PajeDefineStateType 2 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineEventType 3 -> % Alias string -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeDefineLinkType 4 -> % Alias string -> % Type string -> % StartContainerType string -> % EndContainerType string -> % Name string -> %EndEventDef -> %EventDef PajeDefineEntityValue 5 -> % Alias string -> % Type string -> % Name string -> % Color color -> %EndEventDef -> %EventDef PajeCreateContainer 6 -> % Time date -> % Alias string -> % Type string -> % Container string -> % Name string -> %EndEventDef -> %EventDef PajeDestroyContainer 7 -> % Time date -> % Type string -> % Name string -> %EndEventDef -> %EventDef PajeSetVariable 8 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeDefineContainerType 0 +> % Alias string +> % Type string +> % Name string > %EndEventDef -> %EventDef PajeAddVariable 9 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeDefineVariableType 1 +> % Alias string +> % Type string +> % Name string +> % Color string > %EndEventDef -> %EventDef PajeSubVariable 10 -> % Time date -> % Type string -> % Container string -> % Value double +> %EventDef PajeDefineStateType 2 +> % Alias string +> % Type string +> % Name string > %EndEventDef -> %EventDef PajeSetState 11 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajeDefineEventType 3 +> % Alias string +> % Type string +> % Name string > %EndEventDef -> %EventDef PajePushState 12 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajeDefineLinkType 4 +> % Alias string +> % Type string +> % StartContainerType string +> % EndContainerType string +> % Name string > %EndEventDef -> %EventDef PajePopState 13 -> % Time date -> % Type string -> % Container string +> %EventDef PajeDefineEntityValue 5 +> % Alias string +> % Type string +> % Name string +> % Color string > %EndEventDef -> %EventDef PajeResetState 14 -> % Time date -> % Type string -> % Container string +> %EventDef PajeCreateContainer 6 +> % Time date +> % Alias string +> % Type string +> % Container string +> % Name string > %EndEventDef -> %EventDef PajeStartLink 15 -> % Time date -> % Type string -> % Container string -> % Value string -> % StartContainer string -> % Key string +> %EventDef PajeDestroyContainer 7 +> % Time date +> % Type string +> % Name string > %EndEventDef -> %EventDef PajeEndLink 16 -> % Time date -> % Type string -> % Container string -> % Value string -> % EndContainer string -> % Key string +> %EventDef PajeSetVariable 8 +> % Time date +> % Type string +> % Container string +> % Value double > %EndEventDef -> %EventDef PajeNewEvent 17 -> % Time date -> % Type string -> % Container string -> % Value string +> %EventDef PajeAddVariable 9 +> % Time date +> % Type string +> % Container string +> % Value double +> %EndEventDef +> %EventDef PajeSubVariable 10 +> % Time date +> % Type string +> % Container string +> % Value double +> %EndEventDef +> %EventDef PajeSetState 11 +> % Time date +> % Type string +> % Container string +> % Value string +> %EndEventDef +> %EventDef PajePushState 12 +> % Time date +> % Type string +> % Container string +> % Value string +> %EndEventDef +> %EventDef PajePopState 13 +> % Time date +> % Type string +> % Container string +> %EndEventDef +> %EventDef PajeResetState 14 +> % Time date +> % Type string +> % Container string +> %EndEventDef +> %EventDef PajeStartLink 15 +> % Time date +> % Type string +> % Container string +> % Value string +> % StartContainer string +> % Key string +> %EndEventDef +> %EventDef PajeEndLink 16 +> % Time date +> % Type string +> % Container string +> % Value string +> % EndContainer string +> % Key string +> %EndEventDef +> %EventDef PajeNewEvent 17 +> % Time date +> % Type string +> % Container string +> % Value string > %EndEventDef > 0 1 0 HOST > 6 0 1 1 0 "C2-06" diff --git a/examples/smpi/tracing/smpi_traced.tesh b/examples/smpi/tracing/smpi_traced.tesh index 5a22819cf7..ac93a4542d 100644 --- a/examples/smpi/tracing/smpi_traced.tesh +++ b/examples/smpi/tracing/smpi_traced.tesh @@ -56,7 +56,7 @@ $ ../../bin/smpirun -trace -trace-resource -trace-triva -trace-file smpi_traced. > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'triva/categorized' to 'smpi_cat.plist' > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'triva/uncategorized' to 'smpi_uncat.plist' > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s) -> [1.003981] [instr_config/INFO] No categories declared, ignoring generation of triva graph configuration +> [0.013981] [instr_config/INFO] No categories declared, ignoring generation of triva graph configuration p Testing with parameters but without activating them with the safe switch (-trace) $ ../../bin/smpirun -trace-resource -trace-triva -trace-file smpi_traced.trace -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../msg/tracing/platform.xml -np 3 ./smpi_traced_simple diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 652332fe8b..31851b4fc8 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -15,31 +15,6 @@ typedef struct s_routing_edge *sg_routing_edge_t; XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name); - - -typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */ - -/** opaque structure defining a event generator for availability based on a probability distribution */ -typedef struct probabilist_event_generator *probabilist_event_generator_t; - -XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename); -XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id, - const char *input, - double periodicity); -XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_generator(const char *id, - probabilist_event_generator_t generator1, - probabilist_event_generator_t generator2, - int is_state_trace); - -XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id, - double min, - double max); -XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id, - double rate); -XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id, - double scale, - double shape); - /** Defines whether a given resource is working or not */ typedef enum { SURF_RESOURCE_ON = 1, /**< Up & ready */ @@ -65,6 +40,37 @@ typedef enum { SURF_PROCESS_ON_FAILURE_RESTART = 0 } e_surf_process_on_failure_t; + +typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */ + +/** opaque structure defining a event generator for availability based on a probability distribution */ +typedef struct probabilist_event_generator *probabilist_event_generator_t; + +XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename); +XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id, + const char *input, + double periodicity); + +XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_value(const char *id, + probabilist_event_generator_t date_generator, + probabilist_event_generator_t value_generator); +XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_state(const char *id, + probabilist_event_generator_t date_generator, + e_surf_resource_state_t first_event_value); +XBT_PUBLIC(tmgr_trace_t) tmgr_trace_generator_avail_unavail(const char *id, + probabilist_event_generator_t avail_duration_generator, + probabilist_event_generator_t unavail_duration_generator, + e_surf_resource_state_t first_event_value); + +XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_uniform(const char* id, + double min, + double max); +XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(const char* id, + double rate); +XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id, + double scale, + double shape); + /* * Platform creation functions. Instead of passing 123 arguments to the creation functions * (one for each possible XML attribute), we pass structures containing them all. It removes the diff --git a/src/instr/instr_config.c b/src/instr/instr_config.c index 089bfea2ad..40ad2bfd7c 100644 --- a/src/instr/instr_config.c +++ b/src/instr/instr_config.c @@ -23,6 +23,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration"); #define OPT_TRACING_BUFFER "tracing/buffer" #define OPT_TRACING_ONELINK_ONLY "tracing/onelink_only" #define OPT_TRACING_DISABLE_DESTROY "tracing/disable_destroy" +#define OPT_TRACING_BASIC "tracing/basic" #define OPT_TRIVA_UNCAT_CONF "triva/uncategorized" #define OPT_TRIVA_CAT_CONF "triva/categorized" #define OPT_VIVA_UNCAT_CONF "viva/uncategorized" @@ -38,6 +39,7 @@ static int trace_msg_process_enabled; static int trace_buffer; static int trace_onelink_only; static int trace_disable_destroy; +static int trace_basic; static int trace_configured = 0; static int trace_active = 0; @@ -54,6 +56,7 @@ static void TRACE_getopts(void) 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); } int TRACE_start() @@ -190,6 +193,12 @@ int TRACE_disable_destroy (void) return trace_disable_destroy && TRACE_is_enabled(); } +int TRACE_basic (void) +{ + return trace_basic && TRACE_is_enabled(); +} + + char *TRACE_get_filename(void) { return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_FILENAME); @@ -295,6 +304,13 @@ void TRACE_global_init(int *argc, char **argv) xbt_cfgelm_int, &default_disable_destroy, 0, 1, NULL, NULL); + /* basic -- Avoid extended events (impoverished trace file) */ + int default_basic = 0; + xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_BASIC, + "Avoid extended events (impoverished trace file).", + xbt_cfgelm_int, &default_basic, 0, 1, + NULL, NULL); + /* Triva graph configuration for uncategorized tracing */ char *default_triva_uncat_conf_file = xbt_strdup (""); xbt_cfg_register(&_surf_cfg_set, OPT_TRIVA_UNCAT_CONF, @@ -397,6 +413,12 @@ void TRACE_help (int detailed) " used with simulators that have a different notion of time (different from\n" " the simulated time).", detailed); + print_line (OPT_TRACING_BASIC, "Avoid extended events (impoverished trace file).", + " Some visualization tools are not able to parse correctly the Paje file format.\n" + " Use this option if you are using one of these tools to visualize the simulation\n" + " trace. Keep in mind that the trace might be incomplete, without all the\n" + " information that would be registered otherwise.", + detailed); print_line (OPT_TRIVA_UNCAT_CONF, "Generate graph configuration for Triva", " This option can be used in all types of simulators build with SimGrid\n" " to generate a uncategorized resource utilization graph to be used as\n" diff --git a/src/instr/instr_paje_header.c b/src/instr/instr_paje_header.c new file mode 100644 index 0000000000..f7a62db2c7 --- /dev/null +++ b/src/instr/instr_paje_header.c @@ -0,0 +1,257 @@ +/* Copyright (c) 2010. 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" + +#ifdef HAVE_TRACING + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_header, instr, "Paje tracing event system (header)"); + +extern FILE *tracing_file; + +static void TRACE_header_PajeDefineContainerType (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeDefineContainerType %d\n", PAJE_DefineContainerType); + fprintf(tracing_file, "%% Alias string\n"); + if (basic){ + fprintf(tracing_file, "%% ContainerType string\n"); + }else{ + fprintf(tracing_file, "%% Type string\n"); + } + fprintf(tracing_file, "%% Name string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeDefineVariableType (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeDefineVariableType %d\n", PAJE_DefineVariableType); + fprintf(tracing_file, "%% Alias string\n"); + if (basic){ + fprintf(tracing_file, "%% ContainerType string\n"); + }else{ + fprintf(tracing_file, "%% Type string\n"); + } + fprintf(tracing_file, "%% Name string\n"); + fprintf(tracing_file, "%% Color string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeDefineStateType (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeDefineStateType %d\n", PAJE_DefineStateType); + fprintf(tracing_file, "%% Alias string\n"); + if (basic){ + fprintf(tracing_file, "%% ContainerType string\n"); + }else{ + fprintf(tracing_file, "%% Type string\n"); + } + fprintf(tracing_file, "%% Name string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeDefineEventType (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeDefineEventType %d\n", PAJE_DefineEventType); + fprintf(tracing_file, "%% Alias string\n"); + if (basic){ + fprintf(tracing_file, "%% ContainerType string\n"); + }else{ + fprintf(tracing_file, "%% Type string\n"); + } + fprintf(tracing_file, "%% Name string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeDefineLinkType (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeDefineLinkType %d\n", PAJE_DefineLinkType); + fprintf(tracing_file, "%% Alias string\n"); + if (basic){ + fprintf(tracing_file, "%% ContainerType string\n"); + fprintf(tracing_file, "%% SourceContainerType string\n"); + fprintf(tracing_file, "%% DestContainerType string\n"); + }else{ + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% StartContainerType string\n"); + fprintf(tracing_file, "%% EndContainerType string\n"); + } + fprintf(tracing_file, "%% Name string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeDefineEntityValue (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeDefineEntityValue %d\n", PAJE_DefineEntityValue); + fprintf(tracing_file, "%% Alias string\n"); + if (basic){ + fprintf(tracing_file, "%% EntityType string\n"); + }else{ + fprintf(tracing_file, "%% Type string\n"); + } + fprintf(tracing_file, "%% Name string\n"); + fprintf(tracing_file, "%% Color string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeCreateContainer (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeCreateContainer %d\n", PAJE_CreateContainer); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Alias string\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Name string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeDestroyContainer (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeDestroyContainer %d\n", PAJE_DestroyContainer); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Name string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeSetVariable (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeSetVariable %d\n", PAJE_SetVariable); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Value double\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeAddVariable (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeAddVariable %d\n", PAJE_AddVariable); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Value double\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeSubVariable (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeSubVariable %d\n", PAJE_SubVariable); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Value double\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + + +static void TRACE_header_PajeSetState (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeSetState %d\n", PAJE_SetState); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Value string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajePushState (int basic) +{ + fprintf(tracing_file, "%%EventDef PajePushState %d\n", PAJE_PushState); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Value string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajePopState (int basic) +{ + fprintf(tracing_file, "%%EventDef PajePopState %d\n", PAJE_PopState); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeResetState (int basic) +{ + if (basic) return; + + fprintf(tracing_file, "%%EventDef PajeResetState %d\n", PAJE_ResetState); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeStartLink (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeStartLink %d\n", PAJE_StartLink); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Value string\n"); + if (basic){ + fprintf(tracing_file, "%% SourceContainer string\n"); + }else{ + fprintf(tracing_file, "%% StartContainer string\n"); + } + fprintf(tracing_file, "%% Key string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeEndLink (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeEndLink %d\n", PAJE_EndLink); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Value string\n"); + if (basic){ + fprintf(tracing_file, "%% DestContainer string\n"); + }else{ + fprintf(tracing_file, "%% EndContainer string\n"); + } + fprintf(tracing_file, "%% Key string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +static void TRACE_header_PajeNewEvent (int basic) +{ + fprintf(tracing_file, "%%EventDef PajeNewEvent %d\n", PAJE_NewEvent); + fprintf(tracing_file, "%% Time date\n"); + fprintf(tracing_file, "%% Type string\n"); + fprintf(tracing_file, "%% Container string\n"); + fprintf(tracing_file, "%% Value string\n"); + fprintf(tracing_file, "%%EndEventDef\n"); +} + +void TRACE_header(int basic) +{ + XBT_DEBUG ("Define paje header"); + TRACE_header_PajeDefineContainerType (basic); + TRACE_header_PajeDefineVariableType (basic); + TRACE_header_PajeDefineStateType (basic); + TRACE_header_PajeDefineEventType (basic); + TRACE_header_PajeDefineLinkType (basic); + TRACE_header_PajeDefineEntityValue (basic); + TRACE_header_PajeCreateContainer (basic); + TRACE_header_PajeDestroyContainer (basic); + TRACE_header_PajeSetVariable (basic); + TRACE_header_PajeAddVariable (basic); + TRACE_header_PajeSubVariable (basic); + TRACE_header_PajeSetState (basic); + TRACE_header_PajePushState (basic); + TRACE_header_PajePopState (basic); + TRACE_header_PajeResetState (basic); + TRACE_header_PajeStartLink (basic); + TRACE_header_PajeEndLink (basic); + TRACE_header_PajeNewEvent (basic); +} + +#endif + + diff --git a/src/instr/instr_paje_trace.c b/src/instr/instr_paje_trace.c index 0e0af37434..89584d436b 100644 --- a/src/instr/instr_paje_trace.c +++ b/src/instr/instr_paje_trace.c @@ -10,27 +10,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "Paje tracing event system"); -typedef enum { - PAJE_DefineContainerType, - PAJE_DefineVariableType, - PAJE_DefineStateType, - PAJE_DefineEventType, - PAJE_DefineLinkType, - PAJE_DefineEntityValue, - PAJE_CreateContainer, - PAJE_DestroyContainer, - PAJE_SetVariable, - PAJE_AddVariable, - PAJE_SubVariable, - PAJE_SetState, - PAJE_PushState, - PAJE_PopState, - PAJE_ResetState, - PAJE_StartLink, - PAJE_EndLink, - PAJE_NewEvent -} e_event_type; - typedef struct paje_event *paje_event_t; typedef struct paje_event { double timestamp; @@ -154,7 +133,7 @@ typedef struct s_newEvent { val_t value; }s_newEvent_t; -static FILE *tracing_file = NULL; +FILE *tracing_file = NULL; static xbt_dynar_t buffer = NULL; @@ -169,7 +148,7 @@ void TRACE_paje_start(void) XBT_DEBUG("Filename %s is open for writing", filename); /* output header */ - TRACE_paje_create_header(); + TRACE_header(TRACE_basic()); buffer = xbt_dynar_new (sizeof(paje_event_t), NULL); } @@ -212,138 +191,6 @@ void TRACE_paje_dump_buffer (int force) XBT_DEBUG("%s: ends", __FUNCTION__); } -void TRACE_paje_create_header(void) -{ - XBT_DEBUG ("Define paje header"); - fprintf(tracing_file, "\ -%%EventDef PajeDefineContainerType %d \n\ -%% Alias string \n\ -%% Type string \n\ -%% Name string \n\ -%%EndEventDef \n\ -%%EventDef PajeDefineVariableType %d \n\ -%% Alias string \n\ -%% Type string \n\ -%% Name string \n\ -%% Color color \n\ -%%EndEventDef \n\ -%%EventDef PajeDefineStateType %d \n\ -%% Alias string \n\ -%% Type string \n\ -%% Name string \n\ -%%EndEventDef \n\ -%%EventDef PajeDefineEventType %d \n\ -%% Alias string \n\ -%% Type string \n\ -%% Name string \n\ -%%EndEventDef \n\ -%%EventDef PajeDefineLinkType %d \n\ -%% Alias string \n\ -%% Type string \n\ -%% StartContainerType string \n\ -%% EndContainerType string \n\ -%% Name string \n\ -%%EndEventDef \n\ -%%EventDef PajeDefineEntityValue %d \n\ -%% Alias string \n\ -%% Type string \n\ -%% Name string \n\ -%% Color color \n\ -%%EndEventDef \n\ -%%EventDef PajeCreateContainer %d \n\ -%% Time date \n\ -%% Alias string \n\ -%% Type string \n\ -%% Container string \n\ -%% Name string \n\ -%%EndEventDef \n\ -%%EventDef PajeDestroyContainer %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Name string \n\ -%%EndEventDef \n\ -%%EventDef PajeSetVariable %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%% Value double \n\ -%%EndEventDef\n\ -%%EventDef PajeAddVariable %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%% Value double \n\ -%%EndEventDef\n\ -%%EventDef PajeSubVariable %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%% Value double \n\ -%%EndEventDef\n\ -%%EventDef PajeSetState %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%% Value string \n\ -%%EndEventDef\n\ -%%EventDef PajePushState %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%% Value string \n\ -%%EndEventDef\n\ -%%EventDef PajePopState %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%%EndEventDef\n\ -%%EventDef PajeResetState %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%%EndEventDef\n\ -%%EventDef PajeStartLink %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%% Value string \n\ -%% StartContainer string \n\ -%% Key string \n\ -%%EndEventDef\n\ -%%EventDef PajeEndLink %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%% Value string \n\ -%% EndContainer string \n\ -%% Key string \n\ -%%EndEventDef\n\ -%%EventDef PajeNewEvent %d \n\ -%% Time date \n\ -%% Type string \n\ -%% Container string \n\ -%% Value string \n\ -%%EndEventDef\n", - PAJE_DefineContainerType, - PAJE_DefineVariableType, - PAJE_DefineStateType, - PAJE_DefineEventType, - PAJE_DefineLinkType, - PAJE_DefineEntityValue, - PAJE_CreateContainer, - PAJE_DestroyContainer, - PAJE_SetVariable, - PAJE_AddVariable, - PAJE_SubVariable, - PAJE_SetState, - PAJE_PushState, - PAJE_PopState, - PAJE_ResetState, - PAJE_StartLink, - PAJE_EndLink, - PAJE_NewEvent); -} - /* internal do the instrumentation module */ static void insert_into_buffer (paje_event_t tbi) { diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 2508306d5c..58b447546d 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -24,6 +24,27 @@ #include "simix/smx_private.h" #include "xbt/graph_private.h" +typedef enum { + PAJE_DefineContainerType, + PAJE_DefineVariableType, + PAJE_DefineStateType, + PAJE_DefineEventType, + PAJE_DefineLinkType, + PAJE_DefineEntityValue, + PAJE_CreateContainer, + PAJE_DestroyContainer, + PAJE_SetVariable, + PAJE_AddVariable, + PAJE_SubVariable, + PAJE_SetState, + PAJE_PushState, + PAJE_PopState, + PAJE_ResetState, + PAJE_StartLink, + PAJE_EndLink, + PAJE_NewEvent +} e_event_type; + typedef enum { TYPE_VARIABLE, TYPE_LINK, @@ -79,8 +100,10 @@ extern xbt_dict_t user_host_variables; extern xbt_dict_t user_link_variables; extern double TRACE_last_timestamp_to_dump; +/* instr_paje_header.c */ +void TRACE_header(int basic); + /* from paje.c */ -void TRACE_paje_create_header(void); void TRACE_paje_start(void); void TRACE_paje_end(void); void TRACE_paje_dump_buffer (int force); @@ -168,6 +191,7 @@ int TRACE_msg_process_is_enabled(void); int TRACE_buffer (void); int TRACE_onelink_only (void); int TRACE_disable_destroy (void); +int TRACE_basic (void); char *TRACE_get_filename(void); char *TRACE_get_triva_uncat_conf (void); char *TRACE_get_triva_cat_conf (void); diff --git a/src/instr/instr_smpi.c b/src/instr/instr_smpi.c index b0e8dc1f8c..30f1802a72 100644 --- a/src/instr/instr_smpi.c +++ b/src/instr/instr_smpi.c @@ -16,29 +16,29 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_smpi, instr, "Tracing SMPI"); static xbt_dict_t keys; static const char *smpi_colors[] ={ - "recv", "255 000 000", - "irecv", "255 135 135", - "send", "000 000 255", - "isend", "135 135 255", - "sendrecv", "000 255 255", - "wait", "255 255 000", - "waitall", "200 200 000", - "waitany", "200 200 150", - - "allgather", "255 000 000", - "allgatherv", "255 135 135", - "allreduce", "255 000 255", - "alltoall", "135 000 255", - "alltoallv", "200 135 255", - "barrier", "000 200 200", - "bcast", "000 200 100", - "gather", "255 255 000", - "gatherv", "255 255 135", - "reduce", "000 255 000", - "reducescatter", "135 255 135", - "scan", "255 150 060", - "scatterv", "135 000 135", - "scatter", "255 190 140", + "recv", "1 0 0", + "irecv", "1 0.52 0.52", + "send", "0 0 1", + "isend", "0.52 0.52 1", + "sendrecv", "0 1 1", + "wait", "1 1 0", + "waitall", "0.78 0.78 0", + "waitany", "0.78 0.78 0.58", + + "allgather", "1 0 0", + "allgatherv", "1 0.52 0.52", + "allreduce", "1 0 1", + "alltoall", "0.52 0 1", + "alltoallv", "0.78 0.52 1", + "barrier", "0 0.78 0.78", + "bcast", "0 0.78 0.39", + "gather", "1 1 0", + "gatherv", "1 1 0.52", + "reduce", "0 1 0", + "reducescatter", "0.52 1 0.52", + "scan", "1 0.58 0.23", + "scatterv", "0.52 0 0.52", + "scatter", "1 0.74 0.54", NULL, NULL, }; diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 76e288c4ce..3a7bd17afd 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -41,6 +41,8 @@ smx_host_t simcall_host_get_by_name(const char *name) simcall->call = SIMCALL_HOST_GET_BY_NAME; simcall->host_get_by_name.name = name; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->host_get_by_name.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->host_get_by_name.result; } @@ -58,6 +60,8 @@ const char* simcall_host_get_name(smx_host_t host) simcall->call = SIMCALL_HOST_GET_NAME; simcall->host_get_name.host = host; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->host_get_name.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->host_get_name.result; } @@ -75,6 +79,8 @@ xbt_dict_t simcall_host_get_properties(smx_host_t host) simcall->call = SIMCALL_HOST_GET_PROPERTIES; simcall->host_get_properties.host = host; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->host_get_properties.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->host_get_properties.result; } @@ -93,6 +99,8 @@ double simcall_host_get_speed(smx_host_t host) simcall->call = SIMCALL_HOST_GET_SPEED; simcall->host_get_speed.host = host; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->host_get_speed.result = 0.0; SIMIX_simcall_push(simcall->issuer); return simcall->host_get_speed.result; } @@ -109,6 +117,8 @@ double simcall_host_get_available_speed(smx_host_t host) simcall->call = SIMCALL_HOST_GET_AVAILABLE_SPEED; simcall->host_get_available_speed.host = host; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->host_get_available_speed.result = 0.0; SIMIX_simcall_push(simcall->issuer); return simcall->host_get_available_speed.result; } @@ -127,6 +137,8 @@ int simcall_host_get_state(smx_host_t host) simcall->call = SIMCALL_HOST_GET_STATE; simcall->host_get_state.host = host; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->host_get_state.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->host_get_state.result; } @@ -144,6 +156,8 @@ void* simcall_host_get_data(smx_host_t host) simcall->call = SIMCALL_HOST_GET_DATA; simcall->host_get_data.host = host; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->host_get_data.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->host_get_data.result; } @@ -194,6 +208,8 @@ smx_action_t simcall_host_execute(const char *name, smx_host_t host, simcall->host_execute.host = host; simcall->host_execute.computation_amount = computation_amount; simcall->host_execute.priority = priority; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->host_execute.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->host_execute.result; } @@ -244,6 +260,8 @@ smx_action_t simcall_host_parallel_execute(const char *name, simcall->host_parallel_execute.communication_amount = communication_amount; simcall->host_parallel_execute.amount = amount; simcall->host_parallel_execute.rate = rate; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->host_parallel_execute.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->host_parallel_execute.result; } @@ -293,6 +311,8 @@ double simcall_host_execution_get_remains(smx_action_t execution) simcall->call = SIMCALL_HOST_EXECUTION_GET_REMAINS; simcall->host_execution_get_remains.execution = execution; + if(MC_IS_ENABLED) /* Initializeialize result to a default value for snapshot comparison done during simcall */ + simcall->host_execution_get_remains.result = 0.0; SIMIX_simcall_push(simcall->issuer); return simcall->host_execution_get_remains.result; } @@ -310,6 +330,7 @@ e_smx_state_t simcall_host_execution_get_state(smx_action_t execution) simcall->call = SIMCALL_HOST_EXECUTION_GET_STATE; simcall->host_execution_get_state.execution = execution; + simcall->host_execution_get_state.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->host_execution_get_state.result; } @@ -347,6 +368,8 @@ e_smx_state_t simcall_host_execution_wait(smx_action_t execution) simcall->call = SIMCALL_HOST_EXECUTION_WAIT; simcall->host_execution_wait.execution = execution; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->host_execution_wait.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->host_execution_wait.result; } @@ -505,6 +528,8 @@ int simcall_process_count(void) smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_PROCESS_COUNT; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->process_count.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->process_count.result; } @@ -526,6 +551,8 @@ void* simcall_process_get_data(smx_process_t process) simcall->call = SIMCALL_PROCESS_GET_DATA; simcall->process_get_data.process = process; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->process_get_data.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->process_get_data.result; } @@ -588,6 +615,8 @@ smx_host_t simcall_process_get_host(smx_process_t process) simcall->call = SIMCALL_PROCESS_GET_HOST; simcall->process_get_host.process = process; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->process_get_host.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->process_get_host.result; } @@ -611,6 +640,8 @@ const char* simcall_process_get_name(smx_process_t process) simcall->call = SIMCALL_PROCESS_GET_NAME; simcall->process_get_name.process = process; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->process_get_name.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->process_get_name.result; } @@ -629,6 +660,8 @@ int simcall_process_is_suspended(smx_process_t process) simcall->call = SIMCALL_PROCESS_IS_SUSPENDED; simcall->process_is_suspended.process = process; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->process_is_suspended.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->process_is_suspended.result; } @@ -645,6 +678,8 @@ xbt_dict_t simcall_process_get_properties(smx_process_t process) simcall->call = SIMCALL_PROCESS_GET_PROPERTIES; simcall->process_get_properties.process = process; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->process_get_properties.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->process_get_properties.result; } @@ -690,6 +725,8 @@ XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process) simcall->call = SIMCALL_PROCESS_RESTART; simcall->process_restart.process = process; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->process_restart.result = NULL; SIMIX_simcall_push(simcall->issuer); @@ -715,6 +752,8 @@ e_smx_state_t simcall_process_sleep(double duration) simcall->call = SIMCALL_PROCESS_SLEEP; simcall->process_sleep.duration = duration; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->process_sleep.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->process_sleep.result; } @@ -731,6 +770,8 @@ smx_rdv_t simcall_rdv_create(const char *name) simcall->call = SIMCALL_RDV_CREATE; simcall->rdv_create.name = name; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->rdv_create.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->rdv_create.result; @@ -788,6 +829,8 @@ int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host) simcall->call = SIMCALL_RDV_COMM_COUNT_BY_HOST; simcall->rdv_comm_count_by_host.rdv = rdv; simcall->rdv_comm_count_by_host.host = host; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->rdv_comm_count_by_host.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->rdv_comm_count_by_host.result; @@ -805,6 +848,8 @@ smx_action_t simcall_rdv_get_head(smx_rdv_t rdv) simcall->call = SIMCALL_RDV_GET_HEAD; simcall->rdv_get_head.rdv = rdv; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->rdv_get_head.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->rdv_get_head.result; @@ -827,6 +872,8 @@ smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv) simcall->call = SIMCALL_RDV_GET_RECV; simcall->rdv_get_rcv_proc.rdv = rdv; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->rdv_get_rcv_proc.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->rdv_get_rcv_proc.result; @@ -897,6 +944,8 @@ smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate, simcall->comm_isend.clean_fun = clean_fun; simcall->comm_isend.data = data; simcall->comm_isend.detached = detached; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->comm_isend.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->comm_isend.result; @@ -946,6 +995,8 @@ smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff simcall->comm_irecv.dst_buff_size = dst_buff_size; simcall->comm_irecv.match_fun = match_fun; simcall->comm_irecv.data = data; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->comm_irecv.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->comm_irecv.result; @@ -986,6 +1037,8 @@ unsigned int simcall_comm_waitany(xbt_dynar_t comms) simcall->call = SIMCALL_COMM_WAITANY; simcall->comm_waitany.comms = comms; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->comm_waitany.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->comm_waitany.result; @@ -1001,6 +1054,8 @@ int simcall_comm_testany(xbt_dynar_t comms) simcall->call = SIMCALL_COMM_TESTANY; simcall->comm_testany.comms = comms; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->comm_testany.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->comm_testany.result; @@ -1054,6 +1109,8 @@ int simcall_comm_test(smx_action_t comm) simcall->call = SIMCALL_COMM_TEST; simcall->comm_test.comm = comm; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->comm_test.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->comm_test.result; @@ -1068,6 +1125,8 @@ double simcall_comm_get_remains(smx_action_t comm) simcall->call = SIMCALL_COMM_GET_REMAINS; simcall->comm_get_remains.comm = comm; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->comm_get_remains.result = 0.0; SIMIX_simcall_push(simcall->issuer); return simcall->comm_get_remains.result; @@ -1082,6 +1141,8 @@ e_smx_state_t simcall_comm_get_state(smx_action_t comm) simcall->call = SIMCALL_COMM_GET_STATE; simcall->comm_get_state.comm = comm; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->comm_get_state.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->comm_get_state.result; @@ -1096,6 +1157,8 @@ void *simcall_comm_get_src_data(smx_action_t comm) simcall->call = SIMCALL_COMM_GET_SRC_DATA; simcall->comm_get_src_data.comm = comm; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->comm_get_src_data.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->comm_get_src_data.result; @@ -1110,6 +1173,8 @@ void *simcall_comm_get_dst_data(smx_action_t comm) simcall->call = SIMCALL_COMM_GET_DST_DATA; simcall->comm_get_dst_data.comm = comm; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->comm_get_dst_data.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->comm_get_dst_data.result; @@ -1124,6 +1189,8 @@ smx_process_t simcall_comm_get_src_proc(smx_action_t comm) simcall->call = SIMCALL_COMM_GET_SRC_PROC; simcall->comm_get_src_proc.comm = comm; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->comm_get_src_proc.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->comm_get_src_proc.result; @@ -1138,6 +1205,8 @@ smx_process_t simcall_comm_get_dst_proc(smx_action_t comm) simcall->call = SIMCALL_COMM_GET_DST_PROC; simcall->comm_get_dst_proc.comm = comm; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->comm_get_dst_proc.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->comm_get_dst_proc.result; @@ -1150,6 +1219,8 @@ int simcall_comm_is_latency_bounded(smx_action_t comm) simcall->call = SIMCALL_COMM_IS_LATENCY_BOUNDED; simcall->comm_is_latency_bounded.comm = comm; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->comm_is_latency_bounded.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->comm_is_latency_bounded.result; @@ -1168,6 +1239,8 @@ smx_mutex_t simcall_mutex_init(void) smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_MUTEX_INIT; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->mutex_init.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->mutex_init.result; @@ -1208,6 +1281,8 @@ int simcall_mutex_trylock(smx_mutex_t mutex) simcall->call = SIMCALL_MUTEX_TRYLOCK; simcall->mutex_trylock.mutex = mutex; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->mutex_trylock.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->mutex_trylock.result; @@ -1234,6 +1309,8 @@ smx_cond_t simcall_cond_init(void) smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_COND_INIT; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->cond_init.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->cond_init.result; @@ -1320,6 +1397,8 @@ smx_sem_t simcall_sem_init(int capacity) simcall->call = SIMCALL_SEM_INIT; simcall->sem_init.capacity = capacity; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->sem_init.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->sem_init.result; @@ -1360,6 +1439,8 @@ int simcall_sem_would_block(smx_sem_t sem) simcall->call = SIMCALL_SEM_WOULD_BLOCK; simcall->sem_would_block.sem = sem; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->sem_would_block.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->sem_would_block.result; @@ -1403,6 +1484,8 @@ int simcall_sem_get_capacity(smx_sem_t sem) simcall->call = SIMCALL_SEM_GET_CAPACITY; simcall->sem_get_capacity.sem = sem; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->sem_get_capacity.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->sem_get_capacity.result; @@ -1420,6 +1503,8 @@ double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream simcall->file_read.size = size; simcall->file_read.nmemb = nmemb; simcall->file_read.stream = stream; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->file_read.result = 0.0; SIMIX_simcall_push(simcall->issuer); return simcall->file_read.result; @@ -1437,6 +1522,8 @@ size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t simcall->file_write.size = size; simcall->file_write.nmemb = nmemb; simcall->file_write.stream = stream; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->file_write.result = 0; SIMIX_simcall_push(simcall->issuer); return simcall->file_write.result; @@ -1453,6 +1540,8 @@ smx_file_t simcall_file_open(const char* mount, const char* path, const char* mo simcall->file_open.mount = mount; simcall->file_open.path = path; simcall->file_open.mode = mode; + if(MC_IS_ENABLED) /* Initialize result to NULL for snapshot comparison done during simcall */ + simcall->file_open.result = NULL; SIMIX_simcall_push(simcall->issuer); return simcall->file_open.result; @@ -1467,6 +1556,8 @@ int simcall_file_close(smx_file_t fp) simcall->call = SIMCALL_FILE_CLOSE; simcall->file_close.fp = fp; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->file_close.result = -1; SIMIX_simcall_push(simcall->issuer); return simcall->file_close.result; @@ -1480,6 +1571,8 @@ int simcall_file_stat(smx_file_t fd, s_file_stat_t *buf) smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_FILE_STAT; simcall->file_stat.fd = fd; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->file_stat.result = -1; SIMIX_simcall_push(simcall->issuer); @@ -1497,6 +1590,8 @@ int simcall_file_unlink(smx_file_t fd) smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_FILE_UNLINK; simcall->file_unlink.fd = fd; + if(MC_IS_ENABLED) /* Initialize result to a default value for snapshot comparison done during simcall */ + simcall->file_unlink.result = -1; SIMIX_simcall_push(simcall->issuer); diff --git a/src/surf/maxmin.c b/src/surf/maxmin.c index e9f635de1c..929c106638 100644 --- a/src/surf/maxmin.c +++ b/src/surf/maxmin.c @@ -659,7 +659,6 @@ void lmm_solve(lmm_system_t sys) make_elem_inactive(elem); elem_list = &(cnst->element_set); xbt_swag_foreach(elem, elem_list) { -// make_elem_active(elem); if (elem->variable->weight <= 0 || elem->variable->value > 0) break; if (elem->value > 0) diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index 90c2d8d631..402ade6487 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -430,16 +430,24 @@ int platf_graph_is_connected(void) { void platf_graph_clear_links(void) { xbt_dynar_t dynar_nodes = NULL; xbt_dynar_t dynar_edges = NULL; + xbt_dynar_t dynar_edges_cpy = NULL; xbt_node_t graph_node = NULL; xbt_edge_t graph_edge = NULL; context_node_t node_data = NULL; unsigned int i; - //Delete edges from the graph + //The graph edge dynar will be modified directly, so we work on a copy of it dynar_edges = xbt_graph_get_edges(platform_graph); + dynar_edges_cpy = xbt_dynar_new(sizeof(xbt_edge_t), NULL); xbt_dynar_foreach(dynar_edges, i, graph_edge) { + xbt_dynar_push_as(dynar_edges_cpy, xbt_edge_t, graph_edge); + } + //Delete edges from the graph + xbt_dynar_foreach(dynar_edges_cpy, i, graph_edge) { xbt_graph_free_edge(platform_graph, graph_edge, xbt_free); } + //remove the dynar copy + xbt_dynar_free(&dynar_edges_cpy); //All the nodes will be of degree 0, unchecked from connectedness dynar_nodes = xbt_graph_get_nodes(platform_graph); @@ -653,7 +661,8 @@ void platf_generate(void) { sg_platf_new_cluster(cluster_parameters); break; case ROUTER: - router_parameters.id = bprintf("router-%d", ++last_router); + node_data->router_id = bprintf("router-%d", ++last_router); + router_parameters.id = node_data->router_id; sg_platf_new_router(&router_parameters); } } diff --git a/src/surf/surf_routing_vivaldi.c b/src/surf/surf_routing_vivaldi.c index 00b7e77d16..3b97eaa037 100644 --- a/src/surf/surf_routing_vivaldi.c +++ b/src/surf/surf_routing_vivaldi.c @@ -54,7 +54,7 @@ static void vivaldi_get_route_and_latency( src_ctn = xbt_lib_get_or_null(as_router_lib, tmp_src_name, COORD_ASR_LEVEL); } else{ - xbt_die(" "); + THROW_IMPOSSIBLE; } if(dst_p->rc_type == SURF_NETWORK_ELEMENT_HOST){ @@ -76,7 +76,7 @@ static void vivaldi_get_route_and_latency( dst_ctn = xbt_lib_get_or_null(as_router_lib, tmp_dst_name, COORD_ASR_LEVEL); } else{ - xbt_die(" "); + THROW_IMPOSSIBLE; } xbt_assert(src_ctn,"No coordinate found for element '%s'",tmp_src_name); diff --git a/src/surf/trace_mgr.c b/src/surf/trace_mgr.c index 79ec300096..e2a61fe4d2 100644 --- a/src/surf/trace_mgr.c +++ b/src/surf/trace_mgr.c @@ -39,47 +39,94 @@ XBT_INLINE void tmgr_history_free(tmgr_history_t h) * \brief Create a #tmgr_trace_t from probabilist generators * * This trace will generate an infinite set of events. - * It needs two #probabilist_event_generator_t. For regular events, the first one is - * used as a date generator, the second as a value generator. For a state trace, the - * event values are 0 or 1. The first generator rules the time between state changes. - * If the second generator is set, it is used to set the duration of unavailability, - * while the first one set the duration of availability. + * It needs two #probabilist_event_generator_t. The date when the event are + * triggered is directed by date_generator, and will be interpreted as seconds. + * The value of the event is set by value_generator. The value should be between + * 0 and 1. * * \param id The name of the trace - * \param generator1 The #probabilist_event_generator_t which generates the time - * between two events, or which rules the duration of availability for state trace + * \param date_generator The #probabilist_event_generator_t which generates the time + * between two events * \param generator2 The #probabilist_event_generator_t which generates the value - * of each events, or the duration of unavailability for state trace. - * \param is_state_trace Is the trace will be used as a state trace + * of each events. * \return The new #tmgr_trace_t */ -tmgr_trace_t tmgr_trace_new_from_generator(const char *id, - probabilist_event_generator_t generator1, - probabilist_event_generator_t generator2, - int is_state_trace) +tmgr_trace_t tmgr_trace_generator_value(const char *id, + probabilist_event_generator_t date_generator, + probabilist_event_generator_t value_generator) { tmgr_trace_t trace = NULL; trace = xbt_new0(s_tmgr_trace_t, 1); trace->type = e_trace_probabilist; - trace->s_probabilist.event_generator[0] = generator1; + trace->s_probabilist.event_generator[0] = date_generator; + trace->s_probabilist.event_generator[1] = value_generator; + trace->s_probabilist.is_state_trace = 0; - //FIXME : may also be a parameter - trace->s_probabilist.next_event = 0; - trace->s_probabilist.is_state_trace = is_state_trace; + return trace; +} - if(generator2 != NULL) { - trace->s_probabilist.event_generator[1] = generator2; - } else if(is_state_trace) { - trace->s_probabilist.event_generator[1] = generator1; - } else { - THROW_IMPOSSIBLE; //That case should have been checked before, anyway... - } +/** + * \brief Create a #tmgr_trace_t from probabilist generators + * + * This trace will generate an infinite set of events. Value of the events + * will be alternatively 0 and 1, so this should be used as a state trace. + * + * \param id The name of the trace + * \param date_generator The #probabilist_event_generator_t which generates the time + * between two events + * \param first_event_value Set the first event value + * \return The new #tmgr_trace_t + */ +tmgr_trace_t tmgr_trace_generator_state(const char *id, + probabilist_event_generator_t date_generator, + e_surf_resource_state_t first_event_value) +{ + tmgr_trace_t trace = NULL; + + trace = xbt_new0(s_tmgr_trace_t, 1); + trace->type = e_trace_probabilist; + + trace->s_probabilist.event_generator[0] = date_generator; + trace->s_probabilist.event_generator[1] = date_generator; + trace->s_probabilist.is_state_trace = 1; + trace->s_probabilist.next_event = (first_event_value==SURF_RESOURCE_ON ? 1 : 0); return trace; } +/** + * \brief Create a #tmgr_trace_t from probabilist generators + * + * This trace will generate an infinite set of events. Value of the events + * will be alternatively 0 and 1, so this should be used as a state trace. + * + * \param id The name of the trace + * \param avail_duration_generator The #probabilist_event_generator_t which + * set the duration of the available state, (ie 1 value) + * \param unavail_duration_generator The #probabilist_event_generator_t which + * set the duration of the unavailable state, (ie 0 value) + * \param first_event_value Set the first event value + * \return The new #tmgr_trace_t + */ +tmgr_trace_t tmgr_trace_generator_avail_unavail(const char *id, + probabilist_event_generator_t avail_duration_generator, + probabilist_event_generator_t unavail_duration_generator, + e_surf_resource_state_t first_event_value) +{ + tmgr_trace_t trace = NULL; + + trace = xbt_new0(s_tmgr_trace_t, 1); + trace->type = e_trace_probabilist; + + trace->s_probabilist.event_generator[0] = unavail_duration_generator; + trace->s_probabilist.event_generator[1] = avail_duration_generator; + trace->s_probabilist.is_state_trace = 1; + trace->s_probabilist.next_event = (first_event_value==SURF_RESOURCE_ON ? 1 : 0); + + return trace; +} /** * \brief Create a new #probabilist_event_generator_t following the uniform distribution diff --git a/src/xbt/mmalloc/mfree.c b/src/xbt/mmalloc/mfree.c index 8211efc5ea..64e098259e 100644 --- a/src/xbt/mmalloc/mfree.c +++ b/src/xbt/mmalloc/mfree.c @@ -19,7 +19,7 @@ void mfree(struct mdesc *mdp, void *ptr) { int type; - size_t block; + size_t block, frag_nb; register size_t i; struct list *prev, *next; int it; @@ -149,6 +149,10 @@ void mfree(struct mdesc *mdp, void *ptr) ((char *) ADDRESS(block) + (mdp->heapinfo[block].busy_frag.first << type)); + /* Set size used in the fragment to 0 */ + frag_nb = RESIDUAL(ptr, BLOCKSIZE) >> type; + mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = 0; + if (mdp->heapinfo[block].busy_frag.nfree == (BLOCKSIZE >> type) - 1) { /* If all fragments of this block are free, remove them @@ -191,8 +195,7 @@ void mfree(struct mdesc *mdp, void *ptr) it is the first free fragment of this block. */ prev = (struct list *) ptr; mdp->heapinfo[block].busy_frag.nfree = 1; - mdp->heapinfo[block].busy_frag.first = - RESIDUAL(ptr, BLOCKSIZE) >> type; + mdp->heapinfo[block].busy_frag.first = frag_nb; prev->next = mdp->fraghead[type].next; prev->prev = &mdp->fraghead[type]; prev->prev->next = prev; diff --git a/src/xbt/mmalloc/mm_diff.c b/src/xbt/mmalloc/mm_diff.c index a33b54a872..3935b9f88c 100644 --- a/src/xbt/mmalloc/mm_diff.c +++ b/src/xbt/mmalloc/mm_diff.c @@ -118,9 +118,8 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ heapsize2 = heap2->heapsize; /* Start comparison */ - size_t i1, i2, j1, j2, k; + size_t i1, i2, j1, j2, k, current_block, current_fragment; void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2; - size_t frag_size1, frag_size2; xbt_dynar_t previous = xbt_dynar_new(sizeof(heap_area_pair_t), heap_area_pair_free_voidp); @@ -128,14 +127,42 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ ignore_done = 0; + /* Init equal information */ + i1 = 1; + + while(i1<=heaplimit){ + if(heapinfo1[i1].type == 0){ + heapinfo1[i1].busy_block.equal_to = -1; + } + if(heapinfo1[i1].type > 0){ + for(j1=0; j1 < MAX_FRAGMENT_PER_BLOCK; j1++){ + heapinfo1[i1].busy_frag.equal_to[j1] = -1; + } + } + i1++; + } + + i2 = 1; + + while(i2<=heaplimit){ + if(heapinfo2[i2].type == 0){ + heapinfo2[i2].busy_block.equal_to = -1; + } + if(heapinfo2[i2].type > 0){ + for(j2=0; j2 < MAX_FRAGMENT_PER_BLOCK; j2++){ + heapinfo2[i2].busy_frag.equal_to[j2] = -1; + } + } + i2++; + } + /* Check busy blocks*/ i1 = 1; - while(i1 < heaplimit){ + while(i1 <= heaplimit){ - i2 = 1; - equal = 0; + current_block = i1; if(heapinfo1[i1].type == -1){ /* Free block */ i1++; @@ -146,8 +173,55 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ if(heapinfo1[i1].type == 0){ /* Large block */ + if(heapinfo1[i1].busy_block.busy_size == 0){ + i1++; + continue; + } + + i2 = 1; + equal = 0; + + /* Try first to associate to same block in the other heap */ + if(heapinfo2[current_block].type == heapinfo1[current_block].type){ + + if(heapinfo1[current_block].busy_block.busy_size == heapinfo2[current_block].busy_block.busy_size){ + + addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)heapbase2)); + + add_heap_area_pair(previous, current_block, -1, current_block, -1); + + if(ignore_done < xbt_dynar_length(mmalloc_ignore)){ + if(in_mmalloc_ignore((int)current_block, -1)) + res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 1); + else + res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 0); + }else{ + res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 0); + } + + if(res_compare == 0){ + for(k=1; k < heapinfo2[current_block].busy_block.size; k++) + heapinfo2[current_block+k].busy_block.equal_to = 1 ; + for(k=1; k < heapinfo1[current_block].busy_block.size; k++) + heapinfo1[current_block+k].busy_block.equal_to = 1 ; + equal = 1; + match_equals(previous); + i1 = i1 + heapinfo1[i1].busy_block.size; + } + + xbt_dynar_reset(previous); + + } + + } + while(i2 <= heaplimit && !equal){ + if(i2 == current_block){ + i2++; + continue; + } + if(heapinfo2[i2].type != 0){ i2++; continue; @@ -183,54 +257,88 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ } if(!res_compare){ - for(k=0; k < heapinfo2[i2].busy_block.size; k++) + for(k=1; k < heapinfo2[i2].busy_block.size; k++) heapinfo2[i2+k].busy_block.equal_to = 1; - for(k=0; k < heapinfo1[i1].busy_block.size; k++) + for(k=1; k < heapinfo1[i1].busy_block.size; k++) heapinfo1[i1+k].busy_block.equal_to = 1; equal = 1; match_equals(previous); } + xbt_dynar_reset(previous); i2++; } + if(!equal) + i1++; + }else{ /* Fragmented block */ - frag_size1 = 1 << heapinfo1[i1].type; - for(j1=0; j1 < (size_t) (BLOCKSIZE >> heapinfo1[i1].type); j1++){ + current_fragment = j1; + if(heapinfo1[i1].busy_frag.frag_size[j1] == 0) /* Free fragment */ continue; - addr_frag1 = (void*) ((char *)addr_block1 + (j1 * frag_size1)); - + addr_frag1 = (void*) ((char *)addr_block1 + (j1 << heapinfo1[i1].type)); + i2 = 1; equal = 0; + /* Try first to associate to same fragment in the other heap */ + if(heapinfo2[current_block].type == heapinfo1[current_block].type){ + + if(heapinfo1[current_block].busy_frag.frag_size[current_fragment] == heapinfo2[current_block].busy_frag.frag_size[current_fragment]){ + + addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)heapbase2)); + addr_frag2 = (void*) ((char *)addr_block2 + (current_fragment << heapinfo2[current_block].type)); + + add_heap_area_pair(previous, current_block, current_fragment, current_block, current_fragment); + + if(ignore_done < xbt_dynar_length(mmalloc_ignore)){ + if(in_mmalloc_ignore((int)current_block, (int)current_fragment)) + res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 1); + else + res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 0); + }else{ + res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 0); + } + + if(res_compare == 0){ + equal = 1; + match_equals(previous); + } + + xbt_dynar_reset(previous); + + } + + } + + while(i2 <= heaplimit && !equal){ if(heapinfo2[i2].type <= 0){ i2++; continue; } - - frag_size2 = 1 << heapinfo2[i2].type; for(j2=0; j2 < (size_t) (BLOCKSIZE >> heapinfo2[i2].type); j2++){ - if(heapinfo2[i2].busy_frag.equal_to[j2] == 1){ + if(heapinfo2[i2].type == heapinfo1[i1].type && i2 == current_block && j2 == current_fragment) + continue; + + if(heapinfo2[i2].busy_frag.equal_to[j2] == 1) continue; - } - if(heapinfo1[i1].busy_frag.frag_size[j1] != heapinfo2[i2].busy_frag.frag_size[j2]){ /* Different size_used */ + if(heapinfo1[i1].busy_frag.frag_size[j1] != heapinfo2[i2].busy_frag.frag_size[j2]) /* Different size_used */ continue; - } addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)heapbase2)); - addr_frag2 = (void*) ((char *)addr_block2 + (j2 * frag_size2)); + addr_frag2 = (void*) ((char *)addr_block2 + (j2 << heapinfo2[i2].type)); /* Comparison */ add_heap_area_pair(previous, i1, j1, i2, j2); @@ -245,12 +353,12 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ } if(!res_compare){ - heapinfo2[i2].busy_frag.equal_to[j2] = 1; - heapinfo1[i1].busy_frag.equal_to[j1] = 1; equal = 1; match_equals(previous); + xbt_dynar_reset(previous); break; } + xbt_dynar_reset(previous); } @@ -261,16 +369,15 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ } + i1++; + } - i1++; - } /* All blocks/fragments are equal to another block/fragment ? */ size_t i = 1, j = 0; int nb_diff1 = 0, nb_diff2 = 0; - size_t frag_size = 0; while(i 0){ - frag_size = 1 << heapinfo1[i].type; for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo1[i].type); j++){ if(heapinfo1[i].busy_frag.frag_size[j] > 0){ if(heapinfo1[i].busy_frag.equal_to[j] == -1){ if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){ addr_block1 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase1)); - addr_frag1 = (void*) ((char *)addr_block1 + (j * frag_size)); + addr_frag1 = (void*) ((char *)addr_block1 + (j << heapinfo1[i].type)); XBT_DEBUG("Block %zu, Fragment %zu (%p) not found (size used = %d)", i, j, addr_frag1, heapinfo1[i].busy_frag.frag_size[j]); mmalloc_backtrace_fragment_display((void*)heapinfo1, i, j); } @@ -323,13 +429,12 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ } } if(heapinfo2[i].type > 0){ - frag_size = 1 << heapinfo2[i].type; for(j=0; j < (size_t) (BLOCKSIZE >> heapinfo2[i].type); j++){ if(heapinfo2[i].busy_frag.frag_size[j] > 0){ if(heapinfo2[i].busy_frag.equal_to[j] == -1){ if(XBT_LOG_ISENABLED(mm_diff, xbt_log_priority_debug)){ addr_block2 = ((void*) (((ADDR2UINT(i)) - 1) * BLOCKSIZE + (char*)heapbase2)); - addr_frag2 = (void*) ((char *)addr_block2 + (j * frag_size)); + addr_frag2 = (void*) ((char *)addr_block2 + (j << heapinfo2[i].type)); XBT_DEBUG( "Block %zu, Fragment %zu (%p) not found (size used = %d)", i, j, addr_frag2, heapinfo2[i].busy_frag.frag_size[j]); mmalloc_backtrace_fragment_display((void*)heapinfo2, i, j); } @@ -342,36 +447,6 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2){ } XBT_DEBUG("Different blocks or fragments in heap2 : %d\n", nb_diff2); - - - /* Reset equal information */ - i = 1; - - while(i 0){ - for(j=0; j < MAX_FRAGMENT_PER_BLOCK; j++){ - heapinfo1[i].busy_frag.equal_to[j] = -1; - } - } - i++; - } - - i = 1; - - while(i 0){ - for(j=0; j < MAX_FRAGMENT_PER_BLOCK; j++){ - heapinfo2[i].busy_frag.equal_to[j] = -1; - } - } - i++; - } xbt_dynar_free(&previous); @@ -432,7 +507,6 @@ static int compare_area(void *area1, void* area2, size_t size, xbt_dynar_t previ size_t i = 0, pointer_align = 0, ignore1 = 0, ignore2 = 0; void *address_pointed1, *address_pointed2, *addr_block_pointed1, *addr_block_pointed2, *addr_frag_pointed1, *addr_frag_pointed2; size_t block_pointed1, block_pointed2, frag_pointed1, frag_pointed2; - size_t frag_size, frag_size1, frag_size2; int res_compare; void *current_area1, *current_area2; @@ -500,17 +574,15 @@ static int compare_area(void *area1, void* area2, size_t size, xbt_dynar_t previ }else{ /* Fragmented block */ - /* Get pointed fragments number */ + /* Get pointed fragments number */ frag_pointed1 = ((uintptr_t) (ADDR2UINT (address_pointed1) % (BLOCKSIZE))) >> heapinfo1[block_pointed1].type; frag_pointed2 = ((uintptr_t) (ADDR2UINT (address_pointed2) % (BLOCKSIZE))) >> heapinfo2[block_pointed2].type; if(heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1] != heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]) /* Different size_used */ return 1; - - frag_size = 1 << heapinfo1[block_pointed1].type; - addr_frag_pointed1 = (void*) ((char *)addr_block_pointed1 + (frag_pointed1 * frag_size)); - addr_frag_pointed2 = (void*) ((char *)addr_block_pointed2 + (frag_pointed2 * frag_size)); + addr_frag_pointed1 = (void*) ((char *)addr_block_pointed1 + (frag_pointed1 << heapinfo1[block_pointed1].type)); + addr_frag_pointed2 = (void*) ((char *)addr_block_pointed2 + (frag_pointed2 << heapinfo2[block_pointed2].type)); if(add_heap_area_pair(previous, block_pointed1, frag_pointed1, block_pointed2, frag_pointed2)){ @@ -542,12 +614,9 @@ static int compare_area(void *area1, void* area2, size_t size, xbt_dynar_t previ if(heapinfo1[block_pointed1].busy_frag.frag_size[frag_pointed1] != heapinfo2[block_pointed2].busy_frag.frag_size[frag_pointed2]) /* Different size_used */ return 1; - - frag_size1 = 1 << heapinfo1[block_pointed1].type; - frag_size2 = 1 << heapinfo1[block_pointed2].type; - addr_frag_pointed1 = (void*) ((char *)addr_block_pointed1 + (frag_pointed1 * frag_size1)); - addr_frag_pointed2 = (void*) ((char *)addr_block_pointed2 + (frag_pointed2 * frag_size2)); + addr_frag_pointed1 = (void*) ((char *)addr_block_pointed1 + (frag_pointed1 << heapinfo1[block_pointed1].type)); + addr_frag_pointed2 = (void*) ((char *)addr_block_pointed2 + (frag_pointed2 << heapinfo2[block_pointed2].type)); if(add_heap_area_pair(previous, block_pointed1, frag_pointed1, block_pointed2, frag_pointed2)){ diff --git a/src/xbt/mmalloc/mmalloc.c b/src/xbt/mmalloc/mmalloc.c index cae6d3701e..e6f796dbc5 100644 --- a/src/xbt/mmalloc/mmalloc.c +++ b/src/xbt/mmalloc/mmalloc.c @@ -153,7 +153,6 @@ void *mmalloc(xbt_mheap_t mdp, size_t size) frag_nb = RESIDUAL(result, BLOCKSIZE) >> log; mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = requested_size; - mdp->heapinfo[block].busy_frag.equal_to[frag_nb] = -1; xbt_backtrace_no_malloc(mdp->heapinfo[block].busy_frag.bt[frag_nb],XBT_BACKTRACE_SIZE); next->prev->next = next->next; @@ -195,7 +194,6 @@ void *mmalloc(xbt_mheap_t mdp, size_t size) } } mdp->heapinfo[block].busy_frag.frag_size[0] = requested_size; - mdp->heapinfo[block].busy_frag.equal_to[0] = -1; xbt_backtrace_no_malloc(mdp->heapinfo[block].busy_frag.bt[0],XBT_BACKTRACE_SIZE); /* Initialize the nfree and first counters for this block. */ @@ -245,7 +243,6 @@ void *mmalloc(xbt_mheap_t mdp, size_t size) block = BLOCK(result); for (it=0;itheapinfo[block+it].type = 0; - mdp->heapinfo[block+it].busy_block.equal_to = -1; } mdp->heapinfo[block].busy_block.size = blocks; mdp->heapinfo[block].busy_block.busy_size = requested_size; @@ -283,7 +280,6 @@ void *mmalloc(xbt_mheap_t mdp, size_t size) for (it=0;itheapinfo[block+it].type = 0; - mdp->heapinfo[block+it].busy_block.equal_to = -1; } mdp->heapinfo[block].busy_block.size = blocks; mdp->heapinfo[block].busy_block.busy_size = requested_size;