From 05b5984b4ed04c619424efbd097c9be43bcd931a Mon Sep 17 00:00:00 2001 From: Artem Polyakov Date: Wed, 4 Mar 2020 12:39:32 -0800 Subject: [PATCH 01/40] pml/ucx: Warn if UCX is built in a single-threaded mode Signed-off-by: Artem Polyakov --- ompi/mca/pml/ucx/pml_ucx.c | 4 ++-- ompi/mca/pml/ucx/pml_ucx.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ompi/mca/pml/ucx/pml_ucx.c b/ompi/mca/pml/ucx/pml_ucx.c index 93a27601822..5dc7f4a5b7d 100644 --- a/ompi/mca/pml/ucx/pml_ucx.c +++ b/ompi/mca/pml/ucx/pml_ucx.c @@ -289,8 +289,8 @@ int mca_pml_ucx_init(int enable_mpi_threads) if (enable_mpi_threads && (attr.thread_mode != UCS_THREAD_MODE_MULTI)) { /* UCX does not support multithreading, disqualify current PML for now */ /* TODO: we should let OMPI to fallback to THREAD_SINGLE mode */ - PML_UCX_VERBOSE(1, "UCP worker does not support MPI_THREAD_MULTIPLE. " - "PML UCX could not be selected"); + PML_UCX_WARN("UCP worker does not support MPI_THREAD_MULTIPLE. " + "PML UCX could not be selected"); rc = OMPI_ERR_NOT_SUPPORTED; goto err_destroy_worker; } diff --git a/ompi/mca/pml/ucx/pml_ucx.h b/ompi/mca/pml/ucx/pml_ucx.h index f073b56a549..d7c5dba4527 100644 --- a/ompi/mca/pml/ucx/pml_ucx.h +++ b/ompi/mca/pml/ucx/pml_ucx.h @@ -26,7 +26,7 @@ #define PML_UCX_ASSERT MCA_COMMON_UCX_ASSERT #define PML_UCX_ERROR MCA_COMMON_UCX_ERROR #define PML_UCX_VERBOSE MCA_COMMON_UCX_VERBOSE - +#define PML_UCX_WARN MCA_COMMON_UCX_WARN typedef struct mca_pml_ucx_module mca_pml_ucx_module_t; typedef struct pml_ucx_persistent_request mca_pml_ucx_persistent_request_t; From 45bfe038422d27ff41dbac7114d1d2066cb36d6f Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Mon, 7 Sep 2020 22:12:23 +0200 Subject: [PATCH 02/40] Move yield capability to opal thread component This adds two new mca parameters for the pthreads component: threads_pthreads_yield_strategy to choose the strategy (valid values: sched_yield or nanosleep), threads_pthreads_nanosleep_time (time passed to nanosleep) A thread component may also signal that yield-when-idle should be the default (used for Argobots and Qthreads) Signed-off-by: Joseph Schuchart --- ompi/runtime/ompi_mpi_params.c | 9 +- .../argobots/threads_argobots_threads.h | 12 ++- opal/mca/threads/pthreads/Makefile.am | 4 +- opal/mca/threads/pthreads/threads_pthreads.h | 27 ++++++ .../pthreads/threads_pthreads_component.c | 11 ++- .../pthreads/threads_pthreads_threads.h | 14 ++- .../threads/pthreads/threads_pthreads_yield.c | 89 +++++++++++++++++++ .../qthreads/threads_qthreads_threads.h | 11 ++- opal/mca/threads/threads.h | 2 + opal/runtime/opal_progress.c | 17 ++-- 10 files changed, 179 insertions(+), 17 deletions(-) create mode 100644 opal/mca/threads/pthreads/threads_pthreads.h create mode 100644 opal/mca/threads/pthreads/threads_pthreads_yield.c diff --git a/ompi/runtime/ompi_mpi_params.c b/ompi/runtime/ompi_mpi_params.c index ad8ed8ac91e..91e0244646c 100644 --- a/ompi/runtime/ompi_mpi_params.c +++ b/ompi/runtime/ompi_mpi_params.c @@ -43,6 +43,8 @@ #include "opal/util/show_help.h" #include "opal/runtime/opal.h" #include "opal/runtime/opal_params.h" +#include "opal/mca/threads/threads.h" + /* * Global variables * @@ -62,7 +64,8 @@ bool ompi_mpi_keep_fqdn_hostnames = false; bool ompi_have_sparse_group_storage = OPAL_INT_TO_BOOL(OMPI_GROUP_SPARSE); bool ompi_use_sparse_group_storage = OPAL_INT_TO_BOOL(OMPI_GROUP_SPARSE); -bool ompi_mpi_yield_when_idle = false; +/* if the threads module requires yielding we use that as default but allow it to be overridden */ +bool ompi_mpi_yield_when_idle = OPAL_THREAD_YIELD_WHEN_IDLE_DEFAULT; int ompi_mpi_event_tick_rate = -1; char *ompi_mpi_show_mca_params_string = NULL; bool ompi_mpi_have_sparse_group_storage = !!(OMPI_GROUP_SPARSE); @@ -118,7 +121,9 @@ int ompi_mpi_register_params(void) OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY, &ompi_mpi_oversubscribe); - ompi_mpi_yield_when_idle = ompi_mpi_oversubscribe; + + /* yield if the node is oversubscribed and allow users to override */ + ompi_mpi_yield_when_idle |= ompi_mpi_oversubscribe; (void) mca_base_var_register("ompi", "mpi", NULL, "yield_when_idle", "Yield the processor when waiting for MPI communication (for MPI processes, will default to 1 when oversubscribing nodes)", MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, diff --git a/opal/mca/threads/argobots/threads_argobots_threads.h b/opal/mca/threads/argobots/threads_argobots_threads.h index fe513532530..3992b32f274 100644 --- a/opal/mca/threads/argobots/threads_argobots_threads.h +++ b/opal/mca/threads/argobots/threads_argobots_threads.h @@ -6,7 +6,7 @@ * 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, + * Copyright (c) 2004-2020 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. @@ -37,4 +37,14 @@ struct opal_thread_t { void *t_ret; }; + +/* Argobots are cooperatively scheduled so yield when idle */ +#define OPAL_THREAD_YIELD_WHEN_IDLE_DEFAULT true + +static inline +void opal_thread_yield(void) +{ + ABT_thread_yield(); +} + #endif /* OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_THREADS_H */ diff --git a/opal/mca/threads/pthreads/Makefile.am b/opal/mca/threads/pthreads/Makefile.am index 833950d5e17..0f5aa1d45de 100644 --- a/opal/mca/threads/pthreads/Makefile.am +++ b/opal/mca/threads/pthreads/Makefile.am @@ -29,4 +29,6 @@ libmca_threads_pthreads_la_SOURCES = \ threads_pthreads_threads.h \ threads_pthreads_tsd.h \ threads_pthreads_wait_sync.c \ - threads_pthreads_wait_sync.h + threads_pthreads_wait_sync.h \ + threads_pthreads_yield.c \ + threads_pthreads.h diff --git a/opal/mca/threads/pthreads/threads_pthreads.h b/opal/mca/threads/pthreads/threads_pthreads.h new file mode 100644 index 00000000000..e382abde635 --- /dev/null +++ b/opal/mca/threads/pthreads/threads_pthreads.h @@ -0,0 +1,27 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2020 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#ifndef OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_H +#define OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_H + +#include "opal_config.h" +#include +#include + +typedef void (opal_threads_pthreads_yield_fn_t)(void); + +OPAL_DECLSPEC int opal_threads_pthreads_yield_init(const mca_base_component_t *component); + +OPAL_DECLSPEC extern opal_threads_pthreads_yield_fn_t *opal_threads_pthreads_yield_fn; + +#endif /* OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_H */ diff --git a/opal/mca/threads/pthreads/threads_pthreads_component.c b/opal/mca/threads/pthreads/threads_pthreads_component.c index fcd00368831..30c6ca70336 100644 --- a/opal/mca/threads/pthreads/threads_pthreads_component.c +++ b/opal/mca/threads/pthreads/threads_pthreads_component.c @@ -6,7 +6,7 @@ * 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, + * Copyright (c) 2004-2020 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. @@ -26,8 +26,11 @@ #include "opal/mca/threads/thread.h" #include "opal/mca/threads/threads.h" #include "opal/constants.h" +#include "opal/mca/threads/pthreads/threads_pthreads.h" + static int opal_threads_pthreads_open(void); +static int opal_threads_pthreads_register(void); const opal_threads_base_component_1_0_0_t mca_threads_pthreads_component = { /* First, the mca_component_t struct containing meta information @@ -41,6 +44,7 @@ const opal_threads_base_component_1_0_0_t mca_threads_pthreads_component = { OPAL_RELEASE_VERSION), .mca_open_component = opal_threads_pthreads_open, + .mca_register_component_params = opal_threads_pthreads_register }, .threadsc_data = { /* The component is checkpoint ready */ @@ -48,6 +52,11 @@ const opal_threads_base_component_1_0_0_t mca_threads_pthreads_component = { }, }; +int opal_threads_pthreads_register(void) +{ + return opal_threads_pthreads_yield_init(&mca_threads_pthreads_component.threadsc_version); +} + int opal_threads_pthreads_open(void) { return OPAL_SUCCESS; diff --git a/opal/mca/threads/pthreads/threads_pthreads_threads.h b/opal/mca/threads/pthreads/threads_pthreads_threads.h index 27ad13e8e1d..2d5d062f1d0 100644 --- a/opal/mca/threads/pthreads/threads_pthreads_threads.h +++ b/opal/mca/threads/pthreads/threads_pthreads_threads.h @@ -6,7 +6,7 @@ * 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, + * Copyright (c) 2004-2020 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. @@ -30,6 +30,9 @@ #include #include +#include "opal/mca/threads/threads.h" +#include "opal/mca/threads/pthreads/threads_pthreads.h" + struct opal_thread_t { opal_object_t super; opal_thread_fn_t t_run; @@ -37,4 +40,13 @@ struct opal_thread_t { pthread_t t_handle; }; +/* Pthreads do not need to yield when idle */ +#define OPAL_THREAD_YIELD_WHEN_IDLE_DEFAULT false + +static inline +void opal_thread_yield(void) +{ + opal_threads_pthreads_yield_fn(); +} + #endif /* OPAL_MCA_THREADS_PTHREADS_THREADS_PTHREADS_THREADS_H */ diff --git a/opal/mca/threads/pthreads/threads_pthreads_yield.c b/opal/mca/threads/pthreads/threads_pthreads_yield.c new file mode 100644 index 00000000000..d68126fea4a --- /dev/null +++ b/opal/mca/threads/pthreads/threads_pthreads_yield.c @@ -0,0 +1,89 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2020 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" +#include +#ifdef HAVE_SCHED_H +#include +#endif + +#include "opal/constants.h" +#include "opal/mca/threads/thread.h" +#include "opal/mca/threads/pthreads/threads_pthreads.h" + +static void opal_thread_pthreads_yield_sched_yield(void); +static void opal_thread_pthreads_yield_nanosleep(void); + +typedef enum { + OPAL_PTHREADS_YIELD_SCHED_YIELD = 0, + OPAL_PTHREADS_YIELD_NANOSLEEP +} opal_threads_pthreads_yield_strategy_t; + +static mca_base_var_enum_value_t yield_strategy_values[] = { + {OPAL_PTHREADS_YIELD_SCHED_YIELD, "sched_yield"}, + {OPAL_PTHREADS_YIELD_NANOSLEEP, "nanosleep"}, + {0, NULL}}; + + + +/* Number of nanoseconds to nanosleep, if enabled */ +static uint64_t yield_nsleep_nanosecs; +/* The time to nanosleep, if enabled */ +static struct timespec yield_nsleep_time = {.tv_sec = 0, .tv_nsec = 1}; +static opal_threads_pthreads_yield_strategy_t yield_strategy = OPAL_PTHREADS_YIELD_SCHED_YIELD; + +opal_threads_pthreads_yield_fn_t *opal_threads_pthreads_yield_fn = &opal_thread_pthreads_yield_sched_yield; + +int opal_threads_pthreads_yield_init(const mca_base_component_t *component) +{ + mca_base_var_enum_t *yield_strategy_enumerator; + mca_base_var_enum_create("pthread_yield_strategies", yield_strategy_values, &yield_strategy_enumerator); + + (void) mca_base_component_var_register(component, "yield_strategy", + "Pthread yield strategy to use", + MCA_BASE_VAR_TYPE_INT, yield_strategy_enumerator, 0, 0, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, &yield_strategy); + switch(yield_strategy) { + case OPAL_PTHREADS_YIELD_NANOSLEEP: + opal_threads_pthreads_yield_fn = &opal_thread_pthreads_yield_nanosleep; + break; + default: + /* use initial value */ + break; + } + + OBJ_RELEASE(yield_strategy_enumerator); + + yield_nsleep_nanosecs = (yield_nsleep_time.tv_sec * 1E9) + yield_nsleep_time.tv_nsec; + (void) mca_base_component_var_register(component, "nanosleep_time", + "Number of nanoseconds to sleep when using nanosleep as the pthread yield strategy", + MCA_BASE_VAR_TYPE_UINT64_T, NULL, 0, 0, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, &yield_nsleep_nanosecs); + yield_nsleep_time.tv_sec = yield_nsleep_nanosecs / 1E9; + yield_nsleep_time.tv_nsec = yield_nsleep_nanosecs - (uint64_t)(yield_nsleep_time.tv_sec * 1E9); + + return OPAL_SUCCESS; + +} + +void opal_thread_pthreads_yield_sched_yield(void) +{ +#ifdef HAVE_SCHED_H + sched_yield(); +#endif +} + +void opal_thread_pthreads_yield_nanosleep(void) +{ + nanosleep(&yield_nsleep_time, NULL); +} + diff --git a/opal/mca/threads/qthreads/threads_qthreads_threads.h b/opal/mca/threads/qthreads/threads_qthreads_threads.h index e00553078f5..c5eebe10fc8 100644 --- a/opal/mca/threads/qthreads/threads_qthreads_threads.h +++ b/opal/mca/threads/qthreads/threads_qthreads_threads.h @@ -6,7 +6,7 @@ * 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, + * Copyright (c) 2004-2020 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. @@ -38,4 +38,13 @@ struct opal_thread_t { aligned_t *t_thread_ret_ptr; }; +/* Qthreads are cooperatively scheduled so yield when idle */ +#define OPAL_THREAD_YIELD_WHEN_IDLE_DEFAULT true + +static inline +void opal_thread_yield(void) +{ + qthread_yield(); +} + #endif /* OPAL_MCA_THREADS_QTHREADS_THREADS_QTHREADS_THREADS_H */ diff --git a/opal/mca/threads/threads.h b/opal/mca/threads/threads.h index 21a25db6ac8..7d51a9c6a12 100644 --- a/opal/mca/threads/threads.h +++ b/opal/mca/threads/threads.h @@ -133,6 +133,8 @@ 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); +static inline void opal_thread_yield(void); + END_C_DECLS #endif /* OPAL_MCA_THREADS_THREADS_H */ diff --git a/opal/runtime/opal_progress.c b/opal/runtime/opal_progress.c index 6f1032ee6a6..0ba1e1ff007 100644 --- a/opal/runtime/opal_progress.c +++ b/opal/runtime/opal_progress.c @@ -6,7 +6,7 @@ * 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, + * Copyright (c) 2004-2020 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. @@ -27,10 +27,6 @@ #include "opal_config.h" -#ifdef HAVE_SCHED_H -#include -#endif - #include "opal/runtime/opal_progress.h" #include "opal/util/event.h" #include "opal/mca/base/mca_base_var.h" @@ -39,6 +35,7 @@ #include "opal/util/output.h" #include "opal/runtime/opal_params.h" #include "opal/runtime/opal.h" +#include "opal/mca/threads/threads.h" #define OPAL_PROGRESS_USE_TIMERS (OPAL_TIMER_CYCLE_SUPPORTED || OPAL_TIMER_USEC_SUPPORTED) #define OPAL_PROGRESS_ONLY_USEC_NATIVE (OPAL_TIMER_USEC_NATIVE && !OPAL_TIMER_CYCLE_NATIVE) @@ -68,7 +65,7 @@ static volatile opal_progress_callback_t *callbacks_lp = NULL; static size_t callbacks_lp_len = 0; static size_t callbacks_lp_size = 0; -/* do we want to call sched_yield() if nothing happened */ +/* do we want to yield() if nothing happened */ bool opal_progress_yield_when_idle = false; #if OPAL_PROGRESS_USE_TIMERS @@ -212,7 +209,7 @@ static int opal_progress_events(void) * be called. We don't propogate errors from the progress functions, * so no action is taken if they return failures. The functions are * expected to return the number of events progressed, to determine - * whether or not we should call sched_yield() during MPI progress. + * whether or not we should yield the CPU during MPI progress. * This is only losely tracked, as an error return can cause the number * of progressed events to appear lower than it actually is. We don't * care, as the cost of that happening is far outweighed by the cost @@ -246,16 +243,16 @@ opal_progress(void) opal_progress_events(); } -#if OPAL_HAVE_SCHED_YIELD if (opal_progress_yield_when_idle && events <= 0) { /* If there is nothing to do - yield the processor - otherwise * we could consume the processor for the entire time slice. If * the processor is oversubscribed - this will result in a best-case * latency equivalent to the time-slice. + * With some thread implementations, yielding might be required + * to ensure correct scheduling of all communicating threads. */ - sched_yield(); + opal_thread_yield(); } -#endif /* defined(HAVE_SCHED_YIELD) */ } From aaa715db70466858ea517d3efd3d42eca017986b Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Fri, 5 Feb 2021 18:06:11 -0700 Subject: [PATCH 03/40] btl/uct: bump allowed version to v1.9.x Signed-off-by: Nathan Hjelm --- opal/mca/btl/uct/configure.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opal/mca/btl/uct/configure.m4 b/opal/mca/btl/uct/configure.m4 index d6e258ff649..4a6892bb212 100644 --- a/opal/mca/btl/uct/configure.m4 +++ b/opal/mca/btl/uct/configure.m4 @@ -52,7 +52,7 @@ dnl fi max_allowed_uct_major=1 - max_allowed_uct_minor=8 + max_allowed_uct_minor=9 if test "$btl_uct_happy" = "yes" && test "$enable_uct_version_check" != "no"; then AC_MSG_CHECKING([UCT version compatibility]) OPAL_VAR_SCOPE_PUSH([CPPFLAGS_save]) From 92f947ce7c4629551b66b560af53c58b7316d5b1 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Fri, 5 Feb 2021 20:17:53 -0500 Subject: [PATCH 04/40] Fix the rndv protocol over UCT. Signed-off-by: George Bosilca --- opal/mca/btl/uct/btl_uct_am.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opal/mca/btl/uct/btl_uct_am.c b/opal/mca/btl/uct/btl_uct_am.c index 8f0d29bdd36..08f2b21ba8a 100644 --- a/opal/mca/btl/uct/btl_uct_am.c +++ b/opal/mca/btl/uct/btl_uct_am.c @@ -109,7 +109,7 @@ struct mca_btl_base_descriptor_t *mca_btl_uct_prepare_src (mca_btl_base_module_t frag->base.des_segment_count = 2; } else { frag->segments[0].seg_len = total_size; - memcpy ((void *)((intptr_t) frag->segments[1].seg_addr.pval + reserve), data_ptr, *size); + memcpy ((void *)((intptr_t) frag->segments[0].seg_addr.pval + reserve), data_ptr, *size); frag->base.des_segment_count = 1; } } From 1cf8f1b39d4d2a726351eaa1ca2e83ff6372b338 Mon Sep 17 00:00:00 2001 From: Marisa Roman Date: Fri, 5 Feb 2021 10:42:44 -0500 Subject: [PATCH 05/40] Allowing PSM2 to get its TransportKey from PMIx Author: Ralph Castain Signed-off-by: Marisa Roman --- ompi/mca/mtl/psm2/mtl_psm2.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ompi/mca/mtl/psm2/mtl_psm2.c b/ompi/mca/mtl/psm2/mtl_psm2.c index 5ce53f7af27..5d10a025bd5 100644 --- a/ompi/mca/mtl/psm2/mtl_psm2.c +++ b/ompi/mca/mtl/psm2/mtl_psm2.c @@ -16,6 +16,8 @@ * reserved. * Copyright (c) 2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. + * * $COPYRIGHT$ * * Additional copyrights may follow @@ -101,7 +103,20 @@ int ompi_mtl_psm2_module_init(int local_rank, int num_local_procs) { char env_string[256]; int rc; - generated_key = getenv("OMPI_MCA_orte_precondition_transports"); + opal_process_name_t pname; + + generated_key = NULL; + pname.jobid = opal_process_info.my_name.jobid; + pname.vpid = OPAL_VPID_WILDCARD; + OPAL_MODEX_RECV_VALUE_OPTIONAL(rc, PMIX_CREDENTIAL, &pname, + (char**)&generated_key, PMIX_STRING); + + char *tmp_key; + if (PMIX_SUCCESS != rc || NULL == generated_key) { + if (NULL != (tmp_key = getenv("OMPI_MCA_orte_precondition_transports"))) { + generated_key = strdup(tmp_key); + } + } memset(uu, 0, sizeof(psm2_uuid_t)); if (!generated_key || (strlen(generated_key) != 33) || @@ -111,10 +126,13 @@ int ompi_mtl_psm2_module_init(int local_rank, int num_local_procs) { "no uuid present", true, generated_key ? "could not be parsed from" : "not present in", ompi_process_info.nodename); + free(generated_key); return OMPI_ERROR; } + free(generated_key); + /* Handle our own errors for opening endpoints */ psm2_error_register_handler(ompi_mtl_psm2.ep, ompi_mtl_psm2_errhandler); From 23f2784e10570fe39409371380307c90fe9a3267 Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Sun, 14 Feb 2021 15:13:10 -0500 Subject: [PATCH 06/40] Fix case where var->mbv_enumerator can be released when static. Signed-off-by: Austen Lauria --- opal/mca/base/mca_base_var.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index 331400c5e2e..e1ecbbed4a1 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -84,6 +84,12 @@ static int mca_base_var_count = 0; static opal_hash_table_t mca_base_var_index_hash; +#define OPAL_MCA_VAR_MBV_ENUMERATOR_FREE(mbv_enumerator) { \ + if(mbv_enumerator && !mbv_enumerator->enum_is_static) { \ + OBJ_RELEASE(mbv_enumerator); \ + } \ +} + const char *ompi_var_type_names[] = { "int", "unsigned_int", @@ -870,8 +876,8 @@ int mca_base_var_deregister(int vari) var->mbv_storage->stringval) { free (var->mbv_storage->stringval); var->mbv_storage->stringval = NULL; - } else if (var->mbv_enumerator && !var->mbv_enumerator->enum_is_static) { - OBJ_RELEASE(var->mbv_enumerator); + } else { + OPAL_MCA_VAR_MBV_ENUMERATOR_FREE(var -> mbv_enumerator); } var->mbv_enumerator = NULL; @@ -1517,10 +1523,7 @@ static int register_variable (const char *project_name, const char *framework_na if (MCA_BASE_VAR_TYPE_BOOL == var->mbv_type) { enumerator = &mca_base_var_enum_bool; } else if (NULL != enumerator) { - if (var->mbv_enumerator) { - OBJ_RELEASE (var->mbv_enumerator); - } - + OPAL_MCA_VAR_MBV_ENUMERATOR_FREE(var->mbv_enumerator); if (!enumerator->enum_is_static) { OBJ_RETAIN(enumerator); } @@ -1906,9 +1909,7 @@ static void var_destructor(mca_base_var_t *var) } /* don't release the boolean enumerator */ - if (var->mbv_enumerator && !var->mbv_enumerator->enum_is_static) { - OBJ_RELEASE(var->mbv_enumerator); - } + OPAL_MCA_VAR_MBV_ENUMERATOR_FREE(var->mbv_enumerator); if (NULL != var->mbv_long_name) { free(var->mbv_long_name); From 3a0e8bbb73137947e64babd5036d90bfd0438e33 Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Wed, 3 Feb 2021 13:08:42 -0500 Subject: [PATCH 07/40] Fix check for IBM xl compilers for v13.1 and later. By default newer xlc compilers only define __ibmxl__ now. https://www.ibm.com/support/knowledgecenter/en/SSXVZZ_13.1.6/com.ibm.xlcpp1316.lelinux.doc/compiler_ref/xlmacros.html Signed-off-by: Austen Lauria --- config/opal_check_vendor.m4 | 4 ++-- opal/include/opal/opal_portable_platform.h | 2 +- opal/include/opal/sys/powerpc/atomic.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/opal_check_vendor.m4 b/config/opal_check_vendor.m4 index ed789287e6e..92518971a10 100644 --- a/config/opal_check_vendor.m4 +++ b/config/opal_check_vendor.m4 @@ -12,7 +12,7 @@ dnl Copyright (c) 2004-2005 The Regents of the University of California. dnl All rights reserved. dnl Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. dnl Copyright (c) 2014 Intel, Inc. All rights reserved -dnl Copyright (c) 2017 IBM Corporation. All rights reserved. +dnl Copyright (c) 2017-2021 IBM Corporation. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -123,7 +123,7 @@ AC_DEFUN([_OPAL_CHECK_COMPILER_VENDOR], [ # IBM XL C/C++ AS_IF([test "$opal_check_compiler_vendor_result" = "unknown"], - [OPAL_IF_IFELSE([defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)], + [OPAL_IF_IFELSE([defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__)], [opal_check_compiler_vendor_result="ibm" xlc_major_version=`$CC -qversion 2>&1 | tail -n 1 | cut -d ' ' -f 2 | cut -d '.' -f 1` xlc_minor_version=`$CC -qversion 2>&1 | tail -n 1 | cut -d ' ' -f 2 | cut -d '.' -f 2` diff --git a/opal/include/opal/opal_portable_platform.h b/opal/include/opal/opal_portable_platform.h index e54db913099..5eaa28998b3 100644 --- a/opal/include/opal/opal_portable_platform.h +++ b/opal/include/opal/opal_portable_platform.h @@ -171,7 +171,7 @@ /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ # endif -#elif defined(__xlC__) +#elif defined(__xlC__) || defined(__ibmxl__) || defined(__IBMC__) || defined(__IBMCPP__) # define PLATFORM_COMPILER_XLC 1 # define PLATFORM_COMPILER_FAMILYNAME XLC # define PLATFORM_COMPILER_FAMILYID 5 diff --git a/opal/include/opal/sys/powerpc/atomic.h b/opal/include/opal/sys/powerpc/atomic.h index 84261f67cf8..393b92acba5 100644 --- a/opal/include/opal/sys/powerpc/atomic.h +++ b/opal/include/opal/sys/powerpc/atomic.h @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2010-2017 IBM Corporation. All rights reserved. + * Copyright (c) 2010-2021 IBM Corporation. All rights reserved. * Copyright (c) 2015-2018 Los Alamos National Security, LLC. All rights * reserved. * $COPYRIGHT$ @@ -107,7 +107,7 @@ void opal_atomic_isync(void) *********************************************************************/ #if OPAL_GCC_INLINE_ASSEMBLY -#ifdef __xlC__ +#if defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__) /* work-around bizzare xlc bug in which it sign-extends a pointer to a 32-bit signed integer */ #define OPAL_ASM_ADDR(a) ((uintptr_t)a) From a7c4f5dcd6f71ac5070de2eac1035d54b0342fb0 Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Wed, 3 Feb 2021 15:35:27 -0500 Subject: [PATCH 08/40] Fix configury where most compilers will get mislabeled as 'gnu'. Most compilers define the __GNU__ macro, so put it at the bottom as a catch-all. Tested with gcc, xlc, pgi and clang. Signed-off-by: Austen Lauria --- config/opal_check_vendor.m4 | 47 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/config/opal_check_vendor.m4 b/config/opal_check_vendor.m4 index 92518971a10..578f542d0b1 100644 --- a/config/opal_check_vendor.m4 +++ b/config/opal_check_vendor.m4 @@ -132,30 +132,6 @@ AC_DEFUN([_OPAL_CHECK_COMPILER_VENDOR], [ ], [OPAL_IF_IFELSE([defined(_AIX) && !defined(__GNUC__)], [opal_check_compiler_vendor_result="ibm"])])]) - - # GNU - AS_IF([test "$opal_check_compiler_vendor_result" = "unknown"], - [OPAL_IFDEF_IFELSE([__GNUC__], - [opal_check_compiler_vendor_result="gnu" - - # We do not support gccfss as a compiler so die if - # someone tries to use said compiler. gccfss (gcc - # for SPARC Systems) is a compiler that is no longer - # supported by Oracle and it has some major flaws - # that prevents it from actually compiling OMPI code. - # So if we detect it we automatically bail. - - if ($CC --version | grep gccfss) >/dev/null 2>&1; then - AC_MSG_RESULT([gccfss]) - AC_MSG_WARN([Detected gccfss being used to compile Open MPI.]) - AC_MSG_WARN([Because of several issues Open MPI does not support]) - AC_MSG_WARN([the gccfss compiler. Please use a different compiler.]) - AC_MSG_WARN([If you did not think you used gccfss you may want to]) - AC_MSG_WARN([check to see if the compiler you think you used is]) - AC_MSG_WARN([actually a link to gccfss.]) - AC_MSG_ERROR([Cannot continue]) - fi])]) - # Borland Turbo C AS_IF([test "$opal_check_compiler_vendor_result" = "unknown"], [OPAL_IFDEF_IFELSE([__TURBOC__], @@ -279,6 +255,29 @@ AC_DEFUN([_OPAL_CHECK_COMPILER_VENDOR], [ [OPAL_IFDEF_IFELSE([__WATCOMC__], [opal_check_compiler_vendor_result="watcom"])]) + # GNU + AS_IF([test "$opal_check_compiler_vendor_result" = "unknown"], + [OPAL_IFDEF_IFELSE([__GNUC__], + [opal_check_compiler_vendor_result="gnu" + + # We do not support gccfss as a compiler so die if + # someone tries to use said compiler. gccfss (gcc + # for SPARC Systems) is a compiler that is no longer + # supported by Oracle and it has some major flaws + # that prevents it from actually compiling OMPI code. + # So if we detect it we automatically bail. + + if ($CC --version | grep gccfss) >/dev/null 2>&1; then + AC_MSG_RESULT([gccfss]) + AC_MSG_WARN([Detected gccfss being used to compile Open MPI.]) + AC_MSG_WARN([Because of several issues Open MPI does not support]) + AC_MSG_WARN([the gccfss compiler. Please use a different compiler.]) + AC_MSG_WARN([If you did not think you used gccfss you may want to]) + AC_MSG_WARN([check to see if the compiler you think you used is]) + AC_MSG_WARN([actually a link to gccfss.]) + AC_MSG_ERROR([Cannot continue]) + fi])]) + $1="$opal_check_compiler_vendor_result" unset opal_check_compiler_vendor_result ]) From 68bf9cc0f5982d6474644c4f33eab5f829a4bed2 Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Mon, 15 Feb 2021 19:05:30 -0500 Subject: [PATCH 09/40] Silence -qinline xlc compiler warning. With '-g' and '-finline-functions' xlc will throw: 'warning: "-qinline" is not compatible with "-g". "-qnoinline" is being set.' Signed-off-by: Austen Lauria --- config/opal_setup_cc.m4 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/config/opal_setup_cc.m4 b/config/opal_setup_cc.m4 index ab9f180e3dc..91b9d98a873 100644 --- a/config/opal_setup_cc.m4 +++ b/config/opal_setup_cc.m4 @@ -18,6 +18,7 @@ dnl Copyright (c) 2015-2019 Research Organization for Information Science dnl and Technology (RIST). All rights reserved. dnl Copyright (c) 2020 Triad National Security, LLC. All rights dnl reserved. +dnl Copyright (c) 2021 IBM Corporation. All rights reserved. dnl dnl $COPYRIGHT$ dnl @@ -366,11 +367,14 @@ AC_DEFUN([OPAL_SETUP_CC],[ CFLAGS_orig="$CFLAGS" # Note: Some versions of clang (at least >= 3.5 -- perhaps - # older versions, too?) will *warn* about -finline-functions, - # but still allow it. This is very annoying, so check for - # that warning, too. The clang warning looks like this: + # older versions, too?) and xlc with -g (v16.1, perhaps older) + # will *warn* about -finline-functions, but still allow it. + # This is very annoying, so check for that warning, too. + # The clang warning looks like this: # clang: warning: optimization flag '-finline-functions' is not supported # clang: warning: argument unused during compilation: '-finline-functions' + # the xlc warning looks like this: + # warning: "-qinline" is not compatible with "-g". "-qnoinline" is being set. CFLAGS="$CFLAGS_orig -finline-functions" add= AC_CACHE_CHECK([if $CC supports -finline-functions], @@ -378,7 +382,7 @@ AC_DEFUN([OPAL_SETUP_CC],[ [AC_TRY_COMPILE([], [], [opal_cv_cc_finline_functions="yes" if test -s conftest.err ; then - for i in unused 'not supported' ; do + for i in unused 'not supported\|not compatible' ; do if $GREP -iq "$i" conftest.err; then opal_cv_cc_finline_functions="no" break; From afee2b7fc7559f2f219dc813938e9b9f00821642 Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Tue, 16 Feb 2021 15:21:45 -0500 Subject: [PATCH 10/40] Add _OPAL_CHECK_SPECIFIC_*FLAGS to check compiler flags. Instead of assuming some flags are only available with the 'gnu' compiler, add a check to add them as available. Do the same for CFLAGS and CXX flags. Signed-off-by: Austen Lauria --- config/opal_check_cflags.m4 | 72 ++++++++++++ config/opal_config_asm.m4 | 2 + config/opal_setup_cc.m4 | 222 +++++++++--------------------------- config/opal_setup_cxx.m4 | 138 +++++++++------------- 4 files changed, 177 insertions(+), 257 deletions(-) create mode 100644 config/opal_check_cflags.m4 diff --git a/config/opal_check_cflags.m4 b/config/opal_check_cflags.m4 new file mode 100644 index 00000000000..59fc0ce1ace --- /dev/null +++ b/config/opal_check_cflags.m4 @@ -0,0 +1,72 @@ +dnl -*- shell-script -*- +dnl +dnl Copyright (c) 2021 IBM Corporation. All rights reserved. +dnl +dnl $COPYRIGHT$ +dnl +dnl Additional copyrights may follow +dnl +dnl $HEADER$ +dnl + +AC_DEFUN([_OPAL_CFLAGS_FAIL_SEARCH],[ + AC_REQUIRE([AC_PROG_GREP]) + if test -s conftest.err ; then + $GREP -iq $1 conftest.err + if test "$?" = "0" ; then + opal_cv_cc_[$2]=0 + fi + fi +]) + +AC_DEFUN([_OPAL_CHECK_SPECIFIC_CFLAGS], [ +AC_MSG_CHECKING(if $CC supports ([$1])) + CFLAGS_orig=$CFLAGS + CFLAGS="$CFLAGS $1" + AC_CACHE_VAL(opal_cv_cc_[$2], [ + AC_TRY_COMPILE([], [$3], + [ + opal_cv_cc_[$2]=1 + _OPAL_CFLAGS_FAIL_SEARCH("ignored\|not recognized\|not supported\|not compatible\|unrecognized\|unknown", [$2]) + ], + opal_cv_cc_[$2]=1 + _OPAL_CFLAGS_FAIL_SEARCH("ignored\|not recognized\|not supported\|not compatible\|unrecognized\|unknown\|error", [$2]) + )]) + if test "$opal_cv_cc_[$2]" = "0" ; then + CFLAGS="$CFLAGS_orig" + AC_MSG_RESULT([no]) + else + AC_MSG_RESULT([yes]) + fi +]) + +AC_DEFUN([_OPAL_CXXFLAGS_FAIL_SEARCH],[ + AC_REQUIRE([AC_PROG_GREP]) + if test -s conftest.err ; then + $GREP -iq $1 conftest.err + if test "$?" = "0" ; then + opal_cv_cxx_[$2]=0 + fi + fi +]) + +AC_DEFUN([_OPAL_CHECK_SPECIFIC_CXXFLAGS], [ +AC_MSG_CHECKING(if $CXX supports ([$1])) + CXXFLAGS_orig=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $1" + AC_CACHE_VAL(opal_cv_cxx_[$2], [ + AC_TRY_COMPILE([], [$3], + [ + opal_cv_cxx_[$2]=1 + _OPAL_CXXFLAGS_FAIL_SEARCH("ignored\|not recognized\|not supported\|not compatible\|unrecognized\|unknown", [$2]) + ], + opal_cv_cxx_[$2]=1 + _OPAL_CXXFLAGS_FAIL_SEARCH("ignored\|not recognized\|not supported\|not compatible\|unrecognized\|unknown\|error", [$2]) + )]) + if test "$opal_cv_cxx_[$2]" = "0" ; then + CXXFLAGS="$CXXFLAGS_orig" + AC_MSG_RESULT([no]) + else + AC_MSG_RESULT([yes]) + fi +]) diff --git a/config/opal_config_asm.m4 b/config/opal_config_asm.m4 index 14ad4e2d818..c45cd3baf37 100644 --- a/config/opal_config_asm.m4 +++ b/config/opal_config_asm.m4 @@ -19,6 +19,7 @@ dnl Copyright (c) 2017 Amazon.com, Inc. or its affiliates. All Rights dnl reserved. dnl Copyright (c) 2020 Google, LLC. All rights reserved. dnl Copyright (c) 2020 Intel, Inc. All rights reserved. +dnl Copyright (c) 2021 IBM Corporation. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -1086,6 +1087,7 @@ dnl dnl ################################################################# AC_DEFUN([OPAL_CONFIG_ASM],[ AC_REQUIRE([OPAL_SETUP_CC]) + AC_REQUIRE([OPAL_SETUP_CXX]) AC_REQUIRE([AM_PROG_AS]) AC_ARG_ENABLE([c11-atomics],[AC_HELP_STRING([--enable-c11-atomics], diff --git a/config/opal_setup_cc.m4 b/config/opal_setup_cc.m4 index 91b9d98a873..c8f3bb7b8a8 100644 --- a/config/opal_setup_cc.m4 +++ b/config/opal_setup_cc.m4 @@ -161,6 +161,8 @@ AC_DEFUN([OPAL_SETUP_CC],[ OPAL_CHECK_CC_IQUOTE + OPAL_C_COMPILER_VENDOR([opal_c_vendor]) + if test $opal_cv_c11_supported = no ; then # It is not currently an error if C11 support is not available. Uncomment the # following lines and update the warning when we require a C11 compiler. @@ -206,7 +208,6 @@ AC_DEFUN([OPAL_SETUP_CC],[ AC_DEFINE_UNQUOTED([OPAL_C_HAVE___THREAD], [$opal_prog_cc__thread_available], [Whether C compiler supports __thread]) - OPAL_C_COMPILER_VENDOR([opal_c_vendor]) # Check for standard headers, needed here because needed before # the types checks. @@ -244,47 +245,34 @@ AC_DEFUN([OPAL_SETUP_CC],[ # Do we want code coverage if test "$WANT_COVERAGE" = "1"; then - if test "$opal_c_vendor" = "gnu" ; then - # For compilers > gcc-4.x, use --coverage for - # compiling and linking to circumvent trouble with - # libgcov. - CFLAGS_orig="$CFLAGS" - LDFLAGS_orig="$LDFLAGS" - - CFLAGS="$CFLAGS_orig --coverage" - LDFLAGS="$LDFLAGS_orig --coverage" - OPAL_COVERAGE_FLAGS= - - AC_CACHE_CHECK([if $CC supports --coverage], - [opal_cv_cc_coverage], - [AC_TRY_COMPILE([], [], - [opal_cv_cc_coverage="yes"], - [opal_cv_cc_coverage="no"])]) - - if test "$opal_cv_cc_coverage" = "yes" ; then - OPAL_COVERAGE_FLAGS="--coverage" - CLEANFILES="*.gcno ${CLEANFILES}" - CONFIG_CLEAN_FILES="*.gcda *.gcov ${CONFIG_CLEAN_FILES}" - else - OPAL_COVERAGE_FLAGS="-ftest-coverage -fprofile-arcs" - CLEANFILES="*.bb *.bbg ${CLEANFILES}" - CONFIG_CLEAN_FILES="*.da *.*.gcov ${CONFIG_CLEAN_FILES}" - fi - CFLAGS="$CFLAGS_orig $OPAL_COVERAGE_FLAGS" - LDFLAGS="$LDFLAGS_orig $OPAL_COVERAGE_FLAGS" - OPAL_WRAPPER_FLAGS_ADD([CFLAGS], [$OPAL_COVERAGE_FLAGS]) - OPAL_WRAPPER_FLAGS_ADD([LDFLAGS], [$OPAL_COVERAGE_FLAGS]) - - OPAL_FLAGS_UNIQ(CFLAGS) - OPAL_FLAGS_UNIQ(LDFLAGS) + # For compilers > gcc-4.x, use --coverage for + # compiling and linking to circumvent trouble with + # libgcov. + LDFLAGS_orig="$LDFLAGS" + LDFLAGS="$LDFLAGS_orig --coverage" + OPAL_COVERAGE_FLAGS= + + _OPAL_CHECK_SPECIFIC_CFLAGS(--coverage, coverage) + if test "$opal_cv_cc_coverage" = "1" ; then + OPAL_COVERAGE_FLAGS="--coverage" + CLEANFILES="*.gcno ${CLEANFILES}" + CONFIG_CLEAN_FILES="*.gcda *.gcov ${CONFIG_CLEAN_FILES}" AC_MSG_WARN([$OPAL_COVERAGE_FLAGS has been added to CFLAGS (--enable-coverage)]) - - WANT_DEBUG=1 else - AC_MSG_WARN([Code coverage functionality is currently available only with GCC]) - AC_MSG_ERROR([Configure: Cannot continue]) - fi - fi + _OPAL_CHECK_SPECIFIC_CFLAGS(-ftest-coverage, ftest_coverage) + _OPAL_CHECK_SPECIFIC_CFLAGS(-fprofile-arcs, fprofile_arcs) + if test "$opal_cv_cc_ftest_coverage" = "0" || test "opal_cv_cc_fprofile_arcs" = "0" ; then + AC_MSG_WARN([Code coverage functionality is not currently available with $CC]) + AC_MSG_ERROR([Configure: Cannot continue]) + fi + CLEANFILES="*.bb *.bbg ${CLEANFILES}" + OPAL_COVERAGE_FLAGS="-ftest-coverage -fprofile-arcs" + fi + OPAL_FLAGS_UNIQ(CFLAGS) + OPAL_FLAGS_UNIQ(LDFLAGS) + WANT_DEBUG=1 + fi + # Do we want debugging? if test "$WANT_DEBUG" = "1" && test "$enable_debug_symbols" != "no" ; then @@ -299,120 +287,29 @@ AC_DEFUN([OPAL_SETUP_CC],[ OPAL_CFLAGS_BEFORE_PICKY="$CFLAGS" if test $WANT_PICKY_COMPILER -eq 1; then - CFLAGS_orig=$CFLAGS - add= - - # These flags are likely GCC-specific (or, more specifically, - # we don't have general tests for each one, and we know they - # work with all versions of GCC that we have used throughout - # the years, so we'll keep them limited just to GCC). - if test "$opal_c_vendor" = "gnu" ; then - add="$add -Wall -Wundef -Wno-long-long -Wsign-compare" - add="$add -Wmissing-prototypes -Wstrict-prototypes" - add="$add -Wcomment -pedantic" - fi - - # see if -Wno-long-double works... - # Starting with GCC-4.4, the compiler complains about not - # knowing -Wno-long-double, only if -Wstrict-prototypes is set, too. - # - # Actually, this is not real fix, as GCC will pass on any -Wno- flag, - # have fun with the warning: -Wno-britney - CFLAGS="$CFLAGS_orig $add -Wno-long-double -Wstrict-prototypes" - - AC_CACHE_CHECK([if $CC supports -Wno-long-double], - [opal_cv_cc_wno_long_double], - [AC_TRY_COMPILE([], [], - [ - dnl So -Wno-long-double did not produce any errors... - dnl We will try to extract a warning regarding - dnl unrecognized or ignored options - AC_TRY_COMPILE([], [long double test;], - [ - opal_cv_cc_wno_long_double="yes" - if test -s conftest.err ; then - dnl Yes, it should be "ignor", in order to catch ignoring and ignore - for i in unknown invalid ignor unrecognized 'not supported'; do - $GREP -iq $i conftest.err - if test "$?" = "0" ; then - opal_cv_cc_wno_long_double="no" - break; - fi - done - fi - ], - [opal_cv_cc_wno_long_double="no"])], - [opal_cv_cc_wno_long_double="no"]) - ]) - - if test "$opal_cv_cc_wno_long_double" = "yes" ; then - add="$add -Wno-long-double" - fi - - # Per above, we know that this flag works with GCC / haven't - # really tested it elsewhere. - if test "$opal_c_vendor" = "gnu" ; then - add="$add -Werror-implicit-function-declaration " - fi - - CFLAGS="$CFLAGS_orig $add" - OPAL_FLAGS_UNIQ(CFLAGS) - AC_MSG_WARN([$add has been added to CFLAGS (--enable-picky)]) - unset add + _OPAL_CHECK_SPECIFIC_CFLAGS(-Wundef, Wundef) + _OPAL_CHECK_SPECIFIC_CFLAGS(-Wno-long-long, Wno_long_long, int main() { long long x; }) + _OPAL_CHECK_SPECIFIC_CFLAGS(-Wsign-compare, Wsign_compare) + _OPAL_CHECK_SPECIFIC_CFLAGS(-Wmissing-prototypes, Wmissing_prototypes) + _OPAL_CHECK_SPECIFIC_CFLAGS(-Wstrict-prototypes, Wstrict_prototypes) + _OPAL_CHECK_SPECIFIC_CFLAGS(-Wcomment, Wcomment) + _OPAL_CHECK_SPECIFIC_CFLAGS(-Werror-implicit-function-declaration, Werror_implicit_function_declaration) + _OPAL_CHECK_SPECIFIC_CFLAGS(-Wno-long-double, Wno_long_double, int main() { long double x; }) + _OPAL_CHECK_SPECIFIC_CFLAGS(-fno-strict-aliasing, fno_strict_aliasing, int main() { long double x; }) + _OPAL_CHECK_SPECIFIC_CFLAGS(-pedantic, pedantic) + _OPAL_CHECK_SPECIFIC_CFLAGS(-Wall, Wall) fi - # See if this version of gcc allows -finline-functions and/or - # -fno-strict-aliasing. Even check the gcc-impersonating compilers. - if test "$GCC" = "yes"; then - CFLAGS_orig="$CFLAGS" - - # Note: Some versions of clang (at least >= 3.5 -- perhaps - # older versions, too?) and xlc with -g (v16.1, perhaps older) - # will *warn* about -finline-functions, but still allow it. - # This is very annoying, so check for that warning, too. - # The clang warning looks like this: - # clang: warning: optimization flag '-finline-functions' is not supported - # clang: warning: argument unused during compilation: '-finline-functions' - # the xlc warning looks like this: - # warning: "-qinline" is not compatible with "-g". "-qnoinline" is being set. - CFLAGS="$CFLAGS_orig -finline-functions" - add= - AC_CACHE_CHECK([if $CC supports -finline-functions], - [opal_cv_cc_finline_functions], - [AC_TRY_COMPILE([], [], - [opal_cv_cc_finline_functions="yes" - if test -s conftest.err ; then - for i in unused 'not supported\|not compatible' ; do - if $GREP -iq "$i" conftest.err; then - opal_cv_cc_finline_functions="no" - break; - fi - done - fi - ], - [opal_cv_cc_finline_functions="no"])]) - if test "$opal_cv_cc_finline_functions" = "yes" ; then - add=" -finline-functions" - fi - CFLAGS="$CFLAGS_orig$add" - - CFLAGS_orig="$CFLAGS" - CFLAGS="$CFLAGS_orig -fno-strict-aliasing" - add= - AC_CACHE_CHECK([if $CC supports -fno-strict-aliasing], - [opal_cv_cc_fno_strict_aliasing], - [AC_TRY_COMPILE([], [], - [opal_cv_cc_fno_strict_aliasing="yes"], - [opal_cv_cc_fno_strict_aliasing="no"])]) - if test "$opal_cv_cc_fno_strict_aliasing" = "yes" ; then - add=" -fno-strict-aliasing" - fi - CFLAGS="$CFLAGS_orig$add" - - OPAL_FLAGS_UNIQ(CFLAGS) - AC_MSG_WARN([$add has been added to CFLAGS]) - unset add - fi + # Note: Some versions of clang (at least >= 3.5 -- perhaps + # older versions, too?) and xlc with -g (v16.1, perhaps older) + # will *warn* about -finline-functions, but still allow it. + # This is very annoying, so check for that warning, too. + # The clang warning looks like this: + # clang: warning: optimization flag '-finline-functions' is not supported + # clang: warning: argument unused during compilation: '-finline-functions' + # the xlc warning looks like this: + # warning: "-qinline" is not compatible with "-g". "-qnoinline" is being set. + _OPAL_CHECK_SPECIFIC_CFLAGS(-finline-functions, finline_functions) # Try to enable restrict keyword RESTRICT_CFLAGS= @@ -425,24 +322,7 @@ AC_DEFUN([OPAL_SETUP_CC],[ ;; esac if test ! -z "$RESTRICT_CFLAGS" ; then - CFLAGS_orig="$CFLAGS" - CFLAGS="$CFLAGS_orig $RESTRICT_CFLAGS" - add= - AC_CACHE_CHECK([if $CC supports $RESTRICT_CFLAGS], - [opal_cv_cc_restrict_cflags], - [AC_TRY_COMPILE([], [], - [opal_cv_cc_restrict_cflags="yes"], - [opal_cv_cc_restrict_cflags="no"])]) - if test "$opal_cv_cc_restrict_cflags" = "yes" ; then - add=" $RESTRICT_CFLAGS" - fi - - CFLAGS="${CFLAGS_orig}${add}" - OPAL_FLAGS_UNIQ([CFLAGS]) - if test "$add" != "" ; then - AC_MSG_WARN([$add has been added to CFLAGS]) - fi - unset add + _OPAL_CHECK_SPECIFIC_CFLAGS($RESTRICT_CFLAGS, restrict) fi # see if the C compiler supports __builtin_expect @@ -518,6 +398,8 @@ AC_DEFUN([OPAL_SETUP_CC],[ OPAL_ENSURE_CONTAINS_OPTFLAGS(["$CFLAGS"]) AC_MSG_RESULT([$co_result]) CFLAGS="$co_result" + OPAL_FLAGS_UNIQ([CFLAGS]) + AC_MSG_RESULT(CFLAGS result: $CFLAGS) OPAL_VAR_SCOPE_POP ]) diff --git a/config/opal_setup_cxx.m4 b/config/opal_setup_cxx.m4 index 843f94f77dd..ceb9d6264a9 100644 --- a/config/opal_setup_cxx.m4 +++ b/config/opal_setup_cxx.m4 @@ -18,6 +18,7 @@ dnl Copyright (c) 2015-2016 Research Organization for Information Science dnl and Technology (RIST). All rights reserved. dnl Copyright (c) 2020 Triad National Security, LLC. All rights dnl reserved. +dnl Copyright (c) 2021 IBM Corporation. All rights reserved. dnl dnl $COPYRIGHT$ dnl @@ -88,15 +89,15 @@ AC_DEFUN([_OPAL_SETUP_CXX_COMPILER],[ # VERSION file at the base of our source directory on case- # insensitive filesystems. AC_DEFUN([OPAL_CHECK_CXX_IQUOTE],[ - OPAL_VAR_SCOPE_PUSH([opal_check_cxx_iquote_CFLAGS_save]) - opal_check_cxx_iquote_CFLAGS_save=${CFLAGS} - CXXFLAGS="${CFLAGS} -iquote ." + OPAL_VAR_SCOPE_PUSH([opal_check_cxx_iquote_CXXFLAGS_save]) + opal_check_cxx_iquote_CXXFLAGS_save=${CXXFLAGS} + CXXFLAGS="${CXXFLAGS} -iquote ." AC_MSG_CHECKING([for $CXX option to add a directory only to the search path for the quote form of include]) AC_LANG_PUSH(C++) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[])], [opal_cxx_iquote="-iquote"], [opal_cxx_iquote="-I"]) - CXXFLAGS=${opal_check_cxx_iquote_CFLAGS_save} + CXXFLAGS=${opal_check_cxx_iquote_CXXFLAGS_save} AC_LANG_POP(C++) OPAL_VAR_SCOPE_POP AC_MSG_RESULT([$opal_cxx_iquote]) @@ -106,97 +107,58 @@ AC_DEFUN([OPAL_CHECK_CXX_IQUOTE],[ # ---------------------------------- # Back end of _OPAL_SETUP_CXX_COMPILER_BACKEND() AC_DEFUN([_OPAL_SETUP_CXX_COMPILER_BACKEND],[ + AC_LANG_PUSH(C++) + OPAL_CHECK_CXX_IQUOTE + # Do we want code coverage if test "$WANT_COVERAGE" = "1"; then - if test "$opal_cxx_vendor" = "gnu" ; then - AC_MSG_WARN([$OPAL_COVERAGE_FLAGS has been added to CFLAGS (--enable-coverage)]) - WANT_DEBUG=1 - CXXFLAGS="${CXXFLAGS} $OPAL_COVERAGE_FLAGS" - OPAL_WRAPPER_FLAGS_ADD([CXXFLAGS], [$OPAL_COVERAGE_FLAGS]) + # For compilers > gcc-4.x, use --coverage for + # compiling and linking to circumvent trouble with + # libgcov. + OPAL_COVERAGE_FLAGS= + + _OPAL_CHECK_SPECIFIC_CXXFLAGS(--coverage, coverage) + if test "$opal_cv_cxx_coverage" = "1" ; then + OPAL_COVERAGE_FLAGS="--coverage" + CLEANFILES="*.gcno ${CLEANFILES}" + CONFIG_CLEAN_FILES="*.gcda *.gcov ${CONFIG_CLEAN_FILES}" + AC_MSG_WARN([$OPAL_COVERAGE_FLAGS has been added to CXXFLAGS (--enable-coverage)]) else - AC_MSG_WARN([Code coverage functionality is currently available only with GCC suite]) - AC_MSG_ERROR([Configure: cannot continue]) + _OPAL_CHECK_SPECIFIC_CXXFLAGS(-ftest-coverage, ftest_coverage) + _OPAL_CHECK_SPECIFIC_CXXFLAGS(-fprofile-arcs, fprofile_arcs) + if test "$opal_cv_cxx_ftest_coverage" = "0" || test "opal_cv_cxx_fprofile_arcs" = "0" ; then + AC_MSG_WARN([Code coverage functionality is not currently available with $CXX]) + AC_MSG_ERROR([Configure: Cannot continue]) + fi + CLEANFILES="*.bb *.bbg ${CLEANFILES}" + OPAL_COVERAGE_FLAGS="-ftest-coverage -fprofile-arcs" fi - fi + OPAL_FLAGS_UNIQ(CXXFLAGS) + WANT_DEBUG=1 + fi # Do we want debugging? if test "$WANT_DEBUG" = "1" && test "$enable_debug_symbols" != "no" ; then CXXFLAGS="$CXXFLAGS -g" - OPAL_FLAGS_UNIQ(CXXFLAGS) AC_MSG_WARN([-g has been added to CXXFLAGS (--enable-debug)]) fi + if test "$WANT_DEBUG" = "0" ; then + OPAL_ENSURE_CONTAINS_OPTFLAGS(["$CXXFLAGS"]) + fi + # These flags are generally g++-specific; even the g++-impersonating # compilers won't accept them. OPAL_CXXFLAGS_BEFORE_PICKY="$CXXFLAGS" - if test "$WANT_PICKY_COMPILER" = 1 && test "$opal_cxx_vendor" = "gnu"; then - add="-Wall -Wundef -Wno-long-long" - - # see if -Wno-long-double works... - AC_LANG_PUSH(C++) - CXXFLAGS_orig="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $add -Wno-long-double -fstrict-prototype" - AC_CACHE_CHECK([if $CXX supports -Wno-long-double], - [opal_cv_cxx_wno_long_double], - [AC_TRY_COMPILE([], [], - [ - dnl So -Wno-long-double did not produce any errors... - dnl We will try to extract a warning regarding - dnl unrecognized or ignored options - AC_TRY_COMPILE([], [long double test;], - [ - opal_cv_cxx_wno_long_double="yes" - if test -s conftest.err ; then - dnl Yes, it should be "ignor", in order to catch ignoring and ignore - for i in unknown invalid ignor unrecognized 'not supported'; do - $GREP -iq $i conftest.err - if test "$?" = "0" ; then - opal_cv_cxx_wno_long_double="no" - break; - fi - done - fi - ], - [opal_cv_cxx_wno_long_double="no"])], - [opal_cv_cxx_wno_long_double="no"]) - ]) - - CXXFLAGS="$CXXFLAGS_orig" - AC_LANG_POP(C++) - if test "$opal_cv_cxx_wno_long_double" = "yes" ; then - add="$add -Wno-long-double" - fi - - CXXFLAGS="$CXXFLAGS $add" - OPAL_FLAGS_UNIQ(CXXFLAGS) - if test "$add" != "" ; then - AC_MSG_WARN([$add has been added to CXXFLAGS (--enable-picky)]) - fi - unset add + if test "$WANT_PICKY_COMPILER" = 1; then + _OPAL_CHECK_SPECIFIC_CXXFLAGS(-Wundef, Wundef) + _OPAL_CHECK_SPECIFIC_CXXFLAGS(-Wno-long-long, Wno_long_long, int main() { long long x; } ) + _OPAL_CHECK_SPECIFIC_CXXFLAGS(-Wno-long-double, Wno_long_double, int main () { long double x; }) + _OPAL_CHECK_SPECIFIC_CXXFLAGS(-fstrict-prototype, fstrict_prototype) + _OPAL_CHECK_SPECIFIC_CXXFLAGS(-Wall, Wall) fi - # See if this version of g++ allows -finline-functions - if test "$GXX" = "yes"; then - CXXFLAGS_orig="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS -finline-functions" - add= - AC_LANG_PUSH(C++) - AC_CACHE_CHECK([if $CXX supports -finline-functions], - [opal_cv_cxx_finline_functions], - [AC_TRY_COMPILE([], [], - [opal_cv_cxx_finline_functions="yes"], - [opal_cv_cxx_finline_functions="no"])]) - AC_LANG_POP(C++) - if test "$opal_cv_cxx_finline_functions" = "yes" ; then - add=" -finline-functions" - fi - CXXFLAGS="$CXXFLAGS_orig$add" - OPAL_FLAGS_UNIQ(CXXFLAGS) - if test "$add" != "" ; then - AC_MSG_WARN([$add has been added to CXXFLAGS]) - fi - unset add - fi + _OPAL_CHECK_SPECIFIC_CXXFLAGS(-finline-functions, finline_functions) # Make sure we can link with the C compiler if test "$opal_cv_cxx_compiler_vendor" != "microsoft"; then @@ -238,17 +200,19 @@ EOF fi fi - # config/opal_ensure_contains_optflags.m4 - OPAL_ENSURE_CONTAINS_OPTFLAGS(["$CXXFLAGS"]) - AC_MSG_CHECKING([for C++ optimization flags]) - AC_MSG_RESULT([$co_result]) - CXXFLAGS="$co_result" # bool type size and alignment - AC_LANG_PUSH(C++) AC_CHECK_SIZEOF(bool) OPAL_C_GET_ALIGNMENT(bool, OPAL_ALIGNMENT_CXX_BOOL) - AC_LANG_POP(C++) - OPAL_CHECK_CXX_IQUOTE + OPAL_ENSURE_CONTAINS_OPTFLAGS("$OPAL_CXXFLAGS_BEFORE_PICKY") + OPAL_CXXFLAGS_BEFORE_PICKY="$co_result" + + AC_MSG_CHECKING([for CXX optimization flags]) + OPAL_ENSURE_CONTAINS_OPTFLAGS(["$CXXFLAGS"]) + AC_MSG_RESULT([$co_result]) + CXXFLAGS="$co_result" + OPAL_FLAGS_UNIQ([CXXFLAGS]) + AC_MSG_RESULT(CXXFLAGS result: $CXXFLAGS) + AC_LANG_POP(C++) ]) From 37cb001fb1dad1ae56e66f2ad22abcee83517328 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Wed, 17 Feb 2021 11:41:25 -0500 Subject: [PATCH 11/40] Be pedantic to keep some compilers happy. Remove the use of anonymous unions as it is C11 and we currently only require C99. Signed-off-by: George Bosilca --- ompi/mca/coll/adapt/coll_adapt_algorithms.h | 11 ----------- ompi/mca/coll/han/coll_han.h | 20 ++++++++++---------- ompi/mca/coll/han/coll_han_module.c | 2 +- ompi/mca/coll/han/coll_han_subcomms.c | 10 +++++----- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/ompi/mca/coll/adapt/coll_adapt_algorithms.h b/ompi/mca/coll/adapt/coll_adapt_algorithms.h index cfece373043..d95d2b41004 100644 --- a/ompi/mca/coll/adapt/coll_adapt_algorithms.h +++ b/ompi/mca/coll/adapt/coll_adapt_algorithms.h @@ -14,17 +14,6 @@ #include "ompi/mca/coll/base/coll_base_functions.h" #include -typedef int (*ompi_mca_coll_adapt_ibcast_function_t)(IBCAST_ARGS); -typedef int (*ompi_mca_coll_adapt_ireduce_function_t)(IREDUCE_ARGS); - -typedef struct ompi_coll_adapt_algorithm_index_s { - int algorithm_index; - union { - ompi_mca_coll_adapt_ibcast_function_t ibcast_fn_ptr; - ompi_mca_coll_adapt_ireduce_function_t ireduce_fn_ptr; - }; -} ompi_coll_adapt_algorithm_index_t; - /* Bcast */ int ompi_coll_adapt_ibcast_register(void); int ompi_coll_adapt_ibcast_fini(void); diff --git a/ompi/mca/coll/han/coll_han.h b/ompi/mca/coll/han/coll_han.h index 7880021978e..735036e381a 100644 --- a/ompi/mca/coll/han/coll_han.h +++ b/ompi/mca/coll/han/coll_han.h @@ -247,7 +247,7 @@ typedef struct mca_coll_han_single_collective_fallback_s { mca_coll_base_module_gather_fn_t gather; mca_coll_base_module_reduce_fn_t reduce; mca_coll_base_module_scatter_fn_t scatter; - }; + } module_fn; mca_coll_base_module_t* module; } mca_coll_han_single_collective_fallback_t; @@ -316,28 +316,28 @@ OBJ_CLASS_DECLARATION(mca_coll_han_module_t); * Some defines to stick to the naming used in the other components in terms of * fallback routines */ -#define previous_allgather fallback.allgather.allgather +#define previous_allgather fallback.allgather.module_fn.allgather #define previous_allgather_module fallback.allgather.module -#define previous_allgatherv fallback.allgatherv.allgatherv +#define previous_allgatherv fallback.allgatherv.module_fn.allgatherv #define previous_allgatherv_module fallback.allgatherv.module -#define previous_allreduce fallback.allreduce.allreduce +#define previous_allreduce fallback.allreduce.module_fn.allreduce #define previous_allreduce_module fallback.allreduce.module -#define previous_barrier fallback.barrier.barrier +#define previous_barrier fallback.barrier.module_fn.barrier #define previous_barrier_module fallback.barrier.module -#define previous_bcast fallback.bcast.bcast +#define previous_bcast fallback.bcast.module_fn.bcast #define previous_bcast_module fallback.bcast.module -#define previous_reduce fallback.reduce.reduce +#define previous_reduce fallback.reduce.module_fn.reduce #define previous_reduce_module fallback.reduce.module -#define previous_gather fallback.gather.gather +#define previous_gather fallback.gather.module_fn.gather #define previous_gather_module fallback.gather.module -#define previous_scatter fallback.scatter.scatter +#define previous_scatter fallback.scatter.module_fn.scatter #define previous_scatter_module fallback.scatter.module @@ -345,7 +345,7 @@ OBJ_CLASS_DECLARATION(mca_coll_han_module_t); #define HAN_LOAD_FALLBACK_COLLECTIVE(HANM, COMM, COLL) \ do { \ if ( ((COMM)->c_coll->coll_ ## COLL ## _module) == (mca_coll_base_module_t*)(HANM) ) { \ - (COMM)->c_coll->coll_ ## COLL = (HANM)->fallback.COLL.COLL; \ + (COMM)->c_coll->coll_ ## COLL = (HANM)->fallback.COLL.module_fn.COLL; \ mca_coll_base_module_t *coll_module = (COMM)->c_coll->coll_ ## COLL ## _module; \ (COMM)->c_coll->coll_ ## COLL ## _module = (HANM)->fallback.COLL.module; \ OBJ_RETAIN((COMM)->c_coll->coll_ ## COLL ## _module); \ diff --git a/ompi/mca/coll/han/coll_han_module.c b/ompi/mca/coll/han/coll_han_module.c index fef1870182c..799994079a5 100644 --- a/ompi/mca/coll/han/coll_han_module.c +++ b/ompi/mca/coll/han/coll_han_module.c @@ -32,7 +32,7 @@ static int mca_coll_han_module_disable(mca_coll_base_module_t * module, #define CLEAN_PREV_COLL(HANDLE, NAME) \ do { \ - (HANDLE)->fallback.NAME.NAME = NULL; \ + (HANDLE)->fallback.NAME.module_fn.NAME = NULL; \ (HANDLE)->fallback.NAME.module = NULL; \ } while (0) diff --git a/ompi/mca/coll/han/coll_han_subcomms.c b/ompi/mca/coll/han/coll_han_subcomms.c index 580940ec6ac..bb9397c008a 100644 --- a/ompi/mca/coll/han/coll_han_subcomms.c +++ b/ompi/mca/coll/han/coll_han_subcomms.c @@ -26,17 +26,17 @@ #include "coll_han.h" #include "coll_han_dynamic.h" -#define HAN_SUBCOM_SAVE_COLLECTIVE(FALLBACKS, COMM, HANM, COLL) \ +#define HAN_SUBCOM_SAVE_COLLECTIVE(FALLBACKS, COMM, HANM, COLL) \ do { \ - (FALLBACKS).COLL.COLL = (COMM)->c_coll->coll_ ## COLL; \ + (FALLBACKS).COLL.module_fn.COLL = (COMM)->c_coll->coll_ ## COLL; \ (FALLBACKS).COLL.module = (COMM)->c_coll->coll_ ## COLL ## _module; \ - (COMM)->c_coll->coll_ ## COLL = (HANM)->fallback.COLL.COLL; \ + (COMM)->c_coll->coll_ ## COLL = (HANM)->fallback.COLL.module_fn.COLL; \ (COMM)->c_coll->coll_ ## COLL ## _module = (HANM)->fallback.COLL.module; \ } while(0) -#define HAN_SUBCOM_LOAD_COLLECTIVE(FALLBACKS, COMM, HANM, COLL) \ +#define HAN_SUBCOM_LOAD_COLLECTIVE(FALLBACKS, COMM, HANM, COLL) \ do { \ - (COMM)->c_coll->coll_ ## COLL = (FALLBACKS).COLL.COLL; \ + (COMM)->c_coll->coll_ ## COLL = (FALLBACKS).COLL.module_fn.COLL; \ (COMM)->c_coll->coll_ ## COLL ## _module = (FALLBACKS).COLL.module; \ } while(0) From 17d8ba0949019c0987fc7aeb20b1540d04281258 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Wed, 17 Feb 2021 07:53:25 -0800 Subject: [PATCH 12/40] Silence trivial warning Update PMIx/PRRTE pointers Signed-off-by: Ralph Castain --- 3rd-party/openpmix | 2 +- 3rd-party/prrte | 2 +- config/ompi_setup_prrte.m4 | 5 +++++ config/opal_config_pmix.m4 | 5 +++++ opal/mca/base/mca_base_var.c | 2 ++ opal/mca/pmix/base/pmix_base_fns.c | 19 ++++--------------- test/simple/intercomm_create.c | 4 ++-- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/3rd-party/openpmix b/3rd-party/openpmix index 7b003fa9afc..f7777615c26 160000 --- a/3rd-party/openpmix +++ b/3rd-party/openpmix @@ -1 +1 @@ -Subproject commit 7b003fa9afc4a455763e002c685d00c8b131eb72 +Subproject commit f7777615c264184cff3ee77cbb2847522404566e diff --git a/3rd-party/prrte b/3rd-party/prrte index 5fde7cce32d..a248bc690ab 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit 5fde7cce32d15f37f451e0b90a19485758f5e8a3 +Subproject commit a248bc690abd99d8389d7c27fc735d91f91ae0f3 diff --git a/config/ompi_setup_prrte.m4 b/config/ompi_setup_prrte.m4 index b953b6c8e9b..f36120808c3 100644 --- a/config/ompi_setup_prrte.m4 +++ b/config/ompi_setup_prrte.m4 @@ -18,6 +18,7 @@ # Copyright (c) 2019-2020 Intel, Inc. All rights reserved. # Copyright (c) 2020 Amazon.com, Inc. or its affiliates. # All Rights reserved. +# Copyright (c) 2021 Nanook Consulting. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -143,6 +144,10 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [ [internal_prrte_args="--enable-prte-ft $internal_prrte_args"], []) + if test "$WANT_DEBUG" = "1"; then + internal_prrte_args="$internal_prrte_args --enable-debug" + fi + # Pass all our compiler/linker flags to PRRTE, so that it # picks up how to build an internal HWLOC, libevent, and PMIx, plus # picks up any user-specified compiler flags from the master diff --git a/config/opal_config_pmix.m4 b/config/opal_config_pmix.m4 index d77f98d59d2..49b0b5de8da 100644 --- a/config/opal_config_pmix.m4 +++ b/config/opal_config_pmix.m4 @@ -21,6 +21,7 @@ dnl Copyright (c) 2020 Triad National Security, LLC. All rights dnl reserved. dnl Copyright (c) 2020 Amazon.com, Inc. or its affiliates. All Rights dnl reserved. +dnl Copyright (c) 2021 Nanook Consulting. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -86,6 +87,10 @@ AC_DEFUN([OPAL_CONFIG_PMIX], [ AS_IF([test ! -z "$internal_pmix_libs"], [internal_pmix_args="$internal_pmix_args --with-prte-extra-lib=\"$internal_pmix_libs\""]) + if test "$WANT_DEBUG" = "1"; then + internal_pmix_args="$internal_pmix_args --enable-debug" + fi + # Pass all our compiler/linker flags to PMIx, so that it # picks up how to build an internal HWLOC and libevent, plus # picks up any user-specified compiler flags from the master diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index 331400c5e2e..0bb82654920 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -21,6 +21,7 @@ * Copyright (c) 2018 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2020 Google, LLC. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -417,6 +418,7 @@ int mca_base_var_load_extra_files(char* files, bool rel_path_search) { resolve_relative_paths(&tmp1, mca_base_param_file_path, rel_path_search, &mca_base_var_files, OPAL_ENV_SEP); read_files (tmp1, &mca_base_var_file_values, ','); free(tmp1); + return OPAL_SUCCESS; } int mca_base_var_cache_files(bool rel_path_search) diff --git a/opal/mca/pmix/base/pmix_base_fns.c b/opal/mca/pmix/base/pmix_base_fns.c index a21e8157263..b74a88669ad 100644 --- a/opal/mca/pmix/base/pmix_base_fns.c +++ b/opal/mca/pmix/base/pmix_base_fns.c @@ -8,6 +8,7 @@ * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -131,25 +132,13 @@ int opal_pmix_convert_nspace(opal_jobid_t *jobid, pmix_nspace_t nspace) /* set a default */ if (NULL != jobid) { - *jobid = OPAL_JOBID_INVALID; + *jobid = OPAL_JOBID_WILDCARD; } /* if the nspace is empty, there is nothing more to do */ if (0 == strlen(nspace)) { return OPAL_SUCCESS; } - if (NULL != strstr(nspace, "JOBID_WILDCARD")) { - if (NULL != jobid) { - *jobid = OPAL_JOBID_WILDCARD; - } - return OPAL_SUCCESS; - } - if (NULL != strstr(nspace, "JOBID_INVALID")) { - if (NULL != jobid) { - *jobid = OPAL_JOBID_INVALID; - } - return OPAL_SUCCESS; - } /* cycle across our list of known nspace's */ OPAL_LIST_FOREACH(nptr, &localnspaces, opal_nptr_t) { @@ -163,12 +152,12 @@ int opal_pmix_convert_nspace(opal_jobid_t *jobid, pmix_nspace_t nspace) /* if we get here, we don't know this nspace */ /* find the "." at the end that indicates the child job */ - if (NULL != (p = strrchr(nspace, '.'))) { + if (NULL != (p = strrchr(nspace, '@'))) { *p = '\0'; } OPAL_HASH_STR(nspace, hash32); if (NULL != p) { - *p = '.'; + *p = '@'; ++p; localjob = strtoul(p, NULL, 10); } diff --git a/test/simple/intercomm_create.c b/test/simple/intercomm_create.c index 8e6e2cc3b8c..8e76958a212 100644 --- a/test/simple/intercomm_create.c +++ b/test/simple/intercomm_create.c @@ -23,7 +23,7 @@ void ompitest_warning( char* filename, int lineno, const char* fmt, ... ) va_list va_list; va_start(va_list, fmt); - opal_vasprintf( &buf, fmt, va_list ); + vasprintf( &buf, fmt, va_list ); va_end(va_list); printf( "*warning* %s:%d %s\n", filename, lineno, buf ); free(buf); @@ -35,7 +35,7 @@ void ompitest_error( char* filename, int lineno, const char* fmt, ... ) va_list va_list; va_start(va_list, fmt); - opal_vasprintf( &buf, fmt, va_list ); + vasprintf( &buf, fmt, va_list ); va_end(va_list); printf( "*error* %s:%d %s\n", filename, lineno, buf ); free(buf); From 9540b7f5c692f7b3ca6bfc96b7fce3ae4b43ebe7 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Wed, 17 Feb 2021 12:58:36 -0800 Subject: [PATCH 13/40] Update ignores Signed-off-by: Ralph Castain --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index b41cefd4a2d..ad8028633e7 100644 --- a/.gitignore +++ b/.gitignore @@ -265,6 +265,14 @@ ompi/mpi/tool/profile/*.c ompi/mpiext/affinity/c/OMPI_Affinity_str.3 ompi/mpiext/affinity/c/example +ompi/mpiext/ftmpi/c/profile/pcomm_agree.c +ompi/mpiext/ftmpi/c/profile/pcomm_failure_ack.c +ompi/mpiext/ftmpi/c/profile/pcomm_failure_get_acked.c +ompi/mpiext/ftmpi/c/profile/pcomm_iagree.c +ompi/mpiext/ftmpi/c/profile/pcomm_is_revoked.c +ompi/mpiext/ftmpi/c/profile/pcomm_revoke.c +ompi/mpiext/ftmpi/c/profile/pcomm_shrink.c + ompi/mpiext/example/tests/progress_c ompi/mpiext/example/tests/progress_mpifh ompi/mpiext/example/tests/progress_usempi From f84f373272fa8e627d0ed7e6b97c44e42831dfdc Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Thu, 18 Feb 2021 07:34:09 -0800 Subject: [PATCH 14/40] Fix MTT - update PMIx/PRRTE pointers Signed-off-by: Ralph Castain --- 3rd-party/openpmix | 2 +- 3rd-party/prrte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3rd-party/openpmix b/3rd-party/openpmix index f7777615c26..55072c2af6e 160000 --- a/3rd-party/openpmix +++ b/3rd-party/openpmix @@ -1 +1 @@ -Subproject commit f7777615c264184cff3ee77cbb2847522404566e +Subproject commit 55072c2af6e23a64ffb079cc4e47daaf5b6cbc03 diff --git a/3rd-party/prrte b/3rd-party/prrte index a248bc690ab..a949374d90e 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit a248bc690abd99d8389d7c27fc735d91f91ae0f3 +Subproject commit a949374d90e0f43ccf97c2d31f7644e79e6ca1fd From 916c29a21a35b0f48e101da2de02076e9b6365b5 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Thu, 18 Feb 2021 23:37:22 -0500 Subject: [PATCH 15/40] Prevent the establishment of new BTL connections during matching handshake Prevent a "deadlock" scenario, when one of the processes leave the matching before the ack has been sent to the peer. Such a scenario has been described by @bwbarrett in #8498. Signed-off-by: George Bosilca --- ompi/mca/pml/ob1/pml_ob1_recvfrag.c | 6 +++--- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 11 ++++++----- ompi/mca/pml/ob1/pml_ob1_recvreq.h | 21 +++++++++++++++------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c index fe6e1a4d6c9..51239e1210c 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvfrag.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvfrag.c @@ -423,7 +423,7 @@ int mca_pml_ob1_revoke_comm( struct ompi_communicator_t* ompi_comm, bool coll_on "ob1_revoke_comm: sending NACK to %d", hdr->hdr_rndv.hdr_match.hdr_src)); /* Send a ACK with a NULL request to signify revocation */ proc = mca_pml_ob1_peer_lookup(ompi_comm, hdr->hdr_rndv.hdr_match.hdr_src); - mca_pml_ob1_recv_request_ack_send(proc->ompi_proc, hdr->hdr_rndv.hdr_src_req.lval, NULL, 0, 0, false); + mca_pml_ob1_recv_request_ack_send(NULL, proc->ompi_proc, hdr->hdr_rndv.hdr_src_req.lval, NULL, 0, 0, false); } else { /* if it's a TYPE_MATCH, the sender is not expecting anything @@ -605,7 +605,7 @@ void mca_pml_ob1_recv_frag_callback_match (mca_btl_base_module_t *btl, ); } - /* no need to check if complete we know we are.. */ + /* no need to check if complete we know we are. */ /* don't need a rmb as that is for checking */ recv_request_pml_complete(match); } @@ -1074,7 +1074,7 @@ static int mca_pml_ob1_recv_frag_match (mca_btl_base_module_t *btl, MCA_PML_OB1_HDR_TYPE_RNDV == hdr->hdr_common.hdr_type ); /* Send a ACK with a NULL request to signify revocation */ mca_pml_ob1_rendezvous_hdr_t* hdr_rndv = (mca_pml_ob1_rendezvous_hdr_t*) hdr; - mca_pml_ob1_recv_request_ack_send(proc->ompi_proc, hdr_rndv->hdr_src_req.lval, NULL, 0, 0, false); + mca_pml_ob1_recv_request_ack_send(NULL, proc->ompi_proc, hdr_rndv->hdr_src_req.lval, NULL, 0, 0, false); OPAL_OUTPUT_VERBOSE((2, ompi_ftmpi_output_handle, "Recvfrag: comm %d is revoked or collectives force errors, sending a NACK to the RDV/RGET match from %d\n", hdr->hdr_ctx, hdr->hdr_src)); } else { diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 81bd98647b1..8f3dfeece3e 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -285,6 +285,7 @@ int mca_pml_ob1_recv_request_ack_send_btl( static int mca_pml_ob1_recv_request_ack( mca_pml_ob1_recv_request_t* recvreq, + mca_btl_base_module_t* btl, mca_pml_ob1_rendezvous_hdr_t* hdr, size_t bytes_received) { @@ -345,12 +346,12 @@ static int mca_pml_ob1_recv_request_ack( /* let know to shedule function there is no need to put ACK flag. If not all message went over * RDMA then we cancel the GET protocol in order to switch back to send/recv. In this case send - * back the remote send request, the peer kept a poointer to the frag locally. In the future we + * back the remote send request, the peer kept a pointer to the frag locally. In the future we * might want to cancel the fragment itself, in which case we will have to send back the remote * fragment instead of the remote request. */ recvreq->req_ack_sent = true; - return mca_pml_ob1_recv_request_ack_send(proc, hdr->hdr_src_req.lval, + return mca_pml_ob1_recv_request_ack_send(btl, proc, hdr->hdr_src_req.lval, recvreq, recvreq->req_send_offset, 0, recvreq->req_send_offset == bytes_received); } @@ -386,7 +387,7 @@ static int mca_pml_ob1_recv_request_get_frag_failed (mca_pml_ob1_rdma_frag_t *fr } /* tell peer to fall back on send for this region */ - rc = mca_pml_ob1_recv_request_ack_send(proc, frag->rdma_hdr.hdr_rget.hdr_rndv.hdr_src_req.lval, + rc = mca_pml_ob1_recv_request_ack_send(NULL, proc, frag->rdma_hdr.hdr_rget.hdr_rndv.hdr_src_req.lval, recvreq, frag->rdma_offset, frag->rdma_length, false); MCA_PML_OB1_RDMA_FRAG_RETURN(frag); return rc; @@ -710,7 +711,7 @@ void mca_pml_ob1_recv_request_progress_rget( mca_pml_ob1_recv_request_t* recvreq if (mca_pml_ob1_cuda_need_buffers(recvreq, btl)) #endif /* OPAL_CUDA_SUPPORT */ { - mca_pml_ob1_recv_request_ack(recvreq, &hdr->hdr_rndv, 0); + mca_pml_ob1_recv_request_ack(recvreq, btl, &hdr->hdr_rndv, 0); return; } } @@ -853,7 +854,7 @@ void mca_pml_ob1_recv_request_progress_rndv( mca_pml_ob1_recv_request_t* recvreq recvreq->remote_req_send = hdr->hdr_rndv.hdr_src_req; recvreq->req_rdma_offset = bytes_received; MCA_PML_OB1_RECV_REQUEST_MATCHED(recvreq, &hdr->hdr_match); - mca_pml_ob1_recv_request_ack(recvreq, &hdr->hdr_rndv, bytes_received); + mca_pml_ob1_recv_request_ack(recvreq, btl, &hdr->hdr_rndv, bytes_received); /** * The PUT protocol do not attach any data to the original request. * Therefore, we might want to avoid unpacking if there is nothing to diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.h b/ompi/mca/pml/ob1/pml_ob1_recvreq.h index bd3aff3f95a..b0b89388dea 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.h +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.h @@ -431,9 +431,11 @@ int mca_pml_ob1_recv_request_ack_send_btl(ompi_proc_t* proc, mca_bml_base_btl_t* bml_btl, uint64_t hdr_src_req, void *hdr_dst_req, uint64_t hdr_rdma_offset, uint64_t size, bool nordma); -static inline int mca_pml_ob1_recv_request_ack_send(ompi_proc_t* proc, - uint64_t hdr_src_req, void *hdr_dst_req, uint64_t hdr_send_offset, - uint64_t size, bool nordma) +static inline int +mca_pml_ob1_recv_request_ack_send(mca_btl_base_module_t* btl, + ompi_proc_t* proc, + uint64_t hdr_src_req, void *hdr_dst_req, uint64_t hdr_send_offset, + uint64_t size, bool nordma) { size_t i; mca_bml_base_btl_t* bml_btl; @@ -441,11 +443,18 @@ static inline int mca_pml_ob1_recv_request_ack_send(ompi_proc_t* proc, assert (NULL != endpoint); + /** + * If a btl has been requested then send the ack using that specific device, otherwise + * we are free to pick one. We need to force the ack to go over a specific BTL, in order + * to prevent the establishement of new connections during the matching handshake. + */ for(i = 0; i < mca_bml_base_btl_array_get_size(&endpoint->btl_eager); i++) { bml_btl = mca_bml_base_btl_array_get_next(&endpoint->btl_eager); - if(mca_pml_ob1_recv_request_ack_send_btl(proc, bml_btl, hdr_src_req, - hdr_dst_req, hdr_send_offset, size, nordma) == OMPI_SUCCESS) - return OMPI_SUCCESS; + if( (NULL == btl) || (btl == bml_btl->btl) ) { + if(mca_pml_ob1_recv_request_ack_send_btl(proc, bml_btl, hdr_src_req, + hdr_dst_req, hdr_send_offset, size, nordma) == OMPI_SUCCESS) + return OMPI_SUCCESS; + } } MCA_PML_OB1_ADD_ACK_TO_PENDING(proc, hdr_src_req, hdr_dst_req, From 8ea760c266e1fcd1dc69018e05bc75f6ff39bd43 Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Thu, 18 Feb 2021 20:19:24 -0500 Subject: [PATCH 16/40] Remove residual libompi_mpir library. Signed-off-by: Austen Lauria --- ompi/runtime/Makefile.am | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/ompi/runtime/Makefile.am b/ompi/runtime/Makefile.am index e452544844c..61b923db432 100644 --- a/ompi/runtime/Makefile.am +++ b/ompi/runtime/Makefile.am @@ -32,6 +32,7 @@ headers += \ runtime/ompi_rte.h lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ + runtime/ompi_mpi_init.c \ runtime/ompi_mpi_abort.c \ runtime/ompi_mpi_dynamics.c \ runtime/ompi_mpi_finalize.c \ @@ -41,13 +42,3 @@ lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ runtime/ompi_info_support.c \ runtime/ompi_spc.c \ runtime/ompi_rte.c - -# The MPIR portion of the library must be built with flags to -# enable stepping out of MPI_INIT into main. -# Use an intermediate library to isolate the debug object. -noinst_LTLIBRARIES += libompi_mpir.la -libompi_mpir_la_SOURCES = \ - runtime/ompi_mpi_init.c -libompi_mpir_la_CFLAGS = $(MPIR_UNWIND_CFLAGS) - -lib@OMPI_LIBMPI_NAME@_la_LIBADD += libompi_mpir.la From 5bc429c1712af9dfea7f56c9f99fb6dffe740a89 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Fri, 19 Feb 2021 16:09:23 -0800 Subject: [PATCH 17/40] Update PRRTE pointer Signed-off-by: Ralph Castain --- 3rd-party/prrte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rd-party/prrte b/3rd-party/prrte index a949374d90e..8bb249dc188 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit a949374d90e0f43ccf97c2d31f7644e79e6ca1fd +Subproject commit 8bb249dc188c5bb59e42c201b41306298e8fdaa9 From edb1768e1fe474d1f873aab6615e8b75211b78d3 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Sat, 20 Feb 2021 12:18:05 -0800 Subject: [PATCH 18/40] Update PRRTE pointer to fix IBM MTT Signed-off-by: Ralph Castain --- 3rd-party/prrte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rd-party/prrte b/3rd-party/prrte index 8bb249dc188..27c8979069f 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit 8bb249dc188c5bb59e42c201b41306298e8fdaa9 +Subproject commit 27c8979069f9c1659122135e4b6b7145f7568c1e From 772bc830c44c92efb92fe87e771bb6d59e8b0ee0 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Wed, 17 Feb 2021 07:53:25 -0800 Subject: [PATCH 19/40] Remove stale OPAL dss and opal_tree code With the switch to PRRTE, there is no remaining need or use for the dss - it is all in PRRTE now. The opal_tree class is also no longer used anywhere. Signed-off-by: Ralph Castain --- .gitignore | 9 - 3rd-party/prrte | 2 +- configure.ac | 1 - contrib/check_unnecessary_headers.sh | 8 +- ompi/communicator/comm.c | 22 +- ompi/communicator/comm_cid.c | 36 +- ompi/communicator/ft/comm_ft.c | 3 +- ompi/communicator/ft/comm_ft_detector.c | 3 +- ompi/dpm/dpm.c | 4 +- ompi/errhandler/errhandler.c | 26 +- ompi/interlib/interlib.c | 3 +- ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c | 34 +- .../pessimist/vprotocol_pessimist_eventlog.c | 3 +- ompi/proc/proc.c | 58 +- ompi/proc/proc.h | 7 +- ompi/runtime/ompi_rte.c | 2 - ompi/runtime/ompi_rte.h | 2 +- opal/Makefile.am | 1 - opal/class/Makefile.am | 3 +- opal/class/opal_tree.c | 707 ------------- opal/class/opal_tree.h | 530 ---------- opal/dss/Makefile.am | 41 - opal/dss/dss.h | 509 --------- opal/dss/dss_compare.c | 494 --------- opal/dss/dss_copy.c | 387 ------- opal/dss/dss_dump.c | 60 -- opal/dss/dss_internal.h | 551 ---------- opal/dss/dss_internal_functions.c | 133 --- opal/dss/dss_load_unload.c | 480 --------- opal/dss/dss_lookup.c | 35 - opal/dss/dss_open_close.c | 592 ----------- opal/dss/dss_pack.c | 776 -------------- opal/dss/dss_peek.c | 116 --- opal/dss/dss_print.c | 864 ---------------- opal/dss/dss_register.c | 79 -- opal/dss/dss_types.h | 230 ---- opal/dss/dss_unpack.c | 931 ----------------- opal/mca/btl/sm/btl_sm_module.c | 2 +- opal/mca/btl/sm/btl_sm_xpmem.c | 3 +- opal/mca/btl/ugni/btl_ugni.h | 3 + opal/mca/btl/ugni/btl_ugni_add_procs.c | 3 +- opal/mca/btl/ugni/btl_ugni_atomic.c | 25 +- opal/mca/btl/ugni/btl_ugni_init.c | 2 +- opal/mca/hwloc/base/base.h | 3 +- opal/mca/hwloc/base/hwloc_base_frame.c | 2 +- opal/mca/pmix/base/pmix_base_fns.c | 402 ------- opal/mca/pmix/pmix-internal.h | 20 +- opal/runtime/opal_info_support.c | 2 +- opal/runtime/opal_init.c | 9 +- opal/runtime/opal_params.c | 8 +- opal/util/proc.h | 2 +- oshmem/mca/memheap/base/memheap_base_mkey.c | 91 +- oshmem/op/op.h | 2 +- oshmem/proc/proc.c | 2 +- oshmem/proc/proc.h | 2 +- test/Makefile.am | 2 +- test/class/Makefile.am | 7 - test/class/opal_tree.c | 333 ------ test/dss/Makefile.am | 15 - test/dss/dss_buffer.c | 979 ------------------ test/dss/dss_cmp.c | 621 ----------- test/dss/dss_copy.c | 468 --------- test/dss/dss_payload.c | 229 ---- test/dss/dss_print.c | 508 --------- 64 files changed, 208 insertions(+), 11279 deletions(-) delete mode 100644 opal/class/opal_tree.c delete mode 100644 opal/class/opal_tree.h delete mode 100644 opal/dss/Makefile.am delete mode 100644 opal/dss/dss.h delete mode 100644 opal/dss/dss_compare.c delete mode 100644 opal/dss/dss_copy.c delete mode 100644 opal/dss/dss_dump.c delete mode 100644 opal/dss/dss_internal.h delete mode 100644 opal/dss/dss_internal_functions.c delete mode 100644 opal/dss/dss_load_unload.c delete mode 100644 opal/dss/dss_lookup.c delete mode 100644 opal/dss/dss_open_close.c delete mode 100644 opal/dss/dss_pack.c delete mode 100644 opal/dss/dss_peek.c delete mode 100644 opal/dss/dss_print.c delete mode 100644 opal/dss/dss_register.c delete mode 100644 opal/dss/dss_types.h delete mode 100644 opal/dss/dss_unpack.c delete mode 100644 test/class/opal_tree.c delete mode 100644 test/dss/Makefile.am delete mode 100644 test/dss/dss_buffer.c delete mode 100644 test/dss/dss_cmp.c delete mode 100644 test/dss/dss_copy.c delete mode 100644 test/dss/dss_payload.c delete mode 100644 test/dss/dss_print.c diff --git a/.gitignore b/.gitignore index ad8028633e7..caecc6b65b7 100644 --- a/.gitignore +++ b/.gitignore @@ -640,15 +640,6 @@ test/datatype/position_noncontig test/datatype/unpack_ooo test/datatype/unpack_hetero -test/dss/dss_buffer -test/dss/dss_copy -test/dss/dss_size -test/dss/dss_cmp -test/dss/dss_release -test/dss/dss_payload -test/dss/dss_set_get -test/dss/dss_print - test/event/signal-test test/event/event-test test/event/time-test diff --git a/3rd-party/prrte b/3rd-party/prrte index 27c8979069f..b56ef1ad62d 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit 27c8979069f9c1659122135e4b6b7145f7568c1e +Subproject commit b56ef1ad62d81dbd5fe08f27655237fc3d6ab4ce diff --git a/configure.ac b/configure.ac index b8f2fa97f54..554788b3937 100644 --- a/configure.ac +++ b/configure.ac @@ -1489,7 +1489,6 @@ AC_CONFIG_FILES([ test/event/Makefile test/asm/Makefile test/datatype/Makefile - test/dss/Makefile test/class/Makefile test/mpool/Makefile test/support/Makefile diff --git a/contrib/check_unnecessary_headers.sh b/contrib/check_unnecessary_headers.sh index af2c786ed8d..d4632be7926 100644 --- a/contrib/check_unnecessary_headers.sh +++ b/contrib/check_unnecessary_headers.sh @@ -91,10 +91,10 @@ SEARCH_HEADER[6]="opal/class/opal_list.h opal_list_t opal_list_item_t opal_list_ SEARCH_HEADER[7]="opal/class/opal_object.h opal_object_t opal_class_t opal_construct_t opal_destruct_t OPAL_OBJ_STATIC_INIT OBJ_CLASS OBJ_CLASS_INSTANCE OBJ_CLASS_DECLARATION OBJ_NEW OBJ_RETAIN OBJ_RELEASE OBJ_CONSTRUCT OBJ_DESTRUCT opal_class_initialize opal_class_finalize opal_obj_run_constructors opal_obj_run_destructors opal_obj_new opal_obj_update" SEARCH_HEADER[8]="opal/class/opal_pointer_array.h opal_pointer_array_t opal_pointer_array_init opal_pointer_array_add opal_pointer_array_set_item opal_pointer_array_get_item opal_pointer_array_get_size opal_pointer_array_set_size opal_pointer_array_test_and_set_item opal_pointer_array_remove_all" SEARCH_HEADER[9]="opal/class/opal_value_array.h opal_value_array_t opal_value_array_init opal_value_array_reserve opal_value_array_get_size opal_value_array_set_size OPAL_VALUE_ARRAY_GET_ITEM opal_value_array_get_item OPAL_VALUE_ARRAY_SET_ITEM opal_value_array_set_item opal_value_array_append_item opal_value_array_remove_item OPAL_VALUE_ARRAY_GET_BASE" -SEARCH_HEADER[10]="opal/constants.h OPAL_SUCCESS OPAL_ERROR OPAL_ERR_ OPAL_EXISTS" -SEARCH_HEADER[11]="opal/dss/dss.h opal_dss_open opal_dss_close opal_dss_t opal_dss" -SEARCH_HEADER[12]="opal/dss/dss_internal.h OPAL_DSS_DEFAULT_INITIAL_SIZE OPAL_DSS_DEFAULT_THRESHOLD_SIZE DSS_TYPE_SIZE_T DSS_TYPE_BOOL DSS_TYPE_INT DSS_TYPE_UINT DSS_TYPE_PID_T UNPACK_SIZE_MISMATCH opal_dss_type_info_t opal_dss_initialized opal_dss_debug opal_dss_verbose opal_dss_initial_size opal_dss_threshold_size opal_dss_types opal_dss_num_reg_types opal_dss_set opal_dss_get opal_dss_pack opal_dss_unpack opal_dss_copy opal_dss_compare opal_dss_print opal_dss_dump opal_dss_size opal_dss_peek opal_dss_unload opal_dss_load opal_dss_copy_payload opal_dss_register opal_dss_release opal_dss_lookup_data_type opal_dss_dump_data_types opal_dss_pack_buffer opal_dss_unpack_buffer opal_dss_std_copy opal_dss_compare_ opal_dss_std_size opal_dss_size_ opal_dss_print_ opal_dss_std_release opal_dss_std_obj_release opal_dss_release_byte_object opal_dss_buffer_extend opal_dss_too_small opal_dss_find_type opal_dss_store_data_type opal_dss_get_data_type" -SEARCH_HEADER[13]="opal/dss/dss_types.h OPAL_DATA_TYPE_T OPAL_DSS_ID_MAX OPAL_DSS_ID_INVALID OPAL_UNDEF OPAL_BYTE OPAL_BOOL OPAL_STRING OPAL_SIZE OPAL_PID OPAL_INT OPAL_UINT OPAL_BYTE_OBJECT OPAL_DATA_TYPE OPAL_NULL OPAL_DATA_VALUE OPAL_PSTAT OPAL_DSS_ID_DYNAMIC OPAL_VALUE1_GREATER OPAL_VALUE2_GREATER OPAL_EQUAL opal_dss_value_t OPAL_DATA_VALUE_EMPTY OPAL_PSTAT_MAX_STRING_LEN opal_pstats_t OPAL_DSS_STRUCTURED OPAL_DSS_UNSTRUCTURED OPAL_DSS_BUFFER_NON_DESC OPAL_DSS_BUFFER_FULLY_DESC OPAL_DSS_BUFFER_TYPE_HTON OPAL_DSS_BUFFER_TYPE_NTOH opal_buffer_t" +SEARCH_HEADER[10]="opal/constants.h OPAL_EXISTS" +SEARCH_HEADER[11]="OPAL_SUCCESS" +SEARCH_HEADER[12]="OPAL_ERROR" +SEARCH_HEADER[13]="OPAL_ERR_" SEARCH_HEADER[14]="opal/hash_string.h OPAL_HASH_STR" SEARCH_HEADER[15]="opal/mca/crs.h OPAL_CRS_ opal_crs" SEARCH_HEADER[16]="opal/opal_socket_errno.h opal_socket_errno" diff --git a/ompi/communicator/comm.c b/ompi/communicator/comm.c index a2b07393fe1..4277d67acca 100644 --- a/ompi/communicator/comm.c +++ b/ompi/communicator/comm.c @@ -23,6 +23,7 @@ * Copyright (c) 2014-2020 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -36,7 +37,6 @@ #include "ompi/constants.h" #include "opal/mca/hwloc/base/base.h" -#include "opal/dss/dss.h" #include "opal/mca/pmix/pmix-internal.h" #include "opal/util/string_copy.h" @@ -1549,7 +1549,7 @@ int ompi_comm_get_rprocs ( ompi_communicator_t *local_comm, ompi_proc_t **rprocs=NULL; int32_t size_len; int int_len=0, rlen; - opal_buffer_t *sbuf=NULL, *rbuf=NULL; + pmix_data_buffer_t *sbuf=NULL, *rbuf=NULL; void *sendbuf=NULL; char *recvbuf; ompi_proc_t **proc_list = NULL; @@ -1559,7 +1559,7 @@ int ompi_comm_get_rprocs ( ompi_communicator_t *local_comm, local_size = ompi_comm_size (local_comm); if (local_rank == local_leader) { - sbuf = OBJ_NEW(opal_buffer_t); + PMIX_DATA_BUFFER_CREATE(sbuf); if (NULL == sbuf) { rc = OMPI_ERR_OUT_OF_RESOURCE; goto err_exit; @@ -1579,7 +1579,9 @@ int ompi_comm_get_rprocs ( ompi_communicator_t *local_comm, if ( OMPI_SUCCESS != rc ) { goto err_exit; } - if (OPAL_SUCCESS != (rc = opal_dss.unload(sbuf, &sendbuf, &size_len))) { + PMIX_DATA_BUFFER_UNLOAD(sbuf, sendbuf, size_len); + if (NULL == sendbuf) { + rc = OMPI_ERR_UNPACK_FAILURE; goto err_exit; } @@ -1662,21 +1664,19 @@ int ompi_comm_get_rprocs ( ompi_communicator_t *local_comm, goto err_exit; } - rbuf = OBJ_NEW(opal_buffer_t); + PMIX_DATA_BUFFER_CREATE(rbuf); if (NULL == rbuf) { rc = OMPI_ERR_OUT_OF_RESOURCE; goto err_exit; } - if (OMPI_SUCCESS != (rc = opal_dss.load(rbuf, recvbuf, rlen))) { - goto err_exit; - } + PMIX_DATA_BUFFER_LOAD(rbuf, recvbuf, rlen); /* decode the names into a proc-list -- will never add a new proc as the result of this operation, so no need to get the newprocs list or call PML add_procs(). */ rc = ompi_proc_unpack(rbuf, rsize, &rprocs, NULL, NULL); - OBJ_RELEASE(rbuf); + PMIX_DATA_BUFFER_RELEASE(rbuf); if (OMPI_SUCCESS != rc) { goto err_exit; } @@ -1713,10 +1713,10 @@ int ompi_comm_get_rprocs ( ompi_communicator_t *local_comm, } /* make sure the buffers have been released */ if (NULL != sbuf) { - OBJ_RELEASE(sbuf); + PMIX_DATA_BUFFER_RELEASE(sbuf); } if (NULL != rbuf) { - OBJ_RELEASE(rbuf); + PMIX_DATA_BUFFER_RELEASE(rbuf); } if ( NULL != proc_list ) { free ( proc_list ); diff --git a/ompi/communicator/comm_cid.c b/ompi/communicator/comm_cid.c index 846e9badc7b..9015f26bbeb 100644 --- a/ompi/communicator/comm_cid.c +++ b/ompi/communicator/comm_cid.c @@ -23,6 +23,7 @@ * Copyright (c) 2016 IBM Corporation. All rights reserved. * Copyright (c) 2017 Mellanox Technologies. All rights reserved. * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -32,7 +33,6 @@ #include "ompi_config.h" -#include "opal/dss/dss.h" #include "opal/mca/pmix/base/base.h" #include "opal/util/printf.h" @@ -953,28 +953,28 @@ static int ompi_comm_allreduce_pmix_reduce_complete (ompi_comm_request_t *reques int32_t size_count = context->count; pmix_info_t info; pmix_pdata_t pdat; - opal_buffer_t sbuf; + pmix_data_buffer_t sbuf; int rc; int bytes_written; char *key; const int output_id = 0; const int verbosity_level = 1; - OBJ_CONSTRUCT(&sbuf, opal_buffer_t); + PMIX_DATA_BUFFER_CONSTRUCT(&sbuf); - if (OPAL_SUCCESS != (rc = opal_dss.pack(&sbuf, context->tmpbuf, (int32_t)context->count, OPAL_INT))) { - OBJ_DESTRUCT(&sbuf); - opal_output_verbose (verbosity_level, output_id, "pack failed. rc %d\n", rc); - return rc; + rc = PMIx_Data_pack(NULL, &sbuf, context->tmpbuf, (int32_t)context->count, PMIX_INT); + if (PMIX_SUCCESS != rc) { + PMIX_DATA_BUFFER_DESTRUCT(&sbuf); + opal_output_verbose (verbosity_level, output_id, "pack failed: %s\n", PMIx_Error_string(rc)); + return opal_pmix_convert_status(rc); } PMIX_PDATA_CONSTRUCT(&pdat); PMIX_INFO_CONSTRUCT(&info); info.value.type = PMIX_BYTE_OBJECT; - opal_dss.unload(&sbuf, (void**)&info.value.data.bo.bytes, &rc); - info.value.data.bo.size = rc; - OBJ_DESTRUCT(&sbuf); + PMIX_DATA_BUFFER_UNLOAD(&sbuf, info.value.data.bo.bytes, info.value.data.bo.size); + PMIX_DATA_BUFFER_DESTRUCT(&sbuf); bytes_written = opal_asprintf(&key, cid_context->send_first ? "%s:%s:send:%d" @@ -1015,21 +1015,21 @@ static int ompi_comm_allreduce_pmix_reduce_complete (ompi_comm_request_t *reques rc = opal_pmix_base_exchange(&info, &pdat, 600); // give them 10 minutes PMIX_INFO_DESTRUCT(&info); if (OPAL_SUCCESS != rc) { - OBJ_DESTRUCT(&pdat); + PMIX_PDATA_DESTRUCT(&pdat); return rc; } if (PMIX_BYTE_OBJECT != pdat.value.type) { - OBJ_DESTRUCT(&pdat); + PMIX_PDATA_DESTRUCT(&pdat); return OPAL_ERR_TYPE_MISMATCH; } - OBJ_CONSTRUCT(&sbuf, opal_buffer_t); - opal_dss.load(&sbuf, pdat.value.data.bo.bytes, pdat.value.data.bo.size); + PMIX_DATA_BUFFER_CONSTRUCT(&sbuf); + PMIX_DATA_BUFFER_LOAD(&sbuf, pdat.value.data.bo.bytes, pdat.value.data.bo.size); - rc = opal_dss.unpack (&sbuf, context->outbuf, &size_count, OPAL_INT); - OBJ_DESTRUCT(&sbuf); - if (OPAL_UNLIKELY(OPAL_SUCCESS != rc)) { - return rc; + rc = PMIx_Data_unpack(NULL, &sbuf, context->outbuf, &size_count, PMIX_INT); + PMIX_DATA_BUFFER_DESTRUCT(&sbuf); + if (OPAL_UNLIKELY(PMIX_SUCCESS != rc)) { + return opal_pmix_convert_status(rc); } ompi_op_reduce (context->op, context->tmpbuf, context->outbuf, size_count, MPI_INT); diff --git a/ompi/communicator/ft/comm_ft.c b/ompi/communicator/ft/comm_ft.c index 4ceb157e430..3532954f06b 100644 --- a/ompi/communicator/ft/comm_ft.c +++ b/ompi/communicator/ft/comm_ft.c @@ -5,6 +5,7 @@ * of Tennessee Research Foundation. All rights * reserved. * + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -12,8 +13,6 @@ * $HEADER$ */ -#include "opal/dss/dss.h" - #include "ompi/runtime/params.h" #include "ompi/group/group.h" #include "ompi/communicator/communicator.h" diff --git a/ompi/communicator/ft/comm_ft_detector.c b/ompi/communicator/ft/comm_ft_detector.c index 63abce36b27..9fccfaa4d6f 100644 --- a/ompi/communicator/ft/comm_ft_detector.c +++ b/ompi/communicator/ft/comm_ft_detector.c @@ -3,6 +3,7 @@ * of Tennessee Research Foundation. All rights * reserved. * + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -205,9 +206,9 @@ int ompi_comm_failure_detector_finalize(void) { /* wait until the observed process confirms he is not putting in our * memory (or everybody else is dead) */ while( MPI_PROC_NULL != (observing = detector->hb_observing) ) { +#if !FD_LOCAL_PROCS ompi_proc_t* proc = ompi_comm_peer_lookup(detector->comm, observing); assert( NULL != proc ); -#if !FD_LOCAL_PROCS if( OPAL_PROC_ON_LOCAL_NODE(proc->super.proc_flags) ) { break; } diff --git a/ompi/dpm/dpm.c b/ompi/dpm/dpm.c index 7a328996144..6cd698cb0d7 100644 --- a/ompi/dpm/dpm.c +++ b/ompi/dpm/dpm.c @@ -20,6 +20,7 @@ * Copyright (c) 2014-2020 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -44,7 +45,6 @@ #include "opal/util/proc.h" #include "opal/util/show_help.h" #include "opal/util/printf.h" -#include "opal/dss/dss.h" #include "opal/mca/hwloc/base/base.h" #include "opal/mca/pmix/base/base.h" @@ -421,7 +421,7 @@ int ompi_dpm_connect_accept(ompi_communicator_t *comm, int root, /* get their locality string */ val = NULL; OPAL_MODEX_RECV_VALUE_IMMEDIATE(rc, PMIX_LOCALITY_STRING, - &proc->super.proc_name, &val, OPAL_STRING); + &proc->super.proc_name, &val, PMIX_STRING); if (OPAL_SUCCESS == rc && NULL != ompi_process_info.locality) { u16 = opal_hwloc_compute_relative_locality(ompi_process_info.locality, val); free(val); diff --git a/ompi/errhandler/errhandler.c b/ompi/errhandler/errhandler.c index cc311adee9f..3a2d2eab162 100644 --- a/ompi/errhandler/errhandler.c +++ b/ompi/errhandler/errhandler.c @@ -16,6 +16,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -423,20 +424,31 @@ typedef struct ompi_errhandler_event_s { int status; opal_process_name_t source; int nvalue; - opal_value_t value[]; + pmix_info_t info[]; } ompi_errhandler_event_t; static void *ompi_errhandler_event_cb(int fd, int flags, void *context) { ompi_errhandler_event_t *event = (ompi_errhandler_event_t*) context; int status = event->status; opal_process_name_t source = event->source; + opal_process_name_t prc; + int rc; #if OPAL_ENABLE_FT_MPI if( PMIX_ERR_PROC_ABORTED == status ) { int i; for(i = 0; i < event->nvalue; i++) { - if(OPAL_NAME != event->value[i].type) continue; - ompi_proc_t *proc = (ompi_proc_t*)ompi_proc_for_name(event->value[i].data.name); - if( NULL == proc ) continue; /* we are not 'MPI connected' with this proc. */ + if (PMIX_PROC != event->info[i].value.type) { + continue; + } + OPAL_PMIX_CONVERT_PROCT(rc, &prc, event->info[i].value.data.proc); + if (OPAL_SUCCESS != rc) { + OPAL_ERROR_LOG(rc); + break; + } + ompi_proc_t *proc = (ompi_proc_t*)ompi_proc_for_name(prc); + if( NULL == proc ) { + continue; /* we are not 'MPI connected' with this proc. */ + } assert( !ompi_proc_is_sentinel(proc) ); ompi_errhandler_proc_failed_internal(proc, status, false); } @@ -490,7 +502,7 @@ void ompi_errhandler_callback(size_t refid, pmix_status_t status, /* an error has been found, report to the MPI layer and let it take * further action. */ /* transition this from the RTE thread to the MPI progress engine */ - ompi_errhandler_event_t *event = malloc(sizeof(*event)+ninfo*sizeof(opal_value_t)); + ompi_errhandler_event_t *event = malloc(sizeof(*event)+ninfo*sizeof(pmix_info_t)); if(NULL == event) { OMPI_ERROR_LOG(OMPI_ERR_OUT_OF_RESOURCE); goto error; @@ -503,8 +515,8 @@ void ompi_errhandler_callback(size_t refid, pmix_status_t status, goto error; } event->nvalue = ninfo; - for(i = 0; i < ninfo; i++) { - opal_pmix_value_unload(&event->value[i], &info[i].value); + for (i = 0; i < ninfo; i++) { + PMIX_INFO_XFER(&event->info[i], &info[i]); } opal_event_set(opal_sync_event_base, &event->super, -1, OPAL_EV_READ, ompi_errhandler_event_cb, event); diff --git a/ompi/interlib/interlib.c b/ompi/interlib/interlib.c index da18b694199..1071fe6ed0a 100644 --- a/ompi/interlib/interlib.c +++ b/ompi/interlib/interlib.c @@ -16,6 +16,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2015-2020 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -51,7 +52,7 @@ static void model_callback(size_t refid, pmix_status_t status, 0 == strcmp(info[n].value.data.string, "MPI")) { goto cback; } - if (OPAL_STRING == info[n].value.type) { + if (PMIX_STRING == info[n].value.type) { opal_output(0, "OMPI Model Callback Key: %s Val %s", info[n].key, info[n].value.data.string); } } diff --git a/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c b/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c index 2e427ce7167..9da5816c48e 100644 --- a/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c +++ b/ompi/mca/crcp/bkmrk/crcp_bkmrk_pml.c @@ -10,6 +10,7 @@ * reserved. * Copyright (c) 2015-2020 Intel, Inc. All rights reserved. * Copyright (c) 2018-2020 Amazon.com, Inc. or its affiliates. All Rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -27,7 +28,6 @@ #include #endif /* HAVE_UNIST_H */ -#include "opal/dss/dss.h" #include "opal/runtime/opal_cr.h" #include "opal/util/event.h" #include "opal/util/output.h" @@ -1054,7 +1054,7 @@ do { \ #define PACK_BUFFER(buffer, var, count, type, error_msg) \ { \ - if (OMPI_SUCCESS != (ret = opal_dss.pack(buffer, &(var), count, type)) ) { \ + if (OMPI_SUCCESS != (ret = PMIx_Data_pack(NULL, buffer, &(var), count, type)) ) { \ opal_output(mca_crcp_bkmrk_component.super.output_handle, \ "%s (Return %d)", error_msg, ret); \ exit_status = ret; \ @@ -1065,7 +1065,7 @@ do { \ #define UNPACK_BUFFER(buffer, var, count, type, error_msg) \ { \ int32_t n = count; \ - if (OPAL_SUCCESS != (ret = opal_dss.unpack(buffer, &(var), &n, type)) ) { \ + if (OPAL_SUCCESS != (ret = PMIx_Data_unpack(NULL, buffer, &(var), &n, type)) ) { \ opal_output(mca_crcp_bkmrk_component.super.output_handle, \ "%s (Return %d)", error_msg, ret); \ exit_status = ret; \ @@ -4747,7 +4747,7 @@ static int ft_event_post_drain_acks(void) static void drain_message_ack_cbfunc(int status, ompi_process_name_t* sender, - opal_buffer_t *buffer, + pmix_data_buffer_t *buffer, ompi_rml_tag_t tag, void* cbdata) { @@ -4758,7 +4758,7 @@ static void drain_message_ack_cbfunc(int status, /* * Unpack the buffer */ - UNPACK_BUFFER(buffer, ckpt_status, 1, OPAL_SIZE, ""); + UNPACK_BUFFER(buffer, ckpt_status, 1, PMIX_SIZE, ""); /* * Update the outstanding message queue @@ -5070,7 +5070,7 @@ static int wait_quiesce_drained(void) * Send ACK to peer if wanted */ if( cur_peer_ref->ack_required ) { - opal_buffer_t *buffer = NULL; + pmix_data_buffer_t *buffer = NULL; size_t response = 1; OPAL_OUTPUT_VERBOSE((5, mca_crcp_bkmrk_component.super.output_handle, @@ -5079,12 +5079,13 @@ static int wait_quiesce_drained(void) OMPI_NAME_PRINT(&(cur_peer_ref->proc_name)) )); /* Send All Clear to Peer */ - if (NULL == (buffer = OBJ_NEW(opal_buffer_t))) { + PMIX_DATA_BUFFER_CREATE(buffer); + if (NULL == buffer) { exit_status = OMPI_ERROR; goto cleanup; } - PACK_BUFFER(buffer, response, 1, OPAL_SIZE, ""); + PACK_BUFFER(buffer, response, 1, PMIX_SIZE, ""); /* JJH - Performance Optimization? - Why not post all isends, then wait? */ if (ORTE_SUCCESS != (ret = ompi_rte_send_buffer_nb(&(cur_peer_ref->proc_name), @@ -5251,7 +5252,7 @@ static int send_bookmarks(int peer_idx) { ompi_crcp_bkmrk_pml_peer_ref_t *peer_ref; ompi_process_name_t peer_name; - opal_buffer_t *buffer = NULL; + pmix_data_buffer_t *buffer = NULL; int exit_status = OMPI_SUCCESS; int ret; @@ -5280,14 +5281,15 @@ static int send_bookmarks(int peer_idx) /* * Send the bookmarks to peer */ - if (NULL == (buffer = OBJ_NEW(opal_buffer_t))) { + PMIX_DATA_BUFFER_CREATE(buffer); + if (NULL == buffer) { exit_status = OMPI_ERROR; goto cleanup; } - PACK_BUFFER(buffer, (peer_ref->total_msgs_sent), 1, OPAL_UINT32, + PACK_BUFFER(buffer, (peer_ref->total_msgs_sent), 1, PMIX_UINT32, "crcp:bkmrk: send_bookmarks: Unable to pack total_msgs_sent"); - PACK_BUFFER(buffer, (peer_ref->total_msgs_recvd), 1, OPAL_UINT32, + PACK_BUFFER(buffer, (peer_ref->total_msgs_recvd), 1, PMIX_UINT32, "crcp:bkmrk: send_bookmarks: Unable to pack total_msgs_recvd"); if (ORTE_SUCCESS != (ret = ompi_rte_send_buffer_nb(&peer_name, buffer, @@ -5303,7 +5305,7 @@ static int send_bookmarks(int peer_idx) cleanup: if(NULL != buffer) { - OBJ_RELEASE(buffer); + PMIX_DATA_BUFFER_RELEASE(buffer); } END_TIMER(CRCP_TIMER_CKPT_EX_PEER_S); @@ -5336,7 +5338,7 @@ static int recv_bookmarks(int peer_idx) static void recv_bookmarks_cbfunc(int status, ompi_process_name_t* sender, - opal_buffer_t *buffer, + pmix_data_buffer_t *buffer, ompi_rml_tag_t tag, void* cbdata) { @@ -5358,11 +5360,11 @@ static void recv_bookmarks_cbfunc(int status, goto cleanup; } - UNPACK_BUFFER(buffer, tmp_int, 1, OPAL_UINT32, + UNPACK_BUFFER(buffer, tmp_int, 1, PMIX_UINT32, "crcp:bkmrk: recv_bookmarks: Unable to unpack total_msgs_sent"); peer_ref->matched_msgs_sent = tmp_int; - UNPACK_BUFFER(buffer, tmp_int, 1, OPAL_UINT32, + UNPACK_BUFFER(buffer, tmp_int, 1, PMIX_UINT32, "crcp:bkmrk: recv_bookmarks: Unable to unpack total_msgs_recvd"); peer_ref->matched_msgs_recvd = tmp_int; diff --git a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_eventlog.c b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_eventlog.c index 4724575b835..8625e5ca6a7 100644 --- a/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_eventlog.c +++ b/ompi/mca/vprotocol/pessimist/vprotocol_pessimist_eventlog.c @@ -5,6 +5,7 @@ * reserved. * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -34,7 +35,7 @@ int vprotocol_pessimist_event_logger_connect(int el_rank, ompi_communicator_t ** prc = PMIx_Lookup(&pdat, 1, NULL, 0); if (PMIX_SUCCESS != prc || - OPAL_STRING != pdat.value.type || + PMIX_STRING != pdat.value.type || NULL == pdat.value.data.string) { PMIX_PDATA_DESTRUCT(&pdat); return OMPI_ERR_NOT_FOUND; diff --git a/ompi/proc/proc.c b/ompi/proc/proc.c index 62c8c81d7ea..1f4d39cb504 100644 --- a/ompi/proc/proc.c +++ b/ompi/proc/proc.c @@ -19,6 +19,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved. * + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -34,7 +35,6 @@ #include "ompi/constants.h" #include "opal/datatype/opal_convertor.h" #include "opal/mca/threads/mutex.h" -#include "opal/dss/dss.h" #include "opal/util/arch.h" #include "opal/util/show_help.h" #include "opal/mca/hwloc/base/base.h" @@ -622,7 +622,7 @@ int ompi_proc_refresh(void) int ompi_proc_pack(ompi_proc_t **proclist, int proclistsize, - opal_buffer_t* buf) + pmix_data_buffer_t* buf) { int rc; char *nspace; @@ -643,33 +643,35 @@ ompi_proc_pack(ompi_proc_t **proclist, int proclistsize, */ for (int i = 0 ; i < proclistsize ; ++i) { ompi_proc_t *proc = proclist[i]; + pmix_proc_t prc; if (ompi_proc_is_sentinel (proc)) { proc = ompi_proc_for_name_nolock (ompi_proc_sentinel_to_name ((uintptr_t) proc)); } /* send proc name */ - rc = opal_dss.pack(buf, &(proc->super.proc_name), 1, OMPI_NAME); - if(rc != OPAL_SUCCESS) { - OMPI_ERROR_LOG(rc); + OPAL_PMIX_CONVERT_NAME(&prc, &(proc->super.proc_name)); + rc = PMIx_Data_pack(NULL, buf, &prc, 1, PMIX_PROC); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); opal_mutex_unlock (&ompi_proc_lock); - return rc; + return opal_pmix_convert_status(rc); } /* retrieve and send the corresponding nspace for this job * as the remote side may not know the translation */ nspace = opal_jobid_print(proc->super.proc_name.jobid); - rc = opal_dss.pack(buf, &nspace, 1, OPAL_STRING); - if(rc != OPAL_SUCCESS) { - OMPI_ERROR_LOG(rc); + rc = PMIx_Data_pack(NULL, buf, &nspace, 1, PMIX_STRING); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); opal_mutex_unlock (&ompi_proc_lock); - return rc; + return opal_pmix_convert_status(rc); } /* pack architecture flag */ - rc = opal_dss.pack(buf, &(proc->super.proc_arch), 1, OPAL_UINT32); - if(rc != OPAL_SUCCESS) { - OMPI_ERROR_LOG(rc); + rc = PMIx_Data_pack(NULL, buf, &(proc->super.proc_arch), 1, PMIX_UINT32); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); opal_mutex_unlock (&ompi_proc_lock); - return rc; + return opal_pmix_convert_status(rc); } } opal_mutex_unlock (&ompi_proc_lock); @@ -708,7 +710,7 @@ ompi_proc_find_and_add(const ompi_process_name_t * name, bool* isnew) int -ompi_proc_unpack(opal_buffer_t* buf, +ompi_proc_unpack(pmix_data_buffer_t* buf, int proclistsize, ompi_proc_t ***proclist, int *newproclistsize, ompi_proc_t ***newproclist) { @@ -734,33 +736,35 @@ ompi_proc_unpack(opal_buffer_t* buf, for (int i = 0; i < proclistsize ; ++i){ int32_t count=1; ompi_process_name_t new_name; + pmix_proc_t prc; uint32_t new_arch; bool isnew = false; int rc; char *nspace; uint16_t u16, *u16ptr; - rc = opal_dss.unpack(buf, &new_name, &count, OMPI_NAME); - if (rc != OPAL_SUCCESS) { - OMPI_ERROR_LOG(rc); + rc = PMIx_Data_unpack(NULL, buf, &prc, &count, PMIX_PROC); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); free(plist); free(newprocs); - return rc; + return opal_pmix_convert_status(rc); } - rc = opal_dss.unpack(buf, &nspace, &count, OPAL_STRING); - if (rc != OPAL_SUCCESS) { - OMPI_ERROR_LOG(rc); + OPAL_PMIX_CONVERT_PROCT(rc, &new_name, &prc); + rc = PMIx_Data_unpack(NULL, buf, &nspace, &count, PMIX_STRING); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); free(plist); free(newprocs); - return rc; + return opal_pmix_convert_status(rc); } free(nspace); - rc = opal_dss.unpack(buf, &new_arch, &count, OPAL_UINT32); - if (rc != OPAL_SUCCESS) { - OMPI_ERROR_LOG(rc); + rc = PMIx_Data_unpack(NULL, buf, &new_arch, &count, PMIX_UINT32); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); free(plist); free(newprocs); - return rc; + return opal_pmix_convert_status(rc); } /* see if this proc is already on our ompi_proc_list */ plist[i] = ompi_proc_find_and_add(&new_name, &isnew); diff --git a/ompi/proc/proc.h b/ompi/proc/proc.h index 4b31e0756bc..5c5d5576cf8 100644 --- a/ompi/proc/proc.h +++ b/ompi/proc/proc.h @@ -16,6 +16,7 @@ * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -39,7 +40,7 @@ #include "ompi/types.h" #include "opal/util/proc.h" - +#include "opal/mca/pmix/pmix-internal.h" #include "ompi/runtime/ompi_rte.h" @@ -301,7 +302,7 @@ OMPI_DECLSPEC ompi_proc_t * ompi_proc_find_and_add(const ompi_process_name_t * n */ OMPI_DECLSPEC int ompi_proc_pack(ompi_proc_t **proclist, int proclistsize, - opal_buffer_t *buf); + pmix_data_buffer_t *buf); /** @@ -343,7 +344,7 @@ OMPI_DECLSPEC int ompi_proc_pack(ompi_proc_t **proclist, * OMPI_SUCCESS on success * OMPI_ERROR else */ -OMPI_DECLSPEC int ompi_proc_unpack(opal_buffer_t *buf, +OMPI_DECLSPEC int ompi_proc_unpack(pmix_data_buffer_t *buf, int proclistsize, ompi_proc_t ***proclist, int *newproclistsize, diff --git a/ompi/runtime/ompi_rte.c b/ompi/runtime/ompi_rte.c index a088d86be10..381a60bde70 100644 --- a/ompi/runtime/ompi_rte.c +++ b/ompi/runtime/ompi_rte.c @@ -38,7 +38,6 @@ #include #endif /* HAVE_PWD_H */ -#include "opal/dss/dss.h" #include "opal/util/argv.h" #include "opal/util/error.h" #include "opal/util/opal_getcwd.h" @@ -52,7 +51,6 @@ #include "opal/mca/pmix/base/base.h" #include "opal/mca/threads/tsd.h" #include "opal/class/opal_list.h" -#include "opal/dss/dss.h" #include "ompi/runtime/ompi_rte.h" #include "ompi/debuggers/debuggers.h" diff --git a/ompi/runtime/ompi_rte.h b/ompi/runtime/ompi_rte.h index 1051b1d8e59..7071281db82 100644 --- a/ompi/runtime/ompi_rte.h +++ b/ompi/runtime/ompi_rte.h @@ -11,6 +11,7 @@ * Copyright (c) 2020 Amazon.com, Inc. or its affiliates. All Rights * reserved. * + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -177,7 +178,6 @@ struct opal_proc_t; #include "opal/util/proc.h" #include "opal/mca/hwloc/hwloc-internal.h" #include "opal/mca/pmix/pmix-internal.h" -#include "opal/dss/dss_types.h" struct ompi_proc_t; struct ompi_communicator_t; diff --git a/opal/Makefile.am b/opal/Makefile.am index 142eb59d3b6..e7484cd8c51 100644 --- a/opal/Makefile.am +++ b/opal/Makefile.am @@ -85,4 +85,3 @@ include memoryhooks/Makefile.am include runtime/Makefile.am include mca/Makefile.am include tools/Makefile.am -include dss/Makefile.am diff --git a/opal/class/Makefile.am b/opal/class/Makefile.am index c3f3c8cb041..1d3cdeab6e5 100644 --- a/opal/class/Makefile.am +++ b/opal/class/Makefile.am @@ -13,6 +13,7 @@ # Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2014-2018 Los Alamos National Security, LLC. All rights # reserved. +# Copyright (c) 2021 Nanook Consulting. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -29,7 +30,6 @@ headers += \ class/opal_free_list.h \ class/opal_hash_table.h \ class/opal_hotel.h \ - class/opal_tree.h \ class/opal_list.h \ class/opal_object.h \ class/opal_graph.h\ @@ -46,7 +46,6 @@ lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \ class/opal_free_list.c \ class/opal_hash_table.c \ class/opal_hotel.c \ - class/opal_tree.c \ class/opal_list.c \ class/opal_object.c \ class/opal_graph.c\ diff --git a/opal/class/opal_tree.c b/opal/class/opal_tree.c deleted file mode 100644 index d56813f1dd3..00000000000 --- a/opal/class/opal_tree.c +++ /dev/null @@ -1,707 +0,0 @@ -/* - * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2012 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. - * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2014 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" - -#include "opal/class/opal_tree.h" -#include "opal/constants.h" - -/* - * List classes - */ - -static void opal_tree_item_construct(opal_tree_item_t*); -static void opal_tree_item_destruct(opal_tree_item_t*); - -OBJ_CLASS_INSTANCE( - opal_tree_item_t, - opal_object_t, - opal_tree_item_construct, - opal_tree_item_destruct - ); - -static void opal_tree_construct(opal_tree_t*); -static void opal_tree_destruct(opal_tree_t*); - -OBJ_CLASS_INSTANCE( - opal_tree_t, - opal_object_t, - opal_tree_construct, - opal_tree_destruct - ); - - -/* - * - * opal_tree_item_t interface - * - */ - -static void opal_tree_item_construct(opal_tree_item_t *item) -{ - item->opal_tree_parent = NULL; - item->opal_tree_num_ancestors = 0; - item->opal_tree_sibling_rank = 0xdeadbeef; - item->opal_tree_next_sibling = item->opal_tree_prev_sibling = NULL; - item->opal_tree_num_children = 0; - item->opal_tree_first_child = item->opal_tree_last_child = NULL; -#if OPAL_ENABLE_DEBUG - item->opal_tree_item_refcount = 0; - item->opal_tree_item_belong_to = NULL; -#endif -} - -static void opal_tree_item_destruct(opal_tree_item_t *item) -{ -#if OPAL_ENABLE_DEBUG - assert( 0 == item->opal_tree_item_refcount ); - assert( NULL == item->opal_tree_item_belong_to ); -#endif /* OPAL_ENABLE_DEBUG */ -} - - -/* - * - * opal_tree_t interface - * - */ - -static void opal_tree_construct(opal_tree_t *tree) -{ - OBJ_CONSTRUCT( &(tree->opal_tree_sentinel), opal_tree_item_t ); - -#if OPAL_ENABLE_DEBUG - /* These refcounts should never be used in assertions because they - should never be removed from this list, added to another list, - etc. So set them to sentinel values. */ - - tree->opal_tree_sentinel.opal_tree_item_refcount = 1; - tree->opal_tree_sentinel.opal_tree_item_belong_to = tree; -#endif - tree->opal_tree_sentinel.opal_tree_container = tree; - tree->opal_tree_sentinel.opal_tree_parent = &tree->opal_tree_sentinel; - tree->opal_tree_sentinel.opal_tree_num_ancestors = -1; - - tree->opal_tree_sentinel.opal_tree_next_sibling = - &tree->opal_tree_sentinel; - tree->opal_tree_sentinel.opal_tree_prev_sibling = - &tree->opal_tree_sentinel; - - tree->opal_tree_sentinel.opal_tree_first_child = &tree->opal_tree_sentinel; - tree->opal_tree_sentinel.opal_tree_last_child = &tree->opal_tree_sentinel; - - tree->opal_tree_num_items = 0; - tree->comp = NULL; - tree->serialize = NULL; - tree->deserialize = NULL; - tree->get_key = NULL; -} - -/* - * Reset all the pointers to be NULL -- do not actually destroy - * anything. - */ -static void opal_tree_destruct(opal_tree_t *tree) -{ - opal_tree_construct(tree); -} - -/* - * initialize tree container - */ -void opal_tree_init(opal_tree_t *tree, opal_tree_comp_fn_t comp, - opal_tree_item_serialize_fn_t serialize, - opal_tree_item_deserialize_fn_t deserialize, - opal_tree_get_key_fn_t get_key) -{ - tree->comp = comp; - tree->serialize = serialize; - tree->deserialize = deserialize; - tree->get_key = get_key; -} - -/* - * count all the descendants from our level and below - */ -static int count_descendants(opal_tree_item_t* item) -{ - int current_count = 0; - - /* loop over all siblings for descendants to count */ - while (item) { - current_count += count_descendants(opal_tree_get_first_child(item)); - current_count++; /* count ourselves */ - item = opal_tree_get_next_sibling(item); - } - return(current_count); -} - -/* - * get size of tree - */ -size_t opal_tree_get_size(opal_tree_t* tree) -{ -#if OPAL_ENABLE_DEBUG - /* not sure if we really want this running in devel, as it does - * slow things down. Wanted for development of splice / join to - * make sure length was reset properly - */ - size_t check_len = 0; - opal_tree_item_t *root; - - if (!opal_tree_is_empty(tree)) { - /* tree has entries so count up items */ - root = opal_tree_get_root(tree); - check_len = count_descendants(root); - } - - if (check_len != tree->opal_tree_num_items) { - fprintf(stderr," Error :: opal_tree_get_size - opal_tree_num_items does not match actual tree length\n"); - fflush(stderr); - abort(); - } -#endif - - return tree->opal_tree_num_items; -} - -/* - * add item to parent's child list - */ -void opal_tree_add_child(opal_tree_item_t *parent_item, - opal_tree_item_t *new_item) -{ -#if OPAL_ENABLE_DEBUG - /* Spot check: ensure that this item is previously on no lists */ - - assert(0 == new_item->opal_tree_item_refcount); - assert( NULL == new_item->opal_tree_item_belong_to ); -#endif - - new_item->opal_tree_parent = parent_item; - new_item->opal_tree_num_ancestors = parent_item->opal_tree_num_ancestors+1; - if (parent_item->opal_tree_num_children) { - /* append item to end of children and sibling lists */ - new_item->opal_tree_prev_sibling = parent_item->opal_tree_last_child; - parent_item->opal_tree_last_child->opal_tree_next_sibling = new_item; - } else { - /* no children existing on parent */ - parent_item->opal_tree_first_child = new_item; - } - parent_item->opal_tree_last_child = new_item; - parent_item->opal_tree_num_children++; - new_item->opal_tree_container = parent_item->opal_tree_container; - new_item->opal_tree_container->opal_tree_num_items++; - -#if OPAL_ENABLE_DEBUG - /* Spot check: ensure this item is only on the list that we just - appended it to */ - - OPAL_THREAD_ADD_FETCH32( &(new_item->opal_tree_item_refcount), 1 ); - assert(1 == new_item->opal_tree_item_refcount); - new_item->opal_tree_item_belong_to = new_item->opal_tree_container; -#endif -} - -/* - * check to see if item is in tree - */ -#if OPAL_ENABLE_DEBUG -static bool item_in_tree(opal_tree_item_t *item, opal_tree_item_t *search_item) -{ - bool result = false; - opal_tree_item_t *first_child; - - while (!result && item) { - /* check for item match */ - result = (item == search_item) ? true : false; - if (!result && (first_child = opal_tree_get_first_child(item))) { - /* search descendants for match */ - result = item_in_tree(first_child, search_item); - } - if (!result) { - /* didn't find match at our node or descending so check sibling */ - item = opal_tree_get_next_sibling(item); - } - } - return(result); -} -#endif /* OPAL_ENABLE_DEBUG */ - -/* - * remove item and all items below it from tree and return it to the caller - */ -opal_tree_item_t *opal_tree_remove_subtree(opal_tree_item_t *item) -{ - opal_tree_item_t *parent_item = NULL; - -#if OPAL_ENABLE_DEBUG - /* validate that item does exist on tree */ - if (NULL != item->opal_tree_container) { - /* we point to a container, check if we can find item in tree */ - if (!item_in_tree(opal_tree_get_root(item->opal_tree_container), item)) { - return(NULL); - } - } else { - return (NULL); - } -#endif - - parent_item = item->opal_tree_parent; - - /* remove from parent */ - /* If item is the only child, set _first_child and _last_child to - be item's _first_child and _last_child */ - if (parent_item->opal_tree_first_child == item && - parent_item->opal_tree_last_child == item) { - parent_item->opal_tree_first_child = item->opal_tree_first_child; - parent_item->opal_tree_last_child = item->opal_tree_last_child; - } else { - /* Otherwise, there are multiple children of this parent. If - this item is the first or last child of this parent, then - ensure that the parent gets a valid first / last child: - - If I have children, then my first/last child - - If I have no children, then my immediate sibling */ - if (item->opal_tree_parent->opal_tree_first_child == item) { - if (item->opal_tree_num_children > 0) { - parent_item->opal_tree_first_child = - item->opal_tree_next_sibling; - } else { - parent_item->opal_tree_first_child = - opal_tree_get_next_sibling(item); - } - } else if (parent_item->opal_tree_last_child == item) { - if (item->opal_tree_num_children > 0) { - parent_item->opal_tree_last_child = - item->opal_tree_last_child; - } else { - parent_item->opal_tree_last_child = - opal_tree_get_prev_sibling(item); - } - } - } - item->opal_tree_parent->opal_tree_num_children--; - - /* remove from sibling pointers */ - if (NULL != item->opal_tree_prev_sibling) { - item->opal_tree_prev_sibling->opal_tree_next_sibling= - item->opal_tree_next_sibling; - } - if (NULL != item->opal_tree_next_sibling) { - item->opal_tree_next_sibling->opal_tree_prev_sibling= - item->opal_tree_prev_sibling; - } - item->opal_tree_prev_sibling = NULL; - item->opal_tree_next_sibling = NULL; - - /* adjust items relating to container */ - item->opal_tree_container->opal_tree_num_items -= count_descendants(item); - item->opal_tree_container = NULL; - - return(item); -} - -int opal_tree_remove_item(opal_tree_t *tree, - opal_tree_item_t *item) -{ - opal_tree_item_t *parent_item = NULL, *child = NULL; - - parent_item = (opal_tree_item_t*)item->opal_tree_parent; - - /* - * Point each of my children to my parent - */ - for(child = opal_tree_get_first_child(item); - child != NULL; - child = opal_tree_get_next_sibling(child)) { - child->opal_tree_parent = parent_item; - child->opal_tree_num_ancestors--; - - parent_item->opal_tree_num_children++; - } - - /* - * My first child points to my 'prev' sibling - */ - child = opal_tree_get_first_child(item); - if( NULL != child ) { - child->opal_tree_prev_sibling = item->opal_tree_prev_sibling; - } - if( NULL != item->opal_tree_prev_sibling ) { - (item->opal_tree_prev_sibling)->opal_tree_next_sibling = child; - } - - child = opal_tree_get_last_child(item); - if( NULL != child ) { - child->opal_tree_next_sibling = item->opal_tree_next_sibling; - } - if( NULL != item->opal_tree_next_sibling ) { - (item->opal_tree_next_sibling)->opal_tree_prev_sibling = child; - } - - /* - * Remove me from my parent. If I was the only child, then make - * the first child be my first child, and make the last child be - * my last child. - */ - if( parent_item->opal_tree_first_child == item && - parent_item->opal_tree_last_child == item ) { - parent_item->opal_tree_first_child = opal_tree_get_first_child(item); - parent_item->opal_tree_last_child = opal_tree_get_last_child(item); - } else { - /* There were multiple children. If I was the first or last, - then ensure the parent gets a valid first or last child: - - If I have children, then my first/last - - If I have no childen, then my immediate sibling */ - if (parent_item->opal_tree_first_child == item) { - if (item->opal_tree_num_children > 0) { - parent_item->opal_tree_first_child = - item->opal_tree_first_child; - } else { - parent_item->opal_tree_first_child = - opal_tree_get_next_sibling(item); - } - } else if (parent_item->opal_tree_last_child == item) { - if (item->opal_tree_num_children > 0) { - parent_item->opal_tree_last_child = - item->opal_tree_last_child; - } else { - parent_item->opal_tree_last_child = - opal_tree_get_prev_sibling(item); - } - } - } - parent_item->opal_tree_num_children--; - - return OPAL_SUCCESS; -} - -/* delimeter characters that mark items in a serialized stream */ -static char *start_lvl = "["; -static char *end_lvl = "]"; -static char *end_stream = "E"; - -/* - * add item to opal buffer that represents all items of a sub-tree from the - * item passed in on down. We exit out of converting tree items once we've - * done the last child of the tree_item and we are at depth 1. - */ -static int add_tree_item2buf(opal_tree_item_t *tree_item, - opal_buffer_t *buf, - opal_tree_item_serialize_fn_t fn, - int depth - ) -{ - opal_tree_item_t *first_child; - int rc; - - do { - /* add start delim to buffer */ - if (OPAL_SUCCESS != - (rc = opal_dss.pack(buf, &start_lvl, 1, OPAL_STRING))){ - return(rc); - } - /* add item to opal buffer from class creator */ - fn(tree_item, buf); - - if ((first_child = opal_tree_get_first_child(tree_item))) { - /* add items for our children */ - if (OPAL_SUCCESS != - (rc = add_tree_item2buf(first_child, buf, fn, depth+1))){ - return(rc); - } - if (OPAL_SUCCESS != - (rc = opal_dss.pack(buf, &end_lvl, 1, OPAL_STRING))){ - return(rc); - } - } else { - /* end item entry */ - if (OPAL_SUCCESS != - (rc = opal_dss.pack(buf, &end_lvl, 1, OPAL_STRING))){ - return(rc); - } - } - - /* advance to next sibling, if none we'll drop out of - * loop and return to our parent - */ - tree_item = opal_tree_get_next_sibling(tree_item); - } while (tree_item && 1 < depth); - - return(OPAL_SUCCESS); -} - -/* - * serialize tree data - */ -int opal_tree_serialize(opal_tree_item_t *start_item, opal_buffer_t *buffer) -{ - int rc; - - if (OPAL_SUCCESS != - (rc = add_tree_item2buf(start_item, buffer, - start_item->opal_tree_container->serialize, - 1))){ - return(rc); - } - if (OPAL_SUCCESS != - (rc = opal_dss.pack(buffer, &end_stream, 1, OPAL_STRING))){ - return(rc); - } - return(OPAL_SUCCESS); -} - -static int deserialize_add_tree_item(opal_buffer_t *data, - opal_tree_item_t *parent_item, - opal_tree_item_deserialize_fn_t deserialize, - char **curr_delim, - int depth) -{ - int idx = 1, rc; - opal_tree_item_t *new_item = NULL; - int level = 0; /* 0 - one up 1 - curr, 2 - one down */ - - if (!*curr_delim) { - if (OPAL_SUCCESS != - (rc = opal_dss.unpack(data, curr_delim, &idx, OPAL_STRING))) { - return(rc); - } - } - while(*curr_delim[0] != end_stream[0]) { - if (*curr_delim[0] == start_lvl[0]) { - level++; - } else { - level--; - } - - switch (level) { - case 0: - if (1 < depth) { - /* done with this level go up one level */ - return(OPAL_SUCCESS); - } - break; - case 1: - /* add found child at this level */ - deserialize(data, &new_item); - opal_tree_add_child(parent_item, new_item); - break; - case 2: - /* need to add child one level down */ - deserialize_add_tree_item(data, new_item, deserialize, curr_delim, - depth+1); - level--; - break; - } - if (OPAL_SUCCESS != - (rc = opal_dss.unpack(data, curr_delim, &idx, OPAL_STRING))) { - return(rc); - } - } - return(OPAL_SUCCESS); -} - -/* - * deserialize tree data - */ -int opal_tree_deserialize(opal_buffer_t *serialized_data, - opal_tree_item_t *start_item) -{ - char * null = NULL; - deserialize_add_tree_item(serialized_data, - start_item, - start_item->opal_tree_container->deserialize, - &null, - 1); - return OPAL_SUCCESS; -} - -void * opal_tree_get_key(opal_tree_t *tree, opal_tree_item_t *item) -{ - return tree->get_key(item); -} - -int opal_tree_dup(opal_tree_t *from, opal_tree_t *to) -{ - int ret; - opal_buffer_t *buffer = NULL; - - opal_tree_init(to, - from->comp, - from->serialize, - from->deserialize, - from->get_key); - - buffer = OBJ_NEW(opal_buffer_t); - - opal_tree_serialize(opal_tree_get_root(from), buffer); - ret = opal_tree_deserialize(buffer, opal_tree_get_root(to)); - - OBJ_RELEASE(buffer); - return ret; -} - -int opal_tree_copy_subtree(opal_tree_t *from_tree, opal_tree_item_t *from_item, - opal_tree_t *to_tree, opal_tree_item_t *to_parent) -{ - int ret; - opal_buffer_t *buffer = NULL; - - buffer = OBJ_NEW(opal_buffer_t); - - opal_tree_serialize(from_item, buffer); - ret = opal_tree_deserialize(buffer, to_parent); - - OBJ_RELEASE(buffer); - return ret; -} - -opal_tree_item_t *opal_tree_dup_item(opal_tree_t *base, opal_tree_item_t *from) -{ - opal_buffer_t *buffer = NULL; - opal_tree_item_t *new_item = NULL; - - buffer = OBJ_NEW(opal_buffer_t); - - opal_tree_serialize(from, buffer); - - new_item = OBJ_NEW(opal_tree_item_t); - opal_tree_deserialize(buffer, new_item); - - OBJ_RELEASE(buffer); - return new_item; -} - -int opal_tree_num_children(opal_tree_item_t *parent) -{ - opal_tree_item_t *child = NULL; - int i = 0; - - for(child = opal_tree_get_first_child(parent); - child != NULL; - child = opal_tree_get_next_sibling(child) ) { - ++i; - } - - return i; -} - -static int opal_tree_compare_subtrees(opal_tree_t *tree_left, opal_tree_t *tree_right, - opal_tree_item_t *left, opal_tree_item_t *right) -{ - int ret; - opal_tree_item_t *left_child = NULL, *right_child = NULL; - - /* Basecase */ - if( NULL == left && NULL == right ) { - return 0; /* Match */ - } - - /* Compare: Depth */ - if( NULL == left && NULL != right ) { - return -1; - } - else if( NULL != left && NULL == right ) { - return 1; - } - - /* Compare: Keys */ - if( 0 != tree_left->comp(right, opal_tree_get_key(tree_left, left)) ) { - return -2; - } - - /* Compare: Number of children */ - if( opal_tree_num_children(left) != opal_tree_num_children(right) ) { - return 2; - } - - /* Recursively compare all children */ - for(left_child = opal_tree_get_first_child(left), right_child = opal_tree_get_first_child(right); - left_child != NULL && right_child != NULL; - left_child = opal_tree_get_next_sibling(left_child), right_child = opal_tree_get_next_sibling(right_child) ) { - /* On first difference, return the result */ - if( 0 != (ret = opal_tree_compare_subtrees(tree_left, tree_right, left_child, right_child)) ) { - return ret; - } - } - - return 0; -} - -int opal_tree_compare(opal_tree_t *left, opal_tree_t *right) -{ - return opal_tree_compare_subtrees(left, right, opal_tree_get_root(left), opal_tree_get_root(right)); -} - -/* - * search myself, descendants and siblings for item matching key - */ -static opal_tree_item_t *find_in_descendants(opal_tree_item_t* item, void *key) -{ - opal_tree_item_t *result = NULL, *first_child; - - while (!result && item) { - /* check for item match */ - result = (item->opal_tree_container->comp(item, key) == 0) ? - item : NULL; - if (!result && (first_child = opal_tree_get_first_child(item))) { - /* search descendants for match */ - result = find_in_descendants(first_child, key); - } - if (!result) { - /* didn't find match at our node or descending so check sibling */ - item = opal_tree_get_next_sibling(item); - } - } - return(result); -} - -/* - * return next tree item that matches key - */ -opal_tree_item_t *opal_tree_find_with(opal_tree_item_t *item, void *key) -{ - opal_tree_item_t *curr_item = item, *result = NULL; - - if (!opal_tree_is_empty(item->opal_tree_container)) { - /* check my descendant for a match */ - result = find_in_descendants(opal_tree_get_first_child(item), key); - - if (!result) { - /* check my siblings for match */ - if (NULL != (curr_item = opal_tree_get_next_sibling(curr_item))) { - result = find_in_descendants(curr_item, key); - } - } - - /* check my ancestors (uncles) for match */ - curr_item = item; - while (!result && curr_item && curr_item->opal_tree_num_ancestors > 0){ - curr_item = opal_tree_get_next_sibling(item->opal_tree_parent); - while (NULL == curr_item && - item->opal_tree_parent->opal_tree_num_ancestors > 0) { - item = item->opal_tree_parent; - curr_item = opal_tree_get_next_sibling(item->opal_tree_parent); - } - if (curr_item) { - /* search ancestors descendants for match */ - result = find_in_descendants(curr_item, key); - } - } - } - - return(result); -} diff --git a/opal/class/opal_tree.h b/opal/class/opal_tree.h deleted file mode 100644 index c80c52d18af..00000000000 --- a/opal/class/opal_tree.h +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -/** - * @file - * - * The opal_tree_t interface is used to provide a generic - * tree list container for Open MPI. It was inspired by the opal_list_t - * interface but instead of organizing items in a doubly-linked list - * fashion, we order them in a finite tree structure. - * - * The general idea is a user creates an class instance that has two - * components. A tree structure component as defined by opal_tree_item_t - * that links all the items together to form the tree. Then there is - * a user specific data component which the user defines what is stored at - * each item. When a user create a type to be used for a OBJ_CLASS_INSTANCE - * it will contain the opal_tree_item_t followed by any user specific - * data. Then the opal_tree_item_t objects can be put in an - * opal_tree_t. Hence, you create a new type that derives from - * opal_tree_item_t; this new type can then be used with opal_tree_t - * containers. - * - * NOTE: opal_tree_item_t instances can only be on \em one tree at a - * time. Specifically, if you add an opal_tree_item_t to one tree, - * and then add it to another tree (without first removing it from the - * first tree), you will effectively be hosing the first tree. You - * have been warned. - * - * If OPAL_ENABLE_DEBUG is true, a bunch of checks occur, including - * some spot checks for a debugging reference count in an attempt to - * ensure that an opal_tree_item_t is only one *one* tree at a time. - * Given the highly concurrent nature of this class, these spot checks - * cannot guarantee that an item is only one tree at a time. - * Specifically, since it is a desirable attribute of this class to - * not use locks for normal operations, it is possible that two - * threads may [erroneously] modify an opal_tree_item_t concurrently. - * - * The only way to guarantee that a debugging reference count is valid - * for the duration of an operation is to lock the item_t during the - * operation. But this fundamentally changes the desirable attribute - * of this class (i.e., no locks). So all we can do is spot-check the - * reference count in a bunch of places and check that it is still the - * value that we think it should be. But this doesn't mean that you - * can run into "unlucky" cases where two threads are concurrently - * modifying an item_t, but all the spot checks still return the - * "right" values. All we can do is hope that we have enough spot - * checks to statistically drive down the possibility of the unlucky - * cases happening. - */ - -#ifndef OPAL_TREE_H -#define OPAL_TREE_H - -#include "opal_config.h" -#include -#include -#include "opal/class/opal_object.h" -#include "opal/dss/dss.h" - -#if OPAL_ENABLE_DEBUG -/* Need atomics for debugging (reference counting) */ -#include "opal/sys/atomic.h" -#include "opal/mca/threads/mutex.h" -#endif - -BEGIN_C_DECLS - -/** - * \internal - * - * The class for the tree container. - */ -OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_tree_t); -/** - * \internal - * - * Base class for items that are put in tree containers. - */ -OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_tree_item_t); - -/** - * \internal - * - * Struct of an opal_tree_item_t - */ -typedef struct opal_tree_item_t -{ - /** Generic parent class for all Open MPI objects */ - opal_object_t super; - /** Pointer to the tree this item belongs to */ - struct opal_tree_t *opal_tree_container; - /* Parent info */ - /** Pointer to parent tree item */ - struct opal_tree_item_t *opal_tree_parent; - /** Depth from the root item in tree */ - unsigned opal_tree_num_ancestors; - /* Logical rank we are compared to other siblings */ - unsigned opal_tree_sibling_rank; - /** Pointer to next item below same parent (or NULL if this is the - leftmost sibling) */ - struct opal_tree_item_t *opal_tree_next_sibling; - /** Pointer to previous item below same parent (or NULL if this is - the rightmost sibling) */ - struct opal_tree_item_t *opal_tree_prev_sibling; - - /* Children info */ - /** Number of children */ - unsigned opal_tree_num_children; - /** Pointer to first child item, or NULL if there are no children */ - struct opal_tree_item_t *opal_tree_first_child; - /** Pointer to last child item, or NULL if there are no children */ - struct opal_tree_item_t *opal_tree_last_child; - -#if OPAL_ENABLE_DEBUG - /** Atomic reference count for debugging */ - opal_atomic_int32_t opal_tree_item_refcount; - /** The tree this item belong to */ - struct opal_tree_t* opal_tree_item_belong_to; -#endif -} opal_tree_item_t; - -/** - * Check to see if item's user specific data matches key - * - * @param item - The item we want to check to see if it matches key - * @param key - The opaque key that we want the match function to check - * in the item's user specific data. - * - * @returns 0 - If item's user specific data matches key - * @returns non-zero - If item's user specific data does not match key - * - * This function is implemented by the code that constructs the tree - * and initialized the pointer by the call to opal_tree_init. - * - */ -typedef int (*opal_tree_comp_fn_t)(opal_tree_item_t *item, void *key); - -/** - * The serialize function typedef. This function is called by the - * opal tree serialize code to serialize a tree item's user specific - * data of a class type. - * - * @params item - item to serialize the user specific data from - * @params buffer - the opal_buffer_t to store the serialized data in. - * - * @returns OPAL_SUCCESS - when successfully serialized item - */ -typedef int (*opal_tree_item_serialize_fn_t)(opal_tree_item_t *item, - opal_buffer_t *buffer); - -/** - * The deserialize function typedef. This function is called by the - * opal tree deserialize code to deserialize a tree item's user - * specific data. - * - * @params buffer - the opal_buffer_t to deserialized data. - * @params item - item to store the deserialized data into the user - * specific data - * - * @returns OPAL_SUCCESS - when successfully deserialized item - */ -typedef int (*opal_tree_item_deserialize_fn_t)(opal_buffer_t *buffer, - opal_tree_item_t **item); - -/** - * Get the 'key' associated with this item - */ -typedef void *(*opal_tree_get_key_fn_t)(opal_tree_item_t *item); - -/** - * \internal - * - * Struct of an opal_tree_t - * - */ -typedef struct opal_tree_t -{ - /** Generic parent class for all Open MPI objects */ - opal_object_t super; - /** Guard item of the tree that child points to root */ - opal_tree_item_t opal_tree_sentinel; - /** Quick reference to the number of items in the tree */ - volatile size_t opal_tree_num_items; - /** Function to compare two items in tree */ - opal_tree_comp_fn_t comp; - /** Function to serialize tree item data */ - opal_tree_item_serialize_fn_t serialize; - /** Function to deserialize tree item data */ - opal_tree_item_deserialize_fn_t deserialize; - /**< Function to deserialize tree item data */ - opal_tree_get_key_fn_t get_key; -} opal_tree_t; - -/** Macros to access items in the tree */ - -/** - * Get the parent of item in the tree. - * - * @param item A tree item. - * - * @returns The parent item in the tree - * - * This function is safe to be called with a null item pointer. - */ -static inline opal_tree_item_t *opal_tree_get_parent(opal_tree_item_t *item) -{ - return ((item) ? item->opal_tree_parent : NULL); -} - -/** - * Get the next sibling item in the tree. - * - * @param item A tree item. - * - * @returns The next sibling item in the tree - * - * This function is safe to be called with a null item pointer. - */ -static inline opal_tree_item_t *opal_tree_get_next_sibling(opal_tree_item_t - *item) -{ - return ((item) ? item->opal_tree_next_sibling : NULL); -} - - -/** - * Get the previous sibling item in the tree. - * - * @param item A tree item. - * - * @returns The previous sibling item in the tree - * - * This function is safe to be called with a null item pointer. - */ -static inline opal_tree_item_t *opal_tree_get_prev_sibling(opal_tree_item_t - *item) -{ - return ((item) ? item->opal_tree_prev_sibling : NULL); -} - -/** - * Get the first child item in the tree. - * - * @param item A tree item. - * - * @returns The first child item in the tree - * - * This function is safe to be called with a null item pointer. - * - */ -static inline opal_tree_item_t *opal_tree_get_first_child(opal_tree_item_t - *item) -{ - return ((item) ? item->opal_tree_first_child : NULL); -} - -/** - * Get the last child item in the tree. - * - * @param item A tree item. - * - * @returns The last child item in the tree - * - * This function is safe to be called with a null item pointer. - * - */ -static inline opal_tree_item_t *opal_tree_get_last_child(opal_tree_item_t - *item) -{ - return ((item) ? item->opal_tree_last_child : NULL); -} - -/** - * Check for empty tree - * - * @param tree The tree container - * - * @returns true if tree's size is 0, false otherwise - * - * This is an O(1) operation. - * - * This is an inlined function in compilers that support inlining, - * so it's usually a cheap operation. - * - */ -static inline bool opal_tree_is_empty(opal_tree_t* tree) -{ -#if OPAL_ENABLE_DEBUG - /* Spot check that the tree is a non-null pointer */ - assert(NULL != tree); -#endif - return (tree->opal_tree_sentinel.opal_tree_first_child == - &(tree->opal_tree_sentinel) ? true : false); -} - - -/** - * Return the root item on the tree (does not remove it). - * - * @param tree The tree container - * - * @returns A pointer to the first item in the tree - * - * This is an O(1) operation to return the first item in the tree. - * - * This is an inlined function in compilers that support inlining, so - * it's usually a cheap operation. - * - */ -static inline opal_tree_item_t* opal_tree_get_root(opal_tree_t* tree) -{ - opal_tree_item_t* item; -#if OPAL_ENABLE_DEBUG - assert(NULL != tree); -#endif - item = tree->opal_tree_sentinel.opal_tree_first_child; -#if OPAL_ENABLE_DEBUG - /* Spot check: ensure that the first item is only on one list */ - assert(1 == item->opal_tree_item_refcount); - assert(tree == item->opal_tree_item_belong_to ); -#endif - return item; -} - -/** - * Return the number of items in a tree - * - * @param tree The tree container - * - * @returns The size of the tree (size_t) - * - * This is an O(1) (in non-debug mode) lookup to return the - * size of the list. - */ -OPAL_DECLSPEC size_t opal_tree_get_size(opal_tree_t* tree); - - -/* Functions to manage the tree */ -/** - * Initialize tree container; must be called before using - * the tree. - * - * @param tree The tree to initialize - * @param comp Comparison function to attach to tree. - * @param serialize Serialization function to attach to tree. - * @param deserialize De-serialization function to attach to tree. - * - */ -OPAL_DECLSPEC void opal_tree_init(opal_tree_t *tree, - opal_tree_comp_fn_t comp, - opal_tree_item_serialize_fn_t serialize, - opal_tree_item_deserialize_fn_t deserialize, - opal_tree_get_key_fn_t get_key); - -/** - * Add new item as child to its parent item - * - * @param parent_item pointer to what parent the new item belongs to - * @param new_item the item to be added as a child to parent_item - * - * The new_item is added at the end of the child list of the parent_item. - */ -OPAL_DECLSPEC void opal_tree_add_child(opal_tree_item_t *parent_item, - opal_tree_item_t *new_item); - -/** - * Remove an item and everything below from a tree. - * - * @param item The item at the top of subtree to remove - * - * @returns A pointer to the item on the list previous to the one - * that was removed. - * - * This is an O(1) operation to remove an item from the tree. The - * item and all children below it will be removed from the tree. This - * means the item's siblings pointers and potentially the parents first - * and last pointers will be updated to skip over the item. The tree container - * will also have its num_items adjusted to reflect the number of items - * that were removed. The tree item (and all children below it) that is - * returned is now "owned" by the caller -- they are responsible for - * OBJ_RELEASE()'ing it. - * - * With ENABLE_DEBUG on this routine will validate whether the item is actually - * in the tree before doing pointer manipulation. - */ -OPAL_DECLSPEC opal_tree_item_t *opal_tree_remove_subtree(opal_tree_item_t *item); - -/** - * Remove an item, everything below inherited by parent. - * - * @param tree Tree from which to remove - * @param item The item to remove - * - * @returns Success/Failure - */ -OPAL_DECLSPEC int opal_tree_remove_item(opal_tree_t *tree, - opal_tree_item_t *item); - -/** - * Serialize tree data - * - * @param start_item The item of a tree to start serializing data - * @param buffer The opal buffer that contains the serialized - * data stream of the tree - * - * @returns OPAL_SUCCESS if data has been successfully converted. - * - * This routine walks the tree starting at start_item until it has serialized - * all children items of start_item and creates a bytestream of data, - * using the opal_dss.pack routine, that can be sent over a network. - * The format of the bytestream represents the tree parent/child relationship - * of each item in the tree plus the data inside the tree. This routine calls - * the tree's serialization method to serialize the user specific data for - * each item. - * - */ -OPAL_DECLSPEC int opal_tree_serialize(opal_tree_item_t *start_item, - opal_buffer_t *buffer); - -/** - * De-serialize tree data - * - * @param buffer The opal buffer that is to be deserialized - * @param start_item The item in the tree the data should be - * deserialized into - * - * @returns Status of call OPAL_SUCCESS if everything worked - * - * This routine takes a bytestream that was created by the - * opal_tree_serialize() function and deserializes it into the - * tree given. If the tree already has data in it, this routine - * will start adding the new data as a new child of the root - * item. This routine calls the tree's de-serialization - * method to deserialize the user specific data for each item. - * - */ -OPAL_DECLSPEC int opal_tree_deserialize(opal_buffer_t *buffer, - opal_tree_item_t *start_item); - -/** - * Access the 'key' associated with the item - * - * @param tree Source Tree - * @param item Item to access key of - * - * @returns Success/Failure - */ -OPAL_DECLSPEC void * opal_tree_get_key(opal_tree_t *tree, opal_tree_item_t *item); - -/** - * Copy/Duplicate a tree (requires serialize/deserialize) - * - * @param from Source tree to copy 'from' - * @param to Destination tree to copy 'to' - * - * @returns Success/Failure - */ -OPAL_DECLSPEC int opal_tree_dup(opal_tree_t *from, opal_tree_t *to); - -/** - * Copy/Duplicate a subtree (requires serialize/deserialize) - * - * @param base Base tree - * @param from Source tree item to copy 'from' - * - * @returns Tree item copy - */ -OPAL_DECLSPEC int opal_tree_copy_subtree(opal_tree_t *from_tree, opal_tree_item_t *from_item, - opal_tree_t *to_tree, opal_tree_item_t *to_parent); - -/** - * Copy/Duplicate a tree item (requires serialize/deserialize) - * - * @param base Base tree - * @param from Source tree item to copy 'from' - * - * @returns Tree item copy - */ -OPAL_DECLSPEC opal_tree_item_t *opal_tree_dup_item(opal_tree_t *base, opal_tree_item_t *from); - -/** - * Count the number of children of this parent - * - * @param parent A parent node in the tree - * - * @returns Number of children of this parent - */ -OPAL_DECLSPEC int opal_tree_num_children(opal_tree_item_t *parent); - -/** - * Compare two trees - * - * @param left Tree - * @param right Tree - * - * @returns 0 if identical, ow returns non-zero - */ -OPAL_DECLSPEC int opal_tree_compare(opal_tree_t *left, opal_tree_t *right); - -/* Functions to search for items on tree */ -/** - * Return the next tree item that matches key provided - * - * @param item The item to start the find from - * @param key the key we are wanting to match with - * - * @returns A pointer to the next item that in the tree (starting from item) - * that matches the key based on a depth first search of the tree. A null - * pointer is returned if we've reached the end of the tree and have not - * matched the key. - * - * This routine uses the tree container's comp function to determine the - * whether there is a match between the key and each item we search in the - * tree. This means the actual tree type constructed determines how the - * compare is done with the key. In the case no compare routine is given - * and NULL pointer is always returned for this function. - * - */ -OPAL_DECLSPEC opal_tree_item_t *opal_tree_find_with(opal_tree_item_t *item, - void *key); -END_C_DECLS - -#endif /* OPAL_TREE_H */ diff --git a/opal/dss/Makefile.am b/opal/dss/Makefile.am deleted file mode 100644 index 329e14ff706..00000000000 --- a/opal/dss/Makefile.am +++ /dev/null @@ -1,41 +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-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) 2012 Los Alamos National Security, Inc. All rights reserved. -# Copyright (c) 2014 Cisco Systems, Inc. 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 - -headers += \ - dss/dss.h \ - dss/dss_types.h \ - dss/dss_internal.h - -lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += \ - dss/dss_internal_functions.c \ - dss/dss_compare.c \ - dss/dss_copy.c \ - dss/dss_dump.c \ - dss/dss_load_unload.c \ - dss/dss_lookup.c \ - dss/dss_pack.c \ - dss/dss_peek.c \ - dss/dss_print.c \ - dss/dss_register.c \ - dss/dss_unpack.c \ - dss/dss_open_close.c diff --git a/opal/dss/dss.h b/opal/dss/dss.h deleted file mode 100644 index b980d346449..00000000000 --- a/opal/dss/dss.h +++ /dev/null @@ -1,509 +0,0 @@ -/* -*- 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) 2012 Los Alamos National Security, Inc. All rights reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. - * Copyright (c) 2018 Triad National Security, LLC. All rights - * reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -/** - * @file - * - * Data packing subsystem. - */ - -#ifndef OPAL_DSS_H_ -#define OPAL_DSS_H_ - -#include "opal_config.h" - -#include "opal/dss/dss_types.h" - -BEGIN_C_DECLS - -/* Provide a macro for determining the bool value of an opal_value_t */ -#define OPAL_CHECK_BOOL(v, p) \ - do { \ - if (OPAL_UNDEF == (v)->type) { \ - (p) = true; \ - } else { \ - (p) = (v)->data.flag; \ - } \ - } while(0) - -/* A non-API function for something that happens in a number - * of places throughout the code base - loading a value into - * an opal_value_t structure - */ -OPAL_DECLSPEC int opal_value_load(opal_value_t *kv, - void *data, opal_data_type_t type); -OPAL_DECLSPEC int opal_value_unload(opal_value_t *kv, - void **data, opal_data_type_t type); -OPAL_DECLSPEC int opal_value_xfer(opal_value_t *dest, - opal_value_t *src); -/** - * Top-level interface function to pack one or more values into a - * buffer. - * - * The pack function packs one or more values of a specified type into - * the specified buffer. The buffer must have already been - * initialized via an OBJ_NEW or OBJ_CONSTRUCT call - otherwise, the - * pack_value function will return an error. Providing an unsupported - * type flag will likewise be reported as an error. - * - * Note that any data to be packed that is not hard type cast (i.e., - * not type cast to a specific size) may lose precision when unpacked - * by a non-homogeneous recipient. The DSS will do its best to deal - * with heterogeneity issues between the packer and unpacker in such - * cases. Sending a number larger than can be handled by the recipient - * will return an error code (generated by the DSS upon unpacking) via - * the RML upon transmission - the DSS cannot detect such errors - * during packing. - * - * @param *buffer A pointer to the buffer into which the value is to - * be packed. - * - * @param *src A void* pointer to the data that is to be packed. Note - * that strings are to be passed as (char **) - i.e., the caller must - * pass the address of the pointer to the string as the void*. This - * allows the DSS to use a single interface function, but still allow - * the caller to pass multiple strings in a single call. - * - * @param num A size_t value indicating the number of values that are - * to be packed, beginning at the location pointed to by src. A string - * value is counted as a single value regardless of length. The values - * must be contiguous in memory. Arrays of pointers (e.g., string - * arrays) should be contiguous, although (obviously) the data pointed - * to need not be contiguous across array entries. - * - * @param type The type of the data to be packed - must be one of the - * DSS defined data types. - * - * @retval OPAL_SUCCESS The data was packed as requested. - * - * @retval OPAL_ERROR(s) An appropriate OPAL error code indicating the - * problem encountered. This error code should be handled - * appropriately. - * - * @code - * opal_buffer_t *buffer; - * int32_t src; - * - * status_code = opal_dss.pack(buffer, &src, 1, OPAL_INT32); - * @endcode - */ -typedef int (*opal_dss_pack_fn_t)(opal_buffer_t *buffer, const void *src, - int32_t num_values, - opal_data_type_t type); - -/** - * Unpack values from a buffer. - * - * The unpack function unpacks the next value (or values) of a - * specified type from the specified buffer. - * - * The buffer must have already been initialized via an OBJ_NEW or - * OBJ_CONSTRUCT call (and assumedly filled with some data) - - * otherwise, the unpack_value function will return an - * error. Providing an unsupported type flag will likewise be reported - * as an error, as will specifying a data type that DOES NOT match the - * type of the next item in the buffer. An attempt to read beyond the - * end of the stored data held in the buffer will also return an - * error. - * - * NOTE: it is possible for the buffer to be corrupted and that - * the DSS will *think* there is a proper variable type at the - * beginning of an unpack region - but that the value is bogus (e.g., just - * a byte field in a string array that so happens to have a value that - * matches the specified data type flag). Therefore, the data type error check - * is NOT completely safe. This is true for ALL unpack functions. - * - * - * Unpacking values is a "destructive" process - i.e., the values are - * removed from the buffer, thus reducing the buffer size. It is - * therefore not possible for the caller to re-unpack a value from the - * same buffer. - * - * Warning: The caller is responsible for providing adequate memory - * storage for the requested data. The opal_dss_peek() function is - * provided to assist in meeting this requirement. As noted below, the user - * must provide a parameter indicating the maximum number of values that - * can be unpacked into the allocated memory. If more values exist in the - * buffer than can fit into the memory storage, then the dss will unpack - * what it can fit into that location and return an error code indicating - * that the buffer was only partially unpacked. - * - * Note that any data that was not hard type cast (i.e., not type cast - * to a specific size) when packed may lose precision when unpacked by - * a non-homogeneous recipient. The DSS will do its best to deal with - * heterogeneity issues between the packer and unpacker in such - * cases. Sending a number larger than can be handled by the recipient - * will return an error code (generated by the DSS upon unpacking) via - * the RML upon transmission - the DSS cannot detect such errors - * during packing. - * - * @param *buffer A pointer to the buffer from which the value will be - * extracted. - * - * @param *dest A void* pointer to the memory location into which the - * data is to be stored. Note that these values will be stored - * contiguously in memory. For strings, this pointer must be to (char - * **) to provide a means of supporting multiple string - * operations. The DSS unpack function will allocate memory for each - * string in the array - the caller must only provide adequate memory - * for the array of pointers. - * - * @param *num A pointer to a int32_t value indicating the maximum - * number of values that are to be unpacked, beginning at the location - * pointed to by src. This is provided to help protect the caller from - * memory overrun. Note that a string - * value is counted as a single value regardless of length. - * - * @note The unpack function will return the actual number of values - * unpacked in this location. - * - * @param type The type of the data to be unpacked - must be one of - * the DSS defined data types. - * - * @retval *max_num_values The number of values actually unpacked. In - * most cases, this should match the maximum number provided in the - * parameters - but in no case will it exceed the value of this - * parameter. Note that if you unpack fewer values than are actually - * available, the buffer will be in an unpackable state - the dss will - * return an error code to warn of this condition. - * - * @retval OPAL_SUCCESS The next item in the buffer was successfully - * unpacked. - * - * @retval OPAL_ERROR(s) The unpack function returns an error code - * under one of several conditions: (a) the number of values in the - * item exceeds the max num provided by the caller; (b) the type of - * the next item in the buffer does not match the type specified by - * the caller; or (c) the unpack failed due to either an error in the - * buffer or an attempt to read past the end of the buffer. - * - * @code - * opal_buffer_t *buffer; - * int32_t dest; - * char **string_array; - * int32_t num_values; - * - * num_values = 1; - * status_code = opal_dss.unpack(buffer, (void*)&dest, &num_values, OPAL_INT32); - * - * num_values = 5; - * string_array = malloc(num_values*sizeof(char *)); - * status_code = opal_dss.unpack(buffer, (void*)(string_array), &num_values, OPAL_STRING); - * - * @endcode - */ -typedef int (*opal_dss_unpack_fn_t)(opal_buffer_t *buffer, void *dest, - int32_t *max_num_values, - opal_data_type_t type); - -/** - * Get the type and number of values of the next item in the buffer. - * - * The peek function looks at the next item in the buffer and returns - * both its type and the number of values in the item. This is a - * non-destructive function call that does not disturb the buffer, so - * it can be called multiple times if desired. - * - * @param buffer A pointer to the buffer in question. - * - * @param type A pointer to an opal_data_type_t variable where the - * type of the next item in the buffer is to be stored. Caller must - * have memory backing this location. - * - * @param number A pointer to a int32_t variable where the number of - * data values in the next item is to be stored. Caller must have - * memory backing this location. - * - * @retval OPAL_SUCCESS Requested info was successfully returned. - * @retval OPAL_ERROR(s) An appropriate error code indicating the - * problem will be returned. This should be handled appropriately by - * the caller. - * - */ -typedef int (*opal_dss_peek_next_item_fn_t)(opal_buffer_t *buffer, - opal_data_type_t *type, - int32_t *number); - -/** - * Unload the data payload from a buffer. - * - * The unload function provides the caller with a pointer to the data - * payload within the buffer and the size of that payload. This allows - * the user to directly access the payload - typically used in the RML - * to unload the payload from the buffer for transmission. - * - * @note This is a destructive operation. While the payload is - * undisturbed, the function will clear the buffer's pointers to the - * payload. Thus, the buffer and the payload are completely separated, - * leaving the caller free to OBJ_RELEASE the buffer. - * - * @param buffer A pointer to the buffer whose payload is to be - * unloaded. - * - * @param payload The address to a void* pointer that is to be loaded - * with the address of the data payload in the buffer. - * - * @param size The size (in bytes) of the data payload in the buffer. - * - * @retval OPAL_SUCCESS The request was succesfully completed. - * - * @retval OPAL_ERROR(s) An appropriate error code indicating the - * problem will be returned. This should be handled appropriately by - * the caller. - * - * @code - * opal_buffer_t *buffer; - * uint8_t *bytes; - * int32_t size; - * - * status_code = opal_dss.unload(buffer, (void**)(&bytes), &size); - * OBJ_RELEASE(buffer); - * @endcode - */ -typedef int (*opal_dss_unload_fn_t)(opal_buffer_t *buffer, - void **payload, - int32_t *size); - -/** - * Load a data payload into a buffer. - * - * The load function allows the caller to replace the payload in a - * buffer with one provided by the caller. If a payload already exists - * in the buffer, the function will "free" the existing data to - * release it, and then replace the data payload with the one provided - * by the caller. - * - * @note The buffer must be allocated in advance via the OBJ_NEW - * function call - failing to do so will cause the load function to - * return an error code. - * - * @note The caller is responsible for pre-packing the provided - * payload - the load function cannot convert to network byte order - * any data contained in the provided payload. - * - * @param buffer A pointer to the buffer into which lthe payload is to - * be loaded. - * - * @param payload A void* pointer to the payload to be loaded into the - * buffer. - * - * @param size The size (in bytes) of the provided payload. - * - * @retval OPAL_SUCCESS The request was successfully completed - * - * @retval OPAL_ERROR(s) An appropriate error code indicating the - * problem will be returned. This should be handled appropriately by - * the caller. - * - * @code - * opal_buffer_t *buffer; - * uint8_t bytes; - * int32_t size; - * - * buffer = OBJ_NEW(opal_buffer_t); - * status_code = opal_dss.load(buffer, (void*)(&bytes), size); - * @endcode - */ -typedef int (*opal_dss_load_fn_t)(opal_buffer_t *buffer, - void *payload, - int32_t size); - - -/** - * Copy a payload from one buffer to another - * This function will append a copy of the payload in one buffer into - * another buffer. If the destination buffer is NOT empty, then the - * type of the two buffers MUST match or else an - * error will be returned. If the destination buffer IS empty, then - * its type will be set to that of the source buffer. - * NOTE: This is NOT a destructive procedure - the - * source buffer's payload will remain intact, as will any pre-existing - * payload in the destination's buffer. - */ -typedef int (*opal_dss_copy_payload_fn_t)(opal_buffer_t *dest, - opal_buffer_t *src); - -/** - * DSS register function - * - * This function registers variables associated with the DSS system. - */ -OPAL_DECLSPEC int opal_dss_register_vars (void); - -/** - * DSS initialization function. - * - * In dynamic libraries, declared objects and functions don't get - * loaded until called. We need to ensure that the opal_dss function - * structure gets loaded, so we provide an "open" call that is - * executed as part of the program startup. - */ -OPAL_DECLSPEC int opal_dss_open(void); - -/** - * Copy a data value from one location to another. - * - * Since registered data types can be complex structures, the system - * needs some way to know how to copy the data from one location to - * another (e.g., for storage in the registry). This function, which - * can call other copy functions to build up complex data types, defines - * the method for making a copy of the specified data type. - * - * @param **dest The address of a pointer into which the - * address of the resulting data is to be stored. - * - * @param *src A pointer to the memory location from which the - * data is to be copied. - * - * @param type The type of the data to be copied - must be one of - * the DSS defined data types. - * - * @retval OPAL_SUCCESS The value was successfully copied. - * - * @retval OPAL_ERROR(s) An appropriate error code. - * - */ -typedef int (*opal_dss_copy_fn_t)(void **dest, void *src, opal_data_type_t type); - -/** - * Compare two data values. - * - * Since registered data types can be complex structures, the system - * needs some way to know how to compare two data values (e.g., when - * trying to order them in some fashion). This function, which - * can call other compare functions to build up complex data types, defines - * the method for comparing two values of the specified data type. - * - * @retval -1 Indicates first value is greater than second value - * @retval 0 Indicates two values are equal - * @retval +1 Indicates second value is greater than first value - */ -typedef int (*opal_dss_compare_fn_t)(const void *value1, const void *value2, - opal_data_type_t type); - - -/** - * Print a data value. - * - * Since registered data types can be complex structures, the system - * needs some way to know how to print them (i.e., convert them to a string - * representation). - * - * @retval OPAL_SUCCESS The value was successfully printed. - * - * @retval OPAL_ERROR(s) An appropriate error code. - */ -typedef int (*opal_dss_print_fn_t)(char **output, char *prefix, void *src, opal_data_type_t type); - - -/** - * Print a data value to an output stream for debugging purposes - * - * Uses the dss.print command to obtain a string version of the data value - * and prints it to the designated output stream. - * - * @retval OPAL_SUCCESS The value was successfully printed. - * - * @retval OPAL_ERROR(s) An appropriate error code. - */ -typedef int (*opal_dss_dump_fn_t)(int output_stream, void *src, opal_data_type_t type); - -/** - * Register a set of data handling functions. - * - * * This function registers a set of data type functions for a specific - * type. An integer is returned that should be used a an argument to - * future invocations of opal_dss.pack(), opal_dss.unpack(), opal_dss.copy(), - * and opal_dss.compare, which - * will trigger calls to the appropriate functions. This - * is most useful when extending the datatypes that the dss can - * handle; pack and unpack functions can nest calls to opal_dss.pack() - * / opal_dss.unpack(), so defining small pack/unpack functions can be - * used recursively to build larger types (e.g., packing/unpacking - * structs can use calls to opal_dss.pack()/unpack() to serialize / - * deserialize individual members). This is likewise true for the copy - * and compare functions. - * - * @param pack_fn [IN] Function pointer to the pack routine - * @param unpack_fn [IN] Function pointer to the unpack routine - * @param copy_fn [IN] Function pointer to copy routine - * @param compare_fn [IN] Function pointer to compare routine - * @param print_fn [IN] Function pointer to print routine - * @param structured [IN] Boolean indicator as to whether or not the data is structured. A true - * value indicates that this data type is always passed via reference (i.e., a pointer to the - * object is passed) as opposed to directly (e.g., the way an int32_t would appear) - * @param name [IN] String name for this pair (mainly for debugging) - * @param type [OUT] Type number for this registration - * - * @returns OPAL_SUCCESS upon success - * - */ -typedef int (*opal_dss_register_fn_t)(opal_dss_pack_fn_t pack_fn, - opal_dss_unpack_fn_t unpack_fn, - opal_dss_copy_fn_t copy_fn, - opal_dss_compare_fn_t compare_fn, - opal_dss_print_fn_t print_fn, - bool structured, - const char *name, opal_data_type_t *type); -/* - * This function looks up the string name corresponding to the identified - * data type - used for debugging messages. - */ -typedef char* (*opal_dss_lookup_data_type_fn_t)(opal_data_type_t type); - -/* - * Dump the data type list - used for debugging to see what has been registered - */ -typedef void (*opal_dss_dump_data_types_fn_t)(int output); - -/* return true if the data type is structured */ -typedef bool (*opal_dss_structured_fn_t)(opal_data_type_t type); - -/** - * Base structure for the DSS - * - * Base module structure for the DSS - presents the required function - * pointers to the calling interface. - */ -struct opal_dss_t { - opal_dss_pack_fn_t pack; - opal_dss_unpack_fn_t unpack; - opal_dss_copy_fn_t copy; - opal_dss_compare_fn_t compare; - opal_dss_print_fn_t print; - opal_dss_structured_fn_t structured; - opal_dss_peek_next_item_fn_t peek; - opal_dss_unload_fn_t unload; - opal_dss_load_fn_t load; - opal_dss_copy_payload_fn_t copy_payload; - opal_dss_register_fn_t register_type; - opal_dss_lookup_data_type_fn_t lookup_data_type; - opal_dss_dump_data_types_fn_t dump_data_types; - opal_dss_dump_fn_t dump; -}; -typedef struct opal_dss_t opal_dss_t; - -OPAL_DECLSPEC extern opal_dss_t opal_dss; /* holds dss function pointers */ - -END_C_DECLS - -#endif /* OPAL_DSS_H */ diff --git a/opal/dss/dss_compare.c b/opal/dss/dss_compare.c deleted file mode 100644 index 140198b45aa..00000000000 --- a/opal/dss/dss_compare.c +++ /dev/null @@ -1,494 +0,0 @@ -/* - * Copyright (c) 2004-2007 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) 2012 Los Alamos National Security, Inc. All rights reserved. - * Copyright (c) 2014-2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2014-2020 Intel, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" - -#include -#ifdef HAVE_SYS_TIME_H -#include /* for struct timeval */ -#endif - -#include "opal/dss/dss_internal.h" - -int opal_dss_compare(const void *value1, const void *value2, opal_data_type_t type) -{ - opal_dss_type_info_t *info; - - /* check for error */ - if (NULL == value1 || NULL == value2) { - return OPAL_ERR_BAD_PARAM; - } - - /* Lookup the compare function for this type and call it */ - - if (NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, type))) { - return OPAL_ERR_UNKNOWN_DATA_TYPE; - } - - return info->odti_compare_fn(value1, value2, type); -} - -/* - * NUMERIC COMPARE FUNCTIONS - */ -int opal_dss_compare_int(int *value1, int *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_uint(unsigned int *value1, unsigned int *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_size(size_t *value1, size_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_pid(pid_t *value1, pid_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_byte(char *value1, char *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_char(char *value1, char *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_int8(int8_t *value1, int8_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_uint8(uint8_t *value1, uint8_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_int16(int16_t *value1, int16_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_uint16(uint16_t *value1, uint16_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_int32(int32_t *value1, int32_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_uint32(uint32_t *value1, uint32_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_int64(int64_t *value1, int64_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_uint64(uint64_t *value1, uint64_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_float(float *value1, float *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_double(double *value1, double *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -/* - * NON-NUMERIC SYSTEM TYPES - */ - -/* NULL */ -int opal_dss_compare_null(char *value1, char *value2, opal_data_type_t type) -{ - return OPAL_EQUAL; -} - -/* BOOL */ -int opal_dss_compare_bool(bool *value1, bool *value2, opal_data_type_t type) -{ - if (*value1 && !(*value2)) return OPAL_VALUE1_GREATER; - - if (*value2 && !(*value1)) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; - -} - -/* STRING */ -int opal_dss_compare_string(char *value1, char *value2, opal_data_type_t type) -{ - if (0 < strcmp(value1, value2)) return OPAL_VALUE2_GREATER; - - if (0 > strcmp(value1, value2)) return OPAL_VALUE1_GREATER; - - return OPAL_EQUAL; -} - -/* TIMEVAL */ -int opal_dss_compare_timeval(struct timeval *value1, struct timeval *value2, opal_data_type_t type) -{ - if (value1->tv_sec > value2->tv_sec) return OPAL_VALUE1_GREATER; - if (value2->tv_sec > value1->tv_sec) return OPAL_VALUE2_GREATER; - - /* seconds were equal - check usec's */ - if (value1->tv_usec > value2->tv_usec) return OPAL_VALUE1_GREATER; - if (value2->tv_usec > value1->tv_usec) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -/* TIME */ -int opal_dss_compare_time(time_t *value1, time_t *value2, opal_data_type_t type) -{ - if (value1 > value2) return OPAL_VALUE1_GREATER; - if (value2 > value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -/* COMPARE FUNCTIONS FOR GENERIC OPAL TYPES */ -/* OPAL_DATA_TYPE */ -int opal_dss_compare_dt(opal_data_type_t *value1, opal_data_type_t *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -/* OPAL_BYTE_OBJECT */ -int opal_dss_compare_byte_object(opal_byte_object_t *value1, opal_byte_object_t *value2, opal_data_type_t type) -{ - int checksum, diff; - int32_t i; - - /* compare the sizes first - bigger size object is "greater than" */ - if (value1->size > value2->size) return OPAL_VALUE1_GREATER; - - if (value2->size > value1->size) return OPAL_VALUE2_GREATER; - - /* get here if the two sizes are identical - now do a simple checksum-style - * calculation to determine "biggest" - */ - checksum = 0; - - for (i=0; i < value1->size; i++) { - /* protect against overflows */ - diff = value1->bytes[i] - value2->bytes[i]; - if (INT_MAX-abs(checksum)-abs(diff) < 0) { /* got an overflow condition */ - checksum = 0; - } - checksum += diff; - } - - if (0 > checksum) return OPAL_VALUE2_GREATER; /* sum of value2 bytes was greater */ - - if (0 < checksum) return OPAL_VALUE1_GREATER; /* of value1 bytes was greater */ - - return OPAL_EQUAL; /* sum of both value's bytes was identical */ -} - -/* OPAL_VALUE */ -int opal_dss_compare_value(opal_value_t *value1, opal_value_t *value2, opal_data_type_t type) -{ - if (NULL == value1 && NULL == value2) { - return OPAL_EQUAL; - } - if (NULL == value2) { - return OPAL_VALUE1_GREATER; - } - if (NULL == value1) { - return OPAL_VALUE2_GREATER; - } - if (value1->type != value2->type) { - opal_output(0, "COMPARE-OPAL-VALUE: INCONSISTENT TYPE %d vs %d", (int)value1->type, (int)value2->type); - return OPAL_EQUAL; - } - switch (value1->type) { - case OPAL_BYTE: - return opal_dss_compare_byte((char *)&value1->data.byte, (char *)&value2->data.byte, type); - case OPAL_STRING: - return opal_dss_compare_string(value1->data.string, value2->data.string, type); - case OPAL_PID: - return opal_dss_compare_pid(&value1->data.pid, &value2->data.pid, type); - case OPAL_INT: - return opal_dss_compare_int(&value1->data.integer, &value2->data.integer, type); - case OPAL_INT8: - return opal_dss_compare_int8(&value1->data.int8, &value2->data.int8, type); - case OPAL_INT16: - return opal_dss_compare_int16(&value1->data.int16, &value2->data.int16, type); - case OPAL_INT32: - return opal_dss_compare_int32(&value1->data.int32, &value2->data.int32, type); - case OPAL_INT64: - return opal_dss_compare_int64(&value1->data.int64, &value2->data.int64, type); - case OPAL_UINT: - return opal_dss_compare_uint(&value1->data.uint, &value2->data.uint, type); - case OPAL_UINT8: - return opal_dss_compare_uint8(&value1->data.uint8, &value2->data.uint8, type); - case OPAL_UINT16: - return opal_dss_compare_uint16(&value1->data.uint16, &value2->data.uint16, type); - case OPAL_UINT32: - return opal_dss_compare_uint32(&value1->data.uint32, &value2->data.uint32, type); - case OPAL_UINT64: - return opal_dss_compare_uint64(&value1->data.uint64, &value2->data.uint64, type); - case OPAL_BYTE_OBJECT: - return opal_dss_compare_byte_object(&value1->data.bo, &value2->data.bo, type); - case OPAL_SIZE: - return opal_dss_compare_size(&value1->data.size, &value2->data.size, type); - case OPAL_FLOAT: - return opal_dss_compare_float(&value1->data.fval, &value2->data.fval, type); - case OPAL_DOUBLE: - return opal_dss_compare_double(&value1->data.dval, &value2->data.dval, type); - case OPAL_BOOL: - return opal_dss_compare_bool(&value1->data.flag, &value2->data.flag, type); - case OPAL_TIMEVAL: - return opal_dss_compare_timeval(&value1->data.tv, &value2->data.tv, type); - case OPAL_NAME: - return opal_dss_compare_name(&value1->data.name, &value2->data.name, type); - case OPAL_ENVAR: - return opal_dss_compare_envar(&value1->data.envar, &value2->data.envar, type); - default: - opal_output(0, "COMPARE-OPAL-VALUE: UNSUPPORTED TYPE %d", (int)value1->type); - return OPAL_EQUAL; - } -} - -/* OPAL_BUFFER */ -int opal_dss_compare_buffer_contents(opal_buffer_t *value1, opal_buffer_t *value2, opal_data_type_t type) -{ - return OPAL_EQUAL; /* eventually compare bytes in buffers */ -} - -/* OPAL_NAME */ -int opal_dss_compare_name(opal_process_name_t *value1, - opal_process_name_t *value2, - opal_data_type_t type) -{ - if (NULL == value1 && NULL == value2) { - return OPAL_EQUAL; - } else if (NULL == value1) { - return OPAL_VALUE2_GREATER; - } else if (NULL == value2) { - return OPAL_VALUE1_GREATER; - } - - /* If any of the fields are wildcard, - * then we want to just ignore that one field. In the case - * of OPAL_NAME_WILDCARD (where ALL of the fields are wildcard), this - * will automatically result in OPAL_EQUAL for any name in the other - * value - a totally useless result, but consistent in behavior. - */ - - /** check the jobids - if one of them is WILDCARD, then ignore - * this field since anything is okay - */ - if (value1->jobid != OPAL_JOBID_WILDCARD && - value2->jobid != OPAL_JOBID_WILDCARD) { - if (value1->jobid < value2->jobid) { - return OPAL_VALUE2_GREATER; - } else if (value1->jobid > value2->jobid) { - return OPAL_VALUE1_GREATER; - } - } - - /** check the vpids - if one of them is WILDCARD, then ignore - * this field since anything is okay - */ - if (value1->vpid != OPAL_VPID_WILDCARD && - value2->vpid != OPAL_VPID_WILDCARD) { - if (value1->vpid < value2->vpid) { - return OPAL_VALUE2_GREATER; - } else if (value1->vpid > value2->vpid) { - return OPAL_VALUE1_GREATER; - } - } - - /** only way to get here is if all fields are equal or WILDCARD */ - return OPAL_EQUAL; -} - -int opal_dss_compare_vpid(opal_vpid_t *value1, - opal_vpid_t *value2, - opal_data_type_t type) -{ - /** if either value is WILDCARD, then return equal */ - if (*value1 == OPAL_VPID_WILDCARD || - *value2 == OPAL_VPID_WILDCARD) return OPAL_EQUAL; - - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_jobid(opal_jobid_t *value1, - opal_jobid_t *value2, - opal_data_type_t type) -{ - /** if either value is WILDCARD, then return equal */ - if (*value1 == OPAL_JOBID_WILDCARD || - *value2 == OPAL_JOBID_WILDCARD) return OPAL_EQUAL; - - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_status(int *value1, int *value2, opal_data_type_t type) -{ - if (*value1 > *value2) return OPAL_VALUE1_GREATER; - - if (*value2 > *value1) return OPAL_VALUE2_GREATER; - - return OPAL_EQUAL; -} - -int opal_dss_compare_envar(opal_envar_t *value1, opal_envar_t *value2, opal_data_type_t type) -{ - int rc; - - if (NULL != value1->envar) { - if (NULL == value2->envar) { - return OPAL_VALUE1_GREATER; - } - rc = strcmp(value1->envar, value2->envar); - if (rc < 0) { - return OPAL_VALUE2_GREATER; - } else if (0 < rc) { - return OPAL_VALUE1_GREATER; - } - } else if (NULL != value2->envar) { - /* we know value1->envar had to be NULL */ - return OPAL_VALUE2_GREATER; - } - - /* if both are NULL or are equal, then check value */ - if (NULL != value1->value) { - if (NULL == value2->value) { - return OPAL_VALUE1_GREATER; - } - rc = strcmp(value1->value, value2->value); - if (rc < 0) { - return OPAL_VALUE2_GREATER; - } else if (0 < rc) { - return OPAL_VALUE1_GREATER; - } - } else if (NULL != value2->value) { - /* we know value1->value had to be NULL */ - return OPAL_VALUE2_GREATER; - } - - /* finally, check separator */ - if (value1->separator < value2->separator) { - return OPAL_VALUE2_GREATER; - } - if (value2->separator < value1->separator) { - return OPAL_VALUE1_GREATER; - } - return OPAL_EQUAL; -} diff --git a/opal/dss/dss_copy.c b/opal/dss/dss_copy.c deleted file mode 100644 index 9b75c04b7cd..00000000000 --- a/opal/dss/dss_copy.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (c) 2004-2007 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) 2014-2020 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" - -#include "opal/util/output.h" -#include "opal/dss/dss_internal.h" -#include "opal/util/error.h" - -int opal_dss_copy(void **dest, void *src, opal_data_type_t type) -{ - opal_dss_type_info_t *info; - - /* check for error */ - if (NULL == dest) { - return OPAL_ERR_BAD_PARAM; - } - if (NULL == src && (OPAL_NULL != type && OPAL_STRING != type)) { - return OPAL_ERR_BAD_PARAM; - } - - /* Lookup the copy function for this type and call it */ - - if (NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, type))) { - return OPAL_ERR_UNKNOWN_DATA_TYPE; - } - - return info->odti_copy_fn(dest, src, type); -} - -/* - * STANDARD COPY FUNCTION - WORKS FOR EVERYTHING NON-STRUCTURED - */ -int opal_dss_std_copy(void **dest, void *src, opal_data_type_t type) -{ - size_t datasize; - uint8_t *val = NULL; - - switch(type) { - case OPAL_BOOL: - datasize = sizeof(bool); - break; - - case OPAL_INT: - case OPAL_UINT: - case OPAL_STATUS: - datasize = sizeof(int); - break; - - case OPAL_SIZE: - datasize = sizeof(size_t); - break; - - case OPAL_PID: - datasize = sizeof(pid_t); - break; - - case OPAL_BYTE: - case OPAL_INT8: - case OPAL_UINT8: - datasize = 1; - break; - - case OPAL_INT16: - case OPAL_UINT16: - datasize = 2; - break; - - case OPAL_INT32: - case OPAL_UINT32: - datasize = 4; - break; - - case OPAL_INT64: - case OPAL_UINT64: - datasize = 8; - break; - - case OPAL_DATA_TYPE: - datasize = sizeof(opal_data_type_t); - break; - - case OPAL_FLOAT: - datasize = sizeof(float); - break; - - case OPAL_TIMEVAL: - datasize = sizeof(struct timeval); - break; - - case OPAL_TIME: - datasize = sizeof(time_t); - break; - - case OPAL_NAME: - datasize = sizeof(opal_process_name_t); - break; - - default: - return OPAL_ERR_UNKNOWN_DATA_TYPE; - } - - val = (uint8_t*)malloc(datasize); - if (NULL == val) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - memcpy(val, src, datasize); - *dest = val; - - return OPAL_SUCCESS; -} - -/* COPY FUNCTIONS FOR NON-STANDARD SYSTEM TYPES */ - -/* - * NULL - */ -int opal_dss_copy_null(char **dest, char *src, opal_data_type_t type) -{ - char *val; - - *dest = (char*)malloc(sizeof(char)); - if (NULL == *dest) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - val = *dest; /* save the address of the value */ - - /* set the dest to null */ - *val = 0x00; - - return OPAL_SUCCESS; -} - -/* - * STRING - */ -int opal_dss_copy_string(char **dest, char *src, opal_data_type_t type) -{ - if (NULL == src) { /* got zero-length string/NULL pointer - store NULL */ - *dest = NULL; - } else { - *dest = strdup(src); - } - - return OPAL_SUCCESS; -} - -/* COPY FUNCTIONS FOR GENERIC OPAL TYPES */ - -/* - * OPAL_BYTE_OBJECT - */ -int opal_dss_copy_byte_object(opal_byte_object_t **dest, opal_byte_object_t *src, - opal_data_type_t type) -{ - /* allocate space for the new object */ - *dest = (opal_byte_object_t*)malloc(sizeof(opal_byte_object_t)); - if (NULL == *dest) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - (*dest)->size = src->size; - - /* allocate the required space for the bytes */ - if (NULL == src->bytes) { - (*dest)->bytes = NULL; - } else { - (*dest)->bytes = (uint8_t*)malloc(src->size); - if (NULL == (*dest)->bytes) { - OBJ_RELEASE(*dest); - return OPAL_ERR_OUT_OF_RESOURCE; - } - /* copy the data across */ - memcpy((*dest)->bytes, src->bytes, src->size); - } - - return OPAL_SUCCESS; -} - -/* OPAL_VALUE */ -int opal_dss_copy_value(opal_value_t **dest, opal_value_t *src, - opal_data_type_t type) -{ - opal_value_t *p; - - /* create the new object */ - *dest = OBJ_NEW(opal_value_t); - if (NULL == *dest) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - p = *dest; - - /* copy the type and key */ - if (NULL != src->key) { - p->key = strdup(src->key); - } - p->type = src->type; - - /* copy the right field */ - switch (src->type) { - case OPAL_BYTE: - p->data.byte = src->data.byte; - break; - case OPAL_STRING: - if (NULL != src->data.string) { - p->data.string = strdup(src->data.string); - } else { - p->data.string = NULL; - } - break; - case OPAL_PID: - p->data.pid = src->data.pid; - break; - case OPAL_INT: - /* to avoid alignment issues */ - memcpy(&p->data.integer, &src->data.integer, sizeof(int)); - break; - case OPAL_INT8: - p->data.int8 = src->data.int8; - break; - case OPAL_INT16: - /* to avoid alignment issues */ - memcpy(&p->data.int16, &src->data.int16, 2); - break; - case OPAL_INT32: - /* to avoid alignment issues */ - memcpy(&p->data.int32, &src->data.int32, 4); - break; - case OPAL_INT64: - /* to avoid alignment issues */ - memcpy(&p->data.int64, &src->data.int64, 8); - break; - case OPAL_UINT: - /* to avoid alignment issues */ - memcpy(&p->data.uint, &src->data.uint, sizeof(unsigned int)); - break; - case OPAL_UINT8: - p->data.uint8 = src->data.uint8; - break; - case OPAL_UINT16: - /* to avoid alignment issues */ - memcpy(&p->data.uint16, &src->data.uint16, 2); - break; - case OPAL_UINT32: - /* to avoid alignment issues */ - memcpy(&p->data.uint32, &src->data.uint32, 4); - break; - case OPAL_UINT64: - /* to avoid alignment issues */ - memcpy(&p->data.uint64, &src->data.uint64, 8); - break; - case OPAL_BYTE_OBJECT: - if (NULL != src->data.bo.bytes && 0 < src->data.bo.size) { - p->data.bo.bytes = malloc(src->data.bo.size); - memcpy(p->data.bo.bytes, src->data.bo.bytes, src->data.bo.size); - p->data.bo.size = src->data.bo.size; - } else { - p->data.bo.bytes = NULL; - p->data.bo.size = 0; - } - break; - case OPAL_NAME: - memcpy(&p->data.name, &src->data.name, sizeof(opal_process_name_t)); - break; - case OPAL_ENVAR: - OBJ_CONSTRUCT(&p->data.envar, opal_envar_t); - if (NULL != src->data.envar.envar) { - p->data.envar.envar = strdup(src->data.envar.envar); - } - if (NULL != src->data.envar.value) { - p->data.envar.value = strdup(src->data.envar.value); - } - p->data.envar.separator = src->data.envar.separator; - break; - default: - opal_output(0, "COPY-OPAL-VALUE: UNSUPPORTED TYPE %d", (int)src->type); - return OPAL_ERROR; - } - - return OPAL_SUCCESS; -} - -int opal_dss_copy_buffer_contents(opal_buffer_t **dest, opal_buffer_t *src, - opal_data_type_t type) -{ - *dest = OBJ_NEW(opal_buffer_t); - opal_dss.copy_payload(*dest, src); - return OPAL_SUCCESS; -} - -/* PROCESS NAME */ -int opal_dss_copy_name(opal_process_name_t **dest, opal_process_name_t *src, opal_data_type_t type) -{ - opal_process_name_t *val; - - val = (opal_process_name_t*)malloc(sizeof(opal_process_name_t)); - if (NULL == val) { - OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - val->jobid = src->jobid; - val->vpid = src->vpid; - - *dest = val; - return OPAL_SUCCESS; -} - -/* - * JOBID - */ -int opal_dss_copy_jobid(opal_jobid_t **dest, opal_jobid_t *src, opal_data_type_t type) -{ - opal_jobid_t *val; - - val = (opal_jobid_t*)malloc(sizeof(opal_jobid_t)); - if (NULL == val) { - OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - *val = *src; - *dest = val; - - return OPAL_SUCCESS; -} - -/* - * VPID - */ -int opal_dss_copy_vpid(opal_vpid_t **dest, opal_vpid_t *src, opal_data_type_t type) -{ - opal_vpid_t *val; - - val = (opal_vpid_t*)malloc(sizeof(opal_vpid_t)); - if (NULL == val) { - OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - *val = *src; - *dest = val; - - return OPAL_SUCCESS; -} - -int opal_dss_copy_envar(opal_envar_t **dest, opal_envar_t *src, opal_data_type_t type) -{ - opal_envar_t *val; - - val = OBJ_NEW(opal_envar_t); - if (NULL == val) { - OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE); - return OPAL_ERR_OUT_OF_RESOURCE; - } - - if (NULL != src->envar) { - val->envar = strdup(src->envar); - } - if (NULL != src->value) { - val->value = strdup(src->value); - } - val->separator = src->separator; - *dest = val; - - return OPAL_SUCCESS; -} diff --git a/opal/dss/dss_dump.c b/opal/dss/dss_dump.c deleted file mode 100644 index 6d356420ee4..00000000000 --- a/opal/dss/dss_dump.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004-2005 The Trustees of Indiana University. - * All rights reserved. - * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. - * 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 "opal_config.h" - -#include "opal/util/output.h" - -#include "opal/dss/dss_internal.h" - -int opal_dss_dump(int output_stream, void *src, opal_data_type_t type) -{ - char *sptr; - int rc; - - if (OPAL_SUCCESS != (rc = opal_dss.print(&sptr, NULL, src, type))) { - return rc; - } - - opal_output(output_stream, "%s", sptr); - free(sptr); - - return OPAL_SUCCESS; -} - - -void opal_dss_dump_data_types(int output) -{ - opal_dss_type_info_t *ptr; - opal_data_type_t j; - int32_t i; - - opal_output(output, "DUMP OF REGISTERED DATA TYPES"); - - j = 0; - for (i=0; i < opal_pointer_array_get_size(&opal_dss_types); i++) { - ptr = opal_pointer_array_get_item(&opal_dss_types, i); - if (NULL != ptr) { - j++; - /* print out the info */ - opal_output(output, "\tIndex: %lu\tData type: %lu\tName: %s", - (unsigned long)j, - (unsigned long)ptr->odti_type, - ptr->odti_name); - } - } -} - diff --git a/opal/dss/dss_internal.h b/opal/dss/dss_internal.h deleted file mode 100644 index 75967694098..00000000000 --- a/opal/dss/dss_internal.h +++ /dev/null @@ -1,551 +0,0 @@ -/* -*- C -*- - * - * Copyright (c) 2004-2007 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) 2012 Los Alamos National Security, Inc. All rights reserved. - * Copyright (c) 2014-2020 Intel, Inc. All rights reserved. - * Copyright (c) 2014 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - * - */ -#ifndef OPAL_DSS_INTERNAL_H_ -#define OPAL_DSS_INTERNAL_H_ - -#include "opal_config.h" -#include "opal/constants.h" - -#ifdef HAVE_SYS_TIME_H -#include /* for struct timeval */ -#endif - -#include "opal/class/opal_pointer_array.h" - -#include "opal/dss/dss.h" -#include "opal/util/proc.h" - -#if !defined(STDC_HEADERS) && HAVE_MEMORY_H -# include -#endif -#include - -BEGIN_C_DECLS - -/* - * The default starting chunk size - */ -#define OPAL_DSS_DEFAULT_INITIAL_SIZE 2048 -/* - * The default threshold size when we switch from doubling the - * buffer size to addatively increasing it - */ -#define OPAL_DSS_DEFAULT_THRESHOLD_SIZE 4096 - -/* - * Internal type corresponding to size_t. Do not use this in - * interface calls - use OPAL_SIZE instead. - */ -#if SIZEOF_SIZE_T == 1 -#define DSS_TYPE_SIZE_T OPAL_UINT8 -#elif SIZEOF_SIZE_T == 2 -#define DSS_TYPE_SIZE_T OPAL_UINT16 -#elif SIZEOF_SIZE_T == 4 -#define DSS_TYPE_SIZE_T OPAL_UINT32 -#elif SIZEOF_SIZE_T == 8 -#define DSS_TYPE_SIZE_T OPAL_UINT64 -#else -#error Unsupported size_t size! -#endif - -/* - * Internal type corresponding to bool. Do not use this in interface - * calls - use OPAL_BOOL instead. - */ -#if SIZEOF__BOOL == 1 -#define DSS_TYPE_BOOL OPAL_UINT8 -#elif SIZEOF__BOOL == 2 -#define DSS_TYPE_BOOL OPAL_UINT16 -#elif SIZEOF__BOOL == 4 -#define DSS_TYPE_BOOL OPAL_UINT32 -#elif SIZEOF__BOOL == 8 -#define DSS_TYPE_BOOL OPAL_UINT64 -#else -#error Unsupported bool size! -#endif - -/* - * Internal type corresponding to int and unsigned int. Do not use - * this in interface calls - use OPAL_INT / OPAL_UINT instead. - */ -#if SIZEOF_INT == 1 -#define DSS_TYPE_INT OPAL_INT8 -#define DSS_TYPE_UINT OPAL_UINT8 -#elif SIZEOF_INT == 2 -#define DSS_TYPE_INT OPAL_INT16 -#define DSS_TYPE_UINT OPAL_UINT16 -#elif SIZEOF_INT == 4 -#define DSS_TYPE_INT OPAL_INT32 -#define DSS_TYPE_UINT OPAL_UINT32 -#elif SIZEOF_INT == 8 -#define DSS_TYPE_INT OPAL_INT64 -#define DSS_TYPE_UINT OPAL_UINT64 -#else -#error Unsupported int size! -#endif - -/* - * Internal type corresponding to pid_t. Do not use this in interface - * calls - use OPAL_PID instead. - */ -#if SIZEOF_PID_T == 1 -#define DSS_TYPE_PID_T OPAL_UINT8 -#elif SIZEOF_PID_T == 2 -#define DSS_TYPE_PID_T OPAL_UINT16 -#elif SIZEOF_PID_T == 4 -#define DSS_TYPE_PID_T OPAL_UINT32 -#elif SIZEOF_PID_T == 8 -#define DSS_TYPE_PID_T OPAL_UINT64 -#else -#error Unsupported pid_t size! -#endif - -/* Unpack generic size macros */ -#define UNPACK_SIZE_MISMATCH(unpack_type, remote_type, ret) \ - do { \ - switch(remote_type) { \ - case OPAL_UINT8: \ - UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint8_t, remote_type); \ - break; \ - case OPAL_INT8: \ - UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int8_t, remote_type); \ - break; \ - case OPAL_UINT16: \ - UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint16_t, remote_type); \ - break; \ - case OPAL_INT16: \ - UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int16_t, remote_type); \ - break; \ - case OPAL_UINT32: \ - UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint32_t, remote_type); \ - break; \ - case OPAL_INT32: \ - UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int32_t, remote_type); \ - break; \ - case OPAL_UINT64: \ - UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint64_t, remote_type); \ - break; \ - case OPAL_INT64: \ - UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int64_t, remote_type); \ - break; \ - default: \ - ret = OPAL_ERR_NOT_FOUND; \ - } \ - } while (0) - -/* NOTE: do not need to deal with endianness here, as the unpacking of - the underling sender-side type will do that for us. Repeat: the - data in tmpbuf[] is already in host byte order. */ -#define UNPACK_SIZE_MISMATCH_FOUND(unpack_type, tmptype, tmpdsstype) \ - do { \ - int32_t i; \ - tmptype *tmpbuf = (tmptype*)malloc(sizeof(tmptype) * (*num_vals)); \ - ret = opal_dss_unpack_buffer(buffer, tmpbuf, num_vals, tmpdsstype); \ - for (i = 0 ; i < *num_vals ; ++i) { \ - ((unpack_type*) dest)[i] = (unpack_type)(tmpbuf[i]); \ - } \ - free(tmpbuf); \ - } while (0) - - -/** - * Internal struct used for holding registered dss functions - */ -struct opal_dss_type_info_t { - opal_object_t super; - /* type identifier */ - opal_data_type_t odti_type; - /** Debugging string name */ - char *odti_name; - /** Pack function */ - opal_dss_pack_fn_t odti_pack_fn; - /** Unpack function */ - opal_dss_unpack_fn_t odti_unpack_fn; - /** copy function */ - opal_dss_copy_fn_t odti_copy_fn; - /** compare function */ - opal_dss_compare_fn_t odti_compare_fn; - /** print function */ - opal_dss_print_fn_t odti_print_fn; - /** flag to indicate structured data */ - bool odti_structured; -}; -/** - * Convenience typedef - */ -typedef struct opal_dss_type_info_t opal_dss_type_info_t; -OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_dss_type_info_t); - -/* - * globals needed within dss - */ -extern bool opal_dss_initialized; -extern bool opal_dss_debug; -extern int opal_dss_verbose; -extern int opal_dss_initial_size; -extern int opal_dss_threshold_size; -extern opal_pointer_array_t opal_dss_types; -extern opal_data_type_t opal_dss_num_reg_types; - -/* - * Implementations of API functions - */ - -int opal_dss_pack(opal_buffer_t *buffer, const void *src, - int32_t num_vals, - opal_data_type_t type); -int opal_dss_unpack(opal_buffer_t *buffer, void *dest, - int32_t *max_num_vals, - opal_data_type_t type); - -int opal_dss_copy(void **dest, void *src, opal_data_type_t type); - -int opal_dss_compare(const void *value1, const void *value2, - opal_data_type_t type); - -int opal_dss_print(char **output, char *prefix, void *src, opal_data_type_t type); - -int opal_dss_dump(int output_stream, void *src, opal_data_type_t type); - -int opal_dss_peek(opal_buffer_t *buffer, opal_data_type_t *type, - int32_t *number); - -int opal_dss_peek_type(opal_buffer_t *buffer, opal_data_type_t *type); - -int opal_dss_unload(opal_buffer_t *buffer, void **payload, - int32_t *bytes_used); -int opal_dss_load(opal_buffer_t *buffer, void *payload, int32_t bytes_used); - -int opal_dss_copy_payload(opal_buffer_t *dest, opal_buffer_t *src); - -int opal_dss_register(opal_dss_pack_fn_t pack_fn, - opal_dss_unpack_fn_t unpack_fn, - opal_dss_copy_fn_t copy_fn, - opal_dss_compare_fn_t compare_fn, - opal_dss_print_fn_t print_fn, - bool structured, - const char *name, opal_data_type_t *type); - -bool opal_dss_structured(opal_data_type_t type); - -char *opal_dss_lookup_data_type(opal_data_type_t type); - -void opal_dss_dump_data_types(int output); - -/* - * Specialized functions - */ -OPAL_DECLSPEC int opal_dss_pack_buffer(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -OPAL_DECLSPEC int opal_dss_unpack_buffer(opal_buffer_t *buffer, void *dst, - int32_t *num_vals, opal_data_type_t type); - -/* - * Internal pack functions - */ - -int opal_dss_pack_null(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); -int opal_dss_pack_byte(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_bool(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_int(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); -int opal_dss_pack_int16(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); -int opal_dss_pack_int32(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); -int opal_dss_pack_int64(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_sizet(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_pid(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_string(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_data_type(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_byte_object(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_value(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_buffer_contents(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_float(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_double(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_timeval(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_time(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_name(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_jobid(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_vpid(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -int opal_dss_pack_status(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); -int opal_dss_pack_envar(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type); - -/* - * Internal unpack functions - */ - -int opal_dss_unpack_null(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); -int opal_dss_unpack_byte(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_bool(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_int(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); -int opal_dss_unpack_int16(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); -int opal_dss_unpack_int32(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); -int opal_dss_unpack_int64(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_sizet(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_pid(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_string(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_data_type(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_byte_object(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_value(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_buffer_contents(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_float(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_double(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_timeval(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_time(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_name(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_jobid(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_vpid(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_status(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -int opal_dss_unpack_envar(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type); - -/* - * Internal copy functions - */ - -int opal_dss_std_copy(void **dest, void *src, opal_data_type_t type); - -int opal_dss_copy_null(char **dest, char *src, opal_data_type_t type); - -int opal_dss_copy_string(char **dest, char *src, opal_data_type_t type); - -int opal_dss_copy_byte_object(opal_byte_object_t **dest, opal_byte_object_t *src, - opal_data_type_t type); - -int opal_dss_copy_value(opal_value_t **dest, opal_value_t *src, - opal_data_type_t type); - -int opal_dss_copy_buffer_contents(opal_buffer_t **dest, opal_buffer_t *src, - opal_data_type_t type); - -int opal_dss_copy_name(opal_process_name_t **dest, opal_process_name_t *src, opal_data_type_t type); - -int opal_dss_copy_jobid(opal_jobid_t **dest, opal_jobid_t *src, opal_data_type_t type); - -int opal_dss_copy_vpid(opal_vpid_t **dest, opal_vpid_t *src, opal_data_type_t type); - -int opal_dss_copy_envar(opal_envar_t **dest, opal_envar_t *src, opal_data_type_t type); - - -/* - * Internal compare functions - */ - -int opal_dss_compare_bool(bool *value1, bool *value2, opal_data_type_t type); - -int opal_dss_compare_int(int *value1, int *value2, opal_data_type_t type); -int opal_dss_compare_uint(unsigned int *value1, unsigned int *value2, opal_data_type_t type); - -int opal_dss_compare_size(size_t *value1, size_t *value2, opal_data_type_t type); - -int opal_dss_compare_pid(pid_t *value1, pid_t *value2, opal_data_type_t type); - -int opal_dss_compare_byte(char *value1, char *value2, opal_data_type_t type); -int opal_dss_compare_char(char *value1, char *value2, opal_data_type_t type); -int opal_dss_compare_int8(int8_t *value1, int8_t *value2, opal_data_type_t type); -int opal_dss_compare_uint8(uint8_t *value1, uint8_t *value2, opal_data_type_t type); - -int opal_dss_compare_int16(int16_t *value1, int16_t *value2, opal_data_type_t type); -int opal_dss_compare_uint16(uint16_t *value1, uint16_t *value2, opal_data_type_t type); - -int opal_dss_compare_int32(int32_t *value1, int32_t *value2, opal_data_type_t type); -int opal_dss_compare_uint32(uint32_t *value1, uint32_t *value2, opal_data_type_t type); - -int opal_dss_compare_int64(int64_t *value1, int64_t *value2, opal_data_type_t type); -int opal_dss_compare_uint64(uint64_t *value1, uint64_t *value2, opal_data_type_t type); - -int opal_dss_compare_null(char *value1, char *value2, opal_data_type_t type); - -int opal_dss_compare_string(char *value1, char *value2, opal_data_type_t type); - -int opal_dss_compare_dt(opal_data_type_t *value1, opal_data_type_t *value2, opal_data_type_t type); - -int opal_dss_compare_byte_object(opal_byte_object_t *value1, opal_byte_object_t *value2, opal_data_type_t type); - -int opal_dss_compare_value(opal_value_t *value1, opal_value_t *value2, opal_data_type_t type); - -int opal_dss_compare_buffer_contents(opal_buffer_t *value1, opal_buffer_t *value2, opal_data_type_t type); - -int opal_dss_compare_float(float *value1, float *value2, opal_data_type_t type); - -int opal_dss_compare_double(double *value1, double *value2, opal_data_type_t type); - -int opal_dss_compare_timeval(struct timeval *value1, struct timeval *value2, opal_data_type_t type); - -int opal_dss_compare_time(time_t *value1, time_t *value2, opal_data_type_t type); - -int opal_dss_compare_name(opal_process_name_t *value1, - opal_process_name_t *value2, - opal_data_type_t type); - -int opal_dss_compare_vpid(opal_vpid_t *value1, - opal_vpid_t *value2, - opal_data_type_t type); - -int opal_dss_compare_jobid(opal_jobid_t *value1, - opal_jobid_t *value2, - opal_data_type_t type); - -int opal_dss_compare_status(int *value1, int *value2, opal_data_type_t type); -int opal_dss_compare_envar(opal_envar_t *value1, opal_envar_t *value2, opal_data_type_t type); - -/* - * Internal print functions - */ -int opal_dss_print_byte(char **output, char *prefix, uint8_t *src, opal_data_type_t type); - -int opal_dss_print_string(char **output, char *prefix, char *src, opal_data_type_t type); - -int opal_dss_print_size(char **output, char *prefix, size_t *src, opal_data_type_t type); -int opal_dss_print_pid(char **output, char *prefix, pid_t *src, opal_data_type_t type); -int opal_dss_print_bool(char **output, char *prefix, bool *src, opal_data_type_t type); -int opal_dss_print_int(char **output, char *prefix, int *src, opal_data_type_t type); -int opal_dss_print_uint(char **output, char *prefix, int *src, opal_data_type_t type); -int opal_dss_print_uint8(char **output, char *prefix, uint8_t *src, opal_data_type_t type); -int opal_dss_print_uint16(char **output, char *prefix, uint16_t *src, opal_data_type_t type); -int opal_dss_print_uint32(char **output, char *prefix, uint32_t *src, opal_data_type_t type); -int opal_dss_print_int8(char **output, char *prefix, int8_t *src, opal_data_type_t type); -int opal_dss_print_int16(char **output, char *prefix, int16_t *src, opal_data_type_t type); -int opal_dss_print_int32(char **output, char *prefix, int32_t *src, opal_data_type_t type); -#ifdef HAVE_INT64_T -int opal_dss_print_uint64(char **output, char *prefix, uint64_t *src, opal_data_type_t type); -int opal_dss_print_int64(char **output, char *prefix, int64_t *src, opal_data_type_t type); -#else -int opal_dss_print_uint64(char **output, char *prefix, void *src, opal_data_type_t type); -int opal_dss_print_int64(char **output, char *prefix, void *src, opal_data_type_t type); -#endif -int opal_dss_print_null(char **output, char *prefix, void *src, opal_data_type_t type); -int opal_dss_print_data_type(char **output, char *prefix, opal_data_type_t *src, opal_data_type_t type); -int opal_dss_print_byte_object(char **output, char *prefix, opal_byte_object_t *src, opal_data_type_t type); -int opal_dss_print_value(char **output, char *prefix, opal_value_t *src, opal_data_type_t type); -int opal_dss_print_buffer_contents(char **output, char *prefix, opal_buffer_t *src, opal_data_type_t type); -int opal_dss_print_float(char **output, char *prefix, float *src, opal_data_type_t type); -int opal_dss_print_double(char **output, char *prefix, double *src, opal_data_type_t type); -int opal_dss_print_timeval(char **output, char *prefix, struct timeval *src, opal_data_type_t type); -int opal_dss_print_time(char **output, char *prefix, time_t *src, opal_data_type_t type); -int opal_dss_print_name(char **output, char *prefix, opal_process_name_t *name, opal_data_type_t type); -int opal_dss_print_jobid(char **output, char *prefix, opal_process_name_t *src, opal_data_type_t type); -int opal_dss_print_vpid(char **output, char *prefix, opal_process_name_t *src, opal_data_type_t type); -int opal_dss_print_status(char **output, char *prefix, int *src, opal_data_type_t type); -int opal_dss_print_envar(char **output, char *prefix, - opal_envar_t *src, opal_data_type_t type); - - -/* - * Internal helper functions - */ - -char* opal_dss_buffer_extend(opal_buffer_t *bptr, size_t bytes_to_add); - -bool opal_dss_too_small(opal_buffer_t *buffer, size_t bytes_reqd); - -opal_dss_type_info_t* opal_dss_find_type(opal_data_type_t type); - -int opal_dss_store_data_type(opal_buffer_t *buffer, opal_data_type_t type); - -int opal_dss_get_data_type(opal_buffer_t *buffer, opal_data_type_t *type); - -END_C_DECLS - -#endif diff --git a/opal/dss/dss_internal_functions.c b/opal/dss/dss_internal_functions.c deleted file mode 100644 index 7f5e7882825..00000000000 --- a/opal/dss/dss_internal_functions.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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) 2017 Intel, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" - -#include -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "opal/class/opal_pointer_array.h" - -#include "opal/dss/dss_internal.h" - -/** - * Internal function that resizes (expands) an inuse buffer if - * necessary. - */ -char* opal_dss_buffer_extend(opal_buffer_t *buffer, size_t bytes_to_add) -{ - size_t required, to_alloc; - size_t pack_offset, unpack_offset; - - /* Check to see if we have enough space already */ - - if ((buffer->bytes_allocated - buffer->bytes_used) >= bytes_to_add) { - return buffer->pack_ptr; - } - - required = buffer->bytes_used + bytes_to_add; - if(required >= (size_t)opal_dss_threshold_size) { - to_alloc = ((required + opal_dss_threshold_size - 1) - / opal_dss_threshold_size) * opal_dss_threshold_size; - } else { - to_alloc = buffer->bytes_allocated; - if(0 == to_alloc) { - to_alloc = opal_dss_initial_size; - } - while(to_alloc < required) { - to_alloc <<= 1; - } - } - - if (NULL != buffer->base_ptr) { - pack_offset = ((char*) buffer->pack_ptr) - ((char*) buffer->base_ptr); - unpack_offset = ((char*) buffer->unpack_ptr) - - ((char*) buffer->base_ptr); - buffer->base_ptr = (char*)realloc(buffer->base_ptr, to_alloc); - } else { - pack_offset = 0; - unpack_offset = 0; - buffer->bytes_used = 0; - buffer->base_ptr = (char*)malloc(to_alloc); - } - - if (NULL == buffer->base_ptr) { - return NULL; - } - buffer->pack_ptr = ((char*) buffer->base_ptr) + pack_offset; - buffer->unpack_ptr = ((char*) buffer->base_ptr) + unpack_offset; - buffer->bytes_allocated = to_alloc; - - /* All done */ - - return buffer->pack_ptr; -} - -/* - * Internal function that checks to see if the specified number of bytes - * remain in the buffer for unpacking - */ -bool opal_dss_too_small(opal_buffer_t *buffer, size_t bytes_reqd) -{ - size_t bytes_remaining_packed; - - if (buffer->pack_ptr < buffer->unpack_ptr) { - return true; - } - - bytes_remaining_packed = buffer->pack_ptr - buffer->unpack_ptr; - - if (bytes_remaining_packed < bytes_reqd) { - /* don't error log this - it could be that someone is trying to - * simply read until the buffer is empty - */ - return true; - } - - return false; -} - -int opal_dss_store_data_type(opal_buffer_t *buffer, opal_data_type_t type) -{ - opal_dss_type_info_t *info; - - /* Lookup the pack function for the actual opal_data_type type and call it */ - - if (NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, OPAL_DATA_TYPE_T))) { - return OPAL_ERR_PACK_FAILURE; - } - - return info->odti_pack_fn(buffer, &type, 1, OPAL_DATA_TYPE_T); -} - -int opal_dss_get_data_type(opal_buffer_t *buffer, opal_data_type_t *type) -{ - opal_dss_type_info_t *info; - int32_t n=1; - - /* Lookup the unpack function for the actual opal_data_type type and call it */ - - if (NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, OPAL_DATA_TYPE_T))) { - return OPAL_ERR_PACK_FAILURE; - } - - return info->odti_unpack_fn(buffer, type, &n, OPAL_DATA_TYPE_T); -} diff --git a/opal/dss/dss_load_unload.c b/opal/dss/dss_load_unload.c deleted file mode 100644 index d8e8d3897c8..00000000000 --- a/opal/dss/dss_load_unload.c +++ /dev/null @@ -1,480 +0,0 @@ -/* - * 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) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2015-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2018 IBM Corporation. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -/* - * DSS Buffer Operations - */ -#include "opal_config.h" - -#include "opal/util/error.h" - -#include "opal/dss/dss_internal.h" - - -int opal_dss_unload(opal_buffer_t *buffer, void **payload, - int32_t *bytes_used) -{ - /* check that buffer is not null */ - if (!buffer) { - return OPAL_ERR_BAD_PARAM; - } - - /* were we given someplace to point to the payload */ - if (NULL == payload) { - return OPAL_ERR_BAD_PARAM; - } - - /* anything in the buffer - if not, nothing to do */ - if (NULL == buffer->base_ptr || 0 == buffer->bytes_used) { - *payload = NULL; - *bytes_used = 0; - return OPAL_SUCCESS; - } - - /* if nothing has been unpacked, we can pass the entire - * region back and protect it - no need to copy. This is - * an optimization */ - if (buffer->unpack_ptr == buffer->base_ptr) { - *payload = buffer->base_ptr; - *bytes_used = buffer->bytes_used; - buffer->base_ptr = NULL; - buffer->bytes_used = 0; - goto cleanup; - } - - /* okay, we have something to provide - pass it back */ - *bytes_used = buffer->bytes_used - (buffer->unpack_ptr - buffer->base_ptr); - if (0 == (*bytes_used)) { - *payload = NULL; - } else { - /* we cannot just set the pointer as it might be - * partway in a malloc'd region */ - *payload = (void*)malloc(*bytes_used); - memcpy(*payload, buffer->unpack_ptr, *bytes_used); - } - - cleanup: - /* All done - reset the buffer */ - OBJ_DESTRUCT(buffer); - OBJ_CONSTRUCT(buffer, opal_buffer_t); - return OPAL_SUCCESS; -} - - -int opal_dss_load(opal_buffer_t *buffer, void *payload, - int32_t bytes_used) -{ - /* check to see if the buffer has been initialized */ - if (NULL == buffer) { - return OPAL_ERR_BAD_PARAM; - } - - /* check if buffer already has payload - free it if so */ - OBJ_DESTRUCT(buffer); - OBJ_CONSTRUCT(buffer, opal_buffer_t); - - /* if it's a NULL payload, just set things and return */ - if (NULL == payload) { - return OPAL_SUCCESS; - } - - /* populate the buffer */ - buffer->base_ptr = (char*)payload; - - /* set pack/unpack pointers */ - buffer->pack_ptr = ((char*)buffer->base_ptr) + bytes_used; - buffer->unpack_ptr = buffer->base_ptr; - - /* set counts for size and space */ - buffer->bytes_allocated = buffer->bytes_used = bytes_used; - - /* All done */ - - return OPAL_SUCCESS; -} - - -/* Copy the UNPACKED portion of a source buffer into a destination buffer - * The complete contents of the src buffer are NOT copied - only that - * portion that has not been previously unpacked is copied. - */ -int opal_dss_copy_payload(opal_buffer_t *dest, opal_buffer_t *src) -{ - char *dst_ptr; - int32_t bytes_left; - - /* ensure we have valid source and destination */ - if (NULL == dest || NULL == src) { - return OPAL_ERR_BAD_PARAM; - } - - /* if the dest is already populated, check to ensure that both - * source and dest are of the same buffer type - */ - if (0 != dest->bytes_used) { - if (dest->type != src->type) { - return OPAL_ERR_BUFFER; - } - } - - /* either the dest was empty or the two types already match - - * either way, just ensure the two types DO match - */ - dest->type = src->type; - - /* compute how much of the src buffer remains unpacked - * buffer->bytes_used is the total number of bytes in the buffer that - * have been packed. However, we may have already unpacked some of - * that data. We only want to unload what remains unpacked. This - * means we have to look at how much of the buffer remains "used" - * beyond the unpack_ptr - */ - bytes_left = src->bytes_used - (src->unpack_ptr - src->base_ptr); - - /* if nothing is left, then nothing to do */ - if (0 == bytes_left) { - return OPAL_SUCCESS; - } - - /* add room to the dest for the src buffer's payload */ - if (NULL == (dst_ptr = opal_dss_buffer_extend(dest, bytes_left))) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* copy the src payload to the specified location in dest */ - memcpy(dst_ptr, src->unpack_ptr, bytes_left); - - /* adjust the dest buffer's bookkeeping */ - dest->bytes_used += bytes_left; - dest->pack_ptr = ((char*)dest->pack_ptr) + bytes_left; - - return OPAL_SUCCESS; -} - -int opal_value_load(opal_value_t *kv, - void *data, opal_data_type_t type) -{ - opal_byte_object_t *boptr; - struct timeval *tv; - - kv->type = type; - if (NULL == data && OPAL_STRING != type && OPAL_BYTE_OBJECT != type) { - /* just set the fields to zero */ - memset(&kv->data, 0, sizeof(kv->data)); - return OPAL_SUCCESS; - } - - switch (type) { - case OPAL_BOOL: - kv->data.flag = *(bool*)(data); - break; - case OPAL_BYTE: - kv->data.byte = *(uint8_t*)(data); - break; - case OPAL_STRING: - if (NULL != kv->data.string) { - free(kv->data.string); - } - if (NULL != data) { - kv->data.string = strdup( (const char *) data); - } else { - kv->data.string = NULL; - } - break; - case OPAL_SIZE: - kv->data.size = *(size_t*)(data); - break; - case OPAL_PID: - kv->data.pid = *(pid_t*)(data); - break; - - case OPAL_INT: - kv->data.integer = *(int*)(data); - break; - case OPAL_INT8: - kv->data.int8 = *(int8_t*)(data); - break; - case OPAL_INT16: - kv->data.int16 = *(int16_t*)(data); - break; - case OPAL_INT32: - kv->data.int32 = *(int32_t*)(data); - break; - case OPAL_INT64: - kv->data.int64 = *(int64_t*)(data); - break; - - case OPAL_UINT: - kv->data.uint = *(unsigned int*)(data); - break; - case OPAL_UINT8: - kv->data.uint8 = *(uint8_t*)(data); - break; - case OPAL_UINT16: - kv->data.uint16 = *(uint16_t*)(data); - break; - case OPAL_UINT32: - kv->data.uint32 = *(uint32_t*)data; - break; - case OPAL_UINT64: - kv->data.uint64 = *(uint64_t*)(data); - break; - - case OPAL_BYTE_OBJECT: - if (NULL != kv->data.bo.bytes) { - free(kv->data.bo.bytes); - } - boptr = (opal_byte_object_t*)data; - if (NULL != boptr && NULL != boptr->bytes && 0 < boptr->size) { - kv->data.bo.bytes = (uint8_t *) malloc(boptr->size); - memcpy(kv->data.bo.bytes, boptr->bytes, boptr->size); - kv->data.bo.size = boptr->size; - } else { - kv->data.bo.bytes = NULL; - kv->data.bo.size = 0; - } - break; - - case OPAL_FLOAT: - kv->data.fval = *(float*)(data); - break; - - case OPAL_TIMEVAL: - tv = (struct timeval*)data; - kv->data.tv.tv_sec = tv->tv_sec; - kv->data.tv.tv_usec = tv->tv_usec; - break; - - case OPAL_PTR: - kv->data.ptr = data; - break; - - default: - OPAL_ERROR_LOG(OPAL_ERR_NOT_SUPPORTED); - return OPAL_ERR_NOT_SUPPORTED; - } - return OPAL_SUCCESS; -} - -int opal_value_unload(opal_value_t *kv, - void **data, opal_data_type_t type) -{ - opal_byte_object_t *boptr; - - if (type != kv->type) { - return OPAL_ERR_TYPE_MISMATCH; - } - if (NULL == data || - (OPAL_STRING != type && OPAL_BYTE_OBJECT != type && NULL == *data)) { - OPAL_ERROR_LOG(OPAL_ERR_BAD_PARAM); - return OPAL_ERR_BAD_PARAM; - } - - switch (type) { - case OPAL_BOOL: - memcpy(*data, &kv->data.flag, sizeof(bool)); - break; - case OPAL_BYTE: - memcpy(*data, &kv->data.byte, sizeof(uint8_t)); - break; - case OPAL_STRING: - if (NULL != kv->data.string) { - *data = strdup(kv->data.string); - } else { - *data = NULL; - } - break; - case OPAL_SIZE: - memcpy(*data, &kv->data.size, sizeof(size_t)); - break; - case OPAL_PID: - memcpy(*data, &kv->data.pid, sizeof(pid_t)); - break; - - case OPAL_INT: - memcpy(*data, &kv->data.integer, sizeof(int)); - break; - case OPAL_INT8: - memcpy(*data, &kv->data.int8, sizeof(int8_t)); - break; - case OPAL_INT16: - memcpy(*data, &kv->data.int16, sizeof(int16_t)); - break; - case OPAL_INT32: - memcpy(*data, &kv->data.int32, sizeof(int32_t)); - break; - case OPAL_INT64: - memcpy(*data, &kv->data.int64, sizeof(int64_t)); - break; - - case OPAL_UINT: - memcpy(*data, &kv->data.uint, sizeof(unsigned int)); - break; - case OPAL_UINT8: - memcpy(*data, &kv->data.uint8, 1); - break; - case OPAL_UINT16: - memcpy(*data, &kv->data.uint16, 2); - break; - case OPAL_UINT32: - memcpy(*data, &kv->data.uint32, 4); - break; - case OPAL_UINT64: - memcpy(*data, &kv->data.uint64, 8); - break; - - case OPAL_BYTE_OBJECT: - boptr = (opal_byte_object_t*)malloc(sizeof(opal_byte_object_t)); - if (NULL != kv->data.bo.bytes && 0 < kv->data.bo.size) { - boptr->bytes = (uint8_t *) malloc(kv->data.bo.size); - memcpy(boptr->bytes, kv->data.bo.bytes, kv->data.bo.size); - boptr->size = kv->data.bo.size; - } else { - boptr->bytes = NULL; - boptr->size = 0; - } - *data = boptr; - break; - - case OPAL_FLOAT: - memcpy(*data, &kv->data.fval, sizeof(float)); - break; - - case OPAL_TIMEVAL: - memcpy(*data, &kv->data.tv, sizeof(struct timeval)); - break; - - case OPAL_PTR: - *data = kv->data.ptr; - break; - - case OPAL_VPID: - memcpy(*data, &kv->data.name.vpid, sizeof(opal_vpid_t)); - break; - - default: - OPAL_ERROR_LOG(OPAL_ERR_NOT_SUPPORTED); - return OPAL_ERR_NOT_SUPPORTED; - } - return OPAL_SUCCESS; -} - -int opal_value_xfer(opal_value_t *dest, - opal_value_t *src) -{ - opal_byte_object_t *boptr; - - if (NULL != src->key) { - dest->key = strdup(src->key); - } - dest->type = src->type; - - switch (src->type) { - case OPAL_BOOL: - dest->data.flag = src->data.flag; - break; - case OPAL_BYTE: - dest->data.byte = src->data.byte; - break; - case OPAL_STRING: - if (NULL != dest->data.string) { - free(dest->data.string); - } - if (NULL != src->data.string) { - dest->data.string = strdup(src->data.string); - } else { - dest->data.string = NULL; - } - break; - case OPAL_SIZE: - dest->data.size = src->data.size; - break; - case OPAL_PID: - dest->data.pid = src->data.pid; - break; - - case OPAL_INT: - dest->data.integer = src->data.integer; - break; - case OPAL_INT8: - dest->data.int8 = src->data.int8; - break; - case OPAL_INT16: - dest->data.int16 = src->data.int16; - break; - case OPAL_INT32: - dest->data.int32 = src->data.int32; - break; - case OPAL_INT64: - dest->data.int64 = src->data.int64; - break; - - case OPAL_UINT: - dest->data.uint = src->data.uint; - break; - case OPAL_UINT8: - dest->data.uint8 = src->data.uint8; - break; - case OPAL_UINT16: - dest->data.uint16 = src->data.uint16; - break; - case OPAL_UINT32: - dest->data.uint32 = src->data.uint32; - break; - case OPAL_UINT64: - dest->data.uint64 = src->data.uint64; - break; - - case OPAL_BYTE_OBJECT: - if (NULL != dest->data.bo.bytes) { - free(dest->data.bo.bytes); - } - boptr = &src->data.bo; - if (NULL != boptr && NULL != boptr->bytes && 0 < boptr->size) { - dest->data.bo.bytes = (uint8_t *) malloc(boptr->size); - memcpy(dest->data.bo.bytes, boptr->bytes, boptr->size); - dest->data.bo.size = boptr->size; - } else { - dest->data.bo.bytes = NULL; - dest->data.bo.size = 0; - } - break; - - case OPAL_FLOAT: - dest->data.fval = src->data.fval; - break; - - case OPAL_TIMEVAL: - dest->data.tv.tv_sec = src->data.tv.tv_sec; - dest->data.tv.tv_usec = src->data.tv.tv_usec; - break; - - case OPAL_PTR: - dest->data.ptr = src->data.ptr; - break; - - default: - OPAL_ERROR_LOG(OPAL_ERR_NOT_SUPPORTED); - return OPAL_ERR_NOT_SUPPORTED; - } - return OPAL_SUCCESS; -} diff --git a/opal/dss/dss_lookup.c b/opal/dss/dss_lookup.c deleted file mode 100644 index bcb23d31131..00000000000 --- a/opal/dss/dss_lookup.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" - -#include "opal/dss/dss_internal.h" - -char *opal_dss_lookup_data_type(opal_data_type_t type) -{ - opal_dss_type_info_t *info; - char *name; - - info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, type); - if (NULL != info) { /* type found on list */ - name = strdup(info->odti_name); - return name; - } - - return NULL; -} diff --git a/opal/dss/dss_open_close.c b/opal/dss/dss_open_close.c deleted file mode 100644 index 62dd31501d1..00000000000 --- a/opal/dss/dss_open_close.c +++ /dev/null @@ -1,592 +0,0 @@ -/* -*- 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-2009 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) 2012-2013 Los Alamos National Security, Inc. All rights reserved. - * Copyright (c) 2014-2020 Intel, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2017 IBM Corporation. All rights reserved. - * Copyright (c) 2018 Triad National Security, LLC. All rights - * reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -/** @file: - * - */ -#include "opal_config.h" - -#include "opal/runtime/opal.h" -#include "opal/mca/base/mca_base_var.h" - -#include "opal/dss/dss_internal.h" - -/** - * globals - */ -bool opal_dss_initialized = false; -int opal_dss_verbose = -1; /* by default disabled */ -int opal_dss_initial_size = -1; -int opal_dss_threshold_size = -1; -opal_pointer_array_t opal_dss_types = {{0}}; -opal_data_type_t opal_dss_num_reg_types = {0}; -static opal_dss_buffer_type_t default_buf_type = OPAL_DSS_BUFFER_NON_DESC; - -/* variable group id */ -static int opal_dss_group_id = -1; - -static mca_base_var_enum_value_t buffer_type_values[] = { - {OPAL_DSS_BUFFER_NON_DESC, "non-described"}, - {OPAL_DSS_BUFFER_FULLY_DESC, "described"}, - {0, NULL} -}; - -opal_dss_t opal_dss = { - opal_dss_pack, - opal_dss_unpack, - opal_dss_copy, - opal_dss_compare, - opal_dss_print, - opal_dss_structured, - opal_dss_peek, - opal_dss_unload, - opal_dss_load, - opal_dss_copy_payload, - opal_dss_register, - opal_dss_lookup_data_type, - opal_dss_dump_data_types, - opal_dss_dump -}; - -/** - * Object constructors, destructors, and instantiations - */ -/** Value **/ -static void opal_value_construct(opal_value_t* ptr) -{ - ptr->key = NULL; - ptr->type = OPAL_UNDEF; - memset(&ptr->data, 0, sizeof(ptr->data)); -} -static void opal_value_destruct(opal_value_t* ptr) -{ - if (NULL != ptr->key) { - free(ptr->key); - } - if (OPAL_STRING == ptr->type && - NULL != ptr->data.string) { - free(ptr->data.string); - } else if (OPAL_BYTE_OBJECT == ptr->type && - NULL != ptr->data.bo.bytes) { - free(ptr->data.bo.bytes); - } else if (OPAL_LIST == ptr->type && - NULL != ptr->data.ptr) { - OPAL_LIST_RELEASE(ptr->data.ptr); - } -} -OBJ_CLASS_INSTANCE(opal_value_t, - opal_list_item_t, - opal_value_construct, - opal_value_destruct); - - -static void opal_buffer_construct (opal_buffer_t* buffer) -{ - /** set the default buffer type */ - buffer->type = default_buf_type; - - /* Make everything NULL to begin with */ - - buffer->base_ptr = buffer->pack_ptr = buffer->unpack_ptr = NULL; - buffer->bytes_allocated = buffer->bytes_used = 0; -} - -static void opal_buffer_destruct (opal_buffer_t* buffer) -{ - if (NULL != buffer->base_ptr) { - free (buffer->base_ptr); - } -} - -OBJ_CLASS_INSTANCE(opal_buffer_t, - opal_object_t, - opal_buffer_construct, - opal_buffer_destruct); - - -static void opal_dss_type_info_construct(opal_dss_type_info_t *obj) -{ - obj->odti_name = NULL; - obj->odti_pack_fn = NULL; - obj->odti_unpack_fn = NULL; - obj->odti_copy_fn = NULL; - obj->odti_compare_fn = NULL; - obj->odti_print_fn = NULL; - obj->odti_structured = false; -} - -static void opal_dss_type_info_destruct(opal_dss_type_info_t *obj) -{ - if (NULL != obj->odti_name) { - free(obj->odti_name); - } -} - -OBJ_CLASS_INSTANCE(opal_dss_type_info_t, opal_object_t, - opal_dss_type_info_construct, - opal_dss_type_info_destruct); - - -static void opal_envar_construct(opal_envar_t *obj) -{ - obj->envar = NULL; - obj->value = NULL; - obj->separator = '\0'; -} -static void opal_envar_destruct(opal_envar_t *obj) -{ - if (NULL != obj->envar) { - free(obj->envar); - } - if (NULL != obj->value) { - free(obj->value); - } -} -OBJ_CLASS_INSTANCE(opal_envar_t, - opal_list_item_t, - opal_envar_construct, - opal_envar_destruct); - -int opal_dss_register_vars (void) -{ - mca_base_var_enum_t *new_enum; - char *enviro_val; - int ret; - - enviro_val = getenv("OPAL_dss_debug"); - if (NULL != enviro_val) { /* debug requested */ - opal_dss_verbose = 0; - } - - opal_dss_group_id = mca_base_var_group_register ("opal", "dss", NULL, NULL); - - /** set the default buffer type. If we are in debug mode, then we default - * to fully described buffers. Otherwise, we default to non-described for brevity - * and performance - */ -#if OPAL_ENABLE_DEBUG - default_buf_type = OPAL_DSS_BUFFER_FULLY_DESC; -#else - default_buf_type = OPAL_DSS_BUFFER_NON_DESC; -#endif - - ret = mca_base_var_enum_create ("buffer types", buffer_type_values, &new_enum); - if (OPAL_SUCCESS != ret) { - fprintf (stderr, "Fail A\n"); - return ret; - } - - ret = mca_base_var_register ("opal", "dss", NULL, "buffer_type", - "Set the default mode for OpenRTE buffers (0=non-described, 1=described)", - MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE, - OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_ALL_EQ, - &default_buf_type); - OBJ_RELEASE(new_enum); - if (0 > ret) { - return ret; - } - - /* setup the initial size of the buffer. */ - opal_dss_initial_size = OPAL_DSS_DEFAULT_INITIAL_SIZE; - ret = mca_base_var_register ("opal", "dss", NULL, "buffer_initial_size", NULL, - MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, - OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_ALL_EQ, - &opal_dss_initial_size); - if (0 > ret) { - return ret; - } - - /* the threshold as to where to stop doubling the size of the buffer - * allocated memory and start doing additive increases */ - opal_dss_threshold_size = OPAL_DSS_DEFAULT_THRESHOLD_SIZE; - ret = mca_base_var_register ("opal", "dss", NULL, "buffer_threshold_size", NULL, - MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE, - OPAL_INFO_LVL_8, MCA_BASE_VAR_SCOPE_ALL_EQ, - &opal_dss_threshold_size); - - return (0 > ret) ? ret : OPAL_SUCCESS; -} - -static void opal_dss_close (void) -{ - opal_dss_initialized = false; - - for (int i = 0 ; i < opal_pointer_array_get_size(&opal_dss_types) ; ++i) { - opal_dss_type_info_t *info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, i); - if (NULL != info) { - opal_pointer_array_set_item(&opal_dss_types, i, NULL); - OBJ_RELEASE(info); - } - } - - OBJ_DESTRUCT(&opal_dss_types); -} - -int opal_dss_open(void) -{ - int rc; - opal_data_type_t tmp; - - if (opal_dss_initialized) { - return OPAL_SUCCESS; - } - - /* Lock DSS MCA variables */ - mca_base_var_group_set_var_flag (opal_dss_group_id, MCA_BASE_VAR_FLAG_SETTABLE, false); - - /* Setup the types array */ - OBJ_CONSTRUCT(&opal_dss_types, opal_pointer_array_t); - if (OPAL_SUCCESS != (rc = opal_pointer_array_init(&opal_dss_types, - OPAL_DSS_ID_DYNAMIC, - OPAL_DSS_ID_MAX, - OPAL_DSS_ID_MAX))) { - return rc; - } - opal_dss_num_reg_types = 0; - - /* Register all the intrinsic types */ - - tmp = OPAL_NULL; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_null, - opal_dss_unpack_null, - (opal_dss_copy_fn_t)opal_dss_copy_null, - (opal_dss_compare_fn_t)opal_dss_compare_null, - (opal_dss_print_fn_t)opal_dss_print_null, - OPAL_DSS_UNSTRUCTURED, - "OPAL_NULL", &tmp))) { - return rc; - } - tmp = OPAL_BYTE; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_byte, - opal_dss_unpack_byte, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_byte, - (opal_dss_print_fn_t)opal_dss_print_byte, - OPAL_DSS_UNSTRUCTURED, - "OPAL_BYTE", &tmp))) { - return rc; - } - tmp = OPAL_BOOL; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_bool, - opal_dss_unpack_bool, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_bool, - (opal_dss_print_fn_t)opal_dss_print_bool, - OPAL_DSS_UNSTRUCTURED, - "OPAL_BOOL", &tmp))) { - return rc; - } - tmp = OPAL_INT; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_int, - opal_dss_unpack_int, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_int, - (opal_dss_print_fn_t)opal_dss_print_int, - OPAL_DSS_UNSTRUCTURED, - "OPAL_INT", &tmp))) { - return rc; - } - tmp = OPAL_UINT; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_int, - opal_dss_unpack_int, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_uint, - (opal_dss_print_fn_t)opal_dss_print_uint, - OPAL_DSS_UNSTRUCTURED, - "OPAL_UINT", &tmp))) { - return rc; - } - tmp = OPAL_INT8; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_byte, - opal_dss_unpack_byte, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_int8, - (opal_dss_print_fn_t)opal_dss_print_int8, - OPAL_DSS_UNSTRUCTURED, - "OPAL_INT8", &tmp))) { - return rc; - } - tmp = OPAL_UINT8; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_byte, - opal_dss_unpack_byte, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_uint8, - (opal_dss_print_fn_t)opal_dss_print_uint8, - OPAL_DSS_UNSTRUCTURED, - "OPAL_UINT8", &tmp))) { - return rc; - } - tmp = OPAL_INT16; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_int16, - opal_dss_unpack_int16, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_int16, - (opal_dss_print_fn_t)opal_dss_print_int16, - OPAL_DSS_UNSTRUCTURED, - "OPAL_INT16", &tmp))) { - return rc; - } - tmp = OPAL_UINT16; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_int16, - opal_dss_unpack_int16, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_uint16, - (opal_dss_print_fn_t)opal_dss_print_uint16, - OPAL_DSS_UNSTRUCTURED, - "OPAL_UINT16", &tmp))) { - return rc; - } - tmp = OPAL_INT32; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_int32, - opal_dss_unpack_int32, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_int32, - (opal_dss_print_fn_t)opal_dss_print_int32, - OPAL_DSS_UNSTRUCTURED, - "OPAL_INT32", &tmp))) { - return rc; - } - tmp = OPAL_UINT32; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_int32, - opal_dss_unpack_int32, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_uint32, - (opal_dss_print_fn_t)opal_dss_print_uint32, - OPAL_DSS_UNSTRUCTURED, - "OPAL_UINT32", &tmp))) { - return rc; - } - tmp = OPAL_INT64; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_int64, - opal_dss_unpack_int64, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_int64, - (opal_dss_print_fn_t)opal_dss_print_int64, - OPAL_DSS_UNSTRUCTURED, - "OPAL_INT64", &tmp))) { - return rc; - } - tmp = OPAL_UINT64; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_int64, - opal_dss_unpack_int64, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_uint64, - (opal_dss_print_fn_t)opal_dss_print_uint64, - OPAL_DSS_UNSTRUCTURED, - "OPAL_UINT64", &tmp))) { - return rc; - } - tmp = OPAL_SIZE; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_sizet, - opal_dss_unpack_sizet, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_size, - (opal_dss_print_fn_t)opal_dss_print_size, - OPAL_DSS_UNSTRUCTURED, - "OPAL_SIZE", &tmp))) { - return rc; - } - tmp = OPAL_PID; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_pid, - opal_dss_unpack_pid, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_pid, - (opal_dss_print_fn_t)opal_dss_print_pid, - OPAL_DSS_UNSTRUCTURED, - "OPAL_PID", &tmp))) { - return rc; - } - tmp = OPAL_STRING; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_string, - opal_dss_unpack_string, - (opal_dss_copy_fn_t)opal_dss_copy_string, - (opal_dss_compare_fn_t)opal_dss_compare_string, - (opal_dss_print_fn_t)opal_dss_print_string, - OPAL_DSS_STRUCTURED, - "OPAL_STRING", &tmp))) { - return rc; - } - tmp = OPAL_DATA_TYPE; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_data_type, - opal_dss_unpack_data_type, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_dt, - (opal_dss_print_fn_t)opal_dss_print_data_type, - OPAL_DSS_UNSTRUCTURED, - "OPAL_DATA_TYPE", &tmp))) { - return rc; - } - - tmp = OPAL_BYTE_OBJECT; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_byte_object, - opal_dss_unpack_byte_object, - (opal_dss_copy_fn_t)opal_dss_copy_byte_object, - (opal_dss_compare_fn_t)opal_dss_compare_byte_object, - (opal_dss_print_fn_t)opal_dss_print_byte_object, - OPAL_DSS_STRUCTURED, - "OPAL_BYTE_OBJECT", &tmp))) { - return rc; - } - - tmp = OPAL_VALUE; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_value, - opal_dss_unpack_value, - (opal_dss_copy_fn_t)opal_dss_copy_value, - (opal_dss_compare_fn_t)opal_dss_compare_value, - (opal_dss_print_fn_t)opal_dss_print_value, - OPAL_DSS_STRUCTURED, - "OPAL_VALUE", &tmp))) { - return rc; - } - tmp = OPAL_BUFFER; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_buffer_contents, - opal_dss_unpack_buffer_contents, - (opal_dss_copy_fn_t)opal_dss_copy_buffer_contents, - (opal_dss_compare_fn_t)opal_dss_compare_buffer_contents, - (opal_dss_print_fn_t)opal_dss_print_buffer_contents, - OPAL_DSS_STRUCTURED, - "OPAL_BUFFER", &tmp))) { - return rc; - } - tmp = OPAL_FLOAT; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_float, - opal_dss_unpack_float, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_float, - (opal_dss_print_fn_t)opal_dss_print_float, - OPAL_DSS_UNSTRUCTURED, - "OPAL_FLOAT", &tmp))) { - return rc; - } - tmp = OPAL_DOUBLE; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_double, - opal_dss_unpack_double, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_double, - (opal_dss_print_fn_t)opal_dss_print_double, - OPAL_DSS_UNSTRUCTURED, - "OPAL_DOUBLE", &tmp))) { - return rc; - } - tmp = OPAL_TIMEVAL; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_timeval, - opal_dss_unpack_timeval, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_timeval, - (opal_dss_print_fn_t)opal_dss_print_timeval, - OPAL_DSS_UNSTRUCTURED, - "OPAL_TIMEVAL", &tmp))) { - return rc; - } - tmp = OPAL_TIME; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_time, - opal_dss_unpack_time, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_time, - (opal_dss_print_fn_t)opal_dss_print_time, - OPAL_DSS_UNSTRUCTURED, - "OPAL_TIME", &tmp))) { - return rc; - } - - tmp = OPAL_NAME; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_name, - opal_dss_unpack_name, - (opal_dss_copy_fn_t)opal_dss_copy_name, - (opal_dss_compare_fn_t)opal_dss_compare_name, - (opal_dss_print_fn_t)opal_dss_print_name, - OPAL_DSS_UNSTRUCTURED, - "OPAL_NAME", &tmp))) { - return rc; - } - - tmp = OPAL_JOBID; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_jobid, - opal_dss_unpack_jobid, - (opal_dss_copy_fn_t)opal_dss_copy_jobid, - (opal_dss_compare_fn_t)opal_dss_compare_jobid, - (opal_dss_print_fn_t)opal_dss_print_jobid, - OPAL_DSS_UNSTRUCTURED, - "OPAL_JOBID", &tmp))) { - return rc; - } - - tmp = OPAL_VPID; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_vpid, - opal_dss_unpack_vpid, - (opal_dss_copy_fn_t)opal_dss_copy_vpid, - (opal_dss_compare_fn_t)opal_dss_compare_vpid, - (opal_dss_print_fn_t)opal_dss_print_vpid, - OPAL_DSS_UNSTRUCTURED, - "OPAL_VPID", &tmp))) { - return rc; - } - - - tmp = OPAL_STATUS; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_status, - opal_dss_unpack_status, - (opal_dss_copy_fn_t)opal_dss_std_copy, - (opal_dss_compare_fn_t)opal_dss_compare_status, - (opal_dss_print_fn_t)opal_dss_print_status, - OPAL_DSS_UNSTRUCTURED, - "OPAL_STATUS", &tmp))) { - return rc; - } - - tmp = OPAL_ENVAR; - if (OPAL_SUCCESS != (rc = opal_dss.register_type(opal_dss_pack_envar, - opal_dss_unpack_envar, - (opal_dss_copy_fn_t)opal_dss_copy_envar, - (opal_dss_compare_fn_t)opal_dss_compare_envar, - (opal_dss_print_fn_t)opal_dss_print_envar, - OPAL_DSS_UNSTRUCTURED, - "OPAL_ENVAR", &tmp))) { - return rc; - } - /* All done */ - - opal_dss_initialized = true; - - opal_finalize_register_cleanup (opal_dss_close); - - return OPAL_SUCCESS; -} - -bool opal_dss_structured(opal_data_type_t type) -{ - int i; - - /* find the type */ - for (i = 0 ; i < opal_dss_types.size ; ++i) { - opal_dss_type_info_t *info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, i); - if (NULL != info && info->odti_type == type) { - return info->odti_structured; - } - } - - /* default to false */ - return false; -} diff --git a/opal/dss/dss_pack.c b/opal/dss/dss_pack.c deleted file mode 100644 index db590ab847f..00000000000 --- a/opal/dss/dss_pack.c +++ /dev/null @@ -1,776 +0,0 @@ -/* - * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2007 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) 2011-2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2014-2020 Intel, Inc. All rights reserved. - * Copyright (c) 2014 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" - -#include "opal/types.h" -#include "opal/util/error.h" -#include "opal/util/output.h" -#include "opal/util/printf.h" -#include "opal/dss/dss_internal.h" - -int opal_dss_pack(opal_buffer_t *buffer, - const void *src, int32_t num_vals, - opal_data_type_t type) -{ - int rc; - - /* check for error */ - if (NULL == buffer) { - return OPAL_ERR_BAD_PARAM; - } - - /* Pack the number of values */ - if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { - if (OPAL_SUCCESS != (rc = opal_dss_store_data_type(buffer, OPAL_INT32))) { - return rc; - } - } - if (OPAL_SUCCESS != (rc = opal_dss_pack_int32(buffer, &num_vals, 1, OPAL_INT32))) { - return rc; - } - - /* Pack the value(s) */ - return opal_dss_pack_buffer(buffer, src, num_vals, type); -} - -int opal_dss_pack_buffer(opal_buffer_t *buffer, - const void *src, int32_t num_vals, - opal_data_type_t type) -{ - int rc; - opal_dss_type_info_t *info; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_pack_buffer( %p, %p, %lu, %d )\n", - (void*)buffer, src, (long unsigned int)num_vals, (int)type ) ); - - /* Pack the declared data type */ - if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { - if (OPAL_SUCCESS != (rc = opal_dss_store_data_type(buffer, type))) { - return rc; - } - } - - /* Lookup the pack function for this type and call it */ - - if (NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, type))) { - return OPAL_ERR_PACK_FAILURE; - } - - return info->odti_pack_fn(buffer, src, num_vals, type); -} - - -/* PACK FUNCTIONS FOR GENERIC SYSTEM TYPES */ - -/* - * BOOL - */ -int opal_dss_pack_bool(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret; - - /* System types need to always be described so we can properly - unpack them. If we aren't fully described, then add the - description for this type... */ - if (OPAL_DSS_BUFFER_FULLY_DESC != buffer->type) { - if (OPAL_SUCCESS != (ret = opal_dss_store_data_type(buffer, DSS_TYPE_BOOL))) { - return ret; - } - } - - /* Turn around and pack the real type */ - return opal_dss_pack_buffer(buffer, src, num_vals, DSS_TYPE_BOOL); -} - -/* - * INT - */ -int opal_dss_pack_int(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret; - - /* System types need to always be described so we can properly - unpack them. If we aren't fully described, then add the - description for this type... */ - if (OPAL_DSS_BUFFER_FULLY_DESC != buffer->type) { - if (OPAL_SUCCESS != (ret = opal_dss_store_data_type(buffer, DSS_TYPE_INT))) { - return ret; - } - } - - /* Turn around and pack the real type */ - return opal_dss_pack_buffer(buffer, src, num_vals, DSS_TYPE_INT); -} - -/* - * SIZE_T - */ -int opal_dss_pack_sizet(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret; - - /* System types need to always be described so we can properly - unpack them. If we aren't fully described, then add the - description for this type... */ - if (OPAL_DSS_BUFFER_FULLY_DESC != buffer->type) { - if (OPAL_SUCCESS != (ret = opal_dss_store_data_type(buffer, DSS_TYPE_SIZE_T))) { - return ret; - } - } - - return opal_dss_pack_buffer(buffer, src, num_vals, DSS_TYPE_SIZE_T); -} - -/* - * PID_T - */ -int opal_dss_pack_pid(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret; - - /* System types need to always be described so we can properly - unpack them. If we aren't fully described, then add the - description for this type... */ - if (OPAL_DSS_BUFFER_FULLY_DESC != buffer->type) { - if (OPAL_SUCCESS != (ret = opal_dss_store_data_type(buffer, DSS_TYPE_PID_T))) { - return ret; - } - } - - /* Turn around and pack the real type */ - return opal_dss_pack_buffer(buffer, src, num_vals, DSS_TYPE_PID_T); -} - - -/* PACK FUNCTIONS FOR NON-GENERIC SYSTEM TYPES */ - -/* - * NULL - */ -int opal_dss_pack_null(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - char null=0x00; - char *dst; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_pack_null * %d\n", num_vals ) ); - /* check to see if buffer needs extending */ - if (NULL == (dst = opal_dss_buffer_extend(buffer, num_vals))) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* store the nulls */ - memset(dst, (int)null, num_vals); - - /* update buffer pointers */ - buffer->pack_ptr += num_vals; - buffer->bytes_used += num_vals; - - return OPAL_SUCCESS; -} - -/* - * BYTE, CHAR, INT8 - */ -int opal_dss_pack_byte(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - char *dst; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_pack_byte * %d\n", num_vals ) ); - /* check to see if buffer needs extending */ - if (NULL == (dst = opal_dss_buffer_extend(buffer, num_vals))) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - /* store the data */ - memcpy(dst, src, num_vals); - - /* update buffer pointers */ - buffer->pack_ptr += num_vals; - buffer->bytes_used += num_vals; - - return OPAL_SUCCESS; -} - -/* - * INT16 - */ -int opal_dss_pack_int16(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int32_t i; - uint16_t tmp, *srctmp = (uint16_t*) src; - char *dst; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_pack_int16 * %d\n", num_vals ) ); - /* check to see if buffer needs extending */ - if (NULL == (dst = opal_dss_buffer_extend(buffer, num_vals*sizeof(tmp)))) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - for (i = 0; i < num_vals; ++i) { - tmp = htons(srctmp[i]); - memcpy(dst, &tmp, sizeof(tmp)); - dst += sizeof(tmp); - } - buffer->pack_ptr += num_vals * sizeof(tmp); - buffer->bytes_used += num_vals * sizeof(tmp); - - return OPAL_SUCCESS; -} - -/* - * INT32 - */ -int opal_dss_pack_int32(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int32_t i; - uint32_t tmp, *srctmp = (uint32_t*) src; - char *dst; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_pack_int32 * %d\n", num_vals ) ); - /* check to see if buffer needs extending */ - if (NULL == (dst = opal_dss_buffer_extend(buffer, num_vals*sizeof(tmp)))) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - for (i = 0; i < num_vals; ++i) { - tmp = htonl(srctmp[i]); - memcpy(dst, &tmp, sizeof(tmp)); - dst += sizeof(tmp); - } - buffer->pack_ptr += num_vals * sizeof(tmp); - buffer->bytes_used += num_vals * sizeof(tmp); - - return OPAL_SUCCESS; -} - -/* - * INT64 - */ -int opal_dss_pack_int64(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int32_t i; - uint64_t tmp, *srctmp = (uint64_t*) src; - char *dst; - size_t bytes_packed = num_vals * sizeof(tmp); - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_pack_int64 * %d\n", num_vals ) ); - /* check to see if buffer needs extending */ - if (NULL == (dst = opal_dss_buffer_extend(buffer, bytes_packed))) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - - for (i = 0; i < num_vals; ++i) { - tmp = hton64(srctmp[i]); - memcpy(dst, &tmp, sizeof(tmp)); - dst += sizeof(tmp); - } - buffer->pack_ptr += bytes_packed; - buffer->bytes_used += bytes_packed; - - return OPAL_SUCCESS; -} - -/* - * STRING - */ -int opal_dss_pack_string(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret = OPAL_SUCCESS; - int32_t i, len; - char **ssrc = (char**) src; - - for (i = 0; i < num_vals; ++i) { - if (NULL == ssrc[i]) { /* got zero-length string/NULL pointer - store NULL */ - len = 0; - if (OPAL_SUCCESS != (ret = opal_dss_pack_int32(buffer, &len, 1, OPAL_INT32))) { - return ret; - } - } else { - len = (int32_t)strlen(ssrc[i]) + 1; - if (OPAL_SUCCESS != (ret = opal_dss_pack_int32(buffer, &len, 1, OPAL_INT32))) { - return ret; - } - if (OPAL_SUCCESS != (ret = - opal_dss_pack_byte(buffer, ssrc[i], len, OPAL_BYTE))) { - return ret; - } - } - } - - return OPAL_SUCCESS; -} - -/* FLOAT */ -int opal_dss_pack_float(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret = OPAL_SUCCESS; - int32_t i; - float *ssrc = (float*)src; - char *convert; - - for (i = 0; i < num_vals; ++i) { - opal_asprintf(&convert, "%f", ssrc[i]); - if (OPAL_SUCCESS != (ret = opal_dss_pack_string(buffer, &convert, 1, OPAL_STRING))) { - free(convert); - return ret; - } - free(convert); - } - - return OPAL_SUCCESS; -} - -/* DOUBLE */ -int opal_dss_pack_double(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret = OPAL_SUCCESS; - int32_t i; - double *ssrc = (double*)src; - char *convert; - - for (i = 0; i < num_vals; ++i) { - opal_asprintf(&convert, "%f", ssrc[i]); - if (OPAL_SUCCESS != (ret = opal_dss_pack_string(buffer, &convert, 1, OPAL_STRING))) { - free(convert); - return ret; - } - free(convert); - } - - return OPAL_SUCCESS; -} - -/* TIMEVAL */ -int opal_dss_pack_timeval(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int64_t tmp[2]; - int ret = OPAL_SUCCESS; - int32_t i; - struct timeval *ssrc = (struct timeval *)src; - - for (i = 0; i < num_vals; ++i) { - tmp[0] = (int64_t)ssrc[i].tv_sec; - tmp[1] = (int64_t)ssrc[i].tv_usec; - if (OPAL_SUCCESS != (ret = opal_dss_pack_int64(buffer, tmp, 2, OPAL_INT64))) { - return ret; - } - } - - return OPAL_SUCCESS; -} - -/* TIME */ -int opal_dss_pack_time(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret = OPAL_SUCCESS; - int32_t i; - time_t *ssrc = (time_t *)src; - uint64_t ui64; - - /* time_t is a system-dependent size, so cast it - * to uint64_t as a generic safe size - */ - for (i = 0; i < num_vals; ++i) { - ui64 = (uint64_t)ssrc[i]; - if (OPAL_SUCCESS != (ret = opal_dss_pack_int64(buffer, &ui64, 1, OPAL_UINT64))) { - return ret; - } - } - - return OPAL_SUCCESS; -} - - -/* PACK FUNCTIONS FOR GENERIC OPAL TYPES */ - -/* - * OPAL_DATA_TYPE - */ -int opal_dss_pack_data_type(opal_buffer_t *buffer, const void *src, int32_t num_vals, - opal_data_type_t type) -{ - int ret; - - /* Turn around and pack the real type */ - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, src, num_vals, OPAL_DATA_TYPE_T))) { - } - - return ret; -} - -/* - * OPAL_BYTE_OBJECT - */ -int opal_dss_pack_byte_object(opal_buffer_t *buffer, const void *src, int32_t num, - opal_data_type_t type) -{ - opal_byte_object_t **sbyteptr; - int32_t i, n; - int ret; - - sbyteptr = (opal_byte_object_t **) src; - - for (i = 0; i < num; ++i) { - n = sbyteptr[i]->size; - if (OPAL_SUCCESS != (ret = opal_dss_pack_int32(buffer, &n, 1, OPAL_INT32))) { - return ret; - } - if (0 < n) { - if (OPAL_SUCCESS != (ret = - opal_dss_pack_byte(buffer, sbyteptr[i]->bytes, n, OPAL_BYTE))) { - return ret; - } - } - } - - return OPAL_SUCCESS; -} - -/* - * OPAL_VALUE - */ -int opal_dss_pack_value(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - opal_value_t **ptr; - int32_t i, n; - int ret; - - ptr = (opal_value_t **) src; - - for (i = 0; i < num_vals; ++i) { - /* pack the key and type */ - if (OPAL_SUCCESS != (ret = opal_dss_pack_string(buffer, &ptr[i]->key, 1, OPAL_STRING))) { - return ret; - } - if (OPAL_SUCCESS != (ret = opal_dss_pack_data_type(buffer, &ptr[i]->type, 1, OPAL_DATA_TYPE))) { - return ret; - } - /* now pack the right field */ - switch (ptr[i]->type) { - case OPAL_BOOL: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.flag, 1, OPAL_BOOL))) { - return ret; - } - break; - case OPAL_BYTE: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.byte, 1, OPAL_BYTE))) { - return ret; - } - break; - case OPAL_STRING: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.string, 1, OPAL_STRING))) { - return ret; - } - break; - case OPAL_SIZE: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.size, 1, OPAL_SIZE))) { - return ret; - } - break; - case OPAL_PID: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.pid, 1, OPAL_PID))) { - return ret; - } - break; - case OPAL_INT: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.integer, 1, OPAL_INT))) { - return ret; - } - break; - case OPAL_INT8: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.int8, 1, OPAL_INT8))) { - return ret; - } - break; - case OPAL_INT16: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.int16, 1, OPAL_INT16))) { - return ret; - } - break; - case OPAL_INT32: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.int32, 1, OPAL_INT32))) { - return ret; - } - break; - case OPAL_INT64: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.int64, 1, OPAL_INT64))) { - return ret; - } - break; - case OPAL_UINT: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint, 1, OPAL_UINT))) { - return ret; - } - break; - case OPAL_UINT8: - case OPAL_PERSIST: - case OPAL_SCOPE: - case OPAL_DATA_RANGE: - case OPAL_PROC_STATE: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint8, 1, OPAL_UINT8))) { - return ret; - } - break; - case OPAL_UINT16: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint16, 1, OPAL_UINT16))) { - return ret; - } - break; - case OPAL_UINT32: - case OPAL_INFO_DIRECTIVES: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint32, 1, OPAL_UINT32))) { - return ret; - } - break; - case OPAL_UINT64: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint64, 1, OPAL_UINT64))) { - return ret; - } - break; - case OPAL_BYTE_OBJECT: - /* have to pack by hand so we can match unpack without allocation */ - n = ptr[i]->data.bo.size; - if (OPAL_SUCCESS != (ret = opal_dss_pack_int32(buffer, &n, 1, OPAL_INT32))) { - return ret; - } - if (0 < n) { - if (OPAL_SUCCESS != (ret = opal_dss_pack_byte(buffer, ptr[i]->data.bo.bytes, n, OPAL_BYTE))) { - return ret; - } - } - break; - case OPAL_FLOAT: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.fval, 1, OPAL_FLOAT))) { - return ret; - } - break; - case OPAL_DOUBLE: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.dval, 1, OPAL_DOUBLE))) { - return ret; - } - break; - case OPAL_TIMEVAL: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.tv, 1, OPAL_TIMEVAL))) { - return ret; - } - break; - case OPAL_PTR: - /* just ignore these values */ - break; - case OPAL_NAME: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.name, 1, OPAL_NAME))) { - return ret; - } - break; - case OPAL_STATUS: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.status, 1, OPAL_INT))) { - return ret; - } - break; - case OPAL_ENVAR: - if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.envar, 1, OPAL_ENVAR))) { - return ret; - } - break; - default: - opal_output(0, "PACK-OPAL-VALUE: UNSUPPORTED TYPE %d FOR KEY %s", (int)ptr[i]->type, ptr[i]->key); - return OPAL_ERROR; - } - } - - return OPAL_SUCCESS; -} - - -/* - * BUFFER CONTENTS - */ -int opal_dss_pack_buffer_contents(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - opal_buffer_t **ptr; - int32_t i; - int ret; - - ptr = (opal_buffer_t **) src; - - for (i = 0; i < num_vals; ++i) { - /* pack the number of bytes */ - OPAL_OUTPUT((opal_dss_verbose, "opal_dss_pack_buffer_contents: bytes_used %u\n", (unsigned)ptr[i]->bytes_used)); - if (OPAL_SUCCESS != (ret = opal_dss_pack_sizet(buffer, &ptr[i]->bytes_used, 1, OPAL_SIZE))) { - return ret; - } - /* pack the bytes */ - if (0 < ptr[i]->bytes_used) { - if (OPAL_SUCCESS != (ret = opal_dss_pack_byte(buffer, ptr[i]->base_ptr, ptr[i]->bytes_used, OPAL_BYTE))) { - return ret; - } - } else { - ptr[i]->base_ptr = NULL; - } - } - return OPAL_SUCCESS; -} - -/* - * NAME - */ -int opal_dss_pack_name(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int rc; - int32_t i; - opal_process_name_t* proc; - opal_jobid_t *jobid; - opal_vpid_t *vpid; - - /* collect all the jobids in a contiguous array */ - jobid = (opal_jobid_t*)malloc(num_vals * sizeof(opal_jobid_t)); - if (NULL == jobid) { - OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE); - return OPAL_ERR_OUT_OF_RESOURCE; - } - proc = (opal_process_name_t*)src; - for (i=0; i < num_vals; i++) { - jobid[i] = proc->jobid; - proc++; - } - /* now pack them in one shot */ - if (OPAL_SUCCESS != (rc = - opal_dss_pack_jobid(buffer, jobid, num_vals, OPAL_JOBID))) { - OPAL_ERROR_LOG(rc); - free(jobid); - return rc; - } - free(jobid); - - /* collect all the vpids in a contiguous array */ - vpid = (opal_vpid_t*)malloc(num_vals * sizeof(opal_vpid_t)); - if (NULL == vpid) { - OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE); - return OPAL_ERR_OUT_OF_RESOURCE; - } - proc = (opal_process_name_t*)src; - for (i=0; i < num_vals; i++) { - vpid[i] = proc->vpid; - proc++; - } - /* now pack them in one shot */ - if (OPAL_SUCCESS != (rc = - opal_dss_pack_vpid(buffer, vpid, num_vals, OPAL_VPID))) { - OPAL_ERROR_LOG(rc); - free(vpid); - return rc; - } - free(vpid); - - return OPAL_SUCCESS; -} - -/* - * JOBID - */ -int opal_dss_pack_jobid(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret; - - /* Turn around and pack the real type */ - if (OPAL_SUCCESS != ( - ret = opal_dss_pack_buffer(buffer, src, num_vals, OPAL_JOBID_T))) { - OPAL_ERROR_LOG(ret); - } - - return ret; -} - -/* - * VPID - */ -int opal_dss_pack_vpid(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret; - - /* Turn around and pack the real type */ - if (OPAL_SUCCESS != ( - ret = opal_dss_pack_buffer(buffer, src, num_vals, OPAL_VPID_T))) { - OPAL_ERROR_LOG(ret); - } - - return ret; -} - -/* - * STATUS - */ -int opal_dss_pack_status(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret; - - /* Turn around and pack the real type */ - ret = opal_dss_pack_buffer(buffer, src, num_vals, OPAL_INT); - if (OPAL_SUCCESS != ret) { - OPAL_ERROR_LOG(ret); - } - - return ret; -} - -int opal_dss_pack_envar(opal_buffer_t *buffer, const void *src, - int32_t num_vals, opal_data_type_t type) -{ - int ret; - int32_t n; - opal_envar_t *ptr = (opal_envar_t*)src; - - for (n=0; n < num_vals; n++) { - if (OPAL_SUCCESS != (ret = opal_dss_pack_string(buffer, &ptr[n].envar, 1, OPAL_STRING))) { - return ret; - } - if (OPAL_SUCCESS != (ret = opal_dss_pack_string(buffer, &ptr[n].value, 1, OPAL_STRING))) { - return ret; - } - if (OPAL_SUCCESS != (ret = opal_dss_pack_byte(buffer, &ptr[n].separator, 1, OPAL_BYTE))) { - return ret; - } - } - return OPAL_SUCCESS; -} diff --git a/opal/dss/dss_peek.c b/opal/dss/dss_peek.c deleted file mode 100644 index 84561df397e..00000000000 --- a/opal/dss/dss_peek.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 "opal_config.h" - -#include "opal/dss/dss_internal.h" - -int opal_dss_peek(opal_buffer_t *buffer, opal_data_type_t *type, - int32_t *num_vals) -{ - int ret; - opal_buffer_t tmp; - int32_t n=1; - opal_data_type_t local_type; - - /* check for errors */ - if (buffer == NULL) { - return OPAL_ERR_BAD_PARAM; - } - - /* Double check and ensure that there is data left in the buffer. */ - - if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) { - *type = OPAL_NULL; - *num_vals = 0; - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* if this is NOT a fully described buffer, then that is as much as - * we can do - there is no way we can tell the caller what type is - * in the buffer since that info wasn't stored. - */ - if (OPAL_DSS_BUFFER_FULLY_DESC != buffer->type) { - *type = OPAL_UNDEF; - *num_vals = 0; - return OPAL_ERR_UNKNOWN_DATA_TYPE; - } - - /* cheat: unpack from a copy of the buffer -- leaving all the - original pointers intact */ - tmp = *buffer; - - if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(&tmp, &local_type))) { - *type = OPAL_NULL; - *num_vals = 0; - return ret; - } - if (OPAL_INT32 != local_type) { /* if the length wasn't first, then error */ - *type = OPAL_NULL; - *num_vals = 0; - return OPAL_ERR_UNPACK_FAILURE; - } - if (OPAL_SUCCESS != (ret = opal_dss_unpack_int32(&tmp, num_vals, &n, OPAL_INT32))) { - *type = OPAL_NULL; - *num_vals = 0; - return ret; - } - if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(&tmp, type))) { - *type = OPAL_NULL; - *num_vals = 0; - } - - return ret; -} - -int opal_dss_peek_type(opal_buffer_t *buffer, opal_data_type_t *type) -{ - int ret; - opal_buffer_t tmp; - - /* check for errors */ - if (buffer == NULL) { - return OPAL_ERR_BAD_PARAM; - } - - /* if this is NOT a fully described buffer, then there isn't anything - * we can do - there is no way we can tell the caller what type is - * in the buffer since that info wasn't stored. - */ - if (OPAL_DSS_BUFFER_FULLY_DESC != buffer->type) { - *type = OPAL_UNDEF; - return OPAL_ERR_UNKNOWN_DATA_TYPE; - } - /* Double check and ensure that there is data left in the buffer. */ - - if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) { - *type = OPAL_UNDEF; - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* cheat: unpack from a copy of the buffer -- leaving all the - original pointers intact */ - tmp = *buffer; - - if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(&tmp, type))) { - *type = OPAL_UNDEF; - return ret; - } - - return OPAL_SUCCESS; -} diff --git a/opal/dss/dss_print.c b/opal/dss/dss_print.c deleted file mode 100644 index e5293a7fdc3..00000000000 --- a/opal/dss/dss_print.c +++ /dev/null @@ -1,864 +0,0 @@ -/* - * Copyright (c) 2004-2007 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) 2012 Los Alamos National Security, Inc. All rights reserved. - * Copyright (c) 2014-2020 Intel, Inc. All rights reserved. - * Copyright (c) 2014 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" - -#include "opal_stdint.h" -#include - -#include "opal/util/error.h" -#include "opal/util/printf.h" -#include "opal/dss/dss_internal.h" - -int opal_dss_print(char **output, char *prefix, void *src, opal_data_type_t type) -{ - opal_dss_type_info_t *info; - - /* check for error */ - if (NULL == output) { - return OPAL_ERR_BAD_PARAM; - } - - /* Lookup the print function for this type and call it */ - - if(NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, type))) { - return OPAL_ERR_UNKNOWN_DATA_TYPE; - } - - return info->odti_print_fn(output, prefix, src, type); -} - -/* - * STANDARD PRINT FUNCTIONS FOR SYSTEM TYPES - */ -int opal_dss_print_byte(char **output, char *prefix, uint8_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_BYTE\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_BYTE\tValue: %x", prefix, *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_string(char **output, char *prefix, char *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_STRING\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_STRING\tValue: %s", prefx, src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_size(char **output, char *prefix, size_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_SIZE\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_SIZE\tValue: %lu", prefx, (unsigned long) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_pid(char **output, char *prefix, pid_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_PID\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_PID\tValue: %lu", prefx, (unsigned long) *src); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; -} - -int opal_dss_print_bool(char **output, char *prefix, bool *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_BOOL\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_BOOL\tValue: %s", prefx, *src ? "TRUE" : "FALSE"); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_int(char **output, char *prefix, int *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_INT\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_INT\tValue: %ld", prefx, (long) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_uint(char **output, char *prefix, int *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_UINT\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_UINT\tValue: %lu", prefx, (unsigned long) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_uint8(char **output, char *prefix, uint8_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_UINT8\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_UINT8\tValue: %u", prefx, (unsigned int) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_uint16(char **output, char *prefix, uint16_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_UINT16\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_UINT16\tValue: %u", prefx, (unsigned int) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_uint32(char **output, char *prefix, uint32_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_UINT32\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_UINT32\tValue: %u", prefx, (unsigned int) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_int8(char **output, char *prefix, int8_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_INT8\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_INT8\tValue: %d", prefx, (int) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_int16(char **output, char *prefix, int16_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_INT16\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_INT16\tValue: %d", prefx, (int) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_int32(char **output, char *prefix, int32_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_INT32\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_INT32\tValue: %d", prefx, (int) *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} -int opal_dss_print_uint64(char **output, char *prefix, -#ifdef HAVE_INT64_T - uint64_t *src, -#else - void *src, -#endif /* HAVE_INT64_T */ - opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - -#ifdef HAVE_INT64_T - opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: %lu", prefx, (unsigned long) *src); -#else - opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: unsupported", prefx); -#endif /* HAVE_INT64_T */ - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_int64(char **output, char *prefix, -#ifdef HAVE_INT64_T - int64_t *src, -#else - void *src, -#endif /* HAVE_INT64_T */ - opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_INT64\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - -#ifdef HAVE_INT64_T - opal_asprintf(output, "%sData type: OPAL_INT64\tValue: %ld", prefx, (long) *src); -#else - opal_asprintf(output, "%sData type: OPAL_INT64\tValue: unsupported", prefx); -#endif /* HAVE_INT64_T */ - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_float(char **output, char *prefix, - float *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_FLOAT\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_FLOAT\tValue: %f", prefx, *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_double(char **output, char *prefix, - double *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_DOUBLE\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_DOUBLE\tValue: %f", prefx, *src); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_time(char **output, char *prefix, - time_t *src, opal_data_type_t type) -{ - char *prefx; - char *t; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_TIME\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - t = ctime(src); - t[strlen(t)-1] = '\0'; // remove trailing newline - - opal_asprintf(output, "%sData type: OPAL_TIME\tValue: %s", prefx, t); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_timeval(char **output, char *prefix, - struct timeval *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: %ld.%06ld", prefx, - (long)src->tv_sec, (long)src->tv_usec); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_null(char **output, char *prefix, void *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_NULL\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_NULL", prefx); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - - -/* PRINT FUNCTIONS FOR GENERIC OPAL TYPES */ - -/* - * OPAL_DATA_TYPE - */ -int opal_dss_print_data_type(char **output, char *prefix, opal_data_type_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_DATA_TYPE\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_DATA_TYPE\tValue: %lu", prefx, (unsigned long) *src); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; -} - -/* - * OPAL_BYTE_OBJECT - */ -int opal_dss_print_byte_object(char **output, char *prefix, opal_byte_object_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_BYTE_OBJECT\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_BYTE_OBJECT\tSize: %lu", prefx, (unsigned long) src->size); - if (prefx != prefix) { - free(prefx); - } - - return OPAL_SUCCESS; -} - -/* - * OPAL_VALUE - */ -int opal_dss_print_value(char **output, char *prefix, opal_value_t *src, opal_data_type_t type) -{ - char *prefx; - - /* deal with NULL prefix */ - if (NULL == prefix) opal_asprintf(&prefx, " "); - else prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_VALUE\tValue: NULL pointer", prefx); - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; - } - - switch (src->type) { - case OPAL_BOOL: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BOOL\tKey: %s\tValue: %s", - prefx, src->key, src->data.flag ? "true" : "false"); - break; - case OPAL_BYTE: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BYTE\tKey: %s\tValue: %x", - prefx, src->key, src->data.byte); - break; - case OPAL_STRING: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_STRING\tKey: %s\tValue: %s", - prefx, src->key, src->data.string); - break; - case OPAL_SIZE: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_SIZE\tKey: %s\tValue: %lu", - prefx, src->key, (unsigned long)src->data.size); - break; - case OPAL_PID: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PID\tKey: %s\tValue: %lu", - prefx, src->key, (unsigned long)src->data.pid); - break; - case OPAL_INT: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT\tKey: %s\tValue: %d", - prefx, src->key, src->data.integer); - break; - case OPAL_INT8: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT8\tKey: %s\tValue: %d", - prefx, src->key, (int)src->data.int8); - break; - case OPAL_INT16: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT16\tKey: %s\tValue: %d", - prefx, src->key, (int)src->data.int16); - break; - case OPAL_INT32: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT32\tKey: %s\tValue: %d", - prefx, src->key, src->data.int32); - break; - case OPAL_INT64: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT64\tKey: %s\tValue: %ld", - prefx, src->key, (long)src->data.int64); - break; - case OPAL_UINT: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT\tKey: %s\tValue: %u", - prefx, src->key, src->data.uint); - break; - case OPAL_UINT8: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT8\tKey: %s\tValue: %u", - prefx, src->key, (unsigned int)src->data.uint8); - break; - case OPAL_UINT16: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT16\tKey: %s\tValue: %u", - prefx, src->key, (unsigned int)src->data.uint16); - break; - case OPAL_UINT32: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT32\tKey: %s\tValue: %u", - prefx, src->key, src->data.uint32); - break; - case OPAL_UINT64: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT64\tKey: %s\tValue: %lu", - prefx, src->key, (unsigned long)src->data.uint64); - break; - case OPAL_FLOAT: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_FLOAT\tKey: %s\tValue: %f", - prefx, src->key, src->data.fval); - break; - case OPAL_DOUBLE: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_DOUBLE\tKey: %s\tValue: %f", - prefx, src->key, src->data.dval); - break; - case OPAL_BYTE_OBJECT: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BYTE_OBJECT\tKey: %s\tData: %s\tSize: %lu", - prefx, src->key, (NULL == src->data.bo.bytes) ? "NULL" : "NON-NULL", (unsigned long)src->data.bo.size); - break; - case OPAL_TIMEVAL: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIMEVAL\tKey: %s\tValue: %ld.%06ld", prefx, - src->key, (long)src->data.tv.tv_sec, (long)src->data.tv.tv_usec); - break; - case OPAL_TIME: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIME\tKey: %s\tValue: %s", prefx, - src->key, ctime(&src->data.time)); - break; - case OPAL_NAME: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_NAME\tKey: %s\tValue: %s", prefx, - src->key, OPAL_NAME_PRINT(src->data.name)); - break; - case OPAL_PTR: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PTR\tKey: %s", prefx, src->key); - break; - case OPAL_ENVAR: - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_ENVAR\tKey: %s\tName: %s\tValue: %s\tSeparator: %c", - prefx, src->key, - (NULL == src->data.envar.envar) ? "NULL" : src->data.envar.envar, - (NULL == src->data.envar.value) ? "NULL" : src->data.envar.value, - ('\0' == src->data.envar.separator) ? ' ' : src->data.envar.separator); - break; - default: - opal_asprintf(output, "%sOPAL_VALUE: Data type: UNKNOWN\tKey: %s\tValue: UNPRINTABLE", - prefx, src->key); - break; - } - if (prefx != prefix) { - free(prefx); - } - return OPAL_SUCCESS; -} - -int opal_dss_print_buffer_contents(char **output, char *prefix, - opal_buffer_t *src, opal_data_type_t type) -{ - return OPAL_SUCCESS; -} - -/* - * NAME - */ -int opal_dss_print_name(char **output, char *prefix, opal_process_name_t *name, opal_data_type_t type) -{ - /* set default result */ - *output = NULL; - - if (NULL == name) { - opal_asprintf(output, "%sData type: ORTE_PROCESS_NAME\tData Value: NULL", - (NULL == prefix ? " " : prefix)); - } else { - opal_asprintf(output, "%sData type: ORTE_PROCESS_NAME\tData Value: [%d,%d]", - (NULL == prefix ? " " : prefix), name->jobid, name->vpid); - } - - return OPAL_SUCCESS; -} - -int opal_dss_print_jobid(char **output, char *prefix, - opal_process_name_t *src, opal_data_type_t type) -{ - char *prefx = " "; - - /* deal with NULL prefix */ - if (NULL != prefix) prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_JOBID\tValue: NULL pointer", prefx); - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_JOBID\tValue: %s", prefx, opal_jobid_print(src->jobid)); - return OPAL_SUCCESS; -} - -int opal_dss_print_vpid(char **output, char *prefix, - opal_process_name_t *src, opal_data_type_t type) -{ - char *prefx = " "; - - /* deal with NULL prefix */ - if (NULL != prefix) prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_VPID\tValue: NULL pointer", prefx); - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_VPID\tValue: %s", prefx, opal_vpid_print(src->vpid)); - return OPAL_SUCCESS; -} - -int opal_dss_print_status(char **output, char *prefix, - int *src, opal_data_type_t type) -{ - char *prefx = " "; - - /* deal with NULL prefix */ - if (NULL != prefix) prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_STATUS\tValue: NULL pointer", prefx); - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sData type: OPAL_STATUS\tValue: %s", prefx, opal_strerror(*src)); - return OPAL_SUCCESS; -} - - -int opal_dss_print_envar(char **output, char *prefix, - opal_envar_t *src, opal_data_type_t type) -{ - char *prefx = " "; - - /* deal with NULL prefix */ - if (NULL != prefix) prefx = prefix; - - /* if src is NULL, just print data type and return */ - if (NULL == src) { - opal_asprintf(output, "%sData type: OPAL_ENVAR\tValue: NULL pointer", prefx); - return OPAL_SUCCESS; - } - - opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_ENVAR\tName: %s\tValue: %s\tSeparator: %c", - prefx, (NULL == src->envar) ? "NULL" : src->envar, - (NULL == src->value) ? "NULL" : src->value, - ('\0' == src->separator) ? ' ' : src->separator); - return OPAL_SUCCESS; -} diff --git a/opal/dss/dss_register.c b/opal/dss/dss_register.c deleted file mode 100644 index 8e89bc573e7..00000000000 --- a/opal/dss/dss_register.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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) 2012 Los Alamos National Security, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" - -#include "opal/dss/dss_internal.h" - -int opal_dss_register(opal_dss_pack_fn_t pack_fn, - opal_dss_unpack_fn_t unpack_fn, - opal_dss_copy_fn_t copy_fn, - opal_dss_compare_fn_t compare_fn, - opal_dss_print_fn_t print_fn, - bool structured, - const char *name, opal_data_type_t *type) -{ - opal_dss_type_info_t *info, *ptr; - int32_t i; - - /* Check for bozo cases */ - - if (NULL == pack_fn || NULL == unpack_fn || NULL == copy_fn || NULL == compare_fn || - NULL == print_fn || NULL == name || NULL == type) { - return OPAL_ERR_BAD_PARAM; - } - - /* check if this entry already exists - if so, error - we do NOT allow multiple type registrations */ - for (i=0; i < opal_pointer_array_get_size(&opal_dss_types); i++) { - ptr = opal_pointer_array_get_item(&opal_dss_types, i); - if (NULL != ptr) { - /* check if the name exists */ - if (0 == strcmp(ptr->odti_name, name)) { - return OPAL_ERR_DATA_TYPE_REDEF; - } - /* check if the specified type exists */ - if (*type > 0 && ptr->odti_type == *type) { - return OPAL_ERR_DATA_TYPE_REDEF; - } - } - } - - /* if type is given (i.e., *type > 0), then just use it. - * otherwise, it is an error - */ - if (0 >= *type) { - return OPAL_ERR_BAD_PARAM; - } - - /* Add a new entry to the table */ - info = (opal_dss_type_info_t*) OBJ_NEW(opal_dss_type_info_t); - if (NULL == info) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - info->odti_type = *type; - info->odti_name = strdup(name); - info->odti_pack_fn = pack_fn; - info->odti_unpack_fn = unpack_fn; - info->odti_copy_fn = copy_fn; - info->odti_compare_fn = compare_fn; - info->odti_print_fn = print_fn; - info->odti_structured = structured; - - return opal_pointer_array_set_item(&opal_dss_types, *type, info); -} diff --git a/opal/dss/dss_types.h b/opal/dss/dss_types.h deleted file mode 100644 index 29f44beb586..00000000000 --- a/opal/dss/dss_types.h +++ /dev/null @@ -1,230 +0,0 @@ -/* -*- C -*- - * - * 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-2011 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights - * reserved. - * Copyright (c) 2014-2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2014-2020 Intel, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -/** - * @file - * - * Buffer management types. - */ - -#ifndef OPAL_DSS_TYPES_H_ -#define OPAL_DSS_TYPES_H_ - -#include "opal_config.h" - -#ifdef HAVE_SYS_TIME_H -#include /* for struct timeval */ -#endif - -#include "opal/class/opal_object.h" -#include "opal/class/opal_pointer_array.h" -#include "opal/class/opal_list.h" - -typedef uint32_t opal_jobid_t; -typedef uint32_t opal_vpid_t; -typedef struct { - opal_jobid_t jobid; - opal_vpid_t vpid; -} opal_process_name_t; -#define OPAL_SIZEOF_PROCESS_NAME_T 8 - -BEGIN_C_DECLS - -typedef uint8_t opal_data_type_t; /** data type indicators */ -#define OPAL_DATA_TYPE_T OPAL_UINT8 -#define OPAL_DSS_ID_MAX UINT8_MAX -#define OPAL_DSS_ID_INVALID OPAL_DSS_ID_MAX - -/* define a structure to hold generic byte objects */ -typedef struct { - int32_t size; - uint8_t *bytes; -} opal_byte_object_t; - -/* Type defines for packing and unpacking */ -#define OPAL_UNDEF (opal_data_type_t) 0 /**< type hasn't been defined yet */ -#define OPAL_BYTE (opal_data_type_t) 1 /**< a byte of data */ -#define OPAL_BOOL (opal_data_type_t) 2 /**< boolean */ -#define OPAL_STRING (opal_data_type_t) 3 /**< a NULL terminated string */ -#define OPAL_SIZE (opal_data_type_t) 4 /**< the generic size_t */ -#define OPAL_PID (opal_data_type_t) 5 /**< process pid */ - /* all the integer flavors */ -#define OPAL_INT (opal_data_type_t) 6 /**< generic integer */ -#define OPAL_INT8 (opal_data_type_t) 7 /**< an 8-bit integer */ -#define OPAL_INT16 (opal_data_type_t) 8 /**< a 16-bit integer */ -#define OPAL_INT32 (opal_data_type_t) 9 /**< a 32-bit integer */ -#define OPAL_INT64 (opal_data_type_t) 10 /**< a 64-bit integer */ - /* all the unsigned integer flavors */ -#define OPAL_UINT (opal_data_type_t) 11 /**< generic unsigned integer */ -#define OPAL_UINT8 (opal_data_type_t) 12 /**< an 8-bit unsigned integer */ -#define OPAL_UINT16 (opal_data_type_t) 13 /**< a 16-bit unsigned integer */ -#define OPAL_UINT32 (opal_data_type_t) 14 /**< a 32-bit unsigned integer */ -#define OPAL_UINT64 (opal_data_type_t) 15 /**< a 64-bit unsigned integer */ - /* floating point types */ -#define OPAL_FLOAT (opal_data_type_t) 16 -#define OPAL_DOUBLE (opal_data_type_t) 17 - /* system types */ -#define OPAL_TIMEVAL (opal_data_type_t) 18 -#define OPAL_TIME (opal_data_type_t) 19 - /* OPAL types */ -#define OPAL_BYTE_OBJECT (opal_data_type_t) 20 /**< byte object structure */ -#define OPAL_DATA_TYPE (opal_data_type_t) 21 /**< data type */ -#define OPAL_NULL (opal_data_type_t) 22 /**< don't interpret data type */ -#define OPAL_VALUE (opal_data_type_t) 26 /**< opal value structure */ -#define OPAL_BUFFER (opal_data_type_t) 27 /**< pack the remaining contents of a buffer as an object */ -#define OPAL_PTR (opal_data_type_t) 28 /**< pointer to void* */ -#define OPAL_NAME (opal_data_type_t) 29 -#define OPAL_JOBID (opal_data_type_t) 30 -#define OPAL_VPID (opal_data_type_t) 31 -#define OPAL_STATUS (opal_data_type_t) 32 -#define OPAL_PERSIST (opal_data_type_t) 33 /**< corresponds to PMIx persistence type (uint8_t) */ -#define OPAL_SCOPE (opal_data_type_t) 34 /**< corresponds to PMIx scope type (uint8_t) */ -#define OPAL_DATA_RANGE (opal_data_type_t) 35 /**< corresponds to PMIx data range type (uint8_t) */ -#define OPAL_INFO_DIRECTIVES (opal_data_type_t) 36 /**< corresponds to PMIx info directives type (uint32_t) */ -#define OPAL_PROC_STATE (opal_data_type_t) 37 /**< corresponds to PMIx proc state type (uint8_t) */ -#define OPAL_PROC_INFO (opal_data_type_t) 38 /**< corresponds to PMIx proc_info type */ -#define OPAL_ENVAR (opal_data_type_t) 39 /**< corresponds to PMIx envar type */ -#define OPAL_LIST (opal_data_type_t) 40 /**< an opal list */ - - /* OPAL Dynamic */ -#define OPAL_DSS_ID_DYNAMIC (opal_data_type_t) 100 - -/* define the results values for comparisons so we can change them in only one place */ -#define OPAL_VALUE1_GREATER +1 -#define OPAL_VALUE2_GREATER -1 -#define OPAL_EQUAL 0 - -/* define some types so we can store the generic - * values and still *know* how to convert it for PMIx */ -typedef int opal_status_t; -typedef uint32_t opal_proc_state_t; - -/* define an opal_proc_info_t for transferring info to/from PMIx */ -typedef struct { - opal_list_item_t super; - opal_process_name_t name; - char *hostname; - char *executable_name; - pid_t pid; - opal_status_t exit_code; - opal_proc_state_t state; -} opal_proc_info_t; -OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_proc_info_t); - -/* defaine a struct for envar directives */ -typedef struct { - opal_list_item_t super; - char *envar; - char *value; - char separator; -} opal_envar_t; -OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_envar_t); - -/* Data value object */ -typedef struct { - opal_list_item_t super; /* required for this to be on lists */ - char *key; /* key string */ - opal_data_type_t type; /* the type of value stored */ - union { - bool flag; - uint8_t byte; - char *string; - size_t size; - pid_t pid; - int integer; - int8_t int8; - int16_t int16; - int32_t int32; - int64_t int64; - unsigned int uint; - uint8_t uint8; - uint16_t uint16; - uint32_t uint32; - uint64_t uint64; - opal_byte_object_t bo; - float fval; - double dval; - struct timeval tv; - time_t time; - opal_status_t status; - opal_process_name_t name; - opal_proc_info_t pinfo; - void *ptr; // never packed or passed anywhere - opal_envar_t envar; - } data; -} opal_value_t; -OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_value_t); - -/* structured-unstructured data flags */ -#define OPAL_DSS_STRUCTURED true -#define OPAL_DSS_UNSTRUCTURED false - -/** - * buffer type - */ -enum opal_dss_buffer_type_t { - OPAL_DSS_BUFFER_NON_DESC = 0x00, - OPAL_DSS_BUFFER_FULLY_DESC = 0x01 -}; - -typedef enum opal_dss_buffer_type_t opal_dss_buffer_type_t; - -#define OPAL_DSS_BUFFER_TYPE_HTON(h); -#define OPAL_DSS_BUFFER_TYPE_NTOH(h); - -/** - * Structure for holding a buffer to be used with the RML or OOB - * subsystems. - */ -struct opal_buffer_t { - /** First member must be the object's parent */ - opal_object_t parent; - /** type of buffer */ - opal_dss_buffer_type_t type; - /** Start of my memory */ - char *base_ptr; - /** Where the next data will be packed to (within the allocated - memory starting at base_ptr) */ - char *pack_ptr; - /** Where the next data will be unpacked from (within the - allocated memory starting as base_ptr) */ - char *unpack_ptr; - - /** Number of bytes allocated (starting at base_ptr) */ - size_t bytes_allocated; - /** Number of bytes used by the buffer (i.e., amount of data -- - including overhead -- packed in the buffer) */ - size_t bytes_used; -}; -/** - * Convenience typedef - */ -typedef struct opal_buffer_t opal_buffer_t; - -/** formalize the declaration */ -OPAL_DECLSPEC OBJ_CLASS_DECLARATION (opal_buffer_t); - -END_C_DECLS - -#endif /* OPAL_DSS_TYPES_H */ diff --git a/opal/dss/dss_unpack.c b/opal/dss/dss_unpack.c deleted file mode 100644 index a2ad8c66178..00000000000 --- a/opal/dss/dss_unpack.c +++ /dev/null @@ -1,931 +0,0 @@ -/* -*- 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-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) 2012-2015 Los Alamos National Security, Inc. All rights reserved. - * Copyright (c) 2014-2020 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" -#include "opal/types.h" -#include "opal/util/error.h" -#include "opal/util/output.h" -#include "opal/dss/dss_internal.h" - -int opal_dss_unpack(opal_buffer_t *buffer, void *dst, int32_t *num_vals, - opal_data_type_t type) -{ - int rc, ret; - int32_t local_num, n=1; - opal_data_type_t local_type; - - /* check for error */ - if (NULL == buffer || NULL == dst || NULL == num_vals) { - return OPAL_ERR_BAD_PARAM; - } - - /* if user provides a zero for num_vals, then there is no storage allocated - * so return an appropriate error - */ - if (0 == *num_vals) { - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack: inadequate space ( %p, %p, %lu, %d )\n", - (void*)buffer, dst, (long unsigned int)*num_vals, (int)type ) ); - return OPAL_ERR_UNPACK_INADEQUATE_SPACE; - } - - /** Unpack the declared number of values - * REMINDER: it is possible that the buffer is corrupted and that - * the DSS will *think* there is a proper int32_t variable at the - * beginning of the unpack region - but that the value is bogus (e.g., just - * a byte field in a string array that so happens to have a value that - * matches the int32_t data type flag). Therefore, this error check is - * NOT completely safe. This is true for ALL unpack functions, not just - * int32_t as used here. - */ - if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { - if (OPAL_SUCCESS != ( - rc = opal_dss_get_data_type(buffer, &local_type))) { - *num_vals = 0; - return rc; - } - if (OPAL_INT32 != local_type) { /* if the length wasn't first, then error */ - *num_vals = 0; - return OPAL_ERR_UNPACK_FAILURE; - } - } - - n=1; - if (OPAL_SUCCESS != (rc = opal_dss_unpack_int32(buffer, &local_num, &n, OPAL_INT32))) { - *num_vals = 0; - return rc; - } - - /** if the storage provided is inadequate, set things up - * to unpack as much as we can and to return an error code - * indicating that everything was not unpacked - the buffer - * is left in a state where it can not be further unpacked. - */ - if (local_num > *num_vals) { - local_num = *num_vals; - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack: inadequate space ( %p, %p, %lu, %d )\n", - (void*)buffer, dst, (long unsigned int)*num_vals, (int)type ) ); - ret = OPAL_ERR_UNPACK_INADEQUATE_SPACE; - } else { /** enough or more than enough storage */ - *num_vals = local_num; /** let the user know how many we actually unpacked */ - ret = OPAL_SUCCESS; - } - - /** Unpack the value(s) */ - if (OPAL_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, dst, &local_num, type))) { - *num_vals = 0; - ret = rc; - } - - return ret; -} - -int opal_dss_unpack_buffer(opal_buffer_t *buffer, void *dst, int32_t *num_vals, - opal_data_type_t type) -{ - int rc; - opal_data_type_t local_type; - opal_dss_type_info_t *info; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_buffer( %p, %p, %lu, %d )\n", - (void*)buffer, dst, (long unsigned int)*num_vals, (int)type ) ); - - /** Unpack the declared data type */ - if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { - if (OPAL_SUCCESS != (rc = opal_dss_get_data_type(buffer, &local_type))) { - return rc; - } - /* if the data types don't match, then return an error */ - if (type != local_type) { - opal_output(0, "OPAL dss:unpack: got type %d when expecting type %d", local_type, type); - return OPAL_ERR_PACK_MISMATCH; - } - } - - /* Lookup the unpack function for this type and call it */ - - if (NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, type))) { - return OPAL_ERR_UNPACK_FAILURE; - } - - return info->odti_unpack_fn(buffer, dst, num_vals, type); -} - - -/* UNPACK GENERIC SYSTEM TYPES */ - -/* - * BOOL - */ -int opal_dss_unpack_bool(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int ret; - opal_data_type_t remote_type; - - if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { - /* see what type was actually packed */ - if (OPAL_SUCCESS != (ret = opal_dss_peek_type(buffer, &remote_type))) { - return ret; - } - } else { - if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(buffer, &remote_type))) { - return ret; - } - } - - if (remote_type == DSS_TYPE_BOOL) { - /* fast path it if the sizes are the same */ - /* Turn around and unpack the real type */ - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_BOOL))) { - } - } else { - /* slow path - types are different sizes */ - UNPACK_SIZE_MISMATCH(bool, remote_type, ret); - } - return ret; -} - -/* - * INT - */ -int opal_dss_unpack_int(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int ret; - opal_data_type_t remote_type; - - if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { - /* see what type was actually packed */ - if (OPAL_SUCCESS != (ret = opal_dss_peek_type(buffer, &remote_type))) { - return ret; - } - } else { - if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(buffer, &remote_type))) { - return ret; - } - } - - if (remote_type == DSS_TYPE_INT) { - /* fast path it if the sizes are the same */ - /* Turn around and unpack the real type */ - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_INT))) { - } - } else { - /* slow path - types are different sizes */ - UNPACK_SIZE_MISMATCH(int, remote_type, ret); - } - - return ret; -} - -/* - * SIZE_T - */ -int opal_dss_unpack_sizet(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int ret; - opal_data_type_t remote_type; - - if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { - /* see what type was actually packed */ - if (OPAL_SUCCESS != (ret = opal_dss_peek_type(buffer, &remote_type))) { - return ret; - } - } else { - if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(buffer, &remote_type))) { - return ret; - } - } - - if (remote_type == DSS_TYPE_SIZE_T) { - /* fast path it if the sizes are the same */ - /* Turn around and unpack the real type */ - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_SIZE_T))) { - } - } else { - /* slow path - types are different sizes */ - UNPACK_SIZE_MISMATCH(size_t, remote_type, ret); - } - - return ret; -} - -/* - * PID_T - */ -int opal_dss_unpack_pid(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int ret; - opal_data_type_t remote_type; - - if (OPAL_DSS_BUFFER_FULLY_DESC == buffer->type) { - /* see what type was actually packed */ - if (OPAL_SUCCESS != (ret = opal_dss_peek_type(buffer, &remote_type))) { - return ret; - } - } else { - if (OPAL_SUCCESS != (ret = opal_dss_get_data_type(buffer, &remote_type))) { - return ret; - } - } - - if (remote_type == DSS_TYPE_PID_T) { - /* fast path it if the sizes are the same */ - /* Turn around and unpack the real type */ - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, dest, num_vals, DSS_TYPE_PID_T))) { - } - } else { - /* slow path - types are different sizes */ - UNPACK_SIZE_MISMATCH(pid_t, remote_type, ret); - } - - return ret; -} - - -/* UNPACK FUNCTIONS FOR NON-GENERIC SYSTEM TYPES */ - -/* - * NULL - */ -int opal_dss_unpack_null(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_null * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, *num_vals)) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - memcpy(dest, buffer->unpack_ptr, *num_vals); - - /* update buffer pointer */ - buffer->unpack_ptr += *num_vals; - - return OPAL_SUCCESS; -} - -/* - * BYTE, CHAR, INT8 - */ -int opal_dss_unpack_byte(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_byte * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, *num_vals)) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - memcpy(dest, buffer->unpack_ptr, *num_vals); - - /* update buffer pointer */ - buffer->unpack_ptr += *num_vals; - - return OPAL_SUCCESS; -} - -int opal_dss_unpack_int16(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int32_t i; - uint16_t tmp, *desttmp = (uint16_t*) dest; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_int16 * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, (*num_vals)*sizeof(tmp))) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - for (i = 0; i < (*num_vals); ++i) { - memcpy( &(tmp), buffer->unpack_ptr, sizeof(tmp) ); - tmp = ntohs(tmp); - memcpy(&desttmp[i], &tmp, sizeof(tmp)); - buffer->unpack_ptr += sizeof(tmp); - } - - return OPAL_SUCCESS; -} - -int opal_dss_unpack_int32(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int32_t i; - uint32_t tmp, *desttmp = (uint32_t*) dest; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_int32 * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, (*num_vals)*sizeof(tmp))) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - for (i = 0; i < (*num_vals); ++i) { - memcpy( &(tmp), buffer->unpack_ptr, sizeof(tmp) ); - tmp = ntohl(tmp); - memcpy(&desttmp[i], &tmp, sizeof(tmp)); - buffer->unpack_ptr += sizeof(tmp); - } - - return OPAL_SUCCESS; -} - -int opal_dss_unpack_int64(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int32_t i; - uint64_t tmp, *desttmp = (uint64_t*) dest; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_int64 * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, (*num_vals)*sizeof(tmp))) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - for (i = 0; i < (*num_vals); ++i) { - memcpy( &(tmp), buffer->unpack_ptr, sizeof(tmp) ); - tmp = ntoh64(tmp); - memcpy(&desttmp[i], &tmp, sizeof(tmp)); - buffer->unpack_ptr += sizeof(tmp); - } - - return OPAL_SUCCESS; -} - -int opal_dss_unpack_string(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int ret; - int32_t i, len, n=1; - char **sdest = (char**) dest; - - for (i = 0; i < (*num_vals); ++i) { - if (OPAL_SUCCESS != (ret = opal_dss_unpack_int32(buffer, &len, &n, OPAL_INT32))) { - return ret; - } - if (0 == len) { /* zero-length string - unpack the NULL */ - sdest[i] = NULL; - } else { - sdest[i] = (char*)malloc(len); - if (NULL == sdest[i]) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - if (OPAL_SUCCESS != (ret = opal_dss_unpack_byte(buffer, sdest[i], &len, OPAL_BYTE))) { - return ret; - } - } - } - - return OPAL_SUCCESS; -} - -int opal_dss_unpack_float(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int32_t i, n; - float *desttmp = (float*) dest, tmp; - int ret; - char *convert; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_float * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, (*num_vals)*sizeof(float))) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - for (i = 0; i < (*num_vals); ++i) { - n=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_string(buffer, &convert, &n, OPAL_STRING))) { - return ret; - } - if (NULL == convert) { - return OPAL_ERR_UNPACK_FAILURE; - } - tmp = strtof(convert, NULL); - memcpy(&desttmp[i], &tmp, sizeof(tmp)); - free(convert); - convert = NULL; - } - return OPAL_SUCCESS; -} - -int opal_dss_unpack_double(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int32_t i, n; - double *desttmp = (double*) dest, tmp; - int ret; - char *convert; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_double * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, (*num_vals)*sizeof(double))) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - for (i = 0; i < (*num_vals); ++i) { - n=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_string(buffer, &convert, &n, OPAL_STRING))) { - return ret; - } - if (NULL == convert) { - return OPAL_ERR_UNPACK_FAILURE; - } - tmp = strtod(convert, NULL); - memcpy(&desttmp[i], &tmp, sizeof(tmp)); - free(convert); - convert = NULL; - } - return OPAL_SUCCESS; -} - -int opal_dss_unpack_timeval(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int32_t i, n; - int64_t tmp[2]; - struct timeval *desttmp = (struct timeval *) dest, tt; - int ret; - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_timeval * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, (*num_vals)*sizeof(struct timeval))) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - for (i = 0; i < (*num_vals); ++i) { - n=2; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_int64(buffer, tmp, &n, OPAL_INT64))) { - return ret; - } - tt.tv_sec = tmp[0]; - tt.tv_usec = tmp[1]; - memcpy(&desttmp[i], &tt, sizeof(tt)); - } - return OPAL_SUCCESS; -} - -int opal_dss_unpack_time(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int32_t i, n; - time_t *desttmp = (time_t *) dest, tmp; - int ret; - uint64_t ui64; - - /* time_t is a system-dependent size, so cast it - * to uint64_t as a generic safe size - */ - - OPAL_OUTPUT( ( opal_dss_verbose, "opal_dss_unpack_time * %d\n", (int)*num_vals ) ); - /* check to see if there's enough data in buffer */ - if (opal_dss_too_small(buffer, (*num_vals)*(sizeof(uint64_t)))) { - return OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - for (i = 0; i < (*num_vals); ++i) { - n=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_int64(buffer, &ui64, &n, OPAL_UINT64))) { - return ret; - } - tmp = (time_t)ui64; - memcpy(&desttmp[i], &tmp, sizeof(tmp)); - } - return OPAL_SUCCESS; -} - - -/* UNPACK FUNCTIONS FOR GENERIC OPAL TYPES */ - -/* - * OPAL_DATA_TYPE - */ -int opal_dss_unpack_data_type(opal_buffer_t *buffer, void *dest, int32_t *num_vals, - opal_data_type_t type) -{ - /* turn around and unpack the real type */ - return opal_dss_unpack_buffer(buffer, dest, num_vals, OPAL_DATA_TYPE_T); -} - -/* - * OPAL_BYTE_OBJECT - */ -int opal_dss_unpack_byte_object(opal_buffer_t *buffer, void *dest, int32_t *num, - opal_data_type_t type) -{ - int ret; - int32_t i, n, m=1; - opal_byte_object_t **dbyteptr; - - dbyteptr = (opal_byte_object_t**)dest; - n = *num; - for(i=0; isize), &m, OPAL_INT32))) { - return ret; - } - if (0 < dbyteptr[i]->size) { - dbyteptr[i]->bytes = (uint8_t*)malloc(dbyteptr[i]->size); - if (NULL == dbyteptr[i]->bytes) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - if (OPAL_SUCCESS != (ret = opal_dss_unpack_byte(buffer, (dbyteptr[i]->bytes), - &(dbyteptr[i]->size), OPAL_BYTE))) { - return ret; - } - } else { - /* be sure to init the bytes pointer to NULL! */ - dbyteptr[i]->bytes = NULL; - } - } - - return OPAL_SUCCESS; -} - -/* - * OPAL_VALUE - */ -int opal_dss_unpack_value(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - opal_value_t **ptr; - int32_t i, n, m; - int ret; - - ptr = (opal_value_t **) dest; - n = *num_vals; - - for (i = 0; i < n; ++i) { - /* allocate the new object */ - ptr[i] = OBJ_NEW(opal_value_t); - if (NULL == ptr[i]) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - /* unpack the key and type */ - m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_string(buffer, &ptr[i]->key, &m, OPAL_STRING))) { - return ret; - } - m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_data_type(buffer, &ptr[i]->type, &m, OPAL_DATA_TYPE))) { - return ret; - } - /* now unpack the right field */ - m=1; - switch (ptr[i]->type) { - case OPAL_BOOL: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.flag, &m, OPAL_BOOL))) { - return ret; - } - break; - case OPAL_BYTE: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.byte, &m, OPAL_BYTE))) { - return ret; - } - break; - case OPAL_STRING: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.string, &m, OPAL_STRING))) { - return ret; - } - break; - case OPAL_SIZE: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.size, &m, OPAL_SIZE))) { - return ret; - } - break; - case OPAL_PID: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.pid, &m, OPAL_PID))) { - return ret; - } - break; - case OPAL_INT: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.integer, &m, OPAL_INT))) { - return ret; - } - break; - case OPAL_INT8: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.int8, &m, OPAL_INT8))) { - return ret; - } - break; - case OPAL_INT16: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.int16, &m, OPAL_INT16))) { - return ret; - } - break; - case OPAL_INT32: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.int32, &m, OPAL_INT32))) { - return ret; - } - break; - case OPAL_INT64: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.int64, &m, OPAL_INT64))) { - return ret; - } - break; - case OPAL_UINT: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint, &m, OPAL_UINT))) { - return ret; - } - break; - case OPAL_UINT8: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint8, &m, OPAL_UINT8))) { - return ret; - } - break; - case OPAL_UINT16: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint16, &m, OPAL_UINT16))) { - return ret; - } - break; - case OPAL_UINT32: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint32, &m, OPAL_UINT32))) { - return ret; - } - break; - case OPAL_UINT64: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint64, &m, OPAL_UINT64))) { - return ret; - } - break; - case OPAL_BYTE_OBJECT: - /* cannot use byte object unpack as it allocates memory, so unpack object size in bytes */ - if (OPAL_SUCCESS != (ret = opal_dss_unpack_int32(buffer, &(ptr[i]->data.bo.size), &m, OPAL_INT32))) { - return ret; - } - if (0 < ptr[i]->data.bo.size) { - ptr[i]->data.bo.bytes = (uint8_t*)malloc(ptr[i]->data.bo.size); - if (NULL == ptr[i]->data.bo.bytes) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - if (OPAL_SUCCESS != (ret = opal_dss_unpack_byte(buffer, ptr[i]->data.bo.bytes, - &(ptr[i]->data.bo.size), OPAL_BYTE))) { - return ret; - } - } else { - ptr[i]->data.bo.bytes = NULL; - } - break; - case OPAL_FLOAT: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.fval, &m, OPAL_FLOAT))) { - return ret; - } - break; - case OPAL_DOUBLE: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.dval, &m, OPAL_DOUBLE))) { - return ret; - } - break; - case OPAL_TIMEVAL: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.tv, &m, OPAL_TIMEVAL))) { - return ret; - } - break; - case OPAL_PTR: - /* just ignore these values */ - break; - case OPAL_NAME: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.name, &m, OPAL_NAME))) { - return ret; - } - break; - case OPAL_STATUS: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.status, &m, OPAL_INT))) { - return ret; - } - break; - case OPAL_ENVAR: - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.envar, &m, OPAL_ENVAR))) { - return ret; - } - break; - default: - opal_output(0, "UNPACK-OPAL-VALUE: UNSUPPORTED TYPE %d FOR KEY %s", (int)ptr[i]->type, ptr[i]->key); - return OPAL_ERROR; - } - } - - return OPAL_SUCCESS; -} - -/* - * OPAL_BUFFER - */ -int opal_dss_unpack_buffer_contents(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - opal_buffer_t **ptr; - int32_t i, n, m; - int ret; - size_t nbytes; - - ptr = (opal_buffer_t **) dest; - n = *num_vals; - - for (i = 0; i < n; ++i) { - /* allocate the new object */ - ptr[i] = OBJ_NEW(opal_buffer_t); - if (NULL == ptr[i]) { - return OPAL_ERR_OUT_OF_RESOURCE; - } - /* unpack the number of bytes */ - m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_sizet(buffer, &nbytes, &m, OPAL_SIZE))) { - return ret; - } - m = nbytes; - /* setup the buffer's data region */ - if (0 < nbytes) { - ptr[i]->base_ptr = (char*)malloc(nbytes); - /* unpack the bytes */ - if (OPAL_SUCCESS != (ret = opal_dss_unpack_byte(buffer, ptr[i]->base_ptr, &m, OPAL_BYTE))) { - return ret; - } - } - ptr[i]->pack_ptr = ptr[i]->base_ptr + m; - ptr[i]->unpack_ptr = ptr[i]->base_ptr; - ptr[i]->bytes_allocated = nbytes; - ptr[i]->bytes_used = m; - } - return OPAL_SUCCESS; -} - -/* - * NAME - */ -int opal_dss_unpack_name(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int rc; - int32_t i, num; - opal_process_name_t* proc; - opal_jobid_t *jobid; - opal_vpid_t *vpid; - - num = *num_vals; - - /* allocate space for all the jobids in a contiguous array */ - jobid = (opal_jobid_t*)malloc(num * sizeof(opal_jobid_t)); - if (NULL == jobid) { - OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE); - *num_vals = 0; - return OPAL_ERR_OUT_OF_RESOURCE; - } - /* now unpack them in one shot */ - if (OPAL_SUCCESS != (rc = - opal_dss_unpack_jobid(buffer, jobid, num_vals, OPAL_JOBID))) { - OPAL_ERROR_LOG(rc); - *num_vals = 0; - free(jobid); - return rc; - } - - /* collect all the vpids in a contiguous array */ - vpid = (opal_vpid_t*)malloc(num * sizeof(opal_vpid_t)); - if (NULL == vpid) { - OPAL_ERROR_LOG(OPAL_ERR_OUT_OF_RESOURCE); - *num_vals = 0; - free(jobid); - return OPAL_ERR_OUT_OF_RESOURCE; - } - /* now unpack them in one shot */ - if (OPAL_SUCCESS != (rc = - opal_dss_unpack_vpid(buffer, vpid, num_vals, OPAL_VPID))) { - OPAL_ERROR_LOG(rc); - *num_vals = 0; - free(vpid); - free(jobid); - return rc; - } - - /* build the names from the jobid/vpid arrays */ - proc = (opal_process_name_t*)dest; - for (i=0; i < num; i++) { - proc->jobid = jobid[i]; - proc->vpid = vpid[i]; - proc++; - } - - /* cleanup */ - free(vpid); - free(jobid); - - return OPAL_SUCCESS; -} - -/* - * JOBID - */ -int opal_dss_unpack_jobid(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int ret; - - /* Turn around and unpack the real type */ - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, dest, num_vals, OPAL_JOBID_T))) { - OPAL_ERROR_LOG(ret); - } - - return ret; -} - -/* - * VPID - */ -int opal_dss_unpack_vpid(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int ret; - - /* Turn around and unpack the real type */ - if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, dest, num_vals, OPAL_VPID_T))) { - OPAL_ERROR_LOG(ret); - } - - return ret; -} - -/* - * STATUS - */ -int opal_dss_unpack_status(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - int ret; - - /* Turn around and unpack the real type */ - ret = opal_dss_unpack_buffer(buffer, dest, num_vals, OPAL_INT); - if (OPAL_SUCCESS != ret) { - OPAL_ERROR_LOG(ret); - } - - return ret; -} - - -int opal_dss_unpack_envar(opal_buffer_t *buffer, void *dest, - int32_t *num_vals, opal_data_type_t type) -{ - opal_envar_t *ptr; - int32_t i, n, m; - int ret; - - ptr = (opal_envar_t *) dest; - n = *num_vals; - - for (i = 0; i < n; ++i) { - m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_string(buffer, &ptr[i].envar, &m, OPAL_STRING))) { - OPAL_ERROR_LOG(ret); - return ret; - } - m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_string(buffer, &ptr[i].value, &m, OPAL_STRING))) { - OPAL_ERROR_LOG(ret); - return ret; - } - m=1; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_byte(buffer, &ptr[i].separator, &m, OPAL_BYTE))) { - OPAL_ERROR_LOG(ret); - return ret; - } - } - - return OPAL_SUCCESS; -} diff --git a/opal/mca/btl/sm/btl_sm_module.c b/opal/mca/btl/sm/btl_sm_module.c index 7b9250305d7..71499de9336 100644 --- a/opal/mca/btl/sm/btl_sm_module.c +++ b/opal/mca/btl/sm/btl_sm_module.c @@ -20,6 +20,7 @@ * Copyright (c) 2018-2019 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2020 Google, LLC. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -332,7 +333,6 @@ static int sm_add_procs (struct mca_btl_base_module_t* btl, struct mca_btl_base_endpoint_t **peers, opal_bitmap_t *reachability) { - mca_btl_sm_component_t *component = &mca_btl_sm_component; mca_btl_sm_t *sm_btl = (mca_btl_sm_t *) btl; const opal_proc_t *my_proc; int rc = OPAL_SUCCESS; diff --git a/opal/mca/btl/sm/btl_sm_xpmem.c b/opal/mca/btl/sm/btl_sm_xpmem.c index 688a01a1c96..805f5a1d639 100644 --- a/opal/mca/btl/sm/btl_sm_xpmem.c +++ b/opal/mca/btl/sm/btl_sm_xpmem.c @@ -6,6 +6,7 @@ * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2020 Google, LLC. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -123,7 +124,7 @@ void sm_return_registration (mca_rcache_base_registration_t *reg, struct mca_btl ref_count = opal_atomic_add_fetch_32 (®->ref_count, -1); if (OPAL_UNLIKELY(0 == ref_count && !(reg->flags & MCA_RCACHE_FLAGS_PERSIST))) { -#if OPAL_DEBUG +#if OPAL_ENABLE_DEBUG int ret = mca_rcache_base_vma_delete (vma_module, reg); assert (OPAL_SUCCESS == ret); #else diff --git a/opal/mca/btl/ugni/btl_ugni.h b/opal/mca/btl/ugni/btl_ugni.h index bdf7524c015..eaf5c4e5e24 100644 --- a/opal/mca/btl/ugni/btl_ugni.h +++ b/opal/mca/btl/ugni/btl_ugni.h @@ -5,6 +5,7 @@ * Copyright (c) 2011 UT-Battelle, LLC. All rights reserved. * Copyright (c) 2014 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -34,6 +35,8 @@ #include "opal/mca/btl/base/btl_base_error.h" #include "opal/class/opal_hash_table.h" #include "opal/class/opal_free_list.h" +#include "opal/class/opal_pointer_array.h" +#include "opal/mca/pmix/pmix-internal.h" #include #include diff --git a/opal/mca/btl/ugni/btl_ugni_add_procs.c b/opal/mca/btl/ugni/btl_ugni_add_procs.c index 3fcb88db622..664271c17a2 100644 --- a/opal/mca/btl/ugni/btl_ugni_add_procs.c +++ b/opal/mca/btl/ugni/btl_ugni_add_procs.c @@ -4,6 +4,7 @@ * reserved. * Copyright (c) 2011 UT-Battelle, LLC. All rights reserved. * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -310,7 +311,7 @@ mca_btl_ugni_setup_mpools (mca_btl_ugni_module_t *ugni_module) /* determine how many procs are in the job (might want to check universe size here) */ u32 = &nprocs; OPAL_MODEX_RECV_VALUE(rc, PMIX_UNIV_SIZE, &OPAL_PROC_MY_NAME, - &u32, OPAL_UINT32); + &u32, PMIX_UINT32); if (OPAL_SUCCESS != rc) { /* take a wild conservative guess */ nprocs = 512; diff --git a/opal/mca/btl/ugni/btl_ugni_atomic.c b/opal/mca/btl/ugni/btl_ugni_atomic.c index 759dd49ba57..a4396837e2c 100644 --- a/opal/mca/btl/ugni/btl_ugni_atomic.c +++ b/opal/mca/btl/ugni/btl_ugni_atomic.c @@ -5,6 +5,7 @@ * Copyright (c) 2019 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2019 Google, LLC. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,7 +16,7 @@ #include "btl_ugni_rdma.h" static gni_fma_cmd_type_t amo_cmds[][MCA_BTL_ATOMIC_LAST] = { - [OPAL_INT32] = { + [PMIX_INT32] = { [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_IADD_S, [MCA_BTL_ATOMIC_LAND] = GNI_FMA_ATOMIC2_AND_S, [MCA_BTL_ATOMIC_LOR] = GNI_FMA_ATOMIC2_OR_S, @@ -24,7 +25,7 @@ static gni_fma_cmd_type_t amo_cmds[][MCA_BTL_ATOMIC_LAST] = { [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_IMIN_S, [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_IMAX_S, }, - [OPAL_INT64] = { + [PMIX_INT64] = { [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC_ADD, [MCA_BTL_ATOMIC_AND] = GNI_FMA_ATOMIC_AND, [MCA_BTL_ATOMIC_OR] = GNI_FMA_ATOMIC_OR, @@ -33,12 +34,12 @@ static gni_fma_cmd_type_t amo_cmds[][MCA_BTL_ATOMIC_LAST] = { [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_IMIN, [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_IMAX, }, - [OPAL_FLOAT] = { + [PMIX_FLOAT] = { [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FPADD_S, [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FPMIN_S, [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FPMAX_S, }, - [OPAL_DOUBLE] = { + [PMIX_DOUBLE] = { [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FPADD, [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FPMIN, [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FPMAX, @@ -46,7 +47,7 @@ static gni_fma_cmd_type_t amo_cmds[][MCA_BTL_ATOMIC_LAST] = { }; static gni_fma_cmd_type_t famo_cmds[][MCA_BTL_ATOMIC_LAST] = { - [OPAL_INT32] = { + [PMIX_INT32] = { [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FIADD_S, [MCA_BTL_ATOMIC_LAND] = GNI_FMA_ATOMIC2_FAND_S, [MCA_BTL_ATOMIC_LOR] = GNI_FMA_ATOMIC2_FOR_S, @@ -55,7 +56,7 @@ static gni_fma_cmd_type_t famo_cmds[][MCA_BTL_ATOMIC_LAST] = { [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FIMIN_S, [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FIMAX_S, }, - [OPAL_INT64] = { + [PMIX_INT64] = { [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC_FADD, [MCA_BTL_ATOMIC_AND] = GNI_FMA_ATOMIC_FAND, [MCA_BTL_ATOMIC_OR] = GNI_FMA_ATOMIC_FOR, @@ -64,12 +65,12 @@ static gni_fma_cmd_type_t famo_cmds[][MCA_BTL_ATOMIC_LAST] = { [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FIMIN, [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FIMAX, }, - [OPAL_FLOAT] = { + [PMIX_FLOAT] = { [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FFPADD_S, [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FFPMIN_S, [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FFPMAX_S, }, - [OPAL_DOUBLE] = { + [PMIX_DOUBLE] = { [MCA_BTL_ATOMIC_ADD] = GNI_FMA_ATOMIC2_FFPADD, [MCA_BTL_ATOMIC_MIN] = GNI_FMA_ATOMIC2_FFPMIN, [MCA_BTL_ATOMIC_MAX] = GNI_FMA_ATOMIC2_FFPMAX, @@ -88,9 +89,9 @@ int mca_btl_ugni_aop (struct mca_btl_base_module_t *btl, struct mca_btl_base_end size = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? 4 : 8; if (MCA_BTL_ATOMIC_FLAG_FLOAT & flags) { - type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? OPAL_FLOAT : OPAL_DOUBLE; + type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? PMIX_FLOAT : PMIX_DOUBLE; } else { - type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? OPAL_INT32 : OPAL_INT64; + type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? PMIX_INT32 : PMIX_INT64; } gni_op = amo_cmds[type][op]; @@ -119,9 +120,9 @@ int mca_btl_ugni_afop (struct mca_btl_base_module_t *btl, struct mca_btl_base_en size = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? 4 : 8; if (MCA_BTL_ATOMIC_FLAG_FLOAT & flags) { - type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? OPAL_FLOAT : OPAL_DOUBLE; + type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? PMIX_FLOAT : PMIX_DOUBLE; } else { - type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? OPAL_INT32 : OPAL_INT64; + type = (MCA_BTL_ATOMIC_FLAG_32BIT & flags) ? PMIX_INT32 : PMIX_INT64; } gni_op = famo_cmds[type][op]; diff --git a/opal/mca/btl/ugni/btl_ugni_init.c b/opal/mca/btl/ugni/btl_ugni_init.c index c7c46248a35..e29d3da2510 100644 --- a/opal/mca/btl/ugni/btl_ugni_init.c +++ b/opal/mca/btl/ugni/btl_ugni_init.c @@ -6,6 +6,7 @@ * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * Copyright (c) 2014 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -19,7 +20,6 @@ #include "btl_ugni_frag.h" #include "opal/class/opal_list.h" -#include "opal/dss/dss.h" #include "opal/mca/pmix/pmix-internal.h" #include "opal/util/bit_ops.h" #include "opal/mca/hwloc/base/base.h" diff --git a/opal/mca/hwloc/base/base.h b/opal/mca/hwloc/base/base.h index ea725e615a6..80fa9ab356a 100644 --- a/opal/mca/hwloc/base/base.h +++ b/opal/mca/hwloc/base/base.h @@ -3,6 +3,7 @@ * Copyright (c) 2013-2020 Intel, Inc. All rights reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,8 +16,6 @@ #include "opal_config.h" -#include "opal/dss/dss_types.h" - #include "opal/mca/hwloc/hwloc-internal.h" #if HWLOC_API_VERSION < 0x20000 diff --git a/opal/mca/hwloc/base/hwloc_base_frame.c b/opal/mca/hwloc/base/hwloc_base_frame.c index 39ececdb64d..ee69bc6306e 100644 --- a/opal/mca/hwloc/base/hwloc_base_frame.c +++ b/opal/mca/hwloc/base/hwloc_base_frame.c @@ -4,6 +4,7 @@ * Copyright (c) 2016-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2019 IBM Corporation. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,7 +16,6 @@ #include "opal_config.h" #include "opal/constants.h" -#include "opal/dss/dss.h" #include "opal/util/argv.h" #include "opal/util/output.h" #include "opal/util/show_help.h" diff --git a/opal/mca/pmix/base/pmix_base_fns.c b/opal/mca/pmix/base/pmix_base_fns.c index b74a88669ad..13bfc092b60 100644 --- a/opal/mca/pmix/base/pmix_base_fns.c +++ b/opal/mca/pmix/base/pmix_base_fns.c @@ -443,408 +443,6 @@ int opal_pmix_convert_pstate(pmix_proc_state_t state) } } -void opal_pmix_value_load(pmix_value_t *v, - opal_value_t *kv) -{ - opal_list_t *list; - opal_value_t *val; - pmix_info_t *info; - size_t n; - - switch(kv->type) { - case OPAL_UNDEF: - v->type = PMIX_UNDEF; - break; - case OPAL_BOOL: - v->type = PMIX_BOOL; - memcpy(&(v->data.flag), &kv->data.flag, 1); - break; - case OPAL_BYTE: - v->type = PMIX_BYTE; - memcpy(&(v->data.byte), &kv->data.byte, 1); - break; - case OPAL_STRING: - v->type = PMIX_STRING; - if (NULL != kv->data.string) { - v->data.string = strdup(kv->data.string); - } else { - v->data.string = NULL; - } - break; - case OPAL_SIZE: - v->type = PMIX_SIZE; - memcpy(&(v->data.size), &kv->data.size, sizeof(size_t)); - break; - case OPAL_PID: - v->type = PMIX_PID; - memcpy(&(v->data.pid), &kv->data.pid, sizeof(pid_t)); - break; - case OPAL_INT: - v->type = PMIX_INT; - memcpy(&(v->data.integer), &kv->data.integer, sizeof(int)); - break; - case OPAL_INT8: - v->type = PMIX_INT8; - memcpy(&(v->data.int8), &kv->data.int8, 1); - break; - case OPAL_INT16: - v->type = PMIX_INT16; - memcpy(&(v->data.int16), &kv->data.int16, 2); - break; - case OPAL_INT32: - v->type = PMIX_INT32; - memcpy(&(v->data.int32), &kv->data.int32, 4); - break; - case OPAL_INT64: - v->type = PMIX_INT64; - memcpy(&(v->data.int64), &kv->data.int64, 8); - break; - case OPAL_UINT: - v->type = PMIX_UINT; - memcpy(&(v->data.uint), &kv->data.uint, sizeof(int)); - break; - case OPAL_UINT8: - v->type = PMIX_UINT8; - memcpy(&(v->data.uint8), &kv->data.uint8, 1); - break; - case OPAL_UINT16: - v->type = PMIX_UINT16; - memcpy(&(v->data.uint16), &kv->data.uint16, 2); - break; - case OPAL_UINT32: - v->type = PMIX_UINT32; - memcpy(&(v->data.uint32), &kv->data.uint32, 4); - break; - case OPAL_UINT64: - v->type = PMIX_UINT64; - memcpy(&(v->data.uint64), &kv->data.uint64, 8); - break; - case OPAL_FLOAT: - v->type = PMIX_FLOAT; - memcpy(&(v->data.fval), &kv->data.fval, sizeof(float)); - break; - case OPAL_DOUBLE: - v->type = PMIX_DOUBLE; - memcpy(&(v->data.dval), &kv->data.dval, sizeof(double)); - break; - case OPAL_TIMEVAL: - v->type = PMIX_TIMEVAL; - memcpy(&(v->data.tv), &kv->data.tv, sizeof(struct timeval)); - break; - case OPAL_TIME: - v->type = PMIX_TIME; - memcpy(&(v->data.time), &kv->data.time, sizeof(time_t)); - break; - case OPAL_STATUS: - v->type = PMIX_STATUS; - v->data.status = opal_pmix_convert_rc(kv->data.status); - break; - case OPAL_JOBID: - v->type = PMIX_PROC; - /* have to stringify the jobid */ - PMIX_PROC_CREATE(v->data.proc, 1); - OPAL_PMIX_CONVERT_JOBID(v->data.proc->nspace, kv->data.name.jobid); - /* leave the rank as invalid */ - break; - case OPAL_VPID: - v->type = PMIX_PROC_RANK; - OPAL_PMIX_CONVERT_VPID(v->data.rank, kv->data.name.vpid); - break; - case OPAL_NAME: - v->type = PMIX_PROC; - /* have to stringify the jobid */ - PMIX_PROC_CREATE(v->data.proc, 1); - OPAL_PMIX_CONVERT_JOBID(v->data.proc->nspace, kv->data.name.jobid); - OPAL_PMIX_CONVERT_VPID(v->data.proc->rank, kv->data.name.vpid); - break; - case OPAL_BYTE_OBJECT: - v->type = PMIX_BYTE_OBJECT; - if (NULL != kv->data.bo.bytes) { - v->data.bo.bytes = (char*)malloc(kv->data.bo.size); - memcpy(v->data.bo.bytes, kv->data.bo.bytes, kv->data.bo.size); - v->data.bo.size = (size_t)kv->data.bo.size; - } else { - v->data.bo.bytes = NULL; - v->data.bo.size = 0; - } - break; - case OPAL_PERSIST: - v->type = PMIX_PERSIST; - v->data.persist = (pmix_persistence_t)kv->data.uint8; - break; - case OPAL_SCOPE: - v->type = PMIX_SCOPE; - v->data.scope = (pmix_scope_t)kv->data.uint8; - break; - case OPAL_DATA_RANGE: - v->type = PMIX_DATA_RANGE; - v->data.range = (pmix_data_range_t)kv->data.uint8; - break; - case OPAL_PROC_STATE: - v->type = PMIX_PROC_STATE; - /* the OPAL layer doesn't have any concept of proc state, - * so the ORTE layer is responsible for converting it */ - memcpy(&v->data.state, &kv->data.uint8, sizeof(uint8_t)); - break; - case OPAL_PTR: - v->type = PMIX_POINTER; - v->data.ptr = kv->data.ptr; - break; - case OPAL_LIST: - list = (opal_list_t*)kv->data.ptr; - v->type = PMIX_DATA_ARRAY; - v->data.darray = (pmix_data_array_t*)malloc(sizeof(pmix_data_array_t)); - v->data.darray->type = PMIX_INFO; - v->data.darray->size = (NULL == list)?0:opal_list_get_size(list); - if (0 < v->data.darray->size) { - PMIX_INFO_CREATE(info, v->data.darray->size); - v->data.darray->array = info; - n=0; - OPAL_LIST_FOREACH(val, list, opal_value_t) { - if (NULL != val->key) { - (void)strncpy(info[n].key, val->key, PMIX_MAX_KEYLEN); - } - opal_pmix_value_load(&info[n].value, val); - ++n; - } - } else { - v->data.darray->array = NULL; - } - break; - case OPAL_PROC_INFO: - v->type = PMIX_PROC_INFO; - PMIX_PROC_INFO_CREATE(v->data.pinfo, 1); - OPAL_PMIX_CONVERT_JOBID(v->data.pinfo->proc.nspace, kv->data.pinfo.name.jobid); - OPAL_PMIX_CONVERT_VPID(v->data.pinfo->proc.rank, kv->data.pinfo.name.vpid); - if (NULL != kv->data.pinfo.hostname) { - v->data.pinfo->hostname = strdup(kv->data.pinfo.hostname); - } - if (NULL != kv->data.pinfo.executable_name) { - v->data.pinfo->executable_name = strdup(kv->data.pinfo.executable_name); - } - v->data.pinfo->pid = kv->data.pinfo.pid; - v->data.pinfo->exit_code = kv->data.pinfo.exit_code; - v->data.pinfo->state = opal_pmix_convert_state(kv->data.pinfo.state); - break; -#if PMIX_NUMERIC_VERSION >= 0x00030000 - case OPAL_ENVAR: - v->type = PMIX_ENVAR; - PMIX_ENVAR_CONSTRUCT(&v->data.envar); - if (NULL != kv->data.envar.envar) { - v->data.envar.envar = strdup(kv->data.envar.envar); - } - if (NULL != kv->data.envar.value) { - v->data.envar.value = strdup(kv->data.envar.value); - } - v->data.envar.separator = kv->data.envar.separator; - break; -#endif - default: - /* silence warnings */ - break; - } -} - -int opal_pmix_value_unload(opal_value_t *kv, - const pmix_value_t *v) -{ - int rc=OPAL_SUCCESS; - opal_list_t *lt; - opal_value_t *ival; - size_t n; - - switch(v->type) { - case PMIX_UNDEF: - kv->type = OPAL_UNDEF; - break; - case PMIX_BOOL: - kv->type = OPAL_BOOL; - memcpy(&kv->data.flag, &(v->data.flag), 1); - break; - case PMIX_BYTE: - kv->type = OPAL_BYTE; - memcpy(&kv->data.byte, &(v->data.byte), 1); - break; - case PMIX_STRING: - kv->type = OPAL_STRING; - if (NULL != v->data.string) { - kv->data.string = strdup(v->data.string); - } - break; - case PMIX_SIZE: - kv->type = OPAL_SIZE; - memcpy(&kv->data.size, &(v->data.size), sizeof(size_t)); - break; - case PMIX_PID: - kv->type = OPAL_PID; - memcpy(&kv->data.pid, &(v->data.pid), sizeof(pid_t)); - break; - case PMIX_INT: - kv->type = OPAL_INT; - memcpy(&kv->data.integer, &(v->data.integer), sizeof(int)); - break; - case PMIX_INT8: - kv->type = OPAL_INT8; - memcpy(&kv->data.int8, &(v->data.int8), 1); - break; - case PMIX_INT16: - kv->type = OPAL_INT16; - memcpy(&kv->data.int16, &(v->data.int16), 2); - break; - case PMIX_INT32: - kv->type = OPAL_INT32; - memcpy(&kv->data.int32, &(v->data.int32), 4); - break; - case PMIX_INT64: - kv->type = OPAL_INT64; - memcpy(&kv->data.int64, &(v->data.int64), 8); - break; - case PMIX_UINT: - kv->type = OPAL_UINT; - memcpy(&kv->data.uint, &(v->data.uint), sizeof(int)); - break; - case PMIX_UINT8: - kv->type = OPAL_UINT8; - memcpy(&kv->data.uint8, &(v->data.uint8), 1); - break; - case PMIX_UINT16: - kv->type = OPAL_UINT16; - memcpy(&kv->data.uint16, &(v->data.uint16), 2); - break; - case PMIX_UINT32: - kv->type = OPAL_UINT32; - memcpy(&kv->data.uint32, &(v->data.uint32), 4); - break; - case PMIX_UINT64: - kv->type = OPAL_UINT64; - memcpy(&kv->data.uint64, &(v->data.uint64), 8); - break; - case PMIX_FLOAT: - kv->type = OPAL_FLOAT; - memcpy(&kv->data.fval, &(v->data.fval), sizeof(float)); - break; - case PMIX_DOUBLE: - kv->type = OPAL_DOUBLE; - memcpy(&kv->data.dval, &(v->data.dval), sizeof(double)); - break; - case PMIX_TIMEVAL: - kv->type = OPAL_TIMEVAL; - memcpy(&kv->data.tv, &(v->data.tv), sizeof(struct timeval)); - break; - case PMIX_TIME: - kv->type = OPAL_TIME; - memcpy(&kv->data.time, &(v->data.time), sizeof(time_t)); - break; - case PMIX_STATUS: - kv->type = OPAL_STATUS; - kv->data.status = opal_pmix_convert_status(v->data.status); - break; - case PMIX_PROC_RANK: - kv->type = OPAL_VPID; - OPAL_PMIX_CONVERT_RANK(kv->data.name.vpid, v->data.rank); - break; - case PMIX_PROC: - kv->type = OPAL_NAME; - OPAL_PMIX_CONVERT_NSPACE(rc, &kv->data.name.jobid, v->data.proc->nspace); - OPAL_PMIX_CONVERT_RANK(kv->data.name.vpid, v->data.proc->rank); - break; - case PMIX_BYTE_OBJECT: - kv->type = OPAL_BYTE_OBJECT; - if (NULL != v->data.bo.bytes && 0 < v->data.bo.size) { - kv->data.bo.bytes = (uint8_t*)malloc(v->data.bo.size); - memcpy(kv->data.bo.bytes, v->data.bo.bytes, v->data.bo.size); - kv->data.bo.size = (int)v->data.bo.size; - } else { - kv->data.bo.bytes = NULL; - kv->data.bo.size = 0; - } - break; - case PMIX_PERSIST: - kv->type = OPAL_PERSIST; - kv->data.uint8 = v->data.persist; - break; - case PMIX_SCOPE: - kv->type = OPAL_SCOPE; - kv->data.uint8 = v->data.scope; - break; - case PMIX_DATA_RANGE: - kv->type = OPAL_DATA_RANGE; - kv->data.uint8 = v->data.range; - break; - case PMIX_PROC_STATE: - kv->type = OPAL_PROC_STATE; - kv->data.integer = opal_pmix_convert_pstate(v->data.state); - break; - case PMIX_POINTER: - kv->type = OPAL_PTR; - kv->data.ptr = v->data.ptr; - break; - case PMIX_DATA_ARRAY: - if (NULL == v->data.darray || NULL == v->data.darray->array) { - kv->data.ptr = NULL; - break; - } - lt = OBJ_NEW(opal_list_t); - kv->type = OPAL_PTR; - kv->data.ptr = (void*)lt; - for (n=0; n < v->data.darray->size; n++) { - ival = OBJ_NEW(opal_value_t); - opal_list_append(lt, &ival->super); - /* handle the various types */ - if (PMIX_INFO == v->data.darray->type) { - pmix_info_t *iptr = (pmix_info_t*)v->data.darray->array; - if (0 < strlen(iptr[n].key)) { - ival->key = strdup(iptr[n].key); - } - rc = opal_pmix_value_unload(ival, &iptr[n].value); - if (OPAL_SUCCESS != rc) { - OPAL_LIST_RELEASE(lt); - kv->type = OPAL_UNDEF; - kv->data.ptr = NULL; - break; - } - } - } - break; - case PMIX_PROC_INFO: - kv->type = OPAL_PROC_INFO; - if (NULL == v->data.pinfo) { - rc = OPAL_ERR_BAD_PARAM; - break; - } - OPAL_PMIX_CONVERT_NSPACE(rc, &kv->data.pinfo.name.jobid, v->data.pinfo->proc.nspace); - OPAL_PMIX_CONVERT_RANK(kv->data.pinfo.name.vpid, v->data.pinfo->proc.rank); - if (NULL != v->data.pinfo->hostname) { - kv->data.pinfo.hostname = strdup(v->data.pinfo->hostname); - } - if (NULL != v->data.pinfo->executable_name) { - kv->data.pinfo.executable_name = strdup(v->data.pinfo->executable_name); - } - kv->data.pinfo.pid = v->data.pinfo->pid; - kv->data.pinfo.exit_code = v->data.pinfo->exit_code; - kv->data.pinfo.state = opal_pmix_convert_pstate(v->data.pinfo->state); - break; -#if PMIX_NUMERIC_VERSION >= 0x00030000 - case PMIX_ENVAR: - kv->type = OPAL_ENVAR; - OBJ_CONSTRUCT(&kv->data.envar, opal_envar_t); - if (NULL != v->data.envar.envar) { - kv->data.envar.envar = strdup(v->data.envar.envar); - } - if (NULL != v->data.envar.value) { - kv->data.envar.value = strdup(v->data.envar.value); - } - kv->data.envar.separator = v->data.envar.separator; - break; -#endif - default: - /* silence warnings */ - rc = OPAL_ERROR; - break; - } - return rc; -} - #if PMIX_NUMERIC_VERSION >= 0x00030000 static void cleanup_cbfunc(pmix_status_t status, diff --git a/opal/mca/pmix/pmix-internal.h b/opal/mca/pmix/pmix-internal.h index 6a882319f54..23aa731ec78 100644 --- a/opal/mca/pmix/pmix-internal.h +++ b/opal/mca/pmix/pmix-internal.h @@ -9,6 +9,7 @@ * reserved. * Copyright (c) 2020 Amazon.com, Inc. or its affiliates. * All Rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -37,7 +38,6 @@ #include "opal/mca/mca.h" #include "opal/util/event.h" #include "opal/mca/threads/threads.h" -#include "opal/dss/dss.h" #include "opal/util/error.h" #include "opal/hash_string.h" @@ -46,6 +46,18 @@ BEGIN_C_DECLS +typedef uint32_t opal_jobid_t; +typedef pmix_rank_t opal_vpid_t; +typedef struct { + opal_jobid_t jobid; + opal_vpid_t vpid; +} opal_process_name_t; + +#define OPAL_SIZEOF_PROCESS_NAME_T 8 +#define OPAL_EQUAL 0 +#define OPAL_VALUE1_GREATER 1 +#define OPAL_VALUE2_GREATER -1 + /* provide access to the framework verbose output without * exposing the entire base */ OPAL_DECLSPEC extern bool opal_pmix_collect_all_data; @@ -694,12 +706,6 @@ OPAL_DECLSPEC void opal_pmix_finalize_nspace_tracker(void); } \ } while(0) -OPAL_DECLSPEC void opal_pmix_value_load(pmix_value_t *v, - opal_value_t *kv); - -OPAL_DECLSPEC int opal_pmix_value_unload(opal_value_t *kv, - const pmix_value_t *v); - OPAL_DECLSPEC int opal_pmix_register_cleanup(char *path, bool directory, bool ignore, diff --git a/opal/runtime/opal_info_support.c b/opal/runtime/opal_info_support.c index 0d876f322f2..c4bd5eee30e 100644 --- a/opal/runtime/opal_info_support.c +++ b/opal/runtime/opal_info_support.c @@ -17,6 +17,7 @@ * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -45,7 +46,6 @@ #include "opal/util/show_help.h" #include "opal/util/printf.h" #include "opal/runtime/opal.h" -#include "opal/dss/dss.h" #include "opal/mca/base/mca_base_pvar.h" #include "opal/include/opal/frameworks.h" diff --git a/opal/runtime/opal_init.c b/opal/runtime/opal_init.c index 55914023b37..036b75a09d9 100644 --- a/opal/runtime/opal_init.c +++ b/opal/runtime/opal_init.c @@ -25,6 +25,7 @@ * Copyright (c) 2018-2019 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -61,7 +62,6 @@ #include "opal/mca/timer/base/base.h" #include "opal/mca/memchecker/base/base.h" #include "opal/mca/if/base/base.h" -#include "opal/dss/dss.h" #include "opal/mca/shmem/base/base.h" #include "opal/mca/threads/threads.h" #include "opal/mca/threads/tsd.h" @@ -593,13 +593,6 @@ opal_init_util(int* pargc, char*** pargv) OPAL_TIMING_ENV_NEXT(otmng, "opal_datatype_init"); - /* Initialize the data storage service. */ - if (OPAL_SUCCESS != (ret = opal_dss_open())) { - return opal_init_error ("opal_dss_open", ret); - } - - OPAL_TIMING_ENV_NEXT(otmng, "opal_dss_open"); - /* initialize the mca */ if (OPAL_SUCCESS != (ret = mca_base_open())) { return opal_init_error ("mca_base_open", ret); diff --git a/opal/runtime/opal_params.c b/opal/runtime/opal_params.c index d932c615d1f..38766e660c7 100644 --- a/opal/runtime/opal_params.c +++ b/opal/runtime/opal_params.c @@ -23,6 +23,7 @@ * All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -44,7 +45,6 @@ #include "opal/mca/shmem/base/base.h" #include "opal/mca/base/mca_base_var.h" #include "opal/runtime/opal_params.h" -#include "opal/dss/dss.h" #include "opal/util/opal_environ.h" #include "opal/util/show_help.h" #include "opal/util/timings.h" @@ -381,12 +381,6 @@ int opal_register_params(void) return ret; } - /* dss has parameters */ - ret = opal_dss_register_vars (); - if (OPAL_SUCCESS != ret) { - return ret; - } - ret = opal_event_register_params(); if (OPAL_SUCCESS != ret) { return ret; diff --git a/opal/util/proc.h b/opal/util/proc.h index 512f23b6bb8..9d871edded1 100644 --- a/opal/util/proc.h +++ b/opal/util/proc.h @@ -9,6 +9,7 @@ * Copyright (c) 2017 Cisco Systems, Inc. All rights reserved * Copyright (c) 2020 Amazon.com, Inc. or its affiliates. All Rights * reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,7 +25,6 @@ #include "opal/mca/hwloc/hwloc-internal.h" #include "opal/mca/pmix/pmix-internal.h" #include "opal/types.h" -#include "opal/dss/dss_types.h" #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT #include diff --git a/oshmem/mca/memheap/base/memheap_base_mkey.c b/oshmem/mca/memheap/base/memheap_base_mkey.c index ad8fc95bd2f..db682498f73 100644 --- a/oshmem/mca/memheap/base/memheap_base_mkey.c +++ b/oshmem/mca/memheap/base/memheap_base_mkey.c @@ -7,6 +7,7 @@ * Copyright (c) 2015 Intel, Inc. All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -17,7 +18,6 @@ #include "oshmem_config.h" #include "oshmem/util/oshmem_util.h" -#include "opal/dss/dss.h" #include "oshmem/proc/proc.h" #include "oshmem/util/oshmem_util.h" @@ -28,6 +28,7 @@ #include "oshmem/mca/memheap/base/base.h" #include "oshmem/mca/spml/spml.h" #include "opal/util/timings.h" +#include "opal/mca/pmix/pmix-internal.h" /* Turn ON/OFF debug output from build (default 0) */ #ifndef MEMHEAP_BASE_DEBUG @@ -63,7 +64,7 @@ mca_memheap_map_t* memheap_map = NULL; struct oob_comm memheap_oob = {{{0}}}; -static int send_buffer(int pe, opal_buffer_t *msg); +static int send_buffer(int pe, pmix_data_buffer_t *msg); static int oshmem_mkey_recv_cb(void); @@ -85,14 +86,14 @@ int mca_memheap_seg_cmp(const void *k, const void *v) return 0; } -static int pack_local_mkeys(opal_buffer_t *msg, int pe, int seg) +static int pack_local_mkeys(pmix_data_buffer_t *msg, int pe, int seg) { int i, n; sshmem_mkey_t *mkey; /* go over all transports and pack mkeys */ n = memheap_map->num_transports; - opal_dss.pack(msg, &n, 1, OPAL_UINT32); + PMIx_Data_pack(NULL, msg, &n, 1, PMIX_UINT32); MEMHEAP_VERBOSE(5, "found %d transports to %d", n, pe); for (i = 0; i < n; i++) { mkey = mca_memheap_base_get_mkey(mca_memheap_seg2base_va(seg), i); @@ -101,14 +102,14 @@ static int pack_local_mkeys(opal_buffer_t *msg, int pe, int seg) seg, i); return OSHMEM_ERROR; } - opal_dss.pack(msg, &i, 1, OPAL_UINT32); - opal_dss.pack(msg, &mkey->va_base, 1, OPAL_UINT64); + PMIx_Data_pack(NULL, msg, &i, 1, PMIX_UINT32); + PMIx_Data_pack(NULL, msg, &mkey->va_base, 1, PMIX_UINT64); if (0 == mkey->va_base) { - opal_dss.pack(msg, &mkey->u.key, 1, OPAL_UINT64); + PMIx_Data_pack(NULL, msg, &mkey->u.key, 1, PMIX_UINT64); } else { - opal_dss.pack(msg, &mkey->len, 1, OPAL_UINT16); + PMIx_Data_pack(NULL, msg, &mkey->len, 1, PMIX_UINT16); if (0 < mkey->len) { - opal_dss.pack(msg, mkey->u.data, mkey->len, OPAL_BYTE); + PMIx_Data_pack(NULL, msg, mkey->u.data, mkey->len, PMIX_BYTE); } } MEMHEAP_VERBOSE(5, @@ -144,7 +145,7 @@ static void memheap_attach_segment(sshmem_mkey_t *mkey, int tr_id) } -static void unpack_remote_mkeys(shmem_ctx_t ctx, opal_buffer_t *msg, int remote_pe) +static void unpack_remote_mkeys(shmem_ctx_t ctx, pmix_data_buffer_t *msg, int remote_pe) { int32_t cnt; int32_t n; @@ -154,25 +155,25 @@ static void unpack_remote_mkeys(shmem_ctx_t ctx, opal_buffer_t *msg, int remote_ proc = oshmem_proc_group_find(oshmem_group_all, remote_pe); cnt = 1; - opal_dss.unpack(msg, &n, &cnt, OPAL_UINT32); + PMIx_Data_unpack(NULL, msg, &n, &cnt, PMIX_UINT32); for (i = 0; i < n; i++) { cnt = 1; - opal_dss.unpack(msg, &tr_id, &cnt, OPAL_UINT32); + PMIx_Data_unpack(NULL, msg, &tr_id, &cnt, PMIX_UINT32); cnt = 1; - opal_dss.unpack(msg, + PMIx_Data_unpack(NULL, msg, &memheap_oob.mkeys[tr_id].va_base, &cnt, - OPAL_UINT64); + PMIX_UINT64); if (0 == memheap_oob.mkeys[tr_id].va_base) { cnt = 1; - opal_dss.unpack(msg, &memheap_oob.mkeys[tr_id].u.key, &cnt, OPAL_UINT64); + PMIx_Data_unpack(NULL, msg, &memheap_oob.mkeys[tr_id].u.key, &cnt, PMIX_UINT64); if (OPAL_PROC_ON_LOCAL_NODE(proc->super.proc_flags)) { memheap_attach_segment(&memheap_oob.mkeys[tr_id], tr_id); } } else { cnt = 1; - opal_dss.unpack(msg, &memheap_oob.mkeys[tr_id].len, &cnt, OPAL_UINT16); + PMIx_Data_unpack(NULL, msg, &memheap_oob.mkeys[tr_id].len, &cnt, PMIX_UINT16); if (0 < memheap_oob.mkeys[tr_id].len) { memheap_oob.mkeys[tr_id].u.data = malloc(memheap_oob.mkeys[tr_id].len); if (NULL == memheap_oob.mkeys[tr_id].u.data) { @@ -180,7 +181,7 @@ static void unpack_remote_mkeys(shmem_ctx_t ctx, opal_buffer_t *msg, int remote_ oshmem_shmem_abort(-1); } cnt = memheap_oob.mkeys[tr_id].len; - opal_dss.unpack(msg, memheap_oob.mkeys[tr_id].u.data, &cnt, OPAL_BYTE); + PMIx_Data_unpack(NULL, msg, memheap_oob.mkeys[tr_id].u.data, &cnt, PMIX_BYTE); } else { memheap_oob.mkeys[tr_id].u.key = MAP_SEGMENT_SHM_INVALID; } @@ -193,32 +194,32 @@ static void unpack_remote_mkeys(shmem_ctx_t ctx, opal_buffer_t *msg, int remote_ } } -static void do_recv(int source_pe, opal_buffer_t* buffer) +static void do_recv(int source_pe, pmix_data_buffer_t* buffer) { int32_t cnt = 1; int rc; - opal_buffer_t *msg; + pmix_data_buffer_t *msg; uint8_t msg_type; uint32_t seg; - MEMHEAP_VERBOSE(5, "unpacking %d of %d", cnt, OPAL_UINT8); - rc = opal_dss.unpack(buffer, &msg_type, &cnt, OPAL_UINT8); - if (OPAL_SUCCESS != rc) { - OMPI_ERROR_LOG(rc); + MEMHEAP_VERBOSE(5, "unpacking %d of %d", cnt, PMIX_UINT8); + rc = PMIx_Data_unpack(NULL, buffer, &msg_type, &cnt, PMIX_UINT8); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); goto send_fail; } switch (msg_type) { case MEMHEAP_RKEY_REQ: cnt = 1; - rc = opal_dss.unpack(buffer, &seg, &cnt, OPAL_UINT32); - if (OPAL_SUCCESS != rc) { + rc = PMIx_Data_unpack(NULL, buffer, &seg, &cnt, PMIX_UINT32); + if (PMIX_SUCCESS != rc) { MEMHEAP_ERROR("bad RKEY_REQ msg"); goto send_fail; } MEMHEAP_VERBOSE(5, "*** RKEY REQ"); - msg = OBJ_NEW(opal_buffer_t); + PMIX_DATA_BUFFER_CREATE(msg); if (!msg) { MEMHEAP_ERROR("failed to get msg buffer"); OMPI_ERROR_LOG(rc); @@ -226,7 +227,7 @@ static void do_recv(int source_pe, opal_buffer_t* buffer) } msg_type = MEMHEAP_RKEY_RESP; - opal_dss.pack(msg, &msg_type, 1, OPAL_UINT8); + PMIx_Data_pack(NULL, msg, &msg_type, 1, PMIX_UINT8); if (OSHMEM_SUCCESS != pack_local_mkeys(msg, source_pe, seg)) { OBJ_RELEASE(msg); @@ -263,14 +264,14 @@ static void do_recv(int source_pe, opal_buffer_t* buffer) } return; - send_fail: msg = OBJ_NEW(opal_buffer_t); + send_fail: PMIX_DATA_BUFFER_CREATE(msg); if (!msg) { MEMHEAP_ERROR("failed to get msg buffer"); OMPI_ERROR_LOG(rc); return; } msg_type = MEMHEAP_RKEY_RESP_FAIL; - opal_dss.pack(msg, &msg_type, 1, OPAL_UINT8); + PMIx_Data_pack(NULL, msg, &msg_type, 1, PMIX_UINT8); rc = send_buffer(source_pe, msg); if (MPI_SUCCESS != rc) { @@ -317,7 +318,7 @@ static int oshmem_mkey_recv_cb(void) int flag; int n; int rc; - opal_buffer_t *msg; + pmix_data_buffer_t *msg; int32_t size; void *tmp_buf; oob_comm_request_t *r; @@ -346,14 +347,14 @@ static int oshmem_mkey_recv_cb(void) return n; } else { memcpy(tmp_buf, (void*)&r->buf, size); - msg = OBJ_NEW(opal_buffer_t); + PMIX_DATA_BUFFER_CREATE(msg); if (NULL == msg) { MEMHEAP_ERROR("not enough memory"); OMPI_ERROR_LOG(0); free(tmp_buf); return n; } - opal_dss.load(msg, (void*)tmp_buf, size); + PMIX_DATA_BUFFER_LOAD(msg, (void*)tmp_buf, size); /* * send reply before posting the receive request again to limit the recursion size to @@ -362,7 +363,7 @@ static int oshmem_mkey_recv_cb(void) * stack size will be proportional to number of job ranks. */ do_recv(status.MPI_SOURCE, msg); - OBJ_RELEASE(msg); + PMIX_DATA_BUFFER_RELEASE(msg); } rc = PMPI_Start(&r->recv_req); @@ -442,16 +443,16 @@ void memheap_oob_destruct(void) memheap_oob.is_inited = 0; } -static int send_buffer(int pe, opal_buffer_t *msg) +static int send_buffer(int pe, pmix_data_buffer_t *msg) { void *buffer; int32_t size; int rc; - opal_dss.unload(msg, &buffer, &size); + PMIX_DATA_BUFFER_UNLOAD(msg, buffer, size); rc = PMPI_Send(buffer, size, MPI_BYTE, pe, 0, oshmem_comm_world); free(buffer); - OBJ_RELEASE(msg); + PMIX_DATA_BUFFER_RELEASE(msg); MEMHEAP_VERBOSE(5, "message sent: dst=%d, rc=%d, %d bytes!", pe, rc, size); return rc; @@ -459,7 +460,7 @@ static int send_buffer(int pe, opal_buffer_t *msg) static int memheap_oob_get_mkeys(shmem_ctx_t ctx, int pe, uint32_t seg, sshmem_mkey_t *mkeys) { - opal_buffer_t *msg; + pmix_data_buffer_t *msg; uint8_t cmd; int i; int rc; @@ -482,7 +483,7 @@ static int memheap_oob_get_mkeys(shmem_ctx_t ctx, int pe, uint32_t seg, sshmem_m memheap_oob.mkeys_rcvd = 0; memheap_oob.ctx = ctx; - msg = OBJ_NEW(opal_buffer_t); + PMIX_DATA_BUFFER_CREATE(msg); if (!msg) { OPAL_THREAD_UNLOCK(&memheap_oob.lck); MEMHEAP_ERROR("failed to get msg buffer"); @@ -490,8 +491,8 @@ static int memheap_oob_get_mkeys(shmem_ctx_t ctx, int pe, uint32_t seg, sshmem_m } cmd = MEMHEAP_RKEY_REQ; - opal_dss.pack(msg, &cmd, 1, OPAL_UINT8); - opal_dss.pack(msg, &seg, 1, OPAL_UINT32); + PMIx_Data_pack(NULL, msg, &cmd, 1, PMIX_UINT8); + PMIx_Data_pack(NULL, msg, &seg, 1, PMIX_UINT32); rc = send_buffer(pe, msg); if (MPI_SUCCESS != rc) { @@ -520,7 +521,7 @@ void mca_memheap_modex_recv_all(void) int i; int j; int nprocs, my_pe; - opal_buffer_t *msg = NULL; + pmix_data_buffer_t *msg = NULL; void *send_buffer = NULL; char *rcv_buffer = NULL; int size; @@ -566,7 +567,7 @@ void mca_memheap_modex_recv_all(void) OPAL_TIMING_ENV_NEXT(recv_all, "alloc bufs"); /* serialize our own mkeys */ - msg = OBJ_NEW(opal_buffer_t); + PMIX_DATA_BUFFER_CREATE(msg); if (NULL == msg) { MEMHEAP_ERROR("failed to get msg buffer"); rc = OSHMEM_ERR_OUT_OF_RESOURCE; @@ -583,7 +584,7 @@ void mca_memheap_modex_recv_all(void) assert(sizeof(int32_t) == sizeof(int)); /* Do allgather */ - opal_dss.unload(msg, &send_buffer, &size); + PMIX_DATA_BUFFER_UNLOAD(msg, send_buffer, size); MEMHEAP_VERBOSE(1, "local keys packed into %d bytes, %d segments", size, memheap_map->n_segments); OPAL_TIMING_ENV_NEXT(recv_all, "serialize data"); @@ -636,7 +637,7 @@ void mca_memheap_modex_recv_all(void) OPAL_TIMING_ENV_NEXT(recv_all, "Perform mkey exchange"); - opal_dss.load(msg, rcv_buffer, buffer_size); + PMIX_DATA_BUFFER_LOAD(msg, rcv_buffer, buffer_size); /* deserialize mkeys */ OPAL_THREAD_LOCK(&memheap_oob.lck); @@ -685,7 +686,7 @@ void mca_memheap_modex_recv_all(void) free(send_buffer); } if (msg) { - OBJ_RELEASE(msg); + PMIX_DATA_BUFFER_RELEASE(msg); } OPAL_TIMING_ENV_NEXT(recv_all, "Cleanup"); diff --git a/oshmem/op/op.h b/oshmem/op/op.h index 690f0f40542..7ee58f80fd4 100644 --- a/oshmem/op/op.h +++ b/oshmem/op/op.h @@ -3,6 +3,7 @@ * All rights reserved. * Copyright (c) 2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -19,7 +20,6 @@ #include "oshmem/mca/scoll/scoll.h" #include "opal/class/opal_list.h" -#include "opal/dss/dss_types.h" BEGIN_C_DECLS diff --git a/oshmem/proc/proc.c b/oshmem/proc/proc.c index da84e4d9c8b..6e3446c9abe 100644 --- a/oshmem/proc/proc.c +++ b/oshmem/proc/proc.c @@ -5,6 +5,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2016 ARM, Inc. All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -25,7 +26,6 @@ #include "opal/datatype/opal_convertor.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/proc/proc.h b/oshmem/proc/proc.h index ce137717397..0660b691231 100644 --- a/oshmem/proc/proc.h +++ b/oshmem/proc/proc.h @@ -4,6 +4,7 @@ * Copyright (c) 2016-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 Cisco Systems, Inc. All rights reserved + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -19,7 +20,6 @@ #include "opal/class/opal_list.h" #include "opal/util/proc.h" -#include "opal/dss/dss_types.h" #include "opal/mca/hwloc/hwloc-internal.h" #include "ompi/proc/proc.h" diff --git a/test/Makefile.am b/test/Makefile.am index c8ef777fb83..b3fd5f2f32c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -22,7 +22,7 @@ # # support needs to be first for dependencies -SUBDIRS = support asm class threads datatype util dss mpool +SUBDIRS = support asm class threads datatype util mpool if PROJECT_OMPI SUBDIRS += monitoring spc endif diff --git a/test/class/Makefile.am b/test/class/Makefile.am index 4dc7daf24cc..4702b11c5d1 100644 --- a/test/class/Makefile.am +++ b/test/class/Makefile.am @@ -31,7 +31,6 @@ check_PROGRAMS = \ $(REQUIRES_OMPI) opal_bitmap \ opal_hash_table \ opal_proc_table \ - opal_tree \ opal_list \ opal_value_array \ opal_pointer_array \ @@ -52,12 +51,6 @@ opal_list_LDADD = \ $(top_builddir)/test/support/libsupport.a opal_list_DEPENDENCIES = $(opal_list_LDADD) -opal_tree_SOURCES = opal_tree.c -opal_tree_LDADD = \ - $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la \ - $(top_builddir)/test/support/libsupport.a -opal_tree_DEPENDENCIES = $(opal_tree_LDADD) - opal_hash_table_SOURCES = opal_hash_table.c opal_hash_table_LDADD = \ $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la \ diff --git a/test/class/opal_tree.c b/test/class/opal_tree.c deleted file mode 100644 index 89c0293ce3c..00000000000 --- a/test/class/opal_tree.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2019 Intel, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" -#include - -#include "support.h" -#include "opal/class/opal_tree.h" -#include "opal/runtime/opal.h" -#include "opal/constants.h" - -#include -#include - -/* - * Data type used for testing - */ -typedef struct test_data { - /* tree data structure */ - opal_tree_item_t tree_element; - /* test data */ - size_t data; -} test_data_t; - -OBJ_CLASS_INSTANCE(test_data_t, - opal_tree_item_t, - NULL, NULL); - -static void check_descendants(opal_tree_item_t* item, unsigned *data, - unsigned level, int *err_order, - int *err_ancestor); -static int test_comp(opal_tree_item_t *item, void *key); -static int test_serialize(opal_tree_item_t *item, opal_buffer_t *buffer); -static int test_deserialize(opal_buffer_t *serial_data, - opal_tree_item_t **item); -static void *test_get_key(opal_tree_item_t *item); - -int main(int argc, char **argv) -{ - /* local variables */ - opal_tree_t tree, x; - opal_buffer_t *serial_tree; - size_t i, j, tree_size, size_levels, size_elements, total_elements; - int err_order, err_ancestor, rc; - unsigned key; - test_data_t *elements; - opal_tree_item_t *item, *rm_item; - - rc = opal_init_util(&argc, &argv); - test_verify_int(OPAL_SUCCESS, rc); - if (OPAL_SUCCESS != rc) { - test_finalize(); - exit(1); - } - - test_init("opal_tree_t"); - - /* initialize tree */ - - OBJ_CONSTRUCT(&tree, opal_tree_t); - opal_tree_init(&tree, test_comp, test_serialize, test_deserialize, test_get_key); - OBJ_CONSTRUCT(&x, opal_tree_t); - opal_tree_init(&x, test_comp, test_serialize, test_deserialize, test_get_key); - - /* check length of tree */ - tree_size=opal_tree_get_size(&tree); - if( 0 == tree_size ) { - test_success(); - } else { - test_failure(" opal_tree_get_size"); - } - - /* check for empty */ - if (opal_tree_is_empty(&tree)) { - test_success(); - } else { - test_failure(" opal_tree_is_empty(empty tree)"); - } - - /* create test elements */ - size_levels = 4; - size_elements=4; - total_elements = size_elements * size_levels; - elements=(test_data_t *)malloc(sizeof(test_data_t)*total_elements); - assert(elements); - for(i=0 ; i < total_elements; i++) { - OBJ_CONSTRUCT(elements + i, test_data_t); - (elements+i)->data=i; - } - - /* check get_root */ - item = opal_tree_get_root(&tree); - - - /* populate a 4 level tree (this is weighted to the left side) */ - for (i = 0; i < size_levels; i++) { - for(j=0 ; j < size_elements ; j++) { - opal_tree_add_child(item,(opal_tree_item_t *)(elements+ - (i*size_elements)+ - j)); - } - item = opal_tree_get_first_child(item); - } - - /* checking for tree size */ - tree_size=opal_tree_get_size(&tree); - if( tree_size == total_elements ) { - test_success(); - } else { - test_failure(" count off for populating 4 level tree"); - } - - /* checking for empty on non-empty tree */ - if (!opal_tree_is_empty(&tree)) { - test_success(); - } else { - test_failure(" opal_tree_is_empty(non-empty tree)"); - } - - /* check that we have correct tree ordering */ - err_order = 0; - err_ancestor = 0; - if (!opal_tree_is_empty(&tree)) { - item = opal_tree_get_root(&tree); - i = 0; - check_descendants(item, (unsigned *)&i, 0, &err_order, &err_ancestor); - } - - if (!err_order) { - test_success(); - } else { - test_failure(" order values incorrect"); - } - if (!err_ancestor) { - test_success(); - } else { - test_failure(" invalid ancestor count"); - } - - /* test matching code */ - /* check for invalid matching */ - key = 444; - item = opal_tree_find_with(opal_tree_get_root(&tree), (void*)&key); - if (NULL == item) { - test_success(); - } else { - test_failure(" failed invalid matching item test"); - } - - /* check matching, note nest tests because they rely on previous tests */ - /* check for valid matching descendants */ - key = 4; - item = opal_tree_find_with(opal_tree_get_root(&tree), (void*)&key); - if (NULL != item && ((test_data_t*)item)->data == key) { - test_success(); - /* check for valid matching siblings */ - key = 7; - item = opal_tree_find_with(item, (void*)&key); - if (NULL != item && ((test_data_t*)item)->data == key) { - test_success(); - /* check for valid matching ancestors */ - key = 2; - item = opal_tree_find_with(item, (void*)&key); - if (NULL != item && ((test_data_t*)item)->data == key) { - test_success(); - } else { - test_failure(" failed valid matching ancestors test"); - } - } else { - test_failure(" failed valid matching siblings test"); - } - } else { - test_failure(" failed valid matching descendants test"); - } - - /* check subtree removal */ - /* find the first key = 3 item and remove it */ - key = 8; - tree_size=opal_tree_get_size(&tree); - item = opal_tree_find_with(opal_tree_get_root(&tree), (void*)&key); - rm_item = opal_tree_remove_subtree(item); - if (NULL == rm_item) { - test_failure(" rm_item should not be NULL"); - } - /* validate the tree count adjusted */ - if (5 != (tree_size - opal_tree_get_size(&tree))) { - test_failure(" failed subtree removal tree size test"); - } else { - /* validate cannot find children in tree */ - key = 13; - if (NULL != - opal_tree_find_with(opal_tree_get_root(&tree), (void*)&key)) { - test_failure(" failed subtree removal item children removed test"); - } else { - /* validate cannot find the item */ - key = 8; - if (NULL != - opal_tree_find_with(opal_tree_get_root(&tree), (void*)&key)) { - test_failure(" failed subtree removal item removed test"); - } else { - test_success(); - } - } - } - - /* check serialization-deserialization */ - /* serialize tree */ - serial_tree = OBJ_NEW(opal_buffer_t); - - if (OPAL_SUCCESS == opal_tree_serialize(opal_tree_get_root(&tree), serial_tree)) { - opal_tree_t tmp_tree; - opal_buffer_t *serial2_tree; - - /* create new tree */ - OBJ_CONSTRUCT(&tmp_tree, opal_tree_t); - opal_tree_init(&tmp_tree, test_comp, test_serialize, - test_deserialize, test_get_key); - - /* deserialize tree */ - opal_tree_deserialize(serial_tree, &(tmp_tree.opal_tree_sentinel)); - /* serialize tmp tree */ - serial2_tree = OBJ_NEW(opal_buffer_t); - if (OPAL_SUCCESS == opal_tree_serialize(opal_tree_get_root(&tmp_tree), serial2_tree)) { - void *payload1, *payload2; - int32_t size1, size2; - - /* compare new with original serialization */ - serial_tree->unpack_ptr = serial_tree->base_ptr; - serial2_tree->unpack_ptr = serial2_tree->unpack_ptr; - opal_dss.unload(serial_tree, &payload1, &size1); - opal_dss.unload(serial2_tree, &payload2, &size2); - if (size1 == size2) { - if (0 == memcmp(payload1, payload2, size1)) { - test_success(); - } else { - test_failure(" failed tree deserialization data compare"); - } - } else { - test_failure(" failed tree deserialization size compare"); - } - } else { - test_failure(" failed tree second pass serialization"); - } - } else { - test_failure(" failed tree serialization"); - } - - if (NULL != elements) free(elements); - - opal_finalize_util (); - - return test_finalize(); -} - -/* - * check all the descendants from our level and below for correct data and - * level. Note this will traverse the tree in a weird fashion where you - * go across all siblings and then start searching down the last siblings - * children. As the current tests are set up if one populated more than just - * the left sided children things will probably fail. - */ -static void check_descendants(opal_tree_item_t* item, - unsigned *data, - unsigned level, - int *err_order, int *err_ancestor) -{ - test_data_t *ele; - - /* loop over all siblings and then down first child */ - while (item) { - /* check item for correctness */ - ele = (test_data_t *)item; - if (ele->data != *data) { - (*err_order)++; - } - if (item->opal_tree_num_ancestors != level) { - (*err_ancestor)++; - } - (*data)++; - check_descendants(opal_tree_get_next_sibling(item), data, level, - err_order, err_ancestor); - item = opal_tree_get_first_child(item); - level++; - } - return; -} - -static int test_comp(opal_tree_item_t *item, void *key) -{ - if (((test_data_t *)item)->data > *((unsigned *) key)) { - return(1); - } - if (((test_data_t *)item)->data < *((unsigned *) key)) { - return(-1); - } - return(0); -} - -static int test_serialize(opal_tree_item_t *item, opal_buffer_t *buffer) -{ - test_data_t *ele = (test_data_t *)item; - - return(opal_dss.pack(buffer, &ele->data, 1, OPAL_INT32)); -} - -static int test_deserialize(opal_buffer_t *serial_data, opal_tree_item_t **item) -{ - int rc = OPAL_SUCCESS, idx = 1; - test_data_t *ele; - - ele = (test_data_t *)malloc(sizeof(test_data_t)); - OBJ_CONSTRUCT(ele, test_data_t); - if (OPAL_SUCCESS == (rc = opal_dss.unpack(serial_data, &ele->data, &idx, - OPAL_INT32))) { - *item = (opal_tree_item_t*)ele; - } else { - *item = NULL; - } - return(rc); -} - -static void *test_get_key(opal_tree_item_t *item) -{ - return (void*) (((test_data_t *)item)->data); -} diff --git a/test/dss/Makefile.am b/test/dss/Makefile.am deleted file mode 100644 index 08957b50400..00000000000 --- a/test/dss/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2016 Research Organization for Information Science -# and Technology (RIST). All rights reserved. -# $COPYRIGHT$ -# -# Additional copyrights may follow -# -# $HEADER$ -# - -TESTS = dss_buffer dss_cmp dss_payload dss_print - -check_PROGRAMS = $(TESTS) $(MPI_CHECKS) - -LDFLAGS = $(OPAL_PKG_CONFIG_LDFLAGS) -LDADD = $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la diff --git a/test/dss/dss_buffer.c b/test/dss/dss_buffer.c deleted file mode 100644 index 55877c748ea..00000000000 --- a/test/dss/dss_buffer.c +++ /dev/null @@ -1,979 +0,0 @@ -/* - * 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) 2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" -#include "opal/constants.h" - - -#include -#include -#include -#ifdef HAVE_SYS_PARAM_H -#include -#endif -#include - -#include "opal/runtime/opal.h" -#include "opal/dss/dss.h" -#include "opal/util/printf.h" - -#define NUM_ITERS 100 -#define NUM_ELEMS 1024 - -static bool test1(void); /* verify different buffer inits */ -static bool test2(void); /* verify int16 */ -static bool test3(void); /* verify int */ -static bool test4(void); /* verify int32 */ -static bool test5(void); /* verify int64 */ -static bool test6(void); /* verify string */ -static bool test7(void); /* verify BOOL */ -static bool test8(void); /* verify OBJECT */ -static bool test9(void); /* verify composite (multiple types and element counts) */ -static bool test10(void); /* verify KEYVAL */ -static bool test11(void); /* verify int32_t */ -static bool test12(void); /* verify pid_t */ - -static FILE *test_out; - - -int main (int argc, char* argv[]) -{ - int ret = 0; - - opal_init(&argc, &argv); - - test_out = stderr; - - /* run the tests */ - - fprintf(test_out, "executing test1\n"); - if (test1()) { - fprintf(test_out, "Test1 succeeded\n"); - } else { - fprintf(test_out, "Test1 failed\n"); - ret = 1; - } - - fprintf(test_out, "executing test2\n"); - if (test2()) { - fprintf(test_out, "Test2 succeeded\n"); - } else { - fprintf(test_out, "Test2 failed\n"); - ret = 2; - } - - fprintf(test_out, "executing test3\n"); - if (test3()) { - fprintf(test_out, "Test3 succeeded\n"); - } else { - fprintf(test_out, "Test3 failed\n"); - ret = 3; - } - - fprintf(test_out, "executing test4\n"); - if (test4()) { - fprintf(test_out, "Test4 succeeded\n"); - } else { - fprintf(test_out, "Test4 failed\n"); - ret = 4; - } - - fprintf(test_out, "executing test5\n"); - if (test5()) { - fprintf(test_out, "Test5 succeeded\n"); - } else { - fprintf(test_out, "Test5 failed\n"); - ret = 5; - } - - fprintf(test_out, "executing test6\n"); - if (test6()) { - fprintf(test_out, "Test6 succeeded\n"); - } else { - fprintf(test_out, "Test6 failed\n"); - ret = 6; - } - - fprintf(test_out, "executing test7\n"); - if (test7()) { - fprintf(test_out, "Test7 succeeded\n"); - } else { - fprintf(test_out, "Test7 failed\n"); - ret = 7; - } - - fprintf(test_out, "executing test8\n"); - if (test8()) { - fprintf(test_out, "Test8 succeeded\n"); - } else { - fprintf(test_out, "Test8 failed\n"); - ret = 8; - } - - fprintf(test_out, "executing test9\n"); - if (test9()) { - fprintf(test_out, "Test9 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test9 failed\n"); - ret = 9; - } - - fprintf(test_out, "executing test10\n"); - if (test10()) { - fprintf(test_out, "Test10 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test10 failed\n"); - ret = 10; - } - - fprintf(test_out, "executing test11\n"); - if (test11()) { - fprintf(test_out, "Test11 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test11 failed\n"); - ret = 11; - } - - fprintf(test_out, "executing test12\n"); - if (test12()) { - fprintf(test_out, "Test12 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test12 failed\n"); - ret = 12; - } - - fclose(test_out); - - opal_finalize(); - - return ret; -} - -static bool test1(void) /* verify different buffer inits */ -{ - opal_buffer_t *bufA; - - bufA = OBJ_NEW(opal_buffer_t); - if (NULL == bufA) { - fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n"); - return false; - } - - OBJ_RELEASE(bufA); - if (NULL != bufA) { - fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n"); - return false; - } - return (true); -} - -/* - * OMPI_INT16 pack/unpack - */ -static bool test2(void) -{ - opal_buffer_t *bufA; - int rc; - int32_t i; - int16_t src[NUM_ELEMS]; - int16_t dst[NUM_ELEMS]; - - for(i=0; itype = OPAL_DSS_BUFFER_NON_DESC; - - for (i=0;ibytes), "%d", i); - src[i]->size = strlen((char*)(src[i]->bytes)) + 1; - } - - bufA = OBJ_NEW(opal_buffer_t); - if (NULL == bufA) { - fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n"); - return false; - } - - for (i=0;isize != dst[j]->size || - memcmp(src[j]->bytes,dst[j]->bytes,src[j]->size) != 0) { - fprintf(test_out, "test7: invalid results from unpack\n"); - fprintf(test_out, "test7: object element %d has incorrect unpacked value\n", j); - return(false); - } - } - } - - /* cleanup */ - OBJ_RELEASE(bufA); - if (NULL != bufA) { - fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n"); - return false; - } - - return (true); -} - -/** - * ompi everything composite multipack/unpack - */ - -static bool test9(void) -{ - - opal_buffer_t *bufA; - int rc; - int32_t i; - - /* pack and unpack in this order */ - /* each block now has an offset to make debugging easier.. first block=100, 200,... */ - opal_byte_object_t *srco[NUM_ELEMS]; - opal_byte_object_t *dsto[NUM_ELEMS]; - char* srcs[NUM_ELEMS]; - char* dsts[NUM_ELEMS]; - bool srcb[NUM_ELEMS]; - bool dstb[NUM_ELEMS]; - int32_t src32[NUM_ELEMS]; - int32_t dst32[NUM_ELEMS]; - int16_t src16[NUM_ELEMS]; - int16_t dst16[NUM_ELEMS]; - - for(i=0; ibytes), "%d", i+100); - srco[i]->size = strlen((char*)(srco[i]->bytes)) + 1; - - /* strings +200 */ - opal_asprintf(&srcs[i], "%d", i+200); - - /* bool */ - srcb[i] = ((i % 2) == 0) ? true : false; - - /* INT32 +300 */ - src32[i] = i+300; - - /* INT16 +400 */ - src16[i] = i+400; - } - - bufA = OBJ_NEW(opal_buffer_t); - if (NULL == bufA) { - fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n"); - return false; - } - - for (i=0;isize != dsto[j]->size || - memcmp(srco[j]->bytes,dsto[j]->bytes,srco[j]->size) != 0) { - fprintf(test_out, "test8: object element %d has incorrect unpacked value\n", j); - return(false); - } - } - - /* string */ - count = NUM_ELEMS; - rc = opal_dss.unpack(bufA, dsts, &count, OPAL_STRING); - if (OPAL_SUCCESS != rc || count != NUM_ELEMS) { - fprintf(test_out, "opal_dss.unpack on string failed with return code %d\n", rc); - return(false); - } - - for(j=0; jtype = ((i % 2) == 0) ? OPAL_INT16 : OPAL_STRING; - if (OPAL_INT16 == src[i]->type) - src[i]->data.uint16 = i16[i]; - else - src[i]->data.string = strdup("truly-a-dumb-test"); - } - - bufA = OBJ_NEW(opal_buffer_t); - if (NULL == bufA) { - fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n"); - return false; - } - - for (i=0;itype != dst[j]->type) { - fprintf(test_out, "opal_dss.unpack (DATA_VALUE) invalid results type mismatch from unpack\n"); - return(false); - } - if (0 != opal_dss.compare(src[j], dst[j], src[j]->type)) { - fprintf(test_out, "opal_dss.unpack (DATA_VALUE) invalid results value mismatch from unpack"); - return(false); - } - } - } - - OBJ_RELEASE(bufA); - if (NULL != bufA) { - fprintf(test_out, "OBJ_RELEASE did not NULL the buffer pointer\n"); - return false; - } - - return (true); -} - - -/* int32_t */ -static bool test11(void) -{ - opal_buffer_t *bufA; - int rc; - int32_t i; - int32_t src[NUM_ELEMS]; - int32_t dst[NUM_ELEMS]; - - for(i=0; i -#include -#include -#ifdef HAVE_SYS_PARAM_H -#include -#endif -#ifdef HAVE_NETINET_IN_H -#include -#endif - -#include "opal/runtime/opal.h" - -#include "opal/dss/dss.h" - -#define NUM_ITERS 3 -#define NUM_ELEMS 10 - -static bool test1(void); /* verify different buffer inits */ -static bool test2(void); /* verify int16 */ -static bool test3(void); /* verify int */ -static bool test4(void); /* verify int32 */ -static bool test5(void); /* verify int64 */ -static bool test6(void); /* verify string */ -static bool test7(void); /* verify BOOL */ -static bool test8(void); /* verify OBJECT */ -static bool test9(void); /* verify composite (multiple types and element counts) */ -static bool test11(void); /* verify size_t */ -static bool test12(void); /* verify pid_t */ -static bool test13(void); /* verify pid_t */ - -static FILE *test_out; - - -int main (int argc, char* argv[]) -{ - int ret = 0; - - opal_init(&argc, &argv); - - test_out = stderr; - - /* run the tests */ - - fprintf(test_out, "executing test1\n"); - if (test1()) { - fprintf(test_out, "Test1 succeeded\n"); - } else { - fprintf(test_out, "Test1 failed\n"); - ret = 1; - } - - fprintf(test_out, "executing test2\n"); - if (test2()) { - fprintf(test_out, "Test2 succeeded\n"); - } else { - fprintf(test_out, "Test2 failed\n"); - ret = 2; - } - - fprintf(test_out, "executing test3\n"); - if (test3()) { - fprintf(test_out, "Test3 succeeded\n"); - } else { - fprintf(test_out, "Test3 failed\n"); - ret = 3; - } - - fprintf(test_out, "executing test4\n"); - if (test4()) { - fprintf(test_out, "Test4 succeeded\n"); - } else { - fprintf(test_out, "Test4 failed\n"); - ret = 4; - } - - fprintf(test_out, "executing test5\n"); - if (test5()) { - fprintf(test_out, "Test5 succeeded\n"); - } else { - fprintf(test_out, "Test5 failed\n"); - ret = 5; - } - - fprintf(test_out, "executing test6\n"); - if (test6()) { - fprintf(test_out, "Test6 succeeded\n"); - } else { - fprintf(test_out, "Test6 failed\n"); - ret = 6; - } - - fprintf(test_out, "executing test7\n"); - if (test7()) { - fprintf(test_out, "Test7 succeeded\n"); - } else { - fprintf(test_out, "Test7 failed\n"); - ret = 7; - } - - fprintf(test_out, "executing test8\n"); - if (test8()) { - fprintf(test_out, "Test8 succeeded\n"); - } else { - fprintf(test_out, "Test8 failed\n"); - ret = 8; - } - - fprintf(test_out, "executing test9\n"); - if (test9()) { - fprintf(test_out, "Test9 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test9 failed\n"); - ret = 9; - } - - fprintf(test_out, "executing test11\n"); - if (test11()) { - fprintf(test_out, "Test11 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test11 failed\n"); - ret = 11; - } - - fprintf(test_out, "executing test12\n"); - if (test12()) { - fprintf(test_out, "Test12 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test12 failed\n"); - ret = 12; - } - - fprintf(test_out, "executing test13\n"); - if (test13()) { - fprintf(test_out, "Test13 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test13 failed\n"); - ret = 13; - } - - fclose(test_out); - - opal_finalize(); - - return ret; -} - -/* - * INT8 - */ -static bool test1(void) -{ - int8_t v1, v2=100; - uint8_t u1, u2=150; - opal_data_type_t type=OPAL_INT8, utype=OPAL_UINT8; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed equality\n"); - return(false); - } - - v1 = v2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value1 greater\n"); - return(false); - } - - v1 = v2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value2 greater\n"); - return(false); - } - - u1 = u2; - if (OPAL_EQUAL != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned equality\n"); - return(false); - } - - u1 = u2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value1 greater\n"); - return(false); - } - - u1 = u2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value2 greater\n"); - return(false); - } - - return (true); -} - -/* - * INT16 - */ -static bool test2(void) -{ - int16_t v1, v2=100; - uint16_t u1, u2=150; - opal_data_type_t type=OPAL_INT16, utype=OPAL_UINT16; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed equality\n"); - return(false); - } - - v1 = v2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value1 greater\n"); - return(false); - } - - v1 = v2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value2 greater\n"); - return(false); - } - - u1 = u2; - if (OPAL_EQUAL != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned equality\n"); - return(false); - } - - u1 = u2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value1 greater\n"); - return(false); - } - - u1 = u2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value2 greater\n"); - return(false); - } - - return (true); -} - -/* - * INT32 - */ -static bool test3(void) -{ - int32_t v1, v2=100; - uint32_t u1, u2=150; - opal_data_type_t type=OPAL_INT32, utype=OPAL_UINT32; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed equality\n"); - return(false); - } - - v1 = v2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value1 greater\n"); - return(false); - } - - v1 = v2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value2 greater\n"); - return(false); - } - - u1 = u2; - if (OPAL_EQUAL != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned equality\n"); - return(false); - } - - u1 = u2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value1 greater\n"); - return(false); - } - - u1 = u2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value2 greater\n"); - return(false); - } - - return (true); -} - -/* - * INT64 - */ -static bool test4(void) -{ - int64_t v1, v2=100; - uint64_t u1, u2=150; - opal_data_type_t type=OPAL_INT64, utype=OPAL_UINT64; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed equality\n"); - return(false); - } - - v1 = v2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value1 greater\n"); - return(false); - } - - v1 = v2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value2 greater\n"); - return(false); - } - - u1 = u2; - if (OPAL_EQUAL != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned equality\n"); - return(false); - } - - u1 = u2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value1 greater\n"); - return(false); - } - - u1 = u2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value2 greater\n"); - return(false); - } - - return (true); -} - -/* - * INT - */ -static bool test5(void) -{ - int v1, v2=100; - uint u1, u2=150; - opal_data_type_t type=OPAL_INT, utype=OPAL_UINT; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed equality\n"); - return(false); - } - - v1 = v2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value1 greater\n"); - return(false); - } - - v1 = v2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for signed value2 greater\n"); - return(false); - } - - u1 = u2; - if (OPAL_EQUAL != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned equality\n"); - return(false); - } - - u1 = u2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value1 greater\n"); - return(false); - } - - u1 = u2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.compare failed for unsigned value2 greater\n"); - return(false); - } - - return (true); -} - -/* - * STRING - */ -static bool test6(void) -{ - char *string1="This is a short string"; - char *string2="This is a longer string"; - - if (OPAL_EQUAL != opal_dss.compare(string1, string1, OPAL_STRING)) { - fprintf(test_out, "opal_dss.compare failed for equality\n"); - return(false); - } - - if (OPAL_VALUE2_GREATER != opal_dss.compare(string1, string2, OPAL_STRING)) { - fprintf(test_out, "opal_dss.compare failed for value2 greater\n"); - return(false); - } - - if (OPAL_VALUE1_GREATER != opal_dss.compare(string2, string1, OPAL_STRING)) { - fprintf(test_out, "opal_dss.compare failed for value1 greater\n"); - return(false); - } - - return (true); -} - -/* - * BOOL - */ -static bool test7(void) -{ - bool v1, v2=true; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, OPAL_BOOL)) { - fprintf(test_out, "opal_dss.compare failed for equality\n"); - return(false); - } - - v1 = true; - v2 = false; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, OPAL_BOOL)) { - fprintf(test_out, "opal_dss.compare failed for value1 greater\n"); - return(false); - } - - v1 = false; - v2 = true; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, OPAL_BOOL)) { - fprintf(test_out, "opal_dss.compare failed for value2 greater\n"); - return(false); - } - - return (true); -} - - -/* - * SIZE - */ -static bool test8(void) -{ - size_t v1, v2=100; - opal_data_type_t type=OPAL_SIZE; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for equality\n"); - return(false); - } - - v1 = v2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for value1 greater\n"); - return(false); - } - - v1 = v2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for value2 greater\n"); - return(false); - } - - return (true); -} - -/* - * PID - */ -static bool test9(void) -{ - pid_t v1, v2=100; - opal_data_type_t type=OPAL_PID; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for equality\n"); - return(false); - } - - v1 = v2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for value1 greater\n"); - return(false); - } - - v1 = v2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for value2 greater\n"); - return(false); - } - - return (true); -} - -/* - * DATA TYPE - */ -static bool test11(void) -{ - opal_data_type_t v1, v2=100; - opal_data_type_t type=OPAL_DATA_TYPE; - - v1 = v2; - if (OPAL_EQUAL != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for equality\n"); - return(false); - } - - v1 = v2 + 1; - if (OPAL_VALUE1_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for value1 greater\n"); - return(false); - } - - v1 = v2 - 1; - if (OPAL_VALUE2_GREATER != opal_dss.compare(&v1, &v2, type)) { - fprintf(test_out, "opal_dss.compare failed for value2 greater\n"); - return(false); - } - - return (true); -} - -/** - * OPAL_BYTE_OBJECT - */ - -static bool test12(void) -{ - int i; - opal_byte_object_t v1, v2; - opal_data_type_t type=OPAL_BYTE_OBJECT; - - v1.size = 20; - v1.bytes = (uint8_t*)malloc(v1.size); - for (i=0; i -#include -#include -#include "opal/runtime/opal.h" - -#include "opal/dss/dss.h" - -#define NUM_ITERS 3 -#define NUM_ELEMS 10 - -static bool test1(void); /* verify different buffer inits */ -static bool test2(void); /* verify int16 */ -static bool test3(void); /* verify int */ -static bool test4(void); /* verify int32 */ -static bool test5(void); /* verify int64 */ -static bool test6(void); /* verify string */ -static bool test7(void); /* verify BOOL */ -static bool test8(void); /* verify OBJECT */ -static bool test9(void); /* verify composite (multiple types and element counts) */ -static bool test11(void); /* verify size_t */ -static bool test12(void); /* verify pid_t */ -static bool test13(void); /* verify pid_t */ - -static FILE *test_out; - - -int main (int argc, char* argv[]) -{ - int ret = 0; - - opal_init(&argc, &argv); - - test_out = stderr; - - /* run the tests */ - - fprintf(test_out, "executing test1\n"); - if (test1()) { - fprintf(test_out, "Test1 succeeded\n"); - } else { - fprintf(test_out, "Test1 failed\n"); - ret = 1; - } - - fprintf(test_out, "executing test2\n"); - if (test2()) { - fprintf(test_out, "Test2 succeeded\n"); - } else { - fprintf(test_out, "Test2 failed\n"); - ret = 2; - } - - fprintf(test_out, "executing test3\n"); - if (test3()) { - fprintf(test_out, "Test3 succeeded\n"); - } else { - fprintf(test_out, "Test3 failed\n"); - ret = 3; - } - - fprintf(test_out, "executing test4\n"); - if (test4()) { - fprintf(test_out, "Test4 succeeded\n"); - } else { - fprintf(test_out, "Test4 failed\n"); - ret = 4; - } - - fprintf(test_out, "executing test5\n"); - if (test5()) { - fprintf(test_out, "Test5 succeeded\n"); - } else { - fprintf(test_out, "Test5 failed\n"); - ret = 5; - } - - fprintf(test_out, "executing test6\n"); - if (test6()) { - fprintf(test_out, "Test6 succeeded\n"); - } else { - fprintf(test_out, "Test6 failed\n"); - ret = 6; - } - - fprintf(test_out, "executing test7\n"); - if (test7()) { - fprintf(test_out, "Test7 succeeded\n"); - } else { - fprintf(test_out, "Test7 failed\n"); - ret = 7; - } - - fprintf(test_out, "executing test8\n"); - if (test8()) { - fprintf(test_out, "Test8 succeeded\n"); - } else { - fprintf(test_out, "Test8 failed\n"); - ret = 8; - } - - fprintf(test_out, "executing test9\n"); - if (test9()) { - fprintf(test_out, "Test9 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test9 failed\n"); - ret = 9; - } - - fprintf(test_out, "executing test11\n"); - if (test11()) { - fprintf(test_out, "Test11 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test11 failed\n"); - ret = 11; - } - - fprintf(test_out, "executing test12\n"); - if (test12()) { - fprintf(test_out, "Test12 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test12 failed\n"); - ret = 12; - } - - fprintf(test_out, "executing test13\n"); - if (test13()) { - fprintf(test_out, "Test13 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test13 failed\n"); - ret = 13; - } - - fclose(test_out); - - opal_finalize(); - - return(ret); -} - -/* - * INT8 - */ -static bool test1(void) -{ - int8_t *v1, v2=100; - uint8_t *u1, u2=150; - opal_data_type_t type=OPAL_INT8, utype=OPAL_UINT8; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed for signed value\n"); - return(false); - } - - if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*u1 != u2) { - fprintf(test_out, "opal_dss.copy failed for unsigned value\n"); - return(false); - } - - return (true); -} - -/* - * INT16 - */ -static bool test2(void) -{ - int16_t *v1, v2=100; - uint16_t *u1, u2=150; - opal_data_type_t type=OPAL_INT16, utype=OPAL_UINT16; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed for signed value\n"); - return(false); - } - - if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*u1 != u2) { - fprintf(test_out, "opal_dss.copy failed for unsigned value\n"); - return(false); - } - - return (true); -} - -/* - * INT32 - */ -static bool test3(void) -{ - int32_t *v1, v2=100; - uint32_t *u1, u2=150; - opal_data_type_t type=OPAL_INT32, utype=OPAL_UINT32; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed for signed value\n"); - return(false); - } - - if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*u1 != u2) { - fprintf(test_out, "opal_dss.copy failed for unsigned value\n"); - return(false); - } - - return (true); -} - -/* - * INT64 - */ -static bool test4(void) -{ - int64_t *v1, v2=100; - uint64_t *u1, u2=150; - opal_data_type_t type=OPAL_INT64, utype=OPAL_UINT64; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed for signed value\n"); - return(false); - } - - if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*u1 != u2) { - fprintf(test_out, "opal_dss.copy failed for unsigned value\n"); - return(false); - } - - return (true); -} - -/* - * INT - */ -static bool test5(void) -{ - int *v1, v2=100; - uint *u1, u2=150; - opal_data_type_t type=OPAL_INT, utype=OPAL_UINT; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed for signed value\n"); - return(false); - } - - if (OPAL_SUCCESS != opal_dss.copy((void**)&u1, &u2, utype)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*u1 != u2) { - fprintf(test_out, "opal_dss.copy failed for unsigned value\n"); - return(false); - } - - return (true); -} - -/* - * STRING - */ -static bool test6(void) -{ - char *string1="This is a short string"; - char *string2; - - if (OPAL_EQUAL != opal_dss.copy((void**)&string2, string1, OPAL_STRING)) { - fprintf(test_out, "opal_dss.copy returned error code\n"); - return(false); - } - - if (0 != strcmp(string1, string2)) { - fprintf(test_out, "opal_dss.copy failed\n"); - return(false); - } - - return (true); -} - -/* - * BOOL - */ -static bool test7(void) -{ - bool *v1, v2=true; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, OPAL_BOOL)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed\n"); - return(false); - } - - return (true); -} - - -/* - * SIZE - */ -static bool test8(void) -{ - size_t *v1, v2=100; - opal_data_type_t type=OPAL_SIZE; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed\n"); - return(false); - } - - return (true); -} - -/* - * PID - */ -static bool test9(void) -{ - pid_t *v1, v2=100; - opal_data_type_t type=OPAL_PID; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed\n"); - return(false); - } - - return (true); -} - -/* - * DATA TYPE - */ -static bool test11(void) -{ - opal_data_type_t *v1, v2=100; - opal_data_type_t type=OPAL_DATA_TYPE; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (*v1 != v2) { - fprintf(test_out, "opal_dss.copy failed\n"); - return(false); - } - - return (true); -} - -/** - * OPAL_BYTE_OBJECT - */ - -static bool test12(void) -{ - size_t i; - opal_byte_object_t *v1, v2; - opal_data_type_t type=OPAL_BYTE_OBJECT; - - v2.size = 20; - v2.bytes = (uint8_t*)malloc(v2.size); - for (i=0; isize != v2.size) { - fprintf(test_out, "opal_dss.copy failed\n"); - return(false); - } - for (i=0; i < v2.size; i++) { - if (v1->bytes[i] != v2.bytes[i]) { - fprintf(test_out, "opal_dss.copy failed\n"); - return(false); - } - } - - return (true); -} - - -/* OPAL_DATA_VALUE */ -static bool test13(void) -{ - int dat2=200; - opal_dss_value_t *v1, v2; - opal_data_type_t type=OPAL_DATA_VALUE; - - v2.type = OPAL_INT; - v2.data = &dat2; - - if (OPAL_SUCCESS != opal_dss.copy((void**)&v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy returned error\n"); - return(false); - } - if (OPAL_EQUAL != opal_dss.compare(v1, &v2, type)) { - fprintf(test_out, "opal_dss.copy failed\n"); - return(false); - } - return (true); -} - diff --git a/test/dss/dss_payload.c b/test/dss/dss_payload.c deleted file mode 100644 index 4636ae84945..00000000000 --- a/test/dss/dss_payload.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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) 2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "opal_config.h" -#include "opal/constants.h" - -#include -#include -#include - -#include "opal/runtime/opal.h" -#include "opal/dss/dss.h" - -#define NUM_ITERS 100 -#define NUM_ELEMS 1024 - -static bool test1(void); /* verify dss_copy_payload */ - -static FILE *test_out; - - -int main (int argc, char* argv[]) -{ - int ret = 0; - - opal_init(&argc, &argv); - - test_out = stderr; - - /* run the tests */ - - fprintf(test_out, "executing test1\n"); - if (test1()) { - fprintf(test_out, "Test1 succeeded\n"); - } else { - fprintf(test_out, "Test1 failed\n"); - ret = 1; - } - - opal_finalize(); - - return ret; -} - -static bool test1(void) /* verify dss_copy_payload */ -{ - opal_buffer_t *bufA, *bufB; - int rc; - int32_t i; - int16_t src[NUM_ELEMS]; - int16_t dst[NUM_ELEMS]; - int32_t src32[NUM_ELEMS]; - int32_t dst32[NUM_ELEMS]; - - /* init src arrays */ - for (i=0; i < NUM_ELEMS; i++) { - src[i] = i; - src32[i] = 132 * i; - } - - /* init A */ - bufA = OBJ_NEW(opal_buffer_t); - if (NULL == bufA) { - fprintf(test_out, "orte_buffer failed init in OBJ_NEW\n"); - return false; - } - - bufA->type = OPAL_DSS_BUFFER_NON_DESC; - - /* pack something in A */ - for (i=0;itype = OPAL_DSS_BUFFER_NON_DESC; - - /* pack something in B */ - for (i=0;i -#include -#include - -#include "opal/runtime/opal.h" - -#include "opal/dss/dss.h" - -#define NUM_ITERS 3 -#define NUM_ELEMS 10 - -static bool test1(void); /* verify different buffer inits */ -static bool test2(void); /* verify int16 */ -static bool test3(void); /* verify int */ -static bool test4(void); /* verify int32 */ -static bool test5(void); /* verify int64 */ -static bool test6(void); /* verify string */ -static bool test7(void); /* verify BOOL */ -static bool test8(void); /* verify OBJECT */ -static bool test9(void); /* verify composite (multiple types and element counts) */ -static bool test11(void); /* verify size_t */ -static bool test12(void); /* verify pid_t */ -static bool test13(void); /* verify pid_t */ - -static FILE *test_out; - - -int main (int argc, char* argv[]) -{ - int ret = 0; - - opal_init(&argc, &argv); - - test_out = stderr; - - /* run the tests */ - - fprintf(test_out, "executing test1\n"); - if (test1()) { - fprintf(test_out, "Test1 succeeded\n"); - } else { - fprintf(test_out, "Test1 failed\n"); - ret = 1; - } - - fprintf(test_out, "executing test2\n"); - if (test2()) { - fprintf(test_out, "Test2 succeeded\n"); - } else { - fprintf(test_out, "Test2 failed\n"); - ret = 1; - } - - fprintf(test_out, "executing test3\n"); - if (test3()) { - fprintf(test_out, "Test3 succeeded\n"); - } else { - fprintf(test_out, "Test3 failed\n"); - ret = 3; - } - - fprintf(test_out, "executing test4\n"); - if (test4()) { - fprintf(test_out, "Test4 succeeded\n"); - } else { - fprintf(test_out, "Test4 failed\n"); - ret = 4; - } - - fprintf(test_out, "executing test5\n"); - if (test5()) { - fprintf(test_out, "Test5 succeeded\n"); - } else { - fprintf(test_out, "Test5 failed\n"); - ret = 5; - } - - fprintf(test_out, "executing test6\n"); - if (test6()) { - fprintf(test_out, "Test6 succeeded\n"); - } else { - fprintf(test_out, "Test6 failed\n"); - ret = 6; - } - - fprintf(test_out, "executing test7\n"); - if (test7()) { - fprintf(test_out, "Test7 succeeded\n"); - } else { - fprintf(test_out, "Test7 failed\n"); - ret = 7; - } - - fprintf(test_out, "executing test8\n"); - if (test8()) { - fprintf(test_out, "Test8 succeeded\n"); - } else { - fprintf(test_out, "Test8 failed\n"); - ret = 8; - } - - fprintf(test_out, "executing test9\n"); - if (test9()) { - fprintf(test_out, "Test9 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test9 failed\n"); - ret = 9; - } - - fprintf(test_out, "executing test11\n"); - if (test11()) { - fprintf(test_out, "Test11 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test11 failed\n"); - ret = 11; - } - - fprintf(test_out, "executing test12\n"); - if (test12()) { - fprintf(test_out, "Test12 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test12 failed\n"); - ret = 12; - } - - fprintf(test_out, "executing test13\n"); - if (test13()) { - fprintf(test_out, "Test13 succeeded\n"); - } else { - fprintf(test_out, "opal_dss test13 failed\n"); - ret = 13; - } - - fclose(test_out); - - opal_finalize(); - - return ret; -} - -/* - * INT8 - */ -static bool test1(void) -{ - int8_t v2=-100; - uint8_t u2=150; - opal_data_type_t type=OPAL_INT8, utype=OPAL_UINT8; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for signed value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for signed value: %s\n", output); - free(output); - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for unsigned value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output); - free(output); - - return (true); -} - -/* - * INT16 - */ -static bool test2(void) -{ - int16_t v2=-100; - uint16_t u2=150; - opal_data_type_t type=OPAL_INT16, utype=OPAL_UINT16; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for signed value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for signed value: %s\n", output); - free(output); - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for unsigned value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output); - free(output); - - return (true); -} - -/* - * INT32 - */ -static bool test3(void) -{ - int32_t v2=-100; - uint32_t u2=150; - opal_data_type_t type=OPAL_INT32, utype=OPAL_UINT32; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for signed value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for signed value: %s\n", output); - free(output); - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for unsigned value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output); - free(output); - - return (true); -} - -/* - * INT64 - */ -static bool test4(void) -{ - int64_t v2=-100; - uint64_t u2=150; - opal_data_type_t type=OPAL_INT64, utype=OPAL_UINT64; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for signed value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for signed value: %s\n", output); - free(output); - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for unsigned value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output); - free(output); - - return (true); -} - -/* - * INT - */ -static bool test5(void) -{ - int v2=-100; - uint u2=150; - opal_data_type_t type=OPAL_INT, utype=OPAL_UINT; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for signed value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for signed value: %s\n", output); - free(output); - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &u2, utype)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed for unsigned value\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for unsigned value: %s\n", output); - free(output); - - return (true); -} - -/* - * STRING - */ -static bool test6(void) -{ - char *string1="This is a short string"; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, string1, OPAL_STRING)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for string: %s\n", output); - free(output); - - return (true); -} - -/* - * BOOL - */ -static bool test7(void) -{ - bool v2=true; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, OPAL_BOOL)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for bool: %s\n", output); - free(output); - - return (true); -} - - -/* - * SIZE - */ -static bool test8(void) -{ - size_t v2=100; - opal_data_type_t type=OPAL_SIZE; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for size: %s\n", output); - free(output); - - return (true); -} - -/* - * PID - */ -static bool test9(void) -{ - pid_t v2=100; - opal_data_type_t type=OPAL_PID; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for pid: %s\n", output); - free(output); - - return (true); -} - -/* - * DATA TYPE - */ -static bool test11(void) -{ - opal_data_type_t v2=100; - opal_data_type_t type=OPAL_DATA_TYPE; - char *output; - - if (OPAL_SUCCESS != opal_dss.print(&output, NULL, &v2, type)) { - fprintf(test_out, "opal_dss.print returned error\n"); - return(false); - } - if (NULL == output) { - fprintf(test_out, "opal_dss.print failed\n"); - return(false); - } - fprintf(test_out, "opal_dss.print output for data type: %s\n", output); - free(output); - - return (true); -} - -/** - * OPAL_BYTE_OBJECT - */ - -static bool test12(void) -{ - int i; - opal_byte_object_t v2; - opal_data_type_t type=OPAL_BYTE_OBJECT; - char *output; - - v2.size = 20; - v2.bytes = (uint8_t*)malloc(v2.size); - for (i=0; i Date: Tue, 23 Feb 2021 16:24:25 +0100 Subject: [PATCH 20/40] Fixed MCA parameters vs configuration file priority to select coll/tuned algorithms Signed-off-by: Emmanuel Brelle --- .../coll/tuned/coll_tuned_decision_dynamic.c | 237 ++++++++++-------- 1 file changed, 128 insertions(+), 109 deletions(-) diff --git a/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c b/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c index 491141cbdd6..4133a64eefc 100644 --- a/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c +++ b/ompi/mca/coll/tuned/coll_tuned_decision_dynamic.c @@ -62,6 +62,14 @@ ompi_coll_tuned_allreduce_intra_dec_dynamic (const void *sbuf, void *rbuf, int c OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_allreduce_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[ALLREDUCE].algorithm) { + return ompi_coll_tuned_allreduce_intra_do_this(sbuf, rbuf, count, dtype, op, comm, module, + tuned_module->user_forced[ALLREDUCE].algorithm, + tuned_module->user_forced[ALLREDUCE].tree_fanout, + tuned_module->user_forced[ALLREDUCE].segsize); + } + /* check to see if we have some filebased rules */ if (tuned_module->com_rules[ALLREDUCE]) { /* we do, so calc the message size or what ever we need and use this for the evaluation */ @@ -82,12 +90,6 @@ ompi_coll_tuned_allreduce_intra_dec_dynamic (const void *sbuf, void *rbuf, int c } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[ALLREDUCE].algorithm) { - return ompi_coll_tuned_allreduce_intra_do_this(sbuf, rbuf, count, dtype, op, comm, module, - tuned_module->user_forced[ALLREDUCE].algorithm, - tuned_module->user_forced[ALLREDUCE].tree_fanout, - tuned_module->user_forced[ALLREDUCE].segsize); - } return ompi_coll_tuned_allreduce_intra_dec_fixed (sbuf, rbuf, count, dtype, op, comm, module); } @@ -111,6 +113,17 @@ int ompi_coll_tuned_alltoall_intra_dec_dynamic(const void *sbuf, int scount, OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_alltoall_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[ALLTOALL].algorithm) { + return ompi_coll_tuned_alltoall_intra_do_this(sbuf, scount, sdtype, + rbuf, rcount, rdtype, + comm, module, + tuned_module->user_forced[ALLTOALL].algorithm, + tuned_module->user_forced[ALLTOALL].tree_fanout, + tuned_module->user_forced[ALLTOALL].segsize, + tuned_module->user_forced[ALLTOALL].max_requests); + } + /* check to see if we have some filebased rules */ if (tuned_module->com_rules[ALLTOALL]) { /* we do, so calc the message size or what ever we need and use this for the evaluation */ @@ -134,15 +147,6 @@ int ompi_coll_tuned_alltoall_intra_dec_dynamic(const void *sbuf, int scount, } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[ALLTOALL].algorithm) { - return ompi_coll_tuned_alltoall_intra_do_this(sbuf, scount, sdtype, - rbuf, rcount, rdtype, - comm, module, - tuned_module->user_forced[ALLTOALL].algorithm, - tuned_module->user_forced[ALLTOALL].tree_fanout, - tuned_module->user_forced[ALLTOALL].segsize, - tuned_module->user_forced[ALLTOALL].max_requests); - } return ompi_coll_tuned_alltoall_intra_dec_fixed (sbuf, scount, sdtype, rbuf, rcount, rdtype, comm, module); @@ -165,6 +169,14 @@ int ompi_coll_tuned_alltoallv_intra_dec_dynamic(const void *sbuf, const int *sco OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_alltoallv_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[ALLTOALLV].algorithm) { + return ompi_coll_tuned_alltoallv_intra_do_this(sbuf, scounts, sdisps, sdtype, + rbuf, rcounts, rdisps, rdtype, + comm, module, + tuned_module->user_forced[ALLTOALLV].algorithm); + } + /** * check to see if we have some filebased rules. As we don't have global * knowledge about the total amount of data, use the first available rule. @@ -186,12 +198,6 @@ int ompi_coll_tuned_alltoallv_intra_dec_dynamic(const void *sbuf, const int *sco } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[ALLTOALLV].algorithm) { - return ompi_coll_tuned_alltoallv_intra_do_this(sbuf, scounts, sdisps, sdtype, - rbuf, rcounts, rdisps, rdtype, - comm, module, - tuned_module->user_forced[ALLTOALLV].algorithm); - } return ompi_coll_tuned_alltoallv_intra_dec_fixed(sbuf, scounts, sdisps, sdtype, rbuf, rcounts, rdisps, rdtype, comm, module); @@ -211,6 +217,14 @@ int ompi_coll_tuned_barrier_intra_dec_dynamic(struct ompi_communicator_t *comm, OPAL_OUTPUT((ompi_coll_tuned_stream,"ompi_coll_tuned_barrier_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[BARRIER].algorithm) { + return ompi_coll_tuned_barrier_intra_do_this(comm, module, + tuned_module->user_forced[BARRIER].algorithm, + tuned_module->user_forced[BARRIER].tree_fanout, + tuned_module->user_forced[BARRIER].segsize); + } + /* check to see if we have some filebased rules */ if (tuned_module->com_rules[BARRIER]) { /* we do, so calc the message size or what ever we need and use this for the evaluation */ @@ -226,12 +240,6 @@ int ompi_coll_tuned_barrier_intra_dec_dynamic(struct ompi_communicator_t *comm, } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[BARRIER].algorithm) { - return ompi_coll_tuned_barrier_intra_do_this(comm, module, - tuned_module->user_forced[BARRIER].algorithm, - tuned_module->user_forced[BARRIER].tree_fanout, - tuned_module->user_forced[BARRIER].segsize); - } return ompi_coll_tuned_barrier_intra_dec_fixed (comm, module); } @@ -251,6 +259,15 @@ int ompi_coll_tuned_bcast_intra_dec_dynamic(void *buf, int count, OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:bcast_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[BCAST].algorithm) { + return ompi_coll_tuned_bcast_intra_do_this(buf, count, dtype, + root, comm, module, + tuned_module->user_forced[BCAST].algorithm, + tuned_module->user_forced[BCAST].chain_fanout, + tuned_module->user_forced[BCAST].segsize); + } + /* check to see if we have some filebased rules */ if (tuned_module->com_rules[BCAST]) { /* we do, so calc the message size or what ever we need and use this for the evaluation */ @@ -272,13 +289,6 @@ int ompi_coll_tuned_bcast_intra_dec_dynamic(void *buf, int count, } /*end if any com rules to check */ - if (tuned_module->user_forced[BCAST].algorithm) { - return ompi_coll_tuned_bcast_intra_do_this(buf, count, dtype, - root, comm, module, - tuned_module->user_forced[BCAST].algorithm, - tuned_module->user_forced[BCAST].chain_fanout, - tuned_module->user_forced[BCAST].segsize); - } return ompi_coll_tuned_bcast_intra_dec_fixed (buf, count, dtype, root, comm, module); } @@ -301,6 +311,16 @@ int ompi_coll_tuned_reduce_intra_dec_dynamic( const void *sbuf, void *rbuf, OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:reduce_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[REDUCE].algorithm) { + return ompi_coll_tuned_reduce_intra_do_this(sbuf, rbuf, count, dtype, + op, root, comm, module, + tuned_module->user_forced[REDUCE].algorithm, + tuned_module->user_forced[REDUCE].chain_fanout, + tuned_module->user_forced[REDUCE].segsize, + tuned_module->user_forced[REDUCE].max_requests); + } + /* check to see if we have some filebased rules */ if (tuned_module->com_rules[REDUCE]) { @@ -323,14 +343,6 @@ int ompi_coll_tuned_reduce_intra_dec_dynamic( const void *sbuf, void *rbuf, } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[REDUCE].algorithm) { - return ompi_coll_tuned_reduce_intra_do_this(sbuf, rbuf, count, dtype, - op, root, comm, module, - tuned_module->user_forced[REDUCE].algorithm, - tuned_module->user_forced[REDUCE].chain_fanout, - tuned_module->user_forced[REDUCE].segsize, - tuned_module->user_forced[REDUCE].max_requests); - } return ompi_coll_tuned_reduce_intra_dec_fixed (sbuf, rbuf, count, dtype, op, root, comm, module); } @@ -355,6 +367,15 @@ int ompi_coll_tuned_reduce_scatter_intra_dec_dynamic(const void *sbuf, void *rbu OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:reduce_scatter_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[REDUCESCATTER].algorithm) { + return ompi_coll_tuned_reduce_scatter_intra_do_this(sbuf, rbuf, rcounts, dtype, + op, comm, module, + tuned_module->user_forced[REDUCESCATTER].algorithm, + tuned_module->user_forced[REDUCESCATTER].chain_fanout, + tuned_module->user_forced[REDUCESCATTER].segsize); + } + /* check to see if we have some filebased rules */ if (tuned_module->com_rules[REDUCESCATTER]) { /* we do, so calc the message size or what ever we need and use @@ -377,13 +398,6 @@ int ompi_coll_tuned_reduce_scatter_intra_dec_dynamic(const void *sbuf, void *rbu } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[REDUCESCATTER].algorithm) { - return ompi_coll_tuned_reduce_scatter_intra_do_this(sbuf, rbuf, rcounts, dtype, - op, comm, module, - tuned_module->user_forced[REDUCESCATTER].algorithm, - tuned_module->user_forced[REDUCESCATTER].chain_fanout, - tuned_module->user_forced[REDUCESCATTER].segsize); - } return ompi_coll_tuned_reduce_scatter_intra_dec_fixed (sbuf, rbuf, rcounts, dtype, op, comm, module); } @@ -408,6 +422,15 @@ int ompi_coll_tuned_reduce_scatter_block_intra_dec_dynamic(const void *sbuf, voi OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:reduce_scatter_block_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[REDUCESCATTERBLOCK].algorithm) { + return ompi_coll_tuned_reduce_scatter_block_intra_do_this(sbuf, rbuf, rcount, dtype, + op, comm, module, + tuned_module->user_forced[REDUCESCATTERBLOCK].algorithm, + tuned_module->user_forced[REDUCESCATTERBLOCK].chain_fanout, + tuned_module->user_forced[REDUCESCATTERBLOCK].segsize); + } + /* check to see if we have some filebased rules */ if (tuned_module->com_rules[REDUCESCATTERBLOCK]) { /* we do, so calc the message size or what ever we need and use @@ -429,13 +452,6 @@ int ompi_coll_tuned_reduce_scatter_block_intra_dec_dynamic(const void *sbuf, voi } /* found a method */ } /* end if any com rules to check */ - if (tuned_module->user_forced[REDUCESCATTERBLOCK].algorithm) { - return ompi_coll_tuned_reduce_scatter_block_intra_do_this(sbuf, rbuf, rcount, dtype, - op, comm, module, - tuned_module->user_forced[REDUCESCATTERBLOCK].algorithm, - tuned_module->user_forced[REDUCESCATTERBLOCK].chain_fanout, - tuned_module->user_forced[REDUCESCATTERBLOCK].segsize); - } return ompi_coll_tuned_reduce_scatter_block_intra_dec_fixed (sbuf, rbuf, rcount, dtype, op, comm, module); } @@ -461,6 +477,17 @@ int ompi_coll_tuned_allgather_intra_dec_dynamic(const void *sbuf, int scount, OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_allgather_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[ALLGATHER].algorithm) { + /* User-forced algorithm */ + return ompi_coll_tuned_allgather_intra_do_this(sbuf, scount, sdtype, + rbuf, rcount, rdtype, + comm, module, + tuned_module->user_forced[ALLGATHER].algorithm, + tuned_module->user_forced[ALLGATHER].tree_fanout, + tuned_module->user_forced[ALLGATHER].segsize); + } + if (tuned_module->com_rules[ALLGATHER]) { /* We have file based rules: - calculate message size and other necessary information */ @@ -484,17 +511,6 @@ int ompi_coll_tuned_allgather_intra_dec_dynamic(const void *sbuf, int scount, } } - /* We do not have file based rules */ - if (tuned_module->user_forced[ALLGATHER].algorithm) { - /* User-forced algorithm */ - return ompi_coll_tuned_allgather_intra_do_this(sbuf, scount, sdtype, - rbuf, rcount, rdtype, - comm, module, - tuned_module->user_forced[ALLGATHER].algorithm, - tuned_module->user_forced[ALLGATHER].tree_fanout, - tuned_module->user_forced[ALLGATHER].segsize); - } - /* Use default decision */ return ompi_coll_tuned_allgather_intra_dec_fixed (sbuf, scount, sdtype, rbuf, rcount, rdtype, @@ -523,6 +539,17 @@ int ompi_coll_tuned_allgatherv_intra_dec_dynamic(const void *sbuf, int scount, OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_allgatherv_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[ALLGATHERV].algorithm) { + /* User-forced algorithm */ + return ompi_coll_tuned_allgatherv_intra_do_this(sbuf, scount, sdtype, + rbuf, rcounts, rdispls, rdtype, + comm, module, + tuned_module->user_forced[ALLGATHERV].algorithm, + tuned_module->user_forced[ALLGATHERV].tree_fanout, + tuned_module->user_forced[ALLGATHERV].segsize); + } + if (tuned_module->com_rules[ALLGATHERV]) { /* We have file based rules: - calculate message size and other necessary information */ @@ -549,18 +576,6 @@ int ompi_coll_tuned_allgatherv_intra_dec_dynamic(const void *sbuf, int scount, alg, faninout, segsize); } } - - /* We do not have file based rules */ - if (tuned_module->user_forced[ALLGATHERV].algorithm) { - /* User-forced algorithm */ - return ompi_coll_tuned_allgatherv_intra_do_this(sbuf, scount, sdtype, - rbuf, rcounts, rdispls, rdtype, - comm, module, - tuned_module->user_forced[ALLGATHERV].algorithm, - tuned_module->user_forced[ALLGATHERV].tree_fanout, - tuned_module->user_forced[ALLGATHERV].segsize); - } - /* Use default decision */ return ompi_coll_tuned_allgatherv_intra_dec_fixed (sbuf, scount, sdtype, rbuf, rcounts, @@ -581,6 +596,16 @@ int ompi_coll_tuned_gather_intra_dec_dynamic(const void *sbuf, int scount, OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_gather_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[GATHER].algorithm) { + return ompi_coll_tuned_gather_intra_do_this(sbuf, scount, sdtype, + rbuf, rcount, rdtype, + root, comm, module, + tuned_module->user_forced[GATHER].algorithm, + tuned_module->user_forced[GATHER].tree_fanout, + tuned_module->user_forced[GATHER].segsize); + } + /** * check to see if we have some filebased rules. */ @@ -604,15 +629,6 @@ int ompi_coll_tuned_gather_intra_dec_dynamic(const void *sbuf, int scount, } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[GATHER].algorithm) { - return ompi_coll_tuned_gather_intra_do_this(sbuf, scount, sdtype, - rbuf, rcount, rdtype, - root, comm, module, - tuned_module->user_forced[GATHER].algorithm, - tuned_module->user_forced[GATHER].tree_fanout, - tuned_module->user_forced[GATHER].segsize); - } - return ompi_coll_tuned_gather_intra_dec_fixed (sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm, module); @@ -630,6 +646,16 @@ int ompi_coll_tuned_scatter_intra_dec_dynamic(const void *sbuf, int scount, OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_scatter_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[SCATTER].algorithm) { + return ompi_coll_tuned_scatter_intra_do_this(sbuf, scount, sdtype, + rbuf, rcount, rdtype, + root, comm, module, + tuned_module->user_forced[SCATTER].algorithm, + tuned_module->user_forced[SCATTER].chain_fanout, + tuned_module->user_forced[SCATTER].segsize); + } + /** * check to see if we have some filebased rules. */ @@ -653,15 +679,6 @@ int ompi_coll_tuned_scatter_intra_dec_dynamic(const void *sbuf, int scount, } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[SCATTER].algorithm) { - return ompi_coll_tuned_scatter_intra_do_this(sbuf, scount, sdtype, - rbuf, rcount, rdtype, - root, comm, module, - tuned_module->user_forced[SCATTER].algorithm, - tuned_module->user_forced[SCATTER].chain_fanout, - tuned_module->user_forced[SCATTER].segsize); - } - return ompi_coll_tuned_scatter_intra_dec_fixed (sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm, module); @@ -678,6 +695,13 @@ int ompi_coll_tuned_exscan_intra_dec_dynamic(const void *sbuf, void* rbuf, int c OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_exscan_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[EXSCAN].algorithm) { + return ompi_coll_tuned_exscan_intra_do_this(sbuf, rbuf, count, dtype, + op, comm, module, + tuned_module->user_forced[EXSCAN].algorithm); + } + /** * check to see if we have some filebased rules. */ @@ -700,12 +724,6 @@ int ompi_coll_tuned_exscan_intra_dec_dynamic(const void *sbuf, void* rbuf, int c } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[EXSCAN].algorithm) { - return ompi_coll_tuned_exscan_intra_do_this(sbuf, rbuf, count, dtype, - op, comm, module, - tuned_module->user_forced[EXSCAN].algorithm); - } - return ompi_coll_base_exscan_intra_linear(sbuf, rbuf, count, dtype, op, comm, module); } @@ -721,6 +739,13 @@ int ompi_coll_tuned_scan_intra_dec_dynamic(const void *sbuf, void* rbuf, int cou OPAL_OUTPUT((ompi_coll_tuned_stream, "ompi_coll_tuned_scan_intra_dec_dynamic")); + /* Check first if an algorithm is set explicitly for this collective */ + if (tuned_module->user_forced[SCAN].algorithm) { + return ompi_coll_tuned_scan_intra_do_this(sbuf, rbuf, count, dtype, + op, comm, module, + tuned_module->user_forced[SCAN].algorithm); + } + /** * check to see if we have some filebased rules. */ @@ -743,12 +768,6 @@ int ompi_coll_tuned_scan_intra_dec_dynamic(const void *sbuf, void* rbuf, int cou } /* found a method */ } /*end if any com rules to check */ - if (tuned_module->user_forced[SCAN].algorithm) { - return ompi_coll_tuned_scan_intra_do_this(sbuf, rbuf, count, dtype, - op, comm, module, - tuned_module->user_forced[SCAN].algorithm); - } - return ompi_coll_base_scan_intra_linear(sbuf, rbuf, count, dtype, op, comm, module); } From b49cbf450e3e14ee4cb13f3c088e2a5972f108ef Mon Sep 17 00:00:00 2001 From: Yossi Itigin Date: Tue, 23 Feb 2021 00:08:29 +0200 Subject: [PATCH 21/40] ucx: disable version 1.8 Signed-off-by: Yossi Itigin --- config/ompi_check_ucx.m4 | 90 ++++++++++++++++++++++---------------- ompi/mca/pml/ucx/pml_ucx.c | 21 ++++++--- 2 files changed, 68 insertions(+), 43 deletions(-) diff --git a/config/ompi_check_ucx.m4 b/config/ompi_check_ucx.m4 index 0dda6f67985..8a183ef3bf8 100644 --- a/config/ompi_check_ucx.m4 +++ b/config/ompi_check_ucx.m4 @@ -104,44 +104,58 @@ AC_DEFUN([OMPI_CHECK_UCX],[ old_CPPFLAGS="$CPPFLAGS" AS_IF([test -n "$ompi_check_ucx_dir"], [CPPFLAGS="$CPPFLAGS -I$ompi_check_ucx_dir/include"]) - AC_CHECK_DECLS([ucp_tag_send_nbr], - [AC_DEFINE([HAVE_UCP_TAG_SEND_NBR],[1], - [have ucp_tag_send_nbr()])], [], - [#include ]) - AC_CHECK_DECLS([ucp_ep_flush_nb, ucp_worker_flush_nb, - ucp_request_check_status, ucp_put_nb, ucp_get_nb, - ucp_put_nbx, ucp_get_nbx, ucp_atomic_op_nbx], - [], [], - [#include ]) - AC_CHECK_DECLS([ucm_test_events, - ucm_test_external_events], - [], [], - [#include ]) - AC_CHECK_DECLS([UCP_ATOMIC_POST_OP_AND, - UCP_ATOMIC_POST_OP_OR, - UCP_ATOMIC_POST_OP_XOR, - UCP_ATOMIC_FETCH_OP_FAND, - UCP_ATOMIC_FETCH_OP_FOR, - UCP_ATOMIC_FETCH_OP_FXOR, - UCP_PARAM_FIELD_ESTIMATED_NUM_PPN], - [], [], - [#include ]) - AC_CHECK_DECLS([UCP_WORKER_ATTR_FIELD_ADDRESS_FLAGS], - [AC_DEFINE([HAVE_UCP_WORKER_ADDRESS_FLAGS], [1], - [have worker address attribute])], [], - [#include ]) - AC_CHECK_DECLS([UCP_ATTR_FIELD_MEMORY_TYPES], - [AC_DEFINE([HAVE_UCP_ATTR_MEMORY_TYPES], [1], - [have memory types attribute])], [], - [#include ]) - AC_CHECK_DECLS([ucp_tag_send_nbx, - ucp_tag_send_sync_nbx, - ucp_tag_recv_nbx], - [], [], - [#include ]) - AC_CHECK_TYPES([ucp_request_param_t], - [], [], - [[#include ]]) + # Turn off UCX version v1.8 due to issue #8321 + AC_MSG_CHECKING([UCX version]) + AC_PREPROC_IFELSE([AC_LANG_PROGRAM([#include + #if (UCP_API_MAJOR == 1) && (UCP_API_MINOR == 8) + #error "Invalid version" + #endif], [])], + [AC_MSG_RESULT([ok (not 1.8.x)])], + [AC_MSG_RESULT([bad (1.8.x)]) + AC_MSG_WARN([UCX support skipped because version 1.8.x was found, which has a known catastrophic issue.]) + AC_MSG_WARN([Please upgrade to UCX version 1.9 or higher.]) + ompi_check_ucx_happy=no]) + AS_IF([test "$ompi_check_ucx_happy" = yes], + [ + AC_CHECK_DECLS([ucp_tag_send_nbr], + [AC_DEFINE([HAVE_UCP_TAG_SEND_NBR],[1], + [have ucp_tag_send_nbr()])], [], + [#include ]) + AC_CHECK_DECLS([ucp_ep_flush_nb, ucp_worker_flush_nb, + ucp_request_check_status, ucp_put_nb, ucp_get_nb, + ucp_put_nbx, ucp_get_nbx, ucp_atomic_op_nbx], + [], [], + [#include ]) + AC_CHECK_DECLS([ucm_test_events, + ucm_test_external_events], + [], [], + [#include ]) + AC_CHECK_DECLS([UCP_ATOMIC_POST_OP_AND, + UCP_ATOMIC_POST_OP_OR, + UCP_ATOMIC_POST_OP_XOR, + UCP_ATOMIC_FETCH_OP_FAND, + UCP_ATOMIC_FETCH_OP_FOR, + UCP_ATOMIC_FETCH_OP_FXOR, + UCP_PARAM_FIELD_ESTIMATED_NUM_PPN], + [], [], + [#include ]) + AC_CHECK_DECLS([UCP_WORKER_ATTR_FIELD_ADDRESS_FLAGS], + [AC_DEFINE([HAVE_UCP_WORKER_ADDRESS_FLAGS], [1], + [have worker address attribute])], [], + [#include ]) + AC_CHECK_DECLS([UCP_ATTR_FIELD_MEMORY_TYPES], + [AC_DEFINE([HAVE_UCP_ATTR_MEMORY_TYPES], [1], + [have memory types attribute])], [], + [#include ]) + AC_CHECK_DECLS([ucp_tag_send_nbx, + ucp_tag_send_sync_nbx, + ucp_tag_recv_nbx], + [], [], + [#include ]) + AC_CHECK_TYPES([ucp_request_param_t], + [], [], + [[#include ]]) + ]) CPPFLAGS=$old_CPPFLAGS OPAL_SUMMARY_ADD([[Transports]],[[Open UCX]],[$1],[$ompi_check_ucx_happy])])]) diff --git a/ompi/mca/pml/ucx/pml_ucx.c b/ompi/mca/pml/ucx/pml_ucx.c index 1f00966e77e..f1350508da9 100644 --- a/ompi/mca/pml/ucx/pml_ucx.c +++ b/ompi/mca/pml/ucx/pml_ucx.c @@ -190,12 +190,23 @@ static int mca_pml_ucx_recv_worker_address(ompi_proc_t *proc, int mca_pml_ucx_open(void) { + unsigned major_version, minor_version, release_number; ucp_context_attr_t attr; ucp_params_t params; ucp_config_t *config; ucs_status_t status; - PML_UCX_VERBOSE(1, "mca_pml_ucx_open"); + /* Check version */ + ucp_get_version(&major_version, &minor_version, &release_number); + PML_UCX_VERBOSE(1, "mca_pml_ucx_open: UCX version %u.%u.%u", + major_version, minor_version, release_number); + + if ((major_version == 1) && (minor_version == 8)) { + /* disabled due to issue #8321 */ + PML_UCX_VERBOSE(1, "UCX PML is disabled because the run-time UCX version " + "is 1.8, which has a known catastrophic issue"); + return OMPI_ERROR; + } /* Read options */ status = ucp_config_read("MPI", NULL, &config); @@ -690,7 +701,7 @@ int mca_pml_ucx_isend_init(const void *buf, size_t count, ompi_datatype_t *datat } static ucs_status_ptr_t -mca_pml_ucx_bsend(ucp_ep_h ep, const void *buf, size_t count, +mca_pml_ucx_bsend(ucp_ep_h ep, const void *buf, size_t count, ompi_datatype_t *datatype, uint64_t pml_tag) { ompi_request_t *req; @@ -713,7 +724,7 @@ mca_pml_ucx_bsend(ucp_ep_h ep, const void *buf, size_t count, PML_UCX_ERROR("bsend: failed to allocate buffer"); return UCS_STATUS_PTR(OMPI_ERROR); } - + iov_count = 1; iov.iov_base = packed_data; iov.iov_len = packed_length; @@ -801,8 +812,8 @@ int mca_pml_ucx_isend(const void *buf, size_t count, ompi_datatype_t *datatype, ompi_request_t *req; ucp_ep_h ep; - PML_UCX_TRACE_SEND("i%ssend request *%p", - buf, count, datatype, dst, tag, mode, comm, + PML_UCX_TRACE_SEND("i%ssend request *%p", + buf, count, datatype, dst, tag, mode, comm, mode == MCA_PML_BASE_SEND_BUFFERED ? "b" : "", (void*)request) From 5b525b251c3433bf50b44b05c84937a39fb10074 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Tue, 23 Feb 2021 08:21:22 +0100 Subject: [PATCH 22/40] fs/lustre: Remove unneeded includes The functionality was migrated to `fs/base/fs_base_get_parent_dir.c` long ago, but the includes stayed. Though in lustre 2.14 `lustre_user.h` moved the inclusion of `linux/fs.h` outside the `__KERNEL__` guard. This triggered now Debian bug #898743 [1], which states that including `sys/mount.h` after `linux/fs.h` breaks compilation. Thus the include removal also avoids this breakage. Closes #8508. [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=898743 Signed-off-by: Bert Wesarg --- ompi/mca/fs/lustre/fs_lustre.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/ompi/mca/fs/lustre/fs_lustre.c b/ompi/mca/fs/lustre/fs_lustre.c index df2c7c3ac7c..20fdfc76991 100644 --- a/ompi/mca/fs/lustre/fs_lustre.c +++ b/ompi/mca/fs/lustre/fs_lustre.c @@ -32,21 +32,6 @@ #include "ompi/mca/fs/base/base.h" #include "ompi/mca/fs/lustre/fs_lustre.h" -#ifdef HAVE_SYS_STATFS_H -#include /* or */ -#endif -#ifdef HAVE_SYS_PARAM_H -#include -#endif -#ifdef HAVE_SYS_MOUNT_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif - -#include - /* * ******************************************************************* * ************************ actions structure ************************ From 982a1006a3aa3b2470637c8ecbb64469083a39fd Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Tue, 23 Feb 2021 18:01:07 -0800 Subject: [PATCH 23/40] Update PMIx/PRRTE pointers Signed-off-by: Ralph Castain --- 3rd-party/openpmix | 2 +- 3rd-party/prrte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3rd-party/openpmix b/3rd-party/openpmix index 55072c2af6e..fefaed568f3 160000 --- a/3rd-party/openpmix +++ b/3rd-party/openpmix @@ -1 +1 @@ -Subproject commit 55072c2af6e23a64ffb079cc4e47daaf5b6cbc03 +Subproject commit fefaed568f33bf86f28afb6e45237f1ec5e4de93 diff --git a/3rd-party/prrte b/3rd-party/prrte index b56ef1ad62d..be5dcbdbe50 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit b56ef1ad62d81dbd5fe08f27655237fc3d6ab4ce +Subproject commit be5dcbdbe50a99b9711b0dd1432c54fceea3ec4b From e35b0bccbffaeb5fae818c437af646682519332a Mon Sep 17 00:00:00 2001 From: Aboorva Devarajan Date: Wed, 24 Feb 2021 05:32:18 -0500 Subject: [PATCH 24/40] btl/smcuda: fix build issue https://github.com/open-mpi/ompi/pull/8492 Signed-off-by: Aboorva Devarajan --- contrib/scaling/mpi_memprobe.c | 2 +- opal/mca/btl/smcuda/btl_smcuda.c | 4 ++-- test/simple/interlib.c | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/contrib/scaling/mpi_memprobe.c b/contrib/scaling/mpi_memprobe.c index 0858977bba6..a782efba665 100644 --- a/contrib/scaling/mpi_memprobe.c +++ b/contrib/scaling/mpi_memprobe.c @@ -142,7 +142,7 @@ static void sample(void) OBJ_CONSTRUCT(&response, opal_list_t); kv = OBJ_NEW(opal_value_t); kv->key = strdup(OPAL_PMIX_LOG_STDOUT); - kv->type = OPAL_STRING; + kv->type = PMIX_STRING; kv->data.string = opal_argv_join(answer, '\n'); opal_list_append(&response, &kv->super); opal_argv_free(answer); diff --git a/opal/mca/btl/smcuda/btl_smcuda.c b/opal/mca/btl/smcuda/btl_smcuda.c index c41808fcf6c..d6784d07c9b 100644 --- a/opal/mca/btl/smcuda/btl_smcuda.c +++ b/opal/mca/btl/smcuda/btl_smcuda.c @@ -244,7 +244,7 @@ smcuda_btl_first_time_init(mca_btl_smcuda_t *smcuda_btl, wildcard_rank.jobid = OPAL_PROC_MY_NAME.jobid; wildcard_rank.vpid = OPAL_VPID_WILDCARD; OPAL_MODEX_RECV_VALUE_OPTIONAL(rc, PMIX_TOPOLOGY_SIGNATURE, - &wildcard_rank, &loc, OPAL_STRING); + &wildcard_rank, &loc, PMIX_STRING); if (OPAL_SUCCESS == rc) { /* the number of NUMA nodes is right at the front */ mca_btl_smcuda_component.num_mem_nodes = num_mem_nodes = strtoul(loc, NULL, 10); @@ -267,7 +267,7 @@ smcuda_btl_first_time_init(mca_btl_smcuda_t *smcuda_btl, } /* see if we were given our location */ OPAL_MODEX_RECV_VALUE_OPTIONAL(rc, PMIX_LOCALITY_STRING, - &OPAL_PROC_MY_NAME, &loc, OPAL_STRING); + &OPAL_PROC_MY_NAME, &loc, PMIX_STRING); if (OPAL_SUCCESS == rc) { if (NULL == loc) { mca_btl_smcuda_component.mem_node = my_mem_node = -1; diff --git a/test/simple/interlib.c b/test/simple/interlib.c index 5cee48bf11f..fefec2b2385 100644 --- a/test/simple/interlib.c +++ b/test/simple/interlib.c @@ -42,7 +42,7 @@ static void model_callback(int status, 0 == strcmp(val->data.string, "OpenMP")) { goto cback; } - if (OPAL_STRING == val->type) { + if (PMIX_STRING == val->type) { opal_output(0, "Thread Model Callback Key: %s Val %s", val->key, val->data.string); } } @@ -99,22 +99,22 @@ static void *mylib(void *ptr) OBJ_CONSTRUCT(&info, opal_list_t); kv = OBJ_NEW(opal_value_t); kv->key = strdup(OPAL_PMIX_PROGRAMMING_MODEL); - kv->type = OPAL_STRING; + kv->type = PMIX_STRING; kv->data.string = strdup("OpenMP"); opal_list_append(&info, &kv->super); kv = OBJ_NEW(opal_value_t); kv->key = strdup(OPAL_PMIX_MODEL_LIBRARY_NAME); - kv->type = OPAL_STRING; + kv->type = PMIX_STRING; kv->data.string = strdup("foobar"); opal_list_append(&info, &kv->super); kv = OBJ_NEW(opal_value_t); kv->key = strdup(OPAL_PMIX_MODEL_LIBRARY_VERSION); - kv->type = OPAL_STRING; + kv->type = PMIX_STRING; kv->data.string = strdup("1.2.3.4"); opal_list_append(&info, &kv->super); kv = OBJ_NEW(opal_value_t); kv->key = strdup(OPAL_PMIX_THREADING_MODEL); - kv->type = OPAL_STRING; + kv->type = PMIX_STRING; kv->data.string = strdup("PTHREAD"); opal_list_append(&info, &kv->super); @@ -150,7 +150,7 @@ static void *mylib(void *ptr) OBJ_CONSTRUCT(&directives, opal_list_t); kv = OBJ_NEW(opal_value_t); kv->key = strdup(OPAL_PMIX_EVENT_HDLR_NAME); - kv->type = OPAL_STRING; + kv->type = PMIX_STRING; kv->data.string = strdup("My-Declarations"); opal_list_append(&directives, &kv->super); /* specify the event code */ @@ -248,7 +248,7 @@ int main(int argc, char* argv[]) /* push something the thread can recognize */ OBJ_CONSTRUCT(&kv, opal_value_t); kv.key = strdup("WASSUP"); - kv.type = OPAL_STRING; + kv.type = PMIX_STRING; kv.data.string = strdup("nothing"); opal_pmix.put(OPAL_PMIX_LOCAL, &kv); OBJ_DESTRUCT(&kv); @@ -276,7 +276,7 @@ int main(int argc, char* argv[]) OBJ_CONSTRUCT(&list, opal_list_t); kptr = OBJ_NEW(opal_value_t); kptr->key = strdup("SOMETHING"); - kptr->type = OPAL_STRING; + kptr->type = PMIX_STRING; kptr->data.string = strdup("SILLY-THING"); opal_list_append(&list, &kptr->super); opal_pmix.publish(&list); From aaffafc75bbe5f2732b1234ed6a6c4ba0deb84f0 Mon Sep 17 00:00:00 2001 From: Aboorva Devarajan Date: Wed, 24 Feb 2021 05:53:41 -0500 Subject: [PATCH 25/40] pml/ob1: fix build issue in CUDA path https://github.com/open-mpi/ompi/commit/916c29a21a35b0f48e101da2de02076e9b6365b5 Signed-off-by: Aboorva Devarajan --- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 8f3dfeece3e..1b798125c4b 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -731,7 +731,7 @@ void mca_pml_ob1_recv_request_progress_rget( mca_pml_ob1_recv_request_t* recvreq } } else { /* Just default back to send and receive. Must be mix of GPU and HOST memory. */ - mca_pml_ob1_recv_request_ack(recvreq, &hdr->hdr_rndv, 0); + mca_pml_ob1_recv_request_ack(recvreq, btl, &hdr->hdr_rndv, 0); return; } } From 809c51acd2bb798dc8fe0c2851b313dd78f5f98d Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Wed, 24 Feb 2021 16:59:19 -0800 Subject: [PATCH 26/40] Update PRRTE Signed-off-by: Ralph Castain --- 3rd-party/prrte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rd-party/prrte b/3rd-party/prrte index be5dcbdbe50..890d2f16ed9 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit be5dcbdbe50a99b9711b0dd1432c54fceea3ec4b +Subproject commit 890d2f16ed9cfcf1c1279ba9688befbd9f7d2811 From 6a8b2936c33b6cb44c9f3a60f61e8451b21dc026 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Thu, 25 Feb 2021 08:09:00 -0800 Subject: [PATCH 27/40] Replace opal_status_t with pmix_status_t Fix build of opal/common/ofi component Signed-off-by: Ralph Castain --- opal/mca/common/ofi/common_ofi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opal/mca/common/ofi/common_ofi.c b/opal/mca/common/ofi/common_ofi.c index f6dc9762cde..3630aaec5ce 100644 --- a/opal/mca/common/ofi/common_ofi.c +++ b/opal/mca/common/ofi/common_ofi.c @@ -5,6 +5,7 @@ * Copyright (c) 2020 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2020 Cisco Systems, Inc. All rights reserved + * Copyright (c) 2021 Nanook Consulting. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -304,7 +305,7 @@ static uint32_t get_package_rank(opal_process_info_t *process_info) uint16_t current_package_rank = 0; uint16_t package_ranks[process_info->num_local_peers]; opal_process_name_t pname; - opal_status_t rc; + pmix_status_t rc; char **peers = NULL; char *local_peers = NULL; char *locality_string = NULL; From e3a7cbea7241d220a2804badac57bcc275bd437a Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Thu, 25 Feb 2021 08:16:57 -0800 Subject: [PATCH 28/40] Use correct buffer release macro The buffer being released is a PMIx data buffer and not an OMPI object Signed-off-by: Ralph Castain --- ompi/communicator/comm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ompi/communicator/comm.c b/ompi/communicator/comm.c index 4277d67acca..3240f3db346 100644 --- a/ompi/communicator/comm.c +++ b/ompi/communicator/comm.c @@ -1653,7 +1653,7 @@ int ompi_comm_get_rprocs ( ompi_communicator_t *local_comm, #endif goto err_exit; } - OBJ_RELEASE(sbuf); + PMIX_DATA_BUFFER_RELEASE(sbuf); } /* broadcast name list to all proceses in local_comm */ From 73c626af95c2c36de53a3b66d936fdb33e562bae Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Wed, 24 Feb 2021 19:59:20 -0800 Subject: [PATCH 29/40] build: Support building against external PRRTE For reasons that no one can remember, we decided to not support building against an external PRRTE. The only integration between OMPI and PRTTE that isn't through the PMIx interface is the symlinks for mpirun/mpiexec/oshrun. To make it easier to package Open MPI for distros, add support for using an external PRRTE. Signed-off-by: Brian Barrett --- config/ompi_setup_prrte.m4 | 257 ++++++++++++++++++++++++---------- ompi/tools/mpirun/Makefile.am | 8 +- 2 files changed, 189 insertions(+), 76 deletions(-) diff --git a/config/ompi_setup_prrte.m4 b/config/ompi_setup_prrte.m4 index f36120808c3..4089b412b27 100644 --- a/config/ompi_setup_prrte.m4 +++ b/config/ompi_setup_prrte.m4 @@ -1,62 +1,121 @@ -# -*- shell-script -*- -# -# Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana -# University Research and Technology -# Corporation. All rights reserved. -# Copyright (c) 2004-2021 The University of Tennessee and The University -# of Tennessee Research Foundation. All rights -# reserved. -# Copyright (c) 2004-2007 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) 2006-2009 Cisco Systems, Inc. All rights reserved. -# Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved. -# Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights -# reserved. -# Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. -# Copyright (c) 2019-2020 Intel, Inc. All rights reserved. -# Copyright (c) 2020 Amazon.com, Inc. or its affiliates. -# All Rights reserved. -# Copyright (c) 2021 Nanook Consulting. All rights reserved. -# $COPYRIGHT$ -# -# Additional copyrights may follow -# -# $HEADER$ -# - -# Check for / configure PRRTE package. Unlike the other 3rd party -# packages, prrte is either internal or not used (since prrte is a -# pmix server, we don't need to link against it or such in the -# external case). So we don't have to do some of the complex steps we -# do for pmix or hwloc in terms of external hunting. -# -# This macro will not change the environment. -# -# A Makefile conditional OMPI_WANT_PRRTE will be defined based on the -# results of the build. Unless --disable-internal-rte is specified, -# the top-level configure will abort if the PRRTE configure fails. +dnl -*- autoconf -*- +dnl +dnl Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana +dnl University Research and Technology +dnl Corporation. All rights reserved. +dnl Copyright (c) 2004-2021 The University of Tennessee and The University +dnl of Tennessee Research Foundation. All rights +dnl reserved. +dnl Copyright (c) 2004-2007 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) 2006-2009 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved. +dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights +dnl reserved. +dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. +dnl Copyright (c) 2019-2020 Intel, Inc. All rights reserved. +dnl Copyright (c) 2020 Amazon.com, Inc. or its affiliates. +dnl All Rights reserved. +dnl Copyright (c) 2021 Nanook Consulting. All rights reserved. +dnl $COPYRIGHT$ +dnl +dnl Additional copyrights may follow +dnl +dnl $HEADER$ +dnl + +dnl Check for / configure PRRTE package. Prefer finding an external +dnl PRRTE, build our internal one if required. If we can not find an +dnl external PRRTE and the internal one fails to configure, abort. +dnl +dnl This macro wil change the environment in the following way: +dnl +dnl * PRTE_PATH will be AC_SUBST'ed to the full path (minus the EXE +dnl extension) of the prte binary. +dnl +dnl A Makefile conditional OMPI_WANT_PRRTE will be defined based on the +dnl results of the build. AC_DEFUN([OMPI_SETUP_PRRTE],[ - OPAL_VAR_SCOPE_PUSH([internal_prrte_build]) + OPAL_VAR_SCOPE_PUSH([prrte_setup_internal_happy prrte_setup_external_happy prrte_setup_success_var]) + + opal_show_subtitle "Configuring PRRTE" - internal_prrte_build=0 + # Don't use OPAL_3RDPARTY_WITH because it will not allow packages + # to be disabled m4_ifdef([package_prrte], - [OMPI_SETUP_PRRTE_INTERNAL([internal_prrte_build=1], [internal_prrte_build=0])]) + [AC_ARG_WITH([prrte], + [AC_HELP_STRING([--with-prrte(=DIR)], + [Build PRTE support. DIR can take one of four values: "internal", "external", "no", or a valid directory name. "internal" forces Open MPI to use its internal copy of PRRTE. "external" forces Open MPI to use an external installation of PRRTE. Supplying a valid directory name also forces Open MPI to use an external installation of PRRTE, and adds DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries. If no argument is specified, Open MPI will search default locations for PRRTE and fall back to an internal version if one is not found.])])], + [AC_ARG_WITH([prrte], + [AC_HELP_STRING([--with-prrte(=DIR)], + [Build PRRTE support. DIR can take one of three values: "external", "no", or a valid directory name. "external" forces Open MPI to use an external installation of PRRTE. Supplying a valid directory name also forces Open MPI to use an external installation of PRRTE, and adds DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries. If no argument is specified, Open MPI will search default locations for PRRTE and disable creating mpirun symlinks if one is not found.])])]) + + # clean up $with_prrte so that it contains only a path or empty + # string. To determine internal or external preferences, use + # $opal_prrte_mode. + AS_IF([test "$with_prrte" = "yes"], [with_prrte=]) + AS_CASE([$with_prrte], + ["internal"], [with_prrte="" + opal_prrte_mode="internal"], + ["external"], [with_prrte="" + opal_prrte_mode="external"], + [""], [opal_prrte_mode="unspecified"], + ["no"], [opal_prrte_mode="disabled"], + [opal_prrte_mode="external"]) + + echo "with_prrte: $with_prrte" + echo "opal_prrte_mode: $opal_prrte_mode" + + m4_ifdef([package_prrte], [], + [AS_IF([test "$opal_prrte_mode" = "internal"], + [AC_MSG_WARN([Invalid argument to --with-prrte: internal.]) + AC_MSG_ERROR([Cannot continue])])]) + + prrte_setup_internal_happy=0 + m4_ifdef([package_prrte], [ + # always configure the internal prrte, so that + # make dist always works. + AS_IF([test "$opal_prrte_mode" = "disabled"], [prrte_setup_success_var=0], [prrte_setup_success_var=1]) + _OMPI_SETUP_PRRTE_INTERNAL([prrte_setup_internal_happy=$prrte_setup_success_var])]) + + # unless internal specifically requested by the user, try to find + # an external that works. + prrte_setup_external_happy=0 + AS_IF([test "$opal_prrte_mode" != "internal" -o "$opal_prrte_mode" != "disabled"], + [_OMPI_SETUP_PRRTE_EXTERNAL( + [prrte_setup_external_happy=1 + opal_prrte_mode="external"], + [AS_IF([test "$opal_prrte_mode" = "external"], + [AC_MSG_ERROR([External PRRTE requested but not found.])])])]) + + # external did not work out and customer did not specify external, + # so try the internal version. + AS_IF([test "$prrte_setup_external_happy" = "0" -a "$prrte_setup_internal_happy" = "1"], + [opal_prrte_mode="internal" + _OMPI_SETUP_PRRTE_INTERNAL_POST()]) - AM_CONDITIONAL([OMPI_WANT_PRRTE], [test "$internal_prrte_build" = "1"]) + AS_IF([test "$opal_prrte_mode" != "disabled"], + [AS_IF([test "$prrte_setup_external_happy" = "0" -a "$prrte_setup_internal_happy" = "0"], + [AC_MSG_ERROR([Could not find viable prrte build.])])]) + + AC_SUBST([PRTE_PATH]) + + AM_CONDITIONAL([OMPI_WANT_PRRTE], + [test "$prrte_setup_internal_happy" = "1" -o "$prrte_setup_external_happy" = "1"]) + + OPAL_SUMMARY_ADD([[Miscellaneous]], [[prrte]], [prrte], [$opal_prrte_mode]) OPAL_VAR_SCOPE_POP ]) -AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [ - OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_extra_libs internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS]) - opal_show_subtitle "Configuring PRRTE" - - AC_ARG_ENABLE([internal-rte], - [AC_HELP_STRING([--enable-internal-rte], - [Enable internal runtime support and provide mpiexec/mpirun (default: enabled)])]) +dnl _OMPI_SETUP_PRRTE_INTERNAL([action-if-success], [action-if-not-success]) +dnl +dnl Attempt to configure the built-in PRRTE. +AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL], [ + OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_extra_libs internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS]) # This is really a PRTE option that should not be in Open MPI, but # there is not a great way to support the orterun/mpirun checks @@ -88,10 +147,6 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [ AS_IF([test -n "$prte_prefix_by_default" -a -n "$deprecated_prefix_by_default"], [AC_MSG_ERROR([--enable-prte-prefix-by-default cannot be used with --enable-mpirun-prefix-by-default or --enable-orterun-prefix-by-default. Please only specify --enable-prte-prefix-by-default.])]) - internal_prrte_happy="yes" - AS_IF([test "$enable_internal_rte" = "no"], - [internal_prrte_happy="no"]) - internal_prrte_CPPFLAGS= internal_prrte_args="--with-proxy-version-string=$OPAL_VERSION --with-proxy-package-name=\"Open MPI\" --with-proxy-bugreport=\"https://www.open-mpi.org/community/help/\"" internal_prrte_libs= @@ -120,23 +175,22 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [ internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_pmix_CPPFLAGS" internal_prrte_libs="$internal_prrte_libs $opal_pmix_LIBS"]) - AS_IF([test "$internal_prrte_happy" = "yes"], - [AC_MSG_CHECKING([if PMIx version is 4.0.0 or greater]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[ + AC_MSG_CHECKING([if PMIx version is 4.0.0 or greater]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ #if PMIX_VERSION_MAJOR < 4L #error "pmix API version is less than 4.0.0" #endif - ]])], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AC_MSG_WARN([OMPI's internal runtime environment "PRRTE" does not support]) - AC_MSG_WARN([PMIx versions less than v4.x as they lack adequate tool]) - AC_MSG_WARN([support. You can, if desired, build OMPI against an earlier]) - AC_MSG_WARN([version of PMIx for strictly direct-launch purposes - e.g., using)]) - AC_MSG_WARN([Slurm's srun to launch the job - by configuring with the]) - AC_MSG_WARN([--disable-internal-rte option.]) - AC_MSG_ERROR([Cannot continue])])]) + ]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_WARN([OMPI's internal runtime environment "PRRTE" does not support]) + AC_MSG_WARN([PMIx versions less than v4.x as they lack adequate tool]) + AC_MSG_WARN([support. You can, if desired, build OMPI against an earlier]) + AC_MSG_WARN([version of PMIx for strictly direct-launch purposes - e.g., using]) + AC_MSG_WARN([Slurm's srun to launch the job - by configuring with the]) + AC_MSG_WARN([--without-prrte option.]) + AC_MSG_ERROR([Cannot continue])]) # add the extra libs internal_prrte_args="$internal_prrte_args --with-prte-extra-lib=\"$internal_prrte_libs\" --with-prte-extra-ltlib=\"$internal_prrte_libs\"" @@ -160,7 +214,7 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [ [--with-libevent=external], [--with-hwloc=external], [--with-pmix=internal], [--with-pmix=external], [--with-platform=[[^ ]]*]], - [], [internal_prrte_happy="no"]) + [internal_prrte_happy="yes"], [internal_prrte_happy="no"]) OPAL_SUBDIR_ENV_RESTORE([opal_prrte_configure]) OPAL_3RDPARTY_DIST_SUBDIRS="$OPAL_3RDPARTY_DIST_SUBDIRS prrte" @@ -168,11 +222,68 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [ [AC_MSG_ERROR([PRRTE configuration failed. Cannot continue.])]) AS_IF([test "$internal_prrte_happy" = "yes"], - [OPAL_3RDPARTY_SUBDIRS="$OPAL_3RDPARTY_SUBDIRS prrte" - $1], - [$2]) + [$1], [$2]) - OPAL_SUMMARY_ADD([[Miscellaneous]], [[PRRTE]], [prrte], [$internal_prrte_happy]) + OPAL_VAR_SCOPE_POP +]) + + +dnl _OMPI_SETUP_CONFIG_PRRTE_INTERNAL_POST() +dnl +dnl Expectation is that this is called only if external fails, the +dnl caller configured libprrte configure, and the configure script +dnl succeeded. +AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL_POST], [ + OPAL_3RDPARTY_SUBDIRS="$OPAL_3RDPARTY_SUBDIRS prrte" + + PRTE_PATH="prte" +]) + + +dnl _OMPI_SETUP_PRRTE_EXTERNAL([action if success], [action if not success]) +dnl +dnl Try to find an external prrte with sufficient version. Since we +dnl don't link against prrte, only output environment variable is +dnl PRTE_PATH. +AC_DEFUN([_OMPI_SETUP_PRRTE_EXTERNAL], [ + OPAL_VAR_SCOPE_PUSH([setup_prrte_external_happy opal_prrte_CPPFLAGS_save]) + + opal_prrte_CPPFLAGS_save=$CPPFLAGS + + _OPAL_CHECK_PACKAGE_HEADER([opal_prrte], [prte.h], [$with_prrte], + [setup_prrte_external_happy=yes], + [setup_prrte_external_happy=no]) + + CPPFLAGS="$opal_prrte_CPPFLAGS_save $opal_prrte_CPPFLAGS" + + AC_MSG_CHECKING([if external PRRTE version is 2.0.0 or greater]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ +#if PRTE_NUMERIC_VERSION < 0x00020000 +#error "prrte API version is less than 2.0.0" +#endif + ]])], + [AC_MSG_RESULT([yes]) + setup_prrte_external_happy=yes], + [AC_MSG_RESULT([no]) + setup_prrte_external_happy=no]) + + CPPFLAGS="$opal_prrte_CPPFLAGS_save" + + AS_IF([test "$setup_prrte_external_happy" = "yes"], + [AS_IF([test -n "$with_prrte"], + [PRTE_PATH="${with_prrte}/bin/prte" + AS_IF([test ! -r ${PRTE_PATH}], [AC_MSG_ERROR([Could not find prte binary at $PRTE_PATH])])], + [PRTE_PATH="" + OPAL_WHICH([prte], [PRTE_PATH]) + AS_IF([tets -z "$PRTE_PATH"], + [AC_MSG_WARN([Could not find prte in PATH]) + setup_prrte_external_happy=no])])]) + + AS_IF([test "$setup_prrte_external_happy" = "yes"], + [$1], [$2]) OPAL_VAR_SCOPE_POP ]) + + diff --git a/ompi/tools/mpirun/Makefile.am b/ompi/tools/mpirun/Makefile.am index 732607e36ca..bcbc90fe95a 100644 --- a/ompi/tools/mpirun/Makefile.am +++ b/ompi/tools/mpirun/Makefile.am @@ -1,6 +1,8 @@ # # Copyright (c) 2019-2020 Intel, Inc. All rights reserved. # Copyright (c) 2020 IBM Corporation. All rights reserved. +# Copyright (c) 2021 Amazon.com, Inc. or its affiliates. +# All Rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -10,9 +12,9 @@ if OMPI_WANT_PRRTE install-exec-hook: - (cd $(DESTDIR)$(bindir); rm -f mpirun$(EXEEXT); $(LN_S) prte$(EXEEXT) mpirun$(EXEEXT)) - (cd $(DESTDIR)$(bindir); rm -f mpiexec$(EXEEXT); $(LN_S) prte$(EXEEXT) mpiexec$(EXEEXT)) - (cd $(DESTDIR)$(bindir); rm -f oshrun$(EXEEXT); $(LN_S) prte$(EXEEXT) oshrun$(EXEEXT)) + (cd $(DESTDIR)$(bindir); rm -f mpirun$(EXEEXT); $(LN_S) $(PRTE_PATH)$(EXEEXT) mpirun$(EXEEXT)) + (cd $(DESTDIR)$(bindir); rm -f mpiexec$(EXEEXT); $(LN_S) $(PRTE_PATH)$(EXEEXT) mpiexec$(EXEEXT)) + (cd $(DESTDIR)$(bindir); rm -f oshrun$(EXEEXT); $(LN_S) $(PRTE_PATH)$(EXEEXT) oshrun$(EXEEXT)) uninstall-local: rm -f $(DESTDIR)$(bindir)/mpirun$(EXEEXT) \ From fad0630e43954b865a5f9d9836b26c8fb95ec0ce Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Fri, 26 Feb 2021 07:45:39 -0800 Subject: [PATCH 30/40] Update PRRTE pointer Signed-off-by: Ralph Castain --- 3rd-party/prrte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rd-party/prrte b/3rd-party/prrte index 890d2f16ed9..477894f4720 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit 890d2f16ed9cfcf1c1279ba9688befbd9f7d2811 +Subproject commit 477894f4720d822b15cab56eee7665107832921c From 22f773e166797ad1a8a5abca2b537eebcdcf7f5c Mon Sep 17 00:00:00 2001 From: Yaz Saito Date: Thu, 25 Feb 2021 16:27:06 -0800 Subject: [PATCH 31/40] Fix a crash during CUDA initialization From a valgrind log: ``` ==2935008== Conditional jump or move depends on uninitialised value(s) ==2935008== at 0x54D70D5: pmix_bfrops_base_value_unload (bfrop_base_fns.c:358) ==2935008== by 0x54D61CB: pmix_value_unload (bfrop_base_fns.c:49) ==2935008== by 0x527BBD2: smcuda_btl_first_time_init (btl_smcuda.c:269) ==2935008== by 0x527CA5F: mca_btl_smcuda_add_procs (btl_smcuda.c:597) ==2935011== Conditional jump or move depends on uninitialised value(s) ==2935011== at 0x54D70D5: pmix_bfrops_base_value_unload (bfrop_base_fns.c:358) ==2935008== by 0x4F0CB95: mca_bml_r2_add_procs (bml_r2.c:526) ==2935008== by 0x50B04A4: mca_pml_ob1_add_procs (pml_ob1.c:343) ==2935008== by 0x4E75867: ompi_mpi_init (ompi_mpi_init.c:853) ==2935008== by 0x4EC4B30: PMPI_Init (pinit.c:67) ==2935011== by 0x54D61CB: pmix_value_unload (bfrop_base_fns.c:49) ==2935011== by 0x527BBD2: smcuda_btl_first_time_init (btl_smcuda.c:269) ==2935011== by 0x527CA5F: mca_btl_smcuda_add_procs (btl_smcuda.c:597) ==2935011== by 0x4F0CB95: mca_bml_r2_add_procs (bml_r2.c:526) ==2935010== Conditional jump or move depends on uninitialised value(s) ==2935010== at 0x54D70D5: pmix_bfrops_base_value_unload (bfrop_base_fns.c:358) ==2935010== by 0x54D61CB: pmix_value_unload (bfrop_base_fns.c:49) ==2935010== by 0x52927D4: opal_hwloc_base_get_topology (hwloc_base_util.c:316) ==2935010== by 0x5280A4B: mca_btl_smcuda_component_init (btl_smcuda_component.c:882) ==2935010== by 0x526C3F5: mca_btl_base_select (btl_base_select.c:110) ==2935010== by 0x4F0DEC5: mca_bml_r2_component_init (bml_r2_component.c:88) ==2935010== by 0x4F0B3A9: mca_bml_base_init (bml_base_init.c:74) ==2935010== by 0x4E7521E: ompi_mpi_init (ompi_mpi_init.c:609) ==2935010== by 0x4EC4B30: PMPI_Init (pinit.c:67) ``` Signed-off-by: Yaz Saito --- ompi/proc/proc.c | 2 +- opal/mca/btl/smcuda/btl_smcuda.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ompi/proc/proc.c b/ompi/proc/proc.c index 1f4d39cb504..177708f87b7 100644 --- a/ompi/proc/proc.c +++ b/ompi/proc/proc.c @@ -304,7 +304,7 @@ int ompi_proc_complete_init(void) opal_process_name_t wildcard_rank; ompi_proc_t *proc; int ret, errcode = OMPI_SUCCESS; - char *val; + char *val = NULL; opal_mutex_lock (&ompi_proc_lock); diff --git a/opal/mca/btl/smcuda/btl_smcuda.c b/opal/mca/btl/smcuda/btl_smcuda.c index d6784d07c9b..ec1af945ba4 100644 --- a/opal/mca/btl/smcuda/btl_smcuda.c +++ b/opal/mca/btl/smcuda/btl_smcuda.c @@ -251,6 +251,7 @@ smcuda_btl_first_time_init(mca_btl_smcuda_t *smcuda_btl, free(loc); } else { /* If we have hwloc support, then get accurate information */ + loc = NULL; if (OPAL_SUCCESS == opal_hwloc_base_get_topology()) { i = opal_hwloc_base_get_nbobjs_by_type(opal_hwloc_topology, HWLOC_OBJ_NODE, 0, From e167a645835cebecdb0ae6587eb0285fda8d29b7 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 27 Feb 2021 12:21:53 -0800 Subject: [PATCH 32/40] ompi/proc: fix compile errors OPAL_UINT32 --> PMIX_UINT32 Signed-off-by: Jeff Squyres --- ompi/proc/proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ompi/proc/proc.c b/ompi/proc/proc.c index 177708f87b7..e10068514a3 100644 --- a/ompi/proc/proc.c +++ b/ompi/proc/proc.c @@ -154,7 +154,7 @@ int ompi_proc_complete_init_single (ompi_proc_t *proc) } else { ui32ptr = &(proc->super.proc_arch); OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, "OMPI_ARCH", &proc->super.proc_name, - (void**)&ui32ptr, OPAL_UINT32); + (void**)&ui32ptr, PMIX_UINT32); if (OPAL_SUCCESS == ret) { /* if arch is different than mine, create a new convertor for this proc */ if (proc->super.proc_arch != opal_local_arch) { @@ -267,7 +267,7 @@ int ompi_proc_init(void) #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT /* add our arch to the modex */ OPAL_MODEX_SEND_VALUE(ret, PMIX_GLOBAL, - "OMPI_ARCH", &opal_local_arch, OPAL_UINT32); + "OMPI_ARCH", &opal_local_arch, PMIX_UINT32); if (OPAL_SUCCESS != ret) { return ret; } From 9a68bf6577e9e1b804474cd0afaf36d27bde3d9a Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 27 Feb 2021 12:40:17 -0800 Subject: [PATCH 33/40] pml ob1: fix peruse typo Signed-off-by: Jeff Squyres --- ompi/mca/pml/ob1/pml_ob1_recvreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ompi/mca/pml/ob1/pml_ob1_recvreq.c b/ompi/mca/pml/ob1/pml_ob1_recvreq.c index 1b798125c4b..362967e3e07 100644 --- a/ompi/mca/pml/ob1/pml_ob1_recvreq.c +++ b/ompi/mca/pml/ob1/pml_ob1_recvreq.c @@ -1308,7 +1308,7 @@ void mca_pml_ob1_recv_req_start(mca_pml_ob1_recv_request_t *req) req->req_recv.req_base.req_peer, req->req_recv.req_base.req_tag, comm_ptr->c_contextid)); req->req_recv.req_base.req_ompi.req_status.MPI_ERROR = ompi_comm_is_revoked(comm_ptr)? MPI_ERR_REVOKED: MPI_ERR_PROC_FAILED; recv_request_pml_complete( req ); - PERUSE_TRACE_COMM_EVENT(PERSUSE_COMM_SEARCH_UNEX_Q_END, + PERUSE_TRACE_COMM_EVENT(PERUSE_COMM_SEARCH_UNEX_Q_END, &(req->req_recv.req_base), PERUSE_RECV); OB1_MATCHING_UNLOCK(&ob1_comm->matching_lock); return; From a3f62aa223ce10f35acaf365bf6d7d3b35b97070 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Mon, 1 Mar 2021 14:10:11 -0800 Subject: [PATCH 34/40] Update PRRTE pointer to fix HLRS Signed-off-by: Ralph Castain --- 3rd-party/prrte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rd-party/prrte b/3rd-party/prrte index 477894f4720..1b0b100d9d6 160000 --- a/3rd-party/prrte +++ b/3rd-party/prrte @@ -1 +1 @@ -Subproject commit 477894f4720d822b15cab56eee7665107832921c +Subproject commit 1b0b100d9d6de74e5aa7a5e2db7ddcb979558cc8 From 73f29268b3c407696eb7776d731784478adcb858 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 2 Mar 2021 13:05:34 -0500 Subject: [PATCH 35/40] git-commit-checks: use a better name Github shows both the "outer" and "inner" names on the CI line in the Github web UI, so make sure to give good names for both. Signed-off-by: Jeff Squyres --- .github/workflows/git-commit-checks.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/git-commit-checks.yml b/.github/workflows/git-commit-checks.yml index 6ea5355d422..4cf1036878e 100644 --- a/.github/workflows/git-commit-checks.yml +++ b/.github/workflows/git-commit-checks.yml @@ -1,4 +1,4 @@ -name: Git commit checker +name: GitHub Action CI on: pull_request: @@ -11,6 +11,7 @@ on: jobs: ci: + name: Git commit checker runs-on: ubuntu-latest steps: - name: Check out the code From 9ca8d4919604a02895ed464d1c4b42418b6ea888 Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Tue, 2 Mar 2021 14:37:24 -0500 Subject: [PATCH 36/40] Add blurb about --disable-manpages to pandoc configure error. Signed-off-by: Austen Lauria --- config/opal_setup_man_pages.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/opal_setup_man_pages.m4 b/config/opal_setup_man_pages.m4 index 585fc298152..a064f3cf880 100644 --- a/config/opal_setup_man_pages.m4 +++ b/config/opal_setup_man_pages.m4 @@ -67,9 +67,10 @@ AC_DEFUN([_OPAL_SETUP_PANDOC],[ AS_IF([test -z "$PANDOC" || test -n "`echo $PANDOC | $GREP missing`"], [AS_IF([test ! -f "$srcdir/ompi/mpi/man/man5/MPI_T.5"], [AC_MSG_WARN([*** Could not find a suitable pandoc on your system.]) - AC_MSG_WARN([*** You need pandoc >=$min_major_version.$min_minor_version to build Open MPI man pages.]) + AC_MSG_WARN([*** You need pandoc >=$min_major_version.$min_minor_version to build Open MPI with man pages.]) + AC_MSG_WARN([*** If no man pages are needed, rerun configure with option '--disable-manpages'.]) + AC_MSG_WARN([*** NOTE: If you are building from a tarball downloaded from www.open-mpi.org, you do not need Pandoc.]) AC_MSG_WARN([*** See pandoc.org.]) - AC_MSG_WARN([*** NOTE: If you are building from a tarball downloaded from www.open-mpi.org, you do not need Pandoc]) AC_MSG_ERROR([Cannot continue]) ]) ]) From 562c57ce97cd40fb3e3c795fcc65200c737fe7ca Mon Sep 17 00:00:00 2001 From: Yossi Itigin Date: Thu, 18 Feb 2021 00:15:02 +0200 Subject: [PATCH 37/40] ucx: check supported transports and devices for setting priority Add "pml_ucx_tls" parameter to control the transports to include or exclude (with a '^' prefix). UCX will be enabled only if one of the included transports is present, or if a non-excluded transport is present (in case of exclude-list with a '^' prefix). Add "pml_ucx_devices" parameter to control the devices which make UCX component set a high priority for itself. If none of the listed devices is present, the priority will be set to 19 - lower than ob1 priority. Signed-off-by: Yossi Itigin --- contrib/platform/mellanox/optimized.conf | 2 + ompi/mca/pml/ucx/pml_ucx_component.c | 15 +- opal/mca/common/ucx/common_ucx.c | 202 ++++++++++++++++++++++- opal/mca/common/ucx/common_ucx.h | 15 ++ opal/mca/common/ucx/configure.m4 | 2 + 5 files changed, 234 insertions(+), 2 deletions(-) diff --git a/contrib/platform/mellanox/optimized.conf b/contrib/platform/mellanox/optimized.conf index b86b37c9e2f..543fd8d1e22 100644 --- a/contrib/platform/mellanox/optimized.conf +++ b/contrib/platform/mellanox/optimized.conf @@ -61,6 +61,8 @@ coll = ^ml hwloc_base_binding_policy = core btl = self +pml_ucx_tls = any +pml_ucx_devices = any # Basic behavior to smooth startup mca_base_component_show_load_errors = 0 orte_abort_timeout = 10 diff --git a/ompi/mca/pml/ucx/pml_ucx_component.c b/ompi/mca/pml/ucx/pml_ucx_component.c index 28b00fee4f1..91fd188907c 100644 --- a/ompi/mca/pml/ucx/pml_ucx_component.c +++ b/ompi/mca/pml/ucx/pml_ucx_component.c @@ -92,13 +92,26 @@ static mca_pml_base_module_t* mca_pml_ucx_component_init(int* priority, bool enable_progress_threads, bool enable_mpi_threads) { + opal_common_ucx_support_level_t support_level; int ret; + support_level = opal_common_ucx_support_level(ompi_pml_ucx.ucp_context); + if (support_level == OPAL_COMMON_UCX_SUPPORT_NONE) { + return NULL; + } + if ( (ret = mca_pml_ucx_init(enable_mpi_threads)) != 0) { return NULL; } - *priority = ompi_pml_ucx.priority; + /* + * If found supported devices - set to the configured (high) priority. + * Otherwise - Found only supported transports (which could be exposed by + * unsupported devices), so set a priority lower than ob1. + */ + *priority = (support_level == OPAL_COMMON_UCX_SUPPORT_DEVICE) ? + ompi_pml_ucx.priority : 19; + PML_UCX_VERBOSE(2, "returning priority %d", *priority); return &ompi_pml_ucx.super; } diff --git a/opal/mca/common/ucx/common_ucx.c b/opal/mca/common/ucx/common_ucx.c index c25a32f993f..592044a7ccd 100644 --- a/opal/mca/common/ucx/common_ucx.c +++ b/opal/mca/common/ucx/common_ucx.c @@ -17,8 +17,11 @@ #include "opal/mca/base/mca_base_framework.h" #include "opal/mca/pmix/pmix-internal.h" #include "opal/memoryhooks/memory.h" +#include "opal/util/argv.h" #include +#include +#include /***********************************************************************/ @@ -28,7 +31,8 @@ opal_common_ucx_module_t opal_common_ucx = { .verbose = 0, .progress_iterations = 100, .registered = 0, - .opal_mem_hooks = 0 + .opal_mem_hooks = 0, + .tls = NULL }; static void opal_common_ucx_mem_release_cb(void *buf, size_t length, @@ -39,10 +43,15 @@ static void opal_common_ucx_mem_release_cb(void *buf, size_t length, OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *component) { + static const char *default_tls = "rc_verbs,ud_verbs,rc_mlx5,dc_mlx5,cuda_ipc,rocm_ipc"; + static const char *default_devices = "mlx*"; static int registered = 0; static int hook_index; static int verbose_index; static int progress_index; + static int tls_index; + static int devices_index; + if (!registered) { verbose_index = mca_base_var_register("opal", "opal_common", "ucx", "verbose", "Verbose level of the UCX components", @@ -63,6 +72,29 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t * OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_LOCAL, &opal_common_ucx.opal_mem_hooks); + + opal_common_ucx.tls = malloc(sizeof(*opal_common_ucx.tls)); + *opal_common_ucx.tls = strdup(default_tls); + tls_index = mca_base_var_register("opal", "opal_common", "ucx", "tls", + "List of UCX transports which should be supported on the system, to enable " + "selecting the UCX component. Special values: any (any available). " + "A '^' prefix negates the list. " + "For example, in order to exclude on shared memory and TCP transports, " + "please set to '^posix,sysv,self,tcp,cma,knem,xpmem'.", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, + opal_common_ucx.tls); + + opal_common_ucx.devices = malloc(sizeof(*opal_common_ucx.devices)); + *opal_common_ucx.devices = strdup(default_devices); + devices_index = mca_base_var_register("opal", "opal_common", "ucx", "devices", + "List of device driver pattern names, which, if supported by UCX, will " + "bump its priority above ob1. Special values: any (any available)", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, + OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_LOCAL, + opal_common_ucx.devices); registered = 1; } if (component) { @@ -78,6 +110,14 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t * component->mca_type_name, component->mca_component_name, "opal_mem_hooks", 0); + mca_base_var_register_synonym(tls_index, component->mca_project_name, + component->mca_type_name, + component->mca_component_name, + "tls", 0); + mca_base_var_register_synonym(devices_index, component->mca_project_name, + component->mca_type_name, + component->mca_component_name, + "devices", 0); } } @@ -126,6 +166,166 @@ OPAL_DECLSPEC void opal_common_ucx_mca_deregister(void) opal_output_close(opal_common_ucx.output); } +#if HAVE_DECL_OPEN_MEMSTREAM +static bool opal_common_ucx_check_device(const char *device_name, char **device_list) +{ + char sysfs_driver_link[PATH_MAX]; + char driver_path[PATH_MAX]; + char *ib_device_name; + char *driver_name; + char **list_item; + ssize_t ret; + + /* mlx5_0:1 */ + ret = sscanf(device_name, "%m[^:]%*d", &ib_device_name); + if (ret != 1) { + return false; + } + + sysfs_driver_link[sizeof(sysfs_driver_link) - 1] = '\0'; + snprintf(sysfs_driver_link, sizeof(sysfs_driver_link) - 1, + "/sys/class/infiniband/%s/device/driver", ib_device_name); + free(ib_device_name); + + driver_path[sizeof(driver_path) - 1] = '\0'; + ret = readlink(sysfs_driver_link, driver_path, sizeof(driver_path) - 1); + if (ret < 0) { + MCA_COMMON_UCX_VERBOSE(2, "readlink(%s) failed: %s", sysfs_driver_link, + strerror(errno)); + return false; + } + + driver_name = basename(driver_path); + for (list_item = device_list; *list_item != NULL; ++list_item) { + if (!fnmatch(*list_item, driver_name, 0)) { + MCA_COMMON_UCX_VERBOSE(2, "driver '%s' matched by '%s'", + driver_path, *list_item); + return true; + } + } + + return false; +} +#endif + +OPAL_DECLSPEC opal_common_ucx_support_level_t +opal_common_ucx_support_level(ucp_context_h context) +{ + opal_common_ucx_support_level_t support_level = OPAL_COMMON_UCX_SUPPORT_NONE; + static const char *support_level_names[] = { + [OPAL_COMMON_UCX_SUPPORT_NONE] = "none", + [OPAL_COMMON_UCX_SUPPORT_TRANSPORT] = "transports only", + [OPAL_COMMON_UCX_SUPPORT_DEVICE] = "transports and devices" + }; +#if HAVE_DECL_OPEN_MEMSTREAM + char *rsc_tl_name, *rsc_device_name; + char **tl_list, **device_list, **list_item; + bool is_any_tl, is_any_device; + bool found_tl, negate; + char line[128]; + FILE *stream; + char *buffer; + size_t size; + int ret; +#endif + + is_any_tl = !strcmp(*opal_common_ucx.tls, "any"); + is_any_device = !strcmp(*opal_common_ucx.devices, "any"); + + /* Check for special value "any" */ + if (is_any_tl && is_any_device) { + MCA_COMMON_UCX_VERBOSE(1, "ucx is enabled on any transport or device", + *opal_common_ucx.tls); + support_level = OPAL_COMMON_UCX_SUPPORT_DEVICE; + goto out; + } + +#if HAVE_DECL_OPEN_MEMSTREAM + /* Split transports list */ + negate = ('^' == (*opal_common_ucx.tls)[0]); + tl_list = opal_argv_split(*opal_common_ucx.tls + (negate ? 1 : 0), ','); + if (tl_list == NULL) { + MCA_COMMON_UCX_VERBOSE(1, "failed to split tl list '%s', ucx is disabled", + *opal_common_ucx.tls); + goto out; + } + + /* Split devices list */ + device_list = opal_argv_split(*opal_common_ucx.devices, ','); + if (device_list == NULL) { + MCA_COMMON_UCX_VERBOSE(1, "failed to split devices list '%s', ucx is disabled", + *opal_common_ucx.devices); + goto out_free_tl_list; + } + + /* Open memory stream to dump UCX information to */ + stream = open_memstream(&buffer, &size); + if (stream == NULL) { + MCA_COMMON_UCX_VERBOSE(1, "failed to open memory stream for ucx info (%s), " + "ucx is disabled", strerror(errno)); + goto out_free_device_list; + } + + /* Print ucx transports information to the memory stream */ + ucp_context_print_info(context, stream); + + /* Rewind and read transports/devices list from the stream */ + fseek(stream, 0, SEEK_SET); + while ((support_level != OPAL_COMMON_UCX_SUPPORT_DEVICE) && + (fgets(line, sizeof(line), stream) != NULL)) { + rsc_tl_name = NULL; + ret = sscanf(line, + /* "# resource 6 : md 5 dev 4 flags -- rc_verbs/mlx5_0:1" */ + "# resource %*d : md %*d dev %*d flags -- %m[^/ \n\r]/%m[^/ \n\r]", + &rsc_tl_name, &rsc_device_name); + if (ret != 2) { + free(rsc_tl_name); + continue; + } + + /* Check if 'rsc_tl_name' is found provided list */ + found_tl = is_any_tl; + for (list_item = tl_list; !found_tl && (*list_item != NULL); ++list_item) { + found_tl = !strcmp(*list_item, rsc_tl_name); + } + + /* Check if the transport has a match (either positive or negative) */ + assert(!(is_any_tl && negate)); + if (found_tl != negate) { + if (is_any_device || + opal_common_ucx_check_device(rsc_device_name, device_list)) { + MCA_COMMON_UCX_VERBOSE(2, "%s/%s: matched both transport and device list", + rsc_tl_name, rsc_device_name); + support_level = OPAL_COMMON_UCX_SUPPORT_DEVICE; + } else { + MCA_COMMON_UCX_VERBOSE(2, "%s/%s: matched transport list but not device list", + rsc_tl_name, rsc_device_name); + support_level = OPAL_COMMON_UCX_SUPPORT_TRANSPORT; + } + } else { + MCA_COMMON_UCX_VERBOSE(2, "%s/%s: did not match transport list", + rsc_tl_name, rsc_device_name); + } + + free(rsc_device_name); + free(rsc_tl_name); + } + + MCA_COMMON_UCX_VERBOSE(2, "support level is %s", support_level_names[support_level]); + fclose(stream); + free(buffer); + +out_free_device_list: + opal_argv_free(device_list); +out_free_tl_list: + opal_argv_free(tl_list); +out: +#else + MCA_COMMON_UCX_VERBOSE(2, "open_memstream() was not found, ucx is disabled"); +#endif + return support_level; +} + void opal_common_ucx_empty_complete_cb(void *request, ucs_status_t status) { } diff --git a/opal/mca/common/ucx/common_ucx.h b/opal/mca/common/ucx/common_ucx.h index 55324031bb1..a96ba24f2f5 100644 --- a/opal/mca/common/ucx/common_ucx.h +++ b/opal/mca/common/ucx/common_ucx.h @@ -96,6 +96,8 @@ typedef struct opal_common_ucx_module { int progress_iterations; int registered; bool opal_mem_hooks; + char **tls; + char **devices; } opal_common_ucx_module_t; typedef struct opal_common_ucx_del_proc { @@ -103,10 +105,23 @@ typedef struct opal_common_ucx_del_proc { size_t vpid; } opal_common_ucx_del_proc_t; +typedef enum { + /* No supported transports found (according to configured list of supported + transports) */ + OPAL_COMMON_UCX_SUPPORT_NONE, + + /* Have supported transports but not supported devices */ + OPAL_COMMON_UCX_SUPPORT_TRANSPORT, + + /* Have both supported transports and supported devices */ + OPAL_COMMON_UCX_SUPPORT_DEVICE, +} opal_common_ucx_support_level_t; + extern opal_common_ucx_module_t opal_common_ucx; OPAL_DECLSPEC void opal_common_ucx_mca_register(void); OPAL_DECLSPEC void opal_common_ucx_mca_deregister(void); +OPAL_DECLSPEC opal_common_ucx_support_level_t opal_common_ucx_support_level(ucp_context_h context); OPAL_DECLSPEC void opal_common_ucx_mca_proc_added(void); OPAL_DECLSPEC void opal_common_ucx_empty_complete_cb(void *request, ucs_status_t status); OPAL_DECLSPEC int opal_common_ucx_mca_pmix_fence(ucp_worker_h worker); diff --git a/opal/mca/common/ucx/configure.m4 b/opal/mca/common/ucx/configure.m4 index 27e07c2005b..af8628a889c 100644 --- a/opal/mca/common/ucx/configure.m4 +++ b/opal/mca/common/ucx/configure.m4 @@ -18,6 +18,8 @@ AC_DEFUN([MCA_opal_common_ucx_CONFIG],[ [common_ucx_happy="yes"], [common_ucx_happy="no"]) + AC_CHECK_DECLS([open_memstream], [], [], [[#include ]]) + AS_IF([test "$common_ucx_happy" = "yes"], [$1], [$2]) From 26dd34f636d97e02876a1b4bed7c9d7b3a2ac59b Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Tue, 9 Feb 2021 08:57:04 -0600 Subject: [PATCH 38/40] make the sharedfp/sm component pass the configure logic again. Signed-off-by: Edgar Gabriel --- ompi/mca/sharedfp/sm/configure.m4 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ompi/mca/sharedfp/sm/configure.m4 b/ompi/mca/sharedfp/sm/configure.m4 index 7224f15a93a..54b8648ce36 100644 --- a/ompi/mca/sharedfp/sm/configure.m4 +++ b/ompi/mca/sharedfp/sm/configure.m4 @@ -27,10 +27,16 @@ AC_DEFUN([MCA_ompi_sharedfp_sm_CONFIG],[ sharedfp_sm_happy=no AC_CHECK_HEADER([semaphore.h], - [AC_CHECK_FUNCS([sem_open],[sharedfp_sm_happy=yes],[])]) + [dnl requires potentially pthread library + OPAL_SEARCH_LIBS_COMPONENT([sharedfp_sm], + [sem_open], [pthread], + [sharedfp_sm_happy="yes"])]) AC_CHECK_HEADER([semaphore.h], - [AC_CHECK_FUNCS([sem_init],[sharedfp_sm_happy=yes],[])]) + [dnl requires potentially pthread library + OPAL_SEARCH_LIBS_COMPONENT([sharedfp_sm], + [sem_init], [pthread], + [sharedfp_sm_happy="yes"])]) AS_IF([test "$sharedfp_sm_happy" = "yes"], [$1], From 35911c55925376f3e1f9e10f352ea7561715c55e Mon Sep 17 00:00:00 2001 From: Shintaro Iwasaki Date: Tue, 2 Mar 2021 21:24:36 -0600 Subject: [PATCH 39/40] sharedfp/sm: fix configure to define HAVE_SEM_XXX HAVE_SEM_OPEN and HAVE_SEM_INIT are used by sharedfp/sm, but OPAL_SEARCH_LIBS_COMPONENT(), which works similarly to AC_CHECK_FUNCS(), does not define them. This patch adds AC_CHECK_FUNCS() to define those macros in opal_config.h. Signed-off-by: Shintaro Iwasaki --- ompi/mca/sharedfp/sm/configure.m4 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ompi/mca/sharedfp/sm/configure.m4 b/ompi/mca/sharedfp/sm/configure.m4 index 54b8648ce36..92e1a896924 100644 --- a/ompi/mca/sharedfp/sm/configure.m4 +++ b/ompi/mca/sharedfp/sm/configure.m4 @@ -30,14 +30,16 @@ AC_DEFUN([MCA_ompi_sharedfp_sm_CONFIG],[ [dnl requires potentially pthread library OPAL_SEARCH_LIBS_COMPONENT([sharedfp_sm], [sem_open], [pthread], - [sharedfp_sm_happy="yes"])]) - + [AC_CHECK_FUNCS([sem_open], + [sharedfp_sm_happy="yes"],[])] + )]) AC_CHECK_HEADER([semaphore.h], [dnl requires potentially pthread library OPAL_SEARCH_LIBS_COMPONENT([sharedfp_sm], [sem_init], [pthread], - [sharedfp_sm_happy="yes"])]) - + [AC_CHECK_FUNCS([sem_init], + [sharedfp_sm_happy="yes"],[])] + )]) AS_IF([test "$sharedfp_sm_happy" = "yes"], [$1], [$2]) From 42a6ccabeb09c95225829706fb8941071d79169c Mon Sep 17 00:00:00 2001 From: Shintaro Iwasaki Date: Tue, 2 Mar 2021 21:24:47 -0600 Subject: [PATCH 40/40] sharedfp/sm: update license of configure.m4 Signed-off-by: Shintaro Iwasaki --- ompi/mca/sharedfp/sm/configure.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ompi/mca/sharedfp/sm/configure.m4 b/ompi/mca/sharedfp/sm/configure.m4 index 92e1a896924..e6d52a9e69c 100644 --- a/ompi/mca/sharedfp/sm/configure.m4 +++ b/ompi/mca/sharedfp/sm/configure.m4 @@ -11,7 +11,9 @@ # Copyright (c) 2004-2012 The Regents of the University of California. # All rights reserved. # Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved. -# Copyright (c) 2008-2015 University of Houston. All rights reserved. +# Copyright (c) 2008-2021 University of Houston. All rights reserved. +# Copyright (c) 2021 Argonne National Laboratory. All rights +# reserved. # $COPYRIGHT$ # # Additional copyrights may follow