Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix SIMIX_network_copy_data against SMPI (to be tested against ruby bindings).
authorpini <pini@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 5 Mar 2010 12:22:42 +0000 (12:22 +0000)
committerpini <pini@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 5 Mar 2010 12:22:42 +0000 (12:22 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7203 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/simix/simix.h
src/simix/smx_network.c
src/smpi/smpi_global.c

index e5c3458..7c965fe 100644 (file)
@@ -211,6 +211,9 @@ XBT_PUBLIC(double) SIMIX_communication_get_remains(smx_comm_t comm);
 XBT_PUBLIC(void *) SIMIX_communication_get_data(smx_comm_t comm);
 
 /*****Networking*****/
+XBT_PUBLIC(void) SIMIX_network_set_copy_data_callback(void (*callback)(smx_comm_t, size_t));
+XBT_PUBLIC(void) SIMIX_network_copy_pointer_callback(smx_comm_t comm, size_t buff_size);
+XBT_PUBLIC(void) SIMIX_network_copy_buffer_callback(smx_comm_t comm, size_t buff_size);
 XBT_PUBLIC(void) SIMIX_network_send(smx_rdv_t rdv, double task_size, double rate,
                                     double timeout, void *src_buff,
                                     size_t src_buff_size, smx_comm_t *comm, void *data);
index a1bb927..93e5271 100644 (file)
@@ -315,6 +315,24 @@ XBT_INLINE double SIMIX_communication_get_remains(smx_comm_t comm)
   return SIMIX_action_get_remains(comm->act);
 }  
 
+/******************************************************************************/
+/*                    SIMIX_network_copy_data callbacks                       */
+/******************************************************************************/
+static void (*SIMIX_network_copy_data_callback)(smx_comm_t, size_t) = &SIMIX_network_copy_pointer_callback;
+
+void SIMIX_network_set_copy_data_callback(void (*callback)(smx_comm_t, size_t)) {
+  SIMIX_network_copy_data_callback = callback;
+}
+
+void SIMIX_network_copy_pointer_callback(smx_comm_t comm, size_t buff_size) {
+  xbt_assert1((buff_size == sizeof(void*)), "Cannot copy %d bytes: must be sizeof(void*)",buff_size);
+  *(void**)(comm->dst_buff) = comm->src_buff;
+}
+
+void SIMIX_network_copy_buffer_callback(smx_comm_t comm, size_t buff_size) {
+  memcpy(comm->dst_buff, comm->src_buff, buff_size);
+}
+
 /**
  *  \brief Copy the communication data from the sender's buffer to the receiver's one
  *  \param comm The communication
@@ -336,28 +354,14 @@ void SIMIX_network_copy_data(smx_comm_t comm)
 
   if(buff_size == 0)
     return;
-
-#ifdef HAVE_RUBY /* FIXME: KILLME */
-  INFO6("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)",
-      comm,
-      comm->src_proc->smx_host->name, comm->src_buff,
-      comm->dst_proc->smx_host->name, comm->dst_buff,
-      buff_size);
-#else
   DEBUG6("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)",
       comm,
       comm->src_proc->smx_host->name, comm->src_buff,
       comm->dst_proc->smx_host->name, comm->dst_buff,
       buff_size);
-#endif
-
-  xbt_assert1((buff_size == sizeof(void*)), "Cannot copy %d bytes: must be sizeof(void*)",buff_size);
-  //FIXME: cleanup
-//  if  {
-    *(void**)(comm->dst_buff) = (comm->src_buff);
-/*  } else {
-    memcpy(comm->dst_buff, comm->src_buff, buff_size);
-  }*/
+  if(SIMIX_network_copy_data_callback) {
+    SIMIX_network_copy_data_callback(comm, buff_size);
+  }
 }
 
 /**
index 66a1a1a..403d5d6 100644 (file)
@@ -105,6 +105,7 @@ void smpi_global_init(void) {
   int i;
   MPI_Group group;
 
+  SIMIX_network_set_copy_data_callback(&SIMIX_network_copy_buffer_callback);
   process_count = SIMIX_process_count();
   process_data = xbt_new(smpi_process_data_t, process_count);
   for(i = 0; i < process_count; i++) {