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-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-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-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-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-02-14 00:13:57 +03: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 19:33:53 +04:00
|
|
|
bool ompi_mpi_param_check = true;
|
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 */
|
|
|
|
if (OMPI_SUCCESS != (ret = ompi_common_cmd_line_init(argc, argv))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the local system information and populate the ompi_system_info structure */
|
|
|
|
ompi_sys_info();
|
|
|
|
|
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-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-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-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = ompi_rte_init(&allow_multi_user_threads, &have_hidden_threads))) {
|
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-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 */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_mpool_base_open())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
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 */
|
|
|
|
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 */
|
|
|
|
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 */
|
|
|
|
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-03-17 21:45:16 +03:00
|
|
|
(ret = mca_base_init_select_modules(requested, allow_multi_user_threads,
|
2004-02-13 16:56:55 +03:00
|
|
|
have_hidden_threads, provided))) {
|
|
|
|
/* JMS show_help */
|
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-05-08 03:23:03 +04:00
|
|
|
/* Query the coll */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_coll_base_query()))
|
2004-05-08 03:23:03 +04:00
|
|
|
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-03-19 09:12:43 +03:00
|
|
|
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-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-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-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-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-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-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 */
|
|
|
|
if (NULL == (procs = ompi_proc_world(&nprocs)))
|
|
|
|
return OMPI_ERROR;
|
|
|
|
if (OMPI_SUCCESS != (ret = mca_pml.pml_add_procs(procs, nprocs))) {
|
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-07 19:33:53 +04:00
|
|
|
if (OMPI_SUCCESS != (ret = mca_pml.pml_control(MCA_PTL_ENABLE, ¶m, sizeof(param))))
|
2004-04-12 19:39:15 +04:00
|
|
|
return ret;
|
|
|
|
|
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;
|
|
|
|
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-06-07 19:33:53 +04:00
|
|
|
if (OMPI_ERROR == mca_coll_base_init_comm(MPI_COMM_SELF))
|
|
|
|
return OMPI_ERROR;
|
2004-05-08 03:23:03 +04:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_ERROR == mca_coll_base_init_comm(MPI_COMM_WORLD))
|
|
|
|
return OMPI_ERROR;
|
2004-05-08 03:23:03 +04:00
|
|
|
|
|
|
|
/* Wait for everyone to initialize */
|
|
|
|
/* Change the Barrier call to the backend call */
|
|
|
|
|
|
|
|
if (MPI_SUCCESS != (ret = MPI_Barrier(MPI_COMM_WORLD)))
|
|
|
|
return ret;
|
|
|
|
|
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
|
|
|
}
|