Parcourir la source

mpi: call MPI_Init_Thread and not MPI_Init, that is needed as we want to use threads

Nathalie Furmento il y a 12 ans
Parent
commit
2d294f5df5
3 fichiers modifiés avec 10 ajouts et 7 suppressions
  1. 1 1
      ChangeLog
  2. 1 1
      doc/chapters/mpi-support.texi
  3. 8 5
      mpi/src/starpu_mpi.c

+ 1 - 1
ChangeLog

@@ -46,7 +46,7 @@ New features:
         - Initialisation functions starpu_mpi_initialize_extended()
   	  and starpu_mpi_initialize() have been made deprecated. One
 	  should now use starpu_mpi_init() which will initialise MPI
-	  if is not already done.
+	  by calling MPI_Init_Thread if is not already done.
 
 Changes:
   * Fix the block filter functions.

+ 1 - 1
doc/chapters/mpi-support.texi

@@ -46,7 +46,7 @@ Also pass the @code{--static} option if the application is to be linked statical
 
 @deftypefun int starpu_mpi_init (int *@var{argc}, char ***@var{argv})
 Initializes the starpumpi library. If MPI is not already initialized,
-it will be by calling @code{MPI_Init(argc, argv)}.
+it will be by calling @code{MPI_Init_Thread(argc, argv, MPI_THREAD_SERIALIZED, ...)}.
 @end deftypefun
 
 @deftypefun int starpu_mpi_initialize (void)

+ 8 - 5
mpi/src/starpu_mpi.c

@@ -671,12 +671,15 @@ static void *progress_thread_func(void *arg)
 	_STARPU_DEBUG("MPI_Initialized %d\n", flag);
 	if (flag == 0)
 	{
-                _STARPU_DEBUG("Calling MPI_Init\n");
-		fprintf(stderr, "calling MPI_Init\n");
-                if (MPI_Init(argc_argv->argc, argc_argv->argv) != MPI_SUCCESS) {
-                        fprintf(stderr,"MPI_Init failed\n");
-                        exit(1);
+		int thread_support;
+                _STARPU_DEBUG("Calling MPI_Init_thread\n");
+		if (MPI_Init_thread(argc_argv->argc, argc_argv->argv, MPI_THREAD_SERIALIZED, &thread_support) != MPI_SUCCESS) {
+			_STARPU_ERROR("MPI_Init_thread failed\n");
                 }
+		if (thread_support == MPI_THREAD_FUNNELED)
+			_STARPU_DISP("MPI only has funneled thread support, not serialized, hoping this will work\n");
+                if (thread_support < MPI_THREAD_FUNNELED)
+			_STARPU_DISP("MPI does not have thread support!\n");
         }
 
 	/* notify the main thread that the progression thread is ready */