From: Frederic Suter Date: Fri, 3 Mar 2017 12:51:44 +0000 (+0100) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_15~232 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/00e649212cc6ca64c4cb8103e4c5bb4b98d2ff3f?hp=dcd2c367c090bf42195e45d1d5a5bf32dabc4173 Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 0f30c1ad4b..2713dfa78a 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -824,6 +824,12 @@ XBT_PUBLIC(void) smpi_sample_1(int global, const char *file, int line, int iters XBT_PUBLIC(int) smpi_sample_2(int global, const char *file, int line); XBT_PUBLIC(void) smpi_sample_3(int global, const char *file, int line); +/** + * Need a public setter for SMPI copy_callback function, so users can define + * their own while still using default SIMIX_copy_callback for MSG copies. + */ +XBT_PUBLIC(void) smpi_comm_set_copy_data_callback(void (*callback)); + /** * Functions for call location tracing. These functions will be * called from the user's application! (With the __FILE__ and __LINE__ values diff --git a/src/smpi/private.h b/src/smpi/private.h index 30d679f891..5950b3e9f9 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -191,6 +191,8 @@ XBT_PRIVATE void smpi_comm_copy_buffer_callback(smx_activity_t comm, void *buff, XBT_PRIVATE void smpi_comm_null_copy_buffer_callback(smx_activity_t comm, void *buff, size_t buff_size); +static void (*smpi_comm_copy_data_callback) (smx_activity_t, void*, size_t) = &smpi_comm_copy_buffer_callback; + XBT_PRIVATE void print_request(const char *message, MPI_Request request); XBT_PRIVATE int smpi_enabled(); diff --git a/src/smpi/smpi_base.cpp b/src/smpi/smpi_base.cpp index bac438a320..cd9ae5b301 100644 --- a/src/smpi/smpi_base.cpp +++ b/src/smpi/smpi_base.cpp @@ -332,7 +332,7 @@ void smpi_mpi_start(MPI_Request request) // we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later request->real_size=request->size; request->action = simcall_comm_irecv(SIMIX_process_self(), mailbox, request->buf, &request->real_size, &match_recv, - ! smpi_process_get_replaying()? &smpi_comm_copy_buffer_callback + ! smpi_process_get_replaying()? smpi_comm_copy_data_callback : &smpi_comm_null_copy_buffer_callback, request, -1.0); XBT_DEBUG("recv simcall posted"); @@ -422,7 +422,7 @@ void smpi_mpi_start(MPI_Request request) request->action = simcall_comm_isend(SIMIX_process_from_PID(request->src+1), mailbox, request->size, -1.0, buf, request->real_size, &match_send, &xbt_free_f, // how to free the userdata if a detached send fails - !smpi_process_get_replaying() ? &smpi_comm_copy_buffer_callback + !smpi_process_get_replaying() ? smpi_comm_copy_data_callback : &smpi_comm_null_copy_buffer_callback, request, // detach if msg size < eager/rdv switch limit request->detached); diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 8d2f64695b..7cde17bf2c 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -388,6 +388,11 @@ void print_request(const char *message, MPI_Request request) message, request, request->buf, request->size, request->src, request->dst, request->tag, request->flags); } +void smpi_comm_set_copy_data_callback(void (*callback) (smx_activity_t, void*, size_t)) +{ + smpi_comm_copy_data_callback = callback; +} + void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t buff_size) { XBT_DEBUG("Copy the data over"); @@ -808,7 +813,7 @@ int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[]) // parse the platform file: get the host list SIMIX_create_environment(argv[1]); - SIMIX_comm_set_copy_data_callback(&smpi_comm_copy_buffer_callback); + SIMIX_comm_set_copy_data_callback(smpi_comm_copy_data_callback); SIMIX_function_register_default(realmain); SIMIX_launch_application(argv[2]);