2013-09-10 19:34:09 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Mellanox Technologies, Inc.
|
|
|
|
* All rights reserved.
|
2015-08-31 03:36:02 +03:00
|
|
|
* Copyright (c) 2015 Research Organization for Information Science
|
|
|
|
* and Technology (RIST). All rights reserved.
|
2013-09-10 19:34:09 +04:00
|
|
|
* $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2013-09-10 19:34:09 +04:00
|
|
|
* Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2013-09-10 19:34:09 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "oshmem_config.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETDB_H
|
|
|
|
#include <netdb.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "opal/util/output.h"
|
|
|
|
#include "opal/runtime/opal_progress.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
#include "opal/sys/atomic.h"
|
|
|
|
#include "opal/runtime/opal.h"
|
|
|
|
|
|
|
|
#include "orte/util/show_help.h"
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/mca/grpcomm/grpcomm.h"
|
|
|
|
#include "orte/runtime/runtime.h"
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
|
|
|
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
#include "opal/mca/rcache/base/base.h"
|
|
|
|
#include "opal/mca/mpool/base/base.h"
|
|
|
|
#include "opal/mca/allocator/base/base.h"
|
2013-09-10 19:34:09 +04:00
|
|
|
#include "ompi/runtime/mpiruntime.h"
|
|
|
|
|
|
|
|
#include "oshmem/constants.h"
|
|
|
|
#include "oshmem/runtime/runtime.h"
|
2014-02-26 20:32:23 +04:00
|
|
|
#include "oshmem/runtime/params.h"
|
2013-09-10 19:34:09 +04:00
|
|
|
#include "oshmem/mca/spml/base/base.h"
|
|
|
|
#include "oshmem/mca/scoll/base/base.h"
|
|
|
|
#include "oshmem/mca/atomic/base/base.h"
|
|
|
|
#include "oshmem/mca/memheap/base/base.h"
|
2014-02-26 20:32:23 +04:00
|
|
|
#include "oshmem/mca/sshmem/base/base.h"
|
2013-09-10 19:34:09 +04:00
|
|
|
#include "oshmem/proc/proc.h"
|
|
|
|
#include "oshmem/proc/proc_group_cache.h"
|
|
|
|
#include "oshmem/op/op.h"
|
|
|
|
#include "oshmem/request/request.h"
|
|
|
|
#include "oshmem/shmem/shmem_lock.h"
|
|
|
|
#include "oshmem/runtime/oshmem_shmem_preconnect.h"
|
|
|
|
|
2013-11-26 16:46:56 +04:00
|
|
|
static int _shmem_finalize(void);
|
2013-09-10 19:34:09 +04:00
|
|
|
|
|
|
|
int oshmem_shmem_finalize(void)
|
|
|
|
{
|
|
|
|
int ret = OSHMEM_SUCCESS;
|
|
|
|
static int32_t finalize_has_already_started = 0;
|
|
|
|
|
|
|
|
if (opal_atomic_cmpset_32(&finalize_has_already_started, 0, 1)
|
|
|
|
&& oshmem_shmem_initialized && !oshmem_shmem_aborted) {
|
|
|
|
/* Should be called first because ompi_mpi_finalize makes orte and opal finalization */
|
2013-11-26 16:46:56 +04:00
|
|
|
ret = _shmem_finalize();
|
2013-09-10 19:34:09 +04:00
|
|
|
|
|
|
|
if ((OSHMEM_SUCCESS == ret) && ompi_mpi_initialized
|
|
|
|
&& !ompi_mpi_finalized) {
|
2015-10-13 02:52:35 +03:00
|
|
|
PMPI_Comm_free(&oshmem_comm_world);
|
2013-09-10 19:34:09 +04:00
|
|
|
ret = ompi_mpi_finalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OSHMEM_SUCCESS == ret) {
|
|
|
|
oshmem_shmem_initialized = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-11-26 16:46:56 +04:00
|
|
|
static int _shmem_finalize(void)
|
2013-09-10 19:34:09 +04:00
|
|
|
{
|
|
|
|
int ret = OSHMEM_SUCCESS;
|
|
|
|
|
|
|
|
shmem_barrier_all();
|
|
|
|
|
|
|
|
shmem_lock_finalize();
|
|
|
|
|
|
|
|
/* Finalize preconnect framework */
|
|
|
|
if (OSHMEM_SUCCESS != (ret = oshmem_shmem_preconnect_all_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free requests */
|
|
|
|
if (OSHMEM_SUCCESS != (ret = oshmem_request_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/* must free cached groups before we kill collectives */
|
|
|
|
if (OSHMEM_SUCCESS != (ret = oshmem_group_cache_list_free())) {
|
|
|
|
return ret;
|
|
|
|
}
|
2014-01-17 20:57:12 +04:00
|
|
|
/* We need to call mca_scoll_base_group_unselect explicitly for each group
|
|
|
|
* that are not freed by oshmem_group_cache_list_free. We can only release its collectives at this point */
|
2013-09-10 19:34:09 +04:00
|
|
|
mca_scoll_base_group_unselect(oshmem_group_all);
|
2014-01-17 20:57:12 +04:00
|
|
|
mca_scoll_base_group_unselect(oshmem_group_self);
|
2013-09-10 19:34:09 +04:00
|
|
|
|
|
|
|
/* Close down MCA modules */
|
|
|
|
|
|
|
|
if (OSHMEM_SUCCESS != (ret = mca_base_framework_close(&oshmem_atomic_base_framework) ) ) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OSHMEM_SUCCESS != (ret = mca_base_framework_close(&oshmem_scoll_base_framework) ) ) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OSHMEM_SUCCESS != (ret = mca_base_framework_close(&oshmem_memheap_base_framework) ) ) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:32:23 +04:00
|
|
|
if (OSHMEM_SUCCESS != (ret = mca_base_framework_close(&oshmem_sshmem_base_framework) ) ) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-10 19:34:09 +04:00
|
|
|
if (OSHMEM_SUCCESS
|
|
|
|
!= (ret =
|
|
|
|
MCA_SPML_CALL(del_procs(oshmem_group_all->proc_array, oshmem_group_all->proc_count)))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-02-06 12:40:43 +04:00
|
|
|
oshmem_shmem_barrier();
|
|
|
|
|
2013-09-10 19:34:09 +04:00
|
|
|
/* free spml resource */
|
|
|
|
if (OSHMEM_SUCCESS != (ret = mca_spml_base_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OSHMEM_SUCCESS != (ret = mca_base_framework_close(&oshmem_spml_base_framework) ) ) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free op resources */
|
|
|
|
if (OSHMEM_SUCCESS != (ret = oshmem_op_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-09-17 18:20:37 +03:00
|
|
|
/* free proc_group resources */
|
|
|
|
if (OSHMEM_SUCCESS != (ret = oshmem_proc_group_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-10 19:34:09 +04:00
|
|
|
/* free proc resources */
|
|
|
|
if (OSHMEM_SUCCESS != (ret = oshmem_proc_finalize())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|