1
1

Merge pull request #1397 from hjelmn/enable_thread_multiple

ompi: always enable MPI_THREAD_MULTIPLE support
Этот коммит содержится в:
Nathan Hjelm 2016-04-23 08:40:22 -06:00
родитель 628e638a50 230d04327e
Коммит ae0ffbb67f
18 изменённых файлов: 67 добавлений и 203 удалений

Просмотреть файл

@ -1,58 +0,0 @@
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
AC_DEFUN([OMPI_CONFIG_THREADS],[
#
# Arguments: none
#
# Dependencies: None
#
# Modifies:
# none - see called tests
#
# configure threads
#
#
# MPI_THREAD_MULTIPLE
#
# --enable-mpi-thread-multiple
# #if OMPI_ENABLE_THREAD_MULTIPLE == 0 /* Not available */
# #if OMPI_ENABLE_THREAD_MULTIPLE == 1 /* Available */
#
AC_MSG_CHECKING([if want MPI_THREAD_MULTIPLE support])
AC_ARG_ENABLE([mpi_thread_multiple],
[AC_HELP_STRING([--enable-mpi-thread-multiple],
[Enable MPI_THREAD_MULTIPLE support (default: disabled)])])
if test "$enable_mpi_thread_multiple" = "yes" ; then
ompi_want_mpi_threads=1
OMPI_ENABLE_THREAD_MULTIPLE=1
AC_MSG_RESULT([Enabled])
else
# Default: disable
ompi_want_mpi_threads=0
OMPI_ENABLE_THREAD_MULTIPLE=0
AC_MSG_RESULT([Disabled])
fi
AC_DEFINE_UNQUOTED([OMPI_ENABLE_THREAD_MULTIPLE], [$ompi_want_mpi_threads],
[Enable MPI_THREAD_MULTIPLE])
])dnl

Просмотреть файл

@ -896,7 +896,6 @@ OPAL_CHECK_BROKEN_QSORT
# Check out what thread support we have # Check out what thread support we have
# #
OPAL_CONFIG_THREADS OPAL_CONFIG_THREADS
OMPI_CONFIG_THREADS
CFLAGS="$CFLAGS $THREAD_CFLAGS" CFLAGS="$CFLAGS $THREAD_CFLAGS"
CPPFLAGS="$CPPFLAGS $THREAD_CPPFLAGS" CPPFLAGS="$CPPFLAGS $THREAD_CPPFLAGS"

Просмотреть файл

@ -514,7 +514,6 @@ static int ompi_comm_register_cid (uint32_t cid)
if ( regcom->cid > cid ) { if ( regcom->cid > cid ) {
break; break;
} }
#if OMPI_ENABLE_THREAD_MULTIPLE
if( regcom->cid == cid ) { if( regcom->cid == cid ) {
/** /**
* The MPI standard state that is the user responsability to * The MPI standard state that is the user responsability to
@ -527,7 +526,6 @@ static int ompi_comm_register_cid (uint32_t cid)
ok = false; ok = false;
break; break;
} }
#endif /* OMPI_ENABLE_THREAD_MULTIPLE */
} }
if (ok) { if (ok) {
opal_list_insert_pos (&ompi_registered_comms, (opal_list_item_t *) regcom, opal_list_insert_pos (&ompi_registered_comms, (opal_list_item_t *) regcom,

Просмотреть файл

@ -170,8 +170,7 @@ int mca_bml_r2_ft_event(int state)
* This will cause the BTL components to discover the available * This will cause the BTL components to discover the available
* network options on this machine, and post proper modex informaiton. * network options on this machine, and post proper modex informaiton.
*/ */
if( OMPI_SUCCESS != (ret = mca_btl_base_select(OPAL_ENABLE_PROGRESS_THREADS, if( OMPI_SUCCESS != (ret = mca_btl_base_select(OPAL_ENABLE_PROGRESS_THREADS, 1) ) ) {
OMPI_ENABLE_THREAD_MULTIPLE) ) ) {
opal_output(0, "bml:r2: ft_event(Restart): Failed to select in BTL framework\n"); opal_output(0, "bml:r2: ft_event(Restart): Failed to select in BTL framework\n");
return ret; return ret;
} }
@ -257,8 +256,7 @@ int mca_bml_r2_ft_event(int state)
* This will cause the BTL components to discover the available * This will cause the BTL components to discover the available
* network options on this machine, and post proper modex informaiton. * network options on this machine, and post proper modex informaiton.
*/ */
if( OMPI_SUCCESS != (ret = mca_btl_base_select(OPAL_ENABLE_PROGRESS_THREADS, if( OMPI_SUCCESS != (ret = mca_btl_base_select(OPAL_ENABLE_PROGRESS_THREADS, 1) ) ) {
OMPI_ENABLE_THREAD_MULTIPLE) ) ) {
opal_output(0, "bml:r2: ft_event(Restart): Failed to select in BTL framework\n"); opal_output(0, "bml:r2: ft_event(Restart): Failed to select in BTL framework\n");
return ret; return ret;
} }

Просмотреть файл

@ -215,23 +215,19 @@ int mca_io_base_file_select(ompi_file_t *file,
} }
if (OMPI_SUCCESS != if (OMPI_SUCCESS !=
(ret = mca_fs_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, (ret = mca_fs_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, 1))) {
OMPI_ENABLE_THREAD_MULTIPLE))) {
return err; return err;
} }
if (OMPI_SUCCESS != if (OMPI_SUCCESS !=
(ret = mca_fcoll_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, (ret = mca_fcoll_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, 1))) {
OMPI_ENABLE_THREAD_MULTIPLE))) {
return err; return err;
} }
if (OMPI_SUCCESS != if (OMPI_SUCCESS !=
(ret = mca_fbtl_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, (ret = mca_fbtl_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, 1))) {
OMPI_ENABLE_THREAD_MULTIPLE))) {
return err; return err;
} }
if (OMPI_SUCCESS != if (OMPI_SUCCESS !=
(ret = mca_sharedfp_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, (ret = mca_sharedfp_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, 1))) {
OMPI_ENABLE_THREAD_MULTIPLE))) {
return err; return err;
} }
} }

Просмотреть файл

@ -38,7 +38,7 @@ static int mca_io_base_open(mca_base_open_flag_t flags)
return ret; return ret;
} }
return mca_io_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, OMPI_ENABLE_THREAD_MULTIPLE); return mca_io_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, 1);
} }
MCA_BASE_FRAMEWORK_DECLARE(ompi, io, "I/O", NULL, mca_io_base_open, NULL, MCA_BASE_FRAMEWORK_DECLARE(ompi, io, "I/O", NULL, mca_io_base_open, NULL,

Просмотреть файл

@ -43,7 +43,6 @@ ompi_mtl_portals4_recv_block_progress(ptl_event_t *ev,
switch (ev->type) { switch (ev->type) {
case PTL_EVENT_AUTO_FREE: case PTL_EVENT_AUTO_FREE:
#if OMPI_ENABLE_THREAD_MULTIPLE
OPAL_THREAD_LOCK(&ompi_mtl_portals4.short_block_mutex); OPAL_THREAD_LOCK(&ompi_mtl_portals4.short_block_mutex);
switch (block->status) { switch (block->status) {
case BLOCK_STATUS_ACTIVATED: /* May be encountered with multi threading */ case BLOCK_STATUS_ACTIVATED: /* May be encountered with multi threading */
@ -73,19 +72,10 @@ ompi_mtl_portals4_recv_block_progress(ptl_event_t *ev,
__FILE__, __LINE__, block->status); __FILE__, __LINE__, block->status);
break; break;
} }
#else
if (OPAL_UNLIKELY(block->release_on_free)) {
opal_list_remove_item(&ompi_mtl_portals4.recv_short_blocks,
&block->base);
ompi_mtl_portals4_recv_short_block_free(block);
} else {
ompi_mtl_portals4_activate_block(block);
}
#endif
break; break;
case PTL_EVENT_AUTO_UNLINK: case PTL_EVENT_AUTO_UNLINK:
#if OMPI_ENABLE_THREAD_MULTIPLE
OPAL_THREAD_LOCK(&ompi_mtl_portals4.short_block_mutex); OPAL_THREAD_LOCK(&ompi_mtl_portals4.short_block_mutex);
switch (block->status) { switch (block->status) {
case BLOCK_STATUS_ACTIVATED: /* Normal case */ case BLOCK_STATUS_ACTIVATED: /* Normal case */
@ -115,14 +105,10 @@ ompi_mtl_portals4_recv_block_progress(ptl_event_t *ev,
__FILE__, __LINE__, block->status); __FILE__, __LINE__, block->status);
break; break;
} }
#else
block->status = BLOCK_STATUS_WAITING_FREE;
ompi_mtl_portals4.active_recv_short_blocks--;
#endif
break; break;
case PTL_EVENT_LINK: case PTL_EVENT_LINK:
#if OMPI_ENABLE_THREAD_MULTIPLE
OPAL_THREAD_LOCK(&ompi_mtl_portals4.short_block_mutex); OPAL_THREAD_LOCK(&ompi_mtl_portals4.short_block_mutex);
switch (block->status) { switch (block->status) {
case BLOCK_STATUS_WAITING_LINK: case BLOCK_STATUS_WAITING_LINK:
@ -138,10 +124,7 @@ ompi_mtl_portals4_recv_block_progress(ptl_event_t *ev,
__FILE__, __LINE__, block->status); __FILE__, __LINE__, block->status);
break; break;
} }
#else
block->status = BLOCK_STATUS_ACTIVATED;
ompi_mtl_portals4.active_recv_short_blocks++;
#endif
break; break;
default: default:

Просмотреть файл

@ -10,7 +10,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
* Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Sandia National Laboratories. All rights reserved. * Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
@ -101,16 +101,16 @@ int mca_pml_ob1_recv(void *addr,
mca_pml_ob1_recv_request_t *recvreq = NULL; mca_pml_ob1_recv_request_t *recvreq = NULL;
int rc; int rc;
#if !OMPI_ENABLE_THREAD_MULTIPLE if (OPAL_LIKELY(!ompi_mpi_thread_multiple)) {
recvreq = mca_pml_ob1_recvreq; recvreq = mca_pml_ob1_recvreq;
mca_pml_ob1_recvreq = NULL; mca_pml_ob1_recvreq = NULL;
if( OPAL_UNLIKELY(NULL == recvreq) ) }
#endif /* !OMPI_ENABLE_THREAD_MULTIPLE */
{ if( OPAL_UNLIKELY(NULL == recvreq) ) {
MCA_PML_OB1_RECV_REQUEST_ALLOC(recvreq); MCA_PML_OB1_RECV_REQUEST_ALLOC(recvreq);
if (NULL == recvreq) if (NULL == recvreq)
return OMPI_ERR_TEMP_OUT_OF_RESOURCE; return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
} }
MCA_PML_OB1_RECV_REQUEST_INIT(recvreq, addr, count, datatype, MCA_PML_OB1_RECV_REQUEST_INIT(recvreq, addr, count, datatype,
src, tag, comm, false); src, tag, comm, false);
@ -128,16 +128,12 @@ int mca_pml_ob1_recv(void *addr,
rc = recvreq->req_recv.req_base.req_ompi.req_status.MPI_ERROR; rc = recvreq->req_recv.req_base.req_ompi.req_status.MPI_ERROR;
#if OMPI_ENABLE_THREAD_MULTIPLE if (OPAL_UNLIKELY(ompi_mpi_thread_multiple || NULL != mca_pml_ob1_recvreq)) {
MCA_PML_OB1_RECV_REQUEST_RETURN(recvreq);
#else
if( NULL != mca_pml_ob1_recvreq ) {
MCA_PML_OB1_RECV_REQUEST_RETURN(recvreq); MCA_PML_OB1_RECV_REQUEST_RETURN(recvreq);
} else { } else {
mca_pml_ob1_recv_request_fini (recvreq); mca_pml_ob1_recv_request_fini (recvreq);
mca_pml_ob1_recvreq = recvreq; mca_pml_ob1_recvreq = recvreq;
} }
#endif
return rc; return rc;
} }

Просмотреть файл

@ -10,7 +10,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science * Copyright (c) 2015 Research Organization for Information Science
@ -230,16 +230,17 @@ int mca_pml_ob1_send(const void *buf,
} }
} }
#if !OMPI_ENABLE_THREAD_MULTIPLE if (OPAL_LIKELY(!ompi_mpi_thread_multiple)) {
sendreq = mca_pml_ob1_sendreq; sendreq = mca_pml_ob1_sendreq;
mca_pml_ob1_sendreq = NULL; mca_pml_ob1_sendreq = NULL;
if( OPAL_UNLIKELY(NULL == sendreq) ) }
#endif /* !OMPI_ENABLE_THREAD_MULTIPLE */
{ if( OPAL_UNLIKELY(NULL == sendreq) ) {
MCA_PML_OB1_SEND_REQUEST_ALLOC(comm, dst, sendreq); MCA_PML_OB1_SEND_REQUEST_ALLOC(comm, dst, sendreq);
if (NULL == sendreq) if (NULL == sendreq)
return OMPI_ERR_TEMP_OUT_OF_RESOURCE; return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
} }
sendreq->req_send.req_base.req_proc = dst_proc; sendreq->req_send.req_base.req_proc = dst_proc;
sendreq->rdma_frag = NULL; sendreq->rdma_frag = NULL;
@ -261,16 +262,12 @@ int mca_pml_ob1_send(const void *buf,
rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR; rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR;
} }
#if OMPI_ENABLE_THREAD_MULTIPLE if (OPAL_UNLIKELY(ompi_mpi_thread_multiple || NULL != mca_pml_ob1_sendreq)) {
MCA_PML_OB1_SEND_REQUEST_RETURN(sendreq);
#else
if( NULL != mca_pml_ob1_sendreq ) {
MCA_PML_OB1_SEND_REQUEST_RETURN(sendreq); MCA_PML_OB1_SEND_REQUEST_RETURN(sendreq);
} else { } else {
mca_pml_ob1_send_request_fini (sendreq); mca_pml_ob1_send_request_fini (sendreq);
mca_pml_ob1_sendreq = sendreq; mca_pml_ob1_sendreq = sendreq;
} }
#endif
return rc; return rc;
} }

Просмотреть файл

@ -56,7 +56,7 @@ mca_pml_base_component_2_0_0_t mca_pml_v_component =
}; };
static bool pml_v_enable_progress_treads = OPAL_ENABLE_PROGRESS_THREADS; static bool pml_v_enable_progress_treads = OPAL_ENABLE_PROGRESS_THREADS;
static bool pml_v_enable_mpi_thread_multiple = OMPI_ENABLE_THREAD_MULTIPLE; static bool pml_v_enable_mpi_thread_multiple = 1;
static char *ompi_pml_vprotocol_include_list; static char *ompi_pml_vprotocol_include_list;
static char *ompi_pml_v_output; static char *ompi_pml_v_output;

Просмотреть файл

@ -49,8 +49,7 @@ int mca_topo_base_lazy_init(void)
} }
if (OMPI_SUCCESS != if (OMPI_SUCCESS !=
(err = mca_topo_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, (err = mca_topo_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, 1))) {
OMPI_ENABLE_THREAD_MULTIPLE))) {
return err; return err;
} }
} }

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/* /*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
@ -13,6 +14,8 @@
* Copyright (c) 2015 Research Organization for Information Science * Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -50,16 +53,7 @@ int MPI_Init_thread(int *argc, char ***argv, int required,
} }
} }
/* *provided = required;
* A thread compliant MPI implementation will be able to return provided
* = MPI_THREAD_MULTIPLE. Such an implementation may always return provided
* = MPI_THREAD_MULTIPLE, irrespective of the value of required.
*/
#if OMPI_ENABLE_THREAD_MULTIPLE
*provided = MPI_THREAD_MULTIPLE;
#else
*provided = MPI_THREAD_SINGLE;
#endif
/* Call the back-end initialization function (we need to put as /* Call the back-end initialization function (we need to put as
little in this function as possible so that if it's profiled, we little in this function as possible so that if it's profiled, we

Просмотреть файл

@ -324,15 +324,7 @@ void ompi_mpi_thread_level(int requested, int *provided)
*/ */
ompi_mpi_thread_requested = requested; ompi_mpi_thread_requested = requested;
if (OMPI_ENABLE_THREAD_MULTIPLE == 1) { ompi_mpi_thread_provided = *provided = requested;
ompi_mpi_thread_provided = *provided = requested;
} else {
if (MPI_THREAD_MULTIPLE == requested) {
ompi_mpi_thread_provided = *provided = MPI_THREAD_SERIALIZED;
} else {
ompi_mpi_thread_provided = *provided = requested;
}
}
if (!ompi_mpi_main_thread) { if (!ompi_mpi_main_thread) {
ompi_mpi_main_thread = opal_thread_get_self(); ompi_mpi_main_thread = opal_thread_get_self();
@ -529,7 +521,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
memset ( &threadlevel_bf, 0, sizeof(uint8_t)); memset ( &threadlevel_bf, 0, sizeof(uint8_t));
OMPI_THREADLEVEL_SET_BITFLAG ( ompi_mpi_thread_provided, threadlevel_bf ); OMPI_THREADLEVEL_SET_BITFLAG ( ompi_mpi_thread_provided, threadlevel_bf );
#if OMPI_ENABLE_THREAD_MULTIPLE
/* add this bitflag to the modex */ /* add this bitflag to the modex */
OPAL_MODEX_SEND_STRING(ret, OPAL_PMIX_GLOBAL, OPAL_MODEX_SEND_STRING(ret, OPAL_PMIX_GLOBAL,
"MPI_THREAD_LEVEL", &threadlevel_bf, sizeof(uint8_t)); "MPI_THREAD_LEVEL", &threadlevel_bf, sizeof(uint8_t));
@ -537,7 +528,6 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
error = "ompi_mpi_init: modex send thread level"; error = "ompi_mpi_init: modex send thread level";
goto error; goto error;
} }
#endif
/* If thread support was enabled, then setup OPAL to allow for /* If thread support was enabled, then setup OPAL to allow for
them. */ them. */

Просмотреть файл

@ -298,17 +298,11 @@ void ompi_info_do_config(bool want_all)
} }
#if OMPI_RTE_ORTE #if OMPI_RTE_ORTE
(void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: %s, OPAL support: %s, OMPI progress: %s, ORTE progress: yes, Event lib: yes)", (void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, ORTE progress: yes, Event lib: yes)",
"posix", "posix", OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no");
OMPI_ENABLE_THREAD_MULTIPLE ? "yes" : "no",
OPAL_ENABLE_MULTI_THREADS ? "yes" : "no",
OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no");
#else #else
(void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: %s, OPAL support: %s, OMPI progress: %s, Event lib: yes)", (void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, Event lib: yes)",
"posix", "posix", OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no");
OMPI_ENABLE_THREAD_MULTIPLE ? "yes" : "no",
OPAL_ENABLE_MULTI_THREADS ? "yes" : "no",
OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no");
#endif #endif
(void)asprintf(&ft_support, "%s (checkpoint thread: %s)", (void)asprintf(&ft_support, "%s (checkpoint thread: %s)",

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/* /*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
@ -9,7 +10,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
* Copyright (c) 2015 Research Organization for Information Science * Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
@ -28,9 +29,7 @@
* Wait and see if some upper layer wants to use threads, if support * Wait and see if some upper layer wants to use threads, if support
* exists. * exists.
*/ */
#if OMPI_ENABLE_THREAD_MULTIPLE
bool opal_uses_threads = false; bool opal_uses_threads = false;
#endif
static void opal_mutex_construct(opal_mutex_t *m) static void opal_mutex_construct(opal_mutex_t *m)
{ {

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
* Copyright (c) 2007 Voltaire. All rights reserved. * Copyright (c) 2007 Voltaire. All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
@ -29,6 +29,7 @@
#include "opal_config.h" #include "opal_config.h"
#include "opal/sys/atomic.h" #include "opal/sys/atomic.h"
#include "opal/prefetch.h"
BEGIN_C_DECLS BEGIN_C_DECLS
@ -40,12 +41,10 @@ BEGIN_C_DECLS
* Functions for locking of critical sections. * Functions for locking of critical sections.
*/ */
#if OMPI_ENABLE_THREAD_MULTIPLE
/* /*
* declaring this here so that CL does not complain * declaring this here so that CL does not complain
*/ */
OPAL_DECLSPEC extern bool opal_uses_threads; OPAL_DECLSPEC extern bool opal_uses_threads;
#endif
/** /**
* Opaque mutex object * Opaque mutex object
@ -144,11 +143,7 @@ BEGIN_C_DECLS
* possibility that we may have multiple threads, true will be * possibility that we may have multiple threads, true will be
* returned. * returned.
*/ */
#if OMPI_ENABLE_THREAD_MULTIPLE
#define opal_using_threads() opal_uses_threads #define opal_using_threads() opal_uses_threads
#else
#define opal_using_threads() 0
#endif
/** /**
* Set whether the process is using multiple threads or not. * Set whether the process is using multiple threads or not.
@ -168,9 +163,7 @@ BEGIN_C_DECLS
*/ */
static inline bool opal_set_using_threads(bool have) static inline bool opal_set_using_threads(bool have)
{ {
#if OMPI_ENABLE_THREAD_MULTIPLE
opal_uses_threads = have; opal_uses_threads = have;
#endif
return opal_using_threads(); return opal_using_threads();
} }
@ -190,7 +183,7 @@ static inline bool opal_set_using_threads(bool have)
*/ */
#define OPAL_THREAD_LOCK(mutex) \ #define OPAL_THREAD_LOCK(mutex) \
do { \ do { \
if (opal_using_threads()) { \ if (OPAL_UNLIKELY(opal_using_threads())) { \
opal_mutex_lock(mutex); \ opal_mutex_lock(mutex); \
} \ } \
} while (0) } while (0)
@ -212,7 +205,7 @@ static inline bool opal_set_using_threads(bool have)
* Returns 0 if mutex was locked, non-zero otherwise. * Returns 0 if mutex was locked, non-zero otherwise.
*/ */
#define OPAL_THREAD_TRYLOCK(mutex) \ #define OPAL_THREAD_TRYLOCK(mutex) \
(opal_using_threads() ? opal_mutex_trylock(mutex) : 0) (OPAL_UNLIKELY(opal_using_threads()) ? opal_mutex_trylock(mutex) : 0)
/** /**
* Unlock a mutex if opal_using_threads() says that multiple threads * Unlock a mutex if opal_using_threads() says that multiple threads
@ -229,7 +222,7 @@ static inline bool opal_set_using_threads(bool have)
*/ */
#define OPAL_THREAD_UNLOCK(mutex) \ #define OPAL_THREAD_UNLOCK(mutex) \
do { \ do { \
if (opal_using_threads()) { \ if (OPAL_UNLIKELY(opal_using_threads())) { \
opal_mutex_unlock(mutex); \ opal_mutex_unlock(mutex); \
} \ } \
} while (0) } while (0)
@ -252,7 +245,7 @@ static inline bool opal_set_using_threads(bool have)
*/ */
#define OPAL_THREAD_SCOPED_LOCK(mutex, action) \ #define OPAL_THREAD_SCOPED_LOCK(mutex, action) \
do { \ do { \
if(opal_using_threads()) { \ if(OPAL_UNLIKELY(opal_using_threads())) { \
opal_mutex_lock(mutex); \ opal_mutex_lock(mutex); \
action; \ action; \
opal_mutex_unlock(mutex); \ opal_mutex_unlock(mutex); \
@ -271,7 +264,7 @@ OPAL_THREAD_ADD32(volatile int32_t *addr, int delta)
{ {
int32_t ret; int32_t ret;
if (opal_using_threads()) { if (OPAL_UNLIKELY(opal_using_threads())) {
ret = opal_atomic_add_32(addr, delta); ret = opal_atomic_add_32(addr, delta);
} else { } else {
ret = (*addr += delta); ret = (*addr += delta);
@ -286,7 +279,7 @@ OPAL_THREAD_ADD64(volatile int64_t *addr, int delta)
{ {
int64_t ret; int64_t ret;
if (opal_using_threads()) { if (OPAL_UNLIKELY(opal_using_threads())) {
ret = opal_atomic_add_64(addr, delta); ret = opal_atomic_add_64(addr, delta);
} else { } else {
ret = (*addr += delta); ret = (*addr += delta);
@ -301,7 +294,7 @@ OPAL_THREAD_ADD_SIZE_T(volatile size_t *addr, int delta)
{ {
size_t ret; size_t ret;
if (opal_using_threads()) { if (OPAL_UNLIKELY(opal_using_threads())) {
ret = opal_atomic_add_size_t(addr, delta); ret = opal_atomic_add_size_t(addr, delta);
} else { } else {
ret = (*addr += delta); ret = (*addr += delta);
@ -315,15 +308,15 @@ OPAL_THREAD_ADD_SIZE_T(volatile size_t *addr, int delta)
#if OPAL_HAVE_ATOMIC_CMPSET_32 #if OPAL_HAVE_ATOMIC_CMPSET_32
#define OPAL_ATOMIC_CMPSET_32(x, y, z) \ #define OPAL_ATOMIC_CMPSET_32(x, y, z) \
(opal_using_threads() ? opal_atomic_cmpset_32(x, y, z) : OPAL_CMPSET(x, y, z)) (OPAL_UNLIKELY(opal_using_threads()) ? opal_atomic_cmpset_32(x, y, z) : OPAL_CMPSET(x, y, z))
#endif #endif
#if OPAL_HAVE_ATOMIC_CMPSET_64 #if OPAL_HAVE_ATOMIC_CMPSET_64
#define OPAL_ATOMIC_CMPSET_64(x, y, z) \ #define OPAL_ATOMIC_CMPSET_64(x, y, z) \
(opal_using_threads() ? opal_atomic_cmpset_64(x, y, z) : OPAL_CMPSET(x, y, z)) (OPAL_UNLIKELY(opal_using_threads()) ? opal_atomic_cmpset_64(x, y, z) : OPAL_CMPSET(x, y, z))
#endif #endif
#if OPAL_HAVE_ATOMIC_CMPSET_32 || OPAL_HAVE_ATOMIC_CMPSET_64 #if OPAL_HAVE_ATOMIC_CMPSET_32 || OPAL_HAVE_ATOMIC_CMPSET_64
#define OPAL_ATOMIC_CMPSET(x, y, z) \ #define OPAL_ATOMIC_CMPSET(x, y, z) \
(opal_using_threads() ? opal_atomic_cmpset(x, y, z) : OPAL_CMPSET(x, y, z)) (OPAL_UNLIKELY(opal_using_threads()) ? opal_atomic_cmpset(x, y, z) : OPAL_CMPSET(x, y, z))
#endif #endif
END_C_DECLS END_C_DECLS

Просмотреть файл

@ -279,17 +279,12 @@ static int _shmem_init(int argc, char **argv, int requested, int *provided)
goto error; goto error;
} }
if (OSHMEM_SUCCESS if (OSHMEM_SUCCESS != (ret = mca_spml_base_select(OPAL_ENABLE_PROGRESS_THREADS, 1))) {
!= (ret = mca_spml_base_select(OPAL_ENABLE_PROGRESS_THREADS,
OMPI_ENABLE_THREAD_MULTIPLE))) {
error = "mca_spml_base_select() failed"; error = "mca_spml_base_select() failed";
goto error; goto error;
} }
if (OSHMEM_SUCCESS if (OSHMEM_SUCCESS != (ret = mca_scoll_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, 1))) {
!= (ret =
mca_scoll_base_find_available(OPAL_ENABLE_PROGRESS_THREADS,
OMPI_ENABLE_THREAD_MULTIPLE))) {
error = "mca_scoll_base_find_available() failed"; error = "mca_scoll_base_find_available() failed";
goto error; goto error;
} }
@ -345,10 +340,7 @@ static int _shmem_init(int argc, char **argv, int requested, int *provided)
goto error; goto error;
} }
if (OSHMEM_SUCCESS if (OSHMEM_SUCCESS != (ret = mca_atomic_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, 1))) {
!= (ret =
mca_atomic_base_find_available(OPAL_ENABLE_PROGRESS_THREADS,
OMPI_ENABLE_THREAD_MULTIPLE))) {
error = "mca_atomic_base_find_available() failed"; error = "mca_atomic_base_find_available() failed";
goto error; goto error;
} }

Просмотреть файл

@ -266,17 +266,11 @@ void oshmem_info_do_config(bool want_all)
} }
#if OMPI_RTE_ORTE #if OMPI_RTE_ORTE
(void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: %s, OPAL support: %s, OMPI progress: %s, ORTE progress: yes, Event lib: yes)", (void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, ORTE progress: yes, Event lib: yes)",
"posix", "posix", OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no");
OMPI_ENABLE_THREAD_MULTIPLE ? "yes" : "no",
OPAL_ENABLE_MULTI_THREADS ? "yes" : "no",
OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no");
#else #else
(void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: %s, OPAL support: %s, OMPI progress: %s, Event lib: yes)", (void)asprintf(&threads, "%s (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: %s, Event lib: yes)",
"posix", "posix", OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no");
OMPI_ENABLE_THREAD_MULTIPLE ? "yes" : "no",
OPAL_ENABLE_MULTI_THREADS ? "yes" : "no",
OPAL_ENABLE_PROGRESS_THREADS ? "yes" : "no");
#endif #endif
(void)asprintf(&ft_support, "%s (checkpoint thread: %s)", (void)asprintf(&ft_support, "%s (checkpoint thread: %s)",