2004-01-15 09:08:25 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-15 09:08:25 +03:00
|
|
|
|
2004-03-19 00:35:28 +03:00
|
|
|
#include "include/constants.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "runtime/runtime.h"
|
2004-06-17 21:29:47 +04:00
|
|
|
#include "util/sys_info.h"
|
2004-07-01 18:49:54 +04:00
|
|
|
#include "util/proc_info.h"
|
2004-01-15 09:08:25 +03:00
|
|
|
#include "mpi.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "runtime/runtime.h"
|
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "group/group.h"
|
2004-08-12 20:56:24 +04:00
|
|
|
#include "info/info.h"
|
2004-06-17 21:29:47 +04:00
|
|
|
#include "util/common_cmd_line.h"
|
2004-03-19 09:12:43 +03:00
|
|
|
#include "errhandler/errhandler.h"
|
2004-07-27 04:49:41 +04:00
|
|
|
#include "errhandler/errcode.h"
|
|
|
|
#include "errhandler/errclass.h"
|
|
|
|
#include "errhandler/errcode-internal.h"
|
2004-04-21 02:38:22 +04:00
|
|
|
#include "op/op.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mca/base/base.h"
|
|
|
|
#include "mca/base/base.h"
|
2004-06-17 20:23:34 +04:00
|
|
|
#include "mca/allocator/base/base.h"
|
|
|
|
#include "mca/allocator/allocator.h"
|
|
|
|
#include "mca/mpool/base/base.h"
|
|
|
|
#include "mca/mpool/mpool.h"
|
2004-03-17 21:45:16 +03: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-07-21 02:21:47 +04:00
|
|
|
#include "mca/topo/topo.h"
|
|
|
|
#include "mca/topo/base/base.h"
|
2004-01-15 09:08:25 +03:00
|
|
|
|
|
|
|
|
2004-02-05 04:52:56 +03:00
|
|
|
/*
|
|
|
|
* Global variables and symbols for the MPI layer
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
bool ompi_mpi_initialized = false;
|
|
|
|
bool ompi_mpi_finalized = false;
|
2004-08-12 20:56:24 +04:00
|
|
|
|
|
|
|
/* As a deviation from the norm, ompi_mpi_param_check is extern'ed in
|
2004-02-14 00:13:57 +03:00
|
|
|
src/mpi/interface/c/bindings.h because it is already included in
|
|
|
|
all MPI function imlementation files */
|
2004-06-07 19:33:53 +04:00
|
|
|
bool ompi_mpi_param_check = true;
|
2004-08-12 20:56:24 +04:00
|
|
|
bool ompi_debug_show_handle_leaks = false;
|
|
|
|
bool ompi_debug_handle_never_free = false;
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
bool ompi_mpi_thread_multiple = false;
|
|
|
|
int ompi_mpi_thread_requested = MPI_THREAD_SINGLE;
|
|
|
|
int ompi_mpi_thread_provided = MPI_THREAD_SINGLE;
|
2004-02-05 04:52:56 +03:00
|
|
|
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
|
2004-01-15 09:08:25 +03:00
|
|
|
{
|
2004-02-13 22:11:55 +03:00
|
|
|
int ret, param, value;
|
2004-02-13 16:56:55 +03:00
|
|
|
bool allow_multi_user_threads;
|
|
|
|
bool have_hidden_threads;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_proc_t** procs;
|
2004-03-03 19:44:41 +03:00
|
|
|
size_t nprocs;
|
2004-01-15 09:08:25 +03:00
|
|
|
|
2004-06-17 21:29:47 +04:00
|
|
|
/* Save command line parameters */
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-06-17 21:29:47 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_common_cmd_line_init(argc, argv))) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_common_cmd_line_init\n");
|
2004-06-17 21:29:47 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
/* Become a OMPI process */
|
2004-01-29 22:40:22 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_init(argc, argv))) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_init\n");
|
2004-02-13 16:56:55 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-15 09:08:25 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* Open up the MCA */
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_base_open())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_base_open\n");
|
2004-02-14 01:33:30 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* Join the run-time environment */
|
2004-06-29 04:02:25 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_rte_init(&allow_multi_user_threads,
|
|
|
|
&have_hidden_threads))) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_rte_init\n");
|
2004-02-13 16:56:55 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-15 09:08:25 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
/* initialize ompi procs */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_proc_init())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_proc_init\n");
|
2004-03-03 19:44:41 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* Open up relevant MCA modules. Do not open io, topo, or one
|
|
|
|
module types here -- they are loaded upon demand (i.e., upon
|
|
|
|
relevant constructors). */
|
2004-06-17 20:23:34 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_allocator_base_open())) {
|
|
|
|
/* JMS show_help */
|
2004-07-13 16:35:43 +04:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_allocator_base_init\n");
|
2004-06-17 20:23:34 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_mpool_base_open())) {
|
|
|
|
/* JMS show_help */
|
2004-07-13 16:35:43 +04:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_mpool_base_init\n");
|
2004-06-17 20:23:34 +04:00
|
|
|
return ret;
|
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_pml_base_open())) {
|
2004-02-13 16:56:55 +03:00
|
|
|
/* JMS show_help */
|
2004-07-13 16:35:43 +04:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_pml_base_init\n");
|
2004-02-13 16:56:55 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_ptl_base_open())) {
|
2004-02-13 16:56:55 +03:00
|
|
|
/* JMS show_help */
|
2004-07-13 16:35:43 +04:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_ptl_base_init\n");
|
2004-02-13 16:56:55 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_coll_base_open())) {
|
2004-02-13 16:56:55 +03:00
|
|
|
/* JMS show_help */
|
2004-07-13 16:35:43 +04:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_coll_base_init\n");
|
2004-02-13 16:56:55 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-07-21 02:21:47 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_topo_base_open())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* Select which pml, ptl, and coll modules to use, and determine the
|
|
|
|
final thread level */
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS !=
|
2004-08-02 04:24:22 +04:00
|
|
|
(ret = mca_base_init_select_components(requested,
|
|
|
|
allow_multi_user_threads,
|
|
|
|
have_hidden_threads,
|
|
|
|
provided))) {
|
2004-02-13 16:56:55 +03:00
|
|
|
/* JMS show_help */
|
2004-07-13 16:35:43 +04:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_base_init_select_modules\n");
|
2004-02-13 16:56:55 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-08-12 20:56:24 +04:00
|
|
|
/* initialize info */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_info_init())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_info_init\n");
|
|
|
|
return ret;
|
|
|
|
}
|
2004-03-19 09:12:43 +03:00
|
|
|
/* initialize error handlers */
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_errhandler_init())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_errhandler_init\n");
|
2004-03-19 09:12:43 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-07-27 04:49:41 +04:00
|
|
|
|
|
|
|
/* initialize error codes */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_mpi_errcode_init())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_errcode_init\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize error classes */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_errclass_init())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_errclass_init\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize internal error codes */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_errcode_intern_init())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_errcode_internal_init\n");
|
|
|
|
return ret;
|
|
|
|
}
|
2004-05-08 03:23:03 +04:00
|
|
|
|
2004-02-13 17:19:30 +03:00
|
|
|
/* initialize groups */
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_group_init())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_group_init\n");
|
2004-02-13 17:19:30 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-30 20:45:32 +04:00
|
|
|
/* initialize attribute meta-data structure for comm/win/dtype */
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_attr_init())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_attr_init\n");
|
2004-05-30 20:45:32 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* initialize communicators */
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_comm_init())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_comm_init\n");
|
2004-02-13 16:56:55 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-03-31 20:58:01 +04:00
|
|
|
/* initialize datatypes */
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_ddt_init())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_ddt_init\n");
|
2004-03-31 20:58:01 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-04-21 02:38:22 +04:00
|
|
|
/* initialize ops */
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_op_init())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_op_init\n");
|
2004-04-21 02:38:22 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-02-13 22:11:55 +03:00
|
|
|
/* If we have run-time MPI parameter checking possible, register
|
|
|
|
an MCA paramter to find out if the user wants it on or off by
|
|
|
|
default */
|
2004-05-01 00:09:11 +04:00
|
|
|
param = mca_base_param_register_int("mpi", NULL, "error_check", NULL, 1);
|
2004-02-13 22:11:55 +03:00
|
|
|
mca_base_param_lookup_int(param, &value);
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_mpi_param_check = (bool) value;
|
2004-02-13 22:11:55 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* do module exchange */
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_base_modex_exchange())) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_base_modex_exchange\n");
|
2004-03-03 19:44:41 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
/* add all ompi_proc_t's to PML */
|
2004-07-13 16:35:43 +04:00
|
|
|
if (NULL == (procs = ompi_proc_world(&nprocs))) {
|
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in NULL proc world!\n");
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-07-13 16:35:43 +04:00
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_pml.pml_add_procs(procs, nprocs))) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in pml_add_procs!\n");
|
2004-03-03 19:44:41 +03:00
|
|
|
free(procs);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
free(procs);
|
2004-01-29 22:40:22 +03:00
|
|
|
|
2004-04-12 19:39:15 +04:00
|
|
|
/* start PTL's */
|
|
|
|
param = 1;
|
2004-06-29 04:02:25 +04:00
|
|
|
if (OMPI_SUCCESS !=
|
2004-07-13 16:35:43 +04:00
|
|
|
(ret = mca_pml.pml_control(MCA_PTL_ENABLE, ¶m, sizeof(param)))) {
|
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in pml_control!\n");
|
2004-04-12 19:39:15 +04:00
|
|
|
return ret;
|
2004-07-13 16:35:43 +04:00
|
|
|
}
|
2004-04-12 19:39:15 +04:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* save the resulting thread levels */
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_mpi_thread_requested = requested;
|
|
|
|
*provided = ompi_mpi_thread_provided;
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_mpi_thread_multiple = (ompi_mpi_thread_provided ==
|
|
|
|
MPI_THREAD_MULTIPLE);
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-05-08 03:23:03 +04:00
|
|
|
/* Init coll for the comms */
|
|
|
|
|
2004-07-13 16:35:43 +04:00
|
|
|
if (OMPI_ERROR == mca_coll_base_comm_select(MPI_COMM_SELF, NULL)) {
|
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_coll_base_comm_select SELF!\n");
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-07-13 16:35:43 +04:00
|
|
|
}
|
2004-05-08 03:23:03 +04:00
|
|
|
|
2004-07-13 16:35:43 +04:00
|
|
|
if (OMPI_ERROR == mca_coll_base_comm_select(MPI_COMM_WORLD, NULL)) {
|
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_coll_base_comm_select WORLD!\n");
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-07-13 16:35:43 +04:00
|
|
|
}
|
2004-05-08 03:23:03 +04:00
|
|
|
|
|
|
|
/* Wait for everyone to initialize */
|
|
|
|
/* Change the Barrier call to the backend call */
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
if (MPI_SUCCESS != (ret =
|
|
|
|
MPI_COMM_WORLD->c_coll.coll_barrier(MPI_COMM_WORLD))) {
|
2004-07-13 16:35:43 +04:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in WORLD barrier!\n");
|
2004-05-08 03:23:03 +04:00
|
|
|
return ret;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
2004-05-08 03:23:03 +04:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* All done */
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_mpi_initialized = true;
|
|
|
|
ompi_mpi_finalized = false;
|
2004-02-13 16:56:55 +03:00
|
|
|
return MPI_SUCCESS;
|
2004-01-15 09:08:25 +03:00
|
|
|
}
|