From: mquinson Date: Tue, 7 Dec 2010 09:51:45 +0000 (+0000) Subject: stubs for comm_testany, implemented with comm_waitany for now. That's crude but tempo... X-Git-Tag: v3.6_beta2~897 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f4a117d3526fa2bc565827bd37ea5a8a194ed82d?hp=162cef1075ff72cda87df61bf46c8d4ba3fa4e90 stubs for comm_testany, implemented with comm_waitany for now. That's crude but temporarly git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9026 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/include/msg/msg.h b/include/msg/msg.h index 2805298547..8850105c0b 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -181,6 +181,7 @@ XBT_PUBLIC(MSG_error_t) XBT_PUBLIC(msg_comm_t) MSG_task_isend(m_task_t task, const char *alias); XBT_PUBLIC(msg_comm_t) MSG_task_irecv(m_task_t * task, const char *alias); XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm); +XBT_PUBLIC(int) MSG_comm_testany(xbt_dynar_t comms); XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm); XBT_PUBLIC(MSG_error_t) MSG_comm_wait(msg_comm_t comm, double timeout); XBT_PUBLIC(void) MSG_comm_waitall(msg_comm_t * comm, int nb_elem, diff --git a/include/simix/simix.h b/include/simix/simix.h index 0757da1a03..fe8bd2f43d 100644 --- a/include/simix/simix.h +++ b/include/simix/simix.h @@ -178,6 +178,7 @@ XBT_INLINE XBT_PUBLIC(void) SIMIX_req_comm_cancel(smx_action_t comm); XBT_PUBLIC(unsigned int) SIMIX_req_comm_waitany(xbt_dynar_t comms); XBT_PUBLIC(void) SIMIX_req_comm_wait(smx_action_t comm, double timeout); XBT_PUBLIC(int) SIMIX_req_comm_test(smx_action_t comm); +XBT_PUBLIC(int) SIMIX_req_comm_testany(xbt_dynar_t comms); /* Getters and setters */ XBT_PUBLIC(double) SIMIX_req_comm_get_remains(smx_action_t comm); diff --git a/src/msg/gos.c b/src/msg/gos.c index bb22ab20ac..3749d9c0e8 100644 --- a/src/msg/gos.c +++ b/src/msg/gos.c @@ -546,6 +546,18 @@ int MSG_comm_waitany(xbt_dynar_t comms) return SIMIX_req_comm_waitany(comms); } +/** \ingroup msg_gos_functions +* \brief This function wait for the first completed communication +* +* It takes on parameter. +* \param comms a vector of communication +* \return the position of the completed communication, if any, or -1 if none was completed +*/ +int MSG_comm_testany(xbt_dynar_t comms) +{ + return SIMIX_req_comm_testany(comms); +} + m_task_t MSG_comm_get_task(msg_comm_t comm) { xbt_assert0(comm, "Invalid parameters"); diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 182c5621c4..60b71b1a9f 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1,5 +1,6 @@ #include "private.h" +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); /** * \brief Returns a host given its name. * @@ -660,6 +661,20 @@ unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms) return req.comm_waitany.result; } +int SIMIX_req_comm_testany(xbt_dynar_t comms) +{ + s_smx_req_t req; + if (xbt_dynar_length(comms)==0) + return -1; + + WARN0("SIMIX_comm_testany is not implemented yet. Using waitany instead. This changes the semantic..."); + req.call = REQ_COMM_WAITANY; + req.comm_waitany.comms = comms; + + SIMIX_request_push(&req); + return req.comm_waitany.result; +} + void SIMIX_req_comm_wait(smx_action_t comm, double timeout) { s_smx_req_t req;