2004-01-15 09:08:25 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "lam_config.h"
|
|
|
|
|
|
|
|
#include "lam/constants.h"
|
|
|
|
#include "lam/runtime/runtime.h"
|
|
|
|
#include "mpi.h"
|
|
|
|
#include "mpi/runtime/runtime.h"
|
2004-02-10 17:31:41 +03:00
|
|
|
#include "mpi/communicator/communicator.h"
|
2004-02-13 17:19:30 +03:00
|
|
|
#include "mpi/group/group.h"
|
2004-01-30 06:59:39 +03:00
|
|
|
#include "mca/lam/base/base.h"
|
|
|
|
#include "mca/mpi/base/base.h"
|
2004-01-29 22:40:22 +03:00
|
|
|
#include "mca/mpi/ptl/ptl.h"
|
2004-01-30 06:59:39 +03:00
|
|
|
#include "mca/mpi/ptl/base/base.h"
|
2004-01-29 22:40:22 +03:00
|
|
|
#include "mca/mpi/pml/pml.h"
|
2004-01-30 06:59:39 +03:00
|
|
|
#include "mca/mpi/pml/base/base.h"
|
|
|
|
#include "mca/mpi/coll/coll.h"
|
|
|
|
#include "mca/mpi/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
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool lam_mpi_initialized = false;
|
|
|
|
bool lam_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-02-13 22:11:55 +03:00
|
|
|
bool lam_mpi_param_check = true;
|
2004-02-05 04:52:56 +03:00
|
|
|
|
|
|
|
bool lam_mpi_thread_multiple = false;
|
|
|
|
int lam_mpi_thread_requested = MPI_THREAD_SINGLE;
|
|
|
|
int lam_mpi_thread_provided = MPI_THREAD_SINGLE;
|
|
|
|
|
|
|
|
|
2004-01-15 09:08:25 +03:00
|
|
|
int lam_mpi_init(int argc, char **argv, int requested, int *provided)
|
|
|
|
{
|
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-01-15 09:08:25 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* Become a LAM process */
|
2004-01-29 22:40:22 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
if (LAM_SUCCESS != (ret = lam_init(argc, argv))) {
|
|
|
|
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-02-13 16:56:55 +03:00
|
|
|
if (LAM_SUCCESS != (ret = mca_base_open())) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-02-14 01:33:30 +03:00
|
|
|
if (LAM_SUCCESS != (ret = mca_mpi_open())) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* Join the run-time environment */
|
2004-01-29 22:40:22 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
if (LAM_SUCCESS != (ret = lam_rte_init(&allow_multi_user_threads, &have_hidden_threads))) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-01-15 09:08:25 +03:00
|
|
|
|
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-01-29 22:40:22 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
if (LAM_SUCCESS != (ret = mca_pml_base_open())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (LAM_SUCCESS != (ret = mca_ptl_base_open())) {
|
|
|
|
/* JMS show_help */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (LAM_SUCCESS != (ret = mca_coll_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-02-13 16:56:55 +03:00
|
|
|
if (LAM_SUCCESS !=
|
|
|
|
(ret = mca_mpi_init_select_modules(requested, allow_multi_user_threads,
|
|
|
|
have_hidden_threads, provided))) {
|
|
|
|
/* JMS show_help */
|
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* initialize lam procs */
|
|
|
|
if (LAM_SUCCESS != (ret = lam_proc_init())) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-02-13 17:19:30 +03:00
|
|
|
/* initialize groups */
|
|
|
|
if (LAM_SUCCESS != (ret = lam_group_init())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* initialize communicators */
|
|
|
|
if (LAM_SUCCESS != (ret = lam_comm_init())) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
|
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 */
|
|
|
|
|
|
|
|
mca_base_param_lookup_int(param, &value);
|
|
|
|
lam_mpi_param_check = (bool) value;
|
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* do module exchange */
|
2004-01-30 06:59:39 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* add all lam_proc_t's to PML */
|
2004-01-29 22:40:22 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* save the resulting thread levels */
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
lam_mpi_thread_requested = requested;
|
|
|
|
*provided = lam_mpi_thread_provided;
|
|
|
|
lam_mpi_thread_multiple = (lam_mpi_thread_provided == MPI_THREAD_MULTIPLE);
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
/* All done */
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-02-13 16:56:55 +03:00
|
|
|
lam_mpi_initialized = true;
|
|
|
|
return MPI_SUCCESS;
|
2004-01-15 09:08:25 +03:00
|
|
|
}
|