X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8173f52406580284c8ec5feab41784a8f4aed8ce..d2e206d0539afade3722f7aa9f7a65ad8a714253:/src/mc/mc_comm_determinism.cpp diff --git a/src/mc/mc_comm_determinism.cpp b/src/mc/mc_comm_determinism.cpp index 20236c1170..018a90afa4 100644 --- a/src/mc/mc_comm_determinism.cpp +++ b/src/mc/mc_comm_determinism.cpp @@ -1,17 +1,20 @@ -/* Copyright (c) 2008-2014. The SimGrid Team. +/* Copyright (c) 2008-2015. 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 "mc_state.h" -#include "mc_comm_pattern.h" -#include "mc_request.h" -#include "mc_safety.h" -#include "mc_private.h" -#include "mc_record.h" -#include "mc_smx.h" -#include "mc_client.h" +#include "src/mc/mc_state.h" +#include "src/mc/mc_comm_pattern.h" +#include "src/mc/mc_request.h" +#include "src/mc/mc_safety.h" +#include "src/mc/mc_private.h" +#include "src/mc/mc_record.h" +#include "src/mc/mc_smx.h" +#include "src/mc/mc_client.h" +#include "src/mc/mc_exit.h" + +using simgrid::mc::remote; extern "C" { @@ -91,8 +94,7 @@ static char* print_determinism_result(e_mc_comm_pattern_difference_t diff, int p static void update_comm_pattern(mc_comm_pattern_t comm_pattern, smx_synchro_t comm_addr) { s_smx_synchro_t comm; - mc_model_checker->process().read_bytes( - &comm, sizeof(comm), (std::uint64_t)comm_addr); + mc_model_checker->process().read(&comm, remote(comm_addr)); smx_process_t src_proc = MC_smx_resolve_process(comm.comm.src_proc); smx_process_t dst_proc = MC_smx_resolve_process(comm.comm.dst_proc); @@ -102,13 +104,13 @@ static void update_comm_pattern(mc_comm_pattern_t comm_pattern, smx_synchro_t co comm_pattern->dst_host = MC_smx_process_get_host_name(dst_proc); if (comm_pattern->data_size == -1 && comm.comm.src_buff != NULL) { size_t buff_size; - mc_model_checker->process().read_bytes( - &buff_size, sizeof(buff_size), (std::uint64_t)comm.comm.dst_buff_size); + mc_model_checker->process().read( + &buff_size, remote(comm.comm.dst_buff_size)); comm_pattern->data_size = buff_size; comm_pattern->data = xbt_malloc0(comm_pattern->data_size); mc_model_checker->process().read_bytes( comm_pattern->data, comm_pattern->data_size, - (std::uint64_t) comm.comm.src_buff); + remote(comm.comm.src_buff)); } } @@ -143,7 +145,7 @@ static void deterministic_comm_pattern(int process, mc_comm_pattern_t comm, int xbt_free(initial_global_state->send_diff); initial_global_state->send_diff = NULL; MC_print_statistics(mc_stats); - xbt_abort(); + mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM); }else if(_sg_mc_comms_determinism && (!initial_global_state->send_deterministic && !initial_global_state->recv_deterministic)) { XBT_INFO("****************************************************"); XBT_INFO("***** Non-deterministic communications pattern *****"); @@ -155,7 +157,7 @@ static void deterministic_comm_pattern(int process, mc_comm_pattern_t comm, int xbt_free(initial_global_state->recv_diff); initial_global_state->recv_diff = NULL; MC_print_statistics(mc_stats); - xbt_abort(); + mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM); } } } @@ -190,8 +192,7 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type char* remote_name = mc_model_checker->process().read( (std::uint64_t)(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name)); - pattern->rdv = - MC_process_read_string(&mc_model_checker->process(), remote_name); + pattern->rdv = mc_model_checker->process().read_string(remote_name); pattern->src_proc = MC_smx_resolve_process(synchro.comm.src_proc)->pid; pattern->src_host = MC_smx_process_get_host_name(issuer); @@ -204,7 +205,7 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type pattern->data_size = synchro.comm.src_buff_size; pattern->data = xbt_malloc0(pattern->data_size); mc_model_checker->process().read_bytes( - pattern->data, pattern->data_size, (std::uint64_t)synchro.comm.src_buff); + pattern->data, pattern->data_size, remote(synchro.comm.src_buff)); } if(mpi_request.detached){ if (!initial_global_state->initial_communications_pattern_done) { @@ -228,21 +229,17 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type pattern->comm_addr = simcall_comm_irecv__get__result(request); struct s_smpi_mpi_request mpi_request; - mc_model_checker->process().read_bytes( - &mpi_request, sizeof(mpi_request), - (std::uint64_t) simcall_comm_irecv__get__data(request)); + mc_model_checker->process().read( + &mpi_request, remote((struct s_smpi_mpi_request*)simcall_comm_irecv__get__data(request))); pattern->tag = mpi_request.tag; s_smx_synchro_t synchro; - mc_model_checker->process().read_bytes( - &synchro, sizeof(synchro), (std::uint64_t)pattern->comm_addr); + mc_model_checker->process().read(&synchro, remote(pattern->comm_addr)); char* remote_name; - mc_model_checker->process().read_bytes( - &remote_name, sizeof(remote_name), - (std::uint64_t)(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name)); - pattern->rdv = - MC_process_read_string(&mc_model_checker->process(), remote_name); + mc_model_checker->process().read(&remote_name, + remote(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name)); + pattern->rdv = mc_model_checker->process().read_string(remote_name); pattern->dst_proc = MC_smx_resolve_process(synchro.comm.dst_proc)->pid; pattern->dst_host = MC_smx_process_get_host_name(issuer); } else { @@ -293,7 +290,7 @@ void MC_complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm_addr, unsigne /************************ Main algorithm ************************/ -static void MC_modelcheck_comm_determinism_main(void); +static int MC_modelcheck_comm_determinism_main(void); static void MC_pre_modelcheck_comm_determinism(void) { @@ -326,7 +323,7 @@ static void MC_pre_modelcheck_comm_determinism(void) XBT_DEBUG("********* Start communication determinism verification *********"); /* Wait for requests (schedules processes) */ - MC_wait_for_requests(); + mc_model_checker->wait_for_requests(); /* Get an enabled process and insert it in the interleave set of the initial state */ MC_EACH_SIMIX_PROCESS(process, @@ -338,7 +335,7 @@ static void MC_pre_modelcheck_comm_determinism(void) xbt_fifo_unshift(mc_stack, initial_state); } -static void MC_modelcheck_comm_determinism_main(void) +static int MC_modelcheck_comm_determinism_main(void) { char *req_str = NULL; @@ -391,7 +388,7 @@ static void MC_modelcheck_comm_determinism_main(void) MC_handle_comm_pattern(call, req, value, NULL, 0); /* Wait for requests (schedules processes) */ - MC_wait_for_requests(); + mc_model_checker->wait_for_requests(); /* Create the new expanded state */ next_state = MC_state_new(); @@ -443,7 +440,7 @@ static void MC_modelcheck_comm_determinism_main(void) /* Check for deadlocks */ if (MC_deadlock_check()) { MC_show_deadlock(NULL); - return; + return SIMGRID_MC_EXIT_DEADLOCK; } while ((state = (mc_state_t) xbt_fifo_shift(mc_stack)) != NULL) { @@ -466,14 +463,14 @@ static void MC_modelcheck_comm_determinism_main(void) } MC_print_statistics(mc_stats); - exit(0); + return SIMGRID_MC_EXIT_SUCCESS; } -void MC_modelcheck_comm_determinism(void) +int MC_modelcheck_comm_determinism(void) { XBT_INFO("Check communication determinism"); mc_reduce_kind = e_mc_reduce_none; - MC_wait_for_requests(); + mc_model_checker->wait_for_requests(); if (mc_mode == MC_MODE_CLIENT) { // This will move somehwere else: @@ -493,7 +490,7 @@ void MC_modelcheck_comm_determinism(void) initial_global_state->recv_diff = NULL; initial_global_state->send_diff = NULL; - MC_modelcheck_comm_determinism_main(); + return MC_modelcheck_comm_determinism_main(); } }