A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Make SIMIX_req_host_execution_wait to also destroy the execution action when done.
[simgrid.git]
/
src
/
msg
/
gos.c
diff --git
a/src/msg/gos.c
b/src/msg/gos.c
index
3010fa0
..
ace7cc7
100644
(file)
--- a/
src/msg/gos.c
+++ b/
src/msg/gos.c
@@
-38,6
+38,7
@@
MSG_error_t MSG_task_execute(m_task_t task)
{
simdata_task_t simdata = NULL;
m_process_t self = MSG_process_self();
+ e_smx_state_t comp_state;
CHECK_HOST();
simdata = task->simdata;
@@
-64,22
+65,21
@@
MSG_error_t MSG_task_execute(m_task_t task)
simdata->isused=1;
simdata->compute =
SIMIX_req_host_execute(task->name, SIMIX_host_self(),
- simdata->computation_amount
);
-
SIMIX_req_host_execution_set_priority(simdata->compute,
simdata->priority);
+ simdata->computation_amount
,
+
simdata->priority);
#ifdef HAVE_TRACING
SIMIX_req_set_category(simdata->compute, task->category);
#endif
self->simdata->waiting_action = simdata->compute;
- SIMIX_req_host_execution_wait(simdata->compute);
+
comp_state =
SIMIX_req_host_execution_wait(simdata->compute);
self->simdata->waiting_action = NULL;
simdata->isused=0;
- DEBUG2("Execution task '%s' finished in state %d", task->name,
SIMIX_req_host_execution_get_state(task->simdata->compute)
);
- if (
SIMIX_req_host_execution_get_state(task->simdata->compute)
== SIMIX_DONE) {
+ DEBUG2("Execution task '%s' finished in state %d", task->name,
comp_state
);
+ if (
comp_state
== SIMIX_DONE) {
/* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_req_host_execution_destroy(task->simdata->compute);
simdata->computation_amount = 0.0;
simdata->comm = NULL;
simdata->compute = NULL;
@@
-89,7
+89,6
@@
MSG_error_t MSG_task_execute(m_task_t task)
MSG_RETURN(MSG_OK);
} else if (SIMIX_req_host_get_state(SIMIX_host_self()) == 0) {
/* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_req_host_execution_destroy(task->simdata->compute);
simdata->comm = NULL;
simdata->compute = NULL;
#ifdef HAVE_TRACING
@@
-98,7
+97,6
@@
MSG_error_t MSG_task_execute(m_task_t task)
MSG_RETURN(MSG_HOST_FAILURE);
} else {
/* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_req_host_execution_destroy(task->simdata->compute);
simdata->comm = NULL;
simdata->compute = NULL;
#ifdef HAVE_TRACING
@@
-167,6
+165,7
@@
MSG_parallel_task_create(const char *name, int host_nb,
MSG_error_t MSG_parallel_task_execute(m_task_t task)
{
simdata_task_t simdata = NULL;
+ e_smx_state_t comp_state;
m_process_t self = MSG_process_self();
CHECK_HOST();
@@
-191,29
+190,26
@@
MSG_error_t MSG_parallel_task_execute(m_task_t task)
DEBUG1("Parallel execution action created: %p", simdata->compute);
self->simdata->waiting_action = simdata->compute;
- SIMIX_req_host_execution_wait(simdata->compute);
+
comp_state =
SIMIX_req_host_execution_wait(simdata->compute);
self->simdata->waiting_action = NULL;
- DEBUG2("Finished waiting for execution of action %p, state = %d", simdata->compute,
SIMIX_req_host_execution_get_state(task->simdata->compute)
);
+ DEBUG2("Finished waiting for execution of action %p, state = %d", simdata->compute,
comp_state
);
simdata->isused=0;
- if (
SIMIX_req_host_execution_get_state(task->simdata->compute)
== SIMIX_DONE) {
+ if (
comp_state
== SIMIX_DONE) {
/* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_req_host_execution_destroy(task->simdata->compute);
simdata->computation_amount = 0.0;
simdata->comm = NULL;
simdata->compute = NULL;
MSG_RETURN(MSG_OK);
} else if (SIMIX_req_host_get_state(SIMIX_host_self()) == 0) {
/* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_req_host_execution_destroy(task->simdata->compute);
simdata->comm = NULL;
simdata->compute = NULL;
MSG_RETURN(MSG_HOST_FAILURE);
} else {
/* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_req_host_execution_destroy(task->simdata->compute);
simdata->comm = NULL;
simdata->compute = NULL;
MSG_RETURN(MSG_TASK_CANCELLED);
@@
-447,29
+443,78
@@
msg_comm_t MSG_task_irecv(m_task_t * task, const char *alias)
}
/** \ingroup msg_gos_functions
- * \brief Test the status of a communication.
- *
- * It takes one parameter.
- * \param comm the communication to test.
- * \return the status of the communication:
- * TRUE : the communication is completed
- * FALSE: the communication is incompleted
+ * \brief Returns whether a communication is finished.
+ * \param comm the communication to test
+ * \return TRUE if the communication is finished
+ * (but it may have failed, use MSG_comm_get_status() to know its status)
+ * or FALSE if the communication is not finished yet
* If the status is FALSE, don't forget to use MSG_process_sleep() after the test.
*/
int MSG_comm_test(msg_comm_t comm)
{
- return SIMIX_req_comm_test(comm);
+ xbt_ex_t e;
+ int finished = 0;
+ TRY {
+ finished = SIMIX_req_comm_test(comm);
+ }
+ CATCH(e) {
+ switch (e.category) {
+
+ case host_error:
+ case network_error:
+ case timeout_error:
+ finished = 1;
+ break;
+
+ default:
+ RETHROW;
+ }
+ xbt_ex_free(e);
+ }
+ return finished;
+}
+
+/** \ingroup msg_gos_functions
+ * \brief This function checks if a communication is finished
+ * \param comms a vector of communications
+ * \return the position of the finished communication if any
+ * (but it may have failed, use MSG_comm_get_status() to know its status),
+ * or -1 if none is finished
+ */
+int MSG_comm_testany(xbt_dynar_t comms)
+{
+ xbt_ex_t e;
+ int finished_index = -1;
+ TRY {
+ finished_index = SIMIX_req_comm_testany(comms);
+ }
+ CATCH(e) {
+ switch (e.category) {
+
+ case host_error:
+ case network_error:
+ case timeout_error:
+ finished_index = e.value;
+ break;
+
+ default:
+ RETHROW;
+ }
+ xbt_ex_free(e);
+ }
+ return finished_index;
}
/** \ingroup msg_gos_functions
- * \brief After received TRUE to MSG_comm_test(), the communication
must
be destroyed.
+ * \brief After received TRUE to MSG_comm_test(), the communication
should
be destroyed.
*
* It takes one parameter.
* \param comm the communication to destroy.
*/
void MSG_comm_destroy(msg_comm_t comm)
{
- if (SIMIX_req_comm_get_src_proc(comm) != SIMIX_process_self()) {
+ if (SIMIX_req_comm_get_src_proc(comm) != SIMIX_process_self()
+ && MSG_comm_get_status(comm) == MSG_OK) {
m_task_t task;
task = (m_task_t) SIMIX_req_comm_get_src_buff(comm);
task->simdata->isused=0;
@@
-512,7
+557,7
@@
MSG_error_t MSG_comm_wait(msg_comm_t comm, double timeout)
res = MSG_TIMEOUT;
break;
default:
-
xbt_die(bprintf("Unhandled SIMIX network exception: %s", e.msg))
;
+
RETHROW
;
}
xbt_ex_free(e);
}
@@
-544,19
+589,64
@@
void MSG_comm_waitall(msg_comm_t * comm, int nb_elem, double timeout)
*/
int MSG_comm_waitany(xbt_dynar_t comms)
{
- return SIMIX_req_comm_waitany(comms);
+ xbt_ex_t e;
+ int finished_index = -1;
+ TRY {
+ finished_index = SIMIX_req_comm_waitany(comms);
+ }
+ CATCH(e) {
+ switch (e.category) {
+
+ case host_error:
+ case network_error:
+ case timeout_error:
+ finished_index = e.value;
+ default:
+ RETHROW;
+ }
+ xbt_ex_free(e);
+ }
+ return finished_index;
}
-/** \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);
+/**
+ * \ingroup msg_gos_functions
+ * \brief Returns the error (if any) that occured during a finished communication.
+ * \param comm a finished communication
+ * \return the status of the communication, or MSG_OK if the communication
+ * was successfully completed
+ */
+MSG_error_t MSG_comm_get_status(msg_comm_t comm) {
+
+ MSG_error_t result;
+ e_smx_state_t smx_state = SIMIX_req_comm_get_state(comm);
+
+ switch (smx_state) {
+
+ case SIMIX_CANCELED:
+ result = MSG_TASK_CANCELLED;
+ break;
+
+ case SIMIX_FAILED:
+ case SIMIX_SRC_HOST_FAILURE:
+ case SIMIX_DST_HOST_FAILURE:
+ result = MSG_HOST_FAILURE;
+ break;
+
+ case SIMIX_LINK_FAILURE:
+ result = MSG_TRANSFER_FAILURE;
+ break;
+
+ case SIMIX_SRC_TIMEOUT:
+ case SIMIX_DST_TIMEOUT:
+ result = MSG_TIMEOUT;
+ break;
+
+ default:
+ result = MSG_OK;
+ break;
+ }
+ return result;
}
m_task_t MSG_comm_get_task(msg_comm_t comm)