Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: [OMPI devel] Thread safety levels
From: Sylvain Jeaugey (sylvain.jeaugey_at_[hidden])
Date: 2010-01-05 07:41:10


Hi list,

I'm currently playing with thread levels in Open MPI and I'm quite
surprised by the current code.

First, the C interface :
at ompi/mpi/c/init_thread.c:56 we have :
#if OPAL_ENABLE_MPI_THREADS
     *provided = MPI_THREAD_MULTIPLE;
#else
     *provided = MPI_THREAD_SINGLE;
#endif
prior to the call to ompi_mpi_init() which will in turn override the
"provided" value. Should we remove these 5 lines ?

Then at ompi/runtime/ompi_mpi_init.c:372, we have -I guess- the real code
which is :

     ompi_mpi_thread_requested = requested;
     if (OPAL_HAVE_THREAD_SUPPORT == 0) {
         ompi_mpi_thread_provided = *provided = MPI_THREAD_SINGLE;
         ompi_mpi_main_thread = NULL;
     } else if (OPAL_ENABLE_MPI_THREADS == 1) {
         ompi_mpi_thread_provided = *provided = requested;
         ompi_mpi_main_thread = opal_thread_get_self();
     } else {
         if (MPI_THREAD_MULTIPLE == requested) {
             ompi_mpi_thread_provided = *provided = MPI_THREAD_SERIALIZED;
         } else {
             ompi_mpi_thread_provided = *provided = requested;
         }
         ompi_mpi_main_thread = opal_thread_get_self();
     }

This code seems ok to me provided that :
  * (OPAL_ENABLE_MPI_THREADS == 1) means "Open MPI configured to provide
thread multiple",
  * (OPAL_HAVE_THREAD_SUPPORT == 0) means "we do not have threads at all"
though even if we do not have threads at compile time, it does in no way
prevent us from doing THREAD_FUNNELED or THREAD_SERIALIZED.

The reality seems different at opal/include/opal_config_bottom.h:70 :

/* Do we have posix or solaris thread lib */
#define OPAL_HAVE_THREADS (OPAL_HAVE_POSIX_THREADS || OPAL_HAVE_SOLARIS_THREADS)
/* Do we have thread support? */
#define OPAL_HAVE_THREAD_SUPPORT (OPAL_ENABLE_MPI_THREADS || OPAL_ENABLE_PROGRESS_THREADS)

"we do not have threads at all" seems to me to be OPAL_HAVE_THREADS and
not OPAL_HAVE_THREAD_SUPPORT. What do you think ? Maybe
OPAL_HAVE_THREAD_SUPPORT should be renamed, too (seems misleading to me).

The result is that the current default configuration of Open MPI has
OPAL_HAVE_THREAD_SUPPORT defined to 0 and Open MPI always returns
THREAD_SINGLE, even if it is perfectly capable of THREAD_FUNNELED and
THREAD_SERIALIZED.

Sylvain