-/* Copyright (c) 2007-2010, 2012-2013. The SimGrid Team.
+/* Copyright (c) 2007-2010, 2012-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void *data, int detached);
XBT_PUBLIC(void) simcall_comm_recv(smx_rdv_t rdv, void *dst_buff,
- size_t * dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data, double timeout);
+ size_t * dst_buff_size,
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double timeout, double rate);
XBT_PUBLIC(smx_action_t) simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff,
- size_t * dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data);
-
-XBT_PUBLIC(void) simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff,
- size_t * dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data, double timeout, double rate);
-
-XBT_PUBLIC(smx_action_t) simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff,
- size_t * dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data, double rate);
+ size_t * dst_buff_size,
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double rate);
XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
XBT_PUBLIC(smx_action_t) simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
-/* Copyright (c) 2004-2013. The SimGrid Team.
+/* Copyright (c) 2004-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/*proc->simdata->waiting_action = act_sleep;
FIXME: check if not setting the waiting_action breaks something on msg
-
+
proc->simdata->waiting_action = NULL;*/
TRY {
*/
msg_error_t
MSG_task_receive_from_host_bounded(msg_task_t * task, const char *alias,
- msg_host_t host, double rate)
+ msg_host_t host, double rate)
{
return MSG_task_receive_ext_bounded(task, alias, -1, host, rate);
}
* #MSG_OK if the task was successfully received,
* #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise.
*/
-msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias, double rate)
+msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias,
+ double rate)
{
return MSG_task_receive_with_timeout_bounded(task, alias, -1, rate);
}
*/
msg_error_t
MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias,
- double timeout,double rate)
+ double timeout,double rate)
{
- return MSG_task_receive_ext_bounded(task, alias, timeout, NULL,rate);
+ return MSG_task_receive_ext_bounded(task, alias, timeout, NULL, rate);
}
/** \ingroup msg_task_usage
*/
msg_error_t
MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
- msg_host_t host, double rate)
+ msg_host_t host, double rate)
{
XBT_DEBUG
("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'",
alias);
return MSG_mailbox_get_task_ext_bounded(MSG_mailbox_get_by_alias(alias), task,
- host, timeout, rate);
+ host, timeout, rate);
}
+/* Internal function used to factorize code between
+ * MSG_task_isend_with_matching() and MSG_task_dsend().
+ */
+static XBT_INLINE
+msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias,
+ int (*match_fun)(void*,void*, smx_action_t),
+ void *match_data, void_f_pvoid_t cleanup,
+ int detached)
+{
+ simdata_task_t t_simdata = NULL;
+ msg_process_t process = MSG_process_self();
+ msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
+
+#ifdef HAVE_TRACING
+ int call_end = TRACE_msg_task_put_start(task);
+#endif
+
+ /* Prepare the task to send */
+ t_simdata = task->simdata;
+ t_simdata->sender = process;
+ t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
+
+ xbt_assert(t_simdata->isused == 0,
+ "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+
+ t_simdata->isused = 1;
+ t_simdata->comm = NULL;
+ msg_global->sent_msg++;
+
+ /* Send it by calling SIMIX network layer */
+ smx_action_t act = simcall_comm_isend(mailbox, t_simdata->message_size,
+ t_simdata->rate, task, sizeof(void *),
+ match_fun, cleanup, match_data,detached);
+ t_simdata->comm = act; /* FIXME: is the field t_simdata->comm still useful? */
+
+ msg_comm_t comm;
+ if (detached) {
+ comm = NULL;
+ } else {
+ comm = xbt_new0(s_msg_comm_t, 1);
+ comm->task_sent = task;
+ comm->task_received = NULL;
+ comm->status = MSG_OK;
+ comm->s_comm = act;
+ }
+
+#ifdef HAVE_TRACING
+ if (TRACE_is_enabled()) {
+ simcall_set_category(comm->s_comm, task->category);
+ }
+#endif
+
+#ifdef HAVE_TRACING
+ if (call_end)
+ TRACE_msg_task_put_end();
+#endif
+
+ return comm;
+}
+
+
/** \ingroup msg_task_usage
* \brief Sends a task on a mailbox.
*
*/
msg_comm_t MSG_task_isend(msg_task_t task, const char *alias)
{
- return MSG_task_isend_with_matching(task,alias,NULL,NULL);
+ return MSG_task_isend_internal(task, alias, NULL, NULL, NULL, 0);
}
/** \ingroup msg_task_usage
* \param maxrate the maximum communication rate for sending this task .
* \return the msg_comm_t communication created
*/
-msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate)
+msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias,
+ double maxrate)
{
task->simdata->rate = maxrate;
- return MSG_task_isend_with_matching(task,alias,NULL,NULL);
+ return MSG_task_isend_internal(task, alias, NULL, NULL, NULL, 0);
}
* \param match_data user provided data passed to match_fun
* \return the msg_comm_t communication created
*/
-XBT_INLINE msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char *alias,
- int (*match_fun)(void*,void*, smx_action_t),
- void *match_data)
+msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char *alias,
+ int (*match_fun)(void*, void*,
+ smx_action_t),
+ void *match_data)
{
- simdata_task_t t_simdata = NULL;
- msg_process_t process = MSG_process_self();
- msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
-
-#ifdef HAVE_TRACING
- int call_end = TRACE_msg_task_put_start(task);
-#endif
-
- /* Prepare the task to send */
- t_simdata = task->simdata;
- t_simdata->sender = process;
- t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
-
- xbt_assert(t_simdata->isused == 0,
- "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
-
- t_simdata->isused = 1;
- t_simdata->comm = NULL;
- msg_global->sent_msg++;
-
- /* Send it by calling SIMIX network layer */
- msg_comm_t comm = xbt_new0(s_msg_comm_t, 1);
- comm->task_sent = task;
- comm->task_received = NULL;
- comm->status = MSG_OK;
- comm->s_comm =
- simcall_comm_isend(mailbox, t_simdata->message_size,
- t_simdata->rate, task, sizeof(void *), match_fun, NULL, match_data, 0);
- t_simdata->comm = comm->s_comm; /* FIXME: is the field t_simdata->comm still useful? */
-#ifdef HAVE_TRACING
- if (TRACE_is_enabled()) {
- simcall_set_category(comm->s_comm, task->category);
- }
-#endif
-
-#ifdef HAVE_TRACING
- if (call_end)
- TRACE_msg_task_put_end();
-#endif
-
- return comm;
+ return MSG_task_isend_internal(task, alias, match_fun, match_data, NULL, 0);
}
/** \ingroup msg_task_usage
*/
void MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup)
{
- simdata_task_t t_simdata = NULL;
- msg_process_t process = MSG_process_self();
- msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
-
- /* Prepare the task to send */
- t_simdata = task->simdata;
- t_simdata->sender = process;
- t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
-
- xbt_assert(t_simdata->isused == 0,
- "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
-
- t_simdata->isused = 1;
- t_simdata->comm = NULL;
- msg_global->sent_msg++;
-
-#ifdef HAVE_TRACING
- int call_end = TRACE_msg_task_put_start(task);
-#endif
-
- /* Send it by calling SIMIX network layer */
- smx_action_t comm = simcall_comm_isend(mailbox, t_simdata->message_size,
- t_simdata->rate, task, sizeof(void *), NULL, cleanup, NULL, 1);
- t_simdata->comm = comm;
-#ifdef HAVE_TRACING
- if (TRACE_is_enabled()) {
- simcall_set_category(comm, task->category);
- }
-#endif
-
-#ifdef HAVE_TRACING
- if (call_end)
- TRACE_msg_task_put_end();
-#endif
+ MSG_task_isend_internal(task, alias, NULL, NULL, cleanup, 1);
}
-
/** \ingroup msg_task_usage
* \brief Sends a task on a mailbox with a maximal rate.
*
* communication fails, e.g. MSG_task_destroy
* (if NULL, no function will be called)
* \param maxrate the maximum communication rate for sending this task
- *
+ *
*/
-void MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate)
+void MSG_task_dsend_bounded(msg_task_t task, const char *alias,
+ void_f_pvoid_t cleanup, double maxrate)
{
task->simdata->rate = maxrate;
-
- simdata_task_t t_simdata = NULL;
- msg_process_t process = MSG_process_self();
- msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
-
- /* Prepare the task to send */
- t_simdata = task->simdata;
- t_simdata->sender = process;
- t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;
-
- xbt_assert(t_simdata->isused == 0,
- "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
-
- t_simdata->isused = 1;
- t_simdata->comm = NULL;
- msg_global->sent_msg++;
-
-#ifdef HAVE_TRACING
- int call_end = TRACE_msg_task_put_start(task);
-#endif
-
- /* Send it by calling SIMIX network layer */
- smx_action_t comm = simcall_comm_isend(mailbox, t_simdata->message_size,
- t_simdata->rate, task, sizeof(void *), NULL, cleanup, NULL, 1);
- t_simdata->comm = comm;
-#ifdef HAVE_TRACING
- if (TRACE_is_enabled()) {
- simcall_set_category(comm, task->category);
- }
-#endif
-
-#ifdef HAVE_TRACING
- if (call_end)
- TRACE_msg_task_put_end();
-#endif
+ MSG_task_dsend(task, alias, cleanup);
}
/** \ingroup msg_task_usage
*
* This is a non blocking function: use MSG_comm_wait() or MSG_comm_test()
* to end the communication.
- *
+ *
* \param task a memory location for storing a #msg_task_t. has to be valid until the end of the communication.
* \param name of the mailbox to receive the task on
* \return the msg_comm_t communication created
*/
msg_comm_t MSG_task_irecv(msg_task_t *task, const char *name)
{
- smx_rdv_t rdv = MSG_mailbox_get_by_alias(name);
-
- /* FIXME: these functions are not traceable */
-
- /* Sanity check */
- xbt_assert(task, "Null pointer for the task storage");
-
- if (*task)
- XBT_CRITICAL
- ("MSG_task_irecv() was asked to write in a non empty task struct.");
-
- /* Try to receive it by calling SIMIX network layer */
- msg_comm_t comm = xbt_new0(s_msg_comm_t, 1);
- comm->task_sent = NULL;
- comm->task_received = task;
- comm->status = MSG_OK;
- comm->s_comm = simcall_comm_irecv(rdv, task, NULL, NULL, NULL);
-
- return comm;
+ return MSG_task_irecv_bounded(task, name, -1.0);
}
/** \ingroup msg_task_usage
* \param rate limit the bandwidth to the given rate
* \return the msg_comm_t communication created
*/
-msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rate)
+msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name,
+ double rate)
{
-
-
smx_rdv_t rdv = MSG_mailbox_get_by_alias(name);
/* FIXME: these functions are not traceable */
comm->task_sent = NULL;
comm->task_received = task;
comm->status = MSG_OK;
- comm->s_comm = simcall_comm_irecv_bounded(rdv, task, NULL, NULL, NULL, rate);
+ comm->s_comm = simcall_comm_irecv(rdv, task, NULL, NULL, NULL, rate);
return comm;
}
*
* It takes two parameters.
* \param comm the communication to wait.
- * \param timeout Wait until the communication terminates or the timeout
+ * \param timeout Wait until the communication terminates or the timeout
* occurs. You can provide a -1 timeout to obtain an infinite timeout.
* \return msg_error_t
*/
/* Mailboxes in MSG */
-/* Copyright (c) 2008-2013. The SimGrid Team.
+/* Copyright (c) 2008-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise.
*/
msg_error_t
-MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task,
+MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t *task,
msg_host_t host, double timeout)
{
- xbt_ex_t e;
- msg_error_t ret = MSG_OK;
- /* We no longer support getting a task from a specific host */
- if (host)
- THROW_UNIMPLEMENTED;
-
-#ifdef HAVE_TRACING
- TRACE_msg_task_get_start();
- double start_time = MSG_get_clock();
-#endif
-
- /* Sanity check */
- xbt_assert(task, "Null pointer for the task storage");
-
- if (*task)
- XBT_WARN
- ("Asked to write the received task in a non empty struct -- proceeding.");
-
- /* Try to receive it by calling SIMIX network layer */
- TRY {
- simcall_comm_recv(mailbox, task, NULL, NULL, NULL, timeout);
- XBT_DEBUG("Got task %s from %p",(*task)->name,mailbox);
- (*task)->simdata->isused=0;
- }
- CATCH(e) {
- switch (e.category) {
- case cancel_error:
- ret = MSG_HOST_FAILURE;
- break;
- case network_error:
- ret = MSG_TRANSFER_FAILURE;
- break;
- case timeout_error:
- ret = MSG_TIMEOUT;
- break;
- default:
- RETHROW;
- }
- xbt_ex_free(e);
- }
-
-#ifdef HAVE_TRACING
- if (ret != MSG_HOST_FAILURE &&
- ret != MSG_TRANSFER_FAILURE &&
- ret != MSG_TIMEOUT) {
- TRACE_msg_task_get_end(start_time, *task);
- }
-#endif
- MSG_RETURN(ret);
+ return MSG_mailbox_get_task_ext_bounded(mailbox, task, host, timeout, -1.0);
}
/** \ingroup msg_mailbox_management
*/
msg_error_t
MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task,
- msg_host_t host, double timeout, double rate)
+ msg_host_t host, double timeout, double rate)
{
xbt_ex_t e;
msg_error_t ret = MSG_OK;
/* Try to receive it by calling SIMIX network layer */
TRY {
- simcall_comm_recv_bounded(mailbox, task, NULL, NULL, NULL, timeout, rate);
+ simcall_comm_recv(mailbox, task, NULL, NULL, NULL, timeout, rate);
XBT_DEBUG("Got task %s from %p",(*task)->name,mailbox);
(*task)->simdata->isused=0;
}
comm_iprobe True (void*, smx_action_t) (rdv, void*, smx_rdv_t) (src, int) (tag, int) (match_fun, FPtr, simix_match_func_t) (data, void*)
comm_send False (void) (rdv, void*, smx_rdv_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, FPtr, simix_match_func_t) (data, void*) (timeout, double)
comm_isend True (void*, smx_action_t) (rdv, void*, smx_rdv_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, FPtr, simix_match_func_t) (clean_fun, FPtr, simix_clean_func_t) (data, void*) (detached, int)
-comm_recv False (void) (rdv, void*, smx_rdv_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (data, void*) (timeout, double)
-comm_irecv True (void*, smx_action_t) (rdv, void*, smx_rdv_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (data, void*)
-comm_recv_bounded False (void) (rdv, void*, smx_rdv_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (data, void*) (timeout, double) (rate, double)
-comm_irecv_bounded True (void*, smx_action_t) (rdv, void*, smx_rdv_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (data, void*) (rate, double)
+comm_recv False (void) (rdv, void*, smx_rdv_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (data, void*) (timeout, double) (rate, double)
+comm_irecv True (void*, smx_action_t) (rdv, void*, smx_rdv_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (data, void*) (rate, double)
comm_destroy True (void) (comm, void*, smx_action_t)
comm_cancel True (void) (comm, void*, smx_action_t)
comm_waitany False (int) (comms, void*, xbt_dynar_t)
static inline void simcall_comm_recv__set__timeout(smx_simcall_t simcall, double arg){
simcall->args[5].d = arg;
}
+static inline double simcall_comm_recv__get__rate(smx_simcall_t simcall){
+ return simcall->args[6].d;
+}
+static inline void simcall_comm_recv__set__rate(smx_simcall_t simcall, double arg){
+ simcall->args[6].d = arg;
+}
static inline smx_rdv_t simcall_comm_irecv__get__rdv(smx_simcall_t simcall){
return (smx_rdv_t) simcall->args[0].dp;
}
static inline void simcall_comm_irecv__set__data(smx_simcall_t simcall, void* arg){
simcall->args[4].dp = arg;
}
-static inline smx_rdv_t simcall_comm_recv_bounded__get__rdv(smx_simcall_t simcall){
- return (smx_rdv_t) simcall->args[0].dp;
-}
-static inline void simcall_comm_recv_bounded__set__rdv(smx_simcall_t simcall, void* arg){
- simcall->args[0].dp = arg;
-}
-static inline void* simcall_comm_recv_bounded__get__dst_buff(smx_simcall_t simcall){
- return simcall->args[1].dp;
-}
-static inline void simcall_comm_recv_bounded__set__dst_buff(smx_simcall_t simcall, void* arg){
- simcall->args[1].dp = arg;
-}
-static inline size_t* simcall_comm_recv_bounded__get__dst_buff_size(smx_simcall_t simcall){
- return (size_t*) simcall->args[2].dp;
-}
-static inline void simcall_comm_recv_bounded__set__dst_buff_size(smx_simcall_t simcall, void* arg){
- simcall->args[2].dp = arg;
-}
-static inline simix_match_func_t simcall_comm_recv_bounded__get__match_fun(smx_simcall_t simcall){
- return (simix_match_func_t) simcall->args[3].fp;
-}
-static inline void simcall_comm_recv_bounded__set__match_fun(smx_simcall_t simcall, FPtr arg){
- simcall->args[3].fp = arg;
-}
-static inline void* simcall_comm_recv_bounded__get__data(smx_simcall_t simcall){
- return simcall->args[4].dp;
-}
-static inline void simcall_comm_recv_bounded__set__data(smx_simcall_t simcall, void* arg){
- simcall->args[4].dp = arg;
-}
-static inline double simcall_comm_recv_bounded__get__timeout(smx_simcall_t simcall){
- return simcall->args[5].d;
-}
-static inline void simcall_comm_recv_bounded__set__timeout(smx_simcall_t simcall, double arg){
- simcall->args[5].d = arg;
-}
-static inline double simcall_comm_recv_bounded__get__rate(smx_simcall_t simcall){
- return simcall->args[6].d;
-}
-static inline void simcall_comm_recv_bounded__set__rate(smx_simcall_t simcall, double arg){
- simcall->args[6].d = arg;
-}
-static inline smx_rdv_t simcall_comm_irecv_bounded__get__rdv(smx_simcall_t simcall){
- return (smx_rdv_t) simcall->args[0].dp;
-}
-static inline void simcall_comm_irecv_bounded__set__rdv(smx_simcall_t simcall, void* arg){
- simcall->args[0].dp = arg;
-}
-static inline void* simcall_comm_irecv_bounded__get__dst_buff(smx_simcall_t simcall){
- return simcall->args[1].dp;
-}
-static inline void simcall_comm_irecv_bounded__set__dst_buff(smx_simcall_t simcall, void* arg){
- simcall->args[1].dp = arg;
-}
-static inline size_t* simcall_comm_irecv_bounded__get__dst_buff_size(smx_simcall_t simcall){
- return (size_t*) simcall->args[2].dp;
-}
-static inline void simcall_comm_irecv_bounded__set__dst_buff_size(smx_simcall_t simcall, void* arg){
- simcall->args[2].dp = arg;
-}
-static inline simix_match_func_t simcall_comm_irecv_bounded__get__match_fun(smx_simcall_t simcall){
- return (simix_match_func_t) simcall->args[3].fp;
-}
-static inline void simcall_comm_irecv_bounded__set__match_fun(smx_simcall_t simcall, FPtr arg){
- simcall->args[3].fp = arg;
-}
-static inline void* simcall_comm_irecv_bounded__get__data(smx_simcall_t simcall){
- return simcall->args[4].dp;
-}
-static inline void simcall_comm_irecv_bounded__set__data(smx_simcall_t simcall, void* arg){
- simcall->args[4].dp = arg;
-}
-static inline double simcall_comm_irecv_bounded__get__rate(smx_simcall_t simcall){
+static inline double simcall_comm_irecv__get__rate(smx_simcall_t simcall){
return simcall->args[5].d;
}
-static inline void simcall_comm_irecv_bounded__set__rate(smx_simcall_t simcall, double arg){
+static inline void simcall_comm_irecv__set__rate(smx_simcall_t simcall, double arg){
simcall->args[5].d = arg;
}
static inline smx_action_t simcall_comm_destroy__get__comm(smx_simcall_t simcall){
}
return self->simcall.result.dp;
}
- inline static void simcall_BODY_comm_recv(smx_rdv_t rdv, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, void* data, double timeout) {
+ inline static void simcall_BODY_comm_recv(smx_rdv_t rdv, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, void* data, double timeout, double rate) {
smx_process_t self = SIMIX_process_self();
self->simcall.call = SIMCALL_COMM_RECV;
memset(&self->simcall.result, 0, sizeof(self->simcall.result));
self->simcall.args[3].fp = (FPtr) match_fun;
self->simcall.args[4].dp = (void*) data;
self->simcall.args[5].d = (double) timeout;
- if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
- SIMIX_process_yield(self);
- } else {
- SIMIX_simcall_pre(&self->simcall, 0);
- }
-
- }
- inline static smx_action_t simcall_BODY_comm_irecv(smx_rdv_t rdv, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, void* data) {
- smx_process_t self = SIMIX_process_self();
- self->simcall.call = SIMCALL_COMM_IRECV;
- memset(&self->simcall.result, 0, sizeof(self->simcall.result));
- memset(self->simcall.args, 0, sizeof(self->simcall.args));
- self->simcall.args[0].dp = (void*) rdv;
- self->simcall.args[1].dp = (void*) dst_buff;
- self->simcall.args[2].dp = (void*) dst_buff_size;
- self->simcall.args[3].fp = (FPtr) match_fun;
- self->simcall.args[4].dp = (void*) data;
- if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
- SIMIX_process_yield(self);
- } else {
- SIMIX_simcall_pre(&self->simcall, 0);
- }
- return self->simcall.result.dp;
- }
- inline static void simcall_BODY_comm_recv_bounded(smx_rdv_t rdv, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, void* data, double timeout, double rate) {
- smx_process_t self = SIMIX_process_self();
- self->simcall.call = SIMCALL_COMM_RECV_BOUNDED;
- memset(&self->simcall.result, 0, sizeof(self->simcall.result));
- memset(self->simcall.args, 0, sizeof(self->simcall.args));
- self->simcall.args[0].dp = (void*) rdv;
- self->simcall.args[1].dp = (void*) dst_buff;
- self->simcall.args[2].dp = (void*) dst_buff_size;
- self->simcall.args[3].fp = (FPtr) match_fun;
- self->simcall.args[4].dp = (void*) data;
- self->simcall.args[5].d = (double) timeout;
self->simcall.args[6].d = (double) rate;
if (self != simix_global->maestro_process) {
XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
}
}
- inline static smx_action_t simcall_BODY_comm_irecv_bounded(smx_rdv_t rdv, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, void* data, double rate) {
+ inline static smx_action_t simcall_BODY_comm_irecv(smx_rdv_t rdv, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, void* data, double rate) {
smx_process_t self = SIMIX_process_self();
- self->simcall.call = SIMCALL_COMM_IRECV_BOUNDED;
+ self->simcall.call = SIMCALL_COMM_IRECV;
memset(&self->simcall.result, 0, sizeof(self->simcall.result));
memset(self->simcall.args, 0, sizeof(self->simcall.args));
self->simcall.args[0].dp = (void*) rdv;
break;
case SIMCALL_COMM_RECV:
- SIMIX_pre_comm_recv(simcall , (smx_rdv_t) simcall->args[0].dp, simcall->args[1].dp, (size_t*) simcall->args[2].dp, (simix_match_func_t) simcall->args[3].fp, simcall->args[4].dp, simcall->args[5].d);
+ SIMIX_pre_comm_recv(simcall , (smx_rdv_t) simcall->args[0].dp, simcall->args[1].dp, (size_t*) simcall->args[2].dp, (simix_match_func_t) simcall->args[3].fp, simcall->args[4].dp, simcall->args[5].d, simcall->args[6].d);
break;
case SIMCALL_COMM_IRECV:
- simcall->result.dp = SIMIX_pre_comm_irecv(simcall , (smx_rdv_t) simcall->args[0].dp, simcall->args[1].dp, (size_t*) simcall->args[2].dp, (simix_match_func_t) simcall->args[3].fp, simcall->args[4].dp);
- SIMIX_simcall_answer(simcall);
- break;
-
-case SIMCALL_COMM_RECV_BOUNDED:
- SIMIX_pre_comm_recv_bounded(simcall , (smx_rdv_t) simcall->args[0].dp, simcall->args[1].dp, (size_t*) simcall->args[2].dp, (simix_match_func_t) simcall->args[3].fp, simcall->args[4].dp, simcall->args[5].d, simcall->args[6].d);
- break;
-
-case SIMCALL_COMM_IRECV_BOUNDED:
- simcall->result.dp = SIMIX_pre_comm_irecv_bounded(simcall , (smx_rdv_t) simcall->args[0].dp, simcall->args[1].dp, (size_t*) simcall->args[2].dp, (simix_match_func_t) simcall->args[3].fp, simcall->args[4].dp, simcall->args[5].d);
+ simcall->result.dp = SIMIX_pre_comm_irecv(simcall , (smx_rdv_t) simcall->args[0].dp, simcall->args[1].dp, (size_t*) simcall->args[2].dp, (simix_match_func_t) simcall->args[3].fp, simcall->args[4].dp, simcall->args[5].d);
SIMIX_simcall_answer(simcall);
break;
SIMCALL_COMM_ISEND,
SIMCALL_COMM_RECV,
SIMCALL_COMM_IRECV,
-SIMCALL_COMM_RECV_BOUNDED,
-SIMCALL_COMM_IRECV_BOUNDED,
SIMCALL_COMM_DESTROY,
SIMCALL_COMM_CANCEL,
SIMCALL_COMM_WAITANY,
}
-static inline smx_action_t simcall_comm_irecv_bounded__get__result(smx_simcall_t simcall){
- return (smx_action_t) simcall->result.dp;
-}
-static inline void simcall_comm_irecv_bounded__set__result(smx_simcall_t simcall, void* result){
- simcall->result.dp = result;
-}
-
-
static inline int simcall_comm_waitany__get__result(smx_simcall_t simcall){
[SIMCALL_COMM_ISEND] = "SIMCALL_COMM_ISEND",
[SIMCALL_COMM_RECV] = "SIMCALL_COMM_RECV",
[SIMCALL_COMM_IRECV] = "SIMCALL_COMM_IRECV",
-[SIMCALL_COMM_RECV_BOUNDED] = "SIMCALL_COMM_RECV_BOUNDED",
-[SIMCALL_COMM_IRECV_BOUNDED] = "SIMCALL_COMM_IRECV_BOUNDED",
[SIMCALL_COMM_DESTROY] = "SIMCALL_COMM_DESTROY",
[SIMCALL_COMM_CANCEL] = "SIMCALL_COMM_CANCEL",
[SIMCALL_COMM_WAITANY] = "SIMCALL_COMM_WAITANY",
-/* Copyright (c) 2009-2013. The SimGrid Team.
+/* Copyright (c) 2009-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
}
void SIMIX_pre_comm_recv(smx_simcall_t simcall, smx_rdv_t rdv,
- void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data, double timeout){
+ void *dst_buff, size_t *dst_buff_size,
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double timeout, double rate)
+{
smx_action_t comm = SIMIX_comm_irecv(simcall->issuer, rdv, dst_buff,
- dst_buff_size, match_fun, data);
- simcall->mc_value = 0;
- SIMIX_pre_comm_wait(simcall, comm, timeout);
-}
-
-void SIMIX_pre_comm_recv_bounded(smx_simcall_t simcall, smx_rdv_t rdv,
- void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data, double timeout, double rate){
- smx_action_t comm = SIMIX_comm_irecv_bounded(simcall->issuer, rdv, dst_buff,
dst_buff_size, match_fun, data, rate);
simcall->mc_value = 0;
SIMIX_pre_comm_wait(simcall, comm, timeout);
smx_action_t SIMIX_pre_comm_irecv(smx_simcall_t simcall, smx_rdv_t rdv,
void *dst_buff, size_t *dst_buff_size,
int (*match_fun)(void *, void *, smx_action_t),
- void *data){
- return SIMIX_comm_irecv(simcall->issuer, rdv, dst_buff, dst_buff_size,
- match_fun, data);
-}
-
-smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
- void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t), void *data)
+ void *data, double rate)
{
- XBT_DEBUG("recv from %p %p\n", rdv, rdv->comm_fifo);
- smx_action_t this_action = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
-
- smx_action_t other_action;
- //communication already done, get it inside the fifo of completed comms
- //permanent receive v1
- //int already_received=0;
- if(rdv->permanent_receiver && xbt_fifo_size(rdv->done_comm_fifo)!=0){
-
- XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication\n");
- //find a match in the already received fifo
- other_action = SIMIX_fifo_get_comm(rdv->done_comm_fifo, SIMIX_COMM_SEND, match_fun, data, this_action);
- //if not found, assume the receiver came first, register it to the mailbox in the classical way
- if (!other_action) {
- XBT_DEBUG("We have messages in the permanent receive list, but not the one we are looking for, pushing request into fifo\n");
- other_action = this_action;
- SIMIX_rdv_push(rdv, this_action);
- }else{
- if(other_action->comm.surf_comm && SIMIX_comm_get_remains(other_action)==0.0)
- {
- XBT_DEBUG("comm %p has been already sent, and is finished, destroy it\n",&(other_action->comm));
- other_action->state = SIMIX_DONE;
- other_action->comm.type = SIMIX_COMM_DONE;
- other_action->comm.rdv = NULL;
- //SIMIX_comm_destroy(this_action);
- //--smx_total_comms; // this creation was a pure waste
- //already_received=1;
- //other_action->comm.refcount--;
- }/*else{
- XBT_DEBUG("Not yet finished, we have to wait %d\n", xbt_fifo_size(rdv->comm_fifo));
- }*/
- other_action->comm.refcount--;
- SIMIX_comm_destroy(this_action);
- --smx_total_comms; // this creation was a pure waste
- }
- }else{
- /* Prepare an action describing us, so that it gets passed to the user-provided filter of other side */
-
- /* Look for communication action matching our needs. We also provide a description of
- * ourself so that the other side also gets a chance of choosing if it wants to match with us.
- *
- * If it is not found then push our communication into the rendez-vous point */
- other_action = SIMIX_fifo_get_comm(rdv->comm_fifo, SIMIX_COMM_SEND, match_fun, data, this_action);
-
- if (!other_action) {
- XBT_DEBUG("Receive pushed first %d\n", xbt_fifo_size(rdv->comm_fifo));
- other_action = this_action;
- SIMIX_rdv_push(rdv, this_action);
- } else {
- SIMIX_comm_destroy(this_action);
- --smx_total_comms; // this creation was a pure waste
- other_action->state = SIMIX_READY;
- other_action->comm.type = SIMIX_COMM_READY;
- //other_action->comm.refcount--;
- }
- xbt_fifo_push(dst_proc->comms, other_action);
- }
-
- /* Setup communication action */
- other_action->comm.dst_proc = dst_proc;
- other_action->comm.dst_buff = dst_buff;
- other_action->comm.dst_buff_size = dst_buff_size;
- other_action->comm.dst_data = data;
-
- other_action->comm.match_fun = match_fun;
-
-
- /*if(already_received)//do the actual copy, because the first one after the comm didn't have all the info
- SIMIX_comm_copy_data(other_action);*/
-
-
- if (MC_is_active()) {
- other_action->state = SIMIX_RUNNING;
- return other_action;
- }
-
- SIMIX_comm_start(other_action);
- // }
- return other_action;
-}
-
-smx_action_t SIMIX_pre_comm_irecv_bounded(smx_simcall_t simcall, smx_rdv_t rdv,
- void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data, double rate){
- return SIMIX_comm_irecv_bounded(simcall->issuer, rdv, dst_buff, dst_buff_size,
+ return SIMIX_comm_irecv(simcall->issuer, rdv, dst_buff, dst_buff_size,
match_fun, data, rate);
}
-smx_action_t SIMIX_comm_irecv_bounded(smx_process_t dst_proc, smx_rdv_t rdv,
+smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t), void *data, double rate)
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double rate)
{
XBT_DEBUG("recv from %p %p\n", rdv, rdv->comm_fifo);
smx_action_t this_action = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
other_action->comm.dst_buff_size = dst_buff_size;
other_action->comm.dst_data = data;
- if (rate < other_action->comm.rate || other_action->comm.rate == -1.0)
- other_action->comm.rate = rate;
+ if (rate != -1.0 &&
+ (other_action->comm.rate == -1.0 || rate < other_action->comm.rate))
+ other_action->comm.rate = rate;
other_action->comm.match_fun = match_fun;
-/* Copyright (c) 2007-2010, 2012-2013. The SimGrid Team.
+/* Copyright (c) 2007-2010, 2012-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
int detached);
smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
void *dst_buff, size_t *dst_buff_size,
- int (*)(void *, void *, smx_action_t), void *data);
-smx_action_t SIMIX_comm_irecv_bounded(smx_process_t dst_proc, smx_rdv_t rdv,
- void *dst_buff, size_t *dst_buff_size,
- int (*)(void *, void *, smx_action_t), void *data, double rate);
+ int (*)(void *, void *, smx_action_t),
+ void *data, double rate);
void SIMIX_comm_destroy(smx_action_t action);
void SIMIX_comm_destroy_internal_actions(smx_action_t action);
smx_action_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_rdv_t rdv, int src,
void (*clean_fun)(void *),
void *data, int detached);
void SIMIX_pre_comm_recv(smx_simcall_t simcall, smx_rdv_t rdv,
- void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data, double timeout);
-void SIMIX_pre_comm_recv_bounded(smx_simcall_t simcall, smx_rdv_t rdv,
- void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data, double timeout, double rate);
+ void *dst_buff, size_t *dst_buff_size,
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double timeout, double rate);
smx_action_t SIMIX_pre_comm_irecv(smx_simcall_t simcall, smx_rdv_t rdv,
- void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t),
- void *data);
-smx_action_t SIMIX_pre_comm_irecv_bounded(smx_simcall_t simcall, smx_rdv_t rdv,
void *dst_buff, size_t *dst_buff_size,
int (*match_fun)(void *, void *, smx_action_t),
void *data, double rate);
/* smx_user.c - public interface to simix */
-/* Copyright (c) 2010-2013. The SimGrid Team.
+/* Copyright (c) 2010-2014. The SimGrid Team.
All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
src_buff_size, match_fun,
clean_fun, data, detached);
}
+
/**
* \ingroup simix_comm_management
*/
void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double timeout, double rate)
{
xbt_assert(isfinite(timeout), "timeout is not finite!");
xbt_assert(rdv, "No rendez-vous point defined for recv");
if (MC_is_active()) {
/* the model-checker wants two separate simcalls */
- smx_action_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */
- comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
- match_fun, data);
+ smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
+ match_fun, data, rate);
simcall_comm_wait(comm, timeout);
- comm = NULL;
}
else {
simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
- match_fun, data, timeout);
- }
-}
-/**
- * \ingroup simix_comm_management
- */
-smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t), void *data)
-{
- xbt_assert(rdv, "No rendez-vous point defined for irecv");
-
- return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
- match_fun, data);
-}
-
-
-/**
- * \ingroup simix_comm_management
- */
-void simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout, double rate)
-{
- xbt_assert(isfinite(timeout), "timeout is not finite!");
- xbt_assert(rdv, "No rendez-vous point defined for recv");
-
- if (MC_is_active()) {
- /* the model-checker wants two separate simcalls */
- smx_action_t comm = simcall_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
- match_fun, data, rate);
- simcall_comm_wait(comm, timeout);
- }
- else {
- simcall_BODY_comm_recv_bounded(rdv, dst_buff, dst_buff_size,
match_fun, data, timeout, rate);
}
}
/**
* \ingroup simix_comm_management
*/
-smx_action_t simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
- int (*match_fun)(void *, void *, smx_action_t), void *data, double rate)
+smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double rate)
{
xbt_assert(rdv, "No rendez-vous point defined for irecv");
- return simcall_BODY_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
+ return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
match_fun, data, rate);
}
-/* Copyright (c) 2007-2013. The SimGrid Team.
+/* Copyright (c) 2007-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
request->real_size=request->size;
smpi_datatype_use(request->old_type);
smpi_comm_use(request->comm);
- request->action = simcall_comm_irecv(mailbox, request->buf, &request->real_size, &match_recv, request);
+ request->action = simcall_comm_irecv(mailbox, request->buf,
+ &request->real_size, &match_recv,
+ request, -1.0);
//integrate pseudo-timing for buffering of small messages, do not bother to execute the simcall if 0
double sleeptime = request->detached ? smpi_or(request->size) : 0.0;