From 0f86d40fdf09712d615dcc7c8ae54e75ff841301 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 26 Dec 2011 02:23:21 +0100 Subject: [PATCH] dupplicate the sender buffer in eager mode, when isends are changed into dsends (and free it once copied in position) --- include/simix/simix.h | 2 ++ src/simix/smx_network.c | 7 +++++++ src/smpi/smpi_base.c | 12 ++++++++++-- src/smpi/smpi_global.c | 3 +-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/simix/simix.h b/include/simix/simix.h index 7c6a70a66a..b64385e065 100644 --- a/include/simix/simix.h +++ b/include/simix/simix.h @@ -72,6 +72,8 @@ XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c); XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, size_t)); XBT_PUBLIC(void) SIMIX_comm_copy_pointer_callback(smx_action_t comm, size_t buff_size); XBT_PUBLIC(void) SIMIX_comm_copy_buffer_callback(smx_action_t comm, size_t buff_size); +XBT_PUBLIC(void) smpi_comm_copy_data_callback(smx_action_t comm, size_t buff_size); + XBT_PUBLIC(smx_action_t) SIMIX_comm_get_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data); XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data); XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data); diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index c06c6a4fc6..49222ba79a 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -823,6 +823,13 @@ void SIMIX_comm_copy_buffer_callback(smx_action_t comm, size_t buff_size) memcpy(comm->comm.dst_buff, comm->comm.src_buff, buff_size); } +void smpi_comm_copy_data_callback(smx_action_t comm, size_t buff_size) +{ + memcpy(comm->comm.dst_buff, comm->comm.src_buff, buff_size); + if (comm->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 + free(comm->comm.src_buff); +} + /** * \brief Copy the communication data from the sender's buffer to the receiver's one * \param comm The communication diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index fc093b5417..f5aa890b12 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -87,6 +87,7 @@ MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype, void smpi_mpi_start(MPI_Request request) { smx_rdv_t mailbox; + int detached = 0; xbt_assert(!request->action, "Cannot (re)start a non-finished communication"); @@ -101,12 +102,19 @@ void smpi_mpi_start(MPI_Request request) smpi_group_index(smpi_comm_group(request->comm), request->dst)); // FIXME: SIMIX does not yet support non-contiguous datatypes + if (request->size < 64*1024 ) { // eager mode => detached send (FIXME: this limit should be configurable) + void *oldbuf = request->buf; + detached = 1; + request->buf = malloc(request->size); + memcpy(request->buf,oldbuf,request->size); + } + request->action = SIMIX_req_comm_isend(mailbox, request->size, -1.0, request->buf, request->size, &match_send, request, // detach if msg size < eager/rdv switch limit - request->size < 64*1024 ? 1:0); - // if detached request->action == NULL + detached); + #ifdef HAVE_TRACING SIMIX_req_set_category (request->action, TRACE_internal_smpi_get_category()); #endif diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index ad839cbbf5..0089372c0e 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -180,8 +180,7 @@ void smpi_global_init(void) MPI_Group group; char name[MAILBOX_NAME_MAXLEN]; - SIMIX_comm_set_copy_data_callback - (&SIMIX_comm_copy_buffer_callback); + SIMIX_comm_set_copy_data_callback(&smpi_comm_copy_data_callback); process_count = SIMIX_process_count(); process_data = xbt_new(smpi_process_data_t, process_count); for (i = 0; i < process_count; i++) { -- 2.20.1