From 8ba5ebec745c34478bd1082a07edcb76aab3aefb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christophe=20Thi=C3=A9ry?= Date: Fri, 13 Jan 2012 15:24:49 +0100 Subject: [PATCH] Change the prototype of copy data callbacks to add the source buffer --- include/simix/simix.h | 8 ++++---- src/msg/msg_gos.c | 9 +++++---- src/msg/msg_private.h | 2 +- src/simix/smx_network.c | 20 ++++++++++---------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/simix/simix.h b/include/simix/simix.h index c42954d7ab..df128f61cb 100644 --- a/include/simix/simix.h +++ b/include/simix/simix.h @@ -70,10 +70,10 @@ XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c); XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process); /****************************** Communication *********************************/ -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(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, void*, size_t)); +XBT_PUBLIC(void) SIMIX_comm_copy_pointer_callback(smx_action_t comm, void* buff, size_t buff_size); +XBT_PUBLIC(void) SIMIX_comm_copy_buffer_callback(smx_action_t comm, void* buff, size_t buff_size); +XBT_PUBLIC(void) smpi_comm_copy_data_callback(smx_action_t comm, void* buff, 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); diff --git a/src/msg/msg_gos.c b/src/msg/msg_gos.c index ad96462b0c..aa2ec0ddae 100644 --- a/src/msg/msg_gos.c +++ b/src/msg/msg_gos.c @@ -8,7 +8,6 @@ #include "mc/mc.h" #include "xbt/log.h" #include "xbt/sysdep.h" -#include "simix/private.h" // FIXME XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg, "Logging specific to MSG (gos)"); @@ -764,16 +763,18 @@ m_task_t MSG_comm_get_task(msg_comm_t comm) /** * \brief This function is called by SIMIX to copy the data of a comm. * \param comm the comm + * \param buff the data copied * \param buff_size size of the buffer */ -void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, size_t buff_size) { +void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size) { // copy the task - SIMIX_comm_copy_pointer_callback(comm, buff_size); + SIMIX_comm_copy_pointer_callback(comm, buff, buff_size); // notify the user callback if any if (msg_global->task_copy_callback) { - msg_global->task_copy_callback(SIMIX_req_comm_get_src_data(comm), + m_task_t task = buff; + msg_global->task_copy_callback(task, SIMIX_req_comm_get_src_proc(comm), SIMIX_req_comm_get_dst_proc(comm)); } } diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index 4c5e9e486b..0b7ff957f3 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -120,7 +120,7 @@ void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name, const char *hostname, int argc, char **argv, xbt_dict_t properties); void MSG_process_kill_from_SIMIX(smx_process_t p); -void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, size_t buff_size); +void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size); void _MSG_action_init(void); void _MSG_action_exit(void); diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 7cce2f7917..0ee16e8772 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -857,34 +857,34 @@ XBT_INLINE int SIMIX_comm_is_latency_bounded(smx_action_t action) /******************************************************************************/ /* SIMIX_comm_copy_data callbacks */ /******************************************************************************/ -static void (*SIMIX_comm_copy_data_callback) (smx_action_t, size_t) = +static void (*SIMIX_comm_copy_data_callback) (smx_action_t, void*, size_t) = &SIMIX_comm_copy_pointer_callback; void -SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, size_t)) +SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, void*, size_t)) { SIMIX_comm_copy_data_callback = callback; } -void SIMIX_comm_copy_pointer_callback(smx_action_t comm, size_t buff_size) +void SIMIX_comm_copy_pointer_callback(smx_action_t comm, void* buff, size_t buff_size) { xbt_assert((buff_size == sizeof(void *)), "Cannot copy %zu bytes: must be sizeof(void*)", buff_size); - *(void **) (comm->comm.dst_buff) = comm->comm.src_buff; + *(void **) (comm->comm.dst_buff) = buff; } -void SIMIX_comm_copy_buffer_callback(smx_action_t comm, size_t buff_size) +void SIMIX_comm_copy_buffer_callback(smx_action_t comm, void* buff, size_t buff_size) { XBT_DEBUG("Copy the data over"); - memcpy(comm->comm.dst_buff, comm->comm.src_buff, buff_size); + memcpy(comm->comm.dst_buff, buff, buff_size); } -void smpi_comm_copy_data_callback(smx_action_t comm, size_t buff_size) +void smpi_comm_copy_data_callback(smx_action_t comm, void* buff, size_t buff_size) { XBT_DEBUG("Copy the data over"); - memcpy(comm->comm.dst_buff, comm->comm.src_buff, buff_size); + memcpy(comm->comm.dst_buff, 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 - xbt_free(comm->comm.src_buff); + xbt_free(buff); comm->comm.src_buff = NULL; } } @@ -916,7 +916,7 @@ void SIMIX_comm_copy_data(smx_action_t comm) *comm->comm.dst_buff_size = buff_size; if (buff_size > 0) - SIMIX_comm_copy_data_callback (comm, buff_size); + SIMIX_comm_copy_data_callback (comm, comm->comm.src_buff, buff_size); /* Set the copied flag so we copy data only once */ /* (this function might be called from both communication ends) */ -- 2.20.1