From aaa9acf3fdd6714a158a161cac64c82992d52899 Mon Sep 17 00:00:00 2001 From: degomme Date: Fri, 31 Mar 2017 15:03:39 +0200 Subject: [PATCH] Really don't do anything in the copy callback if we are in a shared zone. Attempt to fix https://github.com/simgrid/simgrid/issues/147 --- src/smpi/smpi_global.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 031ff3922c..0acc0d4d59 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -105,7 +105,7 @@ 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) { - void* tmpbuff=buff; + simgrid::kernel::activity::Comm *comm = dynamic_cast(synchro); XBT_DEBUG("Copy the data over"); @@ -114,7 +114,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b }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 ) ){ @@ -135,17 +135,18 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b 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) -- 2.20.1