diff --git a/config/opal_config_threads.m4 b/config/opal_config_threads.m4 deleted file mode 100644 index d136cccf86b..00000000000 --- a/config/opal_config_threads.m4 +++ /dev/null @@ -1,69 +0,0 @@ -dnl -dnl Copyright (c) 2004-2010 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 (c) 2009-2011 Oak Ridge National Labs. All rights reserved. -dnl Copyright (c) 2014 Intel, Inc. All rights reserved -dnl Copyright (c) 2015 Research Organization for Information Science -dnl and Technology (RIST). All rights reserved. -dnl $COPYRIGHT$ -dnl -dnl Additional copyrights may follow -dnl -dnl $HEADER$ -dnl - -AC_DEFUN([OPAL_CONFIG_THREADS],[ -# -# Arguments: none -# -# Dependencies: None -# -# Modifies: -# none - see called tests -# -# configure threads -# - -# -# Check we have POSIX threads -# -OPAL_CONFIG_POSIX_THREADS(HAVE_POSIX_THREADS=1, HAVE_POSIX_THREADS=0) -AC_MSG_CHECKING([for working POSIX threads package]) -if test "$HAVE_POSIX_THREADS" = "1" ; then - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi -export HAVE_POSIX_THREADS - -# -# Ask what threading we want (allow posix right now) -# - -if test "$HAVE_POSIX_THREADS" = "0"; then - AC_MSG_WARN(["*** POSIX threads are not"]) - AC_MSG_WARN(["*** available on your system "]) - AC_MSG_ERROR(["*** Can not continue"]) -fi - -THREAD_CFLAGS="$PTHREAD_CFLAGS" -THREAD_FCFLAGS="$PTHREAD_FCFLAGS" -THREAD_CXXFLAGS="$PTHREAD_CXXFLAGS" -THREAD_CPPFLAGS="$PTHREAD_CPPFLAGS" -THREAD_CXXCPPFLAGS="$PTHREAD_CXXCPPFLAGS" -THREAD_LDFLAGS="$PTHREAD_LDFLAGS" -THREAD_LIBS="$PTHREAD_LIBS" - -OPAL_CHECK_PTHREAD_PIDS - -])dnl - diff --git a/ompi/attribute/attribute.c b/ompi/attribute/attribute.c index b3f5eda4568..c731069728d 100644 --- a/ompi/attribute/attribute.c +++ b/ompi/attribute/attribute.c @@ -232,7 +232,7 @@ #include "ompi_config.h" #include "opal/class/opal_bitmap.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/sys/atomic.h" #include "ompi/attribute/attribute.h" diff --git a/ompi/communicator/comm.c b/ompi/communicator/comm.c index 50b19ee98d5..de46901cbba 100644 --- a/ompi/communicator/comm.c +++ b/ompi/communicator/comm.c @@ -41,7 +41,7 @@ #include "opal/util/string_copy.h" #include "ompi/proc/proc.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/util/bit_ops.h" #include "opal/util/output.h" #include "ompi/mca/topo/topo.h" diff --git a/ompi/communicator/communicator.h b/ompi/communicator/communicator.h index 6adedd7a4a0..87a148dfd72 100644 --- a/ompi/communicator/communicator.h +++ b/ompi/communicator/communicator.h @@ -36,7 +36,7 @@ #include "opal/class/opal_hash_table.h" #include "opal/util/info_subscriber.h" #include "ompi/errhandler/errhandler.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "ompi/communicator/comm_request.h" #include "mpi.h" diff --git a/ompi/file/file.h b/ompi/file/file.h index 8e3fbb85a3d..bb50903ae5d 100644 --- a/ompi/file/file.h +++ b/ompi/file/file.h @@ -30,7 +30,7 @@ #include "mpi.h" #include "opal/class/opal_list.h" #include "ompi/errhandler/errhandler.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/util/info_subscriber.h" #include "ompi/mca/io/io.h" diff --git a/ompi/info/info.h b/ompi/info/info.h index 6e9466bc7c0..4128fb91890 100644 --- a/ompi/info/info.h +++ b/ompi/info/info.h @@ -32,7 +32,7 @@ #include "opal/util/info.h" #include "opal/class/opal_list.h" #include "opal/class/opal_pointer_array.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/mca/base/mca_base_var_enum.h" diff --git a/ompi/mca/common/monitoring/monitoring_prof.c b/ompi/mca/common/monitoring/monitoring_prof.c index a4ea139c679..1dcc0ca916c 100644 --- a/ompi/mca/common/monitoring/monitoring_prof.c +++ b/ompi/mca/common/monitoring/monitoring_prof.c @@ -58,7 +58,7 @@ writing 4x4 matrix to monitoring_avg.mat #define OMPI_COMPILING_FORTRAN_WRAPPERS 1 #endif -#include "opal/threads/thread_usage.h" +#include "opal/mca/threads/thread_usage.h" #include "ompi/include/mpi.h" #include "ompi/mpi/fortran/base/constants.h" diff --git a/ompi/mca/common/ompio/common_ompio.h b/ompi/mca/common/ompio/common_ompio.h index 68e11b51545..3d92bdd6861 100644 --- a/ompi/mca/common/ompio/common_ompio.h +++ b/ompi/mca/common/ompio/common_ompio.h @@ -29,7 +29,7 @@ #include "mpi.h" #include "opal/class/opal_list.h" #include "ompi/errhandler/errhandler.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "ompi/file/file.h" #include "ompi/mca/io/io.h" #include "ompi/mca/fs/fs.h" diff --git a/ompi/mca/io/ompio/io_ompio.h b/ompi/mca/io/ompio/io_ompio.h index 218c8a4ada5..4c019240892 100644 --- a/ompi/mca/io/ompio/io_ompio.h +++ b/ompi/mca/io/ompio/io_ompio.h @@ -29,7 +29,7 @@ #include "mpi.h" #include "opal/class/opal_list.h" #include "ompi/errhandler/errhandler.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "ompi/file/file.h" #include "ompi/mca/io/io.h" #include "ompi/mca/fs/fs.h" diff --git a/ompi/mca/io/ompio/io_ompio_component.c b/ompi/mca/io/ompio/io_ompio_component.c index d2ac847973b..ac0844f9c5e 100644 --- a/ompi/mca/io/ompio/io_ompio_component.c +++ b/ompi/mca/io/ompio/io_ompio_component.c @@ -28,7 +28,7 @@ #include "mpi.h" #include "opal/class/opal_list.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/mca/base/base.h" #include "ompi/mca/io/io.h" #include "ompi/mca/fs/base/base.h" diff --git a/ompi/mca/io/ompio/io_ompio_module.c b/ompi/mca/io/ompio/io_ompio_module.c index 109b99c82ef..0dea57f2a08 100644 --- a/ompi/mca/io/ompio/io_ompio_module.c +++ b/ompi/mca/io/ompio/io_ompio_module.c @@ -20,7 +20,7 @@ #include "ompi_config.h" #include "mpi.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "ompi/mca/io/io.h" #include "io_ompio.h" diff --git a/ompi/mca/io/romio321/src/io_romio321.h b/ompi/mca/io/romio321/src/io_romio321.h index b1c14b2d8c3..ee6a6bc97ab 100644 --- a/ompi/mca/io/romio321/src/io_romio321.h +++ b/ompi/mca/io/romio321/src/io_romio321.h @@ -24,7 +24,7 @@ #define MCA_IO_ROMIO321_H #include "ompi_config.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "ompi/request/request.h" #include "ompi/file/file.h" #include "ompi/mca/io/io.h" diff --git a/ompi/mca/io/romio321/src/io_romio321_component.c b/ompi/mca/io/romio321/src/io_romio321_component.c index e3dbbcf3919..2f1b50a822f 100644 --- a/ompi/mca/io/romio321/src/io_romio321_component.c +++ b/ompi/mca/io/romio321/src/io_romio321_component.c @@ -27,7 +27,7 @@ #include "mpi.h" #include "opal/class/opal_list.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/mca/base/base.h" #include "ompi/mca/io/io.h" #include "io_romio321.h" diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt.h b/ompi/mca/osc/pt2pt/osc_pt2pt.h index 85bad738462..1d1412831bd 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt.h +++ b/ompi/mca/osc/pt2pt/osc_pt2pt.h @@ -30,7 +30,7 @@ #include "opal/class/opal_list.h" #include "opal/class/opal_free_list.h" #include "opal/class/opal_hash_table.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/output.h" #include "ompi/win/win.h" diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt_active_target.c b/ompi/mca/osc/pt2pt/osc_pt2pt_active_target.c index 59831842bc9..ab04c697ed5 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt_active_target.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt_active_target.c @@ -33,7 +33,7 @@ #include "mpi.h" #include "opal/runtime/opal_progress.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "ompi/communicator/communicator.h" #include "ompi/mca/osc/base/base.h" diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt_passive_target.c b/ompi/mca/osc/pt2pt/osc_pt2pt_passive_target.c index 59b585337c0..0cafe109c3a 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt_passive_target.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt_passive_target.c @@ -31,7 +31,7 @@ #include "mpi.h" #include "opal/runtime/opal_progress.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "ompi/communicator/communicator.h" #include "ompi/mca/osc/base/base.h" #include "opal/include/opal_stdint.h" diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt_sync.h b/ompi/mca/osc/pt2pt/osc_pt2pt_sync.h index cf5da61bf88..98d8a084d04 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt_sync.h +++ b/ompi/mca/osc/pt2pt/osc_pt2pt_sync.h @@ -14,7 +14,7 @@ #include "ompi_config.h" #include "opal/class/opal_free_list.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" enum ompi_osc_pt2pt_sync_type_t { /** default value */ diff --git a/ompi/mca/osc/rdma/osc_rdma.h b/ompi/mca/osc/rdma/osc_rdma.h index 095c9ff5a2c..4ea7667ed50 100644 --- a/ompi/mca/osc/rdma/osc_rdma.h +++ b/ompi/mca/osc/rdma/osc_rdma.h @@ -26,7 +26,7 @@ #include "ompi_config.h" #include "opal/class/opal_free_list.h" #include "opal/class/opal_hash_table.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/output.h" #include "opal/mca/shmem/shmem.h" diff --git a/ompi/mca/osc/rdma/osc_rdma_active_target.c b/ompi/mca/osc/rdma/osc_rdma_active_target.c index 80c31fc00b3..f6cf6bb2820 100644 --- a/ompi/mca/osc/rdma/osc_rdma_active_target.c +++ b/ompi/mca/osc/rdma/osc_rdma_active_target.c @@ -31,7 +31,7 @@ #include "osc_rdma_active_target.h" #include "mpi.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "ompi/communicator/communicator.h" #include "ompi/mca/osc/base/base.h" diff --git a/ompi/mca/osc/rdma/osc_rdma_component.c b/ompi/mca/osc/rdma/osc_rdma_component.c index 830e12f99f5..1d96e7d6127 100644 --- a/ompi/mca/osc/rdma/osc_rdma_component.c +++ b/ompi/mca/osc/rdma/osc_rdma_component.c @@ -41,7 +41,7 @@ #include "osc_rdma_dynamic.h" #include "osc_rdma_accumulate.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/util/arch.h" #include "opal/util/argv.h" #include "opal/util/printf.h" diff --git a/ompi/mca/osc/rdma/osc_rdma_sync.h b/ompi/mca/osc/rdma/osc_rdma_sync.h index ce0daa5db94..31bf5bc3295 100644 --- a/ompi/mca/osc/rdma/osc_rdma_sync.h +++ b/ompi/mca/osc/rdma/osc_rdma_sync.h @@ -14,7 +14,7 @@ #include "osc_rdma_types.h" #include "opal/class/opal_object.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" /** * @brief synchronization types diff --git a/ompi/mca/pml/base/pml_base_bsend.c b/ompi/mca/pml/base/pml_base_bsend.c index 4da15522b8b..3826253e2ae 100644 --- a/ompi/mca/pml/base/pml_base_bsend.c +++ b/ompi/mca/pml/base/pml_base_bsend.c @@ -24,8 +24,8 @@ */ #include "ompi_config.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "ompi/datatype/ompi_datatype.h" #include "opal/mca/allocator/base/base.h" #include "opal/mca/allocator/allocator.h" diff --git a/ompi/mca/pml/ob1/pml_ob1_comm.h b/ompi/mca/pml/ob1/pml_ob1_comm.h index 780c9a44fc7..8e48a48e969 100644 --- a/ompi/mca/pml/ob1/pml_ob1_comm.h +++ b/ompi/mca/pml/ob1/pml_ob1_comm.h @@ -26,7 +26,7 @@ #ifndef MCA_PML_OB1_COMM_H #define MCA_PML_OB1_COMM_H -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/class/opal_list.h" #include "ompi/proc/proc.h" #include "ompi/communicator/communicator.h" diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index b61649ad2a5..7652cf317fd 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -33,7 +33,7 @@ #include "ompi_config.h" #include "opal/class/opal_list.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/prefetch.h" #include "ompi/constants.h" diff --git a/ompi/mca/rte/orte/rte_orte.h b/ompi/mca/rte/orte/rte_orte.h index 665cdd9e7bc..c191fe6cabd 100644 --- a/ompi/mca/rte/orte/rte_orte.h +++ b/ompi/mca/rte/orte/rte_orte.h @@ -26,7 +26,7 @@ struct opal_proc_t; -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "orte/types.h" #include "orte/mca/errmgr/errmgr.h" diff --git a/ompi/mca/rte/orte/rte_orte_component.c b/ompi/mca/rte/orte/rte_orte_component.c index 50e49935bd7..48460b55035 100644 --- a/ompi/mca/rte/orte/rte_orte_component.c +++ b/ompi/mca/rte/orte/rte_orte_component.c @@ -21,7 +21,7 @@ #include "ompi_config.h" #include "ompi/constants.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/class/opal_list.h" #include "orte/mca/rml/rml.h" diff --git a/ompi/mca/rte/orte/rte_orte_module.c b/ompi/mca/rte/orte/rte_orte_module.c index 046b6d2532e..c25b6d05f71 100644 --- a/ompi/mca/rte/orte/rte_orte_module.c +++ b/ompi/mca/rte/orte/rte_orte_module.c @@ -22,7 +22,7 @@ #include "opal/util/opal_getcwd.h" #include "opal/util/printf.h" #include "opal/mca/pmix/pmix.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/class/opal_list.h" #include "opal/dss/dss.h" diff --git a/ompi/mca/rte/pmix/rte_pmix.h b/ompi/mca/rte/pmix/rte_pmix.h index fd39621d5f3..ceda68d6dcb 100644 --- a/ompi/mca/rte/pmix/rte_pmix.h +++ b/ompi/mca/rte/pmix/rte_pmix.h @@ -35,7 +35,7 @@ struct opal_proc_t; -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/proc.h" #include "opal/mca/hwloc/hwloc-internal.h" #include "opal/mca/pmix/pmix.h" diff --git a/ompi/mca/rte/pmix/rte_pmix_component.c b/ompi/mca/rte/pmix/rte_pmix_component.c index a54c0b0ab0a..f19ee183106 100644 --- a/ompi/mca/rte/pmix/rte_pmix_component.c +++ b/ompi/mca/rte/pmix/rte_pmix_component.c @@ -21,7 +21,7 @@ #include "ompi_config.h" #include "ompi/constants.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/class/opal_list.h" #include "ompi/mca/rte/rte.h" diff --git a/ompi/mca/rte/pmix/rte_pmix_module.c b/ompi/mca/rte/pmix/rte_pmix_module.c index e876e9895fa..a734971c2a6 100644 --- a/ompi/mca/rte/pmix/rte_pmix_module.c +++ b/ompi/mca/rte/pmix/rte_pmix_module.c @@ -46,8 +46,8 @@ #include "opal/util/string_copy.h" #include "opal/mca/hwloc/base/base.h" #include "opal/mca/pmix/base/base.h" -#include "opal/threads/threads.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/threads.h" +#include "opal/mca/threads/tsd.h" #include "opal/class/opal_list.h" #include "opal/dss/dss.h" diff --git a/ompi/mpi/c/comm_get_name.c b/ompi/mpi/c/comm_get_name.c index c4904f13bf5..f7a0ce43d8a 100644 --- a/ompi/mpi/c/comm_get_name.c +++ b/ompi/mpi/c/comm_get_name.c @@ -23,7 +23,7 @@ #include -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/util/string_copy.h" #include "ompi/mpi/c/bindings.h" diff --git a/ompi/mpi/c/is_thread_main.c b/ompi/mpi/c/is_thread_main.c index 1be65a19194..3dead8d09d8 100644 --- a/ompi/mpi/c/is_thread_main.c +++ b/ompi/mpi/c/is_thread_main.c @@ -25,7 +25,7 @@ #include "ompi/communicator/communicator.h" #include "ompi/errhandler/errhandler.h" #include "ompi/runtime/mpiruntime.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #if OMPI_BUILD_MPI_PROFILING #if OPAL_HAVE_WEAK_SYMBOLS diff --git a/ompi/proc/proc.c b/ompi/proc/proc.c index 5b712bf25e1..8666201be7c 100644 --- a/ompi/proc/proc.c +++ b/ompi/proc/proc.c @@ -32,7 +32,7 @@ #include "ompi/constants.h" #include "opal/datatype/opal_convertor.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/dss/dss.h" #include "opal/util/arch.h" #include "opal/util/show_help.h" diff --git a/ompi/request/request.h b/ompi/request/request.h index 6460fbe4faf..4b0c28c4e6e 100644 --- a/ompi/request/request.h +++ b/ompi/request/request.h @@ -35,8 +35,8 @@ #include "mpi.h" #include "opal/class/opal_free_list.h" #include "opal/class/opal_pointer_array.h" -#include "opal/threads/condition.h" -#include "opal/threads/wait_sync.h" +#include "opal/mca/threads/condition.h" +#include "opal/mca/threads/wait_sync.h" #include "ompi/constants.h" BEGIN_C_DECLS diff --git a/ompi/runtime/mpiruntime.h b/ompi/runtime/mpiruntime.h index f311de538f5..81c9741c2e2 100644 --- a/ompi/runtime/mpiruntime.h +++ b/ompi/runtime/mpiruntime.h @@ -36,7 +36,7 @@ #include "opal/class/opal_list.h" #include "opal/class/opal_hash_table.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" BEGIN_C_DECLS diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index ec980487240..bf9c0eae93f 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -46,7 +46,7 @@ #include "opal/mca/base/base.h" #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal_progress.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/arch.h" #include "opal/util/argv.h" #include "opal/util/output.h" diff --git a/opal/Makefile.am b/opal/Makefile.am index b657794eabc..de2588716ed 100644 --- a/opal/Makefile.am +++ b/opal/Makefile.am @@ -71,7 +71,6 @@ endif include class/Makefile.am include memoryhooks/Makefile.am include runtime/Makefile.am -include threads/Makefile.am include mca/Makefile.am include tools/Makefile.am include dss/Makefile.am diff --git a/opal/class/opal_fifo.h b/opal/class/opal_fifo.h index ebb3a0e7d8e..89b90329383 100644 --- a/opal/class/opal_fifo.h +++ b/opal/class/opal_fifo.h @@ -28,7 +28,7 @@ #include "opal/class/opal_lifo.h" #include "opal/sys/atomic.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" BEGIN_C_DECLS diff --git a/opal/class/opal_free_list.h b/opal/class/opal_free_list.h index b7fd1920219..ddc383fb912 100644 --- a/opal/class/opal_free_list.h +++ b/opal/class/opal_free_list.h @@ -27,7 +27,7 @@ #include "opal_config.h" #include "opal/class/opal_lifo.h" #include "opal/prefetch.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/condition.h" #include "opal/constants.h" #include "opal/runtime/opal.h" diff --git a/opal/class/opal_lifo.h b/opal/class/opal_lifo.h index 4d07ef6ccda..99b90be10a2 100644 --- a/opal/class/opal_lifo.h +++ b/opal/class/opal_lifo.h @@ -31,7 +31,7 @@ #include "opal/class/opal_list.h" #include "opal/sys/atomic.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" BEGIN_C_DECLS diff --git a/opal/class/opal_list.h b/opal/class/opal_list.h index f9f1f00ab26..4ec07fc6e7f 100644 --- a/opal/class/opal_list.h +++ b/opal/class/opal_list.h @@ -75,7 +75,7 @@ #if OPAL_ENABLE_DEBUG /* Need atomics for debugging (reference counting) */ #include "opal/sys/atomic.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #endif BEGIN_C_DECLS diff --git a/opal/class/opal_object.h b/opal/class/opal_object.h index 4d3380f0da0..0f693fa1a9b 100644 --- a/opal/class/opal_object.h +++ b/opal/class/opal_object.h @@ -123,7 +123,7 @@ #include #include -#include "opal/threads/thread_usage.h" +#include "opal/mca/threads/thread_usage.h" BEGIN_C_DECLS diff --git a/opal/class/opal_pointer_array.h b/opal/class/opal_pointer_array.h index 5900243b043..ec6a883f5e4 100644 --- a/opal/class/opal_pointer_array.h +++ b/opal/class/opal_pointer_array.h @@ -31,7 +31,7 @@ #include "opal_config.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/class/opal_object.h" #include "opal/prefetch.h" diff --git a/opal/class/opal_ring_buffer.h b/opal/class/opal_ring_buffer.h index 7a841b3bbcb..ed607709dfd 100644 --- a/opal/class/opal_ring_buffer.h +++ b/opal/class/opal_ring_buffer.h @@ -26,7 +26,7 @@ #include "opal_config.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/class/opal_object.h" #include "opal/util/output.h" diff --git a/opal/class/opal_tree.h b/opal/class/opal_tree.h index e73d0a48d9c..c80c52d18af 100644 --- a/opal/class/opal_tree.h +++ b/opal/class/opal_tree.h @@ -67,7 +67,7 @@ #if OPAL_ENABLE_DEBUG /* Need atomics for debugging (reference counting) */ #include "opal/sys/atomic.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #endif BEGIN_C_DECLS diff --git a/opal/mca/allocator/basic/allocator_basic.h b/opal/mca/allocator/basic/allocator_basic.h index aa257457dbc..4766a994c8d 100644 --- a/opal/mca/allocator/basic/allocator_basic.h +++ b/opal/mca/allocator/basic/allocator_basic.h @@ -29,7 +29,7 @@ #include "opal_config.h" #include #include -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/class/opal_free_list.h" #include "opal/mca/allocator/allocator.h" diff --git a/opal/mca/allocator/bucket/allocator_bucket_alloc.h b/opal/mca/allocator/bucket/allocator_bucket_alloc.h index fe0b66e881e..103b611d7b4 100644 --- a/opal/mca/allocator/bucket/allocator_bucket_alloc.h +++ b/opal/mca/allocator/bucket/allocator_bucket_alloc.h @@ -29,7 +29,7 @@ #include "opal_config.h" #include #include -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/mca/allocator/allocator.h" BEGIN_C_DECLS diff --git a/opal/mca/btl/ofi/btl_ofi_rdma.h b/opal/mca/btl/ofi/btl_ofi_rdma.h index a9ad34c147d..b4e1965081e 100644 --- a/opal/mca/btl/ofi/btl_ofi_rdma.h +++ b/opal/mca/btl/ofi/btl_ofi_rdma.h @@ -14,7 +14,7 @@ #ifndef BTL_OFI_RDMA_H #define BTL_OFI_RDMA_H -#include "opal/threads/thread_usage.h" +#include "opal/mca/threads/thread_usage.h" #include "btl_ofi.h" #include "btl_ofi_endpoint.h" diff --git a/opal/mca/btl/tcp/btl_tcp_component.c b/opal/mca/btl/tcp/btl_tcp_component.c index d86d9a57a7a..297ecba6c73 100644 --- a/opal/mca/btl/tcp/btl_tcp_component.c +++ b/opal/mca/btl/tcp/btl_tcp_component.c @@ -76,7 +76,7 @@ #include "opal/mca/mpool/base/base.h" #include "opal/mca/btl/base/btl_base_error.h" #include "opal/mca/pmix/pmix.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/constants.h" #include "opal/mca/btl/btl.h" diff --git a/opal/mca/btl/uct/btl_uct.h b/opal/mca/btl/uct/btl_uct.h index 38756794430..0adbf9474e8 100644 --- a/opal/mca/btl/uct/btl_uct.h +++ b/opal/mca/btl/uct/btl_uct.h @@ -37,7 +37,7 @@ #include "opal/class/opal_fifo.h" #include "opal/class/opal_hash_table.h" #include "opal/mca/pmix/pmix.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include #include "btl_uct_types.h" diff --git a/opal/mca/btl/usnic/btl_usnic_cagent.c b/opal/mca/btl/usnic/btl_usnic_cagent.c index b265d37f352..ff17600a96c 100644 --- a/opal/mca/btl/usnic/btl_usnic_cagent.c +++ b/opal/mca/btl/usnic/btl_usnic_cagent.c @@ -22,7 +22,7 @@ #endif #include "opal_stdint.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/mca/event/event.h" #include "opal/util/show_help.h" #include "opal/types.h" diff --git a/opal/mca/btl/usnic/btl_usnic_cclient.c b/opal/mca/btl/usnic/btl_usnic_cclient.c index d1498d92249..cca6157dea1 100644 --- a/opal/mca/btl/usnic/btl_usnic_cclient.c +++ b/opal/mca/btl/usnic/btl_usnic_cclient.c @@ -25,7 +25,7 @@ #include #include "opal_stdint.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/mca/event/event.h" #include "opal/util/output.h" #include "opal/util/fd.h" diff --git a/opal/mca/btl/vader/btl_vader_component.c b/opal/mca/btl/vader/btl_vader_component.c index 2a773ceed25..4eb85b4d78b 100644 --- a/opal/mca/btl/vader/btl_vader_component.c +++ b/opal/mca/btl/vader/btl_vader_component.c @@ -32,7 +32,7 @@ #include "opal/util/output.h" #include "opal/util/show_help.h" #include "opal/util/printf.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/mca/btl/base/btl_base_error.h" #include "btl_vader.h" diff --git a/opal/mca/common/ucx/common_ucx_wpool.h b/opal/mca/common/ucx/common_ucx_wpool.h index 59c40c9d437..af1c47398cb 100644 --- a/opal/mca/common/ucx/common_ucx_wpool.h +++ b/opal/mca/common/ucx/common_ucx_wpool.h @@ -15,7 +15,7 @@ #include "opal/runtime/opal_progress.h" #include "opal/include/opal/constants.h" #include "opal/class/opal_list.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" BEGIN_C_DECLS diff --git a/opal/mca/event/event.h b/opal/mca/event/event.h index b0958b64e09..65f8f69e054 100644 --- a/opal/mca/event/event.h +++ b/opal/mca/event/event.h @@ -48,6 +48,8 @@ BEGIN_C_DECLS #define OPAL_TIMEOUT_DEFAULT {1, 0} +OPAL_DECLSPEC void opal_event_use_threads(void); + /** * Structure for event components. */ diff --git a/opal/mca/event/external/external.h b/opal/mca/event/external/external.h index 00378f684fe..6fe67feeeab 100644 --- a/opal/mca/event/external/external.h +++ b/opal/mca/event/external/external.h @@ -71,9 +71,6 @@ OPAL_DECLSPEC int opal_event_finalize(void); #define opal_event_set_priority(x, n) event_priority_set((x), (n)) -/* thread support APIs */ -#define opal_event_use_threads() evthread_use_pthreads() - /* Basic event APIs */ #define opal_event_enable_debug_mode() event_enable_debug_mode() diff --git a/opal/mca/event/libevent2022/libevent2022.h b/opal/mca/event/libevent2022/libevent2022.h index de3443539f0..3b8834d0fb2 100644 --- a/opal/mca/event/libevent2022/libevent2022.h +++ b/opal/mca/event/libevent2022/libevent2022.h @@ -48,8 +48,8 @@ #include #include "opal/class/opal_object.h" -#include "opal/threads/mutex.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/threads.h" #include "opal/util/output.h" #include "opal/constants.h" #include "opal/util/argv.h" @@ -102,9 +102,6 @@ OPAL_DECLSPEC int opal_event_finalize(void); #define opal_event_set_priority(x, n) event_priority_set((x), (n)) -/* thread support APIs */ -#define opal_event_use_threads() evthread_use_pthreads() - /* Basic event APIs */ #define opal_event_enable_debug_mode() event_enable_debug_mode() diff --git a/opal/mca/event/libevent2022/libevent2022_module.c b/opal/mca/event/libevent2022/libevent2022_module.c index b36f4d4f985..68bf898c161 100644 --- a/opal/mca/event/libevent2022/libevent2022_module.c +++ b/opal/mca/event/libevent2022/libevent2022_module.c @@ -53,8 +53,8 @@ #include #include "opal/class/opal_object.h" -#include "opal/threads/mutex.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/threads.h" #include "opal/util/output.h" #include "opal/util/argv.h" #include "opal/util/fd.h" diff --git a/opal/mca/hwloc/base/hwloc_base_frame.c b/opal/mca/hwloc/base/hwloc_base_frame.c index da48d4833ec..6ab3895be5b 100644 --- a/opal/mca/hwloc/base/hwloc_base_frame.c +++ b/opal/mca/hwloc/base/hwloc_base_frame.c @@ -20,7 +20,7 @@ #include "opal/util/show_help.h" #include "opal/mca/mca.h" #include "opal/mca/base/base.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "opal/mca/hwloc/hwloc-internal.h" #include "opal/mca/hwloc/base/base.h" diff --git a/opal/mca/hwloc/base/hwloc_base_util.c b/opal/mca/hwloc/base/hwloc_base_util.c index 5817090320a..6a45eeab764 100644 --- a/opal/mca/hwloc/base/hwloc_base_util.c +++ b/opal/mca/hwloc/base/hwloc_base_util.c @@ -54,7 +54,7 @@ #include "opal/util/os_dirpath.h" #include "opal/util/show_help.h" #include "opal/util/printf.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "opal/mca/pmix/pmix.h" #include "opal/mca/hwloc/hwloc-internal.h" diff --git a/opal/mca/mpool/base/mpool_base_alloc.c b/opal/mca/mpool/base/mpool_base_alloc.c index 1c4f87a9a91..ea5de261b78 100644 --- a/opal/mca/mpool/base/mpool_base_alloc.c +++ b/opal/mca/mpool/base/mpool_base_alloc.c @@ -29,7 +29,7 @@ #include "opal/mca/mpool/mpool.h" #include "base.h" #include "mpool_base_tree.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/util/info.h" diff --git a/opal/mca/patcher/linux/patcher_linux.h b/opal/mca/patcher/linux/patcher_linux.h index de4e85b35da..1d7b041b74f 100644 --- a/opal/mca/patcher/linux/patcher_linux.h +++ b/opal/mca/patcher/linux/patcher_linux.h @@ -18,7 +18,7 @@ #include "opal/mca/patcher/patcher.h" #include "opal/class/opal_list.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" struct mca_patcher_linux_patch_got_t { opal_list_item_t super; diff --git a/opal/mca/pmix/base/base.h b/opal/mca/pmix/base/base.h index 83365891070..54a98c1cd6c 100644 --- a/opal/mca/pmix/base/base.h +++ b/opal/mca/pmix/base/base.h @@ -14,7 +14,7 @@ #include "opal_config.h" #include "opal/types.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/mca/mca.h" #include "opal/mca/base/mca_base_framework.h" @@ -55,11 +55,11 @@ OPAL_DECLSPEC int opal_pmix_base_exchange(opal_value_t *info, OPAL_DECLSPEC void opal_pmix_base_set_evbase(opal_event_base_t *evbase); -#define opal_pmix_condition_wait(a,b) pthread_cond_wait(a, &(b)->m_lock_pthread) -typedef pthread_cond_t opal_pmix_condition_t; -#define opal_pmix_condition_broadcast(a) pthread_cond_broadcast(a) -#define opal_pmix_condition_signal(a) pthread_cond_signal(a) -#define OPAL_PMIX_CONDITION_STATIC_INIT PTHREAD_COND_INITIALIZER +#define opal_pmix_condition_wait(a,b) opal_cond_wait(a, b) +typedef opal_cond_t opal_pmix_condition_t; +#define opal_pmix_condition_broadcast(a) opal_cond_broadcast(a) +#define opal_pmix_condition_signal(a) opal_cond_signal(a) +#define OPAL_PMIX_CONDITION_STATIC_INIT OPAL_CONDITION_STATIC_INIT typedef struct { opal_mutex_t mutex; @@ -81,7 +81,7 @@ extern opal_pmix_base_t opal_pmix_base; #define OPAL_PMIX_CONSTRUCT_LOCK(l) \ do { \ OBJ_CONSTRUCT(&(l)->mutex, opal_mutex_t); \ - pthread_cond_init(&(l)->cond, NULL); \ + opal_cond_init(&(l)->cond); \ (l)->active = true; \ OPAL_POST_OBJECT((l)); \ } while(0) @@ -90,7 +90,7 @@ extern opal_pmix_base_t opal_pmix_base; do { \ OPAL_ACQUIRE_OBJECT((l)); \ OBJ_DESTRUCT(&(l)->mutex); \ - pthread_cond_destroy(&(l)->cond); \ + opal_cond_destroy(&(l)->cond); \ } while(0) diff --git a/opal/mca/pmix/base/pmix_base_frame.c b/opal/mca/pmix/base/pmix_base_frame.c index e06d18c0e36..bf42e7c21ea 100644 --- a/opal/mca/pmix/base/pmix_base_frame.c +++ b/opal/mca/pmix/base/pmix_base_frame.c @@ -13,7 +13,7 @@ #include "opal/constants.h" #include "opal/mca/mca.h" -#include "opal/threads/thread_usage.h" +#include "opal/mca/threads/thread_usage.h" #include "opal/util/argv.h" #include "opal/util/output.h" #include "opal/mca/base/base.h" diff --git a/opal/mca/pmix/ext2x/ext2x.c b/opal/mca/pmix/ext2x/ext2x.c index ce8324978f4..905c1bbdbdd 100644 --- a/opal/mca/pmix/ext2x/ext2x.c +++ b/opal/mca/pmix/ext2x/ext2x.c @@ -31,7 +31,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/opal_environ.h" diff --git a/opal/mca/pmix/ext2x/ext2x_client.c b/opal/mca/pmix/ext2x/ext2x_client.c index 8e01e7a1ac7..91a74c4ca34 100644 --- a/opal/mca/pmix/ext2x/ext2x_client.c +++ b/opal/mca/pmix/ext2x/ext2x_client.c @@ -30,7 +30,7 @@ #endif #include "opal/hash_string.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/opal_environ.h" #include "opal/util/proc.h" diff --git a/opal/mca/pmix/ext2x/ext2x_server_north.c b/opal/mca/pmix/ext2x/ext2x_server_north.c index be406eb6bf7..1203b3d3f89 100644 --- a/opal/mca/pmix/ext2x/ext2x_server_north.c +++ b/opal/mca/pmix/ext2x/ext2x_server_north.c @@ -29,7 +29,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/output.h" diff --git a/opal/mca/pmix/ext2x/ext2x_server_south.c b/opal/mca/pmix/ext2x/ext2x_server_south.c index 45228394ac7..479f44d805d 100644 --- a/opal/mca/pmix/ext2x/ext2x_server_south.c +++ b/opal/mca/pmix/ext2x/ext2x_server_south.c @@ -35,7 +35,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/output.h" diff --git a/opal/mca/pmix/ext3x/ext3x.c b/opal/mca/pmix/ext3x/ext3x.c index d59b393f4a3..abed19fc1ed 100644 --- a/opal/mca/pmix/ext3x/ext3x.c +++ b/opal/mca/pmix/ext3x/ext3x.c @@ -34,7 +34,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/opal_environ.h" diff --git a/opal/mca/pmix/ext3x/ext3x_client.c b/opal/mca/pmix/ext3x/ext3x_client.c index 617f20936b7..c95569ba4fd 100644 --- a/opal/mca/pmix/ext3x/ext3x_client.c +++ b/opal/mca/pmix/ext3x/ext3x_client.c @@ -31,7 +31,7 @@ #endif #include "opal/hash_string.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/opal_environ.h" #include "opal/util/proc.h" diff --git a/opal/mca/pmix/ext3x/ext3x_server_north.c b/opal/mca/pmix/ext3x/ext3x_server_north.c index c22e8862a46..ed0041fb1d3 100644 --- a/opal/mca/pmix/ext3x/ext3x_server_north.c +++ b/opal/mca/pmix/ext3x/ext3x_server_north.c @@ -29,7 +29,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/output.h" diff --git a/opal/mca/pmix/ext3x/ext3x_server_south.c b/opal/mca/pmix/ext3x/ext3x_server_south.c index 2991aca6c2d..fecd6a8a8c7 100644 --- a/opal/mca/pmix/ext3x/ext3x_server_south.c +++ b/opal/mca/pmix/ext3x/ext3x_server_south.c @@ -36,7 +36,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/output.h" diff --git a/opal/mca/pmix/pmix4x/pmix4x.c b/opal/mca/pmix/pmix4x/pmix4x.c index cd38aeeba64..1f82f25e084 100644 --- a/opal/mca/pmix/pmix4x/pmix4x.c +++ b/opal/mca/pmix/pmix4x/pmix4x.c @@ -34,7 +34,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/opal_environ.h" diff --git a/opal/mca/pmix/pmix4x/pmix4x_client.c b/opal/mca/pmix/pmix4x/pmix4x_client.c index d7ea3f6bb1c..2273bc34818 100644 --- a/opal/mca/pmix/pmix4x/pmix4x_client.c +++ b/opal/mca/pmix/pmix4x/pmix4x_client.c @@ -31,7 +31,7 @@ #endif #include "opal/hash_string.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/opal_environ.h" #include "opal/util/proc.h" diff --git a/opal/mca/pmix/pmix4x/pmix4x_local.c b/opal/mca/pmix/pmix4x/pmix4x_local.c index 2665d4b1c09..f98b08da02c 100644 --- a/opal/mca/pmix/pmix4x/pmix4x_local.c +++ b/opal/mca/pmix/pmix4x/pmix4x_local.c @@ -31,7 +31,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/opal_environ.h" diff --git a/opal/mca/pmix/pmix4x/pmix4x_server_north.c b/opal/mca/pmix/pmix4x/pmix4x_server_north.c index ea941149ef6..d8ff9470921 100644 --- a/opal/mca/pmix/pmix4x/pmix4x_server_north.c +++ b/opal/mca/pmix/pmix4x/pmix4x_server_north.c @@ -29,7 +29,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/output.h" diff --git a/opal/mca/pmix/pmix4x/pmix4x_server_south.c b/opal/mca/pmix/pmix4x/pmix4x_server_south.c index 9102af45b00..cceec8252aa 100644 --- a/opal/mca/pmix/pmix4x/pmix4x_server_south.c +++ b/opal/mca/pmix/pmix4x/pmix4x_server_south.c @@ -36,7 +36,7 @@ #include "opal/mca/hwloc/base/base.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_progress_threads.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/output.h" diff --git a/opal/mca/rcache/rcache.h b/opal/mca/rcache/rcache.h index f95fa1a5972..ed68deca7ac 100644 --- a/opal/mca/rcache/rcache.h +++ b/opal/mca/rcache/rcache.h @@ -27,7 +27,7 @@ #define MCA_RCACHE_H #include "opal/mca/mca.h" #include "opal/mca/mpool/mpool.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" /* forward-declaration of rcache module structure */ diff --git a/opal/mca/threads/Makefile.am b/opal/mca/threads/Makefile.am new file mode 100644 index 00000000000..7e7e65173b5 --- /dev/null +++ b/opal/mca/threads/Makefile.am @@ -0,0 +1,40 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2019 Sandia National Laboratories. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# main library setup +noinst_LTLIBRARIES = libmca_threads.la +libmca_threads_la_SOURCES = + +# local files +headers = threads.h +nodist_headers = +libmca_threads_la_SOURCES += $(headers) + +# Conditionally install the header files +if WANT_INSTALL_HEADERS +opaldir = $(opalincludedir)/$(subdir) +nobase_opal_HEADERS = $(headers) +nobase_nodist_opal_HEADERS = $(nodist_headers) +endif + +include base/Makefile.am + +distclean-local: + rm -f base/static-components.h diff --git a/opal/mca/threads/README b/opal/mca/threads/README new file mode 100644 index 00000000000..f09509a604f --- /dev/null +++ b/opal/mca/threads/README @@ -0,0 +1,43 @@ + +MCA THREADING FRAMEWORKS: +------------------------- +This MCA framework makes it possible to integrate new threading frameworks with the OpenMPI runtime. + +BACKGROUND +---------- +There has been a lot of interest in integrating alternative threading models, in particular lightweight threading models with MPI implementations. Open MPI's modular component architecture seems like an ideal architecture for this sort of integration (in fact it was, Open MPI used to support Solaris and Windows threads). + +Recently there has been interest in integrating MPI with lightweight tasking layers, which led to work reviving and modernizing the old modular threading code but with an emphasis on integrating lightweight threading models. + +SELECTING A THREADING MODEL +--------------------------- + +The threading model is chosen via the configure option --with-threads=. This will choose a compile time threading model as well as compiling the relevant MCA. + +IMPLEMENTATION +-------------- +The MCA for threading libraries is implemented in two places, once as a set of .h files in mca/threads//threads__{threads,mutex,tsd}.h which are defined inline to the main thread implementation and also as an mca component that is loaded at runtime. + +For performance reasons, in particular synchonization overhead, it is not possible to implement a threading model as a traditional MCA. This means --at least in the short term-- that threading models are chosen at compile time rather than runtime options, using mechanisms similar to OpenMPI's libevent integration. + +The .h files are meant to be run on the fast path containing inline synchonization functions (threads__mutex.h, thread local storage (threads__tsd.h) and the opal_thread structure (threads__thread.h). + +The rest of the threading implementation follows the normal MCA model: + +* threads__component.c describes the version of the module and specifies the module open behavior (the threading model initialization goes here). + +* threads__condition.c defines an instance of opal_condition_t which is used by condition.h to define Open MPI specific condition variables. + +* threads__event.c defines an interface to Open MPI's libevent hooks. It allows the threading module to use threading model specific memory allocation and synchronization structures with Open MPI's libevent integration. + +* threads__module.c defines the interface to opal's thread handle. It provides ways of comparing threads, getting the value of a thread via its handle and the implementation of thread local storage. + +* threads__mutex.c provides a slow path interface to creating and destroying mutices dynamically via mca allocation. They can also be defined statically using the .h fast path interface. + +* threads__wait_sync.c provides condition variable like waiting capability that ensures MPI progress while it waits. + +TODO +---- +Libevent integration with lightweight threading models is a work in progress. The current Open MPI libevent library assumes preemption and does not yield by default. Lightweight threading libraries typically require tasks to be cooperative and to voluntarily yield after some time. + +Open MPI itself needs to be altered to use a common yielding model instead of usleep(3). diff --git a/opal/mca/threads/argobots/Makefile.am b/opal/mca/threads/argobots/Makefile.am new file mode 100644 index 00000000000..ffec87a40d3 --- /dev/null +++ b/opal/mca/threads/argobots/Makefile.am @@ -0,0 +1,34 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2019 Sandia National Laboratories. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +noinst_LTLIBRARIES = libmca_threads_argobots.la + +libmca_threads_argobots_la_SOURCES = \ + threads_argobots.h \ + threads_argobots_component.c \ + threads_argobots_condition.c \ + threads_argobots_event.c \ + threads_argobots_module.c \ + threads_argobots_mutex.c \ + threads_argobots_mutex.h \ + threads_argobots_threads.h \ + threads_argobots_tsd.h \ + threads_argobots_wait_sync.c \ + threads_argobots_wait_sync.h diff --git a/opal/mca/threads/argobots/configure.m4 b/opal/mca/threads/argobots/configure.m4 new file mode 100644 index 00000000000..d23ce8c3b5a --- /dev/null +++ b/opal/mca/threads/argobots/configure.m4 @@ -0,0 +1,73 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2015 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# Copyright (c) 2019 Sandia National Laboratories. All rights reserved. +# Copyright (c) 2019 Triad National Security, LLC. All rights +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +AC_DEFUN([OPAL_CONFIG_ARGOBOTS_THREADS],[ + AC_CHECK_HEADERS([abt.h], + [AC_CHECK_LIB([abt],[ABT_init], + [threads_argobots_happy="yes"], + [threads_argobots_happy="no"])], + [threads_argobots_happy="no"]) + + AS_IF([test "$threads_argobots_happy" = "yes"], + [$1], + [$2]) +])dnl + +AC_DEFUN([MCA_opal_threads_argobots_PRIORITY], [30]) + +AC_DEFUN([MCA_opal_threads_argobots_COMPILE_MODE], [ + AC_MSG_CHECKING([for MCA component $2:$3 compile mode]) + $4="static" + AC_MSG_RESULT([$$4]) +]) + +AC_DEFUN([MCA_opal_threads_argobots_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [threads_base_include="argobots/threads_argobots_threads.h"]) +])dnl + +AC_DEFUN([MCA_opal_mutex_argobots_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [mutex_base_include="argobots/threads_argobots_mutex.h"]) + AC_MSG_CHECKING([mutex_base_include = $mutex_base_include]) +])dnl + +AC_DEFUN([MCA_opal_tsd_argobots_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [threads_base_include="argobots/threads_argobots_tsd.h"]) + AC_MSG_CHECKING([threads_base_include = $threads_base_include]) +])dnl + +AC_DEFUN([MCA_opal_wait_sync_argobots_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [wait_sync_base_include="argobots/threads_argobots_wait_sync.h"]) + AC_MSG_CHECKING([wait_sync_base_include = $wait_sync_base_include]) +])dnl + +# MCA_threads_argobots_CONFIG(action-if-can-compile, +# [action-if-cant-compile]) +# ------------------------------------------------ +AC_DEFUN([MCA_opal_threads_argobots_CONFIG],[ + AC_CONFIG_FILES([opal/mca/threads/argobots/Makefile]) + + AS_IF([test "$HAVE_THREAD_PKG_TYPE" = "argobots"], + [$1], + [$2]) +]) diff --git a/opal/mca/threads/argobots/owner.txt b/opal/mca/threads/argobots/owner.txt new file mode 100644 index 00000000000..199577ac8cf --- /dev/null +++ b/opal/mca/threads/argobots/owner.txt @@ -0,0 +1,7 @@ +# +# owner/status file +# owner: institution that is responsible for this package +# status: e.g. active, maintenance, unmaintained +# +owner: SNL +status: unmaintained diff --git a/opal/mca/threads/argobots/threads_argobots.h b/opal/mca/threads/argobots/threads_argobots.h new file mode 100644 index 00000000000..133fa81582a --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots.h @@ -0,0 +1,12 @@ + +#ifndef OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_H +#define OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_H 1 + +#include + +static inline void ensure_init_argobots(void) { + if (ABT_initialized() != 0) + ABT_init(0, 0); +} + +#endif /* OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_H */ diff --git a/opal/mca/threads/argobots/threads_argobots_component.c b/opal/mca/threads/argobots/threads_argobots_component.c new file mode 100644 index 00000000000..b72b0bca859 --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_component.c @@ -0,0 +1,57 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2014 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include "opal/mca/threads/argobots/threads_argobots.h" +#include "opal/mca/threads/thread.h" +#include "opal/mca/threads/threads.h" +#include "opal/constants.h" +#include + +static int opal_threads_argobots_open(void); + +const opal_threads_base_component_1_0_0_t mca_threads_argobots_component = { + /* First, the mca_component_t struct containing meta information + about the component itself */ + .threadsc_version = { + OPAL_THREADS_BASE_VERSION_1_0_0, + + /* Component name and version */ + .mca_component_name = "argobots", + MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, + OPAL_RELEASE_VERSION), + + .mca_open_component = opal_threads_argobots_open, + }, + .threadsc_data = { + /* The component is checkpoint ready */ + MCA_BASE_METADATA_PARAM_CHECKPOINT + }, +}; + +int opal_threads_argobots_open(void) +{ + ensure_init_argobots(); + return OPAL_SUCCESS; +} diff --git a/opal/mca/threads/argobots/threads_argobots_condition.c b/opal/mca/threads/argobots/threads_argobots_condition.c new file mode 100644 index 00000000000..6e7c2868569 --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_condition.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include "opal/mca/threads/condition.h" + + +static void opal_condition_construct(opal_condition_t *c) +{ + c->c_waiting = 0; + c->c_signaled = 0; +} + + +static void opal_condition_destruct(opal_condition_t *c) +{ +} + +OBJ_CLASS_INSTANCE(opal_condition_t, + opal_object_t, + opal_condition_construct, + opal_condition_destruct); diff --git a/opal/mca/threads/argobots/threads_argobots_event.c b/opal/mca/threads/argobots/threads_argobots_event.c new file mode 100644 index 00000000000..c9c9fd98baf --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_event.c @@ -0,0 +1,136 @@ + +#include "opal/mca/threads/threads.h" +#include "opal/mca/threads/argobots/threads_argobots.h" +#include "opal/mca/event/libevent2022/libevent/include/event2/thread.h" +#include "opal/mca/event/libevent2022/libevent/include/event2/event-config.h" +#include "opal/mca/event/libevent2022/libevent/include/event2/util.h" + +#include + +static void * +evthread_argobots_lock_alloc(unsigned locktype) +{ + ABT_mutex lock; + if (locktype & EVTHREAD_LOCKTYPE_RECURSIVE) { + ABT_mutex_attr abt_mutex_attr; + ABT_mutex_attr_create(&abt_mutex_attr); + ABT_mutex_attr_set_recursive(abt_mutex_attr, ABT_TRUE); + ABT_mutex_create_with_attr(abt_mutex_attr, &lock); + ABT_mutex_attr_free(&abt_mutex_attr); + } else { + ABT_mutex_create(&lock); + } + return lock; +} + +static void +evthread_argobots_lock_free(void *_lock, unsigned locktype) +{ + ABT_mutex lock = _lock; + ABT_mutex_free(&lock); +} + +static int +evthread_argobots_lock(unsigned mode, void *_lock) +{ + int ret; + ABT_mutex lock = _lock; + if (mode & EVTHREAD_TRY) { + ret = ABT_mutex_trylock(lock); + } else { + ret = ABT_mutex_lock(lock); + } + return ret; +} + +static int +evthread_argobots_unlock(unsigned mode, void *_lock) +{ + ABT_mutex lock = _lock; + int ret = ABT_mutex_unlock(lock); + /* This yield is necessary to avoid taking a lock consecutively. */ + ABT_thread_yield(); + return ret; +} + +static unsigned long +evthread_argobots_get_id(void) +{ + ABT_thread thr; + ABT_thread_self(&thr); + return (unsigned long)((intptr_t)thr); +} + +static void * +evthread_argobots_cond_alloc(unsigned condflags) +{ + ABT_cond cond; + ABT_cond_create(&cond); + return cond; +} + +static void +evthread_argobots_cond_free(void *_cond) +{ + ABT_cond cond = _cond; + ABT_cond_free(&cond); +} + +static int +evthread_argobots_cond_signal(void *_cond, int broadcast) +{ + ABT_cond cond = _cond; + int r; + if (broadcast) + r = ABT_cond_broadcast(cond); + else + r = ABT_cond_signal(cond); + return r ? -1 : 0; +} + +static int +evthread_argobots_cond_wait(void *_cond, void *_lock, const struct timeval *tv) +{ + int r; + ABT_cond cond = _cond; + ABT_mutex lock = _lock; + + if (tv) { + struct timeval now, abstime; + struct timespec ts; + evutil_gettimeofday(&now, NULL); + evutil_timeradd(&now, tv, &abstime); + ts.tv_sec = abstime.tv_sec; + ts.tv_nsec = abstime.tv_usec*1000; + r = ABT_cond_timedwait(cond, lock, &ts); + if (r != 0) + return 1; + else + return 0; + } else { + r = ABT_cond_wait(cond, lock); + return r ? -1 : 0; + } +} + +void opal_event_use_threads(void) { + struct evthread_lock_callbacks cbs = { + EVTHREAD_LOCK_API_VERSION, + EVTHREAD_LOCKTYPE_RECURSIVE, + evthread_argobots_lock_alloc, + evthread_argobots_lock_free, + evthread_argobots_lock, + evthread_argobots_unlock + }; + struct evthread_condition_callbacks cond_cbs = { + EVTHREAD_CONDITION_API_VERSION, + evthread_argobots_cond_alloc, + evthread_argobots_cond_free, + evthread_argobots_cond_signal, + evthread_argobots_cond_wait + }; + ensure_init_argobots(); + evthread_set_lock_callbacks(&cbs); + evthread_set_condition_callbacks(&cond_cbs); + evthread_set_id_callback(evthread_argobots_get_id); +} diff --git a/opal/mca/threads/argobots/threads_argobots_module.c b/opal/mca/threads/argobots/threads_argobots_module.c new file mode 100644 index 00000000000..8587ab0e3e1 --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_module.c @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +#include + +#include "opal/mca/threads/argobots/threads_argobots.h" +#include "opal/constants.h" +#include "opal/util/sys_limits.h" +#include "opal/util/output.h" +#include "opal/prefetch.h" +#include "opal/mca/threads/threads.h" +#include "opal/mca/threads/tsd.h" + +#include + +struct opal_tsd_key_value { + opal_tsd_key_t key; + opal_tsd_destructor_t destructor; +}; + +static ABT_thread opal_main_thread; +struct opal_tsd_key_value *opal_tsd_key_values = NULL; +static int opal_tsd_key_values_count = 0; + +/* + * Constructor + */ +static void opal_thread_construct(opal_thread_t *t) +{ + t->t_run = 0; + t->t_handle = ABT_THREAD_NULL; +} + +OBJ_CLASS_INSTANCE(opal_thread_t, + opal_object_t, + opal_thread_construct, NULL); + +static inline ABT_thread opal_thread_get_argobots_self(void) { + ABT_thread self; + ABT_thread_self(&self); + return self; +} + +static void opal_thread_argobots_wrapper(void *arg) { + opal_thread_t *t = (opal_thread_t *) arg; + t->t_ret = ((void*(*)(void*)) t->t_run)(t); +} + +opal_thread_t *opal_thread_get_self(void) +{ + ensure_init_argobots(); + opal_thread_t *t = OBJ_NEW(opal_thread_t); + t->t_handle = opal_thread_get_argobots_self(); + return t; +} + +bool opal_thread_self_compare(opal_thread_t *t) +{ + ensure_init_argobots(); + return t->t_handle == opal_thread_get_argobots_self(); +} + +int opal_thread_join(opal_thread_t *t, void **thr_return) { + ensure_init_argobots(); + int rc = ABT_thread_free(&t->t_handle); + if (thr_return) + *thr_return = t->t_ret; + t->t_handle = ABT_THREAD_NULL; + return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; +} + +void opal_thread_set_main() { + ensure_init_argobots(); + opal_main_thread = opal_thread_get_argobots_self(); +} + +int opal_thread_start(opal_thread_t *t) { + ensure_init_argobots(); + int rc; + if (OPAL_ENABLE_DEBUG) { + if (NULL == t->t_run || t->t_handle != ABT_THREAD_NULL) { + return OPAL_ERR_BAD_PARAM; + } + } + + ABT_xstream self_xstream; + ABT_xstream_self(&self_xstream); + rc = ABT_thread_create_on_xstream(self_xstream, + opal_thread_argobots_wrapper, t, + ABT_THREAD_ATTR_NULL, &t->t_handle); + + return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; +} + +opal_class_t opal_thread_t_class; + +int opal_tsd_key_create(opal_tsd_key_t *key, opal_tsd_destructor_t destructor) +{ + ensure_init_argobots(); + int rc; + rc = ABT_key_create(destructor, key); + if ((0 == rc) && (opal_thread_get_argobots_self() == opal_main_thread)) { + opal_tsd_key_values = (struct opal_tsd_key_value *)realloc(opal_tsd_key_values, (opal_tsd_key_values_count+1) * sizeof(struct opal_tsd_key_value)); + opal_tsd_key_values[opal_tsd_key_values_count].key = *key; + opal_tsd_key_values[opal_tsd_key_values_count].destructor = destructor; + opal_tsd_key_values_count ++; + } + return rc; +} + +int opal_tsd_keys_destruct() +{ + ensure_init_argobots(); + int i; + void * ptr; + for (i=0; i +#include + +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/argobots/threads_argobots_mutex.h" + +/* + * Wait and see if some upper layer wants to use threads, if support + * exists. + */ +bool opal_uses_threads = false; + +static void mca_threads_argobots_mutex_constructor(opal_mutex_t *p_mutex) { + ensure_init_argobots(); + p_mutex->m_lock_argobots = OPAL_ABT_MUTEX_NULL; + p_mutex->m_recursive = 0; +#if OPAL_ENABLE_DEBUG + p_mutex->m_lock_debug = 0; + p_mutex->m_lock_file = NULL; + p_mutex->m_lock_line = 0; +#endif + opal_atomic_lock_init(&p_mutex->m_lock_atomic, 0); +} + +static void mca_threads_argobots_mutex_desctructor(opal_mutex_t *p_mutex) { + ensure_init_argobots(); + if (p_mutex->m_lock_argobots != OPAL_ABT_MUTEX_NULL) + ABT_mutex_free(&p_mutex->m_lock_argobots); +} + +static void mca_threads_argobots_recursive_mutex_constructor + (opal_recursive_mutex_t *p_mutex) { + ensure_init_argobots(); + p_mutex->m_lock_argobots = OPAL_ABT_MUTEX_NULL; + p_mutex->m_recursive = 1; +#if OPAL_ENABLE_DEBUG + p_mutex->m_lock_debug = 0; + p_mutex->m_lock_file = NULL; + p_mutex->m_lock_line = 0; +#endif + opal_atomic_lock_init(&p_mutex->m_lock_atomic, 0); +} + +static void mca_threads_argobots_recursive_mutex_desctructor + (opal_recursive_mutex_t *p_mutex) { + ensure_init_argobots(); + if (p_mutex->m_lock_argobots != OPAL_ABT_MUTEX_NULL) + ABT_mutex_free(&p_mutex->m_lock_argobots); +} + +OBJ_CLASS_INSTANCE(opal_mutex_t, + opal_object_t, + mca_threads_argobots_mutex_constructor, + mca_threads_argobots_mutex_desctructor); +OBJ_CLASS_INSTANCE(opal_recursive_mutex_t, + opal_object_t, + mca_threads_argobots_recursive_mutex_constructor, + mca_threads_argobots_recursive_mutex_desctructor); diff --git a/opal/mca/threads/argobots/threads_argobots_mutex.h b/opal/mca/threads/argobots/threads_argobots_mutex.h new file mode 100644 index 00000000000..72da868f0a6 --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_mutex.h @@ -0,0 +1,311 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2006 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2007-2018 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2015-2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#ifndef OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_MUTEX_H +#define OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_MUTEX_H 1 + +/** + * @file: + * + * Mutual exclusion functions: Unix implementation. + * + * Functions for locking of critical sections. + * + * On unix, use Argobots or our own atomic operations as + * available. + */ + +#include "opal/mca/threads/argobots/threads_argobots.h" +#include "opal_config.h" + +#include +#include + +#include "opal/class/opal_object.h" +#include "opal/sys/atomic.h" + +#include + +BEGIN_C_DECLS + +/* Don't use ABT_MUTEX_NULL, since it might be not NULL. */ +#define OPAL_ABT_MUTEX_NULL 0 + +struct opal_mutex_t { + opal_object_t super; + + ABT_mutex m_lock_argobots; + int m_recursive; + +#if OPAL_ENABLE_DEBUG + int m_lock_debug; + const char *m_lock_file; + int m_lock_line; +#endif + + opal_atomic_lock_t m_lock_atomic; +}; + +typedef struct opal_argobots_mutex_t opal_pthread_mutex_t; +typedef struct opal_argobots_mutex_t opal_pthread_recursive_mutex_t; + +OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_mutex_t); +OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_recursive_mutex_t); + +#if OPAL_ENABLE_DEBUG +#define OPAL_MUTEX_STATIC_INIT \ + { \ + .super = OPAL_OBJ_STATIC_INIT(opal_mutex_t), \ + .m_lock_argobots = OPAL_ABT_MUTEX_NULL, \ + .m_recursive = 0, \ + .m_lock_debug = 0, \ + .m_lock_file = NULL, \ + .m_lock_line = 0, \ + .m_lock_atomic = OPAL_ATOMIC_LOCK_INIT, \ + } +#else +#define OPAL_MUTEX_STATIC_INIT \ + { \ + .super = OPAL_OBJ_STATIC_INIT(opal_mutex_t), \ + .m_lock_argobots = OPAL_ABT_MUTEX_NULL, \ + .m_recursive = 0, \ + .m_lock_atomic = OPAL_ATOMIC_LOCK_INIT, \ + } +#endif + +#if defined(OPAL_PTHREAD_RECURSIVE_MUTEX_INITIALIZER) + +#if OPAL_ENABLE_DEBUG +#define OPAL_RECURSIVE_MUTEX_STATIC_INIT \ + { \ + .super = OPAL_OBJ_STATIC_INIT(opal_mutex_t), \ + .m_lock_argobots = OPAL_ABT_MUTEX_NULL, \ + .m_recursive = 1, \ + .m_lock_debug = 0, \ + .m_lock_file = NULL, \ + .m_lock_line = 0, \ + .m_lock_atomic = OPAL_ATOMIC_LOCK_INIT, \ + } +#else +#define OPAL_RECURSIVE_MUTEX_STATIC_INIT \ + { \ + .super = OPAL_OBJ_STATIC_INIT(opal_mutex_t), \ + .m_lock_argobots = OPAL_ABT_MUTEX_NULL, \ + .m_recursive = 1, \ + .m_lock_atomic = OPAL_ATOMIC_LOCK_INIT, \ + } +#endif + +#endif + +/************************************************************************ + * + * mutex operations (non-atomic versions) + * + ************************************************************************/ + +static inline void opal_mutex_create(struct opal_mutex_t *m) { + while (m->m_lock_argobots == OPAL_ABT_MUTEX_NULL) { + ABT_mutex abt_mutex; + if (m->m_recursive) { + ABT_mutex_attr abt_mutex_attr; + ABT_mutex_attr_create(&abt_mutex_attr); + ABT_mutex_attr_set_recursive(abt_mutex_attr, ABT_TRUE); + ABT_mutex_create_with_attr(abt_mutex_attr, &abt_mutex); + ABT_mutex_attr_free(&abt_mutex_attr); + } else { + ABT_mutex_create(&abt_mutex); + } + void *null_ptr = OPAL_ABT_MUTEX_NULL; + if (opal_atomic_compare_exchange_strong_ptr( + (intptr_t *)&m->m_lock_argobots, (intptr_t *)&null_ptr, + (intptr_t)abt_mutex)) { + /* mutex is successfully created and substituted. */ + return; + } + ABT_mutex_free(&abt_mutex); + } +} + +static inline int opal_mutex_trylock(opal_mutex_t *m) +{ + ensure_init_argobots(); + if (m->m_lock_argobots == OPAL_ABT_MUTEX_NULL) + opal_mutex_create(m); +#if OPAL_ENABLE_DEBUG + int ret = ABT_mutex_trylock(m->m_lock_argobots); + if (ret != 0) { + errno = ret; + perror("opal_mutex_trylock()"); + abort(); + } + return ret; +#else + return ABT_mutex_trylock(m->m_lock_argobots); +#endif +} + +static inline void opal_mutex_lock(opal_mutex_t *m) +{ + ensure_init_argobots(); + if (m->m_lock_argobots == OPAL_ABT_MUTEX_NULL) + opal_mutex_create(m); +#if OPAL_ENABLE_DEBUG + int ret = ABT_mutex_lock(m->m_lock_argobots); + if (ret != 0) { + errno = ret; + perror("opal_mutex_lock()"); + abort(); + } +#else + ABT_mutex_lock(m->m_lock_argobots); +#endif +} + +static inline void opal_mutex_unlock(opal_mutex_t *m) +{ + ensure_init_argobots(); + if (m->m_lock_argobots == OPAL_ABT_MUTEX_NULL) + opal_mutex_create(m); +#if OPAL_ENABLE_DEBUG + int ret = ABT_mutex_unlock(m->m_lock_argobots); + if (ret != 0) { + errno = ret; + perror("opal_mutex_unlock"); + abort(); + } +#else + ABT_mutex_unlock(m->m_lock_argobots); +#endif + /* For fairness of locking. */ + ABT_thread_yield(); +} + +/************************************************************************ + * + * mutex operations (atomic versions) + * + ************************************************************************/ + +#if OPAL_HAVE_ATOMIC_SPINLOCKS + +/************************************************************************ + * Spin Locks + ************************************************************************/ + +static inline int opal_mutex_atomic_trylock(opal_mutex_t *m) +{ + return opal_atomic_trylock(&m->m_lock_atomic); +} + +static inline void opal_mutex_atomic_lock(opal_mutex_t *m) +{ + opal_atomic_lock(&m->m_lock_atomic); +} + +static inline void opal_mutex_atomic_unlock(opal_mutex_t *m) +{ + opal_atomic_unlock(&m->m_lock_atomic); +} + +#else + +/************************************************************************ + * Standard locking + ************************************************************************/ + +static inline int opal_mutex_atomic_trylock(opal_mutex_t *m) +{ + return opal_mutex_trylock(m); +} + +static inline void opal_mutex_atomic_lock(opal_mutex_t *m) +{ + opal_mutex_lock(m); +} + +static inline void opal_mutex_atomic_unlock(opal_mutex_t *m) +{ + opal_mutex_unlock(m); +} + +#endif + +#define OPAL_ABT_COND_NULL NULL +typedef ABT_cond opal_cond_t; +#define OPAL_CONDITION_STATIC_INIT OPAL_ABT_COND_NULL + +static inline void opal_cond_create(opal_cond_t *cond) { + ensure_init_argobots(); + while (*cond == OPAL_ABT_COND_NULL) { + ABT_cond new_cond; + ABT_cond_create(&new_cond); + void *null_ptr = OPAL_ABT_COND_NULL; + if (opal_atomic_compare_exchange_strong_ptr((intptr_t *)cond, + (intptr_t *)&null_ptr, + (intptr_t)new_cond)) { + /* cond is successfully created and substituted. */ + return; + } + ABT_cond_free(&new_cond); + } +} + +static inline int opal_cond_init(opal_cond_t *cond) { + *cond = OPAL_ABT_COND_NULL; + return 0; +} + +static inline int opal_cond_wait(opal_cond_t *cond, opal_mutex_t *lock) { + ensure_init_argobots(); + if (*cond == OPAL_ABT_COND_NULL) + opal_cond_create(cond); + return ABT_cond_wait(*cond, lock->m_lock_argobots); +} + +static inline int opal_cond_broadcast(opal_cond_t *cond) { + ensure_init_argobots(); + if (*cond == OPAL_ABT_COND_NULL) + opal_cond_create(cond); + return ABT_cond_broadcast(*cond); +} + +static inline int opal_cond_signal(opal_cond_t *cond) { + ensure_init_argobots(); + if (*cond == OPAL_ABT_COND_NULL) + opal_cond_create(cond); + return ABT_cond_signal(*cond); +} + +static inline int opal_cond_destroy(opal_cond_t *cond) { + ensure_init_argobots(); + if (*cond != OPAL_ABT_COND_NULL) + ABT_cond_free(cond); + return 0; +} + +END_C_DECLS + +#endif /* OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_MUTEX_H */ diff --git a/opal/mca/threads/argobots/threads_argobots_threads.h b/opal/mca/threads/argobots/threads_argobots_threads.h new file mode 100644 index 00000000000..5a7d7a772c7 --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_threads.h @@ -0,0 +1,16 @@ + +#ifndef OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_THREADS_H +#define OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_THREADS_H 1 + +#include +#include + +struct opal_thread_t { + opal_object_t super; + opal_thread_fn_t t_run; + void* t_arg; + ABT_thread t_handle; + void* t_ret; +}; + +#endif /* OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_THREADS_H */ diff --git a/opal/mca/threads/argobots/threads_argobots_tsd.h b/opal/mca/threads/argobots/threads_argobots_tsd.h new file mode 100644 index 00000000000..290adadfde3 --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_tsd.h @@ -0,0 +1,32 @@ + +#ifndef OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_TSD_H +#define OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_TSD_H 1 + +#include "opal/mca/threads/argobots/threads_argobots.h" +#include + +typedef ABT_key opal_tsd_key_t; + +static inline int +opal_tsd_key_delete(opal_tsd_key_t key) +{ + ensure_init_argobots(); + return ABT_key_free(&key); +} + +static inline int +opal_tsd_setspecific(opal_tsd_key_t key, void *value) +{ + ensure_init_argobots(); + return ABT_key_set(key, value); +} + +static inline int +opal_tsd_getspecific(opal_tsd_key_t key, void **valuep) +{ + ensure_init_argobots(); + ABT_key_get(key, valuep); + return OPAL_SUCCESS; +} + +#endif /* OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_TSD_H */ diff --git a/opal/mca/threads/argobots/threads_argobots_wait_sync.c b/opal/mca/threads/argobots/threads_argobots_wait_sync.c new file mode 100644 index 00000000000..dddb7eafbf7 --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_wait_sync.c @@ -0,0 +1,112 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2014-2016 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2016 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +#include "opal/mca/threads/argobots/threads_argobots.h" +#include "opal/mca/threads/wait_sync.h" + +static opal_mutex_t wait_sync_lock = OPAL_MUTEX_STATIC_INIT; +static ompi_wait_sync_t* wait_sync_list = NULL; + +static opal_atomic_int32_t num_thread_in_progress = 0; + +#define WAIT_SYNC_PASS_OWNERSHIP(who) \ + do { \ + ensure_init_argobots(); \ + ABT_mutex_lock((who)->lock); \ + ABT_cond_signal((who)->condition ); \ + ABT_mutex_unlock((who)->lock); \ + } while(0) + +int ompi_sync_wait_mt(ompi_wait_sync_t *sync) +{ + ensure_init_argobots(); + /* Don't stop if the waiting synchronization is completed. We avoid the + * race condition around the release of the synchronization using the + * signaling field. + */ + if(sync->count <= 0) + return (0 == sync->status) ? OPAL_SUCCESS : OPAL_ERROR; + + /* lock so nobody can signal us during the list updating */ + ABT_mutex_lock(sync->lock); + + /* Now that we hold the lock make sure another thread has not already + * call cond_signal. + */ + if(sync->count <= 0) { + ABT_mutex_unlock(sync->lock); + return (0 == sync->status) ? OPAL_SUCCESS : OPAL_ERROR; + } + + /* Insert sync on the list of pending synchronization constructs */ + OPAL_THREAD_LOCK(&wait_sync_lock); + if( NULL == wait_sync_list ) { + sync->next = sync->prev = sync; + wait_sync_list = sync; + } else { + sync->prev = wait_sync_list->prev; + sync->prev->next = sync; + sync->next = wait_sync_list; + wait_sync_list->prev = sync; + } + OPAL_THREAD_UNLOCK(&wait_sync_lock); + + /** + * If we are not responsible for progresing, go silent until something worth noticing happen: + * - this thread has been promoted to take care of the progress + * - our sync has been triggered. + */ + check_status: + if( sync != wait_sync_list && num_thread_in_progress >= opal_max_thread_in_progress) { + ABT_cond_wait(sync->condition, sync->lock); + + /** + * At this point either the sync was completed in which case + * we should remove it from the wait list, or/and I was + * promoted as the progress manager. + */ + + if( sync->count <= 0 ) { /* Completed? */ + ABT_mutex_unlock(sync->lock); + goto i_am_done; + } + /* either promoted, or spurious wakeup ! */ + goto check_status; + } + ABT_mutex_unlock(sync->lock); + + OPAL_THREAD_ADD_FETCH32(&num_thread_in_progress, 1); + while(sync->count > 0) { /* progress till completion */ + opal_progress(); /* don't progress with the sync lock locked or you'll deadlock */ + ABT_thread_yield(); + } + OPAL_THREAD_ADD_FETCH32(&num_thread_in_progress, -1); + + i_am_done: + /* My sync is now complete. Trim the list: remove self, wake next */ + OPAL_THREAD_LOCK(&wait_sync_lock); + sync->prev->next = sync->next; + sync->next->prev = sync->prev; + /* In case I am the progress manager, pass the duties on */ + if( sync == wait_sync_list ) { + wait_sync_list = (sync == sync->next) ? NULL : sync->next; + if( NULL != wait_sync_list ) + WAIT_SYNC_PASS_OWNERSHIP(wait_sync_list); + } + OPAL_THREAD_UNLOCK(&wait_sync_lock); + + return (0 == sync->status) ? OPAL_SUCCESS : OPAL_ERROR; +} diff --git a/opal/mca/threads/argobots/threads_argobots_wait_sync.h b/opal/mca/threads/argobots/threads_argobots_wait_sync.h new file mode 100644 index 00000000000..dbe443db550 --- /dev/null +++ b/opal/mca/threads/argobots/threads_argobots_wait_sync.h @@ -0,0 +1,87 @@ + +#ifndef OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_WAIT_SYNC_H +#define OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_WAIT_SYNC_H 1 + +#include "opal/mca/threads/argobots/threads_argobots.h" +#include + +typedef struct ompi_wait_sync_t { + opal_atomic_int32_t count; + int32_t status; + ABT_cond condition; + ABT_mutex lock; + struct ompi_wait_sync_t *next; + struct ompi_wait_sync_t *prev; + volatile bool signaling; +} ompi_wait_sync_t; + +#define SYNC_WAIT(sync) (opal_using_threads() ? ompi_sync_wait_mt (sync) : sync_wait_st (sync)) + +/* The loop in release handles a race condition between the signaling + * thread and the destruction of the condition variable. The signaling + * member will be set to false after the final signaling thread has + * finished operating on the sync object. This is done to avoid + * extra atomics in the signalling function and keep it as fast + * as possible. Note that the race window is small so spinning here + * is more optimal than sleeping since this macro is called in + * the critical path. */ +#define WAIT_SYNC_RELEASE(sync) \ + if (opal_using_threads()) { \ + ensure_init_argobots(); \ + while ((sync)->signaling) { \ + ABT_thread_yield(); \ + continue; \ + } \ + ABT_cond_free(&(sync)->condition); \ + ABT_mutex_free(&(sync)->lock); \ + } + +#define WAIT_SYNC_RELEASE_NOWAIT(sync) \ + if (opal_using_threads()) { \ + ensure_init_argobots(); \ + ABT_cond_free(&(sync)->condition); \ + ABT_mutex_free(&(sync)->lock); \ + } + + +#define WAIT_SYNC_SIGNAL(sync) \ + if (opal_using_threads()) { \ + ensure_init_argobots(); \ + ABT_mutex_lock(sync->lock); \ + ABT_cond_signal(sync->condition); \ + ABT_mutex_unlock(sync->lock); \ + sync->signaling = false; \ + } + +#define WAIT_SYNC_SIGNALLED(sync){ \ + (sync)->signaling = false; \ +} + +OPAL_DECLSPEC int ompi_sync_wait_mt(ompi_wait_sync_t *sync); +static inline int sync_wait_st (ompi_wait_sync_t *sync) +{ + ensure_init_argobots(); + while (sync->count > 0) { + opal_progress(); + ABT_thread_yield(); + } + + return sync->status; +} + + +#define WAIT_SYNC_INIT(sync,c) \ + do { \ + (sync)->count = (c); \ + (sync)->next = NULL; \ + (sync)->prev = NULL; \ + (sync)->status = 0; \ + (sync)->signaling = (0 != (c)); \ + if (opal_using_threads()) { \ + ensure_init_argobots(); \ + ABT_cond_create (&(sync)->condition); \ + ABT_mutex_create (&(sync)->lock); \ + } \ + } while(0) + +#endif /* OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_WAIT_SYNC_H */ diff --git a/opal/mca/threads/base/Makefile.am b/opal/mca/threads/base/Makefile.am new file mode 100644 index 00000000000..d0e6710ce01 --- /dev/null +++ b/opal/mca/threads/base/Makefile.am @@ -0,0 +1,25 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2019 Sandia National Laboratories. All rights reserved. +# +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +headers += \ + base/base.h + +libmca_threads_la_SOURCES += \ + base/threads_base_open.c diff --git a/opal/mca/threads/base/base.h b/opal/mca/threads/base/base.h new file mode 100644 index 00000000000..f407a1784c2 --- /dev/null +++ b/opal/mca/threads/base/base.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2014 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + */ + +#ifndef OPAL_THREADS_BASE_H +#define OPAL_THREADS_BASE_H + +#include "opal_config.h" +#include "opal/mca/base/mca_base_framework.h" +#include "opal/mca/threads/threads.h" + + +/* + * Global functions for MCA overall threads open and close + */ + +BEGIN_C_DECLS + +/** + * Framework structure declaration + */ +OPAL_DECLSPEC extern mca_base_framework_t opal_threads_base_framework; + +END_C_DECLS + +/* include implementation to call */ +#include MCA_threads_base_include_HEADER + +#endif /* OPAL_BASE_THREADS_H */ diff --git a/opal/mca/threads/base/owner.txt b/opal/mca/threads/base/owner.txt new file mode 100644 index 00000000000..340dd610b4f --- /dev/null +++ b/opal/mca/threads/base/owner.txt @@ -0,0 +1,7 @@ +# +# owner/status file +# owner: institution that is responsible for this package +# status: e.g. active, maintenance, unmaintained +# +owner: SNL +status: maintenance diff --git a/opal/mca/threads/base/threads_base_open.c b/opal/mca/threads/base/threads_base_open.c new file mode 100644 index 00000000000..4b497280a34 --- /dev/null +++ b/opal/mca/threads/base/threads_base_open.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2014 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "opal_config.h" + +#include "opal/constants.h" +#include "opal/mca/threads/base/base.h" + + +/* + * The following file was created by configure. It contains extern + * statements and the definition of an array of pointers to each + * component's public mca_base_component_t struct. + */ +#include "opal/mca/threads/base/static-components.h" + +static int mca_threads_base_register(mca_base_register_flag_t flags) +{ + return OPAL_SUCCESS; +} + +/* + * Globals + */ +/* Use default register/open/close functions */ +MCA_BASE_FRAMEWORK_DECLARE(opal, threads, "OPAL OS threads", mca_threads_base_register, NULL, NULL, + mca_threads_base_static_components, 0); diff --git a/opal/threads/condition.h b/opal/mca/threads/condition.h similarity index 92% rename from opal/threads/condition.h rename to opal/mca/threads/condition.h index 4c61fd64ac9..d5533a20d84 100644 --- a/opal/threads/condition.h +++ b/opal/mca/threads/condition.h @@ -13,14 +13,19 @@ * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * Copyright (c) 2019 Triad National Security, LLC. All rights + * reserved. + * + * * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ -#ifndef OPAL_CONDITION_SPINLOCK_H -#define OPAL_CONDITION_SPINLOCK_H +#ifndef OPAL_MCA_THREADS_CONDITION_H +#define OPAL_MCA_THREADS_CONDITION_H #include "opal_config.h" #ifdef HAVE_SYS_TIME_H @@ -29,7 +34,7 @@ #include #include -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/runtime/opal_progress.h" #include "opal/runtime/opal_cr.h" @@ -141,5 +146,4 @@ static inline int opal_condition_broadcast(opal_condition_t *c) END_C_DECLS -#endif - +#endif // OPAL_MCA_THREADS_CONDITION_H diff --git a/opal/mca/threads/configure.m4 b/opal/mca/threads/configure.m4 new file mode 100644 index 00000000000..b3635c4dc20 --- /dev/null +++ b/opal/mca/threads/configure.m4 @@ -0,0 +1,140 @@ +dnl -*- shell-script -*- +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 (c) 2019 Sandia National Laboratories. All rights reserved. +dnl $COPYRIGHT$ +dnl +dnl Additional copyrights may follow +dnl +dnl $HEADER$ +dnl + + +AC_DEFUN([OPAL_CONFIG_THREADS],[ +# +# Arguments: none +# +# Dependencies: None +# +# Modifies: +# none - see called tests +# +# configure threads +# + +# +# First see what kind of threads we are going to use +# + +AC_ARG_WITH([threads], + [AC_HELP_STRING([--with-threads=TYPE], + [Specify thread TYPE to use. default:pthreads. Other options are qthreads and argobots.])]) + +# +# Check we for the thread package requested, or posix +# + +thread_type_found= + +# +# check for posix threads +# +AS_IF([test -z "$with_threads" || test "$with_threads" = "pthreads" || test "$with_threads" = "yes"], + [OPAL_CONFIG_POSIX_THREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0) + AC_MSG_CHECKING([for working POSIX threads package]) + AS_IF([test "$HAVE_THREAD_PKG" = "1"], + [AC_MSG_RESULT([yes]) + thread_type_found="pthreads"], + [AC_MSG_RESULT([no])])], + []) + +# +# see if argobots is called for +# +AS_IF([test -z "$thread_type_found" && test "$with_threads" = "argobots"], + [OPAL_CONFIG_ARGOBOTS_THREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0) + AC_MSG_CHECKING([for working ARGOBOTS threads package]) + AS_IF([test "$HAVE_THREAD_PKG" = "1"], + [AC_MSG_RESULT([yes]) + thread_type_found="argobots"], + [AC_MSG_RESULT([no])])], + []) + +AS_IF([test -z "$thread_type_found" && test "$with_threads" = "qthreads"], + [OPAL_CONFIG_QTHREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0) + AC_MSG_CHECKING([for working Qthreads package]) + AS_IF([test "$HAVE_THREAD_PKG" = "1"], + [AC_MSG_RESULT([yes]) + thread_type_found="qthreads"], + [AC_MSG_RESULT([no])])], + []) + +# +# Bail if we didn't find any thread package +# + +AS_IF([test -z "$thread_type_found"], + [AC_MSG_WARN([*** no thread package $with_threads]) + AC_MSG_WARN([*** available on your system]) + AC_MSG_ERROR([*** Can not continue])]) + +THREAD_CFLAGS="$TPKG_CFLAGS" +THREAD_FCFLAGS="$TPKG_FCFLAGS" +THREAD_CXXFLAGS="$TPKG_CXXFLAGS" +THREAD_CPPFLAGS="$TPKG_CPPFLAGS" +THREAD_CXXCPPFLAGS="$TPKG_CXXCPPFLAGS" +THREAD_LDFLAGS="$TPKG_LDFLAGS" +THREAD_LIBS="$TPKG_LIBS" +HAVE_THREAD_PKG_TYPE="$thread_type_found" +export HAVE_THREAD_PKG_TYPE + +AS_IF([test "$thread_type_found" = "pthreads"], + [OPAL_CHECK_PTHREAD_PIDS],[]) + +OPAL_SUMMARY_ADD([[Miscellaneous]],[[Threading Package]],[opal_threads], [$thread_type_found]) +])dnl + +dnl we only want one :) +m4_define(MCA_opal_threads_CONFIGURE_MODE, STOP_AT_FIRST) + +AC_DEFINE_UNQUOTED([OPAL_ENABLE_MULTI_THREADS], [1], + [Whether we should enable thread support within the OPAL code base]) +AC_DEFUN([MCA_opal_threads_CONFIG],[ + thread_type=$HAVE_THREAD_PKG_TYPE + threads_base_include= + mutex_base_include= + + # first, compile all the components + MCA_CONFIGURE_FRAMEWORK($1, $2, 1) + + threads_base_include="${thread_type}/threads_${thread_type}_threads.h" + mutex_base_include="${thread_type}/threads_${thread_type}_mutex.h" + tsd_base_include="${thread_type}/threads_${thread_type}_tsd.h" + wait_sync_base_include="${thread_type}/threads_${thread_type}_wait_sync.h" + + AC_DEFINE_UNQUOTED([MCA_threads_base_include_HEADER], + ["opal/mca/threads/$threads_base_include"], + [Header to include for threads implementation]) + + AC_DEFINE_UNQUOTED([MCA_threads_mutex_base_include_HEADER], + ["opal/mca/threads/$mutex_base_include"], + [Header to include for mutex implementation]) + + AC_DEFINE_UNQUOTED([MCA_threads_tsd_base_include_HEADER], + ["opal/mca/threads/$tsd_base_include"], + [Header to include for tsd implementation]) + + AC_DEFINE_UNQUOTED([MCA_threads_wait_sync_base_include_HEADER], + ["opal/mca/threads/$wait_sync_base_include"], + [Header to include for wait_sync implementation]) +]) diff --git a/opal/threads/mutex.h b/opal/mca/threads/mutex.h similarity index 94% rename from opal/threads/mutex.h rename to opal/mca/threads/mutex.h index 694c23d988a..35a5812d20a 100644 --- a/opal/threads/mutex.h +++ b/opal/mca/threads/mutex.h @@ -15,6 +15,7 @@ * reserved. * Copyright (c) 2007 Voltaire. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. * * $COPYRIGHT$ * @@ -23,17 +24,15 @@ * $HEADER$ */ -#ifndef OPAL_MUTEX_H -#define OPAL_MUTEX_H 1 +#ifndef OPAL_MCA_THREADS_MUTEX_H +#define OPAL_MCA_THREADS_MUTEX_H 1 #include "opal_config.h" -#include "opal/threads/thread_usage.h" - BEGIN_C_DECLS /** - * @file: +* @file: * * Mutual exclusion functions. * @@ -43,9 +42,16 @@ BEGIN_C_DECLS /** * Opaque mutex object */ + typedef struct opal_mutex_t opal_mutex_t; typedef struct opal_mutex_t opal_recursive_mutex_t; +#include MCA_threads_mutex_base_include_HEADER + +OBJ_CLASS_DECLARATION(opal_mutex_t); +OBJ_CLASS_DECLARATION(opal_recursive_mutex_t); + + /** * Try to acquire a mutex. * @@ -95,11 +101,6 @@ static inline void opal_mutex_atomic_lock(opal_mutex_t *mutex); */ static inline void opal_mutex_atomic_unlock(opal_mutex_t *mutex); -END_C_DECLS - -#include "mutex_unix.h" - -BEGIN_C_DECLS /** * Lock a mutex if opal_using_threads() says that multiple threads may @@ -189,4 +190,4 @@ BEGIN_C_DECLS END_C_DECLS -#endif /* OPAL_MUTEX_H */ +#endif /* OPAL_MCA_THREADS_MUTEX_H */ diff --git a/opal/mca/threads/pthreads/Makefile.am b/opal/mca/threads/pthreads/Makefile.am new file mode 100644 index 00000000000..833950d5e17 --- /dev/null +++ b/opal/mca/threads/pthreads/Makefile.am @@ -0,0 +1,32 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2019 Sandia National Laboratories. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +noinst_LTLIBRARIES = libmca_threads_pthreads.la + +libmca_threads_pthreads_la_SOURCES = \ + threads_pthreads_component.c \ + threads_pthreads_condition.c \ + threads_pthreads_module.c \ + threads_pthreads_mutex.c \ + threads_pthreads_mutex.h \ + threads_pthreads_threads.h \ + threads_pthreads_tsd.h \ + threads_pthreads_wait_sync.c \ + threads_pthreads_wait_sync.h diff --git a/config/opal_config_pthreads.m4 b/opal/mca/threads/pthreads/configure.m4 similarity index 82% rename from config/opal_config_pthreads.m4 rename to opal/mca/threads/pthreads/configure.m4 index b2d9c7aaece..7b50a4e82fd 100644 --- a/config/opal_config_pthreads.m4 +++ b/opal/mca/threads/pthreads/configure.m4 @@ -1,28 +1,26 @@ -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) 2012 Cisco Systems, Inc. All rights reserved. -dnl Copyright (c) 2014 Intel, Inc. All rights reserved. -dnl Copyright (c) 2014-2016 Research Organization for Information Science -dnl and Technology (RIST). All rights reserved. -dnl $COPYRIGHT$ -dnl -dnl Additional copyrights may follow -dnl -dnl $HEADER$ -dnl -dnl OPAL_CONFIG_POSIX_THREADS() -dnl -dnl Configure posix threads, setting the following variables (but -dnl not calling AC_SUBST on them). +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2015 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# Copyright (c) 2019 Sandia National Laboratories. All rights reserved. +# Copyright (c) 2019 Triad National Security, LLC. All rights +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# # ******************************************************************** # @@ -281,11 +279,11 @@ if test "$opal_pthread_c_success" = "0"; then opal_pthread_c_success=0) AC_LANG_POP(C) if test "$opal_pthread_c_success" = "1"; then - PTHREAD_CFLAGS="$pf" + TPKG_CFLAGS="$pf" AC_MSG_RESULT([yes]) break else - PTHREAD_CFLAGS= + TPKG_CFLAGS= CFLAGS="$orig_CFLAGS" AC_MSG_RESULT([no]) fi @@ -307,11 +305,11 @@ if test "$opal_pthread_cxx_success" = "0"; then opal_pthread_cxx_success=0) AC_LANG_POP(C++) if test "$opal_pthread_cxx_success" = "1"; then - PTHREAD_CXXFLAGS="$pf" + TPKG_CXXFLAGS="$pf" AC_MSG_RESULT([yes]) break else - PTHREAD_CXXFLAGS= + TPKG_CXXFLAGS= CXXFLAGS="$orig_CXXFLAGS" AC_MSG_RESULT([no]) fi @@ -335,11 +333,11 @@ if test "$opal_pthread_fortran_success" = "0" && \ opal_pthread_fortran_success=0) AC_LANG_POP(C) if test "$opal_pthread_fortran_success" = "1"; then - PTHREAD_FCFLAGS="$pf" + TPKG_FCFLAGS="$pf" AC_MSG_RESULT([yes]) break else - PTHREAD_FCFLAGS= + TPKG_FCFLAGS= FCFLAGS="$orig_FCFLAGS" AC_MSG_RESULT([no]) fi @@ -406,14 +404,14 @@ if test "$opal_pthread_c_success" = "0"; then case "${host_cpu}-${host-_os}" in *-aix* | *-freebsd*) if test "`echo $CPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then - PTHREAD_CPPFLAGS="-D_THREAD_SAFE" - CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS" + TPKG_CPPFLAGS="-D_THREAD_SAFE" + CPPFLAGS="$CPPFLAGS $TPKG_CPPFLAGS" fi ;; *) if test "`echo $CPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then - PTHREAD_CPPFLAGS="-D_REENTRANT" - CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS" + TPKG_CPPFLAGS="-D_REENTRANT" + CPPFLAGS="$CPPFLAGS $TPKG_CPPFLAGS" fi ;; esac @@ -423,10 +421,10 @@ if test "$opal_pthread_c_success" = "0"; then opal_pthread_c_success=0) AC_LANG_POP(C) if test "$opal_pthread_c_success" = "1"; then - PTHREAD_LIBS="$pl" + TPKG_LIBS="$pl" AC_MSG_RESULT([yes]) else - PTHREAD_CPPFLAGS= + TPKG_CPPFLAGS= CPPFLAGS="$orig_CPPFLAGS" LIBS="$orig_LIBS" AC_MSG_RESULT([no]) @@ -441,23 +439,23 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_LIBS_CXX],[ # C++ compiler # if test "$opal_pthread_cxx_success" = "0"; then - if test ! "$opal_pthread_c_success" = "0" && test ! "$PTHREAD_LIBS" = "" ; then - AC_MSG_CHECKING([if C++ compiler and POSIX threads work with $PTHREAD_LIBS]) + if test ! "$opal_pthread_c_success" = "0" && test ! "$TPKG_LIBS" = "" ; then + AC_MSG_CHECKING([if C++ compiler and POSIX threads work with $TPKG_LIBS]) case "${host_cpu}-${host-_os}" in *-aix* | *-freebsd*) if test "`echo $CXXCPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then - PTHREAD_CXXCPPFLAGS="-D_THREAD_SAFE" - CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS" + TPKG_CXXCPPFLAGS="-D_THREAD_SAFE" + CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS" fi ;; *) if test "`echo $CXXCPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then - PTHREAD_CXXCPPFLAGS="-D_REENTRANT" - CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS" + TPKG_CXXCPPFLAGS="-D_REENTRANT" + CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS" fi ;; esac - LIBS="$orig_LIBS $PTHREAD_LIBS" + LIBS="$orig_LIBS $TPKG_LIBS" AC_LANG_PUSH(C++) OPAL_INTL_PTHREAD_TRY_LINK(opal_pthread_cxx_success=1, opal_pthread_cxx_success=0) @@ -476,14 +474,14 @@ if test "$opal_pthread_cxx_success" = "0"; then case "${host_cpu}-${host-_os}" in *-aix* | *-freebsd*) if test "`echo $CXXCPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then - PTHREAD_CXXCPPFLAGS="-D_THREAD_SAFE" - CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS" + TPKG_CXXCPPFLAGS="-D_THREAD_SAFE" + CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS" fi ;; *) if test "`echo $CXXCPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then - PTHREAD_CXXCPPFLAGS="-D_REENTRANT" - CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS" + TPKG_CXXCPPFLAGS="-D_REENTRANT" + CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS" fi ;; esac @@ -493,10 +491,10 @@ if test "$opal_pthread_cxx_success" = "0"; then opal_pthread_cxx_success=0) AC_LANG_POP(C++) if test "$opal_pthread_cxx_success" = "1"; then - PTHREAD_LIBS="$pl" + TPKG_LIBS="$pl" AC_MSG_RESULT([yes]) else - PTHREAD_CXXCPPFLAGS= + TPKG_CXXCPPFLAGS= CXXCPPFLAGS="$orig_CXXCPPFLAGS" LIBS="$orig_LIBS" AC_MSG_RESULT([no]) @@ -514,9 +512,9 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_LIBS_FC],[ if test "$opal_pthread_fortran_success" = "0" && \ test "$OMPI_TRY_FORTRAN_BINDINGS" -gt "$OMPI_FORTRAN_NO_BINDINGS" && \ test $ompi_fortran_happy -eq 1; then - if test ! "$opal_pthread_c_success" = "0" && test ! "$PTHREAD_LIBS" = "" ; then - AC_MSG_CHECKING([if Fortran compiler and POSIX threads work with $PTHREAD_LIBS]) - LIBS="$orig_LIBS $PTHREAD_LIBS" + if test ! "$opal_pthread_c_success" = "0" && test ! "$TPKG_LIBS" = "" ; then + AC_MSG_CHECKING([if Fortran compiler and POSIX threads work with $TPKG_LIBS]) + LIBS="$orig_LIBS $TPKG_LIBS" AC_LANG_PUSH(C) OPAL_INTL_PTHREAD_TRY_LINK_FORTRAN(opal_pthread_fortran_success=1, opal_pthread_fortran_success=0) @@ -537,7 +535,7 @@ if test "$opal_pthread_fortran_success" = "0" && \ opal_pthread_fortran_success=0) AC_LANG_POP(C) if test "$opal_pthread_fortran_success" = "1"; then - PTHREAD_LIBS="$pl" + TPKG_LIBS="$pl" AC_MSG_RESULT([yes]) break else @@ -600,13 +598,13 @@ orig_CXXCPPFLAGS="$CXXCPPFLAGS" orig_LDFLAGS="$LDFLAGS" orig_LIBS="$LIBS" -PTHREAD_CFLAGS= -PTHREAD_FCFLAGS= -PTHREAD_CXXFLAGS= -PTHREAD_CPPFLAGS= -PTHREAD_CXXCPPFLAGS= -PTHREAD_LDFLAGS= -PTHREAD_LIBS= +TPKG_CFLAGS= +TPKG_FCFLAGS= +TPKG_CXXFLAGS= +TPKG_CPPFLAGS= +TPKG_CXXCPPFLAGS= +TPKG_LDFLAGS= +TPKG_LIBS= # Try with the basics, mam. OPAL_INTL_POSIX_THREADS_PLAIN @@ -674,3 +672,42 @@ fi unset opal_pthread_c_success opal_pthread_fortran_success opal_pthread_cxx_success unset internal_useless ])dnl + +AC_DEFUN([MCA_opal_threads_pthreads_PRIORITY], [30]) + +AC_DEFUN([MCA_opal_threads_pthreads_COMPILE_MODE], [ + AC_MSG_CHECKING([for MCA component $2:$3 compile mode]) + $4="static" + AC_MSG_RESULT([$$4]) +]) + +AC_DEFUN([MCA_opal_threads_pthreads_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [threads_base_include="pthreads/threads_pthreads_threads.h"]) +])dnl + +AC_DEFUN([MCA_opal_mutex_pthreads_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [mutex_base_include="pthreads/threads_pthreads_mutex.h"]) + AC_MSG_CHECKING([mutex_base_include = $mutex_base_include]) +])dnl + +AC_DEFUN([MCA_opal_tsd_pthreads_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [threads_base_include="pthreads/threads_pthreads_tsd.h"]) + AC_MSG_CHECKING([threads_base_include = $threads_base_include]) +])dnl + +AC_DEFUN([MCA_opal_wait_sync_pthreads_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [wait_sync_base_include="pthreads/threads_pthreads_wait_sync.h"]) + AC_MSG_CHECKING([wait_sync_includenclude = $wait_sync_base_include]) +])dnl + +# MCA_threads_pthreads_CONFIG(action-if-can-compile, +# [action-if-cant-compile]) +# ------------------------------------------------ +AC_DEFUN([MCA_opal_threads_pthreads_CONFIG],[ + AC_CONFIG_FILES([opal/mca/threads/pthreads/Makefile]) + + AS_IF([test "$HAVE_THREAD_PKG_TYPE" = "pthreads"], + [$1], + [$2]) +]) + diff --git a/opal/mca/threads/pthreads/owner.txt b/opal/mca/threads/pthreads/owner.txt new file mode 100644 index 00000000000..199577ac8cf --- /dev/null +++ b/opal/mca/threads/pthreads/owner.txt @@ -0,0 +1,7 @@ +# +# owner/status file +# owner: institution that is responsible for this package +# status: e.g. active, maintenance, unmaintained +# +owner: SNL +status: unmaintained diff --git a/opal/mca/threads/pthreads/threads_pthreads_component.c b/opal/mca/threads/pthreads/threads_pthreads_component.c new file mode 100644 index 00000000000..85339d1381c --- /dev/null +++ b/opal/mca/threads/pthreads/threads_pthreads_component.c @@ -0,0 +1,54 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2014 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include "opal/mca/threads/thread.h" +#include "opal/mca/threads/threads.h" +#include "opal/constants.h" + +static int opal_threads_pthreads_open(void); + +const opal_threads_base_component_1_0_0_t mca_threads_pthreads_component = { + /* First, the mca_component_t struct containing meta information + about the component itself */ + .threadsc_version = { + OPAL_THREADS_BASE_VERSION_1_0_0, + + /* Component name and version */ + .mca_component_name = "pthreads", + MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, + OPAL_RELEASE_VERSION), + + .mca_open_component = opal_threads_pthreads_open, + }, + .threadsc_data = { + /* The component is checkpoint ready */ + MCA_BASE_METADATA_PARAM_CHECKPOINT + }, +}; + +int opal_threads_pthreads_open(void) +{ + return OPAL_SUCCESS; +} diff --git a/opal/mca/threads/pthreads/threads_pthreads_condition.c b/opal/mca/threads/pthreads/threads_pthreads_condition.c new file mode 100644 index 00000000000..6e7c2868569 --- /dev/null +++ b/opal/mca/threads/pthreads/threads_pthreads_condition.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include "opal/mca/threads/condition.h" + + +static void opal_condition_construct(opal_condition_t *c) +{ + c->c_waiting = 0; + c->c_signaled = 0; +} + + +static void opal_condition_destruct(opal_condition_t *c) +{ +} + +OBJ_CLASS_INSTANCE(opal_condition_t, + opal_object_t, + opal_condition_construct, + opal_condition_destruct); diff --git a/opal/threads/thread.c b/opal/mca/threads/pthreads/threads_pthreads_module.c similarity index 79% rename from opal/threads/thread.c rename to opal/mca/threads/pthreads/threads_pthreads_module.c index 2d67fa2d693..7d2ae55965a 100644 --- a/opal/threads/thread.c +++ b/opal/mca/threads/pthreads/threads_pthreads_module.c @@ -9,41 +9,30 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2015-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ +#include -#include "opal_config.h" - -#include "opal/threads/threads.h" -#include "opal/threads/tsd.h" #include "opal/constants.h" - -bool opal_debug_threads = false; - -static void opal_thread_construct(opal_thread_t *t); - -static pthread_t opal_main_thread; +#include "opal/util/sys_limits.h" +#include "opal/util/output.h" +#include "opal/prefetch.h" +#include "opal/mca/threads/threads.h" +#include "opal/mca/threads/tsd.h" struct opal_tsd_key_value { opal_tsd_key_t key; opal_tsd_destructor_t destructor; }; -static struct opal_tsd_key_value *opal_tsd_key_values = NULL; +static pthread_t opal_main_thread; +struct opal_tsd_key_value *opal_tsd_key_values = NULL; static int opal_tsd_key_values_count = 0; -OBJ_CLASS_INSTANCE(opal_thread_t, - opal_object_t, - opal_thread_construct, NULL); - - /* * Constructor */ @@ -53,50 +42,51 @@ static void opal_thread_construct(opal_thread_t *t) t->t_handle = (pthread_t) -1; } -int opal_thread_start(opal_thread_t *t) -{ - int rc; - - if (OPAL_ENABLE_DEBUG) { - if (NULL == t->t_run || t->t_handle != (pthread_t) -1) { - return OPAL_ERR_BAD_PARAM; - } - } +OBJ_CLASS_INSTANCE(opal_thread_t, + opal_object_t, + opal_thread_construct, NULL); + - rc = pthread_create(&t->t_handle, NULL, (void*(*)(void*)) t->t_run, t); - return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; +opal_thread_t *opal_thread_get_self(void) +{ + opal_thread_t *t = OBJ_NEW(opal_thread_t); + t->t_handle = pthread_self(); + return t; } - -int opal_thread_join(opal_thread_t *t, void **thr_return) +bool opal_thread_self_compare(opal_thread_t *t) { + return t->t_handle == pthread_self(); +} + +int opal_thread_join(opal_thread_t *t, void **thr_return) { int rc = pthread_join(t->t_handle, thr_return); t->t_handle = (pthread_t) -1; return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; } - -bool opal_thread_self_compare(opal_thread_t *t) -{ - return t->t_handle == pthread_self(); +void opal_thread_set_main() { + opal_main_thread = pthread_self(); } +int opal_thread_start(opal_thread_t *t) { + int rc; -opal_thread_t *opal_thread_get_self(void) -{ - opal_thread_t *t = OBJ_NEW(opal_thread_t); - t->t_handle = pthread_self(); - return t; -} + if (OPAL_ENABLE_DEBUG) { + if (NULL == t->t_run || t->t_handle != (pthread_t) -1) { + return OPAL_ERR_BAD_PARAM; + } + } -void opal_thread_kill(opal_thread_t *t, int sig) -{ - pthread_kill(t->t_handle, sig); + rc = pthread_create(&t->t_handle, NULL, (void*(*)(void*)) t->t_run, t); + + return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; } -int opal_tsd_key_create(opal_tsd_key_t *key, - opal_tsd_destructor_t destructor) +opal_class_t opal_thread_t_class; + +int opal_tsd_key_create(opal_tsd_key_t *key, opal_tsd_destructor_t destructor) { int rc; rc = pthread_key_create(key, destructor); @@ -128,6 +118,6 @@ int opal_tsd_keys_destruct() return OPAL_SUCCESS; } -void opal_thread_set_main() { - opal_main_thread = pthread_self(); +void opal_event_use_threads(void) { + evthread_use_pthreads(); } diff --git a/opal/mca/threads/pthreads/threads_pthreads_mutex.c b/opal/mca/threads/pthreads/threads_pthreads_mutex.c new file mode 100644 index 00000000000..b4e73fbd24c --- /dev/null +++ b/opal/mca/threads/pthreads/threads_pthreads_mutex.c @@ -0,0 +1,97 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include +#include + +#include "opal/mca/threads/mutex.h" + +/* + * Wait and see if some upper layer wants to use threads, if support + * exists. + */ +bool opal_uses_threads = false; + +struct opal_pthread_mutex_t { + opal_object_t super; + + pthread_mutex_t m_lock_pthread; + +#if OPAL_ENABLE_DEBUG + int m_lock_debug; + const char *m_lock_file; + int m_lock_line; +#endif + + opal_atomic_lock_t m_lock_atomic; +}; +typedef struct opal_pthread_mutex_t opal_pthread_mutex_t; +typedef struct opal_pthread_mutex_t opal_pthread_recursive_mutex_t; + +static void mca_threads_pthreads_mutex_constructor(opal_mutex_t *p_mutex) { + pthread_mutex_init(&p_mutex->m_lock_pthread, NULL); +#if OPAL_ENABLE_DEBUG + p_mutex->m_lock_debug = 0; + p_mutex->m_lock_file = NULL; + p_mutex->m_lock_line = 0; +#endif + opal_atomic_lock_init(&p_mutex->m_lock_atomic, 0); +} + +static void mca_threads_pthreads_mutex_desctructor(opal_mutex_t *p_mutex) { + pthread_mutex_destroy(&p_mutex->m_lock_pthread); +} + +static void mca_threads_pthreads_recursive_mutex_constructor + (opal_recursive_mutex_t *p_mutex) { + pthread_mutexattr_t mutex_attr; + pthread_mutexattr_init(&mutex_attr); + pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&p_mutex->m_lock_pthread, &mutex_attr); + pthread_mutexattr_destroy(&mutex_attr); +#if OPAL_ENABLE_DEBUG + p_mutex->m_lock_debug = 0; + p_mutex->m_lock_file = NULL; + p_mutex->m_lock_line = 0; +#endif + opal_atomic_lock_init(&p_mutex->m_lock_atomic, 0); +} + +static void mca_threads_pthreads_recursive_mutex_desctructor + (opal_recursive_mutex_t *p_mutex) { + pthread_mutex_destroy(&p_mutex->m_lock_pthread); +} + +OBJ_CLASS_INSTANCE(opal_mutex_t, + opal_object_t, + mca_threads_pthreads_mutex_constructor, + mca_threads_pthreads_mutex_desctructor); + +OBJ_CLASS_INSTANCE(opal_recursive_mutex_t, + opal_object_t, + mca_threads_pthreads_recursive_mutex_constructor, + mca_threads_pthreads_recursive_mutex_desctructor); diff --git a/opal/threads/mutex_unix.h b/opal/mca/threads/pthreads/threads_pthreads_mutex.h similarity index 90% rename from opal/threads/mutex_unix.h rename to opal/mca/threads/pthreads/threads_pthreads_mutex.h index 1cafdedd4e1..3f8d082c4b4 100644 --- a/opal/threads/mutex_unix.h +++ b/opal/mca/threads/pthreads/threads_pthreads_mutex.h @@ -14,6 +14,8 @@ * reserved. * Copyright (c) 2015-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * * $COPYRIGHT$ * * Additional copyrights may follow @@ -21,8 +23,8 @@ * $HEADER$ */ -#ifndef OPAL_MUTEX_UNIX_H -#define OPAL_MUTEX_UNIX_H 1 +#ifndef OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_MUTEX_H +#define OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_MUTEX_H 1 /** * @file: @@ -209,6 +211,14 @@ static inline void opal_mutex_atomic_unlock(opal_mutex_t *m) #endif +typedef pthread_cond_t opal_cond_t; +#define OPAL_CONDITION_STATIC_INIT PTHREAD_COND_INITIALIZER +#define opal_cond_init(a) pthread_cond_init(a, NULL) +#define opal_cond_wait(a,b) pthread_cond_wait(a, &(b)->m_lock_pthread) +#define opal_cond_broadcast(a) pthread_cond_broadcast(a) +#define opal_cond_signal(a) pthread_cond_signal(a) +#define opal_cond_destroy(a) pthread_cond_destroy(a) + END_C_DECLS -#endif /* OPAL_MUTEX_UNIX_H */ +#endif /* OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_MUTEX_H */ diff --git a/opal/mca/threads/pthreads/threads_pthreads_threads.h b/opal/mca/threads/pthreads/threads_pthreads_threads.h new file mode 100644 index 00000000000..ed0166e4dab --- /dev/null +++ b/opal/mca/threads/pthreads/threads_pthreads_threads.h @@ -0,0 +1,15 @@ + +#ifndef OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_THREADS_H +#define OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_THREADS_H 1 + +#include +#include + +struct opal_thread_t { + opal_object_t super; + opal_thread_fn_t t_run; + void* t_arg; + pthread_t t_handle; +}; + +#endif /* OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_THREADS_H */ diff --git a/opal/mca/threads/pthreads/threads_pthreads_tsd.h b/opal/mca/threads/pthreads/threads_pthreads_tsd.h new file mode 100644 index 00000000000..f3696f7df3d --- /dev/null +++ b/opal/mca/threads/pthreads/threads_pthreads_tsd.h @@ -0,0 +1,29 @@ + +#ifndef OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_TSD_H +#define OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_TSD_H 1 + +#include +#include + +typedef pthread_key_t opal_tsd_key_t; + +static inline int +opal_tsd_key_delete(opal_tsd_key_t key) +{ + return pthread_key_delete(key); +} + +static inline int +opal_tsd_setspecific(opal_tsd_key_t key, void *value) +{ + return pthread_setspecific(key, value); +} + +static inline int +opal_tsd_getspecific(opal_tsd_key_t key, void **valuep) +{ + *valuep = pthread_getspecific(key); + return OPAL_SUCCESS; +} + +#endif /* OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_TSD_H */ diff --git a/opal/threads/wait_sync.c b/opal/mca/threads/pthreads/threads_pthreads_wait_sync.c similarity index 96% rename from opal/threads/wait_sync.c rename to opal/mca/threads/pthreads/threads_pthreads_wait_sync.c index 1f73f7c8ad4..21a8943c5d7 100644 --- a/opal/threads/wait_sync.c +++ b/opal/mca/threads/pthreads/threads_pthreads_wait_sync.c @@ -6,13 +6,15 @@ * Copyright (c) 2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ -#include "wait_sync.h" +#include "opal/mca/threads/wait_sync.h" static opal_mutex_t wait_sync_lock = OPAL_MUTEX_STATIC_INIT; static ompi_wait_sync_t* wait_sync_list = NULL; diff --git a/opal/threads/wait_sync.h b/opal/mca/threads/pthreads/threads_pthreads_wait_sync.h similarity index 62% rename from opal/threads/wait_sync.h rename to opal/mca/threads/pthreads/threads_pthreads_wait_sync.h index 3e6c8f1949f..0b43a51fd62 100644 --- a/opal/threads/wait_sync.h +++ b/opal/mca/threads/pthreads/threads_pthreads_wait_sync.h @@ -1,31 +1,6 @@ -/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2014-2016 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. - * Copyright (c) 2016 Los Alamos National Security, LLC. All rights - * reserved. - * Copyright (c) 2016 Mellanox Technologies. All rights reserved. - * Copyright (c) 2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2017 IBM Corporation. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -#if !defined(OPAL_THREADS_WAIT_SYNC_H) -#define OPAL_THREADS_WAIT_SYNC_H - -#include "opal/sys/atomic.h" -#include "opal/threads/condition.h" -#include - -BEGIN_C_DECLS - -extern int opal_max_thread_in_progress; +#ifndef OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_WAIT_SYNC_H +#define OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_WAIT_SYNC_H 1 typedef struct ompi_wait_sync_t { opal_atomic_int32_t count; @@ -37,9 +12,6 @@ typedef struct ompi_wait_sync_t { volatile bool signaling; } ompi_wait_sync_t; -#define REQUEST_PENDING (void*)0L -#define REQUEST_COMPLETED (void*)1L - #define SYNC_WAIT(sync) (opal_using_threads() ? ompi_sync_wait_mt (sync) : sync_wait_st (sync)) /* The loop in release handles a race condition between the signaling @@ -102,27 +74,4 @@ static inline int sync_wait_st (ompi_wait_sync_t *sync) } \ } while(0) -/** - * Update the status of the synchronization primitive. If an error is - * reported the synchronization is completed and the signal - * triggered. The status of the synchronization will be reported to - * the waiting threads. - */ -static inline void wait_sync_update(ompi_wait_sync_t *sync, int updates, int status) -{ - if( OPAL_LIKELY(OPAL_SUCCESS == status) ) { - if( 0 != (OPAL_THREAD_ADD_FETCH32(&sync->count, -updates)) ) { - return; - } - } else { - /* this is an error path so just use the atomic */ - sync->status = OPAL_ERROR; - opal_atomic_wmb (); - opal_atomic_swap_32 (&sync->count, 0); - } - WAIT_SYNC_SIGNAL(sync); -} - -END_C_DECLS - -#endif /* defined(OPAL_THREADS_WAIT_SYNC_H) */ +#endif /* OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_WAIT_SYNC_H */ diff --git a/opal/mca/threads/qthreads/Makefile.am b/opal/mca/threads/qthreads/Makefile.am new file mode 100644 index 00000000000..9412c63e53c --- /dev/null +++ b/opal/mca/threads/qthreads/Makefile.am @@ -0,0 +1,26 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +noinst_LTLIBRARIES = libmca_threads_qthreads.la + +libmca_threads_qthreads_la_SOURCES = \ + threads_qthreads_component.c \ + threads_qthreads_mutex.c \ + threads_qthreads_condition.c \ + threads_qthreads_module.c diff --git a/opal/mca/threads/qthreads/configure.m4 b/opal/mca/threads/qthreads/configure.m4 new file mode 100644 index 00000000000..4c060111d7a --- /dev/null +++ b/opal/mca/threads/qthreads/configure.m4 @@ -0,0 +1,62 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2015 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +#******************************************************************** +# +# TODO: undoubtedly need some better check than this +# +#******************************************************************** +AC_DEFUN([OPAL_CONFIG_QTHREADS],[ + + AC_CHECK_HEADERS([mach/mach_time.h], + [AC_CHECK_FUNC([mach_absolute_time], + [threads_qthreads_happy="yes"], + [threads_qthreads_happy="no"])], + [threads_qthreads_happy="no"]) + + AS_IF([test "$threads_qthreads_happy" = "yes"], + [$1], + [$2]) +])dnl + +AC_DEFUN([MCA_opal_threads_qthreads_PRIORITY], [30]) + +AC_DEFUN([MCA_opal_threads_qthreads_COMPILE_MODE], [ + AC_MSG_CHECKING([for MCA component $2:$3 compile mode]) + $4="static" + AC_MSG_RESULT([$$4]) +]) + +AC_DEFUN([MCA_opal_threads_qthreads_POST_CONFIG],[ + AS_IF([test "$1" = "1"], [threads_base_include="qthreads/threads_qthreads.h"]) +])dnl + +# MCA_threads_qthreads_CONFIG(action-if-can-compile, +# [action-if-cant-compile]) +# ------------------------------------------------ +AC_DEFUN([MCA_opal_threads_qthreads_CONFIG],[ + AC_CONFIG_FILES([opal/mca/threads/qthreads/Makefile]) + + AS_IF([test "$HAVE_THREAD_PKG_TYPE" = "qthreads"], + [$1], + [$2]) +]) diff --git a/opal/mca/threads/qthreads/owner.txt b/opal/mca/threads/qthreads/owner.txt new file mode 100644 index 00000000000..199577ac8cf --- /dev/null +++ b/opal/mca/threads/qthreads/owner.txt @@ -0,0 +1,7 @@ +# +# owner/status file +# owner: institution that is responsible for this package +# status: e.g. active, maintenance, unmaintained +# +owner: SNL +status: unmaintained diff --git a/opal/mca/threads/qthreads/threads_qthreads_component.c b/opal/mca/threads/qthreads/threads_qthreads_component.c new file mode 100644 index 00000000000..72009c2c4c4 --- /dev/null +++ b/opal/mca/threads/qthreads/threads_qthreads_component.c @@ -0,0 +1,52 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2014 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" + +#include "opal/mca/threads/thread.h" +#include "opal/mca/threads/threads.h" +#include "opal/constants.h" + +static int opal_threads_qthreads_open(void); + +const opal_threads_base_component_1_0_0_t mca_threads_qthreads_component = { + /* First, the mca_component_t struct containing meta information + about the component itself */ + .threadsc_version = { + OPAL_THREADS_BASE_VERSION_1_0_0, + + /* Component name and version */ + .mca_component_name = "qthreads", + MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, + OPAL_RELEASE_VERSION), + + .mca_open_component = opal_threads_qthreads_open, + }, + .threadsc_data = { + /* The component is checkpoint ready */ + MCA_BASE_METADATA_PARAM_CHECKPOINT + }, +}; + +int opal_threads_qthreads_open(void) +{ + return OPAL_SUCCESS; +} diff --git a/opal/threads/condition.c b/opal/mca/threads/qthreads/threads_qthreads_condition.c similarity index 96% rename from opal/threads/condition.c rename to opal/mca/threads/qthreads/threads_qthreads_condition.c index 7745d316544..bdc8a67f214 100644 --- a/opal/threads/condition.c +++ b/opal/mca/threads/qthreads/threads_qthreads_condition.c @@ -18,7 +18,7 @@ #include "opal_config.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/condition.h" static void opal_condition_construct(opal_condition_t *c) diff --git a/opal/mca/threads/qthreads/threads_qthreads_module.c b/opal/mca/threads/qthreads/threads_qthreads_module.c new file mode 100644 index 00000000000..393948c2ef3 --- /dev/null +++ b/opal/mca/threads/qthreads/threads_qthreads_module.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +#include + +#include "opal/constants.h" +#include "opal/util/sys_limits.h" +#include "opal/util/output.h" +#include "opal/prefetch.h" +#include "opal/mca/threads/threads.h" +#include "opal/mca/threads/tsd.h" + +struct opal_tsd_key_value { + opal_tsd_key_t key; + opal_tsd_destructor_t destructor; +}; + +static pthread_t opal_main_thread; +struct opal_tsd_key_value *opal_tsd_key_values = NULL; +static int opal_tsd_key_values_count = 0; + +/* + * Constructor + */ +static void opal_thread_construct(opal_thread_t *t) +{ + t->t_run = 0; + t->t_handle = (pthread_t) -1; +} + +OBJ_CLASS_INSTANCE(opal_thread_t, + opal_object_t, + opal_thread_construct, NULL); + + +opal_thread_t *opal_thread_get_self(void) +{ + opal_thread_t *t = OBJ_NEW(opal_thread_t); + t->t_handle = pthread_self(); + return t; +} + +bool opal_thread_self_compare(opal_thread_t *t) +{ + return t->t_handle == pthread_self(); +} + +int sync_wait_mt(void *p) { + return 0; +} + +int opal_thread_join(opal_thread_t *t, void **thr_return) { + int rc = pthread_join(t->t_handle, thr_return); + t->t_handle = (pthread_t) -1; + return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; +} + +void opal_thread_set_main() { + opal_main_thread = pthread_self(); +} + +int opal_thread_start(opal_thread_t *t) { + int rc; + + if (OPAL_ENABLE_DEBUG) { + if (NULL == t->t_run || t->t_handle != (pthread_t) -1) { + return OPAL_ERR_BAD_PARAM; + } + } + + rc = pthread_create(&t->t_handle, NULL, (void*(*)(void*)) t->t_run, t); + + return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; +} + +opal_class_t opal_thread_t_class; + +int opal_tsd_key_create(opal_tsd_key_t *key, opal_tsd_destructor_t destructor) +{ + int rc; + rc = pthread_key_create(key, destructor); + if ((0 == rc) && (pthread_self() == opal_main_thread)) { + opal_tsd_key_values = (struct opal_tsd_key_value *)realloc(opal_tsd_key_values, (opal_tsd_key_values_count+1) * sizeof(struct opal_tsd_key_value)); + opal_tsd_key_values[opal_tsd_key_values_count].key = *key; + opal_tsd_key_values[opal_tsd_key_values_count].destructor = destructor; + opal_tsd_key_values_count ++; + } + return rc; +} + +int opal_tsd_keys_destruct() +{ + int i; + void * ptr; + for (i=0; i -#include - #include "opal/class/opal_object.h" #if OPAL_ENABLE_DEBUG #include "opal/util/output.h" @@ -43,15 +41,12 @@ typedef void *(*opal_thread_fn_t) (opal_object_t *); #define OPAL_THREAD_CANCELLED ((void*)1); -struct opal_thread_t { - opal_object_t super; - opal_thread_fn_t t_run; - void* t_arg; - pthread_t t_handle; -}; +#include MCA_threads_base_include_HEADER typedef struct opal_thread_t opal_thread_t; +OBJ_CLASS_DECLARATION(opal_thread_t); + #if OPAL_ENABLE_DEBUG OPAL_DECLSPEC extern bool opal_debug_threads; #endif @@ -135,7 +130,8 @@ OPAL_DECLSPEC bool opal_thread_self_compare(opal_thread_t*); OPAL_DECLSPEC opal_thread_t *opal_thread_get_self(void); OPAL_DECLSPEC void opal_thread_kill(opal_thread_t *, int sig); OPAL_DECLSPEC void opal_thread_set_main(void); +OPAL_DECLSPEC void opal_event_use_threads(void); END_C_DECLS -#endif /* OPAL_THREAD_H */ +#endif /* OPAL_MCA_THREAD_H */ diff --git a/opal/threads/tsd.h b/opal/mca/threads/tsd.h similarity index 90% rename from opal/threads/tsd.h rename to opal/mca/threads/tsd.h index e49c08dd96e..83950da1913 100644 --- a/opal/threads/tsd.h +++ b/opal/mca/threads/tsd.h @@ -4,6 +4,8 @@ * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * * $COPYRIGHT$ * * Additional copyrights may follow @@ -12,8 +14,8 @@ */ -#ifndef OPAL_THREADS_TSD_H -#define OPAL_THREADS_TSD_H +#ifndef OPAL_MCA_THREADS_TSD_H +#define OPAL_MCA_THREADS_TSD_H #include "opal_config.h" @@ -106,26 +108,7 @@ OPAL_DECLSPEC int opal_tsd_getspecific(opal_tsd_key_t key, void **valuep); #else -typedef pthread_key_t opal_tsd_key_t; - -static inline int -opal_tsd_key_delete(opal_tsd_key_t key) -{ - return pthread_key_delete(key); -} - -static inline int -opal_tsd_setspecific(opal_tsd_key_t key, void *value) -{ - return pthread_setspecific(key, value); -} - -static inline int -opal_tsd_getspecific(opal_tsd_key_t key, void **valuep) -{ - *valuep = pthread_getspecific(key); - return OPAL_SUCCESS; -} +#include MCA_threads_tsd_base_include_HEADER #endif @@ -175,4 +158,4 @@ OPAL_DECLSPEC int opal_tsd_keys_destruct(void); END_C_DECLS -#endif /* OPAL_MTHREADS_TSD_H */ +#endif /* OPAL_MCA_THREADS_TSD_H */ diff --git a/opal/mca/threads/wait_sync.h b/opal/mca/threads/wait_sync.h new file mode 100644 index 00000000000..0b5f421c75f --- /dev/null +++ b/opal/mca/threads/wait_sync.h @@ -0,0 +1,58 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2014-2016 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2016 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2016 Mellanox Technologies. All rights reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Sandia National Laboratories. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#if !defined(OPAL_MCA_THREADS_WAIT_SYNC_H) +#define OPAL_MCA_THREADS_WAIT_SYNC_H + +#include "opal/sys/atomic.h" +#include "opal/mca/threads/condition.h" + +BEGIN_C_DECLS + +extern int opal_max_thread_in_progress; + +#include MCA_threads_wait_sync_base_include_HEADER + +#define REQUEST_PENDING (void*)0L +#define REQUEST_COMPLETED (void*)1L + +/** + * Update the status of the synchronization primitive. If an error is + * reported the synchronization is completed and the signal + * triggered. The status of the synchronization will be reported to + * the waiting threads. + */ +static inline void wait_sync_update(ompi_wait_sync_t *sync, int updates, int status) +{ + if( OPAL_LIKELY(OPAL_SUCCESS == status) ) { + if( 0 != (OPAL_THREAD_ADD_FETCH32(&sync->count, -updates)) ) { + return; + } + } else { + /* this is an error path so just use the atomic */ + sync->status = OPAL_ERROR; + opal_atomic_wmb (); + opal_atomic_swap_32 (&sync->count, 0); + } + WAIT_SYNC_SIGNAL(sync); +} + +END_C_DECLS + +#endif /* defined(OPAL_MCA_THREADS_WAIT_SYNC_H) */ diff --git a/opal/mca/timer/linux/timer_linux_component.c b/opal/mca/timer/linux/timer_linux_component.c index c5b664afbeb..0eb03baac04 100644 --- a/opal/mca/timer/linux/timer_linux_component.c +++ b/opal/mca/timer/linux/timer_linux_component.c @@ -26,6 +26,7 @@ #include "opal_config.h" #include +#include #include "opal/mca/timer/timer.h" #include "opal/mca/timer/base/base.h" diff --git a/opal/runtime/opal_cr.c b/opal/runtime/opal_cr.c index 11f938edd98..33b94434b8e 100644 --- a/opal/runtime/opal_cr.c +++ b/opal/runtime/opal_cr.c @@ -69,8 +69,8 @@ #include "opal/mca/memory/base/base.h" #include "opal/mca/timer/base/base.h" -#include "opal/threads/mutex.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/threads.h" #include "opal/mca/crs/base/base.h" /****************** diff --git a/opal/runtime/opal_finalize.c b/opal/runtime/opal_finalize.c index 7c7e37c310a..33138b453a6 100644 --- a/opal/runtime/opal_finalize.c +++ b/opal/runtime/opal_finalize.c @@ -39,7 +39,7 @@ #include "opal/memoryhooks/memory.h" #include "opal/runtime/opal.h" #include "opal/constants.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "opal/runtime/opal_cr.h" #include "opal/runtime/opal_progress.h" diff --git a/opal/runtime/opal_init.c b/opal/runtime/opal_init.c index 2db5b441165..da93168d676 100644 --- a/opal/runtime/opal_init.c +++ b/opal/runtime/opal_init.c @@ -62,14 +62,15 @@ #include "opal/dss/dss.h" #include "opal/mca/shmem/base/base.h" #include "opal/mca/compress/base/base.h" -#include "opal/threads/threads.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/threads.h" +#include "opal/mca/threads/tsd.h" #include "opal/runtime/opal_cr.h" #include "opal/mca/crs/base/base.h" #include "opal/runtime/opal_progress.h" #include "opal/mca/event/base/base.h" +#include "opal/mca/threads/base/base.h" #include "opal/mca/backtrace/base/base.h" #include "opal/constants.h" @@ -520,7 +521,7 @@ opal_init_util(int* pargc, char*** pargv) * versions of memcpy correctly configured. */ static mca_base_framework_t *opal_init_frameworks[] = { - &opal_hwloc_base_framework, &opal_memcpy_base_framework, &opal_memchecker_base_framework, + &opal_hwloc_base_framework, &opal_memcpy_base_framework, &opal_threads_base_framework, &opal_memchecker_base_framework, &opal_backtrace_base_framework, &opal_timer_base_framework, &opal_event_base_framework, &opal_shmem_base_framework, &opal_reachable_base_framework, &opal_compress_base_framework, NULL, diff --git a/opal/runtime/opal_params.c b/opal/runtime/opal_params.c index 2897b64737f..f6c9faf5d17 100644 --- a/opal/runtime/opal_params.c +++ b/opal/runtime/opal_params.c @@ -39,8 +39,8 @@ #include "opal/runtime/opal.h" #include "opal/datatype/opal_datatype.h" #include "opal/mca/base/mca_base_var.h" -#include "opal/threads/mutex.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/threads.h" #include "opal/mca/shmem/base/base.h" #include "opal/mca/base/mca_base_var.h" #include "opal/runtime/opal_params.h" @@ -61,6 +61,10 @@ char *opal_timing_output = NULL; bool opal_timing_overhead = true; #endif +#if OPAL_ENABLE_DEBUG +bool opal_debug_threads; +#endif + bool opal_built_with_cuda_support = OPAL_INT_TO_BOOL(OPAL_CUDA_SUPPORT); bool opal_cuda_support = false; bool opal_warn_on_missing_libcuda = true; diff --git a/opal/runtime/opal_progress.h b/opal/runtime/opal_progress.h index 1d25905569d..13bb9ead954 100644 --- a/opal/runtime/opal_progress.h +++ b/opal/runtime/opal_progress.h @@ -33,7 +33,7 @@ BEGIN_C_DECLS #include "opal_config.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/runtime/opal.h" /** diff --git a/opal/runtime/opal_progress_threads.c b/opal/runtime/opal_progress_threads.c index 4c53fa35b67..a675405dc53 100644 --- a/opal/runtime/opal_progress_threads.c +++ b/opal/runtime/opal_progress_threads.c @@ -17,7 +17,7 @@ #include "opal/class/opal_list.h" #include "opal/mca/event/event.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/error.h" #include "opal/util/fd.h" diff --git a/opal/threads/Makefile.am b/opal/threads/Makefile.am deleted file mode 100644 index a4a084038ca..00000000000 --- a/opal/threads/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# -*- makefile -*- -# -# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana -# University Research and Technology -# Corporation. All rights reserved. -# Copyright (c) 2004-2016 The University of Tennessee and The University -# of Tennessee Research Foundation. All rights -# reserved. -# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, -# University of Stuttgart. All rights reserved. -# Copyright (c) 2004-2005 The Regents of the University of California. -# All rights reserved. -# Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. -# Copyright (c) 2015 Research Organization for Information Science -# and Technology (RIST). All rights reserved. -# $COPYRIGHT$ -# -# Additional copyrights may follow -# -# $HEADER$ -# - -# This makefile.am does not stand on its own - it is included from opal/Makefile.am - -# Source code files -headers += \ - threads/condition.h \ - threads/mutex.h \ - threads/mutex_unix.h \ - threads/threads.h \ - threads/tsd.h \ - threads/wait_sync.h \ - threads/thread_usage.h - -lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \ - threads/condition.c \ - threads/mutex.c \ - threads/thread.c \ - threads/wait_sync.c diff --git a/opal/util/cmd_line.c b/opal/util/cmd_line.c index f17263ac3c0..2da39dd3cc1 100644 --- a/opal/util/cmd_line.c +++ b/opal/util/cmd_line.c @@ -32,7 +32,7 @@ #include "opal/class/opal_object.h" #include "opal/class/opal_list.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/util/argv.h" #include "opal/util/cmd_line.h" #include "opal/util/output.h" diff --git a/opal/util/cmd_line.h b/opal/util/cmd_line.h index 546e49200b9..9c49bc25360 100644 --- a/opal/util/cmd_line.h +++ b/opal/util/cmd_line.h @@ -120,7 +120,7 @@ #include "opal/class/opal_object.h" #include "opal/class/opal_list.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" BEGIN_C_DECLS /** diff --git a/opal/util/info.h b/opal/util/info.h index 8f8cc686686..bbab7c35ab9 100644 --- a/opal/util/info.h +++ b/opal/util/info.h @@ -29,7 +29,7 @@ #include "opal/class/opal_list.h" #include "opal/class/opal_pointer_array.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/mca/base/mca_base_var_enum.h" /** diff --git a/opal/util/info_subscriber.h b/opal/util/info_subscriber.h index c676ab0338e..c7ce58f95d7 100644 --- a/opal/util/info_subscriber.h +++ b/opal/util/info_subscriber.h @@ -30,7 +30,7 @@ #include "opal/class/opal_list.h" #include "opal/class/opal_pointer_array.h" #include "opal/class/opal_hash_table.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/util/info.h" #include "opal/mca/base/mca_base_var_enum.h" diff --git a/opal/util/keyval_parse.c b/opal/util/keyval_parse.c index 212773f0e43..fe947131b63 100644 --- a/opal/util/keyval_parse.c +++ b/opal/util/keyval_parse.c @@ -29,7 +29,7 @@ #include "opal/util/keyval/keyval_lex.h" #include "opal/util/output.h" #include "opal/util/string_copy.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include #include diff --git a/opal/util/net.c b/opal/util/net.c index 2ec734aee0b..3f14d524b89 100644 --- a/opal/util/net.c +++ b/opal/util/net.c @@ -69,7 +69,7 @@ #include "opal/util/argv.h" #include "opal/util/show_help.h" #include "opal/constants.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "opal/runtime/opal_params.h" /* this function doesn't depend on sockaddr_h */ diff --git a/opal/util/output.c b/opal/util/output.c index 46638674045..69a85bf9ee3 100644 --- a/opal/util/output.c +++ b/opal/util/output.c @@ -48,7 +48,7 @@ #include "opal/util/output.h" #include "opal/util/string_copy.h" #include "opal/util/printf.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/constants.h" #include "opal/mca/pmix/pmix.h" diff --git a/orte/mca/plm/base/plm_base_receive.c b/orte/mca/plm/base/plm_base_receive.c index c95f203bc78..b1553a61fe2 100644 --- a/orte/mca/plm/base/plm_base_receive.c +++ b/orte/mca/plm/base/plm_base_receive.c @@ -37,7 +37,7 @@ #include "orte/mca/mca.h" #include "opal/dss/dss.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/opal_environ.h" diff --git a/orte/mca/plm/rsh/plm_rsh.h b/orte/mca/plm/rsh/plm_rsh.h index 7cad6d1221f..315bc40469f 100644 --- a/orte/mca/plm/rsh/plm_rsh.h +++ b/orte/mca/plm/rsh/plm_rsh.h @@ -35,7 +35,7 @@ #endif #include -#include "opal/threads/condition.h" +#include "opal/mca/threads/condition.h" #include "orte/mca/mca.h" #include "orte/mca/plm/plm.h" diff --git a/orte/mca/rmaps/base/rmaps_base_binding.c b/orte/mca/rmaps/base/rmaps_base_binding.c index 0715a1fe2d8..773aee5ef74 100644 --- a/orte/mca/rmaps/base/rmaps_base_binding.c +++ b/orte/mca/rmaps/base/rmaps_base_binding.c @@ -37,7 +37,7 @@ #include "orte/mca/mca.h" #include "opal/mca/base/base.h" #include "opal/mca/hwloc/base/base.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "orte/types.h" #include "orte/util/show_help.h" diff --git a/orte/mca/rmaps/base/rmaps_base_print_fns.c b/orte/mca/rmaps/base/rmaps_base_print_fns.c index 7899ebe342f..cc077e49e04 100644 --- a/orte/mca/rmaps/base/rmaps_base_print_fns.c +++ b/orte/mca/rmaps/base/rmaps_base_print_fns.c @@ -32,7 +32,7 @@ #include "orte/mca/mca.h" #include "opal/mca/base/base.h" #include "opal/mca/hwloc/base/base.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "orte/types.h" #include "orte/util/show_help.h" diff --git a/orte/mca/rmaps/base/rmaps_base_ranking.c b/orte/mca/rmaps/base/rmaps_base_ranking.c index e4f67d9f4d5..c80f81925d7 100644 --- a/orte/mca/rmaps/base/rmaps_base_ranking.c +++ b/orte/mca/rmaps/base/rmaps_base_ranking.c @@ -35,7 +35,7 @@ #include "orte/mca/mca.h" #include "opal/mca/base/base.h" #include "opal/mca/hwloc/base/base.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "orte/types.h" #include "orte/util/show_help.h" diff --git a/orte/mca/rmaps/base/rmaps_base_support_fns.c b/orte/mca/rmaps/base/rmaps_base_support_fns.c index 31cc85507e6..cd367799458 100644 --- a/orte/mca/rmaps/base/rmaps_base_support_fns.c +++ b/orte/mca/rmaps/base/rmaps_base_support_fns.c @@ -36,7 +36,7 @@ #include "orte/mca/mca.h" #include "opal/mca/base/base.h" #include "opal/mca/hwloc/base/base.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "orte/types.h" #include "orte/util/show_help.h" diff --git a/orte/mca/sstore/central/sstore_central_app.c b/orte/mca/sstore/central/sstore_central_app.c index 8ab1244bdc5..c1388141032 100644 --- a/orte/mca/sstore/central/sstore_central_app.c +++ b/orte/mca/sstore/central/sstore_central_app.c @@ -38,8 +38,8 @@ #include "opal/util/basename.h" #include "opal/util/os_dirpath.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" diff --git a/orte/mca/sstore/central/sstore_central_global.c b/orte/mca/sstore/central/sstore_central_global.c index aa361860a3b..f2a6a8bc920 100644 --- a/orte/mca/sstore/central/sstore_central_global.c +++ b/orte/mca/sstore/central/sstore_central_global.c @@ -40,8 +40,8 @@ #include "opal/util/basename.h" #include "opal/util/os_dirpath.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" diff --git a/orte/mca/sstore/central/sstore_central_local.c b/orte/mca/sstore/central/sstore_central_local.c index 0ed0f9d2b46..c60a4398f65 100644 --- a/orte/mca/sstore/central/sstore_central_local.c +++ b/orte/mca/sstore/central/sstore_central_local.c @@ -39,8 +39,8 @@ #include "opal/util/opal_environ.h" #include "opal/util/basename.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" diff --git a/orte/mca/sstore/central/sstore_central_module.c b/orte/mca/sstore/central/sstore_central_module.c index 7c02196632f..e3f2d3e8f4c 100644 --- a/orte/mca/sstore/central/sstore_central_module.c +++ b/orte/mca/sstore/central/sstore_central_module.c @@ -35,8 +35,8 @@ #include "opal/util/opal_environ.h" #include "opal/util/basename.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" diff --git a/orte/mca/sstore/stage/sstore_stage_app.c b/orte/mca/sstore/stage/sstore_stage_app.c index ce5ea401530..7ba3f257177 100644 --- a/orte/mca/sstore/stage/sstore_stage_app.c +++ b/orte/mca/sstore/stage/sstore_stage_app.c @@ -38,8 +38,8 @@ #include "opal/util/basename.h" #include "opal/util/os_dirpath.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" diff --git a/orte/mca/sstore/stage/sstore_stage_global.c b/orte/mca/sstore/stage/sstore_stage_global.c index 8379b4e9a57..a38127738a9 100644 --- a/orte/mca/sstore/stage/sstore_stage_global.c +++ b/orte/mca/sstore/stage/sstore_stage_global.c @@ -41,8 +41,8 @@ #include "opal/util/os_dirpath.h" #include "opal/util/opal_getcwd.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "orte/util/show_help.h" #include "orte/util/name_fns.h" diff --git a/orte/mca/sstore/stage/sstore_stage_local.c b/orte/mca/sstore/stage/sstore_stage_local.c index c93943e3d69..998386c6597 100644 --- a/orte/mca/sstore/stage/sstore_stage_local.c +++ b/orte/mca/sstore/stage/sstore_stage_local.c @@ -45,8 +45,8 @@ #include "opal/mca/compress/compress.h" #include "opal/mca/compress/base/base.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" diff --git a/orte/mca/sstore/stage/sstore_stage_module.c b/orte/mca/sstore/stage/sstore_stage_module.c index 7a03e88b093..c69182bba27 100644 --- a/orte/mca/sstore/stage/sstore_stage_module.c +++ b/orte/mca/sstore/stage/sstore_stage_module.c @@ -35,8 +35,8 @@ #include "opal/util/opal_environ.h" #include "opal/util/basename.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "orte/util/name_fns.h" #include "orte/util/proc_info.h" diff --git a/orte/runtime/orte_globals.c b/orte/runtime/orte_globals.c index abd2bfb3862..ebac4081461 100644 --- a/orte/runtime/orte_globals.c +++ b/orte/runtime/orte_globals.c @@ -40,7 +40,7 @@ #include "opal/class/opal_pointer_array.h" #include "opal/class/opal_value_array.h" #include "opal/dss/dss.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "orte/mca/errmgr/errmgr.h" #include "orte/mca/rml/rml.h" diff --git a/orte/runtime/orte_globals.h b/orte/runtime/orte_globals.h index 9abe705a47d..687b32bebae 100644 --- a/orte/runtime/orte_globals.h +++ b/orte/runtime/orte_globals.h @@ -44,7 +44,7 @@ #include "opal/class/opal_pointer_array.h" #include "opal/class/opal_value_array.h" #include "opal/class/opal_ring_buffer.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/mca/event/event.h" #include "opal/mca/hwloc/hwloc-internal.h" #include "opal/mca/hwloc/base/base.h" diff --git a/orte/runtime/orte_init.c b/orte/runtime/orte_init.c index a14891cc9ae..2c4b6fb7e6e 100644 --- a/orte/runtime/orte_init.c +++ b/orte/runtime/orte_init.c @@ -40,7 +40,7 @@ #include "opal/util/proc.h" #include "opal/util/timings.h" #include "opal/runtime/opal.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "orte/util/show_help.h" #include "orte/mca/ess/base/base.h" diff --git a/orte/runtime/orte_wait.c b/orte/runtime/orte_wait.c index bed373d615c..be5163ef4c0 100644 --- a/orte/runtime/orte_wait.c +++ b/orte/runtime/orte_wait.c @@ -53,8 +53,8 @@ #include "opal/util/output.h" #include "opal/class/opal_list.h" #include "opal/mca/event/event.h" -#include "opal/threads/mutex.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/mutex.h" +#include "opal/mca/threads/condition.h" #include "opal/sys/atomic.h" #include "orte/constants.h" diff --git a/orte/test/system/event-threads.c b/orte/test/system/event-threads.c index cdd012d1a78..fd6ed9fc3fd 100644 --- a/orte/test/system/event-threads.c +++ b/orte/test/system/event-threads.c @@ -11,7 +11,7 @@ #include #include "opal/util/fd.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/runtime/opal.h" #include "opal/mca/event/event.h" diff --git a/orte/test/system/evthread-test.c b/orte/test/system/evthread-test.c index 58c464679d7..c85c7c4c35b 100644 --- a/orte/test/system/evthread-test.c +++ b/orte/test/system/evthread-test.c @@ -11,7 +11,7 @@ #endif #include -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/runtime/opal.h" #include "opal/mca/event/event.h" diff --git a/orte/util/comm/comm.c b/orte/util/comm/comm.c index 6f2fba50aa1..b848ed68528 100644 --- a/orte/util/comm/comm.c +++ b/orte/util/comm/comm.c @@ -26,7 +26,7 @@ #include #include "opal/util/output.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "opal/mca/event/event.h" #include "opal/mca/pmix/pmix.h" #include "opal/runtime/opal_progress.h" diff --git a/orte/util/name_fns.c b/orte/util/name_fns.c index 7d5cd876d91..f684ab07edf 100644 --- a/orte/util/name_fns.c +++ b/orte/util/name_fns.c @@ -29,7 +29,7 @@ #include "opal/util/printf.h" #include "opal/util/string_copy.h" -#include "opal/threads/tsd.h" +#include "opal/mca/threads/tsd.h" #include "orte/mca/errmgr/errmgr.h" diff --git a/orte/util/threads.h b/orte/util/threads.h index 5bd1be82b5b..08c6c66ab7e 100644 --- a/orte/util/threads.h +++ b/orte/util/threads.h @@ -13,7 +13,7 @@ #include "orte_config.h" #include "opal/sys/atomic.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" /* provide macros for forward-proofing the shifting * of objects between threads - at some point, we @@ -27,11 +27,11 @@ * we only have a memory barrier */ #define ORTE_ACQUIRE_OBJECT(o) opal_atomic_rmb() -#define orte_condition_wait(a,b) pthread_cond_wait(a, &(b)->m_lock_pthread) -typedef pthread_cond_t orte_condition_t; -#define orte_condition_broadcast(a) pthread_cond_broadcast(a) -#define orte_condition_signal(a) pthread_cond_signal(a) -#define ORTE_CONDITION_STATIC_INIT PTHREAD_COND_INITIALIZER +#define orte_condition_wait(a,b) opal_cond_wait(a,b) +typedef opal_cond_t orte_condition_t; +#define orte_condition_broadcast(a) opal_cond_broadcast(a) +#define orte_condition_signal(a) opal_cond_signal(a) +#define ORTE_CONDITION_STATIC_INIT OPAL_COND_INITIALIZER /* define a threadshift macro */ #define ORTE_THREADSHIFT(x, eb, f, p) \ @@ -51,14 +51,14 @@ typedef struct { #define ORTE_CONSTRUCT_LOCK(l) \ do { \ OBJ_CONSTRUCT(&(l)->mutex, opal_mutex_t); \ - pthread_cond_init(&(l)->cond, NULL); \ + opal_cond_init(&(l)->cond); \ (l)->active = true; \ } while(0) #define ORTE_DESTRUCT_LOCK(l) \ do { \ OBJ_DESTRUCT(&(l)->mutex); \ - pthread_cond_destroy(&(l)->cond); \ + opal_cond_destroy(&(l)->cond); \ } while(0) diff --git a/oshmem/mca/memheap/buddy/memheap_buddy.h b/oshmem/mca/memheap/buddy/memheap_buddy.h index ab7e16b4b3c..246e598453f 100644 --- a/oshmem/mca/memheap/buddy/memheap_buddy.h +++ b/oshmem/mca/memheap/buddy/memheap_buddy.h @@ -17,7 +17,7 @@ #include "oshmem_config.h" #include "oshmem/mca/mca.h" #include "opal/class/opal_list.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "oshmem/mca/memheap/memheap.h" #include "oshmem/mca/memheap/base/base.h" #include "oshmem/mca/spml/spml.h" diff --git a/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.h b/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.h index dba1ed55f7d..9f1a95959a8 100644 --- a/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.h +++ b/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.h @@ -17,7 +17,7 @@ #include "oshmem_config.h" #include "oshmem/mca/mca.h" #include "opal/class/opal_list.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "oshmem/mca/memheap/memheap.h" #include "oshmem/mca/memheap/base/base.h" #include "oshmem/mca/spml/spml.h" diff --git a/oshmem/proc/proc.c b/oshmem/proc/proc.c index 23cbbc685c5..509f04941cc 100644 --- a/oshmem/proc/proc.c +++ b/oshmem/proc/proc.c @@ -24,7 +24,7 @@ #endif #include "opal/datatype/opal_convertor.h" -#include "opal/threads/mutex.h" +#include "opal/mca/threads/mutex.h" #include "opal/dss/dss.h" #include "opal/util/arch.h" #include "opal/class/opal_list.h" diff --git a/oshmem/request/request.h b/oshmem/request/request.h index 8d90bd922cf..97c6c2630ee 100644 --- a/oshmem/request/request.h +++ b/oshmem/request/request.h @@ -24,7 +24,7 @@ #include "opal/class/opal_free_list.h" #include "opal/class/opal_pointer_array.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/condition.h" BEGIN_C_DECLS diff --git a/oshmem/runtime/oshmem_shmem_init.c b/oshmem/runtime/oshmem_shmem_init.c index 696c7518b55..d430c05ef1b 100644 --- a/oshmem/runtime/oshmem_shmem_init.c +++ b/oshmem/runtime/oshmem_shmem_init.c @@ -27,7 +27,7 @@ #include "opal/class/opal_list.h" #include "opal/mca/base/base.h" #include "opal/runtime/opal_progress.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/util/argv.h" #include "opal/util/output.h" #include "opal/util/error.h" diff --git a/test/asm/Makefile.am b/test/asm/Makefile.am index 17f222bbd9d..61bc008caa1 100644 --- a/test/asm/Makefile.am +++ b/test/asm/Makefile.am @@ -43,39 +43,40 @@ atomic_barrier_noinline.c: ln -s $(top_srcdir)/test/asm/atomic_barrier.c atomic_barrier_noinline.c atomic_barrier_noinline_SOURCES = atomic_barrier_noinline.c atomic_barrier_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM +atomic_barrier_noinline_LDADD = $(libs) -lpthread ###################################################################### atomic_spinlock_SOURCES = atomic_spinlock.c -atomic_spinlock_LDADD = $(libs) +atomic_spinlock_LDADD = $(libs) -lpthread atomic_spinlock_noinline.c: ln -s $(top_srcdir)/test/asm/atomic_spinlock.c atomic_spinlock_noinline.c atomic_spinlock_noinline_SOURCES = atomic_spinlock_noinline.c atomic_spinlock_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM -atomic_spinlock_noinline_LDADD = $(libs) +atomic_spinlock_noinline_LDADD = $(libs) -lpthread ###################################################################### atomic_math_SOURCES = atomic_math.c -atomic_math_LDADD = $(libs) +atomic_math_LDADD = $(libs) -lpthread atomic_math_noinline.c: ln -s $(top_srcdir)/test/asm/atomic_math.c atomic_math_noinline.c atomic_math_noinline_SOURCES = atomic_math_noinline.c atomic_math_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM -atomic_math_noinline_LDADD = $(libs) +atomic_math_noinline_LDADD = $(libs) -lpthread ###################################################################### atomic_cmpset_SOURCES = atomic_cmpset.c -atomic_cmpset_LDADD = $(libs) +atomic_cmpset_LDADD = $(libs) -lpthread atomic_cmpset_noinline.c: ln -s $(top_srcdir)/test/asm/atomic_cmpset.c atomic_cmpset_noinline.c atomic_cmpset_noinline_SOURCES = atomic_cmpset_noinline.c atomic_cmpset_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM -atomic_cmpset_noinline_LDADD = $(libs) +atomic_cmpset_noinline_LDADD = $(libs) -lpthread ###################################################################### diff --git a/test/class/Makefile.am b/test/class/Makefile.am index 4dc7daf24cc..46f1c584ac9 100644 --- a/test/class/Makefile.am +++ b/test/class/Makefile.am @@ -92,13 +92,15 @@ ompi_rb_tree_DEPENDENCIES = $(ompi_rb_tree_LDADD) opal_lifo_SOURCES = opal_lifo.c opal_lifo_LDADD = \ $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la \ - $(top_builddir)/test/support/libsupport.a + $(top_builddir)/test/support/libsupport.a \ + -lpthread opal_lifo_DEPENDENCIES = $(opal_lifo_LDADD) opal_fifo_SOURCES = opal_fifo.c opal_fifo_LDADD = \ $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la \ - $(top_builddir)/test/support/libsupport.a + $(top_builddir)/test/support/libsupport.a \ + -lpthread opal_fifo_DEPENDENCIES = $(opal_fifo_LDADD) clean-local: diff --git a/test/class/opal_fifo.c b/test/class/opal_fifo.c index 122524a8d9f..400bfd55222 100644 --- a/test/class/opal_fifo.c +++ b/test/class/opal_fifo.c @@ -18,6 +18,7 @@ #include "opal/runtime/opal.h" #include "opal/constants.h" +#include #include #include #include diff --git a/test/class/opal_lifo.c b/test/class/opal_lifo.c index 521bb4e5d97..7997065b6d0 100644 --- a/test/class/opal_lifo.c +++ b/test/class/opal_lifo.c @@ -20,6 +20,7 @@ #include #include #include +#include #include diff --git a/test/threads/opal_condition.c b/test/threads/opal_condition.c index e163dcb83e4..cacb3acc5f1 100644 --- a/test/threads/opal_condition.c +++ b/test/threads/opal_condition.c @@ -25,8 +25,8 @@ #include "support.h" #include "opal/runtime/opal.h" #include "opal/constants.h" -#include "opal/threads/threads.h" -#include "opal/threads/condition.h" +#include "opal/mca/threads/threads.h" +#include "opal/mca/threads/condition.h" #include "opal/sys/atomic.h" static opal_mutex_t mutex; diff --git a/test/threads/opal_thread.c b/test/threads/opal_thread.c index e795190c5a1..f7f66130d8d 100644 --- a/test/threads/opal_thread.c +++ b/test/threads/opal_thread.c @@ -15,7 +15,7 @@ #include "support.h" #include "opal/constants.h" -#include "opal/threads/threads.h" +#include "opal/mca/threads/threads.h" #include "opal/sys/atomic.h"