Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
solving copy_data_callback issue by adding a new smpi function that can be changed...
authorLuka Stanisic <luka.stanisic@inria.fr>
Thu, 2 Mar 2017 18:19:04 +0000 (19:19 +0100)
committerLuka Stanisic <luka.stanisic@inria.fr>
Fri, 3 Mar 2017 10:01:21 +0000 (11:01 +0100)
include/smpi/smpi.h
src/smpi/private.h
src/smpi/smpi_base.cpp
src/smpi/smpi_global.cpp

index 0f30c1a..2713dfa 100644 (file)
@@ -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
index 30d679f..5950b3e 100644 (file)
@@ -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();
index aeb6422..59f3d3a 100644 (file)
@@ -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);
index 8d2f646..7cde17b 100644 (file)
@@ -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]);