XBT_PUBLIC(void*) SIMIX_process_self_get_data(smx_process_t self);
XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t);
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));
}
/**
- * \brief Move a process to the list of processes to destroy.
+ * \brief Returns whether a process has pending asynchronous communications.
+ * \return true if there are asynchronous communications in this process
+ */
+int SIMIX_process_has_pending_comms(smx_process_t process) {
+
+ return xbt_fifo_size(process->comms) > 0;
+}
+
+/**
+ * \brief Moves a process to the list of processes to destroy.
*/
void SIMIX_process_cleanup(smx_process_t process)
{
void smpi_process_init(int *argc, char ***argv);
void smpi_process_destroy(void);
+void smpi_process_finalize(void);
smpi_process_data_t smpi_process_data(void);
smpi_process_data_t smpi_process_remote_data(int index);
void smpi_mpi_wait(MPI_Request * request, MPI_Status * status)
{
print_request("Waiting", *request);
- if ((*request)->action != NULL )
- SIMIX_req_comm_wait((*request)->action, -1.0);
+ if ((*request)->action != NULL) {
+
+ SIMIX_req_comm_wait((*request)->action, -1.0);
+ }
finish_wait(request, status);
}
XBT_DEBUG("<%d> Process left the game", index);
}
+/**
+ * @brief Prepares the current process for termination.
+ */
+void smpi_process_finalize(void)
+{
+ // wait for all pending asynchronous comms to finish
+ while (SIMIX_process_has_pending_comms(SIMIX_process_self())) {
+ SIMIX_req_process_sleep(1);
+ }
+}
+
int smpi_process_argc(void) {
smpi_process_data_t data = smpi_process_data();
int PMPI_Finalize(void)
{
+ smpi_process_finalize();
smpi_bench_end();
#ifdef HAVE_TRACING
TRACE_smpi_finalize(smpi_process_index());