|
@@ -27,8 +27,8 @@
|
|
|
|
|
|
#define DRIVER_MPI_MASTER_NODE_DEFAULT 0
|
|
|
|
|
|
-static int mpi_initialized;
|
|
|
-static int extern_initialized;
|
|
|
+static int mpi_initialized = 0;
|
|
|
+static int extern_initialized = 0;
|
|
|
static int src_node_id;
|
|
|
|
|
|
static void _starpu_mpi_set_src_node_id()
|
|
@@ -61,37 +61,37 @@ static void _starpu_mpi_set_src_node_id()
|
|
|
|
|
|
int _starpu_mpi_common_mp_init()
|
|
|
{
|
|
|
- //Here we supposed the programmer has already called this function
|
|
|
+ //Here we supposed the programmer called two times starpu_init.
|
|
|
if (mpi_initialized)
|
|
|
- return 0;
|
|
|
+ return -ENODEV;
|
|
|
+
|
|
|
+ mpi_initialized = 1;
|
|
|
|
|
|
if (MPI_Initialized(&extern_initialized) != MPI_SUCCESS)
|
|
|
STARPU_ABORT_MSG("Cannot check if MPI is initialized or not !");
|
|
|
|
|
|
//Here MPI_Init or MPI_Init_thread is already called
|
|
|
- if (extern_initialized)
|
|
|
- return 1;
|
|
|
+ if (!extern_initialized)
|
|
|
+ {
|
|
|
|
|
|
#if defined(STARPU_MPI_MASTER_SLAVE_MULTIPLE_THREAD)
|
|
|
- int required = MPI_THREAD_MULTIPLE;
|
|
|
+ int required = MPI_THREAD_MULTIPLE;
|
|
|
#else
|
|
|
- int required = MPI_THREAD_FUNNELED;
|
|
|
+ int required = MPI_THREAD_FUNNELED;
|
|
|
#endif
|
|
|
|
|
|
- int thread_support;
|
|
|
- if (MPI_Init_thread(_starpu_get_argc(), _starpu_get_argv(), required, &thread_support) != MPI_SUCCESS)
|
|
|
- return 0;
|
|
|
+ int thread_support;
|
|
|
+ STARPU_ASSERT(MPI_Init_thread(_starpu_get_argc(), _starpu_get_argv(), required, &thread_support) == MPI_SUCCESS);
|
|
|
|
|
|
- if (thread_support != required)
|
|
|
- {
|
|
|
- if (required == MPI_THREAD_MULTIPLE)
|
|
|
- fprintf(stderr, "MPI doesn't support MPI_THREAD_MULTIPLE option. MPI Master-Slave can have problems if multiple slaves are launched. \n");
|
|
|
- if (required == MPI_THREAD_FUNNELED)
|
|
|
- fprintf(stderr, "MPI doesn't support MPI_THREAD_FUNNELED option. Many errors can occur. \n");
|
|
|
+ if (thread_support != required)
|
|
|
+ {
|
|
|
+ if (required == MPI_THREAD_MULTIPLE)
|
|
|
+ fprintf(stderr, "MPI doesn't support MPI_THREAD_MULTIPLE option. MPI Master-Slave can have problems if multiple slaves are launched. \n");
|
|
|
+ if (required == MPI_THREAD_FUNNELED)
|
|
|
+ fprintf(stderr, "MPI doesn't support MPI_THREAD_FUNNELED option. Many errors can occur. \n");
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- mpi_initialized = 1;
|
|
|
-
|
|
|
+
|
|
|
/* Find which node is the master */
|
|
|
_starpu_mpi_set_src_node_id();
|
|
|
|
|
@@ -102,8 +102,6 @@ void _starpu_mpi_common_mp_deinit()
|
|
|
{
|
|
|
if (!extern_initialized)
|
|
|
MPI_Finalize();
|
|
|
-
|
|
|
- mpi_initialized = 0;
|
|
|
}
|
|
|
|
|
|
int _starpu_mpi_common_is_src_node()
|