XBT_PUBLIC(int) simcall_comm_testany(xbt_dynar_t comms);
/* Getters and setters */
-XBT_PUBLIC(double) simcall_comm_get_remains(smx_synchro_t comm);
XBT_PUBLIC(void *) simcall_comm_get_src_data(smx_synchro_t comm);
XBT_PUBLIC(void *) simcall_comm_get_dst_data(smx_synchro_t comm);
XBT_PUBLIC(smx_process_t) simcall_comm_get_src_proc(smx_synchro_t comm);
*/
double MSG_task_get_remaining_communication(msg_task_t task)
{
- xbt_assert((task != NULL) && (task->simdata != NULL), "Invalid parameter");
XBT_DEBUG("calling simcall_communication_get_remains(%p)", task->simdata->comm);
- return simcall_comm_get_remains(task->simdata->comm);
+ return task->simdata->comm->remains();
}
/** \ingroup m_task_management
surf_comm->cancel();
}
}
+
+/** @brief get the amount remaining from the communication */
+double simgrid::simix::Comm::remains() {
+ switch (state) {
+
+ case SIMIX_RUNNING:
+ return surf_comm->getRemains();
+ break;
+
+ case SIMIX_WAITING:
+ case SIMIX_READY:
+ return 0; /*FIXME: check what should be returned */
+ break;
+
+ default:
+ return 0; /*FIXME: is this correct? */
+ break;
+ }
+}
void suspend();
void resume();
void cancel();
+ double remains();
e_smx_comm_type_t type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */
return simcall_BODY_comm_test(comm);
}
-/**
- * \ingroup simix_comm_management
- *
- */
-double simcall_comm_get_remains(smx_synchro_t comm)
-{
- return simcall_BODY_comm_get_remains(comm);
-}
-
/**
* \ingroup simix_comm_management
*
simcall->result.i = result;
}
-static inline smx_synchro_t simcall_comm_get_remains__get__comm(smx_simcall_t simcall) {
- return (smx_synchro_t) simcall->args[0].dp;
-}
-static inline void simcall_comm_get_remains__set__comm(smx_simcall_t simcall, void* arg) {
- simcall->args[0].dp = arg;
-}
-static inline double simcall_comm_get_remains__get__result(smx_simcall_t simcall){
- return simcall->result.d;
-}
-static inline void simcall_comm_get_remains__set__result(smx_simcall_t simcall, double result){
- simcall->result.d = result;
-}
-
static inline smx_synchro_t simcall_comm_get_src_data__get__comm(smx_simcall_t simcall) {
return (smx_synchro_t) simcall->args[0].dp;
}
return (int) self->simcall.result.i;
}
-inline static double simcall_BODY_comm_get_remains(smx_synchro_t comm) {
- smx_process_t self = SIMIX_process_self();
-
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) SIMIX_comm_get_remains(comm);
- /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
-
- self->simcall.call = SIMCALL_COMM_GET_REMAINS;
- memset(&self->simcall.result, 0, sizeof(self->simcall.result));
- memset(self->simcall.args, 0, sizeof(self->simcall.args));
- self->simcall.args[0].dp = (void*) comm;
- 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_handle(&self->simcall, 0);
- }
- return (double) self->simcall.result.d;
- }
-
inline static void* simcall_BODY_comm_get_src_data(smx_synchro_t comm) {
smx_process_t self = SIMIX_process_self();
SIMCALL_COMM_WAIT,
SIMCALL_COMM_TEST,
SIMCALL_COMM_TESTANY,
- SIMCALL_COMM_GET_REMAINS,
SIMCALL_COMM_GET_SRC_DATA,
SIMCALL_COMM_GET_DST_DATA,
SIMCALL_COMM_GET_SRC_PROC,
"SIMCALL_COMM_WAIT",
"SIMCALL_COMM_TEST",
"SIMCALL_COMM_TESTANY",
- "SIMCALL_COMM_GET_REMAINS",
"SIMCALL_COMM_GET_SRC_DATA",
"SIMCALL_COMM_GET_DST_DATA",
"SIMCALL_COMM_GET_SRC_PROC",
simcall_HANDLER_comm_testany(simcall , (xbt_dynar_t) simcall->args[0].dp);
break;
-case SIMCALL_COMM_GET_REMAINS:
- simcall->result.d = SIMIX_comm_get_remains((smx_synchro_t) simcall->args[0].dp);
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_COMM_GET_SRC_DATA:
simcall->result.dp = SIMIX_comm_get_src_data((smx_synchro_t) simcall->args[0].dp);
SIMIX_simcall_answer(simcall);
-# Copyright (c) 2014. The SimGrid Team. All rights reserved.
+# Copyright (c) 2014-2016. The SimGrid Team. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
Blck H comm_wait (void) (comm, void*, smx_synchro_t) (timeout, double)
Blck H comm_test (int) (comm, void*, smx_synchro_t)
Blck H comm_testany (int) (comms, void*, xbt_dynar_t)
-Func - comm_get_remains (double) (comm, void*, smx_synchro_t)
Func - comm_get_src_data (void*) (comm, void*, smx_synchro_t)
Func - comm_get_dst_data (void*) (comm, void*, smx_synchro_t)
Func - comm_get_src_proc (void*, smx_process_t) (comm, void*, smx_synchro_t)
} else {
simgrid::simix::Comm *other_comm = static_cast<simgrid::simix::Comm*>(other_synchro);
- if(other_comm->surf_comm && SIMIX_comm_get_remains(other_comm)==0.0) {
+ if(other_comm->surf_comm && other_comm->remains()==0.0) {
XBT_DEBUG("comm %p has been already sent, and is finished, destroy it",other_comm);
other_comm->state = SIMIX_DONE;
other_comm->type = SIMIX_COMM_DONE;
/************* synchro Getters **************/
-/**
- * \brief get the amount remaining from the communication
- * \param synchro The communication
- */
-double SIMIX_comm_get_remains(smx_synchro_t synchro)
-{
- if(!synchro)
- return 0;
- simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
-
- double remains;
- switch (synchro->state) {
-
- case SIMIX_RUNNING:
- remains = comm->surf_comm->getRemains();
- break;
-
- case SIMIX_WAITING:
- case SIMIX_READY:
- remains = 0; /*FIXME: check what should be returned */
- break;
-
- default:
- remains = 0; /*FIXME: is this correct? */
- break;
- }
- return remains;
-}
-
/**
* \brief Return the user data associated to the sender of the communication
* \param synchro The communication
XBT_PRIVATE smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src,
int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data);
XBT_PRIVATE void SIMIX_post_comm(smx_synchro_t synchro);
-XBT_PRIVATE double SIMIX_comm_get_remains(smx_synchro_t synchro);
XBT_PRIVATE smx_process_t SIMIX_comm_get_src_proc(smx_synchro_t synchro);
XBT_PRIVATE smx_process_t SIMIX_comm_get_dst_proc(smx_synchro_t synchro);