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-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;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
int ret;
|
2004-02-01 00:48:41 +03:00
|
|
|
bool allow_multi_user_threads;
|
|
|
|
bool have_hidden_threads;
|
2004-01-15 09:08:25 +03:00
|
|
|
|
2004-01-29 22:40:22 +03:00
|
|
|
/* Become a LAM process */
|
|
|
|
|
2004-01-15 09:08:25 +03:00
|
|
|
if (LAM_SUCCESS != (ret = lam_init(argc, argv))) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-01-30 06:59:39 +03:00
|
|
|
/* Open up the MCA */
|
|
|
|
|
|
|
|
if (LAM_SUCCESS != (ret = mca_base_open())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-01-29 22:40:22 +03:00
|
|
|
/* Join the run-time environment */
|
|
|
|
|
2004-02-01 00:48:41 +03:00
|
|
|
if (LAM_SUCCESS != (ret = lam_rte_init(&allow_multi_user_threads,
|
|
|
|
&have_hidden_threads))) {
|
2004-01-15 09:08:25 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-01-30 06:59:39 +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
|
|
|
|
|
|
|
if (LAM_SUCCESS != (ret = mca_pml_base_open())) {
|
|
|
|
/* JMS show_help */
|
2004-01-31 02:03:12 +03:00
|
|
|
return ret;
|
2004-01-29 22:40:22 +03:00
|
|
|
}
|
|
|
|
if (LAM_SUCCESS != (ret = mca_ptl_base_open())) {
|
|
|
|
/* JMS show_help */
|
2004-01-31 02:03:12 +03:00
|
|
|
return ret;
|
2004-01-29 22:40:22 +03:00
|
|
|
}
|
2004-01-30 06:59:39 +03:00
|
|
|
if (LAM_SUCCESS != (ret = mca_coll_base_open())) {
|
|
|
|
/* JMS show_help */
|
2004-01-31 02:03:12 +03:00
|
|
|
return ret;
|
2004-01-30 06:59:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Select which pml, ptl, and coll modules to use, and determine the
|
|
|
|
final thread level */
|
|
|
|
|
|
|
|
if (LAM_SUCCESS !=
|
2004-02-01 00:48:41 +03:00
|
|
|
(ret = mca_mpi_init_select_modules(requested, allow_multi_user_threads,
|
|
|
|
have_hidden_threads, provided))) {
|
2004-01-30 06:59:39 +03:00
|
|
|
/* JMS show_help */
|
2004-01-31 02:03:12 +03:00
|
|
|
return ret;
|
2004-01-30 06:59:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add MPI_COMM_WORLD lam_proc_t's to PML */
|
|
|
|
|
|
|
|
/* All parent lam_proc_t's to PML */
|
|
|
|
|
|
|
|
/* Save the resulting thread levels */
|
|
|
|
|
|
|
|
lam_mpi_thread_requested = requested;
|
|
|
|
*provided = lam_mpi_thread_provided;
|
|
|
|
lam_mpi_thread_multiple = (lam_mpi_thread_provided == MPI_THREAD_MULTIPLE);
|
2004-01-29 22:40:22 +03:00
|
|
|
|
2004-02-10 17:31:41 +03:00
|
|
|
#if 0
|
2004-02-05 04:52:56 +03:00
|
|
|
/* Setup MPI_COMM_WORLD */
|
|
|
|
|
|
|
|
lam_comm_init(MPI_COMM_WORLD);
|
|
|
|
|
|
|
|
/* Setup MPI_COMM_SELF */
|
|
|
|
|
|
|
|
lam_comm_init(MPI_COMM_SELF);
|
2004-02-10 20:03:15 +03:00
|
|
|
#else
|
|
|
|
lam_comm_link_function();
|
2004-02-10 17:31:41 +03:00
|
|
|
#endif
|
2004-02-05 04:52:56 +03:00
|
|
|
|
2004-01-15 09:08:25 +03:00
|
|
|
/* All done */
|
|
|
|
|
2004-01-29 22:40:22 +03:00
|
|
|
lam_mpi_initialized = true;
|
2004-01-15 09:08:25 +03:00
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|