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-03-17 18:45:16 +00:00
|
|
|
#include "runtime/runtime.h"
|
2004-06-17 17:29:47 +00:00
|
|
|
#include "util/sys_info.h"
|
2004-07-01 14:49:54 +00:00
|
|
|
#include "util/proc_info.h"
|
2004-01-15 06:08:25 +00:00
|
|
|
#include "mpi.h"
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "runtime/runtime.h"
|
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "group/group.h"
|
2004-06-17 17:29:47 +00:00
|
|
|
#include "util/common_cmd_line.h"
|
2004-03-19 06:12:43 +00:00
|
|
|
#include "errhandler/errhandler.h"
|
2004-07-27 00:49:41 +00:00
|
|
|
#include "errhandler/errcode.h"
|
|
|
|
#include "errhandler/errclass.h"
|
|
|
|
#include "errhandler/errcode-internal.h"
|
2004-04-20 22:38:22 +00:00
|
|
|
#include "op/op.h"
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "mca/base/base.h"
|
|
|
|
#include "mca/base/base.h"
|
2004-06-17 16:23:34 +00: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 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-07-20 22:21:47 +00:00
|
|
|
#include "mca/topo/topo.h"
|
|
|
|
#include "mca/topo/base/base.h"
|
2004-01-15 06:08:25 +00:00
|
|
|
|
|
|
|
|
2004-02-05 01:52:56 +00:00
|
|
|
/*
|
|
|
|
* Global variables and symbols for the MPI layer
|
|
|
|
*/
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
bool ompi_mpi_initialized = false;
|
|
|
|
bool ompi_mpi_finalized = false;
|
2004-02-13 21:13:57 +00:00
|
|
|
/* As a deviation from the norm, this variable is extern'ed in
|
|
|
|
src/mpi/interface/c/bindings.h because it is already included in
|
|
|
|
all MPI function imlementation files */
|
2004-06-07 15:33:53 +00:00
|
|
|
bool ompi_mpi_param_check = true;
|
2004-02-05 01:52:56 +00:00
|
|
|
|
2004-06-07 15:33:53 +00: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 01:52:56 +00:00
|
|
|
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
|
2004-01-15 06:08:25 +00:00
|
|
|
{
|
2004-02-13 19:11:55 +00:00
|
|
|
int ret, param, value;
|
2004-02-13 13:56:55 +00:00
|
|
|
bool allow_multi_user_threads;
|
|
|
|
bool have_hidden_threads;
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_proc_t** procs;
|
2004-03-03 16:44:41 +00:00
|
|
|
size_t nprocs;
|
2004-01-15 06:08:25 +00:00
|
|
|
|
2004-06-17 17:29:47 +00:00
|
|
|
/* Save command line parameters */
|
2004-06-29 00:02:25 +00:00
|
|
|
|
2004-06-17 17:29:47 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_common_cmd_line_init(argc, argv))) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_common_cmd_line_init\n");
|
2004-06-17 17:29:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
/* Become a OMPI process */
|
2004-01-29 19:40:22 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_init(argc, argv))) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_init\n");
|
2004-02-13 13:56:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-15 06:08:25 +00:00
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
/* Open up the MCA */
|
2004-01-30 03:59:39 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_base_open())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_base_open\n");
|
2004-02-13 22:33:30 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 03:59:39 +00:00
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
/* Join the run-time environment */
|
2004-06-29 00:02:25 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_rte_init(&allow_multi_user_threads,
|
|
|
|
&have_hidden_threads))) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_rte_init\n");
|
2004-02-13 13:56:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-15 06:08:25 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
/* initialize ompi procs */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_proc_init())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_proc_init\n");
|
2004-03-03 16:44:41 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-02-13 13:56:55 +00: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 16:23:34 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_allocator_base_open())) {
|
|
|
|
/* JMS show_help */
|
2004-07-13 12:35:43 +00:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_allocator_base_init\n");
|
2004-06-17 16:23:34 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_mpool_base_open())) {
|
|
|
|
/* JMS show_help */
|
2004-07-13 12:35:43 +00:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_mpool_base_init\n");
|
2004-06-17 16:23:34 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_pml_base_open())) {
|
2004-02-13 13:56:55 +00:00
|
|
|
/* JMS show_help */
|
2004-07-13 12:35:43 +00:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_pml_base_init\n");
|
2004-02-13 13:56:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_ptl_base_open())) {
|
2004-02-13 13:56:55 +00:00
|
|
|
/* JMS show_help */
|
2004-07-13 12:35:43 +00:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_ptl_base_init\n");
|
2004-02-13 13:56:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_coll_base_open())) {
|
2004-02-13 13:56:55 +00:00
|
|
|
/* JMS show_help */
|
2004-07-13 12:35:43 +00:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_coll_base_init\n");
|
2004-02-13 13:56:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-07-20 22:21:47 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_topo_base_open())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 03:59:39 +00:00
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
/* Select which pml, ptl, and coll modules to use, and determine the
|
|
|
|
final thread level */
|
2004-01-30 03:59:39 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS !=
|
2004-08-02 00:24:22 +00:00
|
|
|
(ret = mca_base_init_select_components(requested,
|
|
|
|
allow_multi_user_threads,
|
|
|
|
have_hidden_threads,
|
|
|
|
provided))) {
|
2004-02-13 13:56:55 +00:00
|
|
|
/* JMS show_help */
|
2004-07-13 12:35:43 +00:00
|
|
|
printf("show_help: ompi_mpi_init failed in mca_base_init_select_modules\n");
|
2004-02-13 13:56:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 03:59:39 +00:00
|
|
|
|
2004-03-19 06:12:43 +00:00
|
|
|
/* initialize error handlers */
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_errhandler_init())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_errhandler_init\n");
|
2004-03-19 06:12:43 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-07-27 00:49:41 +00: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-07 23:23:03 +00:00
|
|
|
|
2004-02-13 14:19:30 +00:00
|
|
|
/* initialize groups */
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_group_init())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_group_init\n");
|
2004-02-13 14:19:30 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-05-30 16:45:32 +00:00
|
|
|
/* initialize attribute meta-data structure for comm/win/dtype */
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_attr_init())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_attr_init\n");
|
2004-05-30 16:45:32 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
/* initialize communicators */
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_comm_init())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_comm_init\n");
|
2004-02-13 13:56:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 03:59:39 +00:00
|
|
|
|
2004-03-31 16:58:01 +00:00
|
|
|
/* initialize datatypes */
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_ddt_init())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_ddt_init\n");
|
2004-03-31 16:58:01 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-04-20 22:38:22 +00:00
|
|
|
/* initialize ops */
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_op_init())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in ompi_op_init\n");
|
2004-04-20 22:38:22 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-02-13 19:11:55 +00: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-04-30 20:09:11 +00:00
|
|
|
param = mca_base_param_register_int("mpi", NULL, "error_check", NULL, 1);
|
2004-02-13 19:11:55 +00:00
|
|
|
mca_base_param_lookup_int(param, &value);
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_mpi_param_check = (bool) value;
|
2004-02-13 19:11:55 +00:00
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
/* do module exchange */
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_base_modex_exchange())) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in mca_base_modex_exchange\n");
|
2004-03-03 16:44:41 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 03:59:39 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
/* add all ompi_proc_t's to PML */
|
2004-07-13 12:35:43 +00: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 15:33:53 +00:00
|
|
|
return OMPI_ERROR;
|
2004-07-13 12:35:43 +00:00
|
|
|
}
|
2004-06-07 15:33:53 +00:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_pml.pml_add_procs(procs, nprocs))) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in pml_add_procs!\n");
|
2004-03-03 16:44:41 +00:00
|
|
|
free(procs);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
free(procs);
|
2004-01-29 19:40:22 +00:00
|
|
|
|
2004-04-12 15:39:15 +00:00
|
|
|
/* start PTL's */
|
|
|
|
param = 1;
|
2004-06-29 00:02:25 +00:00
|
|
|
if (OMPI_SUCCESS !=
|
2004-07-13 12:35:43 +00: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 15:39:15 +00:00
|
|
|
return ret;
|
2004-07-13 12:35:43 +00:00
|
|
|
}
|
2004-04-12 15:39:15 +00:00
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
/* save the resulting thread levels */
|
2004-02-05 01:52:56 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_mpi_thread_requested = requested;
|
|
|
|
*provided = ompi_mpi_thread_provided;
|
2004-06-29 00:02:25 +00:00
|
|
|
ompi_mpi_thread_multiple = (ompi_mpi_thread_provided ==
|
|
|
|
MPI_THREAD_MULTIPLE);
|
2004-02-05 01:52:56 +00:00
|
|
|
|
2004-05-07 23:23:03 +00:00
|
|
|
/* Init coll for the comms */
|
|
|
|
|
2004-07-13 12:35:43 +00: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 15:33:53 +00:00
|
|
|
return OMPI_ERROR;
|
2004-07-13 12:35:43 +00:00
|
|
|
}
|
2004-05-07 23:23:03 +00:00
|
|
|
|
2004-07-13 12:35:43 +00: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 15:33:53 +00:00
|
|
|
return OMPI_ERROR;
|
2004-07-13 12:35:43 +00:00
|
|
|
}
|
2004-05-07 23:23:03 +00:00
|
|
|
|
|
|
|
/* Wait for everyone to initialize */
|
|
|
|
/* Change the Barrier call to the backend call */
|
|
|
|
|
2004-06-29 00:02:25 +00:00
|
|
|
if (MPI_SUCCESS != (ret =
|
|
|
|
MPI_COMM_WORLD->c_coll.coll_barrier(MPI_COMM_WORLD))) {
|
2004-07-13 12:35:43 +00:00
|
|
|
/* JMS show_help */
|
|
|
|
printf("show_help: ompi_mpi_init failed in WORLD barrier!\n");
|
2004-05-07 23:23:03 +00:00
|
|
|
return ret;
|
2004-06-29 00:02:25 +00:00
|
|
|
}
|
2004-05-07 23:23:03 +00:00
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
/* All done */
|
2004-02-05 01:52:56 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_mpi_initialized = true;
|
|
|
|
ompi_mpi_finalized = false;
|
2004-02-13 13:56:55 +00:00
|
|
|
return MPI_SUCCESS;
|
2004-01-15 06:08:25 +00:00
|
|
|
}
|