X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/31a6e7924c82cf18f981739b2f27f5920b970e73..65d226053e9899ca078e460632ce7aed82bdfb32:/src/smpi/smpi_global.cpp diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index db497bfdbf..9ce3361fcb 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -105,40 +105,48 @@ void smpi_comm_set_copy_data_callback(void (*callback) (smx_activity_t, void*, s void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t buff_size) { - XBT_DEBUG("Copy the data over"); - void* tmpbuff=buff; + simgrid::kernel::activity::Comm *comm = dynamic_cast(synchro); - if((smpi_privatize_global_variables) && (static_cast(buff) >= smpi_start_data_exe) - && (static_cast(buff) < smpi_start_data_exe + smpi_size_data_exe ) - ){ - XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !"); + XBT_DEBUG("Copy the data over"); + if(smpi_is_shared(buff)){ + XBT_DEBUG("Sender %p is shared. Let's ignore it.", buff); + }else if(smpi_is_shared((char*)comm->dst_buff)){ + XBT_DEBUG("Receiver %p is shared. Let's ignore it.", (char*)comm->dst_buff); + }else{ + void* tmpbuff=buff; + if((smpi_privatize_global_variables) && (static_cast(buff) >= smpi_start_data_exe) + && (static_cast(buff) < smpi_start_data_exe + smpi_size_data_exe ) + ){ + XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !"); + + smpi_switch_data_segment( + (static_cast((static_cast(comm->src_proc->data)->data))->index())); + tmpbuff = static_cast(xbt_malloc(buff_size)); + memcpy(tmpbuff, buff, buff_size); + } - smpi_switch_data_segment( - (static_cast((static_cast(comm->src_proc->data)->data))->index())); - tmpbuff = static_cast(xbt_malloc(buff_size)); - memcpy(tmpbuff, buff, buff_size); - } + if((smpi_privatize_global_variables) && ((char*)comm->dst_buff >= smpi_start_data_exe) + && ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){ + XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment"); + smpi_switch_data_segment( + (static_cast((static_cast(comm->dst_proc->data)->data))->index())); + } - if((smpi_privatize_global_variables) && ((char*)comm->dst_buff >= smpi_start_data_exe) - && ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){ - XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment"); - smpi_switch_data_segment( - (static_cast((static_cast(comm->dst_proc->data)->data))->index())); - } + XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff); + memcpy(comm->dst_buff, tmpbuff, buff_size); - XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff); - memcpy(comm->dst_buff, tmpbuff, buff_size); - if (comm->detached) { - // if this is a detached send, the source buffer was duplicated by SMPI - // sender to make the original buffer available to the application ASAP - xbt_free(buff); - //It seems that the request is used after the call there this should be free somewhere else but where??? - //xbt_free(comm->comm.src_data);// inside SMPI the request is kept inside the user data and should be free - comm->src_buff = nullptr; + if (comm->detached) { + // if this is a detached send, the source buffer was duplicated by SMPI + // sender to make the original buffer available to the application ASAP + xbt_free(buff); + //It seems that the request is used after the call there this should be free somewhere else but where??? + //xbt_free(comm->comm.src_data);// inside SMPI the request is kept inside the user data and should be free + comm->src_buff = nullptr; + } + if(tmpbuff!=buff)xbt_free(tmpbuff); } - if(tmpbuff!=buff)xbt_free(tmpbuff); } void smpi_comm_null_copy_buffer_callback(smx_activity_t comm, void *buff, size_t buff_size) @@ -169,9 +177,7 @@ int smpi_enabled() { void smpi_global_init() { - int i; MPI_Group group; - int smpirun=0; if (!MC_is_active()) { global_timer = xbt_os_timer_new(); @@ -268,24 +274,26 @@ void smpi_global_init() } } #endif + + int smpirun = 0; if (process_count == 0){ process_count = SIMIX_process_count(); smpirun=1; } smpi_universe_size = process_count; process_data = new simgrid::smpi::Process*[process_count]; - for (i = 0; i < process_count; i++) { - process_data[i] = new simgrid::smpi::Process(i); + for (int i = 0; i < process_count; i++) { + process_data[i] = new simgrid::smpi::Process(i); } //if the process was launched through smpirun script we generate a global mpi_comm_world //if not, we let MPI_COMM_NULL, and the comm world will be private to each mpi instance - if(smpirun){ + if (smpirun) { group = new simgrid::smpi::Group(process_count); MPI_COMM_WORLD = new simgrid::smpi::Comm(group, nullptr); MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, reinterpret_cast(process_count)); msg_bar_t bar = MSG_barrier_init(process_count); - for (i = 0; i < process_count; i++) { + for (int i = 0; i < process_count; i++) { group->set_mapping(i, i); process_data[i]->set_finalization_barrier(bar); } @@ -297,6 +305,7 @@ void smpi_global_destroy() int count = smpi_process_count(); smpi_bench_destroy(); + smpi_shared_destroy(); if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){ delete MPI_COMM_WORLD->group(); MSG_barrier_destroy(process_data[0]->finalization_barrier()); @@ -391,6 +400,7 @@ static void smpi_init_logs(){ XBT_LOG_CONNECT(smpi_request); XBT_LOG_CONNECT(smpi_replay); XBT_LOG_CONNECT(smpi_rma); + XBT_LOG_CONNECT(smpi_shared); XBT_LOG_CONNECT(smpi_utils); } }