2004-01-15 06:08:25 +00:00
|
|
|
/*
|
2004-11-22 01:38:40 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-15 06:08:25 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
#include "ompi_config.h"
|
2004-01-15 06:08:25 +00:00
|
|
|
|
2004-03-18 21:35:28 +00:00
|
|
|
#include "include/constants.h"
|
2004-01-15 06:08:25 +00:00
|
|
|
#include "mpi.h"
|
2004-09-16 09:22:28 +00:00
|
|
|
#include "event/event.h"
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "group/group.h"
|
2004-08-29 09:05:14 +00:00
|
|
|
#include "errhandler/errcode.h"
|
|
|
|
#include "errhandler/errclass.h"
|
2004-04-20 22:38:22 +00:00
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "datatype/datatype.h"
|
|
|
|
#include "op/op.h"
|
2004-08-14 01:56:05 +00:00
|
|
|
#include "file/file.h"
|
2004-08-12 16:56:24 +00:00
|
|
|
#include "info/info.h"
|
2004-11-17 02:30:07 +00:00
|
|
|
#include "util/proc_info.h"
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "runtime/runtime.h"
|
2004-10-28 15:40:46 +00:00
|
|
|
#include "runtime/ompi_progress.h"
|
2004-09-28 01:38:16 +00:00
|
|
|
#include "runtime/ompi_rte_wait.h"
|
2004-11-05 07:52:30 +00:00
|
|
|
#include "attribute/attribute.h"
|
2004-08-14 01:56:05 +00:00
|
|
|
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "mca/base/base.h"
|
2004-10-14 20:50:06 +00:00
|
|
|
#include "mca/base/mca_base_module_exchange.h"
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "mca/ptl/ptl.h"
|
|
|
|
#include "mca/ptl/base/base.h"
|
|
|
|
#include "mca/pml/pml.h"
|
|
|
|
#include "mca/pml/base/base.h"
|
|
|
|
#include "mca/coll/coll.h"
|
|
|
|
#include "mca/coll/base/base.h"
|
2004-08-14 01:56:05 +00:00
|
|
|
#include "mca/topo/topo.h"
|
|
|
|
#include "mca/topo/base/base.h"
|
|
|
|
#include "mca/io/io.h"
|
|
|
|
#include "mca/io/base/base.h"
|
2004-09-16 08:38:24 +00:00
|
|
|
#include "mca/oob/base/base.h"
|
2004-09-23 14:34:35 +00:00
|
|
|
#include "mca/ns/base/base.h"
|
2004-11-20 19:12:43 +00:00
|
|
|
#include "mca/gpr/base/base.h"
|
2004-01-29 19:40:22 +00:00
|
|
|
|
2004-01-15 06:08:25 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
int ompi_mpi_finalize(void)
|
2004-01-15 06:08:25 +00:00
|
|
|
{
|
2004-11-20 19:12:43 +00:00
|
|
|
int ret;
|
|
|
|
ompi_rte_process_status_t my_status;
|
2004-01-15 06:08:25 +00:00
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
ompi_mpi_finalized = true;
|
2004-10-28 15:40:46 +00:00
|
|
|
#if OMPI_HAVE_THREADS == 0
|
2004-11-20 19:12:43 +00:00
|
|
|
ompi_progress_events(OMPI_EVLOOP_ONCE);
|
2004-10-28 15:40:46 +00:00
|
|
|
#endif
|
2004-01-29 19:40:22 +00:00
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
/* begin recording compound command */
|
|
|
|
ompi_registry.begin_compound_cmd();
|
|
|
|
|
|
|
|
/* Set process status to "terminating"*/
|
2004-11-30 16:27:32 +00:00
|
|
|
my_status.rank = mca_ns_base_get_vpid(ompi_rte_get_self());
|
|
|
|
my_status.local_pid = (int32_t)ompi_process_info.pid;
|
|
|
|
my_status.nodename = strdup(ompi_system_info.nodename);
|
2004-11-20 19:12:43 +00:00
|
|
|
my_status.status_key = OMPI_PROC_TERMINATING;
|
|
|
|
my_status.exit_code = 0;
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_rte_set_process_status(&my_status, ompi_rte_get_self()))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* execute the compound command - no return data requested
|
|
|
|
* we'll get it through the shutdown message
|
|
|
|
*/
|
|
|
|
ompi_registry.exec_compound_cmd(OMPI_REGISTRY_NO_RETURN_REQUESTED);
|
|
|
|
|
|
|
|
/* wait for all processes to reach same state */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_rte_wait_shutdown_msg())) {
|
|
|
|
if (ompi_rte_debug_flag) {
|
|
|
|
ompi_output(0, "mpi_finalize: gave up waiting for other processes to complete");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-02 13:28:10 +00:00
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
/* Shut down any bindings-specific issues: C++, F77, F90 (may or
|
|
|
|
may not be necessary...?) */
|
|
|
|
|
|
|
|
/* Free communication objects */
|
|
|
|
|
|
|
|
/* free window resources */
|
|
|
|
|
|
|
|
/* free file resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_file_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free communicator resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_comm_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free requests */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_request_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-12-02 13:28:10 +00:00
|
|
|
/* Now that all MPI objects dealing with communications are gone,
|
|
|
|
shut down MCA types having to do with communications */
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_ptl_base_close())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_pml_base_close())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
/* Free secondary resources */
|
|
|
|
|
|
|
|
/* free attr resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_attr_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free group resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_group_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-12-02 13:28:10 +00:00
|
|
|
/* free proc resources */
|
|
|
|
if ( OMPI_SUCCESS != (ret = ompi_proc_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
/* free internal error resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_errcode_intern_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-08-29 09:05:14 +00:00
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
/* free error class resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_errclass_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free error code resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_mpi_errcode_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free errhandler resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_errhandler_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free all other resources */
|
|
|
|
|
|
|
|
/* free op resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_op_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free ddt resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_ddt_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free info resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_info_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free module exchange resources */
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_base_modex_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close down MCA modules */
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_io_base_close())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_topo_base_close())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_coll_base_close())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Leave the RTE */
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_rte_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close down the MCA */
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_base_close())) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-08-31 09:37:28 +00:00
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
/* Leave OMPI land */
|
2004-08-29 09:05:14 +00:00
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-08-29 09:05:14 +00:00
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
/* All done */
|
2004-01-15 06:08:25 +00:00
|
|
|
|
2004-11-20 19:12:43 +00:00
|
|
|
return MPI_SUCCESS;
|
2004-01-15 06:08:25 +00:00
|
|
|
}
|