diff --git a/opal/mca/pmix/pmix4x/pmix/VERSION b/opal/mca/pmix/pmix4x/pmix/VERSION index f472bda640..6149d089f2 100644 --- a/opal/mca/pmix/pmix4x/pmix/VERSION +++ b/opal/mca/pmix/pmix4x/pmix/VERSION @@ -23,14 +23,14 @@ release=0 # The only requirement is that it must be entirely printable ASCII # characters and have no white space. -greek= +greek=a1 # If repo_rev is empty, then the repository version number will be # obtained during "make dist" via the "git describe --tags --always" # command, or with the date (if "git describe" fails) in the form of # "date". -repo_rev=gita1212af2 +repo_rev=git0c93c13f # If tarball_version is not empty, it is used as the version string in # the tarball filename, regardless of all other versions listed in @@ -44,7 +44,7 @@ tarball_version= # The date when this release was created -date="Feb 04, 2019" +date="Mar 19, 2019" # The shared library version of each of PMIx's public libraries. # These versions are maintained in accordance with the "Library diff --git a/opal/mca/pmix/pmix4x/pmix/config/Makefile.am b/opal/mca/pmix/pmix4x/pmix/config/Makefile.am index 3793162404..075f5b859e 100644 --- a/opal/mca/pmix/pmix4x/pmix/config/Makefile.am +++ b/opal/mca/pmix/pmix4x/pmix/config/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2016 Intel, Inc. All rights reserved +# Copyright (c) 2013-2019 Intel, Inc. All rights reserved. # Copyright (c) 2016 Research Organization for Information Science # and Technology (RIST). All rights reserved. # Copyright (c) 2006-2016 Cisco Systems, Inc. All rights reserved. @@ -42,7 +42,6 @@ EXTRA_DIST = \ pmix.m4 \ pmix_search_libs.m4 \ pmix_setup_cc.m4 \ - pmix_setup_zlib.m4 \ pmix_setup_libevent.m4 \ pmix_mca_priority_sort.pl diff --git a/opal/mca/pmix/pmix4x/pmix/config/pmix.m4 b/opal/mca/pmix/pmix4x/pmix/config/pmix.m4 index 631fbf1c9a..576a57f992 100644 --- a/opal/mca/pmix/pmix4x/pmix/config/pmix.m4 +++ b/opal/mca/pmix/pmix4x/pmix/config/pmix.m4 @@ -18,8 +18,8 @@ dnl reserved. dnl Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved. dnl Copyright (c) 2011-2013 NVIDIA Corporation. All rights reserved. dnl Copyright (c) 2013-2019 Intel, Inc. All rights reserved. -dnl Copyright (c) 2015-2017 Research Organization for Information Science -dnl and Technology (RIST). All rights reserved. +dnl Copyright (c) 2015-2019 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. dnl Copyright (c) 2016 Mellanox Technologies, Inc. dnl All rights reserved. dnl @@ -120,9 +120,11 @@ AC_DEFUN([PMIX_SETUP_CORE],[ pmixmajor=${PMIX_MAJOR_VERSION}L pmixminor=${PMIX_MINOR_VERSION}L pmixrelease=${PMIX_RELEASE_VERSION}L + pmixnumeric=$(printf 0x%4.4x%2.2x%2.2x $PMIX_MAJOR_VERSION $PMIX_MINOR_VERSION $PMIX_RELEASE_VERSION) AC_SUBST(pmixmajor) AC_SUBST(pmixminor) AC_SUBST(pmixrelease) + AC_SUBST(pmixnumeric) AC_CONFIG_FILES(pmix_config_prefix[include/pmix_version.h]) PMIX_GREEK_VERSION="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION --greek`" @@ -414,7 +416,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[ time.h unistd.h dirent.h \ crt_externs.h signal.h \ ioLib.h sockLib.h hostLib.h limits.h \ - sys/statfs.h sys/statvfs.h \ + sys/fcntl.h sys/statfs.h sys/statvfs.h \ netdb.h ucred.h zlib.h sys/auxv.h \ sys/sysctl.h]) @@ -752,10 +754,24 @@ AC_DEFUN([PMIX_SETUP_CORE],[ ################################## # Libevent ################################## - pmix_show_title "Libevent" + pmix_show_title "Event libraries" + PMIX_LIBEV_CONFIG PMIX_LIBEVENT_CONFIG + AS_IF([test $pmix_libevent_support -eq 1 && test $pmix_libev_support -eq 1], + [AC_MSG_WARN([Both libevent and libev support have been specified.]) + AC_MSG_WARN([Only one can be configured against at a time. Please]) + AC_MSG_WARN([remove one from the configure command line.]) + AC_MSG_ERROR([Cannot continue])]) + + AS_IF([test $pmix_libevent_support -eq 0 && test $pmix_libev_support -eq 0], + [AC_MSG_WARN([Either libevent or libev support is required, but neither]) + AC_MSG_WARN([was found. Please use the configure options to point us]) + AC_MSG_WARN([to where we can find one or the other library]) + AC_MSG_ERROR([Cannot continue])]) + + ################################## # HWLOC ################################## @@ -764,13 +780,6 @@ AC_DEFUN([PMIX_SETUP_CORE],[ PMIX_HWLOC_CONFIG - ################################## - # ZLIB COMPRESSION - ################################## - pmix_show_title "ZLIB" - - PMIX_ZLIB_CONFIG - ################################## # MCA ################################## @@ -874,6 +883,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[ pmix_config_prefix[src/tools/pmix_info/Makefile] pmix_config_prefix[src/tools/plookup/Makefile] pmix_config_prefix[src/tools/pps/Makefile] + pmix_config_prefix[src/tools/pattrs/Makefile] ) # publish any embedded flags so external wrappers can use them diff --git a/opal/mca/pmix/pmix4x/pmix/config/pmix_mca.m4 b/opal/mca/pmix/pmix4x/pmix/config/pmix_mca.m4 index 79f8d04bcb..2131f85be0 100644 --- a/opal/mca/pmix/pmix4x/pmix/config/pmix_mca.m4 +++ b/opal/mca/pmix/pmix4x/pmix/config/pmix_mca.m4 @@ -11,7 +11,7 @@ dnl University of Stuttgart. All rights reserved. dnl Copyright (c) 2004-2005 The Regents of the University of California. dnl All rights reserved. dnl Copyright (c) 2010-2015 Cisco Systems, Inc. All rights reserved. -dnl Copyright (c) 2013-2018 Intel, Inc. All rights reserved. +dnl Copyright (c) 2013-2019 Intel, Inc. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -262,11 +262,6 @@ AC_DEFUN([PMIX_MCA],[ [MCA_pmix_]mca_framework[_CONFIG](mca_framework), [MCA_CONFIGURE_FRAMEWORK(mca_framework, 1)])])]) - # note that mca_wrapper_extra_* is a running list, and we take checkpoints at the end of our project - pmix_mca_wrapper_extra_cppflags="$mca_wrapper_extra_cppflags" - pmix_mca_wrapper_extra_ldflags="$mca_wrapper_extra_ldflags" - pmix_mca_wrapper_extra_libs="$mca_wrapper_extra_libs" - AC_SUBST(MCA_pmix_FRAMEWORKS) AC_SUBST(MCA_pmix_FRAMEWORKS_SUBDIRS) AC_SUBST(MCA_pmix_FRAMEWORK_COMPONENT_ALL_SUBDIRS) @@ -622,14 +617,6 @@ AC_DEFUN([MCA_CONFIGURE_ALL_CONFIG_COMPONENTS],[ AC_MSG_WARN([MCA component configure script told me to abort]) AC_MSG_ERROR([cannot continue]) fi - - m4_foreach(flags, [LDFLAGS, LIBS], - [[line="`$GREP WRAPPER_EXTRA_]flags[= $infile | cut -d= -f2-`"] - eval "line=$line" - if test -n "$line"; then - $2[_]$3[_WRAPPER_EXTRA_]flags[="$line"] - fi - ])dnl fi MCA_PROCESS_COMPONENT($1, $component, $2, $3, $4, $5, $compile_mode) @@ -754,38 +741,6 @@ AC_MSG_ERROR([*** $1 component $2 was supposed to be direct-called, but *** Aborting]) fi fi - - # if the component is building, add it's WRAPPER_EXTRA_LDFLAGS and - # WRAPPER_EXTRA_LIBS. If the component doesn't specify it's - # WRAPPER_EXTRA_LIBS and WRAPPER_EXTRA_LDFLAGS, try using LDFLAGS and LIBS if - # component didn't have it's own configure script (in which case, - # we know it didn't set LDFLAGS and LIBS because it can't) Don't - # have to do this if the component is building dynamically, - # because it will link against these (without a dependency from - # libmpi.so to these flags) - if test "$7" = "static"; then - AS_LITERAL_IF([$2], - [m4_foreach(flags, [LDFLAGS, LIBS], - [AS_IF([test "$$1_$2_WRAPPER_EXTRA_]flags[" = ""], - [PMIX_FLAGS_APPEND_UNIQ([mca_wrapper_extra_]m4_tolower(flags), [$$1_$2_]flags)], - [PMIX_FLAGS_APPEND_UNIQ([mca_wrapper_extra_]m4_tolower(flags), [$$1_$2_WRAPPER_EXTRA_]flags)]) - ])], - [m4_foreach(flags, [LDFLAGS, LIBS], - [[str="line=\$$1_$2_WRAPPER_EXTRA_]flags["] - eval "$str" - PMIX_FLAGS_APPEND_UNIQ([mca_wrapper_extra_]m4_tolower(flags), [$line])])]) - fi - - # if needed, copy over WRAPPER_EXTRA_CPPFLAGS. Since a configure script - # component can never be used in a STOP_AT_FIRST framework, we - # don't have to implement the else clause in the literal check... - AS_LITERAL_IF([$2], - [AS_IF([test "$$1_$2_WRAPPER_EXTRA_CPPFLAGS" != ""], - [m4_if(PMIX_EVAL_ARG([MCA_pmix_$1_CONFIGURE_MODE]), [STOP_AT_FIRST], [stop_at_first=1], [stop_at_first=0]) - AS_IF([test "$7" = "static" && test "$stop_at_first" = "1"], - [AS_IF([test "$with_devel_headers" = "yes"], - [PMIX_FLAGS_APPEND_UNIQ([mca_wrapper_extra_cppflags], [$$1_$2_WRAPPER_EXTRA_CPPFLAGS])])], - [AC_MSG_WARN([ignoring $1_$2_WRAPPER_EXTRA_CPPFLAGS ($$1_$2_WRAPPER_EXTRA_CPPFLAGS): component conditions not met])])])]) ]) diff --git a/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_cc.m4 b/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_cc.m4 index a8956a1d22..026c3a800b 100644 --- a/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_cc.m4 +++ b/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_cc.m4 @@ -16,7 +16,7 @@ dnl Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights dnl reserved. dnl Copyright (c) 2015-2019 Research Organization for Information Science dnl and Technology (RIST). All rights reserved. -dnl Copyright (c) 2018-2019 Intel, Inc. All rights reserved. +dnl Copyright (c) 2018 Intel, Inc. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow diff --git a/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_libev.m4 b/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_libev.m4 new file mode 100644 index 0000000000..494cc2a2c3 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_libev.m4 @@ -0,0 +1,96 @@ +# -*- shell-script -*- +# +# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. +# Copyright (c) 2013-2019 Intel, Inc. All rights reserved. +# Copyright (c) 2017-2019 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# MCA_libev_CONFIG([action-if-found], [action-if-not-found]) +# -------------------------------------------------------------------- +AC_DEFUN([PMIX_LIBEV_CONFIG],[ + PMIX_VAR_SCOPE_PUSH([pmix_libev_dir pmix_libev_libdir pmix_libev_standard_header_location pmix_libev_standard_lib_location]) + + AC_ARG_WITH([libev], + [AC_HELP_STRING([--with-libev=DIR], + [Search for libev headers and libraries in DIR ])]) + PMIX_CHECK_WITHDIR([libev], [$with_libev], [include/event.h]) + + AC_ARG_WITH([libev-libdir], + [AC_HELP_STRING([--with-libev-libdir=DIR], + [Search for libev libraries in DIR ])]) + PMIX_CHECK_WITHDIR([libev-libdir], [$with_livev_libdir], [libev.*]) + + pmix_libev_support=0 + + AS_IF([test -n "$with_libev" && test "$with_libev" != "no"], + [AC_MSG_CHECKING([for libev in]) + pmix_check_libev_save_CPPFLAGS="$CPPFLAGS" + pmix_check_libeve_save_LDFLAGS="$LDFLAGS" + pmix_check_libev_save_LIBS="$LIBS" + if test "$with_libev" != "yes"; then + pmix_libev_dir=$with_libev/include + pmix_libev_standard_header_location=no + pmix_libev_standard_lib_location=no + AS_IF([test -z "$with_libev_libdir" || test "$with_libev_libdir" = "yes"], + [if test -d $with_libev/lib; then + pmix_libev_libdir=$with_libev/lib + elif test -d $with_libev/lib64; then + pmix_libev_libdir=$with_libev/lib64 + else + AC_MSG_RESULT([Could not find $with_libev/lib or $with_libev/lib64]) + AC_MSG_ERROR([Can not continue]) + fi + AC_MSG_RESULT([$pmix_libev_dir and $pmix_libev_libdir])], + [AC_MSG_RESULT([$with_libev_libdir])]) + else + AC_MSG_RESULT([(default search paths)]) + pmix_libev_standard_header_location=yes + pmix_libev_standard_lib_location=yes + fi + AS_IF([test ! -z "$with_libev_libdir" && test "$with_libev_libdir" != "yes"], + [pmix_libev_libdir="$with_libev_libdir" + pmix_libev_standard_lib_location=no]) + + PMIX_CHECK_PACKAGE([pmix_libev], + [event.h], + [ev], + [event_base_new], + [], + [$pmix_libev_dir], + [$pmix_libev_libdir], + [pmix_libev_support=1], + [pmix_libev_support=0]) + CPPFLAGS="$pmix_check_libev_save_CPPFLAGS" + LDFLAGS="$pmix_check_libev_save_LDFLAGS" + LIBS="$pmix_check_libev_save_LIBS"]) + + AS_IF([test $pmix_libev_support -eq 1], + [LIBS="$LIBS $pmix_libev_LIBS" + + AS_IF([test "$pmix_libev_standard_header_location" != "yes"], + [CPPFLAGS="$CPPFLAGS $pmix_libev_CPPFLAGS"]) + AS_IF([test "$pmix_libev_standard_lib_location" != "yes"], + [LDFLAGS="$LDFLAGS $pmix_libev_LDFLAGS"])]) + + AC_MSG_CHECKING([will libev support be built]) + if test $pmix_libev_support -eq 1; then + AC_MSG_RESULT([yes]) + PMIX_EVENT_HEADER="" + AC_DEFINE_UNQUOTED([PMIX_EVENT_HEADER], [$PMIX_EVENT_HEADER], + [Location of event.h]) + PMIX_SUMMARY_ADD([[External Packages]],[[libev]],[libev],[$pmix_libev_dir]) + else + AC_MSG_RESULT([no]) + fi + + AC_DEFINE_UNQUOTED([PMIX_HAVE_LIBEV], [$pmix_libev_support], [Whether we are building against libev]) + + PMIX_VAR_SCOPE_POP +])dnl diff --git a/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_libevent.m4 b/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_libevent.m4 index 949af1cfd5..28e3a41227 100644 --- a/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_libevent.m4 +++ b/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_libevent.m4 @@ -3,8 +3,8 @@ # Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. # Copyright (c) 2013-2019 Intel, Inc. All rights reserved. -# Copyright (c) 2017 Research Organization for Information Science -# and Technology (RIST). All rights reserved. +# Copyright (c) 2017-2019 Research Organization for Information Science +# and Technology (RIST). All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -19,20 +19,25 @@ AC_DEFUN([PMIX_LIBEVENT_CONFIG],[ [AC_HELP_STRING([--with-libevent-header=HEADER], [The value that should be included in C files to include event.h])]) + pmix_libevent_support=0 + AS_IF([test "$pmix_mode" = "embedded"], [_PMIX_LIBEVENT_EMBEDDED_MODE], - [_PMIX_LIBEVENT_EXTERNAL]) + [AS_IF([test $pmix_libev_support -eq 0], + [_PMIX_LIBEVENT_EXTERNAL])]) - AC_MSG_CHECKING([libevent header]) - AC_DEFINE_UNQUOTED([PMIX_EVENT_HEADER], [$PMIX_EVENT_HEADER], - [Location of event.h]) - AC_MSG_RESULT([$PMIX_EVENT_HEADER]) - AC_MSG_CHECKING([libevent2/thread header]) - AC_DEFINE_UNQUOTED([PMIX_EVENT2_THREAD_HEADER], [$PMIX_EVENT2_THREAD_HEADER], - [Location of event2/thread.h]) - AC_MSG_RESULT([$PMIX_EVENT2_THREAD_HEADER]) + if test $pmix_libevent_support -eq 1; then + AC_MSG_CHECKING([libevent header]) + AC_DEFINE_UNQUOTED([PMIX_EVENT_HEADER], [$PMIX_EVENT_HEADER], + [Location of event.h]) + AC_MSG_RESULT([$PMIX_EVENT_HEADER]) + AC_MSG_CHECKING([libevent2/thread header]) + AC_DEFINE_UNQUOTED([PMIX_EVENT2_THREAD_HEADER], [$PMIX_EVENT2_THREAD_HEADER], + [Location of event2/thread.h]) + AC_MSG_RESULT([$PMIX_EVENT2_THREAD_HEADER]) - PMIX_SUMMARY_ADD([[External Packages]],[[Libevent]], [pmix_libevent], [yes ($pmix_libevent_source)]) + PMIX_SUMMARY_ADD([[External Packages]],[[Libevent]], [pmix_libevent], [yes ($pmix_libevent_source)]) + fi ]) AC_DEFUN([_PMIX_LIBEVENT_EMBEDDED_MODE],[ @@ -46,7 +51,8 @@ AC_DEFUN([_PMIX_LIBEVENT_EMBEDDED_MODE],[ PMIX_EVENT2_THREAD_HEADER="$with_libevent_header"]) pmix_libevent_source=embedded - ]) + pmix_libevent_support=1 +]) AC_DEFUN([_PMIX_LIBEVENT_EXTERNAL],[ PMIX_VAR_SCOPE_PUSH([pmix_event_dir pmix_event_libdir pmix_event_defaults]) @@ -55,88 +61,109 @@ AC_DEFUN([_PMIX_LIBEVENT_EXTERNAL],[ [AC_HELP_STRING([--with-libevent=DIR], [Search for libevent headers and libraries in DIR ])]) - # Bozo check - AS_IF([test "$with_libevent" = "no"], - [AC_MSG_WARN([It is not possible to configure PMIx --without-libevent]) - AC_MSG_ERROR([Cannot continue])]) - AC_ARG_WITH([libevent-libdir], [AC_HELP_STRING([--with-libevent-libdir=DIR], [Search for libevent libraries in DIR ])]) + pmix_check_libevent_save_CPPFLAGS="$CPPFLAGS" + pmix_check_libevent_save_LDFLAGS="$LDFLAGS" + pmix_check_libevent_save_LIBS="$LIBS" + # get rid of the trailing slash(es) libevent_prefix=$(echo $with_libevent | sed -e 'sX/*$XXg') libeventdir_prefix=$(echo $with_libevent_libdir | sed -e 'sX/*$XXg') - AC_MSG_CHECKING([for libevent in]) - if test ! -z "$libevent_prefix" && test "$libevent_prefix" != "yes"; then - pmix_event_defaults=no - pmix_event_dir=$libevent_prefix - if test -d $libevent_prefix/lib; then - pmix_event_libdir=$libevent_prefix/lib - elif test -d $libevent_prefix/lib64; then - pmix_event_libdir=$libevent_prefix/lib64 - elif test -d $libevent_prefix; then - pmix_event_libdir=$libevent_prefix + if test "$libevent_prefix" != "no"; then + AC_MSG_CHECKING([for libevent in]) + if test ! -z "$libevent_prefix" && test "$libevent_prefix" != "yes"; then + pmix_event_defaults=no + pmix_event_dir=$libevent_prefix/include + if test -d $libevent_prefix/lib; then + pmix_event_libdir=$libevent_prefix/lib + elif test -d $libevent_prefix/lib64; then + pmix_event_libdir=$libevent_prefix/lib64 + elif test -d $libevent_prefix; then + pmix_event_libdir=$libevent_prefix + else + AC_MSG_RESULT([Could not find $libevent_prefix/lib, $libevent_prefix/lib64, or $libevent_prefix]) + AC_MSG_ERROR([Can not continue]) + fi + AC_MSG_RESULT([$pmix_event_dir and $pmix_event_libdir]) else - AC_MSG_RESULT([Could not find $libevent_prefix/lib, $libevent_prefix/lib64, or $libevent_prefix]) - AC_MSG_ERROR([Can not continue]) + pmix_event_defaults=yes + pmix_event_dir=/usr/include + if test -d /usr/lib; then + pmix_event_libdir=/usr/lib + AC_MSG_RESULT([(default search paths)]) + elif test -d /usr/lib64; then + pmix_event_libdir=/usr/lib64 + AC_MSG_RESULT([(default search paths)]) + else + AC_MSG_RESULT([default paths not found]) + pmix_libevent_support=0 + fi fi - AC_MSG_RESULT([$pmix_event_dir and $pmix_event_libdir]) - else - pmix_event_defaults=yes - pmix_event_dir=/usr/include - if test -d /usr/lib; then - pmix_event_libdir=/usr/lib - elif test -d /usr/lib64; then - pmix_event_libdir=/usr/lib64 - else - AC_MSG_RESULT([not found]) - AC_MSG_WARN([Could not find /usr/lib or /usr/lib64 - you may]) - AC_MSG_WARN([need to specify --with-libevent-libdir=]) - AC_MSG_ERROR([Can not continue]) + AS_IF([test ! -z "$libeventdir_prefix" && "$libeventdir_prefix" != "yes"], + [pmix_event_libdir="$libeventdir_prefix"]) + + PMIX_CHECK_PACKAGE([pmix_libevent], + [event.h], + [event], + [event_config_new], + [-levent -levent_pthreads], + [$pmix_event_dir], + [$pmix_event_libdir], + [pmix_libevent_support=1], + [pmix_libevent_support=0]) + + AS_IF([test "$pmix_event_defaults" = "no"], + [PMIX_FLAGS_APPEND_UNIQ(CPPFLAGS, $pmix_libevent_CPPFLAGS) + PMIX_FLAGS_APPEND_UNIQ(LDFLAGS, $pmix_libevent_LDFLAGS)]) + PMIX_FLAGS_APPEND_UNIQ(LIBS, $pmix_libevent_LIBS) + + if test $pmix_libevent_support -eq 1; then + # Ensure that this libevent has the symbol + # "evthread_set_lock_callbacks", which will only exist if + # libevent was configured with thread support. + AC_CHECK_LIB([event], [evthread_set_lock_callbacks], + [], + [AC_MSG_WARN([External libevent does not have thread support]) + AC_MSG_WARN([PMIx requires libevent to be compiled with]) + AC_MSG_WARN([thread support enabled]) + pmix_libevent_support=0]) + fi + if test $pmix_libevent_support -eq 1; then + AC_CHECK_LIB([event_pthreads], [evthread_use_pthreads], + [], + [AC_MSG_WARN([External libevent does not have thread support]) + AC_MSG_WARN([PMIx requires libevent to be compiled with]) + AC_MSG_WARN([thread support enabled]) + pmix_libevent_support=0]) fi - AC_MSG_RESULT([(default search paths)]) fi - AS_IF([test ! -z "$libeventdir_prefix" && "$libeventdir_prefix" != "yes"], - [pmix_event_libdir="$libeventdir_prefix"]) - PMIX_CHECK_PACKAGE([pmix_libevent], - [event.h], - [event], - [event_config_new], - [-levent -levent_pthreads], - [$pmix_event_dir], - [$pmix_event_libdir], - [], - [AC_MSG_WARN([LIBEVENT SUPPORT NOT FOUND]) - AC_MSG_ERROR([CANNOT CONTINUE])]) + CPPFLAGS="$pmix_check_libevent_save_CPPFLAGS" + LDFLAGS="$pmix_check_libevent_save_LDFLAGS" + LIBS="$pmix_check_libevent_save_LIBS" - AS_IF([test "$pmix_event_defaults" = "no"], - [PMIX_FLAGS_APPEND_UNIQ(CPPFLAGS, $pmix_libevent_CPPFLAGS) - PMIX_FLAGS_APPEND_UNIQ(LDFLAGS, $pmix_libevent_LDFLAGS)]) - PMIX_FLAGS_APPEND_UNIQ(LIBS, $pmix_libevent_LIBS) + AC_MSG_CHECKING([will libevent support be built]) + if test $pmix_libevent_support -eq 1; then + AC_MSG_RESULT([yes]) + # Set output variables + PMIX_EVENT_HEADER="" + PMIX_EVENT2_THREAD_HEADER="" + AC_DEFINE_UNQUOTED([PMIX_EVENT_HEADER], [$PMIX_EVENT_HEADER], + [Location of event.h]) + pmix_libevent_source=$pmix_event_dir + AS_IF([test "$pmix_event_defaults" = "no"], + [PMIX_FLAGS_APPEND_UNIQ(CPPFLAGS, $pmix_libevent_CPPFLAGS) + PMIX_FLAGS_APPEND_UNIQ(LDFLAGS, $pmix_libevent_LDFLAGS)]) + PMIX_FLAGS_APPEND_UNIQ(LIBS, $pmix_libevent_LIBS) + else + AC_MSG_RESULT([no]) + fi - # Ensure that this libevent has the symbol - # "evthread_set_lock_callbacks", which will only exist if - # libevent was configured with thread support. - AC_CHECK_LIB([event], [evthread_set_lock_callbacks], - [], - [AC_MSG_WARN([External libevent does not have thread support]) - AC_MSG_WARN([PMIx requires libevent to be compiled with]) - AC_MSG_WARN([thread support enabled]) - AC_MSG_ERROR([Cannot continue])]) - AC_CHECK_LIB([event_pthreads], [evthread_use_pthreads], - [], - [AC_MSG_WARN([External libevent does not have thread support]) - AC_MSG_WARN([PMIx requires libevent to be compiled with]) - AC_MSG_WARN([thread support enabled]) - AC_MSG_ERROR([Cannot continue])]) - - # Set output variables - PMIX_EVENT_HEADER="" - PMIX_EVENT2_THREAD_HEADER="" - pmix_libevent_source=$pmix_event_dir + AC_DEFINE_UNQUOTED([PMIX_HAVE_LIBEVENT], [$pmix_libevent_support], [Whether we are building against libevent]) PMIX_VAR_SCOPE_POP ])dnl diff --git a/opal/mca/pmix/pmix4x/pmix/contrib/pmix.spec b/opal/mca/pmix/pmix4x/pmix/contrib/pmix.spec index 8f5a982460..0139e85997 100644 --- a/opal/mca/pmix/pmix4x/pmix/contrib/pmix.spec +++ b/opal/mca/pmix/pmix4x/pmix/contrib/pmix.spec @@ -12,7 +12,7 @@ # Copyright (c) 2006-2016 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2013 Mellanox Technologies, Inc. # All rights reserved. -# Copyright (c) 2015-2019 Intel, Inc. All rights reserved. +# Copyright (c) 2015-2018 Intel, Inc. All rights reserved. # Copyright (c) 2015 Research Organization for Information Science # and Technology (RIST). All rights reserved. # $COPYRIGHT$ @@ -192,7 +192,7 @@ Summary: An extended/exascale implementation of PMI Name: %{?_name:%{_name}}%{!?_name:pmix} -Version: 4.0.0 +Version: 4.0.0a1 Release: 1%{?dist} License: BSD Group: Development/Libraries @@ -204,6 +204,7 @@ Prefix: %{_prefix} Provides: pmix Provides: pmix = %{version} BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root +BuildRequires: libevent-devel %if %{disable_auto_requires} AutoReq: no %endif diff --git a/opal/mca/pmix/pmix4x/pmix/examples/server.c b/opal/mca/pmix/pmix4x/pmix/examples/server.c index a720384f5d..2d024107f4 100644 --- a/opal/mca/pmix/pmix4x/pmix/examples/server.c +++ b/opal/mca/pmix/pmix4x/pmix/examples/server.c @@ -13,7 +13,7 @@ * All rights reserved. * Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. @@ -42,8 +42,6 @@ #include #include -#include PMIX_EVENT_HEADER - #include "src/class/pmix_list.h" #include "src/util/pmix_environ.h" #include "src/util/output.h" @@ -266,9 +264,9 @@ int main(int argc, char **argv) /* setup to see sigchld on the forked tests */ PMIX_CONSTRUCT(&children, pmix_list_t); - event_assign(&handler, pmix_globals.evbase, SIGCHLD, - EV_SIGNAL|EV_PERSIST,wait_signal_callback, &handler); - event_add(&handler, NULL); + pmix_event_assign(&handler, pmix_globals.evbase, SIGCHLD, + EV_SIGNAL|EV_PERSIST,wait_signal_callback, &handler); + pmix_event_add(&handler, NULL); /* see if we were passed the number of procs to run or * the executable to use */ @@ -871,7 +869,7 @@ static void wait_signal_callback(int fd, short event, void *arg) pid_t pid; wait_tracker_t *t2; - if (SIGCHLD != event_get_signal(sig)) { + if (SIGCHLD != pmix_event_get_signal(sig)) { return; } diff --git a/opal/mca/pmix/pmix4x/pmix/include/pmix.h b/opal/mca/pmix/pmix4x/pmix/include/pmix.h index a854720ef7..55c0015575 100644 --- a/opal/mca/pmix/pmix4x/pmix/include/pmix.h +++ b/opal/mca/pmix/pmix4x/pmix/include/pmix.h @@ -694,7 +694,7 @@ PMIX_EXPORT pmix_status_t PMIx_IOF_deregister(size_t iofhdlr, pmix_op_cbfunc_t cbfunc, void *cbdata); /* Push data collected locally (typically from stdin) to - * target recipients. + * stdin of target recipients. * * targets - array of process identifiers to which the data is to be delivered. Note * that a WILDCARD rank indicates that all procs in the given nspace are @@ -768,7 +768,7 @@ PMIX_EXPORT pmix_status_t PMIx_IOF_push(const pmix_proc_t targets[], size_t ntar * Any participant that returns PMIX_GROUP_CONSTRUCT_ABORT from the leader failed * event handler will cause the construct process to abort. Those processes * engaged in the blocking construct will return from the call with the - * PMIX_GROUP_CONSTRUCT_ABORT status. Non-blocking partipants will have + * PMIX_GROUP_CONSTRUCT_ABORT status. Non-blocking participants will have * their callback function executed with that status. * * Some relevant attributes for this operation: @@ -790,7 +790,6 @@ PMIX_EXPORT pmix_status_t PMIx_IOF_push(const pmix_proc_t targets[], size_t ntar * specified number of seconds. Targets the scenario where a * process fails to call PMIx_Group_connect due to hanging * - * Recognizing */ PMIX_EXPORT pmix_status_t PMIx_Group_construct(const char grp[], const pmix_proc_t procs[], size_t nprocs, diff --git a/opal/mca/pmix/pmix4x/pmix/include/pmix_common.h.in b/opal/mca/pmix/pmix4x/pmix/include/pmix_common.h.in index 8522f07382..3b952f1443 100644 --- a/opal/mca/pmix/pmix4x/pmix/include/pmix_common.h.in +++ b/opal/mca/pmix/pmix4x/pmix/include/pmix_common.h.in @@ -4,7 +4,7 @@ * Copyright (c) 2016-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. - * Copyright (c) 2016-2018 Mellanox Technologies, Inc. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -265,6 +265,9 @@ typedef uint32_t pmix_rank_t; #define PMIX_PARENT_ID "pmix.parent" // (pmix_proc_t*) identifier of the process that called PMIx_Spawn // to launch this proc's application #define PMIX_EXIT_CODE "pmix.exit.code" // (int) exit code returned when proc terminated +#define PMIX_NETWORK_COORDINATE "pmix.net.coord" // (pmix_coord_t*) Network coordinate of the specified process +#define PMIX_NETWORK_COORD_SYSTEM "pmix.net.coordsys" // (pmix_coord_system_t) Network coordinate system being employed to + // describe the specified network plane /* size info */ @@ -275,6 +278,7 @@ typedef uint32_t pmix_rank_t; #define PMIX_LOCAL_SIZE "pmix.local.size" // (uint32_t) #procs in this job on this node #define PMIX_NODE_SIZE "pmix.node.size" // (uint32_t) #procs across all jobs on this node #define PMIX_MAX_PROCS "pmix.max.size" // (uint32_t) max #procs for this job +#define PMIX_NUM_SLOTS "pmix.num.slots" // (uint32_t) #slots allocated #define PMIX_NUM_NODES "pmix.num.nodes" // (uint32_t) #nodes in this nspace @@ -451,6 +455,24 @@ typedef uint32_t pmix_rank_t; // in the specified range (defaults to session) #define PMIX_QUERY_PSET_NAMES "pmix.qry.psets" // (char*) return a comma-delimited list of the names of the // psets defined in the specified range (defaults to session) +#define PMIX_QUERY_ATTRIBUTE_SUPPORT "pmix.qry.attrs" // (bool) query attribute support for specified functions +#define PMIX_CLIENT_FUNCTIONS "pmix.client.fns" // (bool) query the list of supported PMIx client functions +#define PMIX_SERVER_FUNCTIONS "pmix.srvr.fns" // (bool) query the list of supported PMIx server functions +#define PMIX_TOOL_FUNCTIONS "pmix.tool.fns" // (bool) query the list of supported PMIx tool functions +#define PMIX_HOST_FUNCTIONS "pmix.host.fns" // (bool) query the list of PMIx functions supported by the host environment +#define PMIX_CLIENT_ATTRIBUTES "pmix.client.attrs" // (char*) comma-delimited list of functions, including "all" + // when used in a query, indicates whether or not to include + // attributes supported by the PMIx client library +#define PMIX_SERVER_ATTRIBUTES "pmix.srvr.attrs" // (char*) comma-delimited list of functions, including "all" + // when used in a query, indicates whether or not to include + // attributes supported by the PMIx server library +#define PMIX_HOST_ATTRIBUTES "pmix.host.attrs" // (char*) comma-delimited list of functions, including "all" + // when used in a query, indicates whether or not to include + // attributes supported by the host environment +#define PMIX_TOOL_ATTRIBUTES "pmix.tool.attrs" // (char*) comma-delimited list of functions, including "all" + // when used in a query, indicates whether or not to include + // attributes supported by the PMIx tool library + /* information retrieval attributes */ #define PMIX_SESSION_INFO "pmix.ssn.info" // (bool) Return information about the specified session. If information @@ -863,6 +885,9 @@ typedef int pmix_status_t; #define PMIX_GROUP_LEADER_SELECTED -167 #define PMIX_GROUP_LEADER_FAILED -168 #define PMIX_GROUP_CONTEXT_ID_ASSIGNED -169 +#define PMIX_ERR_REPEAT_ATTR_REGISTRATION -170 +#define PMIX_ERR_IOF_FAILURE -171 +#define PMIX_ERR_IOF_COMPLETE -172 /* system failures */ #define PMIX_ERR_NODE_DOWN -231 @@ -941,6 +966,8 @@ typedef uint16_t pmix_data_type_t; // Hole left by deprecation/removal of PMIX_INFO_ARRAY #define PMIX_IOF_CHANNEL 45 #define PMIX_ENVAR 46 +#define PMIX_COORD 47 +#define PMIX_REGATTR 48 /********************/ /* define a boundary for implementers so they can add their own data types */ @@ -1038,14 +1065,28 @@ typedef enum { } pmix_group_operation_t; +/* define a structure for a proc's network coordinate */ +typedef struct pmix_coord { + int x; + int y; + int z; +} pmix_coord_t; + +/* define coordinate system values */ +typedef uint8_t pmix_coord_system_t; +#define PMIX_COORD_CARTESIAN 0x00 +#define PMIX_COORD_TOROID 0x01 +#define PMIX_COORD_CYLINDRICAL 0x02 + + /* declare a convenience macro for checking keys */ #define PMIX_CHECK_KEY(a, b) \ (0 == strncmp((a)->key, (b), PMIX_MAX_KEYLEN)) -#define PMIX_LOAD_KEY(a, b) \ - do { \ - memset((a), 0, PMIX_MAX_KEYLEN+1); \ - pmix_strncpy((a), (b), PMIX_MAX_KEYLEN); \ +#define PMIX_LOAD_KEY(a, b) \ + do { \ + memset((a), 0, PMIX_MAX_KEYLEN+1); \ + pmix_strncpy((char*)(a), (const char*)(b), PMIX_MAX_KEYLEN); \ }while(0) /* define a convenience macro for loading nspaces */ @@ -1362,6 +1403,11 @@ typedef struct pmix_data_array { /**** AVOID CIRCULAR DEPENDENCIES ****/ +/* we cannot forward-declare the pmix_regattr_t struct + * as Cython doesn't know what to do with it. Thus, we + * will utilize the void* entry of the pmix_value_t to + * hold the point to pmix_regattr_t */ + /**** PMIX VALUE STRUCT ****/ /* NOTE: operations can supply a collection of values under @@ -1404,6 +1450,7 @@ typedef struct pmix_value { void *ptr; pmix_alloc_directive_t adir; pmix_envar_t envar; + pmix_coord_t *coord; } data; } pmix_value_t; /* allocate and initialize a specified number of value structs */ @@ -1506,26 +1553,6 @@ typedef struct pmix_value { } \ } while(0) -#define PMIX_VALUE_COMPRESSED_STRING_UNPACK(s) \ - do { \ - char *tmp; \ - /* if this is a compressed string, then uncompress it */ \ - if (PMIX_COMPRESSED_STRING == (s)->type) { \ - pmix_util_uncompress_string(&tmp, (uint8_t*)(s)->data.bo.bytes, \ - (s)->data.bo.size); \ - if (NULL == tmp) { \ - PMIX_ERROR_LOG(PMIX_ERR_NOMEM); \ - rc = PMIX_ERR_NOMEM; \ - PMIX_VALUE_RELEASE(s); \ - val = NULL; \ - } else { \ - PMIX_VALUE_DESTRUCT(s); \ - (s)->data.string = tmp; \ - (s)->type = PMIX_STRING; \ - } \ - } \ - } while(0) - /**** PMIX INFO STRUCT ****/ typedef struct pmix_info { pmix_key_t key; @@ -1538,8 +1565,10 @@ typedef struct pmix_info { do { \ pmix_info_t *_i; \ (m) = (pmix_info_t*)calloc((n), sizeof(pmix_info_t)); \ - _i = (pmix_info_t*)(m); \ - _i[(n)-1].flags = PMIX_INFO_ARRAY_END; \ + if (NULL != (m)) { \ + _i = (pmix_info_t*)(m); \ + _i[(n)-1].flags = PMIX_INFO_ARRAY_END; \ + } \ } while (0) #define PMIX_INFO_CONSTRUCT(m) \ @@ -1814,6 +1843,97 @@ typedef struct pmix_query { } \ } while (0) +/**** ATTRIBUTE REGISTRATION STRUCT ****/ +typedef struct pmix_regattr_t { + char *name; + pmix_key_t string; + pmix_data_type_t type; + pmix_info_t *info; + size_t ninfo; + char **description; +} pmix_regattr_t; + +#define PMIX_REGATTR_CONSTRUCT(a) \ + do { \ + if (NULL != (a)) { \ + (a)->name = NULL; \ + memset((a)->string, 0, PMIX_MAX_KEYLEN+1); \ + (a)->type = PMIX_UNDEF; \ + (a)->info = NULL; \ + (a)->ninfo = 0; \ + (a)->description = NULL; \ + } \ + } while(0) + +#define PMIX_REGATTR_LOAD(a, n, k, t, ni, v) \ + do { \ + pmix_status_t _rgl; \ + if (NULL != (n)) { \ + (a)->name = strdup((n)); \ + } \ + if (NULL != (k)) { \ + PMIX_LOAD_KEY((a)->string, (k)); \ + } \ + (a)->type = (t); \ + if (0 < (ni)) { \ + PMIX_INFO_CREATE((a)->info, (ni)); \ + (a)->ninfo = (ni); \ + } \ + if (NULL != (v)) { \ + PMIX_ARGV_APPEND(_rgl, &(a)->description, (v)); \ + } \ + } while(0) + +#define PMIX_REGATTR_DESTRUCT(a) \ + do { \ + if (NULL != (a)) { \ + if (NULL != (a)->name) { \ + free((a)->name); \ + } \ + if (NULL != (a)->description) { \ + PMIX_ARGV_FREE((a)->description); \ + } \ + } \ + } while(0) + +#define PMIX_REGATTR_CREATE(m, n) \ + do { \ + (m) = (pmix_regattr_t*)calloc((n) , sizeof(pmix_regattr_t)); \ + } while (0) + +#define PMIX_REGATTR_FREE(m, n) \ + do { \ + size_t _ra; \ + if (NULL != (m)) { \ + for (_ra=0; _ra < (n); _ra++) { \ + PMIX_REGATTR_DESTRUCT(&((m)[_ra])); \ + } \ + free((m)); \ + (m) = NULL; \ + } \ + } while (0) + +#define PMIX_REGATTR_XFER(a, b) \ + do { \ + size_t _n; \ + PMIX_REGATTR_CONSTRUCT((a)); \ + if (NULL != ((b)->name)) { \ + (a)->name = strdup((b)->name); \ + } \ + PMIX_LOAD_KEY((a)->string, (b)->string); \ + (a)->type = (b)->type; \ + if (0 < (b)->ninfo) { \ + (a)->ninfo = (b)->ninfo; \ + PMIX_INFO_CREATE((a)->info, (a)->ninfo); \ + for (_n=0; _n < (a)->ninfo; _n++) { \ + PMIX_INFO_XFER(&(a)->info[_n], &(b)->info[_n]); \ + } \ + } \ + if (NULL != (b)->description) { \ + PMIX_ARGV_COPY((a)->description, (b)->description); \ + } \ + } while(0) + /**** GENERIC HELPER MACROS ****/ @@ -2183,8 +2303,11 @@ typedef void (*pmix_validation_cbfunc_t)(pmix_status_t status, pmix_info_t info[], size_t ninfo, void *cbdata); - +/****************************************/ /**** COMMON SUPPORT FUNCTIONS ****/ +/****************************************/ + +/****** EVENT NOTIFICATION SUPPORT ******/ /* Register an event handler to report events. Three types of events * can be reported: * @@ -2278,6 +2401,8 @@ PMIX_EXPORT pmix_status_t PMIx_Notify_event(pmix_status_t status, const pmix_info_t info[], size_t ninfo, pmix_op_cbfunc_t cbfunc, void *cbdata); + +/****** PRETTY-PRINT DEFINED VALUE TYPES ******/ /* Provide a string representation for several types of value. Note * that the provided string is statically defined and must NOT be * free'd. Supported value types: @@ -2311,6 +2436,8 @@ PMIX_EXPORT const char* PMIx_Get_version(void); PMIX_EXPORT pmix_status_t PMIx_Store_internal(const pmix_proc_t *proc, const pmix_key_t key, pmix_value_t *val); + +/****** DATA BUFFER PACK/UNPACK SUPPORT ******/ /** * Top-level interface function to pack one or more values into a * buffer. @@ -2539,6 +2666,7 @@ PMIX_EXPORT pmix_status_t PMIx_Data_copy_payload(pmix_data_buffer_t *dest, pmix_data_buffer_t *src); +/******** STANDARD MACROS FOR DARRAY AND VALUE SUPPORT ********/ static inline void pmix_darray_destruct(pmix_data_array_t *m); static inline void pmix_value_destruct(pmix_value_t * m) @@ -2595,7 +2723,8 @@ static inline void pmix_darray_destruct(pmix_data_array_t *m) } else if (PMIX_APP == m->type) { pmix_app_t *_a = (pmix_app_t*)m->array; PMIX_APP_FREE(_a, m->size); - } else if (PMIX_BYTE_OBJECT == m->type) { + } else if (PMIX_BYTE_OBJECT == m->type || + PMIX_COMPRESSED_STRING == m->type) { pmix_byte_object_t *_b = (pmix_byte_object_t*)m->array; PMIX_BYTE_OBJECT_FREE(_b, m->size); } else if (PMIX_STRING == m->type) { @@ -2633,7 +2762,8 @@ static inline void pmix_darray_destruct(pmix_data_array_t *m) PMIX_QUERY_CREATE((m)->array, (n)); \ } else if (PMIX_APP == (t)) { \ PMIX_APP_CREATE((m)->array, (n)); \ - } else if (PMIX_BYTE_OBJECT == (t)) { \ + } else if (PMIX_BYTE_OBJECT == (t) || \ + PMIX_COMPRESSED_STRING == (t)) { \ PMIX_BYTE_OBJECT_CREATE((m)->array, (n)); \ } else if (PMIX_ALLOC_DIRECTIVE == (t) || \ PMIX_PROC_STATE == (t) || \ @@ -2642,7 +2772,8 @@ static inline void pmix_darray_destruct(pmix_data_array_t *m) PMIX_DATA_RANGE == (t) || \ PMIX_BYTE == (t) || \ PMIX_INT8 == (t) || \ - PMIX_UINT8 == (t)) { \ + PMIX_UINT8 == (t) || \ + PMIX_POINTER == (t)) { \ (m)->array = calloc((n), sizeof(int8_t)); \ } else if (PMIX_STRING == (t)) { \ (m)->array = calloc((n), sizeof(char*)); \ @@ -2675,6 +2806,12 @@ static inline void pmix_darray_destruct(pmix_data_array_t *m) (m)->array = calloc((n), sizeof(struct timeval)); \ } else if (PMIX_TIME == (t)) { \ (m)->array = calloc((n), sizeof(time_t)); \ + } else if (PMIX_REGATTR == (t)) { \ + PMIX_REGATTR_CREATE((m)->array, (n)); \ + } else if (PMIX_BOOL == (t)) { \ + (m)->array = calloc((n), sizeof(bool)); \ + } else if (PMIX_COORD == (t)) { \ + (m)->array = calloc((n), sizeof(pmix_coord_t)); \ } \ } else { \ (m)->array = NULL; \ @@ -2709,21 +2846,21 @@ static inline void pmix_darray_destruct(pmix_data_array_t *m) * @param len Size of the dest array - 1 * */ -static inline void pmix_strncpy(char *dest, const char *src, size_t len) +static inline void pmix_strncpy(char *dest, + const char *src, + size_t len) { - size_t i, k; - char *new_dest = dest; + size_t i; /* use an algorithm that also protects against * non-NULL-terminated src strings */ - for (i=0, k=0; i <= len; ++i, ++src, ++new_dest) { - ++k; - *new_dest = *src; + for (i=0; i < len; ++i, ++src, ++dest) { + *dest = *src; if ('\0' == *src) { break; } } - dest[k-1] = '\0'; + *dest = '\0'; } #include diff --git a/opal/mca/pmix/pmix4x/pmix/include/pmix_server.h b/opal/mca/pmix/pmix4x/pmix/include/pmix_server.h index 68b474f13f..d96cac7c53 100644 --- a/opal/mca/pmix/pmix4x/pmix/include/pmix_server.h +++ b/opal/mca/pmix/pmix4x/pmix/include/pmix_server.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2015 Research Organization for Information Science @@ -779,6 +779,28 @@ PMIX_EXPORT pmix_status_t PMIx_server_deliver_inventory(pmix_info_t info[], size pmix_info_t directives[], size_t ndirs, pmix_op_cbfunc_t cbfunc, void *cbdata); +/****** ATTRIBUTE REGISTRATION ******/ +/** + * This function is used by the host environment to register with its + * server library the attributes it supports for each pmix_server_module_t + * function. + * + * Parameters include: + * + * function - the string name of the server module function + * (e.g., "register_events", "validate_credential", + * or "allocate") whose attributes are being registered. + * + * attrs - array of pmix_regattr_t describing the attributes supported + * by the host environment for the specified function + * + * nattrs - number of elements in the attrs array + * + */ +PMIX_EXPORT pmix_status_t PMIx_Register_attributes(char *function, + pmix_regattr_t attrs[], size_t nattrs); + + #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/opal/mca/pmix/pmix4x/pmix/include/pmix_version.h.in b/opal/mca/pmix/pmix4x/pmix/include/pmix_version.h.in index e541c5fbd6..38145c04a6 100644 --- a/opal/mca/pmix/pmix4x/pmix/include/pmix_version.h.in +++ b/opal/mca/pmix/pmix4x/pmix/include/pmix_version.h.in @@ -3,6 +3,8 @@ * All rights reserved. * Copyright (c) 2018 IBM Corporation. All rights reserved. * Copyright (c) 2018 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -19,5 +21,5 @@ #define PMIX_VERSION_MINOR @pmixminor@ #define PMIX_VERSION_RELEASE @pmixrelease@ -#define PMIX_NUMERIC_VERSION 0x00040000 +#define PMIX_NUMERIC_VERSION @pmixnumeric@ #endif diff --git a/opal/mca/pmix/pmix4x/pmix/src/atomics/sys/powerpc/atomic.h b/opal/mca/pmix/pmix4x/pmix/src/atomics/sys/powerpc/atomic.h index cfb46eb519..17134e11c1 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/atomics/sys/powerpc/atomic.h +++ b/opal/mca/pmix/pmix4x/pmix/src/atomics/sys/powerpc/atomic.h @@ -13,7 +13,7 @@ * Copyright (c) 2010-2017 IBM Corporation. All rights reserved. * Copyright (c) 2015-2018 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2018 Intel, Inc. All rights reserved. + * Copyright (c) 2018-2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -99,27 +99,7 @@ void pmix_atomic_isync(void) ISYNC(); } -#elif PMIX_XLC_INLINE_ASSEMBLY /* end PMIX_GCC_INLINE_ASSEMBLY */ - -/* Yeah, I don't know who thought this was a reasonable syntax for - * inline assembly. Do these because they are used so often and they - * are fairly simple (aka: there is a tech pub on IBM's web site - * containing the right hex for the instructions). - */ - -#undef PMIX_HAVE_INLINE_ATOMIC_MEM_BARRIER -#define PMIX_HAVE_INLINE_ATOMIC_MEM_BARRIER 0 - -#pragma mc_func pmix_atomic_mb { "7c0004ac" } /* sync */ -#pragma reg_killed_by pmix_atomic_mb /* none */ - -#pragma mc_func pmix_atomic_rmb { "7c2004ac" } /* lwsync */ -#pragma reg_killed_by pmix_atomic_rmb /* none */ - -#pragma mc_func pmix_atomic_wmb { "7c2004ac" } /* lwsync */ -#pragma reg_killed_by pmix_atomic_wmb /* none */ - -#endif +#endif /* end PMIX_GCC_INLINE_ASSEMBLY */ /********************************************************************** * @@ -297,7 +277,7 @@ static inline bool pmix_atomic_compare_exchange_strong_64 (pmix_atomic_int64_t * #define pmix_atomic_sc_64(addr, value, ret) \ do { \ pmix_atomic_int64_t *_addr = (addr); \ - int64_t _foo, _newval = (int64_t) value; \ + int64_t _newval = (int64_t) value; \ int32_t _ret; \ \ __asm__ __volatile__ (" stdcx. %2, 0, %1 \n\t" \ diff --git a/opal/mca/pmix/pmix4x/pmix/src/class/pmix_hotel.h b/opal/mca/pmix/pmix4x/pmix/src/class/pmix_hotel.h index 883a2c5c6c..c26d6cb0e5 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/class/pmix_hotel.h +++ b/opal/mca/pmix/pmix4x/pmix/src/class/pmix_hotel.h @@ -3,6 +3,8 @@ * Copyright (c) 2012-2016 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012 Los Alamos National Security, LLC. All rights reserved * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -53,9 +55,9 @@ #define PMIX_HOTEL_H #include -#include "src/include/types.h" #include "src/include/prefetch.h" #include "pmix_common.h" +#include "src/include/types.h" #include "src/class/pmix_object.h" #include PMIX_EVENT_HEADER @@ -306,7 +308,7 @@ static inline void pmix_hotel_checkout_and_return_occupant(pmix_hotel_t *hotel, *occupant = room->occupant; room->occupant = NULL; if (NULL != hotel->evbase) { - event_del(&(room->eviction_timer_event)); + pmix_event_del(&(room->eviction_timer_event)); } hotel->last_unoccupied_room++; assert(hotel->last_unoccupied_room < hotel->num_rooms); diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmi1.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmi1.c index dd5cb66e7d..52e137a9cf 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmi1.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmi1.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2014 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ @@ -14,8 +14,6 @@ #include -#include - #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmi2.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmi2.c index 4adf6ba37d..0f7a88e0a2 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmi2.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmi2.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ @@ -14,8 +14,6 @@ #include -#include - #ifdef HAVE_STRING_H #include #endif diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client.c index a99f714192..f5b8b0c90c 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2018 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016-2017 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include @@ -46,11 +45,10 @@ #include #endif -#if PMIX_HAVE_ZLIB -#include -#endif #include PMIX_EVENT_HEADER +#ifdef PMIX_EVENT2_THREAD_HEADER #include PMIX_EVENT2_THREAD_HEADER +#endif static const char pmix_version_string[] = PMIX_VERSION; static pmix_status_t pmix_init_result = PMIX_ERR_INIT; @@ -58,7 +56,6 @@ static pmix_status_t pmix_init_result = PMIX_ERR_INIT; #include "src/class/pmix_list.h" #include "src/event/pmix_event.h" #include "src/util/argv.h" -#include "src/util/compress.h" #include "src/util/error.h" #include "src/util/hash.h" #include "src/util/name_fns.h" @@ -67,10 +64,12 @@ static pmix_status_t pmix_init_result = PMIX_ERR_INIT; #include "src/runtime/pmix_rte.h" #include "src/threads/threads.h" #include "src/mca/bfrops/base/base.h" +#include "src/mca/pcompress/base/base.h" #include "src/mca/gds/base/base.h" #include "src/mca/preg/preg.h" #include "src/mca/ptl/base/base.h" #include "src/include/pmix_globals.h" +#include "src/common/pmix_attributes.h" #include "src/common/pmix_iof.h" #include "pmix_client_ops.h" @@ -421,7 +420,7 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, pmix_info_t info[], size_t ninfo) { char *evar; - pmix_status_t rc; + pmix_status_t rc = PMIX_SUCCESS; pmix_cb_t cb; pmix_buffer_t *req; pmix_cmd_t cmd = PMIX_REQ_CMD; @@ -695,7 +694,10 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, if (NULL != info) { _check_for_notify(info, ninfo); } - return PMIX_SUCCESS; + + /* register the client supported attrs */ + rc = pmix_register_client_attrs(); + return rc; } PMIX_EXPORT int PMIx_Initialized(void) @@ -979,7 +981,7 @@ static void _putfn(int sd, short args, void *cbdata) kv->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); if (PMIX_STRING_SIZE_CHECK(cb->value)) { /* compress large strings */ - if (pmix_util_compress_string(cb->value->data.string, &tmp, &len)) { + if (pmix_compress.compress_string(cb->value->data.string, &tmp, &len)) { if (NULL == tmp) { PMIX_ERROR_LOG(PMIX_ERR_NOMEM); rc = PMIX_ERR_NOMEM; diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_connect.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_connect.c index 3938f5f513..7e7b625d6d 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_connect.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_connect.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_fence.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_fence.c index 7a587dcad4..f80eda94ad 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_fence.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_fence.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_get.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_get.c index 46d6c62db8..eb42169294 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_get.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_get.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016-2018 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include @@ -45,16 +44,13 @@ #include #endif -#if PMIX_HAVE_ZLIB -#include -#endif #include PMIX_EVENT_HEADER #include "src/class/pmix_list.h" #include "src/mca/bfrops/bfrops.h" +#include "src/mca/pcompress/base/base.h" #include "src/threads/threads.h" #include "src/util/argv.h" -#include "src/util/compress.h" #include "src/util/error.h" #include "src/util/hash.h" #include "src/util/output.h" @@ -453,7 +449,9 @@ static void infocb(pmix_status_t status, /* if this is a compressed string, then uncompress it */ if (PMIX_COMPRESSED_STRING == info[0].value.type) { kv->type = PMIX_STRING; - pmix_util_uncompress_string(&kv->data.string, (uint8_t*)info[0].value.data.bo.bytes, info[0].value.data.bo.size); + pmix_compress.decompress_string(&kv->data.string, + (uint8_t*)info[0].value.data.bo.bytes, + info[0].value.data.bo.size); if (NULL == kv->data.string) { PMIX_ERROR_LOG(PMIX_ERR_NOMEM); rc = PMIX_ERR_NOMEM; diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_group.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_group.c index 2c73790889..86038be4e6 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_group.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_group.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_pub.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_pub.c index bd6795eac5..54b72ace91 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_pub.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_pub.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_spawn.c b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_spawn.c index b7aefc4316..667d2e84b3 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_spawn.c +++ b/opal/mca/pmix/pmix4x/pmix/src/client/pmix_client_spawn.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/Makefile.include b/opal/mca/pmix/pmix4x/pmix/src/common/Makefile.include index dcd723b956..55bfbb4a81 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/common/Makefile.include +++ b/opal/mca/pmix/pmix4x/pmix/src/common/Makefile.include @@ -1,6 +1,6 @@ # -*- makefile -*- # -# Copyright (c) 2015-2018 Intel, Inc. All rights reserved. +# Copyright (c) 2015-2019 Intel, Inc. All rights reserved. # Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. # $COPYRIGHT$ # @@ -16,7 +16,9 @@ sources += \ common/pmix_control.c \ common/pmix_data.c \ common/pmix_security.c \ - common/pmix_iof.c + common/pmix_iof.c \ + common/pmix_attributes.c headers += \ - common/pmix_iof.h + common/pmix_iof.h \ + common/pmix_attributes.h diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_attributes.c b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_attributes.c new file mode 100644 index 0000000000..7f9410a76e --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_attributes.c @@ -0,0 +1,1145 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2016 Mellanox Technologies, Inc. + * All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +#include + +#include +#include +#include +#include + +#include "src/mca/bfrops/bfrops.h" +#include "src/mca/gds/base/base.h" +#include "src/include/pmix_globals.h" +#include "src/threads/threads.h" +#include "src/client/pmix_client_ops.h" + +#include "src/common/pmix_attributes.h" + +static bool initialized = false; +static pmix_list_t client_attrs; +static pmix_list_t server_attrs; +static pmix_list_t host_attrs; +static pmix_list_t tool_attrs; + +typedef struct { + pmix_list_item_t super; + char *function; + pmix_regattr_t *attrs; + size_t nattrs; +} pmix_attribute_trk_t; + +static void atrkcon(pmix_attribute_trk_t *p) +{ + p->function = NULL; + p->attrs = NULL; + p->nattrs = 0; +} +static void atrkdes(pmix_attribute_trk_t *p) +{ + if (NULL != p->function) { + free(p->function); + } + if (NULL != p->attrs) { + PMIX_REGATTR_FREE(p->attrs, p->nattrs); + } +} +static PMIX_CLASS_INSTANCE(pmix_attribute_trk_t, + pmix_list_item_t, + atrkcon, atrkdes); + +PMIX_EXPORT void pmix_init_registered_attrs(void) +{ + if (!initialized) { + PMIX_CONSTRUCT(&client_attrs, pmix_list_t); + PMIX_CONSTRUCT(&server_attrs, pmix_list_t); + PMIX_CONSTRUCT(&host_attrs, pmix_list_t); + PMIX_CONSTRUCT(&tool_attrs, pmix_list_t); + initialized = true; + } +} + +static pmix_status_t process_reg(char *level, char *function, + pmix_regattr_t attrs[], size_t nattrs) +{ + pmix_attribute_trk_t *fnptr; + pmix_list_t *lst; + size_t n; + + /* select the list this will appear on */ + if (0 == strcmp(level, PMIX_CLIENT_ATTRIBUTES)) { + lst = &client_attrs; + } else if (0 == strcmp(level, PMIX_SERVER_ATTRIBUTES)) { + lst = &server_attrs; + } else if (0 == strcmp(level, PMIX_HOST_ATTRIBUTES)) { + lst = &host_attrs; + } else if (0 == strcmp(level, PMIX_TOOL_ATTRIBUTES)) { + lst = &tool_attrs; + } else { + return PMIX_ERR_BAD_PARAM; + } + + /* see if we already have this function */ + PMIX_LIST_FOREACH(fnptr, lst, pmix_attribute_trk_t) { + if (0 == strcmp(function, fnptr->function)) { + /* we already have this function at this level + * so we must return an error */ + return PMIX_ERR_REPEAT_ATTR_REGISTRATION; + } + } + + fnptr = PMIX_NEW(pmix_attribute_trk_t); + pmix_list_append(lst, &fnptr->super); + fnptr->function = strdup(function); + if (0 < nattrs) { + fnptr->nattrs = nattrs; + PMIX_REGATTR_CREATE(fnptr->attrs, fnptr->nattrs); + for (n=0; n < nattrs; n++) { + fnptr->attrs[n].name = strdup(attrs[n].name); + PMIX_LOAD_KEY(fnptr->attrs[n].string, attrs[n].string); + fnptr->attrs[n].type = attrs[n].type; + PMIX_ARGV_COPY(fnptr->attrs[n].description, attrs[n].description); + } + } + return PMIX_SUCCESS; +} + +PMIX_EXPORT pmix_status_t PMIx_Register_attributes(char *function, + pmix_regattr_t attrs[], size_t nattrs) +{ + pmix_status_t rc; + + PMIX_ACQUIRE_THREAD(&pmix_global_lock); + if (pmix_globals.init_cntr <= 0) { + PMIX_RELEASE_THREAD(&pmix_global_lock); + return PMIX_ERR_INIT; + } + + rc = process_reg(PMIX_HOST_ATTRIBUTES, function, attrs, nattrs); + PMIX_RELEASE_THREAD(&pmix_global_lock); + return rc; +} + +PMIX_EXPORT void pmix_release_registered_attrs(void) +{ + if (initialized) { + PMIX_LIST_DESTRUCT(&client_attrs); + PMIX_LIST_DESTRUCT(&server_attrs); + PMIX_LIST_DESTRUCT(&host_attrs); + PMIX_LIST_DESTRUCT(&tool_attrs); + } +} + +/* sadly, we cannot dynamically register our supported attributes + * as that would require the user to first call the function whose + * attributes they want to know about - which somewhat defeats the + * purpose. Until someone comes up with a better solution, we will + * manually maintain the list */ +static char *client_fns[] = { + "PMIx_Init", + "PMIx_Finalize", + "PMIx_Put", + "PMIx_Get", + "PMIx_Get_nb", + "PMIx_Store_internal", + "PMIx_Commit", + "PMIx_Fence", + "PMIx_Fence_nb", + "PMIx_Publish", + "PMIx_Group_construct", + "PMIx_Group_construct_nb", + "PMIx_Group_destruct", + "PMIx_Group_destruct_nb", + "PMIx_Group_invite", + "PMIx_Group_invite_nb", + "PMIx_Group_join", + "PMIx_Group_join_nb", + "PMIx_Spawn", + "PMIx_Spawn_nb", + "PMIx_Log", + "PMIx_Log_nb" +}; + +typedef struct { + char *name; + char *string; + pmix_data_type_t type; + char **description; +} pmix_regattr_input_t; + +static pmix_regattr_input_t client_attributes[] = { + // init + {.name = "PMIX_GDS_MODULE", .string = PMIX_GDS_MODULE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_EVENT_BASE", .string = PMIX_EVENT_BASE, .type = PMIX_POINTER, .description = (char *[]){"VALID MEMORY REFERENCE", NULL}}, + {.name = "PMIX_HOSTNAME", .string = PMIX_HOSTNAME, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_NODEID", .string = PMIX_NODEID, .type = PMIX_UINT32, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = "PMIX_PROGRAMMING_MODEL", .string = PMIX_PROGRAMMING_MODEL, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_MODEL_LIBRARY_NAME", .string = PMIX_MODEL_LIBRARY_NAME, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_MODEL_LIBRARY_VERSION", .string = PMIX_MODEL_LIBRARY_VERSION, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_THREADING_MODEL", .string = PMIX_THREADING_MODEL, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_USOCK_DISABLE", .string = PMIX_USOCK_DISABLE, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Disable usock messaging interface", NULL}}, + {.name = "PMIX_SOCKET_MODE", .string = PMIX_SOCKET_MODE, .type = PMIX_UINT32, .description = (char *[]){"Valid POSIX mode_t value", NULL}}, + {.name = "PMIX_TCP_REPORT_URI", .string = PMIX_TCP_REPORT_URI, .type = PMIX_STRING, .description = (char *[]){"-, +, or filename", NULL}}, + {.name = "PMIX_TCP_IF_INCLUDE", .string = PMIX_TCP_IF_INCLUDE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Comma-separated list of", "TCP interfaces to include", NULL}}, + {.name = "PMIX_TCP_IF_EXCLUDE", .string = PMIX_TCP_IF_EXCLUDE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Comma-separated list of", "TCP interfaces to exclude", NULL}}, + {.name = "PMIX_TCP_IPV4_PORT", .string = PMIX_TCP_IPV4_PORT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", "IPv4 port to be used", NULL}}, + {.name = "PMIX_TCP_IPV6_PORT", .string = PMIX_TCP_IPV6_PORT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", "IPv6 port to be used", NULL}}, + {.name = "PMIX_TCP_DISABLE_IPV4", .string = PMIX_TCP_DISABLE_IPV4, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Disable IPv4 messaging interface", NULL}}, + {.name = "PMIX_TCP_DISABLE_IPV6", .string = PMIX_TCP_DISABLE_IPV6, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Disable IPv6 messaging interface", NULL}}, + {.name = ""}, + // finalize + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Execute fence during finalize", NULL}}, + {.name = ""}, + // put + {.name = ""}, + // get + {.name = "PMIX_DATA_SCOPE", .string = PMIX_DATA_SCOPE, .type = PMIX_SCOPE, .description = (char *[]){"PMIX_SCOPE_UNDEF,PMIX_LOCAL,", "PMIX_REMOTE,PMIX_GLOBAL,", "PMIX_INTERNAL", NULL}}, + {.name = "PMIX_OPTIONAL", .string = PMIX_OPTIONAL, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_IMMEDIATE", .string = PMIX_IMMEDIATE, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_SESSION_INFO", .string = PMIX_SESSION_INFO, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Requesting session-level value", NULL}}, + {.name = "PMIX_JOB_INFO", .string = PMIX_JOB_INFO, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Requesting job-level value", NULL}}, + {.name = "PMIX_APP_INFO", .string = PMIX_APP_INFO, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Requesting app-level value", NULL}}, + {.name = "PMIX_NODE_INFO", .string = PMIX_NODE_INFO, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Requesting node-level value", NULL}}, + {.name = ""}, + // get_nb + {.name = "PMIX_DATA_SCOPE", .string = PMIX_DATA_SCOPE, .type = PMIX_SCOPE, .description = (char *[]){"PMIX_SCOPE_UNDEF,PMIX_LOCAL,", "PMIX_REMOTE,PMIX_GLOBAL,", "PMIX_INTERNAL", NULL}}, + {.name = "PMIX_OPTIONAL", .string = PMIX_OPTIONAL, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_IMMEDIATE", .string = PMIX_IMMEDIATE, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_SESSION_INFO", .string = PMIX_SESSION_INFO, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Requesting session-level value", NULL}}, + {.name = "PMIX_JOB_INFO", .string = PMIX_JOB_INFO, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Requesting job-level value", NULL}}, + {.name = "PMIX_APP_INFO", .string = PMIX_APP_INFO, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Requesting app-level value", NULL}}, + {.name = "PMIX_NODE_INFO", .string = PMIX_NODE_INFO, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Requesting node-level value", NULL}}, + {.name = ""}, + // store_internal + {.name = ""}, + // commit + {.name = ""}, + // fence + {.name = ""}, + // fence_nb + {.name = ""}, + // publish + {.name = ""}, + // group_construct + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // group_construct_nb + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // group_destruct + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // group_destruct_nb + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // group_invite + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // group_invite_nb + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // group_join + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // group_join_nb + {.name = "PMIX_SETUP_APP_ENVARS", .string = PMIX_SETUP_APP_ENVARS, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = ""}, + // spawn + {.name = "PMIX_SETUP_APP_ENVARS", .string = PMIX_SETUP_APP_ENVARS, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = ""}, + // spawn_nb + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // log + {.name = "PMIX_LOG_GENERATE_TIMESTAMP", .string = PMIX_LOG_GENERATE_TIMESTAMP, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // log_nb + {.name = "PMIX_LOG_GENERATE_TIMESTAMP", .string = PMIX_LOG_GENERATE_TIMESTAMP, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, +}; + +/***** REGISTER CLIENT ATTRS *****/ +static bool client_attrs_regd = false; + +PMIX_EXPORT pmix_status_t pmix_register_client_attrs(void) +{ + size_t nregs, nattrs, n, m; + size_t cnt = 0; + pmix_status_t rc = PMIX_SUCCESS; + pmix_regattr_t *attrs; + + if (client_attrs_regd) { + return PMIX_SUCCESS; + } + client_attrs_regd = true; + + nregs = sizeof(client_fns) / sizeof(char*); + + /* we know we have to prep the GDS, PTL, BFROPS, and SEC + * entries as these are dynamically defined */ + client_attributes[0].description[0] = pmix_gds_base_get_available_modules(); + + for (n=0; n < nregs; n++) { + nattrs = 0; + while (0 != strlen(client_attributes[cnt+nattrs].name)) { + ++nattrs; + } + PMIX_REGATTR_CREATE(attrs, nattrs); + for (m=0; m < nattrs; m++) { + attrs[m].name = strdup(client_attributes[m+cnt].name); + PMIX_LOAD_KEY(attrs[m].string, client_attributes[m+cnt].string); + attrs[m].type = client_attributes[m+cnt].type; + PMIX_ARGV_COPY(attrs[m].description, client_attributes[m+cnt].description); + } + rc = process_reg(PMIX_CLIENT_ATTRIBUTES, + client_fns[n], + attrs, nattrs); + PMIX_REGATTR_FREE(attrs, nattrs); + if (PMIX_SUCCESS != rc) { + break; + } + cnt += nattrs + 1; + } + + if (NULL != client_attributes[0].description[0]) { + free(client_attributes[0].description[0]); + client_attributes[0].description[0] = NULL; + } + return PMIX_SUCCESS; +} + +static char *server_fns[] = { + "PMIx_server_init", + "PMIx_server_finalize", + "PMIx_generate_regex", + "PMIx_generate_ppn", + "PMIx_server_register_nspace", + "PMIx_server_deregister_nspace", + "PMIx_server_register_client", + "PMIx_server_deregister_client", + "PMIx_server_setup_fork", + "PMIx_server_dmodex_request", + "PMIx_server_setup_application", + "PMIx_Register_attributes", + "PMIx_server_setup_local_support", + "PMIx_server_IOF_deliver", + "PMIx_server_collect_inventory", + "PMIx_server_deliver_inventory", + "PMIx_Get", + "PMIx_Get_nb", + "PMIx_Fence", + "PMIx_Fence_nb", + "PMIx_Spawn", + "PMIx_Spawn_nb", + "PMIx_Connect", + "PMIx_Connect_nb", + "PMIx_Register_event_handler", + "PMIx_Query_info_nb", + "PMIx_Job_control", + "PMIx_Job_control_nb" +}; + +static pmix_regattr_input_t server_attributes[] = { + // init + {.name = "PMIX_GDS_MODULE", .string = PMIX_GDS_MODULE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_EVENT_BASE", .string = PMIX_EVENT_BASE, .type = PMIX_POINTER, .description = (char *[]){"VALID MEMORY REFERENCE", NULL}}, + {.name = "PMIX_HOSTNAME", .string = PMIX_HOSTNAME, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_NODEID", .string = PMIX_NODEID, .type = PMIX_UINT32, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = "PMIX_SINGLE_LISTENER", .string = PMIX_SINGLE_LISTENER, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Only use one messaging interface", NULL}}, + {.name = "PMIX_USOCK_DISABLE", .string = PMIX_USOCK_DISABLE, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Disable usock messaging interface", NULL}}, + {.name = "PMIX_SOCKET_MODE", .string = PMIX_SOCKET_MODE, .type = PMIX_UINT32, .description = (char *[]){"Valid POSIX mode_t value", NULL}}, + {.name = "PMIX_TCP_REPORT_URI", .string = PMIX_TCP_REPORT_URI, .type = PMIX_STRING, .description = (char *[]){"-, +, or filename", NULL}}, + {.name = "PMIX_TCP_IF_INCLUDE", .string = PMIX_TCP_IF_INCLUDE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Comma-separated list of", "TCP interfaces to include", NULL}}, + {.name = "PMIX_TCP_IF_EXCLUDE", .string = PMIX_TCP_IF_EXCLUDE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Comma-separated list of", "TCP interfaces to exclude", NULL}}, + {.name = "PMIX_TCP_IPV4_PORT", .string = PMIX_TCP_IPV4_PORT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", "IPv4 port to be used", NULL}}, + {.name = "PMIX_TCP_IPV6_PORT", .string = PMIX_TCP_IPV6_PORT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", "IPv6 port to be used", NULL}}, + {.name = "PMIX_TCP_DISABLE_IPV4", .string = PMIX_TCP_DISABLE_IPV4, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Disable IPv4 messaging interface", NULL}}, + {.name = "PMIX_TCP_DISABLE_IPV6", .string = PMIX_TCP_DISABLE_IPV6, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Disable IPv6 messaging interface", NULL}}, + {.name = "PMIX_SERVER_REMOTE_CONNECTIONS", .string = PMIX_SERVER_REMOTE_CONNECTIONS, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Allow connections from", "remote tools", NULL}}, + {.name = "PMIX_SERVER_NSPACE", .string = PMIX_SERVER_NSPACE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Namespace assigned to server", NULL}}, + {.name = "PMIX_SERVER_RANK", .string = PMIX_SERVER_RANK, .type = PMIX_PROC_RANK, .description = (char *[]){"POSITIVE INTEGERS", "Rank assigned to server", NULL}}, + {.name = "PMIX_SERVER_TMPDIR", .string = PMIX_SERVER_TMPDIR, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Path to temp directory", "assigned to server", NULL}}, + {.name = "PMIX_SYSTEM_TMPDIR", .string = PMIX_SYSTEM_TMPDIR, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Path to system temp directory", NULL}}, + {.name = "PMIX_SERVER_TOOL_SUPPORT", .string = PMIX_SERVER_TOOL_SUPPORT, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Allow tool connections", NULL}}, + {.name = "PMIX_SERVER_SYSTEM_SUPPORT", .string = PMIX_SERVER_SYSTEM_SUPPORT, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Declare server as being the", "local system server for PMIx", "connection requests", NULL}}, + {.name = ""}, + // finalize + {.name = ""}, + // regex + {.name = "PMIX_DATA_SCOPE", .string = PMIX_DATA_SCOPE, .type = PMIX_SCOPE, .description = (char *[]){"PMIX_SCOPE_UNDEF,PMIX_LOCAL,","PMIX_REMOTE,PMIX_GLOBAL,", "PMIX_INTERNAL", NULL}}, + {.name = "PMIX_OPTIONAL", .string = PMIX_OPTIONAL, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_IMMEDIATE", .string = PMIX_IMMEDIATE, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // ppn + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // register_nspace + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // deregister_nspace + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // register_client + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // deregister_client + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // setup_fork + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // dmodex_request + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // setup_application + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // register_attributes + {.name = "PMIX_SETUP_APP_ENVARS", .string = PMIX_SETUP_APP_ENVARS, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = ""}, + // setup_local_support + {.name = "PMIX_SETUP_APP_ENVARS", .string = PMIX_SETUP_APP_ENVARS, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = ""}, + // IOF deliver + {.name = "PMIX_EMBED_BARRIER", .string = PMIX_EMBED_BARRIER, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // collect_inventory + {.name = "PMIX_LOG_GENERATE_TIMESTAMP", .string = PMIX_LOG_GENERATE_TIMESTAMP, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // deliver_inventory + {.name = "PMIX_LOG_GENERATE_TIMESTAMP", .string = PMIX_LOG_GENERATE_TIMESTAMP, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // get + {.name = "PMIX_IMMEDIATE", .string = PMIX_IMMEDIATE, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // get_nb + {.name = "PMIX_IMMEDIATE", .string = PMIX_IMMEDIATE, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // fence + {.name = "PMIX_COLLECT_DATA", .string = PMIX_COLLECT_DATA, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // fence_nb + {.name = "PMIX_COLLECT_DATA", .string = PMIX_COLLECT_DATA, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // spawn + {.name = "PMIX_FWD_STDIN", .string = PMIX_FWD_STDIN, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_FWD_STDOUT", .string = PMIX_FWD_STDOUT, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_FWD_STDERR", .string = PMIX_FWD_STDERR, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_FWD_STDDIAG", .string = PMIX_FWD_STDDIAG, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // spawn_nb + {.name = "PMIX_FWD_STDIN", .string = PMIX_FWD_STDIN, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_FWD_STDOUT", .string = PMIX_FWD_STDOUT, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_FWD_STDERR", .string = PMIX_FWD_STDERR, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_FWD_STDDIAG", .string = PMIX_FWD_STDDIAG, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // connect + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // connect_nb + {.name = "PMIX_TIMEOUT", .string = PMIX_TIMEOUT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = ""}, + // register_event + {.name = "PMIX_EVENT_AFFECTED_PROC", .string = PMIX_EVENT_AFFECTED_PROC, .type = PMIX_PROC, .description = (char *[]){"pmix_proc_t*", NULL}}, + {.name = "PMIX_EVENT_AFFECTED_PROCS", .string = PMIX_EVENT_AFFECTED_PROCS, .type = PMIX_DATA_ARRAY, .description = (char *[]){"Array of pmix_proc_t", NULL}}, + {.name = ""}, + // query + {.name = "PMIX_QUERY_REFRESH_CACHE", .string = PMIX_QUERY_REFRESH_CACHE, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_PROCID", .string = PMIX_PROCID, .type = PMIX_PROC, .description = (char *[]){"pmix_proc_t*", NULL}}, + {.name = "PMIX_NSPACE", .string = PMIX_NSPACE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_RANK", .string = PMIX_RANK, .type = PMIX_PROC_RANK, .description = (char *[]){"UNSIGNED INT32", NULL}}, + {.name = "PMIX_HOSTNAME", .string = PMIX_HOSTNAME, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = ""}, + // job_ctrl + {.name = "PMIX_REGISTER_CLEANUP", .string = PMIX_REGISTER_CLEANUP, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_REGISTER_CLEANUP_DIR", .string = PMIX_REGISTER_CLEANUP_DIR, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_CLEANUP_RECURSIVE", .string = PMIX_CLEANUP_RECURSIVE, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_CLEANUP_IGNORE", .string = PMIX_CLEANUP_IGNORE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_CLEANUP_LEAVE_TOPDIR", .string = PMIX_CLEANUP_LEAVE_TOPDIR, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, + // job_ctrl_nb + {.name = "PMIX_REGISTER_CLEANUP", .string = PMIX_REGISTER_CLEANUP, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_REGISTER_CLEANUP_DIR", .string = PMIX_REGISTER_CLEANUP_DIR, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_CLEANUP_RECURSIVE", .string = PMIX_CLEANUP_RECURSIVE, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = "PMIX_CLEANUP_IGNORE", .string = PMIX_CLEANUP_IGNORE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_CLEANUP_LEAVE_TOPDIR", .string = PMIX_CLEANUP_LEAVE_TOPDIR, .type = PMIX_BOOL, .description = (char *[]){"True,False", NULL}}, + {.name = ""}, +}; + +/***** REGISTER SERVER ATTRS *****/ +static bool server_attrs_regd = false; + +PMIX_EXPORT pmix_status_t pmix_register_server_attrs(void) +{ + size_t nregs, nattrs, n, m; + size_t cnt = 0; + pmix_status_t rc = PMIX_SUCCESS; + pmix_regattr_t *attrs; + + if (server_attrs_regd) { + return PMIX_SUCCESS; + } + server_attrs_regd = true; + + nregs = sizeof(server_fns) / sizeof(char*); + + /* we know we have to prep the GDS, PTL, BFROPS, and SEC + * entries as these are dynamically defined */ + server_attributes[0].description[0] = pmix_gds_base_get_available_modules(); + + for (n=0; n < nregs; n++) { + nattrs = 0; + while (0 != strlen(server_attributes[cnt+nattrs].name)) { + ++nattrs; + } + PMIX_REGATTR_CREATE(attrs, nattrs); + for (m=0; m < nattrs; m++) { + attrs[m].name = strdup(server_attributes[m+cnt].name); + PMIX_LOAD_KEY(attrs[m].string, server_attributes[m+cnt].string); + attrs[m].type = server_attributes[m+cnt].type; + PMIX_ARGV_COPY(attrs[m].description, server_attributes[m+cnt].description); + } + rc = process_reg(PMIX_SERVER_ATTRIBUTES, + server_fns[n], + attrs, nattrs); + PMIX_REGATTR_FREE(attrs, nattrs); + if (PMIX_SUCCESS != rc) { + break; + } + cnt += nattrs + 1; + } + + return PMIX_SUCCESS; +} + +static char *tool_fns[] = { + "PMIx_tool_init", + "PMIx_tool_finalize", + "PMIx_tool_connect_to_server" +}; + +static pmix_regattr_input_t tool_attributes[] = { + // init + {.name = "PMIX_GDS_MODULE", .string = PMIX_GDS_MODULE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_EVENT_BASE", .string = PMIX_EVENT_BASE, .type = PMIX_POINTER, .description = (char *[]){"VALID MEMORY REFERENCE", NULL}}, + {.name = "PMIX_HOSTNAME", .string = PMIX_HOSTNAME, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_NODEID", .string = PMIX_NODEID, .type = PMIX_UINT32, .description = (char *[]){"POSITIVE INTEGERS", NULL}}, + {.name = "PMIX_TOOL_NSPACE", .string = PMIX_TOOL_NSPACE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", NULL}}, + {.name = "PMIX_TOOL_RANK", .string = PMIX_TOOL_RANK, .type = PMIX_PROC_RANK, .description = (char *[]){"POSITIVE INTEGERS", "Rank assigned to tool", NULL}}, + {.name = "PMIX_TOOL_DO_NOT_CONNECT", .string = PMIX_TOOL_DO_NOT_CONNECT, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Do not connect to server", NULL}}, + {.name = "PMIX_CONNECT_TO_SYSTEM", .string = PMIX_CONNECT_TO_SYSTEM, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Connect to system PMIx server", NULL}}, + {.name = "PMIX_CONNECT_SYSTEM_FIRST", .string = PMIX_CONNECT_SYSTEM_FIRST, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Try system PMIx server first", NULL}}, + {.name = "PMIX_SERVER_PIDINFO", .string = PMIX_SERVER_PIDINFO, .type = PMIX_PID, .description = (char *[]){"Valid pid_t value", "PID of target PMIx server", NULL}}, + {.name = "PMIX_TCP_URI", .string = PMIX_TCP_URI, .type = PMIX_STRING, .description = (char *[]){"Valid PMIx URI", "URI of PMIx server to connect to", NULL}}, + {.name = "PMIX_SERVER_URI", .string = PMIX_SERVER_URI, .type = PMIX_STRING, .description = (char *[]){"Valid PMIx URI", "URI of PMIx server to connect to", NULL}}, + {.name = "PMIX_SERVER_NSPACE", .string = PMIX_SERVER_NSPACE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Namespace of PMIx server to", "connect to", NULL}}, + {.name = "PMIX_CONNECT_RETRY_DELAY", .string = PMIX_CONNECT_RETRY_DELAY, .type = PMIX_UINT32, .description = (char *[]){"POSITIVE INTEGERS", "Seconds between connection", "attempts", NULL}}, + {.name = "PMIX_CONNECT_MAX_RETRIES", .string = PMIX_CONNECT_MAX_RETRIES, .type = PMIX_UINT32, .description = (char *[]){"POSITIVE INTEGERS", "Max number of connection retries", NULL}}, + {.name = "PMIX_SOCKET_MODE", .string = PMIX_SOCKET_MODE, .type = PMIX_UINT32, .description = (char *[]){"Valid POSIX mode_t value", NULL}}, + {.name = "PMIX_TCP_REPORT_URI", .string = PMIX_TCP_REPORT_URI, .type = PMIX_STRING, .description = (char *[]){"-, +, or filename", NULL}}, + {.name = "PMIX_TCP_IF_INCLUDE", .string = PMIX_TCP_IF_INCLUDE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Comma-separated list of", "TCP interfaces to include", NULL}}, + {.name = "PMIX_TCP_IF_EXCLUDE", .string = PMIX_TCP_IF_EXCLUDE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Comma-separated list of", "TCP interfaces to exclude", NULL}}, + {.name = "PMIX_TCP_IPV4_PORT", .string = PMIX_TCP_IPV4_PORT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", "IPv4 port to be used", NULL}}, + {.name = "PMIX_TCP_IPV6_PORT", .string = PMIX_TCP_IPV6_PORT, .type = PMIX_INT, .description = (char *[]){"POSITIVE INTEGERS", "IPv6 port to be used", NULL}}, + {.name = "PMIX_TCP_DISABLE_IPV4", .string = PMIX_TCP_DISABLE_IPV4, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Disable IPv4 messaging interface", NULL}}, + {.name = "PMIX_TCP_DISABLE_IPV6", .string = PMIX_TCP_DISABLE_IPV6, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Disable IPv6 messaging interface", NULL}}, + {.name = "PMIX_FWD_STDIN", .string = PMIX_FWD_STDIN, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Forward stdin of the tool", NULL}}, + {.name = "PMIX_LAUNCHER", .string = PMIX_LAUNCHER, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Tool is a job launcher", NULL}}, + {.name = "PMIX_SERVER_TMPDIR", .string = PMIX_SERVER_TMPDIR, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Path to temp directory", "assigned to tool", NULL}}, + {.name = "PMIX_SYSTEM_TMPDIR", .string = PMIX_SYSTEM_TMPDIR, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Path to system temp directory", NULL}}, + {.name = ""}, + // finalize + {.name = ""}, + // connect_to_server + {.name = "PMIX_CONNECT_TO_SYSTEM", .string = PMIX_CONNECT_TO_SYSTEM, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Connect to system PMIx server", NULL}}, + {.name = "PMIX_CONNECT_SYSTEM_FIRST", .string = PMIX_CONNECT_SYSTEM_FIRST, .type = PMIX_BOOL, .description = (char *[]){"True,False", "Try system PMIx server first", NULL}}, + {.name = "PMIX_SERVER_PIDINFO", .string = PMIX_SERVER_PIDINFO, .type = PMIX_PID, .description = (char *[]){"Valid pid_t value", "PID of target PMIx server", NULL}}, + {.name = "PMIX_TCP_URI", .string = PMIX_TCP_URI, .type = PMIX_STRING, .description = (char *[]){"Valid PMIx URI", "URI of PMIx server to connect to", NULL}}, + {.name = "PMIX_SERVER_URI", .string = PMIX_SERVER_URI, .type = PMIX_STRING, .description = (char *[]){"Valid PMIx URI", "URI of PMIx server to connect to", NULL}}, + {.name = "PMIX_SERVER_NSPACE", .string = PMIX_SERVER_NSPACE, .type = PMIX_STRING, .description = (char *[]){"UNRESTRICTED", "Namespace of PMIx server to", "connect to", NULL}}, + {.name = ""}, +}; + +/***** REGISTER TOOL ATTRS *****/ +static bool tool_attrs_regd = false; + +PMIX_EXPORT pmix_status_t pmix_register_tool_attrs(void) +{ + size_t nregs, nattrs, n, m; + size_t cnt = 0; + pmix_status_t rc = PMIX_SUCCESS; + pmix_regattr_t *attrs; + + if (tool_attrs_regd) { + return PMIX_SUCCESS; + } + tool_attrs_regd = true; + + nregs = sizeof(tool_fns) / sizeof(char*); + + /* we know we have to prep the GDS, PTL, BFROPS, and SEC + * entries as these are dynamically defined */ + tool_attributes[0].description[0] = pmix_gds_base_get_available_modules(); + + for (n=0; n < nregs; n++) { + nattrs = 0; + while (0 != strlen(tool_attributes[cnt+nattrs].name)) { + ++nattrs; + } + PMIX_REGATTR_CREATE(attrs, nattrs); + for (m=0; m < nattrs; m++) { + attrs[m].name = strdup(tool_attributes[m+cnt].name); + PMIX_LOAD_KEY(attrs[m].string, tool_attributes[m+cnt].string); + attrs[m].type = tool_attributes[m+cnt].type; + PMIX_ARGV_COPY(attrs[m].description, tool_attributes[m+cnt].description); + } + rc = process_reg(PMIX_TOOL_ATTRIBUTES, + tool_fns[n], + attrs, nattrs); + PMIX_REGATTR_FREE(attrs, nattrs); + if (PMIX_SUCCESS != rc) { + break; + } + cnt += nattrs + 1; + } + + return PMIX_SUCCESS; +} + +/***** PROCESS QUERY ATTRS *****/ +static void _get_attrs(pmix_list_t *lst, + pmix_info_t *info, + pmix_list_t *attrs) +{ + pmix_attribute_trk_t *trk, *tptr; + pmix_infolist_t *ip; + pmix_data_array_t *darray; + pmix_regattr_t *regarray; + size_t m; + char **fns; + + /* the value in the info is a comma-delimited list of + * functions whose attributes are being requested */ + fns = pmix_argv_split(info->value.data.string, ','); + + /* search the list for these functions */ + PMIX_LIST_FOREACH(tptr, attrs, pmix_attribute_trk_t) { + trk = NULL; + for (m=0; NULL != fns[m] && NULL == trk; m++) { + if (0 == strcmp(fns[m], tptr->function) || + 0 == strcmp(fns[m], "all")) { + trk = tptr; + break; + } + } + if (NULL == trk || NULL == trk->attrs) { + /* function wasn't found - no attrs + * registered for it */ + continue; + } + /* add the found attrs to the results */ + ip = PMIX_NEW(pmix_infolist_t); + PMIX_LOAD_KEY(ip->info.key, tptr->function); + /* create the data array to hold the results */ + PMIX_DATA_ARRAY_CREATE(darray, trk->nattrs, PMIX_REGATTR); + ip->info.value.type = PMIX_DATA_ARRAY; + ip->info.value.data.darray = darray; + regarray = (pmix_regattr_t*)darray->array; + for (m=0; m < trk->nattrs; m++) { + PMIX_REGATTR_XFER(®array[m], &trk->attrs[m]); + } + pmix_list_append(lst, &ip->super); + } +} + +static void _get_fns(pmix_list_t *lst, + pmix_info_t *info, + pmix_list_t *attrs) +{ + pmix_attribute_trk_t *tptr; + pmix_infolist_t *ip; + char **fns = NULL, *tmp; + + /* search the list for these functions */ + PMIX_LIST_FOREACH(tptr, attrs, pmix_attribute_trk_t) { + pmix_argv_append_nosize(&fns, tptr->function); + } + if (0 < pmix_argv_count(fns)) { + ip = PMIX_NEW(pmix_infolist_t); + tmp = pmix_argv_join(fns, ','); + PMIX_INFO_LOAD(&ip->info, info->key, tmp, PMIX_STRING); + pmix_list_append(lst, &ip->super); + pmix_argv_free(fns); + } +} + +static void _local_relcb(void *cbdata) +{ + pmix_query_caddy_t *cd = (pmix_query_caddy_t*)cbdata; + PMIX_RELEASE(cd); +} + +static void relcbfunc(void *cbdata) +{ + pmix_shift_caddy_t *cd = (pmix_shift_caddy_t*)cbdata; + + pmix_output_verbose(2, pmix_globals.debug_output, + "pmix:query release callback"); + + if (NULL != cd->info) { + PMIX_INFO_FREE(cd->info, cd->ninfo); + } + PMIX_RELEASE(cd); +} +static void query_cbfunc(struct pmix_peer_t *peer, + pmix_ptl_hdr_t *hdr, + pmix_buffer_t *buf, void *cbdata) +{ + pmix_query_caddy_t *cd = (pmix_query_caddy_t*)cbdata; + pmix_status_t rc; + pmix_shift_caddy_t *results; + int cnt; + + pmix_output_verbose(2, pmix_globals.debug_output, + "pmix:attrs:query cback from server"); + + results = PMIX_NEW(pmix_shift_caddy_t); + + /* unpack the status */ + cnt = 1; + PMIX_BFROPS_UNPACK(rc, peer, buf, &results->status, &cnt, PMIX_STATUS); + if (PMIX_SUCCESS != rc) { + results->status = rc; + goto complete; + } + if (PMIX_SUCCESS != results->status) { + goto complete; + } + + /* unpack any returned data */ + cnt = 1; + PMIX_BFROPS_UNPACK(rc, peer, buf, &results->ninfo, &cnt, PMIX_SIZE); + if (PMIX_SUCCESS != rc) { + results->status = rc; + goto complete; + } + if (0 < results->ninfo) { + PMIX_INFO_CREATE(results->info, results->ninfo); + cnt = results->ninfo; + PMIX_BFROPS_UNPACK(rc, peer, buf, results->info, &cnt, PMIX_INFO); + if (PMIX_SUCCESS != rc) { + results->status = rc; + goto complete; + } + } + + complete: + pmix_output_verbose(2, pmix_globals.debug_output, + "pmix:query cback from server releasing"); + /* release the caller */ + if (NULL != cd->cbfunc) { + cd->cbfunc(results->status, results->info, results->ninfo, cd->cbdata, relcbfunc, results); + } + PMIX_RELEASE(cd); +} + +PMIX_EXPORT void pmix_attrs_query_support(int sd, short args, void *cbdata) +{ + pmix_query_caddy_t *cd = (pmix_query_caddy_t*)cbdata; + pmix_infolist_t *info, *head; + pmix_list_t kyresults; + size_t n, m, p; + pmix_info_t *iptr; + pmix_data_array_t *darray; + pmix_buffer_t *msg; + pmix_cmd_t cmd = PMIX_QUERY_CMD; + pmix_status_t rc; + + PMIX_ACQUIRE_THREAD(&pmix_global_lock); + + for (n=0; n < cd->nqueries; n++) { + if (0 != strcmp(cd->queries[n].keys[0], PMIX_QUERY_ATTRIBUTE_SUPPORT)) { + /* skip this one */ + continue; + } + head = NULL; + for (m=0; m < cd->queries[n].nqual; m++) { + PMIX_CONSTRUCT(&kyresults, pmix_list_t); + if (NULL == cd->queries[n].qualifiers || + PMIX_CHECK_KEY(&cd->queries[n].qualifiers[m], PMIX_CLIENT_ATTRIBUTES)) { + /* everyone has access to the client attrs */ + _get_attrs(&kyresults, &cd->queries[n].qualifiers[m], &client_attrs); + } + if (NULL == cd->queries[n].qualifiers || + PMIX_CHECK_KEY(&cd->queries[n].qualifiers[m], PMIX_CLIENT_FUNCTIONS)) { + /* everyone has access to the client functions */ + _get_fns(&kyresults, &cd->queries[n].qualifiers[m], &client_attrs); + } + if (NULL == cd->queries[n].qualifiers || + PMIX_CHECK_KEY(&cd->queries[n].qualifiers[m], PMIX_SERVER_ATTRIBUTES)) { + /* if I am a server, add in my attrs */ + if (PMIX_PROC_IS_SERVER(pmix_globals.mypeer)) { + _get_attrs(&kyresults, &cd->queries[n].qualifiers[m], &server_attrs); + } else { + /* we need to ask our server for them */ + PMIX_LIST_DESTRUCT(&kyresults); + goto query; + } + } + if (NULL == cd->queries[n].qualifiers || + PMIX_CHECK_KEY(&cd->queries[n].qualifiers[m], PMIX_SERVER_FUNCTIONS)) { + /* if I am a server, add in my fns */ + if (PMIX_PROC_IS_SERVER(pmix_globals.mypeer)) { + _get_fns(&kyresults, &cd->queries[n].qualifiers[m], &server_attrs); + } else { + /* we need to ask our server for them */ + PMIX_LIST_DESTRUCT(&kyresults); + goto query; + } + } + if (NULL == cd->queries[n].qualifiers || + PMIX_CHECK_KEY(&cd->queries[n].qualifiers[m], PMIX_TOOL_ATTRIBUTES)) { + if (PMIX_PROC_IS_TOOL(pmix_globals.mypeer)) { + _get_attrs(&kyresults, &cd->queries[n].qualifiers[m], &tool_attrs); + } + } + if (NULL == cd->queries[n].qualifiers || + PMIX_CHECK_KEY(&cd->queries[n].qualifiers[m], PMIX_TOOL_FUNCTIONS)) { + if (PMIX_PROC_IS_TOOL(pmix_globals.mypeer)) { + _get_fns(&kyresults, &cd->queries[n].qualifiers[m], &tool_attrs); + } + } + if (NULL == cd->queries[n].qualifiers || + PMIX_CHECK_KEY(&cd->queries[n].qualifiers[m], PMIX_HOST_ATTRIBUTES)) { + /* if I am a server, add in the host's */ + if (PMIX_PROC_IS_SERVER(pmix_globals.mypeer)) { + _get_attrs(&kyresults, &cd->queries[n].qualifiers[m], &host_attrs); + } else { + /* we need to ask our server for them */ + PMIX_LIST_DESTRUCT(&kyresults); + goto query; + } + } + if (NULL == cd->queries[n].qualifiers || + PMIX_CHECK_KEY(&cd->queries[n].qualifiers[m], PMIX_HOST_FUNCTIONS)) { + /* if I am a server, add in the host's */ + if (PMIX_PROC_IS_SERVER(pmix_globals.mypeer)) { + _get_fns(&kyresults, &cd->queries[n].qualifiers[m], &host_attrs); + } else { + /* we need to ask our server for them */ + PMIX_LIST_DESTRUCT(&kyresults); + goto query; + } + } + if (0 < (p = pmix_list_get_size(&kyresults))) { + head = PMIX_NEW(pmix_infolist_t); + PMIX_LOAD_KEY(head->info.key, cd->queries[n].keys[m]); + head->info.value.type = PMIX_DATA_ARRAY; + /* create the data array to hold the results */ + PMIX_DATA_ARRAY_CREATE(darray, p, PMIX_INFO); + head->info.value.data.darray = darray; + iptr = (pmix_info_t*)darray->array; + p = 0; + PMIX_LIST_FOREACH(info, &kyresults, pmix_infolist_t) { + PMIX_INFO_XFER(&iptr[p], &info->info); + ++p; + } + pmix_list_append(&cd->results, &head->super); + } + PMIX_LIST_DESTRUCT(&kyresults); + } + } + /* prep the response by converting the list + * of results into an array */ + if (0 < (cd->ninfo = pmix_list_get_size(&cd->results))) { + PMIX_INFO_CREATE(cd->info, cd->ninfo); + n = 0; + PMIX_LIST_FOREACH(info, &cd->results, pmix_infolist_t) { + PMIX_INFO_XFER(&cd->info[n], &info->info); + ++n; + } + cd->status = PMIX_SUCCESS; + } else { + cd->status = PMIX_ERR_NOT_FOUND; + } + PMIX_RELEASE_THREAD(&pmix_global_lock); + goto release; + + query: + /* if we aren't connected, don't attempt to send */ + if (!pmix_globals.connected) { + PMIX_RELEASE_THREAD(&pmix_global_lock); + cd->status = PMIX_ERR_NOT_FOUND; + goto release; + } + PMIX_RELEASE_THREAD(&pmix_global_lock); + + /* relay this request to the server */ + msg = PMIX_NEW(pmix_buffer_t); + PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, + msg, &cmd, 1, PMIX_COMMAND); + if (PMIX_SUCCESS != rc) { + PMIX_RELEASE(msg); + cd->status = rc; + goto release; + } + PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, + msg, &cd->nqueries, 1, PMIX_SIZE); + if (PMIX_SUCCESS != rc) { + PMIX_RELEASE(msg); + cd->status = rc; + goto release; + } + PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, + msg, cd->queries, cd->nqueries, PMIX_QUERY); + if (PMIX_SUCCESS != rc) { + PMIX_RELEASE(msg); + cd->status = rc; + goto release; + } + + pmix_output_verbose(2, pmix_globals.debug_output, + "pmix:query sending to server"); + PMIX_PTL_SEND_RECV(rc, pmix_client_globals.myserver, + msg, query_cbfunc, (void*)cd); + if (PMIX_SUCCESS != rc) { + cd->status = rc; + goto release; + } + return; + + release: + if (NULL != cd->cbfunc) { + cd->cbfunc(cd->status, cd->info, cd->ninfo, cd, _local_relcb, cd); + return; + } + + PMIX_RELEASE(cd); +} + +/***** PRINT QUERY FUNCTIONS RESULTS *****/ +PMIX_EXPORT char** pmix_attributes_print_functions(char *level) +{ + char *title1 = "CLIENT SUPPORTED FUNCTIONS: "; + char *title2 = "SERVER SUPPORTED FUNCTIONS: "; + char *title3 = "HOST SUPPORTED FUNCTIONS: "; + char *title4 = "TOOL SUPPORTED FUNCTIONS: "; + char **ans = NULL; + pmix_list_t *lst; + pmix_attribute_trk_t *fnptr; + + /* select title */ + if (0 == strcmp(level, PMIX_CLIENT_FUNCTIONS)) { + pmix_argv_append_nosize(&ans, title1); + lst = &client_attrs; + } else if (0 == strcmp(level, PMIX_SERVER_FUNCTIONS)) { + pmix_argv_append_nosize(&ans, title2); + lst = &server_attrs; + } else if (0 == strcmp(level, PMIX_HOST_FUNCTIONS)) { + pmix_argv_append_nosize(&ans, title3); + lst = &host_attrs; + } else if (0 == strcmp(level, PMIX_TOOL_FUNCTIONS)) { + pmix_argv_append_nosize(&ans, title4); + lst = &tool_attrs; + } else { + return NULL; + } + + PMIX_LIST_FOREACH(fnptr, lst, pmix_attribute_trk_t) { + pmix_argv_append_nosize(&ans, fnptr->function); + } + return ans; +} + +/***** PRINT QUERY ATTRS RESULTS *****/ + +#define PMIX_PRINT_NAME_COLUMN_WIDTH 30 +#define PMIX_PRINT_STRING_COLUMN_WIDTH 30 +#define PMIX_PRINT_TYPE_COLUMN_WIDTH 20 +#define PMIX_PRINT_ATTR_COLUMN_WIDTH 120 + +void pmix_attributes_print_attrs(char ***ans, char *function, + pmix_regattr_t *attrs, + size_t nattrs) +{ + char line[PMIX_PRINT_ATTR_COLUMN_WIDTH], *tmp; + size_t n, m, len; + + /* print the function */ + memset(line, ' ', PMIX_PRINT_ATTR_COLUMN_WIDTH); + m = 0; + for (n=0; n < strlen(function); n++) { + line[m] = function[n]; + ++m; + } + line[m++] = ':'; + line[m] = '\0'; + pmix_argv_append_nosize(ans, line); + + for (n=0; n < nattrs; n++) { + memset(line, ' ', PMIX_PRINT_ATTR_COLUMN_WIDTH); + line[PMIX_PRINT_ATTR_COLUMN_WIDTH-1] = '\0'; + len = strlen(attrs[n].name); + if (PMIX_PRINT_NAME_COLUMN_WIDTH < len) { + len = PMIX_PRINT_NAME_COLUMN_WIDTH; + } + memcpy(line, attrs[n].name, len); + + len = strlen(attrs[n].string); + if (PMIX_PRINT_STRING_COLUMN_WIDTH < len) { + len = PMIX_PRINT_STRING_COLUMN_WIDTH; + } + memcpy(&line[PMIX_PRINT_NAME_COLUMN_WIDTH+2], attrs[n].string, len); + + tmp = (char*)PMIx_Data_type_string(attrs[n].type); + len = strlen(tmp); + if (PMIX_PRINT_STRING_COLUMN_WIDTH < len) { + len = PMIX_PRINT_STRING_COLUMN_WIDTH; + } + memcpy(&line[PMIX_PRINT_NAME_COLUMN_WIDTH+PMIX_PRINT_STRING_COLUMN_WIDTH+4], tmp, len); + + len = strlen(attrs[n].description[0]); + if ((PMIX_PRINT_ATTR_COLUMN_WIDTH-PMIX_PRINT_NAME_COLUMN_WIDTH-PMIX_PRINT_STRING_COLUMN_WIDTH-PMIX_PRINT_TYPE_COLUMN_WIDTH-6) < len) { + len = PMIX_PRINT_ATTR_COLUMN_WIDTH-PMIX_PRINT_NAME_COLUMN_WIDTH-PMIX_PRINT_STRING_COLUMN_WIDTH-PMIX_PRINT_TYPE_COLUMN_WIDTH-6; + } + memcpy(&line[PMIX_PRINT_NAME_COLUMN_WIDTH+PMIX_PRINT_STRING_COLUMN_WIDTH+PMIX_PRINT_TYPE_COLUMN_WIDTH+6], attrs[n].description[0], len); + line[PMIX_PRINT_ATTR_COLUMN_WIDTH-1] = '\0'; // ensure NULL termination + pmix_argv_append_nosize(ans, line); + + for (m=1; NULL != attrs[n].description[m]; m++) { + memset(line, ' ', PMIX_PRINT_ATTR_COLUMN_WIDTH); + line[PMIX_PRINT_ATTR_COLUMN_WIDTH-1] = '\0'; + len = strlen(attrs[n].description[m]); + if ((PMIX_PRINT_ATTR_COLUMN_WIDTH-PMIX_PRINT_NAME_COLUMN_WIDTH-PMIX_PRINT_STRING_COLUMN_WIDTH-PMIX_PRINT_TYPE_COLUMN_WIDTH-6) < len) { + len = PMIX_PRINT_ATTR_COLUMN_WIDTH-PMIX_PRINT_NAME_COLUMN_WIDTH-PMIX_PRINT_STRING_COLUMN_WIDTH-PMIX_PRINT_TYPE_COLUMN_WIDTH-6; + } + memcpy(&line[PMIX_PRINT_NAME_COLUMN_WIDTH+PMIX_PRINT_STRING_COLUMN_WIDTH+PMIX_PRINT_TYPE_COLUMN_WIDTH+6], attrs[n].description[m], len); + line[PMIX_PRINT_ATTR_COLUMN_WIDTH-1] = '\0'; // ensure NULL termination + pmix_argv_append_nosize(ans, line); + } + } +} + +void pmix_attributes_print_headers(char ***ans, char *level) +{ + size_t n, m, left; + char *title1 = "CLIENT SUPPORTED ATTRIBUTES: "; + char *title2 = "SERVER SUPPORTED ATTRIBUTES: "; + char *title3 = "HOST SUPPORTED ATTRIBUTES: "; + char *title4 = "TOOL SUPPORTED ATTRIBUTES: "; + char line[PMIX_PRINT_ATTR_COLUMN_WIDTH]; + + /* select title */ + if (0 == strcmp(level, PMIX_CLIENT_ATTRIBUTES)) { + pmix_argv_append_nosize(ans, title1); + } else if (0 == strcmp(level, PMIX_SERVER_ATTRIBUTES)) { + pmix_argv_append_nosize(ans, title2); + } else if (0 == strcmp(level, PMIX_HOST_ATTRIBUTES)) { + pmix_argv_append_nosize(ans, title3); + } else if (0 == strcmp(level, PMIX_TOOL_ATTRIBUTES)) { + pmix_argv_append_nosize(ans, title4); + } else { + return; + } + + /* print the column headers */ + memset(line, ' ', PMIX_PRINT_ATTR_COLUMN_WIDTH); + line[PMIX_PRINT_ATTR_COLUMN_WIDTH-1] = '\0'; + left = PMIX_PRINT_NAME_COLUMN_WIDTH/2 - 1; + memcpy(&line[left], "NAME", 4); + + left = 3 + PMIX_PRINT_NAME_COLUMN_WIDTH + (PMIX_PRINT_STRING_COLUMN_WIDTH/2) - 2; + memcpy(&line[left], "STRING", 6); + + left = 3 + PMIX_PRINT_NAME_COLUMN_WIDTH + PMIX_PRINT_STRING_COLUMN_WIDTH + (PMIX_PRINT_TYPE_COLUMN_WIDTH/2) - 2; + memcpy(&line[left], "TYPE", 4); + + left = PMIX_PRINT_NAME_COLUMN_WIDTH + PMIX_PRINT_STRING_COLUMN_WIDTH + PMIX_PRINT_TYPE_COLUMN_WIDTH + + ((PMIX_PRINT_ATTR_COLUMN_WIDTH-PMIX_PRINT_NAME_COLUMN_WIDTH-PMIX_PRINT_STRING_COLUMN_WIDTH-PMIX_PRINT_TYPE_COLUMN_WIDTH)/2) - 3 - strlen("DESCRIPTION")/2; + memcpy(&line[left], "DESCRIPTION", strlen("DESCRIPTION")); + pmix_argv_append_nosize(ans, line); + + /* print the dashes under the column headers */ + memset(line, ' ', PMIX_PRINT_ATTR_COLUMN_WIDTH); + line[PMIX_PRINT_ATTR_COLUMN_WIDTH-1] = '\0'; + m=0; + for (n=0; n < PMIX_PRINT_NAME_COLUMN_WIDTH; n++) { + line[m] = '-'; + ++m; + } + m += 2; // leave gap + for (n=0; n < PMIX_PRINT_STRING_COLUMN_WIDTH; n++) { + line[m] = '-'; + ++m; + } + m += 2; // leave gap + for (n=0; n < PMIX_PRINT_TYPE_COLUMN_WIDTH; n++) { + line[m] = '-'; + ++m; + } + m += 2; // leave gap + while (m < PMIX_PRINT_ATTR_COLUMN_WIDTH-1) { + line[m] = '-'; + ++m; + } + pmix_argv_append_nosize(ans, line); +} + +PMIX_EXPORT char** pmix_attributes_print_attr(char *level, char *function) +{ + size_t n; + char **tmp, **ans=NULL; + pmix_list_t *lst; + pmix_attribute_trk_t *fnptr; + char line[PMIX_PRINT_ATTR_COLUMN_WIDTH]; + + /* select title */ + if (0 == strcmp(level, PMIX_CLIENT_ATTRIBUTES)) { + lst = &client_attrs; + } else if (0 == strcmp(level, PMIX_SERVER_ATTRIBUTES)) { + lst = &server_attrs; + } else if (0 == strcmp(level, PMIX_HOST_ATTRIBUTES)) { + lst = &host_attrs; + } else if (0 == strcmp(level, PMIX_TOOL_ATTRIBUTES)) { + lst = &tool_attrs; + } else { + return NULL; + } + + /* print the column headers */ + pmix_attributes_print_headers(&ans, level); + memset(line, ' ', PMIX_PRINT_ATTR_COLUMN_WIDTH); + line[1] = '\0'; + + /* can be comma-delimited list of functions */ + tmp = pmix_argv_split(function, ','); + for (n=0; NULL != tmp[n]; n++) { + PMIX_LIST_FOREACH(fnptr, lst, pmix_attribute_trk_t) { + if (0 == strcmp(tmp[n], "all")) { + pmix_attributes_print_attrs(&ans, fnptr->function, fnptr->attrs, fnptr->nattrs); + pmix_argv_append_nosize(&ans, line); + } else if (0 == strcmp(tmp[n], fnptr->function)) { + pmix_attributes_print_attrs(&ans, fnptr->function, fnptr->attrs, fnptr->nattrs); + break; + } + } + } + pmix_argv_free(tmp); + + + return ans; +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_attributes.h b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_attributes.h new file mode 100644 index 0000000000..3ce46c8eb5 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_attributes.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012-2013 Los Alamos National Security, LLC. + * All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2017 IBM Corporation. All rights reserved. + * Copyright (c) 2017 Mellanox Technologies. All rights reserved. + * Copyright (c) 2018 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +/** + * @file + * + * I/O Forwarding Service + */ + +#ifndef PMIX_ATTRIBUTES_H +#define PMIX_ATTRIBUTES_H + +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_UIO_H +#include +#endif +#ifdef HAVE_NET_UIO_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "src/class/pmix_list.h" + +BEGIN_C_DECLS + +PMIX_EXPORT void pmix_init_registered_attrs(void); +PMIX_EXPORT void pmix_release_registered_attrs(void); +PMIX_EXPORT pmix_status_t pmix_register_tool_attrs(void); + +PMIX_EXPORT pmix_status_t pmix_register_client_attrs(void); +PMIX_EXPORT pmix_status_t pmix_register_server_attrs(void); + +PMIX_EXPORT char** pmix_attributes_print_functions(char *level); +PMIX_EXPORT char** pmix_attributes_print_attr(char *level, char *function); +PMIX_EXPORT void pmix_attributes_print_attrs(char ***ans, char *function, + pmix_regattr_t *attrs, + size_t nattrs); +PMIX_EXPORT void pmix_attributes_print_headers(char ***ans, char *level); + +PMIX_EXPORT void pmix_attrs_query_support(int sd, short args, void *cbdata); + +END_C_DECLS + +#endif /* PMIX_IOF_H */ diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_control.c b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_control.c index 9a639f1df8..9ed53ef829 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_control.c +++ b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_control.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. @@ -14,7 +14,6 @@ */ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_iof.c b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_iof.c index 03f38eddc6..be2d6b11a2 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_iof.c +++ b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_iof.c @@ -1,9 +1,11 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -12,7 +14,14 @@ */ #include -#include +#ifdef HAVE_FCNTL_H +#include +#else +#ifdef HAVE_SYS_FCNTL_H +#include +#endif +#endif + #include #include @@ -187,6 +196,9 @@ typedef struct { void *cbdata; } pmix_ltcaddy_t; +static pmix_event_t stdinsig_ev; +static pmix_iof_read_event_t *stdinev = NULL; + static void stdincbfunc(struct pmix_peer_t *peer, pmix_ptl_hdr_t *hdr, pmix_buffer_t *buf, void *cbdata) @@ -225,8 +237,11 @@ pmix_status_t PMIx_IOF_push(const pmix_proc_t targets[], size_t ntargets, { pmix_buffer_t *msg; pmix_cmd_t cmd = PMIX_IOF_PUSH_CMD; - pmix_status_t rc; + pmix_status_t rc = PMIX_SUCCESS; pmix_ltcaddy_t *cd; + size_t n; + bool begincollecting, stopcollecting; + int flags, fd = fileno(stdin); PMIX_ACQUIRE_THREAD(&pmix_global_lock); if (pmix_globals.init_cntr <= 0) { @@ -235,6 +250,104 @@ pmix_status_t PMIx_IOF_push(const pmix_proc_t targets[], size_t ntargets, } PMIX_RELEASE_THREAD(&pmix_global_lock); + if (NULL == bo) { + /* check the directives */ + for (n=0; n < ndirs; n++) { + if (PMIX_CHECK_KEY(&directives[n], PMIX_IOF_PUSH_STDIN)) { + /* we are to start collecting our stdin and pushing + * it to the specified targets */ + begincollecting = PMIX_INFO_TRUE(&directives[n]); + if (begincollecting) { + /* add these targets to our list */ + if (!pmix_globals.pushstdin) { + /* not already collecting, so start */ + pmix_globals.pushstdin = true; + /* We don't want to set nonblocking on our + * stdio stream. If we do so, we set the file descriptor to + * non-blocking for everyone that has that file descriptor, which + * includes everyone else in our shell pipeline chain. (See + * http://lists.freebsd.org/pipermail/freebsd-hackers/2005-January/009742.html). + * This causes things like "prun -np 1 big_app | cat" to lose + * output, because cat's stdout is then ALSO non-blocking and cat + * isn't built to deal with that case (same with almost all other + * unix text utils). + */ + if (0 != fd) { + if((flags = fcntl(fd, F_GETFL, 0)) < 0) { + pmix_output(pmix_client_globals.iof_output, + "[%s:%d]: fcntl(F_GETFL) failed with errno=%d\n", + __FILE__, __LINE__, errno); + } else { + flags |= O_NONBLOCK; + fcntl(fd, F_SETFL, flags); + } + } + if (isatty(fd)) { + /* We should avoid trying to read from stdin if we + * have a terminal, but are backgrounded. Catch the + * signals that are commonly used when we switch + * between being backgrounded and not. If the + * filedescriptor is not a tty, don't worry about it + * and always stay connected. + */ + pmix_event_signal_set(pmix_globals.evbase, &stdinsig_ev, + SIGCONT, pmix_iof_stdin_cb, + NULL); + + /* setup a read event to read stdin, but don't activate it yet. The + * dst_name indicates who should receive the stdin. If that recipient + * doesn't do a corresponding pull, however, then the stdin will + * be dropped upon receipt at the local daemon + */ + PMIX_IOF_READ_EVENT(&stdinev, + targets, ntargets, + directives, ndirs, fd, + pmix_iof_read_local_handler, false); + + /* check to see if we want the stdin read event to be + * active - we will always at least define the event, + * but may delay its activation + */ + if (pmix_iof_stdin_check(fd)) { + PMIX_IOF_READ_ACTIVATE(stdinev); + } + } else { + /* if we are not looking at a tty, just setup a read event + * and activate it + */ + PMIX_IOF_READ_EVENT(&stdinev, targets, ntargets, + directives, ndirs, fd, + pmix_iof_read_local_handler, true); + } + } + } else { + if (pmix_globals.pushstdin) { + /* remove these targets from the list of + * recipients - if the list is then empty, + * stop collecting. If the targets param + * is NULL, then remove all targets and stop. + * Flush any cached input before calling + * the cbfunc */ + } + } + } else if (PMIX_CHECK_KEY(&directives[n], PMIX_IOF_COMPLETE)) { + /* if we are collecting our stdin for the specified + * targets, then stop - a NULL for targets indicates + * stop for everyone. Flush any remaining cached input + * before calling the cbfunc */ + stopcollecting = PMIX_INFO_TRUE(&directives[n]); + if (stopcollecting) { + if (pmix_globals.pushstdin) { + /* remove these targets from the list of + * recipients - if the list is then empty, + * stop collecting */ + } + } + } + } + return PMIX_OPERATION_SUCCEEDED; + } + /* if we are not a server, then we send the provided * data to our server for processing */ if (!PMIX_PROC_IS_SERVER(pmix_globals.mypeer) || @@ -282,12 +395,14 @@ pmix_status_t PMIx_IOF_push(const pmix_proc_t targets[], size_t ntargets, return rc; } } - PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, - msg, bo, 1, PMIX_BYTE_OBJECT); - if (PMIX_SUCCESS != rc) { - PMIX_ERROR_LOG(rc); - PMIX_RELEASE(msg); - return rc; + if (NULL != bo) { + PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, + msg, bo, 1, PMIX_BYTE_OBJECT); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(msg); + return rc; + } } cd = (pmix_ltcaddy_t*)malloc(sizeof(pmix_ltcaddy_t)); @@ -296,6 +411,8 @@ pmix_status_t PMIx_IOF_push(const pmix_proc_t targets[], size_t ntargets, rc = PMIX_ERR_NOMEM; return rc; } + cd->cbfunc = cbfunc; + cd->cbdata = cbdata; PMIX_PTL_SEND_RECV(rc, pmix_client_globals.myserver, msg, stdincbfunc, cd); if (PMIX_SUCCESS != rc) { @@ -314,7 +431,7 @@ pmix_status_t PMIx_IOF_push(const pmix_proc_t targets[], size_t ntargets, targets, ntargets, directives, ndirs, bo, cbfunc, cbdata); - return PMIX_SUCCESS; + return rc; } pmix_status_t pmix_iof_write_output(const pmix_proc_t *name, @@ -691,15 +808,41 @@ void pmix_iof_stdin_cb(int fd, short event, void *cbdata) } } -static void restart_stdin(int fd, short event, void *cbdata) +static void iof_stdin_cbfunc(struct pmix_peer_t *peer, + pmix_ptl_hdr_t *hdr, + pmix_buffer_t *buf, void *cbdata) { - pmix_iof_read_event_t *tm = (pmix_iof_read_event_t*)cbdata; + pmix_iof_read_event_t *stdinev = (pmix_iof_read_event_t*)cbdata; + int cnt; + pmix_status_t rc, ret; - PMIX_ACQUIRE_OBJECT(tm); + PMIX_ACQUIRE_OBJECT(stdinev); - if (!tm->active) { - PMIX_IOF_READ_ACTIVATE(tm); + /* check the return status */ + cnt = 1; + PMIX_BFROPS_UNPACK(rc, peer, buf, &ret, &cnt, PMIX_STATUS); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + pmix_event_del(&stdinev->ev); + stdinev->active = false; + PMIX_POST_OBJECT(stdinev); + return; } + /* if the status wasn't success, then terminate the forward */ + if (PMIX_SUCCESS != ret) { + pmix_event_del(&stdinev->ev); + stdinev->active = false; + PMIX_POST_OBJECT(stdinev); + if (PMIX_ERR_IOF_COMPLETE != ret) { + /* generate an IOF-failed event so the tool knows */ + PMIx_Notify_event(PMIX_ERR_IOF_FAILURE, + &pmix_globals.myid, PMIX_RANGE_PROC_LOCAL, + NULL, 0, NULL, NULL); + } + return; + } + + pmix_iof_stdin_cb(0, 0, stdinev); } /* this is the read handler for stdin */ @@ -712,6 +855,7 @@ void pmix_iof_read_local_handler(int unusedfd, short event, void *cbdata) pmix_status_t rc; pmix_buffer_t *msg; pmix_cmd_t cmd = PMIX_IOF_PUSH_CMD; + pmix_byte_object_t bo; PMIX_ACQUIRE_OBJECT(rev); @@ -759,49 +903,62 @@ void pmix_iof_read_local_handler(int unusedfd, short event, void *cbdata) if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); PMIX_RELEASE(msg); - goto restart; + return; } + /* pack the number of targets */ PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, - msg, &numbytes, 1, PMIX_INT32); + msg, &rev->ntargets, 1, PMIX_SIZE); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); PMIX_RELEASE(msg); - goto restart; + return; } + /* and the targets */ + if (0 < rev->ntargets) { + PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, + msg, rev->targets, rev->ntargets, PMIX_PROC); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(msg); + return; + } + } + /* pack the number of directives */ PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, - msg, data, numbytes, PMIX_BYTE); + msg, &rev->ndirs, 1, PMIX_SIZE); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); PMIX_RELEASE(msg); - goto restart; + return; } - PMIX_PTL_SEND_RECV(rc, pmix_client_globals.myserver, - msg, stdincbfunc, NULL); - if (PMIX_SUCCESS != rc) { - PMIX_ERROR_LOG(rc); - PMIX_RELEASE(msg); + /* and the directives */ + if (0 < rev->ndirs) { + PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, + msg, rev->directives, rev->ndirs, PMIX_INFO); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(msg); + return; + } } - restart: - /* if num_bytes was zero, or we read the last piece of the file, then we need to terminate the event */ - if (0 == numbytes) { - /* this will also close our stdin file descriptor */ - PMIX_RELEASE(rev); - } else { - /* if we are looking at a tty, then we just go ahead and restart the - * read event assuming we are not backgrounded - */ - if (pmix_iof_stdin_check(fd)) { - restart_stdin(fd, 0, rev); - } else { - /* delay for awhile and then restart */ - pmix_event_evtimer_set(pmix_globals.evbase, - &rev->ev, restart_stdin, rev); - rev->tv.tv_sec = 0; - rev->tv.tv_usec = 10000; - PMIX_POST_OBJECT(rev); - pmix_event_evtimer_add(&rev->ev, &rev->tv); - } + /* pack the data */ + bo.bytes = (char*)data; + bo.size = numbytes; + PMIX_BFROPS_PACK(rc, pmix_client_globals.myserver, + msg, &bo, 1, PMIX_BYTE_OBJECT); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(msg); + return; + } + + /* send it to the server */ + PMIX_PTL_SEND_RECV(rc, pmix_client_globals.myserver, + msg, iof_stdin_cbfunc, rev); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(msg); } /* nothing more to do */ return; @@ -837,6 +994,10 @@ static void iof_read_event_construct(pmix_iof_read_event_t* rev) rev->active = false; rev->tv.tv_sec = 0; rev->tv.tv_usec = 0; + rev->targets = NULL; + rev->ntargets = 0; + rev->directives = NULL; + rev->ndirs = 0; } static void iof_read_event_destruct(pmix_iof_read_event_t* rev) { @@ -848,6 +1009,12 @@ static void iof_read_event_destruct(pmix_iof_read_event_t* rev) close(rev->fd); rev->fd = -1; } + if (NULL != rev->targets) { + PMIX_PROC_FREE(rev->targets, rev->ntargets); + } + if (NULL != rev->directives) { + PMIX_INFO_FREE(rev->directives, rev->ndirs); + } } PMIX_CLASS_INSTANCE(pmix_iof_read_event_t, pmix_object_t, diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_iof.h b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_iof.h index 3525c5fb47..b4cf8c20c4 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_iof.h +++ b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_iof.h @@ -12,7 +12,7 @@ * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 Mellanox Technologies. All rights reserved. * Copyright (c) 2018 Research Organization for Information Science @@ -52,8 +52,6 @@ #include "src/include/pmix_globals.h" #include "src/util/fd.h" -#include "src/common/pmix_iof.h" - BEGIN_C_DECLS /* @@ -100,6 +98,10 @@ typedef struct { int fd; bool active; bool always_readable; + pmix_proc_t *targets; + size_t ntargets; + pmix_info_t *directives; + size_t ndirs; } pmix_iof_read_event_t; PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_iof_read_event_t); @@ -188,6 +190,42 @@ pmix_iof_fd_always_ready(int fd) } while(0); +#define PMIX_IOF_READ_EVENT(rv, p, np, d, nd, fid, cbfunc, actv) \ + do { \ + size_t _ii; \ + pmix_iof_read_event_t *rev; \ + PMIX_OUTPUT_VERBOSE((1, pmix_client_globals.iof_output, \ + "defining read event at: %s %d", \ + __FILE__, __LINE__)); \ + rev = PMIX_NEW(pmix_iof_read_event_t); \ + (rev)->ntargets = (np); \ + PMIX_PROC_CREATE((rev)->targets, (rev)->ntargets); \ + memcpy((rev)->targets, (p), (np) * sizeof(pmix_proc_t)); \ + if (NULL != (d)) { \ + PMIX_INFO_CREATE((rev)->directives, (nd)); \ + (rev)->ndirs = (nd); \ + for (_ii=0; _ii < (nd); _ii++) { \ + PMIX_INFO_XFER(&((rev)->directives[_ii]), &((d)[_ii])); \ + } \ + } \ + rev->fd = (fid); \ + rev->always_readable = pmix_iof_fd_always_ready(fid); \ + *(rv) = rev; \ + if(rev->always_readable) { \ + pmix_event_evtimer_set(pmix_globals.evbase, \ + &rev->ev, (cbfunc), rev); \ + } else { \ + pmix_event_set(pmix_globals.evbase, \ + &rev->ev, (fid), \ + PMIX_EV_READ, \ + (cbfunc), rev); \ + } \ + if ((actv)) { \ + PMIX_IOF_READ_ACTIVATE(rev) \ + } \ + } while(0); + + PMIX_EXPORT pmix_status_t pmix_iof_flush(void); PMIX_EXPORT pmix_status_t pmix_iof_write_output(const pmix_proc_t *name, @@ -196,10 +234,9 @@ PMIX_EXPORT pmix_status_t pmix_iof_write_output(const pmix_proc_t *name, pmix_iof_flags_t *flags); PMIX_EXPORT void pmix_iof_static_dump_output(pmix_iof_sink_t *sink); PMIX_EXPORT void pmix_iof_write_handler(int fd, short event, void *cbdata); -PMIX_EXPORT void pmix_iof_stdin_write_handler(int fd, short event, void *cbdata); PMIX_EXPORT bool pmix_iof_stdin_check(int fd); +PMIX_EXPORT void pmix_iof_read_local_handler(int unusedfd, short event, void *cbdata); PMIX_EXPORT void pmix_iof_stdin_cb(int fd, short event, void *cbdata); -PMIX_EXPORT void pmix_iof_read_local_handler(int fd, short event, void *cbdata); END_C_DECLS diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_log.c b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_log.c index 582a64e4ea..caf01fa54c 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_log.c +++ b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_log.c @@ -4,6 +4,8 @@ * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -12,7 +14,6 @@ */ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_query.c b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_query.c index c40f08b6a0..7475c618fe 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_query.c +++ b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_query.c @@ -4,6 +4,8 @@ * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -12,7 +14,6 @@ */ #include -#include #include #include @@ -28,6 +29,7 @@ #include "src/util/output.h" #include "src/mca/bfrops/bfrops.h" #include "src/mca/ptl/ptl.h" +#include "src/common/pmix_attributes.h" #include "src/client/pmix_client_ops.h" #include "src/server/pmix_server_ops.h" @@ -107,7 +109,7 @@ static void query_cbfunc(struct pmix_peer_t *peer, complete: pmix_output_verbose(2, pmix_globals.debug_output, - "pmix:query cback from server releasing"); + "pmix:query cback from server releasing with status %s", PMIx_Error_string(results->status)); /* release the caller */ if (NULL != cd->cbfunc) { cd->cbfunc(results->status, results->info, results->ninfo, cd->cbdata, relcbfunc, results); @@ -186,10 +188,25 @@ PMIX_EXPORT pmix_status_t PMIx_Query_info_nb(pmix_query_t queries[], size_t nque * more, we would check each query and allow those that don't * want to be refreshed to be executed locally, and those that * did would be sent to the host. However, for now we simply - * */ + * assume that any requirement to refresh will force all to + * do so */ memset(proc.nspace, 0, PMIX_MAX_NSLEN+1); proc.rank = PMIX_RANK_INVALID; for (n=0; n < nqueries; n++) { + /* check for requests to report supported attributes */ + if (0 == strcmp(queries[n].keys[0], PMIX_QUERY_ATTRIBUTE_SUPPORT)) { + cd = PMIX_NEW(pmix_query_caddy_t); + cd->queries = queries; + cd->nqueries = nqueries; + cd->cbfunc = cbfunc; + cd->cbdata = cbdata; + PMIX_THREADSHIFT(cd, pmix_attrs_query_support); + /* regardless of the result of the query, we return + * PMIX_SUCCESS here to indicate that the operation + * was accepted for processing */ + PMIX_RELEASE_THREAD(&pmix_global_lock); + return PMIX_SUCCESS; + } for (p=0; p < queries[n].nqual; p++) { if (PMIX_CHECK_KEY(&queries[n].qualifiers[p], PMIX_QUERY_REFRESH_CACHE)) { if (PMIX_INFO_TRUE(&queries[n].qualifiers[p])) { diff --git a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_security.c b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_security.c index c4797c1cd0..fef84599ae 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/common/pmix_security.c +++ b/opal/mca/pmix/pmix4x/pmix/src/common/pmix_security.c @@ -4,6 +4,8 @@ * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -12,7 +14,6 @@ */ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/event/pmix_event_notification.c b/opal/mca/pmix/pmix4x/pmix/src/event/pmix_event_notification.c index ab7593cdae..8444fdac87 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/event/pmix_event_notification.c +++ b/opal/mca/pmix/pmix4x/pmix/src/event/pmix_event_notification.c @@ -293,7 +293,7 @@ static pmix_status_t notify_server_of_event(pmix_status_t status, PMIX_RELEASE(cb); goto cleanup; } - } else { + } else if (NULL != cbfunc) { cbfunc(PMIX_SUCCESS, cbdata); } @@ -1020,16 +1020,6 @@ static void _notify_client_event(int sd, short args, void *cbdata) if (!pmix_notify_check_range(&rngtrk, &proc)) { continue; } - if (NULL != cd->targets) { - /* track the number of targets we have left to notify */ - --cd->nleft; - /* if the event was cached and this is the last one, - * then evict this event from the cache */ - if (0 == cd->nleft) { - pmix_hotel_checkout(&pmix_globals.notifications, cd->room); - PMIX_RELEASE(cd); - } - } pmix_output_verbose(2, pmix_server_globals.event_output, "pmix_server: notifying client %s:%u on status %s", pr->peer->info->pname.nspace, pr->peer->info->pname.rank, @@ -1087,6 +1077,17 @@ static void _notify_client_event(int sd, short args, void *cbdata) if (PMIX_SUCCESS != rc) { PMIX_RELEASE(bfr); } + if (NULL != cd->targets && 0 < cd->nleft) { + /* track the number of targets we have left to notify */ + --cd->nleft; + /* if the event was cached and this is the last one, + * then evict this event from the cache */ + if (0 == cd->nleft) { + pmix_hotel_checkout(&pmix_globals.notifications, cd->room); + holdcd = false; + break; + } + } } } } diff --git a/opal/mca/pmix/pmix4x/pmix/src/include/pmix_globals.c b/opal/mca/pmix/pmix4x/pmix/src/include/pmix_globals.c index 8959ba5684..cafe531aee 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/include/pmix_globals.c +++ b/opal/mca/pmix/pmix4x/pmix/src/include/pmix_globals.c @@ -1,12 +1,13 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2017 Research Organization for Information Science - * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014-2015 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -18,6 +19,7 @@ #include +#include #include #include #include @@ -326,6 +328,18 @@ PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_info_caddy_t, pmix_list_item_t, NULL, NULL); +static void ifcon(pmix_infolist_t *p) +{ + PMIX_INFO_CONSTRUCT(&p->info); +} +static void ifdes(pmix_infolist_t *p) +{ + PMIX_INFO_DESTRUCT(&p->info); +} +PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_infolist_t, + pmix_list_item_t, + ifcon, ifdes); + static void qcon(pmix_query_caddy_t *p) { PMIX_CONSTRUCT_LOCK(&p->lock); @@ -336,6 +350,7 @@ static void qcon(pmix_query_caddy_t *p) p->info = NULL; p->ninfo = 0; PMIX_BYTE_OBJECT_CONSTRUCT(&p->bo); + PMIX_CONSTRUCT(&p->results, pmix_list_t); p->cbfunc = NULL; p->valcbfunc = NULL; p->cbdata = NULL; @@ -349,6 +364,7 @@ static void qdes(pmix_query_caddy_t *p) PMIX_BYTE_OBJECT_DESTRUCT(&p->bo); PMIX_PROC_FREE(p->targets, p->ntargets); PMIX_INFO_FREE(p->info, p->ninfo); + PMIX_LIST_DESTRUCT(&p->results); } PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_query_caddy_t, pmix_object_t, @@ -566,3 +582,30 @@ static bool dirpath_is_empty(const char *path ) return true; } + +int pmix_event_assign(struct event *ev, pmix_event_base_t *evbase, + int fd, short arg, event_callback_fn cbfn, void *cbd) +{ +#if PMIX_HAVE_LIBEV + event_set(ev, fd, arg, cbfn, cbd); + event_base_set(evbase, ev); +#else + event_assign(ev, evbase, fd, arg, cbfn, cbd); +#endif + return 0; +} + +pmix_event_t* pmix_event_new(pmix_event_base_t *b, int fd, + short fg, event_callback_fn cbfn, void *cbd) +{ + pmix_event_t *ev = NULL; + +#if PMIX_HAVE_LIBEV + ev = (pmix_event_t*)calloc(1, sizeof(pmix_event_t)); + ev->ev_base = b; +#else + ev = event_new(b, fd, fg, (event_callback_fn) cbfn, cbd); +#endif + + return ev; +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/include/pmix_globals.h b/opal/mca/pmix/pmix4x/pmix/src/include/pmix_globals.h index d63d7536fe..36d67f79dc 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/include/pmix_globals.h +++ b/opal/mca/pmix/pmix4x/pmix/src/include/pmix_globals.h @@ -11,6 +11,10 @@ * 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) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -23,6 +27,8 @@ #include +#include + #include #include @@ -216,6 +222,11 @@ typedef struct { } pmix_info_caddy_t; PMIX_CLASS_DECLARATION(pmix_info_caddy_t); +typedef struct { + pmix_list_item_t super; + pmix_info_t info; +} pmix_infolist_t; +PMIX_CLASS_DECLARATION(pmix_infolist_t); /* object for tracking peers - each peer can have multiple * connections. This can occur if the initial app executes @@ -269,6 +280,7 @@ typedef struct { size_t ntargets; pmix_info_t *info; size_t ninfo; + pmix_list_t results; pmix_byte_object_t bo; pmix_info_cbfunc_t cbfunc; pmix_value_cbfunc_t valcbfunc; @@ -285,7 +297,7 @@ typedef struct { pmix_list_item_t super; pmix_event_t ev; bool event_active; - bool lost_connection; // tracker went thru lost connection procedure + bool host_called; // tracker has been passed up to host bool local; // operation is strictly local char *id; // string identifier for the collective pmix_cmd_t type; @@ -293,6 +305,7 @@ typedef struct { bool hybrid; // true if participating procs are from more than one nspace pmix_proc_t *pcs; // copy of the original array of participants size_t npcs; // number of procs in the array + pmix_list_t nslist; // unique nspace list of participants pmix_lock_t lock; // flag for waiting for completion bool def_complete; // all local procs have been registered and the trk definition is complete pmix_list_t local_cbs; // list of pmix_server_caddy_t for sending result to the local participants @@ -479,6 +492,8 @@ typedef struct { * look them up */ pmix_gds_base_module_t *mygds; /* IOF controls */ + bool pushstdin; + pmix_list_t stdin_targets; // list of pmix_namelist_t bool tag_output; bool xml_output; bool timestamp_output; diff --git a/opal/mca/pmix/pmix4x/pmix/src/include/types.h b/opal/mca/pmix/pmix4x/pmix/src/include/types.h index cf8d082c34..821c788e6d 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/include/types.h +++ b/opal/mca/pmix/pmix4x/pmix/src/include/types.h @@ -9,9 +9,11 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. * All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -43,11 +45,16 @@ #include #endif #include PMIX_EVENT_HEADER +#if ! PMIX_HAVE_LIBEV +#include PMIX_EVENT2_THREAD_HEADER +#endif #if PMIX_ENABLE_DEBUG #include "src/util/output.h" #endif +#include + /* * portable assignment of pointer to int @@ -232,42 +239,53 @@ typedef struct event pmix_event_t; #define pmix_event_base_free(b) event_base_free(b) -#define pmix_event_free(x) event_free(x) - -#define pmix_event_base_loopbreak(b) event_base_loopbreak(b) - #define pmix_event_base_loopexit(b) event_base_loopexit(b, NULL) +#if PMIX_HAVE_LIBEV +#define pmix_event_use_threads() +#define pmix_event_free(b) free(b) +#define pmix_event_get_signal(x) (x)->ev_fd +#else + /* thread support APIs */ #define pmix_event_use_threads() evthread_use_pthreads() +#define pmix_event_free(x) event_free(x) +#define pmix_event_get_signal(x) event_get_signal(x) +#endif /* Basic event APIs */ #define pmix_event_enable_debug_mode() event_enable_debug_mode() -#define pmix_event_assign(x, b, fd, fg, cb, arg) event_assign((x), (b), (fd), (fg), (event_callback_fn) (cb), (arg)) +PMIX_EXPORT int pmix_event_assign(struct event *ev, pmix_event_base_t *evbase, + int fd, short arg, event_callback_fn cbfn, void *cbd); -#define pmix_event_set(b, x, fd, fg, cb, arg) event_assign((x), (b), (fd), (fg), (event_callback_fn) (cb), (arg)) +#define pmix_event_set(b, x, fd, fg, cb, arg) pmix_event_assign((x), (b), (fd), (fg), (event_callback_fn) (cb), (arg)) +#if PMIX_HAVE_LIBEV +PMIX_EXPORT int pmix_event_add(struct event *ev, struct timeval *tv); +PMIX_EXPORT int pmix_event_del(struct event *ev); +PMIX_EXPORT void pmix_event_active (struct event *ev, int res, short ncalls); +PMIX_EXPORT void pmix_event_base_loopbreak (pmix_event_base_t *b); +#else #define pmix_event_add(ev, tv) event_add((ev), (tv)) - #define pmix_event_del(ev) event_del((ev)) - #define pmix_event_active(x, y, z) event_active((x), (y), (z)) +#define pmix_event_base_loopbreak(b) event_base_loopbreak(b) +#endif -#define pmix_event_new(b, fd, fg, cb, arg) event_new((b), (fd), (fg), (event_callback_fn) (cb), (arg)) +PMIX_EXPORT pmix_event_t* pmix_event_new(pmix_event_base_t *b, int fd, + short fg, event_callback_fn cbfn, void *cbd); #define pmix_event_loop(b, fg) event_base_loop((b), (fg)) -#define pmix_event_active(x, y, z) event_active((x), (y), (z)) - #define pmix_event_evtimer_new(b, cb, arg) pmix_event_new((b), -1, 0, (cb), (arg)) #define pmix_event_evtimer_add(x, tv) pmix_event_add((x), (tv)) -#define pmix_event_evtimer_set(b, x, cb, arg) event_assign((x), (b), -1, 0, (event_callback_fn) (cb), (arg)) +#define pmix_event_evtimer_set(b, x, cb, arg) pmix_event_assign((x), (b), -1, 0, (event_callback_fn) (cb), (arg)) #define pmix_event_evtimer_del(x) pmix_event_del((x)) -#define pmix_event_signal_set(b, x, fd, cb, arg) event_assign((x), (b), (fd), EV_SIGNAL|EV_PERSIST, (event_callback_fn) (cb), (arg)) +#define pmix_event_signal_set(b, x, fd, cb, arg) pmix_event_assign((x), (b), (fd), EV_SIGNAL|EV_PERSIST, (event_callback_fn) (cb), (arg)) #endif /* PMIX_TYPES_H */ diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/base.h b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/base.h index 41ee2de266..0a7f83ccf8 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/base.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/base.h @@ -11,9 +11,11 @@ * 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-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -159,46 +161,72 @@ PMIX_EXPORT extern pmix_bfrops_globals_t pmix_bfrops_globals; #endif /* Unpack generic size macros */ -#define PMIX_BFROP_UNPACK_SIZE_MISMATCH(unpack_type, remote_type, ret) \ +#define PMIX_BFROP_UNPACK_SIZE_MISMATCH(reg_types, unpack_type, remote_type, ret) \ do { \ switch(remote_type) { \ case PMIX_UINT8: \ - PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint8_t, remote_type); \ + PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, uint8_t, remote_type); \ break; \ case PMIX_INT8: \ - PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int8_t, remote_type); \ + PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, int8_t, remote_type); \ break; \ case PMIX_UINT16: \ - PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint16_t, remote_type); \ + PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, uint16_t, remote_type); \ break; \ case PMIX_INT16: \ - PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int16_t, remote_type); \ + PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, int16_t, remote_type); \ break; \ case PMIX_UINT32: \ - PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint32_t, remote_type); \ + PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, uint32_t, remote_type); \ break; \ case PMIX_INT32: \ - PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int32_t, remote_type); \ + PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, int32_t, remote_type); \ break; \ case PMIX_UINT64: \ - PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, uint64_t, remote_type); \ + PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, uint64_t, remote_type); \ break; \ case PMIX_INT64: \ - PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, int64_t, remote_type); \ + PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, int64_t, remote_type); \ break; \ default: \ ret = PMIX_ERR_NOT_FOUND; \ } \ } while (0) +#define PMIX_BFROPS_PACK_TYPE(r, b, s, n, t, arr) \ + do { \ + pmix_bfrop_type_info_t *__info; \ + /* Lookup the pack function for this type and call it */ \ + __info = (pmix_bfrop_type_info_t*)pmix_pointer_array_get_item((arr),\ + (t)); \ + if (NULL == __info) { \ + (r) = PMIX_ERR_UNKNOWN_DATA_TYPE; \ + } else { \ + (r) = __info->odti_pack_fn(arr, b, s, n, t); \ + } \ + } while(0) + +#define PMIX_BFROPS_UNPACK_TYPE(r, b, d, n, t, arr) \ + do { \ + pmix_bfrop_type_info_t *__info; \ + /* Lookup the unpack function for this type and call it */ \ + __info = (pmix_bfrop_type_info_t*)pmix_pointer_array_get_item((arr),\ + (t)); \ + if (NULL == __info) { \ + (r) = PMIX_ERR_UNKNOWN_DATA_TYPE; \ + } else { \ + (r) = __info->odti_unpack_fn(arr, b, d, n, t); \ + } \ + } 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 PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(unpack_type, tmptype, tmpbfroptype) \ +#define PMIX_BFROP_UNPACK_SIZE_MISMATCH_FOUND(reg_types, unpack_type, tmptype, tmpbfroptype) \ do { \ int32_t i; \ tmptype *tmpbuf = (tmptype*)malloc(sizeof(tmptype) * (*num_vals)); \ - ret = unpack_gentype(buffer, tmpbuf, num_vals, tmpbfroptype); \ + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, tmpbuf, num_vals, tmpbfroptype, reg_types); \ for (i = 0 ; i < *num_vals ; ++i) { \ ((unpack_type*) dest)[i] = (unpack_type)(tmpbuf[i]); \ } \ @@ -211,6 +239,16 @@ typedef struct pmix_info_array { pmix_info_t *array; } pmix_info_array_t; +typedef pmix_status_t (*pmix_bfrop_internal_pack_fn_t)(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, + const void *src, + int32_t num_values, + pmix_data_type_t type); + +typedef pmix_status_t (*pmix_bfrop_internal_unpack_fn_t)(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *max_num_values, + pmix_data_type_t type); /** * Internal struct used for holding registered bfrop functions @@ -222,9 +260,9 @@ typedef struct pmix_info_array { /** Debugging string name */ char *odti_name; /** Pack function */ - pmix_bfrop_pack_fn_t odti_pack_fn; + pmix_bfrop_internal_pack_fn_t odti_pack_fn; /** Unpack function */ - pmix_bfrop_unpack_fn_t odti_unpack_fn; + pmix_bfrop_internal_unpack_fn_t odti_unpack_fn; /** copy function */ pmix_bfrop_copy_fn_t odti_copy_fn; /** prpmix_status_t function */ @@ -240,8 +278,8 @@ PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_bfrop_type_info_t); _info = PMIX_NEW(pmix_bfrop_type_info_t); \ _info->odti_name = strdup((n)); \ _info->odti_type = (t); \ - _info->odti_pack_fn = (pmix_bfrop_pack_fn_t)(p); \ - _info->odti_unpack_fn = (pmix_bfrop_unpack_fn_t)(u); \ + _info->odti_pack_fn = (pmix_bfrop_internal_pack_fn_t)(p); \ + _info->odti_unpack_fn = (pmix_bfrop_internal_unpack_fn_t)(u); \ _info->odti_copy_fn = (pmix_bfrop_copy_fn_t)(c) ; \ _info->odti_print_fn = (pmix_bfrop_print_fn_t)(pr) ; \ pmix_pointer_array_set_item((arr), (t), _info); \ @@ -306,89 +344,135 @@ PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_buffer(pmix_pointer_array_t *reg const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_bool(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_int(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_sizet(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_byte(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_string(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_pid(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_int16(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_int32(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_int64(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_string(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_float(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_double(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_timeval(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_time(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_status(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_buf(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_bo(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_proc(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_value(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_info(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_pdata(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_app(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_kval(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_array(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_modex(pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_persist(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_datatype(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_ptr(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_scope(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_range(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_cmd(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_info_directives(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_info_directives(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_pstate(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_pstate(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_pinfo(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_pinfo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_darray(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_rank(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_query(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_val(pmix_buffer_t *buffer, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_val(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_value_t *p); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_alloc_directive(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_alloc_directive(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_iof_channel(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_iof_channel(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_envar(pmix_buffer_t *buffer, const void *src, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_envar(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_coord(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrops_base_pack_regattr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); /* * "Standard" unpack functions @@ -398,90 +482,137 @@ PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack(pmix_pointer_array_t *regtypes void *dst, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_bool(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_byte(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_string(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_int(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_sizet(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_pid(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_int16(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_int32(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_datatype(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_int64(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_float(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_double(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_timeval(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_time(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_status(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_val(pmix_buffer_t *buffer, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_val(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_value_t *val); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_value(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_info(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_pdata(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_buf(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_proc(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_app(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_kval(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_modex(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_persist(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_bo(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_ptr(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_scope(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_range(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_cmd(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_info_directives(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_info_directives(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_datatype(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_pstate(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_pstate(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_pinfo(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_pinfo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_darray(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_rank(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_query(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_alloc_directive(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_alloc_directive(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_iof_channel(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_iof_channel(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_envar(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_envar(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_coord(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_regattr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); /**** DEPRECATED ****/ -PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_array(pmix_buffer_t *buffer, void *dest, +PMIX_EXPORT pmix_status_t pmix_bfrops_base_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); /* @@ -538,6 +669,12 @@ PMIX_EXPORT pmix_status_t pmix_bfrops_base_copy_query(pmix_query_t **dest, PMIX_EXPORT pmix_status_t pmix_bfrops_base_copy_envar(pmix_envar_t **dest, pmix_envar_t *src, pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrops_base_copy_coord(pmix_coord_t **dest, + pmix_coord_t *src, + pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrops_base_copy_regattr(pmix_regattr_t **dest, + pmix_regattr_t *src, + pmix_data_type_t type); /* * "Standard" print functions @@ -646,6 +783,12 @@ PMIX_EXPORT pmix_status_t pmix_bfrops_base_print_iof_channel(char **output, char PMIX_EXPORT pmix_status_t pmix_bfrops_base_print_envar(char **output, char *prefix, pmix_envar_t *src, pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrops_base_print_coord(char **output, char *prefix, + pmix_coord_t *src, + pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrops_base_print_regattr(char **output, char *prefix, + pmix_regattr_t *src, + pmix_data_type_t type); /* * Common helper functions @@ -655,9 +798,11 @@ PMIX_EXPORT char* pmix_bfrop_buffer_extend(pmix_buffer_t *bptr, size_t bytes_to_ PMIX_EXPORT bool pmix_bfrop_too_small(pmix_buffer_t *buffer, size_t bytes_reqd); -PMIX_EXPORT pmix_status_t pmix_bfrop_store_data_type(pmix_buffer_t *buffer, pmix_data_type_t type); +PMIX_EXPORT pmix_status_t pmix_bfrop_store_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t type); -PMIX_EXPORT pmix_status_t pmix_bfrop_get_data_type(pmix_buffer_t *buffer, pmix_data_type_t *type); +PMIX_EXPORT pmix_status_t pmix_bfrop_get_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t *type); PMIX_EXPORT pmix_status_t pmix_bfrops_base_copy_payload(pmix_buffer_t *dest, pmix_buffer_t *src); diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_copy.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_copy.c index d5bf41e94f..9675c15078 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_copy.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_copy.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -387,6 +387,7 @@ pmix_status_t pmix_bfrops_base_copy_darray(pmix_data_array_t **dest, pmix_proc_info_t *pi, *si; pmix_query_t *pq, *sq; pmix_envar_t *pe, *se; + pmix_regattr_t *pr, *sr; p = (pmix_data_array_t*)calloc(1, sizeof(pmix_data_array_t)); if (NULL == p) { @@ -800,6 +801,35 @@ pmix_status_t pmix_bfrops_base_copy_darray(pmix_data_array_t **dest, pe[n].separator = se[n].separator; } break; + case PMIX_COORD: + p->array = malloc(src->size * sizeof(pmix_coord_t)); + if (NULL == p->array) { + free(p); + return PMIX_ERR_NOMEM; + } + memcpy(p->array, src->array, src->size * sizeof(pmix_coord_t)); + break; + case PMIX_REGATTR: + PMIX_REGATTR_CREATE(p->array, src->size); + if (NULL == p->array) { + free(p); + return PMIX_ERR_NOMEM; + } + pr = (pmix_regattr_t*)p->array; + sr = (pmix_regattr_t*)src->array; + for (n=0; n < src->size; n++) { + if (NULL != sr[n].name) { + pr[n].name = strdup(sr[n].name); + } + PMIX_LOAD_KEY(pr[n].string, sr[n].string); + pr[n].type = sr[n].type; + if (NULL != sr[n].info) { + PMIX_INFO_XFER(pr[n].info, sr[n].info); + } + pr[n].ninfo = sr[n].ninfo; + pr[n].description = pmix_argv_copy(sr[n].description); + } + break; default: free(p); return PMIX_ERR_UNKNOWN_DATA_TYPE; @@ -846,3 +876,33 @@ pmix_status_t pmix_bfrops_base_copy_envar(pmix_envar_t **dest, (*dest)->separator = src->separator; return PMIX_SUCCESS; } + +pmix_status_t pmix_bfrops_base_copy_coord(pmix_coord_t **dest, + pmix_coord_t *src, + pmix_data_type_t type) +{ + *dest = (pmix_coord_t*)malloc(sizeof(pmix_coord_t)); + memcpy(*dest, src, sizeof(pmix_coord_t)); + return PMIX_SUCCESS; +} + +pmix_status_t pmix_bfrops_base_copy_regattr(pmix_regattr_t **dest, + pmix_regattr_t *src, + pmix_data_type_t type) +{ + PMIX_REGATTR_CREATE(*dest, 1); + if (NULL == (*dest)) { + return PMIX_ERR_NOMEM; + } + if (NULL != src->name) { + (*dest)->name = strdup(src->name); + } + PMIX_LOAD_KEY((*dest)->string, src->string); + (*dest)->type = src->type; + if (NULL != src->info) { + PMIX_INFO_XFER((*dest)->info, src->info); + } + (*dest)->ninfo = src->ninfo; + (*dest)->description = pmix_argv_copy(src->description); + return PMIX_SUCCESS; +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_fns.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_fns.c index e93f14889a..274bc8c521 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_fns.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_fns.c @@ -9,7 +9,9 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -59,6 +61,8 @@ void pmix_bfrops_base_value_load(pmix_value_t *v, const void *data, pmix_envar_t *envar; pmix_data_array_t *darray; pmix_status_t rc; + pmix_coord_t *coord; + pmix_regattr_t *regattr; v->type = type; if (NULL == data) { @@ -201,6 +205,20 @@ void pmix_bfrops_base_value_load(pmix_value_t *v, const void *data, PMIX_ERROR_LOG(rc); } break; + case PMIX_COORD: + coord = (pmix_coord_t*)data; + rc = pmix_bfrops_base_copy_coord(&v->data.coord, coord, PMIX_COORD); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + } + break; + case PMIX_REGATTR: + regattr = (pmix_regattr_t*)data; + rc = pmix_bfrops_base_copy_regattr((pmix_regattr_t**)&v->data.ptr, regattr, PMIX_REGATTR); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + } + break; default: /* silence warnings */ @@ -217,6 +235,8 @@ pmix_status_t pmix_bfrops_base_value_unload(pmix_value_t *kv, pmix_status_t rc; pmix_envar_t *envar; pmix_data_array_t **darray; + pmix_coord_t *coord; + pmix_regattr_t *regattr, *r; rc = PMIX_SUCCESS; if (NULL == data || @@ -354,6 +374,32 @@ pmix_status_t pmix_bfrops_base_value_unload(pmix_value_t *kv, *data = envar; *sz = sizeof(pmix_envar_t); break; + case PMIX_COORD: + coord = (pmix_coord_t*)malloc(sizeof(pmix_coord_t)); + if (NULL == coord) { + return PMIX_ERR_NOMEM; + } + memcpy(coord, kv->data.coord, sizeof(pmix_coord_t)); + *data = coord; + break; + case PMIX_REGATTR: + PMIX_REGATTR_CREATE(regattr, 1); + if (NULL == regattr) { + return PMIX_ERR_NOMEM; + } + r = (pmix_regattr_t*)kv->data.ptr; + if (NULL != r->name) { + regattr->name = strdup(r->name); + } + PMIX_LOAD_KEY(regattr->string, r->string); + regattr->type = r->type; + if (NULL != r->info) { + PMIX_INFO_XFER(regattr->info, r->info); + } + regattr->ninfo = r->ninfo; + regattr->description = pmix_argv_copy(r->description); + *data = regattr; + break; default: /* silence warnings */ rc = PMIX_ERROR; @@ -501,6 +547,27 @@ pmix_value_cmp_t pmix_bfrops_base_value_cmp(pmix_value_t *p, } rc = PMIX_EQUAL; break; + case PMIX_COORD: + rc = memcmp(p->data.coord, p1->data.coord, sizeof(pmix_coord_t)); + if (0 > rc) { + rc = PMIX_VALUE2_GREATER; + } else if (0 < rc) { + rc = PMIX_VALUE1_GREATER; + } else { + rc = PMIX_EQUAL; + } + break; + case PMIX_REGATTR: + rc = memcmp(p->data.ptr, p1->data.ptr, sizeof(pmix_regattr_t)); + if (0 > rc) { + rc = PMIX_VALUE2_GREATER; + } else if (0 < rc) { + rc = PMIX_VALUE1_GREATER; + } else { + rc = PMIX_EQUAL; + } + break; + default: pmix_output(0, "COMPARE-PMIX-VALUE: UNSUPPORTED TYPE %d", (int)p->type); } @@ -639,7 +706,12 @@ pmix_status_t pmix_bfrops_base_value_xfer(pmix_value_t *p, } p->data.envar.separator = src->data.envar.separator; break; - + case PMIX_COORD: + pmix_bfrops_base_copy_coord(&p->data.coord, src->data.coord, PMIX_COORD); + break; + case PMIX_REGATTR: + pmix_bfrops_base_copy_regattr((pmix_regattr_t**)&p->data.ptr, src->data.ptr, PMIX_REGATTR); + break; default: pmix_output(0, "PMIX-XFER-VALUE: UNSUPPORTED TYPE %d", (int)src->type); return PMIX_ERROR; @@ -727,39 +799,23 @@ bool pmix_bfrop_too_small(pmix_buffer_t *buffer, size_t bytes_reqd) return false; } -pmix_status_t pmix_bfrop_store_data_type(pmix_buffer_t *buffer, pmix_data_type_t type) +pmix_status_t pmix_bfrop_store_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t type) { - uint16_t tmp; - char *dst; + pmix_status_t ret; - /* check to see if buffer needs extending */ - if (NULL == (dst = pmix_bfrop_buffer_extend(buffer, sizeof(tmp)))) { - return PMIX_ERR_OUT_OF_RESOURCE; - } - tmp = pmix_htons(type); - memcpy(dst, &tmp, sizeof(tmp)); - buffer->pack_ptr += sizeof(tmp); - buffer->bytes_used += sizeof(tmp); - - return PMIX_SUCCESS; + PMIX_BFROPS_PACK_TYPE(ret, buffer, &type, 1, PMIX_UINT16, regtypes); + return ret; } -pmix_status_t pmix_bfrop_get_data_type(pmix_buffer_t *buffer, pmix_data_type_t *type) +pmix_status_t pmix_bfrop_get_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t *type) { - uint16_t tmp; + pmix_status_t ret; + int32_t m = 1; - /* check to see if there's enough data in buffer */ - if (pmix_bfrop_too_small(buffer, sizeof(tmp))) { - return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - - /* unpack the data */ - memcpy(&tmp, buffer->unpack_ptr, sizeof(tmp)); - tmp = pmix_ntohs(tmp); - memcpy(type, &tmp, sizeof(tmp)); - buffer->unpack_ptr += sizeof(tmp); - - return PMIX_SUCCESS; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, type, &m, PMIX_UINT16, regtypes); + return ret; } const char* pmix_bfrops_base_data_type_string(pmix_pointer_array_t *regtypes, diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_pack.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_pack.c index 4045d874ec..2f06f411a9 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_pack.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_pack.c @@ -9,7 +9,9 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -49,14 +51,14 @@ pmix_status_t pmix_bfrops_base_pack(pmix_pointer_array_t *regtypes, /* Pack the number of values */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix_bfrop_store_data_type(buffer, PMIX_INT32))) { + if (PMIX_SUCCESS != (rc = pmix_bfrop_store_data_type(regtypes, buffer, PMIX_INT32))) { return rc; } } - if (PMIX_SUCCESS != (rc = pmix_bfrops_base_pack_int32(buffer, &num_vals, 1, PMIX_INT32))) { + PMIX_BFROPS_PACK_TYPE(rc, buffer, &num_vals, 1, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != rc) { return rc; } - /* Pack the value(s) */ return pmix_bfrops_base_pack_buffer(regtypes, buffer, src, num_vals, type); } @@ -68,7 +70,6 @@ pmix_status_t pmix_bfrops_base_pack_buffer(pmix_pointer_array_t *regtypes, pmix_data_type_t type) { pmix_status_t rc; - pmix_bfrop_type_info_t *info; pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrops_base_pack_buffer( %p, %p, %lu, %d )\n", @@ -76,47 +77,12 @@ pmix_status_t pmix_bfrops_base_pack_buffer(pmix_pointer_array_t *regtypes, /* Pack the declared data type */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix_bfrop_store_data_type(buffer, type))) { + if (PMIX_SUCCESS != (rc = pmix_bfrop_store_data_type(regtypes, buffer, type))) { return rc; } } - - /* Lookup the pack function for this type and call it */ - if (NULL == (info = (pmix_bfrop_type_info_t*)pmix_pointer_array_get_item(regtypes, type))) { - PMIX_ERROR_LOG(PMIX_ERR_UNKNOWN_DATA_TYPE); - return PMIX_ERR_UNKNOWN_DATA_TYPE; - } - - return info->odti_pack_fn(buffer, src, num_vals, type); -} - -static pmix_status_t pack_gentype(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) -{ - switch(type) { - case PMIX_INT8: - case PMIX_UINT8: - return pmix_bfrops_base_pack_byte(buffer, src, num_vals, type); - break; - - case PMIX_INT16: - case PMIX_UINT16: - return pmix_bfrops_base_pack_int16(buffer, src, num_vals, type); - break; - - case PMIX_INT32: - case PMIX_UINT32: - return pmix_bfrops_base_pack_int32(buffer, src, num_vals, type); - break; - - case PMIX_INT64: - case PMIX_UINT64: - return pmix_bfrops_base_pack_int64(buffer, src, num_vals, type); - break; - - default: - return PMIX_ERR_UNKNOWN_DATA_TYPE; - } + PMIX_BFROPS_PACK_TYPE(rc, buffer, src, num_vals, type, regtypes); + return rc; } /* PACK FUNCTIONS FOR GENERIC SYSTEM TYPES */ @@ -124,7 +90,8 @@ static pmix_status_t pack_gentype(pmix_buffer_t *buffer, const void *src, /* * BOOL */ - pmix_status_t pmix_bfrops_base_pack_bool(pmix_buffer_t *buffer, const void *src, + pmix_status_t pmix_bfrops_base_pack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { uint8_t *dst; @@ -158,61 +125,67 @@ static pmix_status_t pack_gentype(pmix_buffer_t *buffer, const void *src, /* * INT */ -pmix_status_t pmix_bfrops_base_pack_int(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret; /* System types need to always be described so we can properly unpack them */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(buffer, BFROP_TYPE_INT))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_INT))) { return ret; } /* Turn around and pack the real type */ - return pack_gentype(buffer, src, num_vals, BFROP_TYPE_INT); + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, BFROP_TYPE_INT, regtypes); + return ret; } /* * SIZE_T */ -pmix_status_t pmix_bfrops_base_pack_sizet(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int ret; /* System types need to always be described so we can properly unpack them. */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(buffer, BFROP_TYPE_SIZE_T))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_SIZE_T))) { return ret; } - return pack_gentype(buffer, src, num_vals, BFROP_TYPE_SIZE_T); + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, BFROP_TYPE_SIZE_T, regtypes); + return ret; } /* * PID_T */ -pmix_status_t pmix_bfrops_base_pack_pid(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int ret; /* System types need to always be described so we can properly unpack them. */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(buffer, BFROP_TYPE_PID_T))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_PID_T))) { return ret; } /* Turn around and pack the real type */ - return pack_gentype(buffer, src, num_vals, BFROP_TYPE_PID_T); + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, BFROP_TYPE_PID_T, regtypes); + return ret; } - /* * BYTE, CHAR, INT8 */ -pmix_status_t pmix_bfrops_base_pack_byte(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { char *dst; @@ -238,7 +211,8 @@ pmix_status_t pmix_bfrops_base_pack_byte(pmix_buffer_t *buffer, const void *src, /* * INT16 */ -pmix_status_t pmix_bfrops_base_pack_int16(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int32_t i; @@ -267,7 +241,8 @@ pmix_status_t pmix_bfrops_base_pack_int16(pmix_buffer_t *buffer, const void *src /* * INT32 */ -pmix_status_t pmix_bfrops_base_pack_int32(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int32_t i; @@ -295,7 +270,8 @@ pmix_status_t pmix_bfrops_base_pack_int32(pmix_buffer_t *buffer, const void *src /* * INT64 */ -pmix_status_t pmix_bfrops_base_pack_int64(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int32_t i; @@ -326,7 +302,8 @@ pmix_status_t pmix_bfrops_base_pack_int64(pmix_buffer_t *buffer, const void *src /* * STRING */ -pmix_status_t pmix_bfrops_base_pack_string(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int ret = PMIX_SUCCESS; @@ -336,24 +313,28 @@ pmix_status_t pmix_bfrops_base_pack_string(pmix_buffer_t *buffer, const void *sr for (i = 0; i < num_vals; ++i) { if (NULL == ssrc[i]) { /* got zero-length string/NULL pointer - store NULL */ len = 0; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, &len, 1, PMIX_INT32))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &len, 1, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } else { len = (int32_t)strlen(ssrc[i]) + 1; // retain the NULL terminator - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, &len, 1, PMIX_INT32))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &len, 1, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, ssrc[i], len, PMIX_BYTE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, ssrc[i], len, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } } -return ret; + return ret; } /* FLOAT */ -pmix_status_t pmix_bfrops_base_pack_float(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int ret = PMIX_SUCCESS; @@ -366,18 +347,19 @@ pmix_status_t pmix_bfrops_base_pack_float(pmix_buffer_t *buffer, const void *src if (0 > ret) { return PMIX_ERR_OUT_OF_RESOURCE; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &convert, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &convert, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { free(convert); return ret; } free(convert); } - return PMIX_SUCCESS; } /* DOUBLE */ -pmix_status_t pmix_bfrops_base_pack_double(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int ret = PMIX_SUCCESS; @@ -390,18 +372,19 @@ pmix_status_t pmix_bfrops_base_pack_double(pmix_buffer_t *buffer, const void *sr if (0 > ret) { return PMIX_ERR_OUT_OF_RESOURCE; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &convert, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &convert, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { free(convert); return ret; } free(convert); } - return PMIX_SUCCESS; } /* TIMEVAL */ -pmix_status_t pmix_bfrops_base_pack_timeval(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int64_t tmp[2]; @@ -412,16 +395,17 @@ pmix_status_t pmix_bfrops_base_pack_timeval(pmix_buffer_t *buffer, const void *s for (i = 0; i < num_vals; ++i) { tmp[0] = (int64_t)ssrc[i].tv_sec; tmp[1] = (int64_t)ssrc[i].tv_usec; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int64(buffer, tmp, 2, PMIX_INT64))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, tmp, 2, PMIX_INT64, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } - return PMIX_SUCCESS; } /* TIME */ -pmix_status_t pmix_bfrops_base_pack_time(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int ret = PMIX_SUCCESS; @@ -434,16 +418,17 @@ pmix_status_t pmix_bfrops_base_pack_time(pmix_buffer_t *buffer, const void *src, */ for (i = 0; i < num_vals; ++i) { ui64 = (uint64_t)ssrc[i]; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int64(buffer, &ui64, 1, PMIX_UINT64))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ui64, 1, PMIX_UINT64, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } - return PMIX_SUCCESS; } /* STATUS */ -pmix_status_t pmix_bfrops_base_pack_status(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int ret = PMIX_SUCCESS; @@ -453,16 +438,17 @@ pmix_status_t pmix_bfrops_base_pack_status(pmix_buffer_t *buffer, const void *sr for (i = 0; i < num_vals; ++i) { status = (int32_t)ssrc[i]; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, &status, 1, PMIX_INT32))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &status, 1, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { PMIX_ERROR_LOG(ret); return ret; } } - return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_buf(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_buffer_t *ptr; @@ -473,16 +459,22 @@ pmix_status_t pmix_bfrops_base_pack_buf(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the type of buffer */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, &ptr[i].type, 1, PMIX_BYTE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].type, 1, + PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack the number of bytes */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &ptr[i].bytes_used, 1, PMIX_SIZE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].bytes_used, 1, + PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack the bytes */ if (0 < ptr[i].bytes_used) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, ptr[i].base_ptr, ptr[i].bytes_used, PMIX_BYTE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, ptr[i].base_ptr, + ptr[i].bytes_used, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -490,7 +482,8 @@ pmix_status_t pmix_bfrops_base_pack_buf(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_bo(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { int ret; @@ -499,11 +492,14 @@ pmix_status_t pmix_bfrops_base_pack_bo(pmix_buffer_t *buffer, const void *src, bo = (pmix_byte_object_t*)src; for (i=0; i < num_vals; i++) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &bo[i].size, 1, PMIX_SIZE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &bo[i].size, 1, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 < bo[i].size) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, bo[i].bytes, bo[i].size, PMIX_BYTE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, bo[i].bytes, bo[i].size, + PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -511,7 +507,8 @@ pmix_status_t pmix_bfrops_base_pack_bo(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_proc(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_proc_t *proc; @@ -522,10 +519,13 @@ pmix_status_t pmix_bfrops_base_pack_proc(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { char *ptr = proc[i].nspace; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &ptr, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_rank(buffer, &proc[i].rank, 1, PMIX_PROC_RANK))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &proc[i].rank, 1, + PMIX_PROC_RANK, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -534,7 +534,8 @@ pmix_status_t pmix_bfrops_base_pack_proc(pmix_buffer_t *buffer, const void *src, /* PMIX_VALUE */ -pmix_status_t pmix_bfrops_base_pack_value(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_value_t *ptr; @@ -545,20 +546,20 @@ pmix_status_t pmix_bfrops_base_pack_value(pmix_buffer_t *buffer, const void *src for (i = 0; i < num_vals; ++i) { /* pack the type */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(buffer, ptr[i].type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(regtypes, buffer, ptr[i].type))) { return ret; } /* now pack the right field */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_val(buffer, &ptr[i]))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_val(regtypes, buffer, &ptr[i]))) { return ret; } } - return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_info(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_info_t *info; @@ -571,26 +572,30 @@ pmix_status_t pmix_bfrops_base_pack_info(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack key */ foo = info[i].key; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &foo, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &foo, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack info directives */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info_directives(buffer, &info[i].flags, 1, PMIX_INFO_DIRECTIVES))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &info[i].flags, 1, + PMIX_INFO_DIRECTIVES, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack the type */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(buffer, info[i].value.type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(regtypes, buffer, info[i].value.type))) { return ret; } /* pack value */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_val(buffer, &info[i].value))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_val(regtypes, buffer, &info[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_pdata(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_pdata_t *pdata; @@ -602,22 +607,25 @@ pmix_status_t pmix_bfrops_base_pack_pdata(pmix_buffer_t *buffer, const void *src for (i = 0; i < num_vals; ++i) { /* pack the proc */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_proc(buffer, &pdata[i].proc, 1, PMIX_PROC))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &pdata[i].proc, 1, + PMIX_PROC, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack key */ foo = pdata[i].key; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &foo, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &foo, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { PMIX_ERROR_LOG(ret); return ret; } /* pack the type */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(buffer, pdata[i].value.type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(regtypes, buffer, pdata[i].value.type))) { PMIX_ERROR_LOG(ret); return ret; } /* pack value */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_val(buffer, &pdata[i].value))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_val(regtypes, buffer, &pdata[i].value))) { PMIX_ERROR_LOG(ret); return ret; } @@ -625,7 +633,8 @@ pmix_status_t pmix_bfrops_base_pack_pdata(pmix_buffer_t *buffer, const void *src return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_app(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_app_t *app; @@ -635,43 +644,55 @@ pmix_status_t pmix_bfrops_base_pack_app(pmix_buffer_t *buffer, const void *src, app = (pmix_app_t *) src; for (i = 0; i < num_vals; ++i) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &app[i].cmd, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &app[i].cmd, 1, PMIX_STRING, + regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* argv */ nvals = pmix_argv_count(app[i].argv); - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int(buffer, &nvals, 1, PMIX_INT32))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &nvals, 1, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } for (j=0; j < nvals; j++) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &app[i].argv[j], 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &app[i].argv[j], 1, PMIX_STRING, + regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } /* env */ nvals = pmix_argv_count(app[i].env); - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, &nvals, 1, PMIX_INT32))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &nvals, 1, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } for (j=0; j < nvals; j++) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &app[i].env[j], 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &app[i].env[j], 1, + PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } /* cwd */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &app[i].cwd, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &app[i].cwd, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* maxprocs */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int(buffer, &app[i].maxprocs, 1, PMIX_INT))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &app[i].maxprocs, 1, PMIX_INT, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* info array */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &app[i].ninfo, 1, PMIX_SIZE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &app[i].ninfo, 1, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 < app[i].ninfo) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(buffer, app[i].info, app[i].ninfo, PMIX_INFO))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, app[i].info, app[i].ninfo, PMIX_INFO, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -680,7 +701,8 @@ pmix_status_t pmix_bfrops_base_pack_app(pmix_buffer_t *buffer, const void *src, } -pmix_status_t pmix_bfrops_base_pack_kval(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_kval_t *ptr; @@ -691,316 +713,178 @@ pmix_status_t pmix_bfrops_base_pack_kval(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the key */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &ptr[i].key, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].key, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack the value */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_value(buffer, ptr[i].value, 1, PMIX_VALUE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, ptr[i].value, 1, PMIX_VALUE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } - return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_persist(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_byte(buffer, src, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_BYTE, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_datatype(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_int16(buffer, src, num_vals, type); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT16, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_ptr(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { + pmix_status_t ret; uint8_t foo=1; /* it obviously makes no sense to pack a pointer and * send it somewhere else, so we just pack a sentinel */ - return pmix_bfrops_base_pack_byte(buffer, &foo, 1, PMIX_UINT8); + PMIX_BFROPS_PACK_TYPE(ret, buffer, &foo, 1, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_scope(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_byte(buffer, src, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_range(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_byte(buffer, src, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_cmd(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_byte(buffer, src, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_info_directives(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_info_directives(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_int32(buffer, src, num_vals, PMIX_UINT32); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT32, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_pstate(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_pstate(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_byte(buffer, src, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_pinfo(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_pinfo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - pmix_proc_info_t *pinfo = (pmix_proc_info_t*)src; + pmix_proc_info_t *pinfo = (pmix_proc_info_t *) src; pmix_status_t ret; int32_t i; for (i=0; i < num_vals; i++) { /* pack the proc identifier */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_proc(buffer, &pinfo[i].proc, 1, PMIX_PROC))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &pinfo[i].proc, 1, PMIX_PROC, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack the hostname and exec */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &pinfo[i].hostname, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &pinfo[i].hostname, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &pinfo[i].executable_name, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &pinfo[i].executable_name, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack the pid and state */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_pid(buffer, &pinfo[i].pid, 1, PMIX_PID))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &pinfo[i].pid, 1, PMIX_PID, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_pstate(buffer, &pinfo[i].state, 1, PMIX_PROC_STATE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &pinfo[i].state, 1, PMIX_PROC_STATE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_darray(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - pmix_data_array_t *p = (pmix_data_array_t*)src; + pmix_data_array_t *p = (pmix_data_array_t *) src; pmix_status_t ret; int32_t i; for (i=0; i < num_vals; i++) { /* pack the actual type in the array */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(buffer, p[i].type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_store_data_type(regtypes, buffer, + p[i].type))) { return ret; } /* pack the number of array elements */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &p[i].size, 1, PMIX_SIZE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &p[i].size, 1, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 == p[i].size || PMIX_UNDEF == p[i].type) { /* nothing left to do */ continue; } - /* pack the actual elements - have to do this the hard way */ - switch(p[i].type) { - case PMIX_UNDEF: - break; - case PMIX_BOOL: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_bool(buffer, p[i].array, p[i].size, PMIX_BOOL))) { - return ret; - } - break; - case PMIX_BYTE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, p[i].array, p[i].size, PMIX_BYTE))) { - return ret; - } - break; - case PMIX_STRING: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, p[i].array, p[i].size, PMIX_STRING))) { - return ret; - } - break; - case PMIX_SIZE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, p[i].array, p[i].size, PMIX_SIZE))) { - return ret; - } - break; - case PMIX_PID: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_pid(buffer, p[i].array, p[i].size, PMIX_PID))) { - return ret; - } - break; - case PMIX_INT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int(buffer, p[i].array, p[i].size, PMIX_INT))) { - return ret; - } - break; - case PMIX_INT8: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, p[i].array, p[i].size, PMIX_INT8))) { - return ret; - } - break; - case PMIX_INT16: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int16(buffer, p[i].array, p[i].size, PMIX_INT16))) { - return ret; - } - break; - case PMIX_INT32: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, p[i].array, p[i].size, PMIX_INT32))) { - return ret; - } - break; - case PMIX_INT64: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int64(buffer, p[i].array, p[i].size, PMIX_INT64))) { - return ret; - } - break; - case PMIX_UINT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int(buffer, p[i].array, p[i].size, PMIX_UINT))) { - return ret; - } - break; - case PMIX_UINT8: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, p[i].array, p[i].size, PMIX_UINT8))) { - return ret; - } - break; - case PMIX_UINT16: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int16(buffer, p[i].array, p[i].size, PMIX_UINT16))) { - return ret; - } - break; - case PMIX_UINT32: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, p[i].array, p[i].size, PMIX_UINT32))) { - return ret; - } - break; - case PMIX_UINT64: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int64(buffer, p[i].array, p[i].size, PMIX_UINT64))) { - return ret; - } - break; - case PMIX_FLOAT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_float(buffer, p[i].array, p[i].size, PMIX_FLOAT))) { - return ret; - } - break; - case PMIX_DOUBLE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_double(buffer, p[i].array, p[i].size, PMIX_DOUBLE))) { - return ret; - } - break; - case PMIX_TIMEVAL: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_timeval(buffer, p[i].array, p[i].size, PMIX_TIMEVAL))) { - return ret; - } - break; - case PMIX_TIME: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_time(buffer, p[i].array, p[i].size, PMIX_TIME))) { - return ret; - } - break; - case PMIX_STATUS: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_status(buffer, p[i].array, p[i].size, PMIX_STATUS))) { - return ret; - } - break; - case PMIX_INFO: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(buffer, p[i].array, p[i].size, PMIX_INFO))) { - return ret; - } - break; - case PMIX_PROC: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_proc(buffer, p[i].array, p[i].size, PMIX_PROC))) { - return ret; - } - break; - case PMIX_PROC_RANK: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_rank(buffer, p[i].array, p[i].size, PMIX_PROC_RANK))) { - return ret; - } - break; - case PMIX_BYTE_OBJECT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_bo(buffer, p[i].array, p[i].size, PMIX_BYTE_OBJECT))) { - return ret; - } - break; - case PMIX_PERSIST: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_persist(buffer, p[i].array, p[i].size, PMIX_PERSIST))) { - return ret; - } - break; - case PMIX_POINTER: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_ptr(buffer, p[i].array, p[i].size, PMIX_POINTER))) { - return ret; - } - break; - case PMIX_SCOPE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_scope(buffer, p[i].array, p[i].size, PMIX_SCOPE))) { - return ret; - } - break; - case PMIX_DATA_RANGE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_range(buffer, p[i].array, p[i].size, PMIX_DATA_RANGE))) { - return ret; - } - break; - case PMIX_PROC_STATE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_pstate(buffer, p[i].array, p[i].size, PMIX_PROC_STATE))) { - return ret; - } - break; - case PMIX_PROC_INFO: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_pinfo(buffer, p[i].array, p[i].size, PMIX_PROC_INFO))) { - return ret; - } - break; - case PMIX_DATA_ARRAY: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_darray(buffer, p[i].array, p[i].size, PMIX_DATA_ARRAY))) { - return ret; - } - break; - case PMIX_QUERY: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_query(buffer, p[i].array, p[i].size, PMIX_QUERY))) { - return ret; - } - break; - case PMIX_VALUE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_value(buffer, p[i].array, p[i].size, PMIX_QUERY))) { - return ret; - } - break; - case PMIX_ALLOC_DIRECTIVE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_alloc_directive(buffer, p[i].array, p[i].size, PMIX_ALLOC_DIRECTIVE))) { - return ret; - } - break; - case PMIX_ENVAR: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_envar(buffer, p[i].array, p[i].size, PMIX_ENVAR))) { - return ret; - } - break; - - default: - pmix_output(0, "PACK-PMIX-VALUE[%s:%d]: UNSUPPORTED TYPE %d", - __FILE__, __LINE__, (int)p[i].type); - return PMIX_ERROR; + /* pack the actual elements */ + PMIX_BFROPS_PACK_TYPE(ret, buffer, p[i].array, p[i].size, p[i].type, regtypes); + if (PMIX_ERR_UNKNOWN_DATA_TYPE == ret) { + pmix_output(0, "PACK-PMIX-VALUE[%s:%d]: UNSUPPORTED TYPE %d", + __FILE__, __LINE__, (int)p[i].type); + } + if (PMIX_SUCCESS != ret) { + return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_rank(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_int32(buffer, src, num_vals, PMIX_UINT32); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT32, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_query(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_query_t *pq = (pmix_query_t*)src; @@ -1011,24 +895,29 @@ pmix_status_t pmix_bfrops_base_pack_query(pmix_buffer_t *buffer, const void *src for (i=0; i < num_vals; i++) { /* pack the number of keys */ nkeys = pmix_argv_count(pq[i].keys); - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, &nkeys, 1, PMIX_INT32))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &nkeys, 1, PMIX_UINT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 < nkeys) { /* pack the keys */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, pq[i].keys, nkeys, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, pq[i].keys, nkeys, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } /* pack the number of qualifiers */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &pq[i].nqual, 1, PMIX_SIZE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &pq[i].nqual, 1, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 < pq[i].nqual) { /* pack any provided qualifiers */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(buffer, pq[i].qualifiers, pq[i].nqual, PMIX_INFO))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, pq[i].qualifiers, pq[i].nqual, PMIX_INFO, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } + } } return PMIX_SUCCESS; @@ -1037,7 +926,8 @@ pmix_status_t pmix_bfrops_base_pack_query(pmix_buffer_t *buffer, const void *src /********************/ /* PACK FUNCTIONS FOR VALUE TYPES */ -pmix_status_t pmix_bfrops_base_pack_val(pmix_buffer_t *buffer, +pmix_status_t pmix_bfrops_base_pack_val(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_value_t *p) { pmix_status_t ret; @@ -1045,189 +935,49 @@ pmix_status_t pmix_bfrops_base_pack_val(pmix_buffer_t *buffer, switch (p->type) { case PMIX_UNDEF: break; - case PMIX_BOOL: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_bool(buffer, &p->data.flag, 1, PMIX_BOOL))) { - return ret; - } - break; - case PMIX_BYTE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, &p->data.byte, 1, PMIX_BYTE))) { - return ret; - } - break; - case PMIX_STRING: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &p->data.string, 1, PMIX_STRING))) { - return ret; - } - break; - case PMIX_SIZE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &p->data.size, 1, PMIX_SIZE))) { - return ret; - } - break; - case PMIX_PID: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_pid(buffer, &p->data.pid, 1, PMIX_PID))) { - return ret; - } - break; - case PMIX_INT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int(buffer, &p->data.integer, 1, PMIX_INT))) { - return ret; - } - break; - case PMIX_INT8: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, &p->data.int8, 1, PMIX_INT8))) { - return ret; - } - break; - case PMIX_INT16: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int16(buffer, &p->data.int16, 1, PMIX_INT16))) { - return ret; - } - break; - case PMIX_INT32: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, &p->data.int32, 1, PMIX_INT32))) { - return ret; - } - break; - case PMIX_INT64: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int64(buffer, &p->data.int64, 1, PMIX_INT64))) { - return ret; - } - break; - case PMIX_UINT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int(buffer, &p->data.uint, 1, PMIX_UINT))) { - return ret; - } - break; - case PMIX_UINT8: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, &p->data.uint8, 1, PMIX_UINT8))) { - return ret; - } - break; - case PMIX_UINT16: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int16(buffer, &p->data.uint16, 1, PMIX_UINT16))) { - return ret; - } - break; - case PMIX_UINT32: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int32(buffer, &p->data.uint32, 1, PMIX_UINT32))) { - return ret; - } - break; - case PMIX_UINT64: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_int64(buffer, &p->data.uint64, 1, PMIX_UINT64))) { - return ret; - } - break; - case PMIX_FLOAT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_float(buffer, &p->data.fval, 1, PMIX_FLOAT))) { - return ret; - } - break; - case PMIX_DOUBLE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_double(buffer, &p->data.dval, 1, PMIX_DOUBLE))) { - return ret; - } - break; - case PMIX_TIMEVAL: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_timeval(buffer, &p->data.tv, 1, PMIX_TIMEVAL))) { - return ret; - } - break; - case PMIX_TIME: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_time(buffer, &p->data.time, 1, PMIX_TIME))) { - return ret; - } - break; - case PMIX_STATUS: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_status(buffer, &p->data.status, 1, PMIX_STATUS))) { - return ret; - } - break; - case PMIX_PROC: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_proc(buffer, p->data.proc, 1, PMIX_PROC))) { - return ret; - } - break; - case PMIX_PROC_RANK: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_rank(buffer, &p->data.rank, 1, PMIX_PROC_RANK))) { - return ret; - } - break; - case PMIX_BYTE_OBJECT: - case PMIX_COMPRESSED_STRING: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_bo(buffer, &p->data.bo, 1, PMIX_BYTE_OBJECT))) { - return ret; - } - break; - case PMIX_PERSIST: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_persist(buffer, &p->data.persist, 1, PMIX_PERSIST))) { - return ret; - } - break; - case PMIX_POINTER: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_ptr(buffer, &p->data.ptr, 1, PMIX_POINTER))) { - return ret; - } - break; - case PMIX_SCOPE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_scope(buffer, &p->data.scope, 1, PMIX_SCOPE))) { - return ret; - } - break; - case PMIX_DATA_RANGE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_range(buffer, &p->data.range, 1, PMIX_DATA_RANGE))) { - return ret; - } - break; - case PMIX_PROC_STATE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_pstate(buffer, &p->data.state, 1, PMIX_PROC_STATE))) { - return ret; - } - break; case PMIX_PROC_INFO: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_pinfo(buffer, p->data.pinfo, 1, PMIX_PROC_INFO))) { - return ret; - } - break; case PMIX_DATA_ARRAY: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_darray(buffer, p->data.darray, 1, PMIX_DATA_ARRAY))) { + case PMIX_PROC: + case PMIX_COORD: + case PMIX_REGATTR: + PMIX_BFROPS_PACK_TYPE(ret, buffer, p->data.ptr, 1, p->type, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } break; - case PMIX_ALLOC_DIRECTIVE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_alloc_directive(buffer, &p->data.adir, 1, PMIX_ALLOC_DIRECTIVE))) { - return ret; - } - break; - case PMIX_ENVAR: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_envar(buffer, &p->data.envar, 1, PMIX_ENVAR))) { - return ret; - } - break; - default: - pmix_output(0, "PACK-PMIX-VALUE[%s:%d]: UNSUPPORTED TYPE %d", - __FILE__, __LINE__, (int)p->type); - return PMIX_ERROR; + PMIX_BFROPS_PACK_TYPE(ret, buffer, &p->data, 1, p->type, regtypes); + if (PMIX_ERR_UNKNOWN_DATA_TYPE == ret) { + pmix_output(0, "PACK-PMIX-VALUE[%s:%d]: UNSUPPORTED TYPE %d", + __FILE__, __LINE__, (int)p->type); + return PMIX_ERROR; + } else if (PMIX_SUCCESS != ret) { + return ret; + } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_pack_alloc_directive(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_alloc_directive(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_byte(buffer, src, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_iof_channel(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_iof_channel(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_pack_int16(buffer, src, num_vals, PMIX_UINT16); + pmix_status_t ret; + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_UINT16, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_pack_envar(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix_bfrops_base_pack_envar(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_envar_t *ptr = (pmix_envar_t*)src; @@ -1236,15 +986,103 @@ pmix_status_t pmix_bfrops_base_pack_envar(pmix_buffer_t *buffer, const void *src for (i=0; i < num_vals; ++i) { /* pack the name */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &ptr[i].envar, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].envar, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack the value */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_string(buffer, &ptr[i].value, 1, PMIX_STRING))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].value, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* pack the separator */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, &ptr[i].separator, 1, PMIX_BYTE))) { + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].separator, 1, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + } + return PMIX_SUCCESS; +} + +pmix_status_t pmix_bfrops_base_pack_coord(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) +{ + pmix_coord_t *ptr = (pmix_coord_t*)src; + int32_t i; + pmix_status_t ret; + + for (i=0; i < num_vals; ++i) { + /* pack the x-coord */ + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].x, 1, PMIX_INT, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + /* pack the y-coord */ + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].y, 1, PMIX_INT, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + /* pack the z-coord */ + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].z, 1, PMIX_INT, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + } + return PMIX_SUCCESS; +} + +pmix_status_t pmix_bfrops_base_pack_regattr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) +{ + pmix_regattr_t *ptr = (pmix_regattr_t*)src; + int32_t i, nd; + pmix_status_t ret; + char *foo; + + for (i=0; i < num_vals; ++i) { + /* pack the name */ + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].name, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + /* pack the string */ + foo = ptr[i].string; + PMIX_BFROPS_PACK_TYPE(ret, buffer, &foo, 1, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + /* pack the type */ + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].type, 1, PMIX_DATA_TYPE, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + /* pack the number of info */ + PMIX_BFROPS_PACK_TYPE(ret, buffer, &ptr[i].ninfo, 1, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + if (0 < ptr[i].ninfo) { + /* pack the info array */ + PMIX_BFROPS_PACK_TYPE(ret, buffer, ptr[i].info, ptr[i].ninfo, PMIX_INFO, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + } + /* pack the description */ + nd = pmix_argv_count(ptr[i].description); + PMIX_BFROPS_PACK_TYPE(ret, buffer, &nd, 1, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + PMIX_BFROPS_PACK_TYPE(ret, buffer, ptr[i].description, nd, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); return ret; } } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_print.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_print.c index d17a731257..a00629d0db 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_print.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_print.c @@ -10,7 +10,7 @@ * 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-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * @@ -875,6 +875,7 @@ int pmix_bfrops_base_print_status(char **output, char *prefix, { char *prefx; int rc; + pmix_regattr_t *r; /* deal with NULL prefix */ if (NULL == prefix) { @@ -1021,6 +1022,18 @@ int pmix_bfrops_base_print_status(char **output, char *prefix, src->data.envar.separator); break; + case PMIX_COORD: + rc = asprintf(output, "%sPMIX_VALUE: Data type: PMIX_COORD\tx-axis: %d\ty-axis: %d\tz-axis: %d", + prefx, src->data.coord->x, src->data.coord->y, src->data.coord->z); + break; + + case PMIX_REGATTR: + r = (pmix_regattr_t*)src->data.ptr; + rc = asprintf(output, "%sPMIX_VALUE: Data type: PMIX_REGATTR\tName: %s\tString: %s", + prefx, (NULL == r->name) ? "NULL" : r->name, + (NULL == r->string) ? "NULL" : r->string); + break; + default: rc = asprintf(output, "%sPMIX_VALUE: Data type: UNKNOWN\tValue: UNPRINTABLE", prefx); break; @@ -1690,3 +1703,63 @@ pmix_status_t pmix_bfrops_base_print_envar(char **output, char *prefix, return PMIX_SUCCESS; } } + +pmix_status_t pmix_bfrops_base_print_coord(char **output, char *prefix, + pmix_coord_t *src, + pmix_data_type_t type) +{ + char *prefx; + int ret; + + /* deal with NULL prefix */ + if (NULL == prefix) { + if (0 > asprintf(&prefx, " ")) { + return PMIX_ERR_NOMEM; + } + } else { + prefx = prefix; + } + + ret = asprintf(output, "%sData type: PMIX_COORD\tx-axis: %d\ty-axis: %d\tz-axis: %d", + prefx, src->x, src->y, src->z); + if (prefx != prefix) { + free(prefx); + } + + if (0 > ret) { + return PMIX_ERR_OUT_OF_RESOURCE; + } else { + return PMIX_SUCCESS; + } +} + +pmix_status_t pmix_bfrops_base_print_regattr(char **output, char *prefix, + pmix_regattr_t *src, + pmix_data_type_t type) +{ + char *prefx; + int ret; + + /* deal with NULL prefix */ + if (NULL == prefix) { + if (0 > asprintf(&prefx, " ")) { + return PMIX_ERR_NOMEM; + } + } else { + prefx = prefix; + } + + ret = asprintf(output, "%sData type: PMIX_REGATTR\tName: %s\tString: %s", + prefx, (NULL == src->name) ? "NULL" : src->name, + (NULL == src->string) ? "NULL" : src->string); + + if (prefx != prefix) { + free(prefx); + } + + if (0 > ret) { + return PMIX_ERR_OUT_OF_RESOURCE; + } else { + return PMIX_SUCCESS; + } +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_unpack.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_unpack.c index 051c35d82a..6ee9b75504 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_unpack.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_unpack.c @@ -10,10 +10,10 @@ * 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-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2016 Mellanox Technologies, Inc. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ * @@ -24,8 +24,6 @@ #include -#include - #include "src/util/argv.h" #include "src/util/error.h" #include "src/util/output.h" @@ -41,7 +39,6 @@ static pmix_status_t pmix_bfrops_base_unpack_buffer(pmix_pointer_array_t *regtyp { pmix_status_t rc; pmix_data_type_t local_type; - pmix_bfrop_type_info_t *info; pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrops_base_unpack_buffer( %p, %p, %lu, %d )\n", @@ -49,7 +46,7 @@ static pmix_status_t pmix_bfrops_base_unpack_buffer(pmix_pointer_array_t *regtyp /** Unpack the declared data type */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix_bfrop_get_data_type(buffer, &local_type))) { + if (PMIX_SUCCESS != (rc = pmix_bfrop_get_data_type(regtypes, buffer, &local_type))) { PMIX_ERROR_LOG(rc); return rc; } @@ -59,14 +56,8 @@ static pmix_status_t pmix_bfrops_base_unpack_buffer(pmix_pointer_array_t *regtyp return PMIX_ERR_PACK_MISMATCH; } } - - /* Lookup the unpack function for this type and call it */ - if (NULL == (info = (pmix_bfrop_type_info_t*)pmix_pointer_array_get_item(regtypes, type))) { - PMIX_ERROR_LOG(PMIX_ERR_UNPACK_FAILURE); - return PMIX_ERR_UNPACK_FAILURE; - } - - return info->odti_unpack_fn(buffer, dst, num_vals, type); + PMIX_BFROPS_UNPACK_TYPE(rc, buffer, dst, num_vals, type, regtypes); + return rc; } pmix_status_t pmix_bfrops_base_unpack(pmix_pointer_array_t *regtypes, @@ -103,7 +94,7 @@ pmix_status_t pmix_bfrops_base_unpack(pmix_pointer_array_t *regtypes, * int32_t as used here. */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix_bfrop_get_data_type(buffer, &local_type))) { + if (PMIX_SUCCESS != (rc = pmix_bfrop_get_data_type(regtypes, buffer, &local_type))) { *num_vals = 0; /* don't error log here as the user may be unpacking past * the end of the buffer, which isn't necessarily an error */ @@ -117,7 +108,8 @@ pmix_status_t pmix_bfrops_base_unpack(pmix_pointer_array_t *regtypes, } n=1; - if (PMIX_SUCCESS != (rc = pmix_bfrops_base_unpack_int32(buffer, &local_num, &n, PMIX_INT32))) { + PMIX_BFROPS_UNPACK_TYPE(rc, buffer, &local_num, &n, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != rc) { *num_vals = 0; /* don't error log here as the user may be unpacking past * the end of the buffer, which isn't necessarily an error */ @@ -152,41 +144,13 @@ pmix_status_t pmix_bfrops_base_unpack(pmix_pointer_array_t *regtypes, return ret; } -static pmix_status_t unpack_gentype(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) -{ - switch(type) { - case PMIX_INT8: - case PMIX_UINT8: - return pmix_bfrops_base_unpack_byte(buffer, dest, num_vals, type); - break; - - case PMIX_INT16: - case PMIX_UINT16: - return pmix_bfrops_base_unpack_int16(buffer, dest, num_vals, type); - break; - - case PMIX_INT32: - case PMIX_UINT32: - return pmix_bfrops_base_unpack_int32(buffer, dest, num_vals, type); - break; - - case PMIX_INT64: - case PMIX_UINT64: - return pmix_bfrops_base_unpack_int64(buffer, dest, num_vals, type); - break; - - default: - return PMIX_ERR_UNKNOWN_DATA_TYPE; - } -} - /* UNPACK GENERIC SYSTEM TYPES */ /* * BOOL */ - pmix_status_t pmix_bfrops_base_unpack_bool(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix_bfrops_base_unpack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { int32_t i; @@ -222,24 +186,24 @@ static pmix_status_t unpack_gentype(pmix_buffer_t *buffer, void *dest, /* * INT */ -pmix_status_t pmix_bfrops_base_unpack_int(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(regtypes, buffer, &remote_type))) { return ret; } if (remote_type == BFROP_TYPE_INT) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = unpack_gentype(buffer, dest, num_vals, BFROP_TYPE_INT))) { - } + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, BFROP_TYPE_INT, regtypes); } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(int, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, int, remote_type, ret); } return ret; @@ -248,50 +212,55 @@ pmix_status_t pmix_bfrops_base_unpack_int(pmix_buffer_t *buffer, void *dest, /* * SIZE_T */ -pmix_status_t pmix_bfrops_base_unpack_sizet(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(regtypes, buffer, + &remote_type))) { + PMIX_ERROR_LOG(ret); return ret; } if (remote_type == BFROP_TYPE_SIZE_T) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = unpack_gentype(buffer, dest, num_vals, BFROP_TYPE_SIZE_T))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, BFROP_TYPE_SIZE_T, + regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); } } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(size_t, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, size_t, remote_type, ret); } - return ret; } /* * PID_T */ -pmix_status_t pmix_bfrops_base_unpack_pid(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(regtypes, buffer, &remote_type))) { return ret; } if (remote_type == BFROP_TYPE_PID_T) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = unpack_gentype(buffer, dest, num_vals, BFROP_TYPE_PID_T))) { - } + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, BFROP_TYPE_PID_T, regtypes); } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(pid_t, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, pid_t, remote_type, ret); } return ret; @@ -303,7 +272,8 @@ pmix_status_t pmix_bfrops_base_unpack_pid(pmix_buffer_t *buffer, void *dest, /* * BYTE, CHAR, INT8 */ -pmix_status_t pmix_bfrops_base_unpack_byte(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, @@ -323,7 +293,8 @@ pmix_status_t pmix_bfrops_base_unpack_byte(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_int16(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { int32_t i; @@ -348,7 +319,8 @@ pmix_status_t pmix_bfrops_base_unpack_int16(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_int32(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { int32_t i; @@ -373,13 +345,18 @@ pmix_status_t pmix_bfrops_base_unpack_int32(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_datatype(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_int16(buffer, dest, num_vals, type); + pmix_status_t ret; + + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_INT16, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_int64(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { int32_t i; @@ -404,7 +381,8 @@ pmix_status_t pmix_bfrops_base_unpack_int64(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_string(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; @@ -412,7 +390,8 @@ pmix_status_t pmix_bfrops_base_unpack_string(pmix_buffer_t *buffer, void *dest, char **sdest = (char**) dest; for (i = 0; i < (*num_vals); ++i) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int32(buffer, &len, &n, PMIX_INT32))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &len, &n, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 == len) { /* zero-length string - unpack the NULL */ @@ -422,7 +401,8 @@ pmix_status_t pmix_bfrops_base_unpack_string(pmix_buffer_t *buffer, void *dest, if (NULL == sdest[i]) { return PMIX_ERR_OUT_OF_RESOURCE; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, sdest[i], &len, PMIX_BYTE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, sdest[i], &len, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -431,7 +411,8 @@ pmix_status_t pmix_bfrops_base_unpack_string(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_float(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; @@ -442,16 +423,12 @@ pmix_status_t pmix_bfrops_base_unpack_float(pmix_buffer_t *buffer, void *dest, pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrop_unpack_float * %d\n", (int)*num_vals); - /* check to see if there's enough data in buffer */ - if (pmix_bfrop_too_small(buffer, (*num_vals)*sizeof(float))) { - return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - /* unpack the data */ for (i = 0; i < (*num_vals); ++i) { n=1; convert = NULL; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &convert, &n, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &convert, &n, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (NULL != convert) { @@ -463,7 +440,8 @@ pmix_status_t pmix_bfrops_base_unpack_float(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_double(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; @@ -474,16 +452,12 @@ pmix_status_t pmix_bfrops_base_unpack_double(pmix_buffer_t *buffer, void *dest, pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrop_unpack_double * %d\n", (int)*num_vals); - /* check to see if there's enough data in buffer */ - if (pmix_bfrop_too_small(buffer, (*num_vals)*sizeof(double))) { - return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - /* unpack the data */ for (i = 0; i < (*num_vals); ++i) { n=1; convert = NULL; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &convert, &n, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &convert, &n, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (NULL != convert) { @@ -495,7 +469,8 @@ pmix_status_t pmix_bfrops_base_unpack_double(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_timeval(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; @@ -506,15 +481,11 @@ pmix_status_t pmix_bfrops_base_unpack_timeval(pmix_buffer_t *buffer, void *dest, pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrop_unpack_timeval * %d\n", (int)*num_vals); - /* check to see if there's enough data in buffer */ - if (pmix_bfrop_too_small(buffer, (*num_vals)*sizeof(struct timeval))) { - return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - /* unpack the data */ for (i = 0; i < (*num_vals); ++i) { n=2; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int64(buffer, tmp, &n, PMIX_INT64))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, tmp, &n, PMIX_INT64, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } tt.tv_sec = tmp[0]; @@ -524,7 +495,8 @@ pmix_status_t pmix_bfrops_base_unpack_timeval(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_time(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; @@ -539,15 +511,11 @@ pmix_status_t pmix_bfrops_base_unpack_time(pmix_buffer_t *buffer, void *dest, pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrop_unpack_time * %d\n", (int)*num_vals); - /* check to see if there's enough data in buffer */ - if (pmix_bfrop_too_small(buffer, (*num_vals)*(sizeof(uint64_t)))) { - return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - /* unpack the data */ for (i = 0; i < (*num_vals); ++i) { n=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int64(buffer, &ui64, &n, PMIX_UINT64))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ui64, &n, PMIX_UINT64, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } tmp = (time_t)ui64; @@ -557,19 +525,18 @@ pmix_status_t pmix_bfrops_base_unpack_time(pmix_buffer_t *buffer, void *dest, } -pmix_status_t pmix_bfrops_base_unpack_status(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + pmix_status_t ret; + + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrop_unpack_status * %d\n", (int)*num_vals); - /* check to see if there's enough data in buffer */ - if (pmix_bfrop_too_small(buffer, (*num_vals)*(sizeof(pmix_status_t)))) { - return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - /* unpack the data */ - return pmix_bfrops_base_unpack_int32(buffer, dest, num_vals, PMIX_INT32); + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_INT32, regtypes); + return ret; } @@ -578,161 +545,24 @@ pmix_status_t pmix_bfrops_base_unpack_status(pmix_buffer_t *buffer, void *dest, /* * PMIX_VALUE */ -pmix_status_t pmix_bfrops_base_unpack_val(pmix_buffer_t *buffer, +pmix_status_t pmix_bfrops_base_unpack_val(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_value_t *val) { int m; - pmix_status_t ret; + pmix_status_t ret = PMIX_SUCCESS; m = 1; switch (val->type) { case PMIX_UNDEF: break; - case PMIX_BOOL: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_bool(buffer, &val->data.flag, &m, PMIX_BOOL))) { - return ret; - } - break; - case PMIX_BYTE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, &val->data.byte, &m, PMIX_BYTE))) { - return ret; - } - break; - case PMIX_STRING: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &val->data.string, &m, PMIX_STRING))) { - return ret; - } - break; - case PMIX_SIZE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &val->data.size, &m, PMIX_SIZE))) { - return ret; - } - break; - case PMIX_PID: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_pid(buffer, &val->data.pid, &m, PMIX_PID))) { - return ret; - } - break; - case PMIX_INT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int(buffer, &val->data.integer, &m, PMIX_INT))) { - return ret; - } - break; - case PMIX_INT8: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, &val->data.int8, &m, PMIX_INT8))) { - return ret; - } - break; - case PMIX_INT16: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int16(buffer, &val->data.int16, &m, PMIX_INT16))) { - return ret; - } - break; - case PMIX_INT32: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int32(buffer, &val->data.int32, &m, PMIX_INT32))) { - return ret; - } - break; - case PMIX_INT64: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int64(buffer, &val->data.int64, &m, PMIX_INT64))) { - return ret; - } - break; - case PMIX_UINT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int(buffer, &val->data.uint, &m, PMIX_UINT))) { - return ret; - } - break; - case PMIX_UINT8: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, &val->data.uint8, &m, PMIX_UINT8))) { - return ret; - } - break; - case PMIX_UINT16: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int16(buffer, &val->data.uint16, &m, PMIX_UINT16))) { - return ret; - } - break; - case PMIX_UINT32: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int32(buffer, &val->data.uint32, &m, PMIX_UINT32))) { - return ret; - } - break; - case PMIX_UINT64: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int64(buffer, &val->data.uint64, &m, PMIX_UINT64))) { - return ret; - } - break; - case PMIX_FLOAT: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_float(buffer, &val->data.fval, &m, PMIX_FLOAT))) { - return ret; - } - break; - case PMIX_DOUBLE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_double(buffer, &val->data.dval, &m, PMIX_DOUBLE))) { - return ret; - } - break; - case PMIX_TIMEVAL: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_timeval(buffer, &val->data.tv, &m, PMIX_TIMEVAL))) { - return ret; - } - break; - case PMIX_TIME: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_time(buffer, &val->data.time, &m, PMIX_TIME))) { - return ret; - } - break; - case PMIX_STATUS: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_status(buffer, &val->data.status, &m, PMIX_STATUS))) { - return ret; - } - break; case PMIX_PROC: /* this field is now a pointer, so we must allocate storage for it */ PMIX_PROC_CREATE(val->data.proc, m); if (NULL == val->data.proc) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_proc(buffer, val->data.proc, &m, PMIX_PROC))) { - return ret; - } - break; - case PMIX_PROC_RANK: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_rank(buffer, &val->data.rank, &m, PMIX_PROC_RANK))) { - return ret; - } - break; - case PMIX_BYTE_OBJECT: - case PMIX_COMPRESSED_STRING: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_bo(buffer, &val->data.bo, &m, PMIX_BYTE_OBJECT))) { - return ret; - } - break; - case PMIX_PERSIST: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_persist(buffer, &val->data.proc, &m, PMIX_PERSIST))) { - return ret; - } - break; - case PMIX_POINTER: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_ptr(buffer, &val->data.ptr, &m, PMIX_POINTER))) { - return ret; - } - break; - case PMIX_SCOPE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_scope(buffer, &val->data.scope, &m, PMIX_SCOPE))) { - return ret; - } - break; - case PMIX_DATA_RANGE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_range(buffer, &val->data.range, &m, PMIX_DATA_RANGE))) { - return ret; - } - break; - case PMIX_PROC_STATE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_pstate(buffer, &val->data.state, &m, PMIX_PROC_STATE))) { - return ret; - } + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, val->data.proc, &m, PMIX_PROC, regtypes); break; case PMIX_PROC_INFO: /* this is now a pointer, so allocate storage for it */ @@ -740,9 +570,7 @@ pmix_status_t pmix_bfrops_base_unpack_val(pmix_buffer_t *buffer, if (NULL == val->data.pinfo) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_pinfo(buffer, val->data.pinfo, &m, PMIX_PROC_INFO))) { - return ret; - } + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, val->data.pinfo, &m, PMIX_PROC_INFO, regtypes); break; case PMIX_DATA_ARRAY: /* this is now a pointer, so allocate storage for it */ @@ -750,29 +578,27 @@ pmix_status_t pmix_bfrops_base_unpack_val(pmix_buffer_t *buffer, if (NULL == val->data.darray) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_darray(buffer, val->data.darray, &m, PMIX_DATA_ARRAY))) { - return ret; - } + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, val->data.darray, &m, PMIX_DATA_ARRAY, regtypes); break; - case PMIX_ALLOC_DIRECTIVE: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_alloc_directive(buffer, &val->data.adir, &m, PMIX_ALLOC_DIRECTIVE))) { - return ret; + case PMIX_COORD: + val->data.coord = (pmix_coord_t*)malloc(sizeof(pmix_coord_t)); + if (NULL == val->data.coord) { + return PMIX_ERR_NOMEM; } - break; - case PMIX_ENVAR: - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_envar(buffer, &val->data.envar, &m, PMIX_ENVAR))) { - return ret; - } - break; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, val->data.coord, &m, PMIX_COORD, regtypes); + return ret; default: - pmix_output(0, "UNPACK-PMIX-VALUE: UNSUPPORTED TYPE %d", (int)val->type); - return PMIX_ERROR; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &val->data, &m, val->type, regtypes); + if (PMIX_ERR_UNKNOWN_DATA_TYPE == ret) { + pmix_output(0, "UNPACK-PMIX-VALUE: UNSUPPORTED TYPE %d", (int)val->type); + } } - return PMIX_SUCCESS; + return ret; } -pmix_status_t pmix_bfrops_base_unpack_value(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_value_t *ptr; @@ -784,12 +610,12 @@ pmix_status_t pmix_bfrops_base_unpack_value(pmix_buffer_t *buffer, void *dest, for (i = 0; i < n; ++i) { /* unpack the type */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(buffer, &ptr[i].type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(regtypes, buffer, &ptr[i].type))) { PMIX_ERROR_LOG(ret); return ret; } /* unpack value */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_val(buffer, &ptr[i])) ) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_val(regtypes, buffer, &ptr[i])) ) { PMIX_ERROR_LOG(ret); return ret; } @@ -797,7 +623,8 @@ pmix_status_t pmix_bfrops_base_unpack_value(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_info(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_info_t *ptr; @@ -817,7 +644,8 @@ pmix_status_t pmix_bfrops_base_unpack_info(pmix_buffer_t *buffer, void *dest, /* unpack key */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &tmp, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { PMIX_ERROR_LOG(ret); return ret; } @@ -828,26 +656,28 @@ pmix_status_t pmix_bfrops_base_unpack_info(pmix_buffer_t *buffer, void *dest, free(tmp); /* unpack the directives */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_info_directives(buffer, &ptr[i].flags, &m, PMIX_INFO_DIRECTIVES))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].flags, &m, PMIX_INFO_DIRECTIVES, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack value - since the value structure is statically-defined * instead of a pointer in this struct, we directly unpack it to * avoid the malloc */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(buffer, &ptr[i].value.type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(regtypes, buffer, &ptr[i].value.type))) { return ret; } pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrop_unpack: info type %d", ptr[i].value.type); m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_val(buffer, &ptr[i].value))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_val(regtypes, buffer, &ptr[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_pdata(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_pdata_t *ptr; @@ -865,13 +695,15 @@ pmix_status_t pmix_bfrops_base_unpack_pdata(pmix_buffer_t *buffer, void *dest, PMIX_PDATA_CONSTRUCT(&ptr[i]); /* unpack the proc */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_proc(buffer, &ptr[i].proc, &m, PMIX_PROC))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].proc, &m, PMIX_PROC, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack key */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &tmp, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (NULL == tmp) { @@ -883,14 +715,14 @@ pmix_status_t pmix_bfrops_base_unpack_pdata(pmix_buffer_t *buffer, void *dest, /* unpack value - since the value structure is statically-defined * instead of a pointer in this struct, we directly unpack it to * avoid the malloc */ - if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(buffer, &ptr[i].value.type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(regtypes, buffer, &ptr[i].value.type))) { PMIX_ERROR_LOG(ret); return ret; } pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrop_unpack: pdata type %d %s", ptr[i].value.type, ptr[i].value.data.string); m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_val(buffer, &ptr[i].value))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_val(regtypes, buffer, &ptr[i].value))) { PMIX_ERROR_LOG(ret); return ret; } @@ -898,7 +730,8 @@ pmix_status_t pmix_bfrops_base_unpack_pdata(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_buf(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_buffer_t *ptr; @@ -913,12 +746,14 @@ pmix_status_t pmix_bfrops_base_unpack_buf(pmix_buffer_t *buffer, void *dest, PMIX_CONSTRUCT(&ptr[i], pmix_buffer_t); /* unpack the type of buffer */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, &ptr[i].type, &m, PMIX_BYTE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].type, &m, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &nbytes, &m, PMIX_SIZE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &nbytes, &m, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } m = nbytes; @@ -929,7 +764,8 @@ pmix_status_t pmix_bfrops_base_unpack_buf(pmix_buffer_t *buffer, void *dest, return PMIX_ERR_NOMEM; } /* unpack the bytes */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, ptr[i].base_ptr, &m, PMIX_BYTE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, ptr[i].base_ptr, &m, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -941,7 +777,8 @@ pmix_status_t pmix_bfrops_base_unpack_buf(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_proc(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_proc_t *ptr; @@ -962,8 +799,8 @@ pmix_status_t pmix_bfrops_base_unpack_proc(pmix_buffer_t *buffer, void *dest, /* unpack nspace */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { - PMIX_ERROR_LOG(ret); + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &tmp, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (NULL == tmp) { @@ -974,15 +811,16 @@ pmix_status_t pmix_bfrops_base_unpack_proc(pmix_buffer_t *buffer, void *dest, free(tmp); /* unpack the rank */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_rank(buffer, &ptr[i].rank, &m, PMIX_PROC_RANK))) { - PMIX_ERROR_LOG(ret); + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].rank, &m, PMIX_PROC_RANK, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_app(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_app_t *ptr; @@ -1002,19 +840,22 @@ pmix_status_t pmix_bfrops_base_unpack_app(pmix_buffer_t *buffer, void *dest, PMIX_APP_CONSTRUCT(&ptr[i]); /* unpack cmd */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &ptr[i].cmd, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].cmd, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack argc */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int(buffer, &nval, &m, PMIX_INT32))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &nval, &m, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack argv */ for (k=0; k < nval; k++) { m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &tmp, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (NULL == tmp) { @@ -1025,13 +866,15 @@ pmix_status_t pmix_bfrops_base_unpack_app(pmix_buffer_t *buffer, void *dest, } /* unpack env */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int32(buffer, &nval, &m, PMIX_INT32))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &nval, &m, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } for (k=0; k < nval; k++) { m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &tmp, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (NULL == tmp) { @@ -1042,23 +885,27 @@ pmix_status_t pmix_bfrops_base_unpack_app(pmix_buffer_t *buffer, void *dest, } /* unpack cwd */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &ptr[i].cwd, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].cwd, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack maxprocs */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int(buffer, &ptr[i].maxprocs, &m, PMIX_INT))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].maxprocs, &m, PMIX_INT, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack info array */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &ptr[i].ninfo, &m, PMIX_SIZE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].ninfo, &m, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 < ptr[i].ninfo) { PMIX_INFO_CREATE(ptr[i].info, ptr[i].ninfo); m = ptr[i].ninfo; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_info(buffer, ptr[i].info, &m, PMIX_INFO))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].info, &m, PMIX_INFO, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -1066,7 +913,8 @@ pmix_status_t pmix_bfrops_base_unpack_app(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_kval(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_kval_t *ptr; @@ -1083,29 +931,33 @@ pmix_status_t pmix_bfrops_base_unpack_kval(pmix_buffer_t *buffer, void *dest, PMIX_CONSTRUCT(&ptr[i], pmix_kval_t); /* unpack the key */ m = 1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &ptr[i].key, &m, PMIX_STRING))) { - PMIX_ERROR_LOG(ret); + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].key, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* allocate the space */ ptr[i].value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); /* unpack the value */ m = 1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_value(buffer, ptr[i].value, &m, PMIX_VALUE))) { - PMIX_ERROR_LOG(ret); + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, ptr[i].value, &m, PMIX_VALUE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_persist(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_BYTE, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_bo(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_byte_object_t *ptr; @@ -1122,13 +974,15 @@ pmix_status_t pmix_bfrops_base_unpack_bo(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_byte_object_t)); /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].size, &m, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 < ptr[i].size) { ptr[i].bytes = (char*)malloc(ptr[i].size * sizeof(char)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, ptr[i].bytes, &m, PMIX_BYTE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, ptr[i].bytes, &m, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -1136,49 +990,68 @@ pmix_status_t pmix_bfrops_base_unpack_bo(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_ptr(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { uint8_t foo=1; int32_t cnt=1; + pmix_status_t ret; /* it obviously makes no sense to pack a pointer and * send it somewhere else, so we just unpack the sentinel */ - return pmix_bfrops_base_unpack_byte(buffer, &foo, &cnt, PMIX_UINT8); + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &foo, &cnt, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_scope(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_range(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_cmd(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_info_directives(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_info_directives(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_int32(buffer, dest, num_vals, PMIX_UINT32); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_UINT32, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_pstate(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_pstate(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_pinfo(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_pinfo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_proc_info_t *ptr; @@ -1195,39 +1068,46 @@ pmix_status_t pmix_bfrops_base_unpack_pinfo(pmix_buffer_t *buffer, void *dest, PMIX_PROC_INFO_CONSTRUCT(&ptr[i]); /* unpack the proc */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_proc(buffer, &ptr[i].proc, &m, PMIX_PROC))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].proc, &m, PMIX_PROC, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack the hostname */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &ptr[i].hostname, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].hostname, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack the executable */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &ptr[i].executable_name, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].executable_name, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack pid */ - m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_pid(buffer, &ptr[i].pid, &m, PMIX_PID))) { + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].pid, &m, PMIX_PID, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack state */ - m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_pstate(buffer, &ptr[i].state, &m, PMIX_PROC_STATE))) { + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].state, &m, PMIX_PROC_STATE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_darray(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_data_array_t *ptr; int32_t i, n, m; pmix_status_t ret; + pmix_data_type_t t; pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix_bfrop_unpack: %d data arrays", *num_vals); @@ -1239,12 +1119,13 @@ pmix_status_t pmix_bfrops_base_unpack_darray(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_data_array_t)); /* unpack the type */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(buffer, &ptr[i].type))) { + if (PMIX_SUCCESS != (ret = pmix_bfrop_get_data_type(regtypes, buffer, &ptr[i].type))) { return ret; } /* unpack the number of array elements */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].size, &m, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 == ptr[i].size || PMIX_UNDEF == ptr[i].type) { @@ -1253,262 +1134,31 @@ pmix_status_t pmix_bfrops_base_unpack_darray(pmix_buffer_t *buffer, void *dest, } /* allocate storage for the array and unpack the array elements */ m = ptr[i].size; - switch(ptr[i].type) { - case PMIX_BOOL: - ptr[i].array = (bool*)malloc(m * sizeof(bool)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_bool(buffer, ptr[i].array, &m, PMIX_BOOL))) { - return ret; - } - break; - case PMIX_BYTE: - case PMIX_INT8: - case PMIX_UINT8: - ptr[i].array = (uint8_t*)malloc(m * sizeof(uint8_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_INT16: - case PMIX_UINT16: - ptr[i].array = (uint16_t*)malloc(m * sizeof(uint16_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int16(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_INT32: - case PMIX_UINT32: - ptr[i].array = (uint32_t*)malloc(m * sizeof(uint32_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int32(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_INT64: - case PMIX_UINT64: - ptr[i].array = (uint64_t*)malloc(m * sizeof(uint64_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int64(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_STRING: - ptr[i].array = (char**)malloc(m * sizeof(char*)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_SIZE: - ptr[i].array = (size_t*)malloc(m * sizeof(size_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_PID: - ptr[i].array = (pid_t*)malloc(m * sizeof(pid_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_pid(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_INT: - case PMIX_UINT: - ptr[i].array = (int*)malloc(m * sizeof(int)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_FLOAT: - ptr[i].array = (float*)malloc(m * sizeof(float)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_float(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_DOUBLE: - ptr[i].array = (double*)malloc(m * sizeof(double)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_double(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_TIMEVAL: - ptr[i].array = (struct timeval *)malloc(m * sizeof(struct timeval)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_timeval(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_TIME: - ptr[i].array = (time_t*)malloc(m * sizeof(time_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_time(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_STATUS: - ptr[i].array = (pmix_status_t*)malloc(m * sizeof(pmix_status_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_status(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_INFO: - ptr[i].array = (pmix_info_t*)malloc(m * sizeof(pmix_info_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_info(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_PROC: - ptr[i].array = (pmix_proc_t*)malloc(m * sizeof(pmix_proc_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_proc(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_BYTE_OBJECT: - case PMIX_COMPRESSED_STRING: - ptr[i].array = (pmix_byte_object_t*)malloc(m * sizeof(pmix_byte_object_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_bo(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_PERSIST: - ptr[i].array = (pmix_persistence_t*)malloc(m * sizeof(pmix_persistence_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_persist(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_POINTER: - ptr[i].array = (char*)malloc(m * sizeof(char*)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_ptr(buffer, ptr[i].array, &m, PMIX_POINTER))) { - return ret; - } - break; - case PMIX_SCOPE: - ptr[i].array = (pmix_scope_t*)malloc(m * sizeof(pmix_scope_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_scope(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_DATA_RANGE: - ptr[i].array = (pmix_data_range_t*)malloc(m * sizeof(pmix_data_range_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_range(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_PROC_STATE: - ptr[i].array = (pmix_proc_state_t*)malloc(m * sizeof(pmix_proc_state_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_pstate(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_PROC_INFO: - ptr[i].array = (pmix_proc_info_t*)malloc(m * sizeof(pmix_proc_info_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_pinfo(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_QUERY: - ptr[i].array = (pmix_query_t*)malloc(m * sizeof(pmix_query_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_query(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_VALUE: - ptr[i].array = (pmix_value_t*)malloc(m * sizeof(pmix_value_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_value(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - case PMIX_ENVAR: - ptr[i].array = (pmix_envar_t*)malloc(m * sizeof(pmix_envar_t)); - if (NULL == ptr[i].array) { - return PMIX_ERR_NOMEM; - } - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_envar(buffer, ptr[i].array, &m, ptr[i].type))) { - return ret; - } - break; - default: - return PMIX_ERR_NOT_SUPPORTED; + t = ptr[i].type; + + PMIX_DATA_ARRAY_CONSTRUCT(&ptr[i], m, t); + if (NULL == ptr[i].array) { + return PMIX_ERR_NOMEM; + } + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, ptr[i].array, &m, t, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_rank(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_int32(buffer, dest, num_vals, PMIX_UINT32); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_UINT32, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_query(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_query_t *ptr; @@ -1526,7 +1176,8 @@ pmix_status_t pmix_bfrops_base_unpack_query(pmix_buffer_t *buffer, void *dest, PMIX_QUERY_CONSTRUCT(&ptr[i]); /* unpack the number of keys */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_int32(buffer, &nkeys, &m, PMIX_INT32))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &nkeys, &m, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 < nkeys) { @@ -1536,20 +1187,23 @@ pmix_status_t pmix_bfrops_base_unpack_query(pmix_buffer_t *buffer, void *dest, } /* unpack keys */ m=nkeys; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, ptr[i].keys, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, ptr[i].keys, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } /* unpack the number of qualifiers */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &ptr[i].nqual, &m, PMIX_SIZE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].nqual, &m, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 < ptr[i].nqual) { /* unpack the qualifiers */ PMIX_INFO_CREATE(ptr[i].qualifiers, ptr[i].nqual); m = ptr[i].nqual; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_info(buffer, ptr[i].qualifiers, &m, PMIX_INFO))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, ptr[i].qualifiers, &m, PMIX_INFO, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -1557,19 +1211,26 @@ pmix_status_t pmix_bfrops_base_unpack_query(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix_bfrops_base_unpack_alloc_directive(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_alloc_directive(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_UINT8, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_iof_channel(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_iof_channel(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix_bfrops_base_unpack_int16(buffer, dest, num_vals, PMIX_UINT16); + pmix_status_t ret; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_UINT16, regtypes); + return ret; } -pmix_status_t pmix_bfrops_base_unpack_envar(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix_bfrops_base_unpack_envar(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_envar_t *ptr; @@ -1586,19 +1247,142 @@ pmix_status_t pmix_bfrops_base_unpack_envar(pmix_buffer_t *buffer, void *dest, PMIX_ENVAR_CONSTRUCT(&ptr[i]); /* unpack the name */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &ptr[i].envar, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].envar, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack the value */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_string(buffer, &ptr[i].value, &m, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].value, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } /* unpack the separator */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, &ptr[i].separator, &m, PMIX_BYTE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].separator, &m, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } return PMIX_SUCCESS; } + +pmix_status_t pmix_bfrops_base_unpack_coord(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) +{ + pmix_coord_t *ptr; + int32_t i, n, m; + pmix_status_t ret; + + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + "pmix_bfrop_unpack: %d coordinates", *num_vals); + + ptr = (pmix_coord_t *) dest; + n = *num_vals; + + for (i = 0; i < n; ++i) { + /* unpack the x-axis */ + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].x, &m, PMIX_INT, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + /* unpack the y-coord */ + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].y, &m, PMIX_INT, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + /* unpack the z-coord */ + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].z, &m, PMIX_INT, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + } + return PMIX_SUCCESS; +} + +pmix_status_t pmix_bfrops_base_unpack_regattr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) +{ + pmix_regattr_t *ptr; + int32_t i, n, m, nd; + pmix_status_t ret; + char *tmp; + + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + "pmix_bfrop_unpack: %d regattrs", *num_vals); + + ptr = (pmix_regattr_t *) dest; + n = *num_vals; + + for (i = 0; i < n; ++i) { + PMIX_REGATTR_CONSTRUCT(&ptr[i]); + /* unpack the name */ + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].name, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { + return ret; + } + /* unpack the string */ + m=1; + tmp = NULL; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &tmp, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + if (NULL == tmp) { + return PMIX_ERROR; + } + pmix_strncpy(ptr[i].string, tmp, PMIX_MAX_KEYLEN); + free(tmp); + /* unpack the type */ + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].type, &m, PMIX_DATA_TYPE, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + /* unpack the number of info */ + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ptr[i].ninfo, &m, PMIX_SIZE, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + if (0 < ptr[i].ninfo) { + /* unpack the info */ + PMIX_INFO_CREATE(ptr[i].info, ptr[i].ninfo); + m = ptr[i].ninfo; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, ptr[i].info, &m, PMIX_INFO, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + } + /* unpack the description */ + m=1; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &nd, &m, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + if (0 < nd) { + /* unpack the description */ + if (NULL == (ptr[i].description = (char**)calloc(nd+1, sizeof(char*)))) { + return PMIX_ERR_NOMEM; + } + m=nd; + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, ptr[i].description, &m, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); + return ret; + } + } + } + return PMIX_SUCCESS; +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/bfrop_v12.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/bfrop_v12.c index 84e0387cd8..66b971ea82 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/bfrop_v12.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/bfrop_v12.c @@ -14,6 +14,8 @@ * Copyright (c) 201-2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -444,13 +446,15 @@ int pmix12_v2_to_v1_datatype(pmix_data_type_t v2type) return v1type; } -pmix_status_t pmix12_bfrop_store_data_type(pmix_buffer_t *buffer, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_store_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, + pmix_data_type_t type) { int v1type; v1type = pmix12_v2_to_v1_datatype(type); - return pmix12_bfrop_pack_datatype(buffer, &v1type, 1, PMIX_INT); + return pmix12_bfrop_pack_datatype(regtypes, buffer, &v1type, 1, PMIX_INT); } pmix_data_type_t pmix12_v1_to_v2_datatype(int v1type) @@ -491,13 +495,14 @@ pmix_data_type_t pmix12_v1_to_v2_datatype(int v1type) return v2type; } -pmix_status_t pmix12_bfrop_get_data_type(pmix_buffer_t *buffer, pmix_data_type_t *type) +pmix_status_t pmix12_bfrop_get_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t *type) { int32_t n=1; int v1type; pmix_status_t rc; - rc = pmix12_bfrop_unpack_datatype(buffer, &v1type, &n, PMIX_INT); + rc = pmix12_bfrop_unpack_datatype(regtypes, buffer, &v1type, &n, PMIX_INT); if (UINT16_MAX < v1type) { *type = 0; return PMIX_ERR_UNKNOWN_DATA_TYPE; diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/internal.h b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/internal.h index 9c74c85568..f5c41b526f 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/internal.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/internal.h @@ -15,6 +15,8 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -122,175 +124,249 @@ pmix_value_cmp_t pmix12_bfrop_value_cmp(pmix_value_t *p, /* * Specialized functions */ -pmix_status_t pmix12_bfrop_pack_buffer(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_buffer(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, - int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_buffer(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dst, + int32_t *num_vals, pmix_data_type_t type); /* * Internal pack functions */ -pmix_status_t pmix12_bfrop_pack_bool(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_byte(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_string(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_sizet(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_pid(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); - -pmix_status_t pmix12_bfrop_pack_int(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_int16(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_int32(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_datatype(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_int64(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); - -pmix_status_t pmix12_bfrop_pack_float(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_double(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); - -pmix_status_t pmix12_bfrop_pack_timeval(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_value(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_proc(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_app(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_info(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_buf(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_kval(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_persist(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_bo(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_pdata(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -/* compatibility functions - no corresponding PMIx v1.x definitions */ -pmix_status_t pmix12_bfrop_pack_ptr(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_scope(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_status(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_range(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_cmd(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_info_directives(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_proc_state(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_darray(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_proc_info(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_query(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); + +pmix_status_t pmix12_bfrop_pack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); + +pmix_status_t pmix12_bfrop_pack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_pack_rank(pmix_buffer_t *buffer, const void *src, + +pmix_status_t pmix12_bfrop_pack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +/* compatibility functions - no corresponding PMIx v1.x definitions */ +pmix_status_t pmix12_bfrop_pack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_info_directives(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_proc_state(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_proc_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_pack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type); /* * Internal unpack functions */ -pmix_status_t pmix12_bfrop_unpack_bool(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_byte(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_string(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_sizet(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_pid(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - -pmix_status_t pmix12_bfrop_unpack_int(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_int16(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_int32(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_datatype(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_int64(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - -pmix_status_t pmix12_bfrop_unpack_float(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_double(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - -pmix_status_t pmix12_bfrop_unpack_timeval(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_value(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_persist(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_bo(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -/* compatibility functions - no corresponding PMIx v1.x definitions */ -pmix_status_t pmix12_bfrop_unpack_ptr(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_scope(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_range(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_cmd(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_info_directives(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_proc_state(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_darray(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_proc_info(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_query(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + +pmix_status_t pmix12_bfrop_unpack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + +pmix_status_t pmix12_bfrop_unpack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix12_bfrop_unpack_rank(pmix_buffer_t *buffer, void *dest, + +pmix_status_t pmix12_bfrop_unpack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +/* compatibility functions - no corresponding PMIx v1.x definitions */ +pmix_status_t pmix12_bfrop_unpack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_info_directives(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_proc_state(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_proc_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_unpack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); /* @@ -408,9 +484,12 @@ pmix_status_t pmix12_bfrop_print_rank(char **output, char *prefix, /* * Internal helper functions */ -pmix_status_t pmix12_bfrop_store_data_type(pmix_buffer_t *buffer, pmix_data_type_t type); +pmix_status_t pmix12_bfrop_store_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, + pmix_data_type_t type); -pmix_status_t pmix12_bfrop_get_data_type(pmix_buffer_t *buffer, pmix_data_type_t *type); +pmix_status_t pmix12_bfrop_get_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t *type); int pmix12_v2_to_v1_datatype(pmix_data_type_t v2type); diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/pack.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/pack.c index efddd287de..579173e379 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/pack.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/pack.c @@ -11,9 +11,9 @@ * All rights reserved. * Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2016 Mellanox Technologies, Inc. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ @@ -25,8 +25,6 @@ #include -#include - #ifdef HAVE_ARPA_INET_H #include #endif @@ -37,11 +35,12 @@ #include "bfrop_v12.h" #include "internal.h" - pmix_status_t pmix12_bfrop_pack(pmix_buffer_t *buffer, +pmix_status_t pmix12_bfrop_pack(pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_status_t rc; + pmix_pointer_array_t *regtypes = &mca_bfrops_v12_component.types; /* check for error */ if (NULL == buffer) { @@ -50,21 +49,22 @@ /* Pack the number of values */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix12_bfrop_store_data_type(buffer, PMIX_INT32))) { + if (PMIX_SUCCESS != (rc = pmix12_bfrop_store_data_type(regtypes, buffer, PMIX_INT32))) { return rc; } } - if (PMIX_SUCCESS != (rc = pmix12_bfrop_pack_int32(buffer, &num_vals, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (rc = pmix12_bfrop_pack_int32(regtypes, buffer, &num_vals, 1, PMIX_INT32))) { return rc; } /* Pack the value(s) */ - return pmix12_bfrop_pack_buffer(buffer, src, num_vals, type); + return pmix12_bfrop_pack_buffer(regtypes, buffer, src, num_vals, type); } -pmix_status_t pmix12_bfrop_pack_buffer(pmix_buffer_t *buffer, - const void *src, int32_t num_vals, - pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_buffer(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, + const void *src, int32_t num_vals, + pmix_data_type_t type) { pmix_status_t rc; pmix_bfrop_type_info_t *info; @@ -95,7 +95,7 @@ pmix_status_t pmix12_bfrop_pack_buffer(pmix_buffer_t *buffer, /* Pack the declared data type */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix12_bfrop_store_data_type(buffer, v1type))) { + if (PMIX_SUCCESS != (rc = pmix12_bfrop_store_data_type(regtypes, buffer, v1type))) { return rc; } } @@ -111,7 +111,7 @@ pmix_status_t pmix12_bfrop_pack_buffer(pmix_buffer_t *buffer, return PMIX_ERR_PACK_FAILURE; } - return info->odti_pack_fn(buffer, src, num_vals, v1type); + return info->odti_pack_fn(regtypes, buffer, src, num_vals, v1type); } @@ -120,8 +120,9 @@ pmix_status_t pmix12_bfrop_pack_buffer(pmix_buffer_t *buffer, /* * BOOL */ -pmix_status_t pmix12_bfrop_pack_bool(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { uint8_t *dst; int32_t i; @@ -152,54 +153,57 @@ pmix_status_t pmix12_bfrop_pack_bool(pmix_buffer_t *buffer, const void *src, /* * INT */ -pmix_status_t pmix12_bfrop_pack_int(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret; /* System types need to always be described so we can properly unpack them */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_store_data_type(buffer, BFROP_TYPE_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_INT))) { return ret; } /* Turn around and pack the real type */ - return pmix12_bfrop_pack_buffer(buffer, src, num_vals, BFROP_TYPE_INT); + return pmix12_bfrop_pack_buffer(regtypes, buffer, src, num_vals, BFROP_TYPE_INT); } /* * SIZE_T */ -pmix_status_t pmix12_bfrop_pack_sizet(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret; /* System types need to always be described so we can properly unpack them. */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_store_data_type(buffer, BFROP_TYPE_SIZE_T))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_SIZE_T))) { return ret; } - return pmix12_bfrop_pack_buffer(buffer, src, num_vals, BFROP_TYPE_SIZE_T); + return pmix12_bfrop_pack_buffer(regtypes, buffer, src, num_vals, BFROP_TYPE_SIZE_T); } /* * PID_T */ -pmix_status_t pmix12_bfrop_pack_pid(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret; /* System types need to always be described so we can properly unpack them. */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_store_data_type(buffer, BFROP_TYPE_PID_T))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_PID_T))) { return ret; } /* Turn around and pack the real type */ - return pmix12_bfrop_pack_buffer(buffer, src, num_vals, BFROP_TYPE_PID_T); + return pmix12_bfrop_pack_buffer(regtypes, buffer, src, num_vals, BFROP_TYPE_PID_T); } @@ -208,8 +212,9 @@ pmix_status_t pmix12_bfrop_pack_pid(pmix_buffer_t *buffer, const void *src, /* * BYTE, CHAR, INT8 */ -pmix_status_t pmix12_bfrop_pack_byte(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { char *dst; @@ -232,8 +237,9 @@ pmix_status_t pmix12_bfrop_pack_byte(pmix_buffer_t *buffer, const void *src, /* * INT16 */ -pmix_status_t pmix12_bfrop_pack_int16(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int32_t i; uint16_t tmp, *srctmp = (uint16_t*) src; @@ -259,8 +265,9 @@ pmix_status_t pmix12_bfrop_pack_int16(pmix_buffer_t *buffer, const void *src, /* * INT32 */ -pmix_status_t pmix12_bfrop_pack_int32(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int32_t i; uint32_t tmp, *srctmp = (uint32_t*) src; @@ -283,17 +290,19 @@ pmix_status_t pmix12_bfrop_pack_int32(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_datatype(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { - return pmix12_bfrop_pack_int32(buffer, src, num_vals, type); + return pmix12_bfrop_pack_int32(regtypes, buffer, src, num_vals, type); } /* * INT64 */ -pmix_status_t pmix12_bfrop_pack_int64(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int32_t i; uint64_t tmp, tmp2; @@ -321,8 +330,9 @@ pmix_status_t pmix12_bfrop_pack_int64(pmix_buffer_t *buffer, const void *src, /* * STRING */ -pmix_status_t pmix12_bfrop_pack_string(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int ret = PMIX_SUCCESS; int32_t i, len; @@ -331,16 +341,16 @@ pmix_status_t pmix12_bfrop_pack_string(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { if (NULL == ssrc[i]) { /* got zero-length string/NULL pointer - store NULL */ len = 0; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int32(buffer, &len, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int32(regtypes, buffer, &len, 1, PMIX_INT32))) { return ret; } } else { len = (int32_t)strlen(ssrc[i]) + 1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int32(buffer, &len, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int32(regtypes, buffer, &len, 1, PMIX_INT32))) { return ret; } if (PMIX_SUCCESS != (ret = - pmix12_bfrop_pack_byte(buffer, ssrc[i], len, PMIX_BYTE))) { + pmix12_bfrop_pack_byte(regtypes, buffer, ssrc[i], len, PMIX_BYTE))) { return ret; } } @@ -350,8 +360,9 @@ pmix_status_t pmix12_bfrop_pack_string(pmix_buffer_t *buffer, const void *src, } /* FLOAT */ -pmix_status_t pmix12_bfrop_pack_float(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret = PMIX_SUCCESS; int32_t i; @@ -362,7 +373,7 @@ pmix_status_t pmix12_bfrop_pack_float(pmix_buffer_t *buffer, const void *src, if (0 > asprintf(&convert, "%f", ssrc[i])) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &convert, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &convert, 1, PMIX_STRING))) { free(convert); return ret; } @@ -373,8 +384,9 @@ pmix_status_t pmix12_bfrop_pack_float(pmix_buffer_t *buffer, const void *src, } /* DOUBLE */ -pmix_status_t pmix12_bfrop_pack_double(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret = PMIX_SUCCESS; int32_t i; @@ -385,7 +397,7 @@ pmix_status_t pmix12_bfrop_pack_double(pmix_buffer_t *buffer, const void *src, if (0 > asprintf(&convert, "%f", ssrc[i])) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &convert, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &convert, 1, PMIX_STRING))) { free(convert); return ret; } @@ -396,8 +408,9 @@ pmix_status_t pmix12_bfrop_pack_double(pmix_buffer_t *buffer, const void *src, } /* TIMEVAL */ -pmix_status_t pmix12_bfrop_pack_timeval(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int64_t tmp[2]; pmix_status_t ret = PMIX_SUCCESS; @@ -407,7 +420,7 @@ pmix_status_t pmix12_bfrop_pack_timeval(pmix_buffer_t *buffer, const void *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 (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int64(buffer, tmp, 2, PMIX_INT64))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int64(regtypes, buffer, tmp, 2, PMIX_INT64))) { return ret; } } @@ -416,8 +429,9 @@ pmix_status_t pmix12_bfrop_pack_timeval(pmix_buffer_t *buffer, const void *src, } /* TIME */ -pmix_status_t pmix12_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret = PMIX_SUCCESS; int32_t i; @@ -429,7 +443,7 @@ pmix_status_t pmix12_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, */ for (i = 0; i < num_vals; ++i) { ui64 = (uint64_t)ssrc[i]; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int64(buffer, &ui64, 1, PMIX_UINT64))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int64(regtypes, buffer, &ui64, 1, PMIX_UINT64))) { return ret; } } @@ -439,7 +453,8 @@ pmix_status_t pmix12_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, /* PACK FUNCTIONS FOR GENERIC PMIX TYPES */ -static pmix_status_t pack_val(pmix_buffer_t *buffer, +static pmix_status_t pack_val(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_value_t *p) { pmix_status_t ret; @@ -448,97 +463,97 @@ static pmix_status_t pack_val(pmix_buffer_t *buffer, switch (p->type) { case PMIX_BOOL: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.flag, 1, PMIX_BOOL))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.flag, 1, PMIX_BOOL))) { return ret; } break; case PMIX_BYTE: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.byte, 1, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.byte, 1, PMIX_BYTE))) { return ret; } break; case PMIX_STRING: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.string, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.string, 1, PMIX_STRING))) { return ret; } break; case PMIX_SIZE: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.size, 1, PMIX_SIZE))) { return ret; } break; case PMIX_PID: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.pid, 1, PMIX_PID))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.pid, 1, PMIX_PID))) { return ret; } break; case PMIX_INT: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.integer, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.integer, 1, PMIX_INT))) { return ret; } break; case PMIX_INT8: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.int8, 1, PMIX_INT8))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.int8, 1, PMIX_INT8))) { return ret; } break; case PMIX_INT16: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.int16, 1, PMIX_INT16))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.int16, 1, PMIX_INT16))) { return ret; } break; case PMIX_INT32: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.int32, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.int32, 1, PMIX_INT32))) { return ret; } break; case PMIX_INT64: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.int64, 1, PMIX_INT64))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.int64, 1, PMIX_INT64))) { return ret; } break; case PMIX_UINT: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.uint, 1, PMIX_UINT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.uint, 1, PMIX_UINT))) { return ret; } break; case PMIX_UINT8: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.uint8, 1, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.uint8, 1, PMIX_UINT8))) { return ret; } break; case PMIX_UINT16: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.uint16, 1, PMIX_UINT16))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.uint16, 1, PMIX_UINT16))) { return ret; } break; case PMIX_UINT32: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.uint32, 1, PMIX_UINT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.uint32, 1, PMIX_UINT32))) { return ret; } break; case PMIX_UINT64: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.uint64, 1, PMIX_UINT64))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.uint64, 1, PMIX_UINT64))) { return ret; } break; case PMIX_FLOAT: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.fval, 1, PMIX_FLOAT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.fval, 1, PMIX_FLOAT))) { return ret; } break; case PMIX_DOUBLE: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.dval, 1, PMIX_DOUBLE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.dval, 1, PMIX_DOUBLE))) { return ret; } break; case PMIX_TIMEVAL: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.tv, 1, PMIX_TIMEVAL))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.tv, 1, PMIX_TIMEVAL))) { return ret; } break; case PMIX_BYTE_OBJECT: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &p->data.bo, 1, PMIX_BYTE_OBJECT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &p->data.bo, 1, PMIX_BYTE_OBJECT))) { return ret; } break; @@ -549,7 +564,7 @@ static pmix_status_t pack_val(pmix_buffer_t *buffer, } array.size = p->data.darray->size; array.array = (pmix_info_t*)p->data.darray->array; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &array, 1, PMIX_INFO_ARRAY))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &array, 1, PMIX_INFO_ARRAY))) { return ret; } break; @@ -557,7 +572,7 @@ static pmix_status_t pack_val(pmix_buffer_t *buffer, case PMIX_PROC_RANK: /* must convert this to an int */ rank = p->data.rank; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(buffer, &rank, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_buffer(regtypes, buffer, &rank, 1, PMIX_INT))) { return ret; } break; @@ -572,8 +587,9 @@ static pmix_status_t pack_val(pmix_buffer_t *buffer, /* * PMIX_VALUE */ -pmix_status_t pmix12_bfrop_pack_value(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_value_t *ptr; int32_t i; @@ -587,11 +603,11 @@ pmix_status_t pmix12_bfrop_pack_value(pmix_buffer_t *buffer, const void *src, * using the store_data_type function. This means we lose the translation! * So get it here */ v1type = pmix12_v2_to_v1_datatype(ptr[i].type); - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(buffer, &v1type, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(regtypes, buffer, &v1type, 1, PMIX_INT))) { return ret; } /* now pack the right field */ - if (PMIX_SUCCESS != (ret = pack_val(buffer, &ptr[i]))) { + if (PMIX_SUCCESS != (ret = pack_val(regtypes, buffer, &ptr[i]))) { return ret; } } @@ -600,8 +616,9 @@ pmix_status_t pmix12_bfrop_pack_value(pmix_buffer_t *buffer, const void *src, } -pmix_status_t pmix12_bfrop_pack_info(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_info_t *info; int32_t i; @@ -614,26 +631,27 @@ pmix_status_t pmix12_bfrop_pack_info(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack key */ foo = info[i].key; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &foo, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &foo, 1, PMIX_STRING))) { return ret; } /* pack the type - unfortunately, v1.2 directly packed the int instead of * using the store_data_type function. This means we lose the translation! * So get it here */ v1type = pmix12_v2_to_v1_datatype(info[i].value.type); - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(buffer, &v1type, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(regtypes, buffer, &v1type, 1, PMIX_INT))) { return ret; } /* pack value */ - if (PMIX_SUCCESS != (ret = pack_val(buffer, &info[i].value))) { + if (PMIX_SUCCESS != (ret = pack_val(regtypes, buffer, &info[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_pdata(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_pdata_t *pdata; int32_t i; @@ -645,31 +663,32 @@ pmix_status_t pmix12_bfrop_pack_pdata(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the proc */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_proc(buffer, &pdata[i].proc, 1, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_proc(regtypes, buffer, &pdata[i].proc, 1, PMIX_PROC))) { return ret; } /* pack key */ foo = pdata[i].key; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &foo, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &foo, 1, PMIX_STRING))) { return ret; } /* pack the type - unfortunately, v1.2 directly packed the int instead of * using the store_data_type function. This means we lose the translation! * So get it here */ v1type = pmix12_v2_to_v1_datatype(pdata[i].value.type); - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(buffer, &v1type, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(regtypes, buffer, &v1type, 1, PMIX_INT))) { return ret; } /* pack value */ - if (PMIX_SUCCESS != (ret = pack_val(buffer, &pdata[i].value))) { + if (PMIX_SUCCESS != (ret = pack_val(regtypes, buffer, &pdata[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_buf(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_buffer_t *ptr; int32_t i; @@ -679,12 +698,12 @@ pmix_status_t pmix12_bfrop_pack_buf(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the number of bytes */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(buffer, &ptr[i].bytes_used, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(regtypes, buffer, &ptr[i].bytes_used, 1, PMIX_SIZE))) { return ret; } /* pack the bytes */ if (0 < ptr[i].bytes_used) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_byte(buffer, ptr[i].base_ptr, ptr[i].bytes_used, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_byte(regtypes, buffer, ptr[i].base_ptr, ptr[i].bytes_used, PMIX_BYTE))) { return ret; } } @@ -692,8 +711,9 @@ pmix_status_t pmix12_bfrop_pack_buf(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_proc(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_proc_t *proc; int32_t i; @@ -703,18 +723,19 @@ pmix_status_t pmix12_bfrop_pack_proc(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { char *ptr = proc[i].nspace; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &ptr, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &ptr, 1, PMIX_STRING))) { return ret; } - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(buffer, &proc[i].rank, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(regtypes, buffer, &proc[i].rank, 1, PMIX_INT))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_app(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_app_t *app; int32_t i, j, nvals; @@ -724,39 +745,39 @@ pmix_status_t pmix12_bfrop_pack_app(pmix_buffer_t *buffer, const void *src, app = (pmix_app_t *) src; for (i = 0; i < num_vals; ++i) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &app[i].cmd, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &app[i].cmd, 1, PMIX_STRING))) { return ret; } /* argv */ argc = pmix_argv_count(app[i].argv); - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(buffer, &argc, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(regtypes, buffer, &argc, 1, PMIX_INT))) { return ret; } for (j=0; j < argc; j++) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &app[i].argv[j], 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &app[i].argv[j], 1, PMIX_STRING))) { return ret; } } /* env */ nvals = pmix_argv_count(app[i].env); - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int32(buffer, &nvals, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int32(regtypes, buffer, &nvals, 1, PMIX_INT32))) { return ret; } for (j=0; j < nvals; j++) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &app[i].env[j], 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &app[i].env[j], 1, PMIX_STRING))) { return ret; } } /* maxprocs */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(buffer, &app[i].maxprocs, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_int(regtypes, buffer, &app[i].maxprocs, 1, PMIX_INT))) { return ret; } /* info array */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(buffer, &app[i].ninfo, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(regtypes, buffer, &app[i].ninfo, 1, PMIX_SIZE))) { return ret; } if (0 < app[i].ninfo) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_info(buffer, app[i].info, app[i].ninfo, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_info(regtypes, buffer, app[i].info, app[i].ninfo, PMIX_INFO))) { return ret; } } @@ -765,8 +786,9 @@ pmix_status_t pmix12_bfrop_pack_app(pmix_buffer_t *buffer, const void *src, } -pmix_status_t pmix12_bfrop_pack_kval(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_kval_t *ptr; int32_t i; @@ -776,11 +798,11 @@ pmix_status_t pmix12_bfrop_pack_kval(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the key */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(buffer, &ptr[i].key, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_string(regtypes, buffer, &ptr[i].key, 1, PMIX_STRING))) { return ret; } /* pack the value */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_value(buffer, ptr[i].value, 1, ptr[i].value->type))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_value(regtypes, buffer, ptr[i].value, 1, ptr[i].value->type))) { return ret; } } @@ -788,8 +810,9 @@ pmix_status_t pmix12_bfrop_pack_kval(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_info_array_t *ptr; int32_t i; @@ -799,12 +822,12 @@ pmix_status_t pmix12_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the size */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(buffer, &ptr[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { /* pack the values */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_info(buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_info(regtypes, buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) { return ret; } } @@ -813,8 +836,9 @@ pmix_status_t pmix12_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_modex_data_t *ptr; int32_t i; @@ -823,11 +847,11 @@ pmix_status_t pmix12_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, ptr = (pmix_modex_data_t *) src; for (i = 0; i < num_vals; ++i) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(buffer, &ptr[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) { return ret; } if( 0 < ptr[i].size){ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_byte(buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_byte(regtypes, buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) { return ret; } } @@ -835,14 +859,16 @@ pmix_status_t pmix12_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_persist(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { - return pmix12_bfrop_pack_int(buffer, src, num_vals, PMIX_INT); + return pmix12_bfrop_pack_int(regtypes, buffer, src, num_vals, PMIX_INT); } -pmix_status_t pmix12_bfrop_pack_bo(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret; int i; @@ -850,11 +876,11 @@ pmix_status_t pmix12_bfrop_pack_bo(pmix_buffer_t *buffer, const void *src, bo = (pmix_byte_object_t*)src; for (i=0; i < num_vals; i++) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(buffer, &bo[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_sizet(regtypes, buffer, &bo[i].size, 1, PMIX_SIZE))) { return ret; } if (0 < bo[i].size) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_byte(buffer, bo[i].bytes, bo[i].size, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_pack_byte(regtypes, buffer, bo[i].bytes, bo[i].size, PMIX_BYTE))) { return ret; } } @@ -862,15 +888,17 @@ pmix_status_t pmix12_bfrop_pack_bo(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_ptr(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { /* v1.x has no concept of packing a pointer, so just return */ return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_scope(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_scope_t *scope = (pmix_scope_t*)src; unsigned int *v1scope; @@ -885,21 +913,23 @@ pmix_status_t pmix12_bfrop_pack_scope(pmix_buffer_t *buffer, const void *src, for (i=0; i < num_vals; i++) { v1scope[i] = (unsigned int)scope[i]; } - ret = pmix12_bfrop_pack_int(buffer, (void*)v1scope, num_vals, PMIX_UINT); + ret = pmix12_bfrop_pack_int(regtypes, buffer, (void*)v1scope, num_vals, PMIX_UINT); free(v1scope); return ret; } -pmix_status_t pmix12_bfrop_pack_status(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { /* v1.2 declares pmix_status_t as an enum, which translates to int and * matches that of v2 */ - return pmix12_bfrop_pack_int(buffer, src, num_vals, PMIX_INT); + return pmix12_bfrop_pack_int(regtypes, buffer, src, num_vals, PMIX_INT); } -pmix_status_t pmix12_bfrop_pack_range(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_data_range_t *range = (pmix_data_range_t*)src; unsigned int *v1range; @@ -914,13 +944,14 @@ pmix_status_t pmix12_bfrop_pack_range(pmix_buffer_t *buffer, const void *src, for (i=0; i < num_vals; i++) { v1range[i] = (unsigned int)range[i]; } - ret = pmix12_bfrop_pack_int(buffer, (void*)v1range, num_vals, PMIX_UINT); + ret = pmix12_bfrop_pack_int(regtypes, buffer, (void*)v1range, num_vals, PMIX_UINT); free(v1range); return ret; } -pmix_status_t pmix12_bfrop_pack_cmd(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_cmd_t *cmd = (pmix_cmd_t*)src; int *v1cmd; @@ -935,48 +966,54 @@ pmix_status_t pmix12_bfrop_pack_cmd(pmix_buffer_t *buffer, const void *src, for (i=0; i < num_vals; i++) { v1cmd[i] = cmd[i]; } - ret = pmix12_bfrop_pack_int(buffer, (void*)v1cmd, num_vals, PMIX_INT); + ret = pmix12_bfrop_pack_int(regtypes, buffer, (void*)v1cmd, num_vals, PMIX_INT); free(v1cmd); return ret; } -pmix_status_t pmix12_bfrop_pack_info_directives(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_info_directives(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { /* v1.x has no concept of an info directive, so just return */ return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_proc_state(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_pack_proc_state(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { /* v1.x has no concept of proc state, so just return */ return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_pack_darray(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) +{ + return PMIX_ERR_NOT_SUPPORTED; +} + +pmix_status_t pmix12_bfrop_pack_proc_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) +{ + return PMIX_ERR_NOT_SUPPORTED; + +} + +pmix_status_t pmix12_bfrop_pack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } -pmix_status_t pmix12_bfrop_pack_proc_info(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) -{ - return PMIX_ERR_NOT_SUPPORTED; - -} - -pmix_status_t pmix12_bfrop_pack_query(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix12_bfrop_pack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) -{ - return PMIX_ERR_NOT_SUPPORTED; -} - -pmix_status_t pmix12_bfrop_pack_rank(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) { /* v1 rank is just an int, not a separate data type - it is defined * to be an unint32 in v2 */ - return pmix12_bfrop_pack_int(buffer, src, num_vals, PMIX_INT); + return pmix12_bfrop_pack_int(regtypes, buffer, src, num_vals, PMIX_INT); } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/unpack.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/unpack.c index a001728ef0..60b4892f89 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/unpack.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v12/unpack.c @@ -11,9 +11,9 @@ * All rights reserved. * Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved. * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2016 Mellanox Technologies, Inc. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ @@ -25,8 +25,6 @@ #include -#include - #include "src/util/argv.h" #include "src/util/error.h" #include "src/util/output.h" @@ -34,42 +32,14 @@ #include "bfrop_v12.h" #include "internal.h" -static pmix_status_t unpack_gentype(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) -{ - switch(type) { - case PMIX_INT8: - case PMIX_UINT8: - return pmix12_bfrop_unpack_byte(buffer, dest, num_vals, type); - break; - - case PMIX_INT16: - case PMIX_UINT16: - return pmix12_bfrop_unpack_int16(buffer, dest, num_vals, type); - break; - - case PMIX_INT32: - case PMIX_UINT32: - return pmix12_bfrop_unpack_int32(buffer, dest, num_vals, type); - break; - - case PMIX_INT64: - case PMIX_UINT64: - return pmix12_bfrop_unpack_int64(buffer, dest, num_vals, type); - break; - - default: - return PMIX_ERR_UNKNOWN_DATA_TYPE; - } -} - pmix_status_t pmix12_bfrop_unpack(pmix_buffer_t *buffer, - void *dst, int32_t *num_vals, - pmix_data_type_t type) + void *dst, int32_t *num_vals, + pmix_data_type_t type) { pmix_status_t rc, ret; int32_t local_num, n=1; pmix_data_type_t local_type; + pmix_pointer_array_t *regtypes = &mca_bfrops_v12_component.types; pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack: for type %d", (int)type); @@ -101,7 +71,7 @@ pmix_status_t pmix12_bfrop_unpack(pmix_buffer_t *buffer, * int32_t as used here. */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix12_bfrop_get_data_type(buffer, &local_type))) { + if (PMIX_SUCCESS != (rc = pmix12_bfrop_get_data_type(regtypes, buffer, &local_type))) { *num_vals = 0; /* don't error log here as the user may be unpacking past * the end of the buffer, which isn't necessarily an error */ @@ -115,7 +85,7 @@ pmix_status_t pmix12_bfrop_unpack(pmix_buffer_t *buffer, } n=1; - if (PMIX_SUCCESS != (rc = pmix12_bfrop_unpack_int32(buffer, &local_num, &n, PMIX_INT32))) { + if (PMIX_SUCCESS != (rc = pmix12_bfrop_unpack_int32(regtypes, buffer, &local_num, &n, PMIX_INT32))) { *num_vals = 0; /* don't error log here as the user may be unpacking past * the end of the buffer, which isn't necessarily an error */ @@ -134,8 +104,9 @@ pmix_status_t pmix12_bfrop_unpack(pmix_buffer_t *buffer, */ if (local_num > *num_vals) { local_num = *num_vals; - pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack: inadequate space ( %p, %p, %lu, %d )\n", - (void*)buffer, dst, (long unsigned int)*num_vals, (int)type); + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + "pmix12_bfrop_unpack: inadequate space ( %p, %p, %lu, %d )\n", + (void*)buffer, dst, (long unsigned int)*num_vals, (int)type); ret = PMIX_ERR_UNPACK_INADEQUATE_SPACE; } else { /** enough or more than enough storage */ *num_vals = local_num; /** let the user know how many we actually unpacked */ @@ -143,7 +114,7 @@ pmix_status_t pmix12_bfrop_unpack(pmix_buffer_t *buffer, } /** Unpack the value(s) */ - if (PMIX_SUCCESS != (rc = pmix12_bfrop_unpack_buffer(buffer, dst, &local_num, type))) { + if (PMIX_SUCCESS != (rc = pmix12_bfrop_unpack_buffer(regtypes, buffer, dst, &local_num, type))) { PMIX_ERROR_LOG(rc); *num_vals = 0; ret = rc; @@ -152,12 +123,12 @@ pmix_status_t pmix12_bfrop_unpack(pmix_buffer_t *buffer, return ret; } -pmix_status_t pmix12_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, int32_t *num_vals, - pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_buffer(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dst, int32_t *num_vals, + pmix_data_type_t type) { pmix_status_t rc; pmix_data_type_t local_type, v1type; - pmix_bfrop_type_info_t *info; pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack_buffer( %p, %p, %lu, %d )\n", (void*)buffer, dst, (long unsigned int)*num_vals, (int)type); @@ -182,7 +153,7 @@ pmix_status_t pmix12_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, int32 /** Unpack the declared data type */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix12_bfrop_get_data_type(buffer, &local_type))) { + if (PMIX_SUCCESS != (rc = pmix12_bfrop_get_data_type(regtypes, buffer, &local_type))) { PMIX_ERROR_LOG(rc); return rc; } @@ -193,18 +164,8 @@ pmix_status_t pmix12_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, int32 return PMIX_ERR_PACK_MISMATCH; } } + PMIX_BFROPS_UNPACK_TYPE(rc, buffer, dst, num_vals, v1type, regtypes); - /* Lookup the unpack function for this type and call it */ - - if (NULL == (info = (pmix_bfrop_type_info_t*)pmix_pointer_array_get_item(&mca_bfrops_v12_component.types, v1type))) { - PMIX_ERROR_LOG(PMIX_ERR_UNPACK_FAILURE); - return PMIX_ERR_UNPACK_FAILURE; - } - - rc = info->odti_unpack_fn(buffer, dst, num_vals, v1type); - if (PMIX_SUCCESS != rc) { - PMIX_ERROR_LOG(rc); - } return rc; } @@ -214,8 +175,9 @@ pmix_status_t pmix12_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, int32 /* * BOOL */ -pmix_status_t pmix12_bfrop_unpack_bool(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i; uint8_t *src; @@ -248,24 +210,25 @@ pmix_status_t pmix12_bfrop_unpack_bool(pmix_buffer_t *buffer, void *dest, /* * INT */ -pmix_status_t pmix12_bfrop_unpack_int(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_get_data_type(regtypes, buffer, &remote_type))) { return ret; } if (remote_type == BFROP_TYPE_INT) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, dest, num_vals, BFROP_TYPE_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, dest, num_vals, BFROP_TYPE_INT))) { } } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(int, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, int, remote_type, ret); } return ret; @@ -274,24 +237,25 @@ pmix_status_t pmix12_bfrop_unpack_int(pmix_buffer_t *buffer, void *dest, /* * SIZE_T */ -pmix_status_t pmix12_bfrop_unpack_sizet(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_get_data_type(regtypes, buffer, &remote_type))) { return ret; } if (remote_type == BFROP_TYPE_SIZE_T) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, dest, num_vals, BFROP_TYPE_SIZE_T))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, dest, num_vals, BFROP_TYPE_SIZE_T))) { } } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(size_t, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, size_t, remote_type, ret); } return ret; @@ -300,24 +264,25 @@ pmix_status_t pmix12_bfrop_unpack_sizet(pmix_buffer_t *buffer, void *dest, /* * PID_T */ -pmix_status_t pmix12_bfrop_unpack_pid(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_get_data_type(regtypes, buffer, &remote_type))) { return ret; } if (remote_type == BFROP_TYPE_PID_T) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, dest, num_vals, BFROP_TYPE_PID_T))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, dest, num_vals, BFROP_TYPE_PID_T))) { } } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(pid_t, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, pid_t, remote_type, ret); } return ret; @@ -329,8 +294,9 @@ pmix_status_t pmix12_bfrop_unpack_pid(pmix_buffer_t *buffer, void *dest, /* * BYTE, CHAR, INT8 */ -pmix_status_t pmix12_bfrop_unpack_byte(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack_byte * %d\n", (int)*num_vals); /* check to see if there's enough data in buffer */ @@ -347,8 +313,9 @@ pmix_status_t pmix12_bfrop_unpack_byte(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_int16(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i; uint16_t tmp, *desttmp = (uint16_t*) dest; @@ -370,8 +337,9 @@ pmix_status_t pmix12_bfrop_unpack_int16(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_int32(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i; uint32_t tmp, *desttmp = (uint32_t*) dest; @@ -393,19 +361,22 @@ pmix_status_t pmix12_bfrop_unpack_int32(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_datatype(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { - return pmix12_bfrop_unpack_int32(buffer, dest, num_vals, type); + return pmix12_bfrop_unpack_int32(regtypes, buffer, dest, num_vals, type); } -pmix_status_t pmix12_bfrop_unpack_int64(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i; uint64_t tmp, *desttmp = (uint64_t*) dest; - pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack_int64 * %d\n", (int)*num_vals); + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + "pmix12_bfrop_unpack_int64 * %d\n", (int)*num_vals); /* check to see if there's enough data in buffer */ if (pmix_bfrop_too_small(buffer, (*num_vals)*sizeof(tmp))) { return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; @@ -422,15 +393,17 @@ pmix_status_t pmix12_bfrop_unpack_int64(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_string(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; int32_t i, len, n=1; char **sdest = (char**) dest; for (i = 0; i < (*num_vals); ++i) { - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int32(buffer, &len, &n, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int32(regtypes, buffer, + &len, &n, PMIX_INT32))) { return ret; } if (0 == len) { /* zero-length string - unpack the NULL */ @@ -440,7 +413,9 @@ pmix_status_t pmix12_bfrop_unpack_string(pmix_buffer_t *buffer, void *dest, if (NULL == sdest[i]) { return PMIX_ERR_OUT_OF_RESOURCE; } - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_byte(buffer, sdest[i], &len, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_byte(regtypes, buffer, + sdest[i], &len, + PMIX_BYTE))) { return ret; } } @@ -449,15 +424,17 @@ pmix_status_t pmix12_bfrop_unpack_string(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_float(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; float *desttmp = (float*) dest, tmp; pmix_status_t ret; char *convert; - pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack_float * %d\n", (int)*num_vals); + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + "pmix12_bfrop_unpack_float * %d\n", (int)*num_vals); /* check to see if there's enough data in buffer */ if (pmix_bfrop_too_small(buffer, (*num_vals)*sizeof(float))) { return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; @@ -467,7 +444,8 @@ pmix_status_t pmix12_bfrop_unpack_float(pmix_buffer_t *buffer, void *dest, for (i = 0; i < (*num_vals); ++i) { n=1; convert = NULL; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &convert, &n, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, + &convert, &n, PMIX_STRING))) { return ret; } if (NULL != convert) { @@ -479,15 +457,17 @@ pmix_status_t pmix12_bfrop_unpack_float(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_double(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; double *desttmp = (double*) dest, tmp; pmix_status_t ret; char *convert; - pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack_double * %d\n", (int)*num_vals); + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + "pmix12_bfrop_unpack_double * %d\n", (int)*num_vals); /* check to see if there's enough data in buffer */ if (pmix_bfrop_too_small(buffer, (*num_vals)*sizeof(double))) { return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; @@ -497,7 +477,9 @@ pmix_status_t pmix12_bfrop_unpack_double(pmix_buffer_t *buffer, void *dest, for (i = 0; i < (*num_vals); ++i) { n=1; convert = NULL; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &convert, &n, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, + &convert, &n, + PMIX_STRING))) { return ret; } if (NULL != convert) { @@ -509,15 +491,17 @@ pmix_status_t pmix12_bfrop_unpack_double(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_timeval(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; int64_t tmp[2]; struct timeval *desttmp = (struct timeval *) dest, tt; pmix_status_t ret; - pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack_timeval * %d\n", (int)*num_vals); + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + "pmix12_bfrop_unpack_timeval * %d\n", (int)*num_vals); /* check to see if there's enough data in buffer */ if (pmix_bfrop_too_small(buffer, (*num_vals)*sizeof(struct timeval))) { return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; @@ -526,7 +510,8 @@ pmix_status_t pmix12_bfrop_unpack_timeval(pmix_buffer_t *buffer, void *dest, /* unpack the data */ for (i = 0; i < (*num_vals); ++i) { n=2; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int64(buffer, tmp, &n, PMIX_INT64))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int64(regtypes, buffer, + tmp, &n, PMIX_INT64))) { return ret; } tt.tv_sec = tmp[0]; @@ -536,8 +521,9 @@ pmix_status_t pmix12_bfrop_unpack_timeval(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; time_t *desttmp = (time_t *) dest, tmp; @@ -548,7 +534,8 @@ pmix_status_t pmix12_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, * to uint64_t as a generic safe size */ - pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack_time * %d\n", (int)*num_vals); + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + "pmix12_bfrop_unpack_time * %d\n", (int)*num_vals); /* check to see if there's enough data in buffer */ if (pmix_bfrop_too_small(buffer, (*num_vals)*(sizeof(uint64_t)))) { return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; @@ -557,7 +544,8 @@ pmix_status_t pmix12_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, /* unpack the data */ for (i = 0; i < (*num_vals); ++i) { n=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int64(buffer, &ui64, &n, PMIX_UINT64))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int64(regtypes, buffer, + &ui64, &n, PMIX_UINT64))) { return ret; } tmp = (time_t)ui64; @@ -572,7 +560,8 @@ pmix_status_t pmix12_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, /* * PMIX_VALUE */ -static pmix_status_t unpack_val(pmix_buffer_t *buffer, pmix_value_t *val) +static pmix_status_t unpack_val(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_value_t *val) { int32_t m; pmix_status_t ret; @@ -580,92 +569,92 @@ static pmix_status_t unpack_val(pmix_buffer_t *buffer, pmix_value_t *val) m = 1; switch (val->type) { case PMIX_BOOL: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.flag, &m, PMIX_BOOL))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.flag, &m, PMIX_BOOL))) { return ret; } break; case PMIX_BYTE: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.byte, &m, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.byte, &m, PMIX_BYTE))) { return ret; } break; case PMIX_STRING: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.string, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.string, &m, PMIX_STRING))) { return ret; } break; case PMIX_SIZE: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.size, &m, PMIX_SIZE))) { return ret; } break; case PMIX_PID: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.pid, &m, PMIX_PID))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.pid, &m, PMIX_PID))) { return ret; } break; case PMIX_INT: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.integer, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.integer, &m, PMIX_INT))) { return ret; } break; case PMIX_INT8: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.int8, &m, PMIX_INT8))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.int8, &m, PMIX_INT8))) { return ret; } break; case PMIX_INT16: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.int16, &m, PMIX_INT16))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.int16, &m, PMIX_INT16))) { return ret; } break; case PMIX_INT32: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.int32, &m, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.int32, &m, PMIX_INT32))) { return ret; } break; case PMIX_INT64: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.int64, &m, PMIX_INT64))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.int64, &m, PMIX_INT64))) { return ret; } break; case PMIX_UINT: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.uint, &m, PMIX_UINT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint, &m, PMIX_UINT))) { return ret; } break; case PMIX_UINT8: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.uint8, &m, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint8, &m, PMIX_UINT8))) { return ret; } break; case PMIX_UINT16: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.uint16, &m, PMIX_UINT16))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint16, &m, PMIX_UINT16))) { return ret; } break; case PMIX_UINT32: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.uint32, &m, PMIX_UINT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint32, &m, PMIX_UINT32))) { return ret; } break; case PMIX_UINT64: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.uint64, &m, PMIX_UINT64))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint64, &m, PMIX_UINT64))) { return ret; } break; case PMIX_FLOAT: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.fval, &m, PMIX_FLOAT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.fval, &m, PMIX_FLOAT))) { return ret; } break; case PMIX_DOUBLE: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.dval, &m, PMIX_DOUBLE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.dval, &m, PMIX_DOUBLE))) { return ret; } break; case PMIX_TIMEVAL: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.tv, &m, PMIX_TIMEVAL))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.tv, &m, PMIX_TIMEVAL))) { return ret; } break; @@ -676,12 +665,12 @@ static pmix_status_t unpack_val(pmix_buffer_t *buffer, pmix_value_t *val) val->data.darray->type = PMIX_INFO_ARRAY; val->data.darray->size = m; /* unpack into it */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.darray->array, &m, PMIX_INFO_ARRAY))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.darray->array, &m, PMIX_INFO_ARRAY))) { return ret; } break; case PMIX_BYTE_OBJECT: - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(buffer, &val->data.bo, &m, PMIX_BYTE_OBJECT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_buffer(regtypes, buffer, &val->data.bo, &m, PMIX_BYTE_OBJECT))) { return ret; } break; @@ -693,8 +682,9 @@ static pmix_status_t unpack_val(pmix_buffer_t *buffer, pmix_value_t *val) return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_value(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_value_t *ptr; int32_t i, m, n; @@ -707,7 +697,7 @@ pmix_status_t pmix12_bfrop_unpack_value(pmix_buffer_t *buffer, void *dest, for (i = 0; i < n; ++i) { /* unpack the type */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(buffer, &v1type, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(regtypes, buffer, &v1type, &m, PMIX_INT))) { return ret; } /* convert the type - unfortunately, v1.2 directly packed the int instead of @@ -715,15 +705,16 @@ pmix_status_t pmix12_bfrop_unpack_value(pmix_buffer_t *buffer, void *dest, * So get it here */ ptr[i].type = pmix12_v1_to_v2_datatype(v1type); /* unpack value */ - if (PMIX_SUCCESS != (ret = unpack_val(buffer, &ptr[i])) ) { + if (PMIX_SUCCESS != (ret = unpack_val(regtypes, buffer, &ptr[i])) ) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_info_t *ptr; int32_t i, n, m; @@ -743,7 +734,7 @@ pmix_status_t pmix12_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, /* unpack key */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -755,7 +746,7 @@ pmix_status_t pmix12_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, * instead of a pointer in this struct, we directly unpack it to * avoid the malloc */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(buffer, &v1type, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(regtypes, buffer, &v1type, &m, PMIX_INT))) { return ret; } /* convert the type - unfortunately, v1.2 directly packed the int instead of @@ -765,15 +756,16 @@ pmix_status_t pmix12_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack: info type %d", ptr[i].value.type); m=1; - if (PMIX_SUCCESS != (ret = unpack_val(buffer, &ptr[i].value))) { + if (PMIX_SUCCESS != (ret = unpack_val(regtypes, buffer, &ptr[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_pdata_t *ptr; int32_t i, n, m; @@ -791,13 +783,13 @@ pmix_status_t pmix12_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, PMIX_PDATA_CONSTRUCT(&ptr[i]); /* unpack the proc */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_proc(buffer, &ptr[i].proc, &m, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_proc(regtypes, buffer, &ptr[i].proc, &m, PMIX_PROC))) { return ret; } /* unpack key */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -809,7 +801,7 @@ pmix_status_t pmix12_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, * instead of a pointer in this struct, we directly unpack it to * avoid the malloc */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(buffer, &v1type, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(regtypes, buffer, &v1type, &m, PMIX_INT))) { return ret; } /* convert the type - unfortunately, v1.2 directly packed the int instead of @@ -819,15 +811,16 @@ pmix_status_t pmix12_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix12_bfrop_unpack: pdata type %d", ptr[i].value.type); m=1; - if (PMIX_SUCCESS != (ret = unpack_val(buffer, &ptr[i].value))) { + if (PMIX_SUCCESS != (ret = unpack_val(regtypes, buffer, &ptr[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_buffer_t *ptr; int32_t i, n, m; @@ -840,7 +833,7 @@ pmix_status_t pmix12_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, for (i = 0; i < n; ++i) { /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(buffer, &nbytes, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(regtypes, buffer, &nbytes, &m, PMIX_SIZE))) { return ret; } m = nbytes; @@ -848,7 +841,7 @@ pmix_status_t pmix12_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, if (0 < nbytes) { ptr[i].base_ptr = (char*)malloc(nbytes); /* unpack the bytes */ - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_byte(buffer, ptr[i].base_ptr, &m, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_byte(regtypes, buffer, ptr[i].base_ptr, &m, PMIX_BYTE))) { return ret; } } @@ -860,8 +853,9 @@ pmix_status_t pmix12_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_proc_t *ptr; int32_t i, n, m; @@ -881,7 +875,7 @@ pmix_status_t pmix12_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, /* unpack nspace */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -891,7 +885,7 @@ pmix_status_t pmix12_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, free(tmp); /* unpack the rank */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(buffer, &ptr[i].rank, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(regtypes, buffer, &ptr[i].rank, &m, PMIX_INT))) { return ret; } /* we have to do some conversion here as the definition of rank @@ -905,8 +899,9 @@ pmix_status_t pmix12_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_app_t *ptr; int32_t i, k, n, m; @@ -926,19 +921,19 @@ pmix_status_t pmix12_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, PMIX_APP_CONSTRUCT(&ptr[i]); /* unpack cmd */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &ptr[i].cmd, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, &ptr[i].cmd, &m, PMIX_STRING))) { return ret; } /* unpack argc */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(buffer, &argc, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(regtypes, buffer, &argc, &m, PMIX_INT))) { return ret; } /* unpack argv */ for (k=0; k < argc; k++) { m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -949,13 +944,13 @@ pmix_status_t pmix12_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, } /* unpack env */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int32(buffer, &nval, &m, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int32(regtypes, buffer, &nval, &m, PMIX_INT32))) { return ret; } for (k=0; k < nval; k++) { m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -966,18 +961,18 @@ pmix_status_t pmix12_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, } /* unpack maxprocs */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(buffer, &ptr[i].maxprocs, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_int(regtypes, buffer, &ptr[i].maxprocs, &m, PMIX_INT))) { return ret; } /* unpack info array */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(buffer, &ptr[i].ninfo, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].ninfo, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].ninfo) { PMIX_INFO_CREATE(ptr[i].info, ptr[i].ninfo); m = ptr[i].ninfo; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_info(buffer, ptr[i].info, &m, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_info(regtypes, buffer, ptr[i].info, &m, PMIX_INFO))) { return ret; } } @@ -985,8 +980,9 @@ pmix_status_t pmix12_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_kval_t *ptr; int32_t i, n, m; @@ -1002,7 +998,7 @@ pmix_status_t pmix12_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, PMIX_CONSTRUCT(&ptr[i], pmix_kval_t); /* unpack the key */ m = 1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(buffer, &ptr[i].key, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_string(regtypes, buffer, &ptr[i].key, &m, PMIX_STRING))) { PMIX_ERROR_LOG(ret); return ret; } @@ -1010,7 +1006,7 @@ pmix_status_t pmix12_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, ptr[i].value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); /* unpack the value */ m = 1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_value(buffer, ptr[i].value, &m, PMIX_VALUE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_value(regtypes, buffer, ptr[i].value, &m, PMIX_VALUE))) { PMIX_ERROR_LOG(ret); return ret; } @@ -1018,8 +1014,9 @@ pmix_status_t pmix12_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_info_array_t *ptr; int32_t i, n, m; @@ -1037,13 +1034,13 @@ pmix_status_t pmix12_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_info_array_t)); /* unpack the size of this array */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].array = (pmix_info_t*)malloc(ptr[i].size * sizeof(pmix_info_t)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_value(buffer, ptr[i].array, &m, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_value(regtypes, buffer, ptr[i].array, &m, PMIX_INFO))) { return ret; } } @@ -1051,8 +1048,9 @@ pmix_status_t pmix12_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_modex_data_t *ptr; int32_t i, n, m; @@ -1068,13 +1066,13 @@ pmix_status_t pmix12_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_modex_data_t)); /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].blob = (uint8_t*)malloc(ptr[i].size * sizeof(uint8_t)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_byte(buffer, ptr[i].blob, &m, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_byte(regtypes, buffer, ptr[i].blob, &m, PMIX_UINT8))) { return ret; } } @@ -1083,14 +1081,16 @@ pmix_status_t pmix12_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, } -pmix_status_t pmix12_bfrop_unpack_persist(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { - return pmix12_bfrop_unpack_int(buffer, dest, num_vals, PMIX_INT); + return pmix12_bfrop_unpack_int(regtypes, buffer, dest, num_vals, PMIX_INT); } -pmix_status_t pmix12_bfrop_unpack_bo(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_byte_object_t *ptr; int32_t i, n, m; @@ -1106,13 +1106,13 @@ pmix_status_t pmix12_bfrop_unpack_bo(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_byte_object_t)); /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].bytes = (char*)malloc(ptr[i].size * sizeof(char)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_byte(buffer, ptr[i].bytes, &m, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix12_bfrop_unpack_byte(regtypes, buffer, ptr[i].bytes, &m, PMIX_BYTE))) { return ret; } } @@ -1120,68 +1120,79 @@ pmix_status_t pmix12_bfrop_unpack_bo(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix12_bfrop_unpack_ptr(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } -pmix_status_t pmix12_bfrop_unpack_scope(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) -{ - return PMIX_ERR_NOT_SUPPORTED; -} - -pmix_status_t pmix12_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } -pmix_status_t pmix12_bfrop_unpack_range(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } -pmix_status_t pmix12_bfrop_unpack_cmd(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } -pmix_status_t pmix12_bfrop_unpack_info_directives(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix12_bfrop_unpack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } -pmix_status_t pmix12_bfrop_unpack_proc_state(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_info_directives(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) +{ + return PMIX_ERR_NOT_SUPPORTED; +} + +pmix_status_t pmix12_bfrop_unpack_proc_state(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) +{ + return PMIX_ERR_NOT_SUPPORTED; +} + +pmix_status_t pmix12_bfrop_unpack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) +{ + return PMIX_ERR_NOT_SUPPORTED; +} + +pmix_status_t pmix12_bfrop_unpack_proc_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } -pmix_status_t pmix12_bfrop_unpack_darray(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } -pmix_status_t pmix12_bfrop_unpack_proc_info(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) -{ - return PMIX_ERR_NOT_SUPPORTED; -} - -pmix_status_t pmix12_bfrop_unpack_query(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix12_bfrop_unpack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { return PMIX_ERR_NOT_SUPPORTED; } - -pmix_status_t pmix12_bfrop_unpack_rank(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) -{ - return PMIX_ERR_NOT_SUPPORTED; -} diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/bfrop_pmix20.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/bfrop_pmix20.c index 15774eb4ce..010ccf1406 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/bfrop_pmix20.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/bfrop_pmix20.c @@ -14,6 +14,8 @@ * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -436,20 +438,22 @@ pmix_data_type_t pmix20_v21_to_v20_datatype(pmix_data_type_t v21type) return v20type; } -pmix_status_t pmix20_bfrop_store_data_type(pmix_buffer_t *buffer, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_store_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t type) { pmix_data_type_t v20type; v20type = pmix20_v21_to_v20_datatype(type); - return pmix20_bfrop_pack_datatype(buffer, &v20type, 1, PMIX_DATA_TYPE); + return pmix20_bfrop_pack_datatype(regtypes, buffer, &v20type, 1, PMIX_DATA_TYPE); } -pmix_status_t pmix20_bfrop_get_data_type(pmix_buffer_t *buffer, pmix_data_type_t *type) +pmix_status_t pmix20_bfrop_get_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t *type) { int32_t n=1; pmix_status_t rc; - rc = pmix20_bfrop_unpack_datatype(buffer, type, &n, PMIX_DATA_TYPE); + rc = pmix20_bfrop_unpack_datatype(regtypes, buffer, type, &n, PMIX_DATA_TYPE); return rc; } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/internal.h b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/internal.h index 1478687f6c..ee1652123a 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/internal.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/internal.h @@ -15,6 +15,8 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -123,176 +125,254 @@ pmix_value_cmp_t pmix20_bfrop_value_cmp(pmix_value_t *p, /* * Specialized functions */ -pmix_status_t pmix20_bfrop_pack_buffer(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type); +pmix_status_t pmix20_bfrop_pack_buffer(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, + const void *src, int32_t num_vals, + pmix_data_type_t type); -pmix_status_t pmix20_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, +pmix_status_t pmix20_bfrop_unpack_buffer(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dst, int32_t *num_vals, pmix_data_type_t type); /* * Internal pack functions */ -pmix_status_t pmix20_bfrop_pack_bool(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_byte(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_string(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_sizet(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_pid(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_int(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_int16(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_int32(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_datatype(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_int64(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_float(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_double(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_timeval(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_status(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_value(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_proc(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_app(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_info(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_buf(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_kval(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_persist(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_scope(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_range(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_cmd(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_infodirs(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_infodirs(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_bo(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_pdata(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_ptr(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_pstate(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_pstate(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_pinfo(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_pinfo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_darray(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_query(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_rank(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_pack_alloc_directive(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_alloc_directive(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); /**** DEPRECATED ****/ -pmix_status_t pmix20_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); /********************/ /* * Internal unpack functions */ - pmix_status_t pmix20_bfrop_unpack_bool(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_byte(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_string(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_sizet(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_pid(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_int(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_int16(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_int32(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_datatype(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_int64(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_float(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_double(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_timeval(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_value(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_persist(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_scope(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_range(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_cmd(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_infodirs(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_bo(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_infodirs(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); + pmix_status_t pmix20_bfrop_unpack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_ptr(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_pstate(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_pstate(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_pinfo(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_pinfo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); - pmix_status_t pmix20_bfrop_unpack_darray(pmix_buffer_t *buffer, void *dest, + pmix_status_t pmix20_bfrop_unpack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_unpack_query(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix20_bfrop_unpack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_unpack_rank(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix20_bfrop_unpack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_unpack_alloc_directive(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix20_bfrop_unpack_alloc_directive(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); /**** DEPRECATED ****/ -pmix_status_t pmix20_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix20_bfrop_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); /********************/ @@ -414,9 +494,11 @@ pmix_status_t pmix20_bfrop_print_array(char **output, char *prefix, * Internal helper functions */ -pmix_status_t pmix20_bfrop_store_data_type(pmix_buffer_t *buffer, pmix_data_type_t type); +pmix_status_t pmix20_bfrop_store_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t type); -pmix_status_t pmix20_bfrop_get_data_type(pmix_buffer_t *buffer, pmix_data_type_t *type); +pmix_status_t pmix20_bfrop_get_data_type(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_data_type_t *type); pmix_data_type_t pmix20_v21_to_v20_datatype(pmix_data_type_t v21type); diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/pack.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/pack.c index 6aa194b8b9..fbb86143aa 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/pack.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/pack.c @@ -11,9 +11,9 @@ * All rights reserved. * Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2016 Mellanox Technologies, Inc. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ @@ -25,8 +25,6 @@ #include -#include - #ifdef HAVE_ARPA_INET_H #include #endif @@ -39,10 +37,11 @@ #include "internal.h" pmix_status_t pmix20_bfrop_pack(pmix_buffer_t *buffer, - const void *src, int32_t num_vals, - pmix_data_type_t type) + const void *src, int32_t num_vals, + pmix_data_type_t type) { pmix_status_t rc; + pmix_pointer_array_t *regtypes = &mca_bfrops_v20_component.types; /* check for error */ if (NULL == buffer) { @@ -51,21 +50,24 @@ pmix_status_t pmix20_bfrop_pack(pmix_buffer_t *buffer, /* Pack the number of values */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix20_bfrop_store_data_type(buffer, PMIX_INT32))) { + if (PMIX_SUCCESS != (rc = pmix20_bfrop_store_data_type(regtypes, buffer, + PMIX_INT32))) { return rc; } } - if (PMIX_SUCCESS != (rc = pmix20_bfrop_pack_int32(buffer, &num_vals, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (rc = pmix20_bfrop_pack_int32(regtypes, buffer, + &num_vals, 1, PMIX_INT32))) { return rc; } /* Pack the value(s) */ - return pmix20_bfrop_pack_buffer(buffer, src, num_vals, type); + return pmix20_bfrop_pack_buffer(regtypes, buffer, src, num_vals, type); } -pmix_status_t pmix20_bfrop_pack_buffer(pmix_buffer_t *buffer, - const void *src, int32_t num_vals, - pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_buffer(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, + const void *src, int32_t num_vals, + pmix_data_type_t type) { pmix_data_type_t v20type; pmix_status_t rc; @@ -86,7 +88,7 @@ pmix_status_t pmix20_bfrop_pack_buffer(pmix_buffer_t *buffer, /* Pack the declared data type */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix20_bfrop_store_data_type(buffer, v20type))) { + if (PMIX_SUCCESS != (rc = pmix20_bfrop_store_data_type(regtypes, buffer, v20type))) { return rc; } } @@ -97,7 +99,7 @@ pmix_status_t pmix20_bfrop_pack_buffer(pmix_buffer_t *buffer, return PMIX_ERR_PACK_FAILURE; } - return info->odti_pack_fn(buffer, src, num_vals, v20type); + return info->odti_pack_fn(regtypes, buffer, src, num_vals, v20type); } @@ -106,8 +108,9 @@ pmix_status_t pmix20_bfrop_pack_buffer(pmix_buffer_t *buffer, /* * BOOL */ -pmix_status_t pmix20_bfrop_pack_bool(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { uint8_t *dst; int32_t i; @@ -139,54 +142,57 @@ pmix_status_t pmix20_bfrop_pack_bool(pmix_buffer_t *buffer, const void *src, /* * INT */ -pmix_status_t pmix20_bfrop_pack_int(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret; /* System types need to always be described so we can properly unpack them */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_store_data_type(buffer, BFROP_TYPE_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_INT))) { return ret; } /* Turn around and pack the real type */ - return pmix20_bfrop_pack_buffer(buffer, src, num_vals, BFROP_TYPE_INT); + return pmix20_bfrop_pack_buffer(regtypes, buffer, src, num_vals, BFROP_TYPE_INT); } /* * SIZE_T */ -pmix_status_t pmix20_bfrop_pack_sizet(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) + { + pmix_status_t ret; + + /* System types need to always be described so we can properly + unpack them. */ + if (PMIX_SUCCESS != (ret = pmix20_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_SIZE_T))) { + return ret; + } + + return pmix20_bfrop_pack_buffer(regtypes, buffer, src, num_vals, BFROP_TYPE_SIZE_T); +} + +/* + * PID_T + */ +pmix_status_t pmix20_bfrop_pack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret; /* System types need to always be described so we can properly unpack them. */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_store_data_type(buffer, BFROP_TYPE_SIZE_T))) { - return ret; - } - - return pmix20_bfrop_pack_buffer(buffer, src, num_vals, BFROP_TYPE_SIZE_T); -} - -/* - * PID_T - */ -pmix_status_t pmix20_bfrop_pack_pid(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) - { - pmix_status_t ret; - - /* System types need to always be described so we can properly - unpack them. */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_store_data_type(buffer, BFROP_TYPE_PID_T))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_store_data_type(regtypes, buffer, BFROP_TYPE_PID_T))) { return ret; } /* Turn around and pack the real type */ - return pmix20_bfrop_pack_buffer(buffer, src, num_vals, BFROP_TYPE_PID_T); + return pmix20_bfrop_pack_buffer(regtypes, buffer, src, num_vals, BFROP_TYPE_PID_T); } @@ -195,8 +201,9 @@ pmix_status_t pmix20_bfrop_pack_pid(pmix_buffer_t *buffer, const void *src, /* * BYTE, CHAR, INT8 */ -pmix_status_t pmix20_bfrop_pack_byte(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { char *dst; @@ -220,8 +227,9 @@ pmix_status_t pmix20_bfrop_pack_byte(pmix_buffer_t *buffer, const void *src, /* * INT16 */ -pmix_status_t pmix20_bfrop_pack_int16(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int32_t i; uint16_t tmp, *srctmp = (uint16_t*) src; @@ -248,8 +256,9 @@ pmix_status_t pmix20_bfrop_pack_int16(pmix_buffer_t *buffer, const void *src, /* * INT32 */ -pmix_status_t pmix20_bfrop_pack_int32(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int32_t i; uint32_t tmp, *srctmp = (uint32_t*) src; @@ -273,17 +282,22 @@ pmix_status_t pmix20_bfrop_pack_int32(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_datatype(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { - return pmix20_bfrop_pack_int16(buffer, src, num_vals, type); + pmix_status_t ret; + + PMIX_BFROPS_PACK_TYPE(ret, buffer, src, num_vals, PMIX_INT16, regtypes); + return ret; } /* * INT64 */ -pmix_status_t pmix20_bfrop_pack_int64(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int32_t i; uint64_t tmp, tmp2; @@ -312,8 +326,9 @@ pmix_status_t pmix20_bfrop_pack_int64(pmix_buffer_t *buffer, const void *src, /* * STRING */ -pmix_status_t pmix20_bfrop_pack_string(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret = PMIX_SUCCESS; int32_t i, len; @@ -322,16 +337,16 @@ pmix_status_t pmix20_bfrop_pack_string(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { if (NULL == ssrc[i]) { /* got zero-length string/NULL pointer - store NULL */ len = 0; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(buffer, &len, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(regtypes, buffer, &len, 1, PMIX_INT32))) { return ret; } } else { len = (int32_t)strlen(ssrc[i]) + 1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(buffer, &len, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(regtypes, buffer, &len, 1, PMIX_INT32))) { return ret; } if (PMIX_SUCCESS != (ret = - pmix20_bfrop_pack_byte(buffer, ssrc[i], len, PMIX_BYTE))) { + pmix20_bfrop_pack_byte(regtypes, buffer, ssrc[i], len, PMIX_BYTE))) { return ret; } } @@ -341,8 +356,9 @@ return PMIX_SUCCESS; } /* FLOAT */ -pmix_status_t pmix20_bfrop_pack_float(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret = PMIX_SUCCESS; int32_t i; @@ -353,7 +369,7 @@ pmix_status_t pmix20_bfrop_pack_float(pmix_buffer_t *buffer, const void *src, if (0 > asprintf(&convert, "%f", ssrc[i])) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &convert, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &convert, 1, PMIX_STRING))) { free(convert); return ret; } @@ -364,8 +380,9 @@ pmix_status_t pmix20_bfrop_pack_float(pmix_buffer_t *buffer, const void *src, } /* DOUBLE */ -pmix_status_t pmix20_bfrop_pack_double(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret = PMIX_SUCCESS; int32_t i; @@ -376,7 +393,7 @@ pmix_status_t pmix20_bfrop_pack_double(pmix_buffer_t *buffer, const void *src, if (0 > asprintf(&convert, "%f", ssrc[i])) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &convert, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &convert, 1, PMIX_STRING))) { free(convert); return ret; } @@ -387,8 +404,9 @@ pmix_status_t pmix20_bfrop_pack_double(pmix_buffer_t *buffer, const void *src, } /* TIMEVAL */ -pmix_status_t pmix20_bfrop_pack_timeval(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { int64_t tmp[2]; pmix_status_t ret = PMIX_SUCCESS; @@ -398,7 +416,7 @@ pmix_status_t pmix20_bfrop_pack_timeval(pmix_buffer_t *buffer, const void *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 (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int64(buffer, tmp, 2, PMIX_INT64))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int64(regtypes, buffer, tmp, 2, PMIX_INT64))) { return ret; } } @@ -407,8 +425,9 @@ pmix_status_t pmix20_bfrop_pack_timeval(pmix_buffer_t *buffer, const void *src, } /* TIME */ -pmix_status_t pmix20_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret = PMIX_SUCCESS; int32_t i; @@ -420,7 +439,7 @@ pmix_status_t pmix20_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, */ for (i = 0; i < num_vals; ++i) { ui64 = (uint64_t)ssrc[i]; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int64(buffer, &ui64, 1, PMIX_UINT64))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int64(regtypes, buffer, &ui64, 1, PMIX_UINT64))) { return ret; } } @@ -429,8 +448,9 @@ pmix_status_t pmix20_bfrop_pack_time(pmix_buffer_t *buffer, const void *src, } /* STATUS */ -pmix_status_t pmix20_bfrop_pack_status(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret = PMIX_SUCCESS; int32_t i; @@ -439,7 +459,7 @@ pmix_status_t pmix20_bfrop_pack_status(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { status = (int32_t)ssrc[i]; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(buffer, &status, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(regtypes, buffer, &status, 1, PMIX_INT32))) { return ret; } } @@ -449,7 +469,8 @@ pmix_status_t pmix20_bfrop_pack_status(pmix_buffer_t *buffer, const void *src, /* PACK FUNCTIONS FOR GENERIC PMIX TYPES */ -static pmix_status_t pack_val(pmix_buffer_t *buffer, +static pmix_status_t pack_val(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_value_t *p) { pmix_status_t ret; @@ -458,158 +479,158 @@ static pmix_status_t pack_val(pmix_buffer_t *buffer, case PMIX_UNDEF: break; case PMIX_BOOL: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.flag, 1, PMIX_BOOL))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.flag, 1, PMIX_BOOL))) { return ret; } break; case PMIX_BYTE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.byte, 1, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.byte, 1, PMIX_BYTE))) { return ret; } break; case PMIX_STRING: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.string, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.string, 1, PMIX_STRING))) { return ret; } break; case PMIX_SIZE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.size, 1, PMIX_SIZE))) { return ret; } break; case PMIX_PID: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.pid, 1, PMIX_PID))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.pid, 1, PMIX_PID))) { return ret; } break; case PMIX_INT: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.integer, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.integer, 1, PMIX_INT))) { return ret; } break; case PMIX_INT8: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.int8, 1, PMIX_INT8))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.int8, 1, PMIX_INT8))) { return ret; } break; case PMIX_INT16: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.int16, 1, PMIX_INT16))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.int16, 1, PMIX_INT16))) { return ret; } break; case PMIX_INT32: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.int32, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.int32, 1, PMIX_INT32))) { return ret; } break; case PMIX_INT64: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.int64, 1, PMIX_INT64))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.int64, 1, PMIX_INT64))) { return ret; } break; case PMIX_UINT: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.uint, 1, PMIX_UINT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.uint, 1, PMIX_UINT))) { return ret; } break; case PMIX_UINT8: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.uint8, 1, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.uint8, 1, PMIX_UINT8))) { return ret; } break; case PMIX_UINT16: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.uint16, 1, PMIX_UINT16))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.uint16, 1, PMIX_UINT16))) { return ret; } break; case PMIX_UINT32: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.uint32, 1, PMIX_UINT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.uint32, 1, PMIX_UINT32))) { return ret; } break; case PMIX_UINT64: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.uint64, 1, PMIX_UINT64))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.uint64, 1, PMIX_UINT64))) { return ret; } break; case PMIX_FLOAT: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.fval, 1, PMIX_FLOAT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.fval, 1, PMIX_FLOAT))) { return ret; } break; case PMIX_DOUBLE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.dval, 1, PMIX_DOUBLE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.dval, 1, PMIX_DOUBLE))) { return ret; } break; case PMIX_TIMEVAL: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.tv, 1, PMIX_TIMEVAL))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.tv, 1, PMIX_TIMEVAL))) { return ret; } break; case PMIX_TIME: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.time, 1, PMIX_TIME))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.time, 1, PMIX_TIME))) { return ret; } break; case PMIX_STATUS: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.status, 1, PMIX_STATUS))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.status, 1, PMIX_STATUS))) { return ret; } break; case PMIX_PROC: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, p->data.proc, 1, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, p->data.proc, 1, PMIX_PROC))) { return ret; } break; case PMIX_PROC_RANK: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.rank, 1, PMIX_PROC_RANK))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.rank, 1, PMIX_PROC_RANK))) { return ret; } break; case PMIX_BYTE_OBJECT: case PMIX_COMPRESSED_STRING: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.bo, 1, PMIX_BYTE_OBJECT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.bo, 1, PMIX_BYTE_OBJECT))) { return ret; } break; case PMIX_PERSIST: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.persist, 1, PMIX_PERSIST))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.persist, 1, PMIX_PERSIST))) { return ret; } break; case PMIX_POINTER: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.ptr, 1, PMIX_POINTER))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.ptr, 1, PMIX_POINTER))) { return ret; } break; case PMIX_SCOPE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.scope, 1, PMIX_SCOPE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.scope, 1, PMIX_SCOPE))) { return ret; } break; case PMIX_DATA_RANGE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.range, 1, PMIX_DATA_RANGE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.range, 1, PMIX_DATA_RANGE))) { return ret; } break; case PMIX_PROC_STATE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, &p->data.state, 1, PMIX_PROC_STATE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, &p->data.state, 1, PMIX_PROC_STATE))) { return ret; } break; case PMIX_PROC_INFO: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, p->data.pinfo, 1, PMIX_PROC_INFO))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, p->data.pinfo, 1, PMIX_PROC_INFO))) { return ret; } break; case PMIX_DATA_ARRAY: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, p->data.darray, 1, PMIX_DATA_ARRAY))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, p->data.darray, 1, PMIX_DATA_ARRAY))) { return ret; } break; case PMIX_QUERY: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, p->data.darray, 1, PMIX_QUERY))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, p->data.darray, 1, PMIX_QUERY))) { return ret; } break; @@ -623,7 +644,8 @@ static pmix_status_t pack_val(pmix_buffer_t *buffer, /* * PMIX_VALUE */ - pmix_status_t pmix20_bfrop_pack_value(pmix_buffer_t *buffer, const void *src, + pmix_status_t pmix20_bfrop_pack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_value_t *ptr; @@ -634,11 +656,11 @@ static pmix_status_t pack_val(pmix_buffer_t *buffer, for (i = 0; i < num_vals; ++i) { /* pack the type */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_store_data_type(buffer, ptr[i].type))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_store_data_type(regtypes, buffer, ptr[i].type))) { return ret; } /* now pack the right field */ - if (PMIX_SUCCESS != (ret = pack_val(buffer, &ptr[i]))) { + if (PMIX_SUCCESS != (ret = pack_val(regtypes, buffer, &ptr[i]))) { return ret; } } @@ -647,8 +669,9 @@ static pmix_status_t pack_val(pmix_buffer_t *buffer, } -pmix_status_t pmix20_bfrop_pack_info(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_info_t *info; int32_t i; @@ -660,27 +683,28 @@ pmix_status_t pmix20_bfrop_pack_info(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack key */ foo = info[i].key; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &foo, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &foo, 1, PMIX_STRING))) { return ret; } /* pack info directives flag */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_infodirs(buffer, &info[i].flags, 1, PMIX_INFO_DIRECTIVES))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_infodirs(regtypes, buffer, &info[i].flags, 1, PMIX_INFO_DIRECTIVES))) { return ret; } /* pack the type */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int(buffer, &info[i].value.type, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int(regtypes, buffer, &info[i].value.type, 1, PMIX_INT))) { return ret; } /* pack value */ - if (PMIX_SUCCESS != (ret = pack_val(buffer, &info[i].value))) { + if (PMIX_SUCCESS != (ret = pack_val(regtypes, buffer, &info[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_pdata(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_pdata_t *pdata; int32_t i; @@ -691,28 +715,29 @@ pmix_status_t pmix20_bfrop_pack_pdata(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the proc */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_proc(buffer, &pdata[i].proc, 1, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_proc(regtypes, buffer, &pdata[i].proc, 1, PMIX_PROC))) { return ret; } /* pack key */ foo = pdata[i].key; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &foo, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &foo, 1, PMIX_STRING))) { return ret; } /* pack the type */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int(buffer, &pdata[i].value.type, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int(regtypes, buffer, &pdata[i].value.type, 1, PMIX_INT))) { return ret; } /* pack value */ - if (PMIX_SUCCESS != (ret = pack_val(buffer, &pdata[i].value))) { + if (PMIX_SUCCESS != (ret = pack_val(regtypes, buffer, &pdata[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_buf(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_buffer_t *ptr; int32_t i; @@ -722,12 +747,12 @@ pmix_status_t pmix20_bfrop_pack_buf(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the number of bytes */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(buffer, &ptr[i].bytes_used, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(regtypes, buffer, &ptr[i].bytes_used, 1, PMIX_SIZE))) { return ret; } /* pack the bytes */ if (0 < ptr[i].bytes_used) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_byte(buffer, ptr[i].base_ptr, ptr[i].bytes_used, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_byte(regtypes, buffer, ptr[i].base_ptr, ptr[i].bytes_used, PMIX_BYTE))) { return ret; } } @@ -735,8 +760,9 @@ pmix_status_t pmix20_bfrop_pack_buf(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_proc(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_proc_t *proc; int32_t i; @@ -746,18 +772,19 @@ pmix_status_t pmix20_bfrop_pack_proc(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { char *ptr = proc[i].nspace; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &ptr, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &ptr, 1, PMIX_STRING))) { return ret; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_rank(buffer, &proc[i].rank, 1, PMIX_PROC_RANK))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_rank(regtypes, buffer, &proc[i].rank, 1, PMIX_PROC_RANK))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_app(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_app_t *app; int32_t i, j, nvals; @@ -766,43 +793,43 @@ pmix_status_t pmix20_bfrop_pack_app(pmix_buffer_t *buffer, const void *src, app = (pmix_app_t *) src; for (i = 0; i < num_vals; ++i) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &app[i].cmd, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &app[i].cmd, 1, PMIX_STRING))) { return ret; } /* argv */ nvals = pmix_argv_count(app[i].argv); - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int(buffer, &nvals, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int(regtypes, buffer, &nvals, 1, PMIX_INT32))) { return ret; } for (j=0; j < nvals; j++) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &app[i].argv[j], 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &app[i].argv[j], 1, PMIX_STRING))) { return ret; } } /* env */ nvals = pmix_argv_count(app[i].env); - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(buffer, &nvals, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(regtypes, buffer, &nvals, 1, PMIX_INT32))) { return ret; } for (j=0; j < nvals; j++) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &app[i].env[j], 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &app[i].env[j], 1, PMIX_STRING))) { return ret; } } /* cwd */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &app[i].cwd, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &app[i].cwd, 1, PMIX_STRING))) { return ret; } /* maxprocs */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int(buffer, &app[i].maxprocs, 1, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int(regtypes, buffer, &app[i].maxprocs, 1, PMIX_INT))) { return ret; } /* info array */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(buffer, &app[i].ninfo, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(regtypes, buffer, &app[i].ninfo, 1, PMIX_SIZE))) { return ret; } if (0 < app[i].ninfo) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_info(buffer, app[i].info, app[i].ninfo, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_info(regtypes, buffer, app[i].info, app[i].ninfo, PMIX_INFO))) { return ret; } } @@ -811,8 +838,9 @@ pmix_status_t pmix20_bfrop_pack_app(pmix_buffer_t *buffer, const void *src, } -pmix_status_t pmix20_bfrop_pack_kval(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_kval_t *ptr; int32_t i; @@ -824,11 +852,11 @@ pmix_status_t pmix20_bfrop_pack_kval(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the key */ st = ptr[i].key; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &st, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &st, 1, PMIX_STRING))) { return ret; } /* pack the value */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_value(buffer, ptr[i].value, 1, PMIX_VALUE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_value(regtypes, buffer, ptr[i].value, 1, PMIX_VALUE))) { return ret; } } @@ -836,8 +864,9 @@ pmix_status_t pmix20_bfrop_pack_kval(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_modex_data_t *ptr; int32_t i; @@ -846,11 +875,11 @@ pmix_status_t pmix20_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, ptr = (pmix_modex_data_t *) src; for (i = 0; i < num_vals; ++i) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(buffer, &ptr[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) { return ret; } if( 0 < ptr[i].size){ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_byte(buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_byte(regtypes, buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) { return ret; } } @@ -858,38 +887,44 @@ pmix_status_t pmix20_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_persist(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) +{ + return pmix20_bfrop_pack_byte(regtypes, buffer, src, num_vals, PMIX_UINT8); +} + +pmix_status_t pmix20_bfrop_pack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix20_bfrop_pack_byte(buffer, src, num_vals, PMIX_UINT8); + return pmix20_bfrop_pack_byte(regtypes, buffer, src, num_vals, PMIX_UINT8); } -pmix_status_t pmix20_bfrop_pack_scope(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) +{ + return pmix20_bfrop_pack_byte(regtypes, buffer, src, num_vals, PMIX_UINT8); +} + +pmix_status_t pmix20_bfrop_pack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix20_bfrop_pack_byte(buffer, src, num_vals, PMIX_UINT8); + return pmix20_bfrop_pack_byte(regtypes, buffer, src, num_vals, PMIX_UINT8); } -pmix_status_t pmix20_bfrop_pack_range(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_infodirs(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { - return pmix20_bfrop_pack_byte(buffer, src, num_vals, PMIX_UINT8); + return pmix20_bfrop_pack_int32(regtypes, buffer, src, num_vals, PMIX_UINT32); } -pmix_status_t pmix20_bfrop_pack_cmd(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) -{ - return pmix20_bfrop_pack_byte(buffer, src, num_vals, PMIX_UINT8); -} - -pmix_status_t pmix20_bfrop_pack_infodirs(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) -{ - return pmix20_bfrop_pack_int32(buffer, src, num_vals, PMIX_UINT32); -} - -pmix_status_t pmix20_bfrop_pack_bo(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_status_t ret; int i; @@ -897,11 +932,11 @@ pmix_status_t pmix20_bfrop_pack_bo(pmix_buffer_t *buffer, const void *src, bo = (pmix_byte_object_t*)src; for (i=0; i < num_vals; i++) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(buffer, &bo[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(regtypes, buffer, &bo[i].size, 1, PMIX_SIZE))) { return ret; } if (0 < bo[i].size) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_byte(buffer, bo[i].bytes, bo[i].size, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_byte(regtypes, buffer, bo[i].bytes, bo[i].size, PMIX_BYTE))) { return ret; } } @@ -909,23 +944,26 @@ pmix_status_t pmix20_bfrop_pack_bo(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_ptr(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { uint8_t foo=1; /* it obviously makes no sense to pack a pointer and * send it somewhere else, so we just pack a sentinel */ - return pmix20_bfrop_pack_byte(buffer, &foo, 1, PMIX_UINT8); + return pmix20_bfrop_pack_byte(regtypes, buffer, &foo, 1, PMIX_UINT8); } -pmix_status_t pmix20_bfrop_pack_pstate(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_pstate(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { - return pmix20_bfrop_pack_byte(buffer, src, num_vals, PMIX_UINT8); + return pmix20_bfrop_pack_byte(regtypes, buffer, src, num_vals, PMIX_UINT8); } -pmix_status_t pmix20_bfrop_pack_pinfo(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_pinfo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_proc_info_t *pinfo = (pmix_proc_info_t*)src; pmix_status_t ret; @@ -933,29 +971,30 @@ pmix_status_t pmix20_bfrop_pack_pinfo(pmix_buffer_t *buffer, const void *src, for (i=0; i < num_vals; i++) { /* pack the proc identifier */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_proc(buffer, &pinfo[i].proc, 1, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_proc(regtypes, buffer, &pinfo[i].proc, 1, PMIX_PROC))) { return ret; } /* pack the hostname and exec */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &pinfo[i].hostname, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &pinfo[i].hostname, 1, PMIX_STRING))) { return ret; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, &pinfo[i].executable_name, 1, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, &pinfo[i].executable_name, 1, PMIX_STRING))) { return ret; } /* pack the pid and state */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_pid(buffer, &pinfo[i].pid, 1, PMIX_PID))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_pid(regtypes, buffer, &pinfo[i].pid, 1, PMIX_PID))) { return ret; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_pstate(buffer, &pinfo[i].state, 1, PMIX_PROC_STATE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_pstate(regtypes, buffer, &pinfo[i].state, 1, PMIX_PROC_STATE))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_darray(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_data_array_t *p = (pmix_data_array_t*)src; pmix_status_t ret; @@ -963,11 +1002,11 @@ pmix_status_t pmix20_bfrop_pack_darray(pmix_buffer_t *buffer, const void *src, for (i=0; i < num_vals; i++) { /* pack the actual type in the array */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_datatype(buffer, &p[i].type, 1, PMIX_DATA_TYPE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_datatype(regtypes, buffer, &p[i].type, 1, PMIX_DATA_TYPE))) { return ret; } /* pack the number of array elements */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(buffer, &p[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(regtypes, buffer, &p[i].size, 1, PMIX_SIZE))) { return ret; } if (0 == p[i].size || PMIX_UNDEF == p[i].type) { @@ -975,21 +1014,23 @@ pmix_status_t pmix20_bfrop_pack_darray(pmix_buffer_t *buffer, const void *src, continue; } /* pack the actual elements */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(buffer, p[i].array, p[i].size, p[i].type))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_buffer(regtypes, buffer, p[i].array, p[i].size, p[i].type))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_rank(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { - return pmix20_bfrop_pack_int32(buffer, src, num_vals, PMIX_UINT32); + return pmix20_bfrop_pack_int32(regtypes, buffer, src, num_vals, PMIX_UINT32); } -pmix_status_t pmix20_bfrop_pack_query(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_query_t *pq = (pmix_query_t*)src; pmix_status_t ret; @@ -999,22 +1040,22 @@ pmix_status_t pmix20_bfrop_pack_query(pmix_buffer_t *buffer, const void *src, for (i=0; i < num_vals; i++) { /* pack the number of keys */ nkeys = pmix_argv_count(pq[i].keys); - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(buffer, &nkeys, 1, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_int32(regtypes, buffer, &nkeys, 1, PMIX_INT32))) { return ret; } if (0 < nkeys) { /* pack the keys */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(buffer, pq[i].keys, nkeys, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_string(regtypes, buffer, pq[i].keys, nkeys, PMIX_STRING))) { return ret; } } /* pack the number of qualifiers */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(buffer, &pq[i].nqual, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_sizet(regtypes, buffer, &pq[i].nqual, 1, PMIX_SIZE))) { return ret; } if (0 < pq[i].nqual) { /* pack any provided qualifiers */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_info(buffer, pq[i].qualifiers, pq[i].nqual, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_pack_info(regtypes, buffer, pq[i].qualifiers, pq[i].nqual, PMIX_INFO))) { return ret; } } @@ -1022,14 +1063,16 @@ pmix_status_t pmix20_bfrop_pack_query(pmix_buffer_t *buffer, const void *src, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_pack_alloc_directive(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_pack_alloc_directive(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { - return pmix20_bfrop_pack_byte(buffer, src, num_vals, PMIX_UINT8); + return pmix20_bfrop_pack_byte(regtypes, buffer, src, num_vals, PMIX_UINT8); } /**** DEPRECATED ****/ -pmix_status_t pmix20_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, +pmix_status_t pmix20_bfrop_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_info_array_t *ptr; @@ -1040,12 +1083,12 @@ pmix_status_t pmix20_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, for (i = 0; i < num_vals; ++i) { /* pack the size */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &ptr[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { /* pack the values */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(regtypes, buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) { return ret; } } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/unpack.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/unpack.c index 91ce264fd3..0b00653de8 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/unpack.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v20/unpack.c @@ -11,9 +11,9 @@ * All rights reserved. * Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved. * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. - * Copyright (c) 2016 Mellanox Technologies, Inc. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ @@ -25,8 +25,6 @@ #include -#include - #include "src/util/argv.h" #include "src/util/error.h" #include "src/util/output.h" @@ -34,42 +32,14 @@ #include "bfrop_pmix20.h" #include "internal.h" -static pmix_status_t unpack_gentype(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) -{ - switch(type) { - case PMIX_INT8: - case PMIX_UINT8: - return pmix20_bfrop_unpack_byte(buffer, dest, num_vals, type); - break; - - case PMIX_INT16: - case PMIX_UINT16: - return pmix20_bfrop_unpack_int16(buffer, dest, num_vals, type); - break; - - case PMIX_INT32: - case PMIX_UINT32: - return pmix20_bfrop_unpack_int32(buffer, dest, num_vals, type); - break; - - case PMIX_INT64: - case PMIX_UINT64: - return pmix20_bfrop_unpack_int64(buffer, dest, num_vals, type); - break; - - default: - return PMIX_ERR_UNKNOWN_DATA_TYPE; - } -} - pmix_status_t pmix20_bfrop_unpack(pmix_buffer_t *buffer, - void *dst, int32_t *num_vals, - pmix_data_type_t type) + void *dst, int32_t *num_vals, + pmix_data_type_t type) { pmix_status_t rc, ret; int32_t local_num, n=1; pmix_data_type_t local_type; + pmix_pointer_array_t *regtypes = &mca_bfrops_v20_component.types; /* check for error */ if (NULL == buffer || NULL == dst || NULL == num_vals) { @@ -96,7 +66,7 @@ pmix_status_t pmix20_bfrop_unpack(pmix_buffer_t *buffer, * int32_t as used here. */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix20_bfrop_get_data_type(buffer, &local_type))) { + if (PMIX_SUCCESS != (rc = pmix20_bfrop_get_data_type(regtypes, buffer, &local_type))) { *num_vals = 0; /* don't error log here as the user may be unpacking past * the end of the buffer, which isn't necessarily an error */ @@ -109,7 +79,8 @@ pmix_status_t pmix20_bfrop_unpack(pmix_buffer_t *buffer, } n=1; - if (PMIX_SUCCESS != (rc = pmix20_bfrop_unpack_int32(buffer, &local_num, &n, PMIX_INT32))) { + PMIX_BFROPS_UNPACK_TYPE(rc, buffer, &local_num, &n, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != rc) { *num_vals = 0; /* don't error log here as the user may be unpacking past * the end of the buffer, which isn't necessarily an error */ @@ -137,7 +108,7 @@ pmix_status_t pmix20_bfrop_unpack(pmix_buffer_t *buffer, } /** Unpack the value(s) */ - if (PMIX_SUCCESS != (rc = pmix20_bfrop_unpack_buffer(buffer, dst, &local_num, type))) { + if (PMIX_SUCCESS != (rc = pmix20_bfrop_unpack_buffer(regtypes, buffer, dst, &local_num, type))) { *num_vals = 0; ret = rc; } @@ -145,12 +116,12 @@ pmix_status_t pmix20_bfrop_unpack(pmix_buffer_t *buffer, return ret; } -pmix_status_t pmix20_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, int32_t *num_vals, - pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_buffer(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dst, int32_t *num_vals, + pmix_data_type_t type) { pmix_status_t rc; pmix_data_type_t local_type, v20type; - pmix_bfrop_type_info_t *info; pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix20_bfrop_unpack_buffer( %p, %p, %lu, %d )\n", @@ -167,7 +138,7 @@ pmix_status_t pmix20_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, int32 /** Unpack the declared data type */ if (PMIX_BFROP_BUFFER_FULLY_DESC == buffer->type) { - if (PMIX_SUCCESS != (rc = pmix20_bfrop_get_data_type(buffer, &local_type))) { + if (PMIX_SUCCESS != (rc = pmix20_bfrop_get_data_type(regtypes, buffer, &local_type))) { return rc; } /* if the data types don't match, then return an error */ @@ -176,14 +147,8 @@ pmix_status_t pmix20_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, int32 return PMIX_ERR_PACK_MISMATCH; } } - - /* Lookup the unpack function for this type and call it */ - - if (NULL == (info = (pmix_bfrop_type_info_t*)pmix_pointer_array_get_item(&mca_bfrops_v20_component.types, v20type))) { - return PMIX_ERR_UNPACK_FAILURE; - } - - return info->odti_unpack_fn(buffer, dst, num_vals, v20type); + PMIX_BFROPS_UNPACK_TYPE(rc, buffer, dst, num_vals, v20type, regtypes); + return rc; } @@ -192,8 +157,9 @@ pmix_status_t pmix20_bfrop_unpack_buffer(pmix_buffer_t *buffer, void *dst, int32 /* * BOOL */ -pmix_status_t pmix20_bfrop_unpack_bool(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_bool(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i; uint8_t *src; @@ -227,24 +193,26 @@ pmix_status_t pmix20_bfrop_unpack_bool(pmix_buffer_t *buffer, void *dest, /* * INT */ -pmix_status_t pmix20_bfrop_unpack_int(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_int(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_get_data_type(regtypes, buffer, &remote_type))) { return ret; } if (remote_type == BFROP_TYPE_INT) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, dest, num_vals, BFROP_TYPE_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, dest, + num_vals, BFROP_TYPE_INT))) { } } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(int, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, int, remote_type, ret); } return ret; @@ -253,24 +221,26 @@ pmix_status_t pmix20_bfrop_unpack_int(pmix_buffer_t *buffer, void *dest, /* * SIZE_T */ -pmix_status_t pmix20_bfrop_unpack_sizet(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_sizet(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_get_data_type(regtypes, buffer, &remote_type))) { return ret; } if (remote_type == BFROP_TYPE_SIZE_T) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, dest, num_vals, BFROP_TYPE_SIZE_T))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, + dest, num_vals, BFROP_TYPE_SIZE_T))) { } } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(size_t, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, size_t, remote_type, ret); } return ret; @@ -279,24 +249,25 @@ pmix_status_t pmix20_bfrop_unpack_sizet(pmix_buffer_t *buffer, void *dest, /* * PID_T */ -pmix_status_t pmix20_bfrop_unpack_pid(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_pid(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; pmix_data_type_t remote_type; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_get_data_type(buffer, &remote_type))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_get_data_type(regtypes, buffer, &remote_type))) { return ret; } if (remote_type == BFROP_TYPE_PID_T) { /* fast path it if the sizes are the same */ /* Turn around and unpack the real type */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, dest, num_vals, BFROP_TYPE_PID_T))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, dest, num_vals, BFROP_TYPE_PID_T))) { } } else { /* slow path - types are different sizes */ - PMIX_BFROP_UNPACK_SIZE_MISMATCH(pid_t, remote_type, ret); + PMIX_BFROP_UNPACK_SIZE_MISMATCH(regtypes, pid_t, remote_type, ret); } return ret; @@ -308,8 +279,9 @@ pmix_status_t pmix20_bfrop_unpack_pid(pmix_buffer_t *buffer, void *dest, /* * BYTE, CHAR, INT8 */ -pmix_status_t pmix20_bfrop_unpack_byte(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_byte(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix20_bfrop_unpack_byte * %d\n", (int)*num_vals); @@ -327,8 +299,9 @@ pmix_status_t pmix20_bfrop_unpack_byte(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_int16(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_int16(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i; uint16_t tmp, *desttmp = (uint16_t*) dest; @@ -351,8 +324,9 @@ pmix_status_t pmix20_bfrop_unpack_int16(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_int32(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_int32(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i; uint32_t tmp, *desttmp = (uint32_t*) dest; @@ -375,14 +349,19 @@ pmix_status_t pmix20_bfrop_unpack_int32(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_datatype(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_datatype(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { - return pmix20_bfrop_unpack_int16(buffer, dest, num_vals, type); + pmix_status_t ret; + + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_INT16, regtypes); + return ret; } -pmix_status_t pmix20_bfrop_unpack_int64(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_int64(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i; uint64_t tmp, *desttmp = (uint64_t*) dest; @@ -405,15 +384,17 @@ pmix_status_t pmix20_bfrop_unpack_int64(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_string(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_string(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_status_t ret; int32_t i, len, n=1; char **sdest = (char**) dest; for (i = 0; i < (*num_vals); ++i) { - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int32(buffer, &len, &n, PMIX_INT32))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &len, &n, PMIX_INT32, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (0 == len) { /* zero-length string - unpack the NULL */ @@ -423,7 +404,8 @@ pmix_status_t pmix20_bfrop_unpack_string(pmix_buffer_t *buffer, void *dest, if (NULL == sdest[i]) { return PMIX_ERR_OUT_OF_RESOURCE; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_byte(buffer, sdest[i], &len, PMIX_BYTE))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, sdest[i], &len, PMIX_BYTE, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } } @@ -432,8 +414,9 @@ pmix_status_t pmix20_bfrop_unpack_string(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_float(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_float(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; float *desttmp = (float*) dest, tmp; @@ -451,7 +434,8 @@ pmix_status_t pmix20_bfrop_unpack_float(pmix_buffer_t *buffer, void *dest, for (i = 0; i < (*num_vals); ++i) { n=1; convert = NULL; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &convert, &n, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &convert, &n, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (NULL != convert) { @@ -463,8 +447,9 @@ pmix_status_t pmix20_bfrop_unpack_float(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_double(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_double(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; double *desttmp = (double*) dest, tmp; @@ -482,7 +467,8 @@ pmix_status_t pmix20_bfrop_unpack_double(pmix_buffer_t *buffer, void *dest, for (i = 0; i < (*num_vals); ++i) { n=1; convert = NULL; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &convert, &n, PMIX_STRING))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &convert, &n, PMIX_STRING, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } if (NULL != convert) { @@ -494,8 +480,9 @@ pmix_status_t pmix20_bfrop_unpack_double(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_timeval(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_timeval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; int64_t tmp[2]; @@ -512,7 +499,8 @@ pmix_status_t pmix20_bfrop_unpack_timeval(pmix_buffer_t *buffer, void *dest, /* unpack the data */ for (i = 0; i < (*num_vals); ++i) { n=2; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int64(buffer, tmp, &n, PMIX_INT64))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, tmp, &n, PMIX_INT64, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } tt.tv_sec = tmp[0]; @@ -522,8 +510,9 @@ pmix_status_t pmix20_bfrop_unpack_timeval(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_time(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { int32_t i, n; time_t *desttmp = (time_t *) dest, tmp; @@ -536,15 +525,11 @@ pmix_status_t pmix20_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix20_bfrop_unpack_time * %d\n", (int)*num_vals); - /* check to see if there's enough data in buffer */ - if (pmix_bfrop_too_small(buffer, (*num_vals)*(sizeof(uint64_t)))) { - return PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER; - } - /* unpack the data */ for (i = 0; i < (*num_vals); ++i) { n=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int64(buffer, &ui64, &n, PMIX_UINT64))) { + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, &ui64, &n, PMIX_UINT64, regtypes); + if (PMIX_SUCCESS != ret) { return ret; } tmp = (time_t)ui64; @@ -554,10 +539,13 @@ pmix_status_t pmix20_bfrop_unpack_time(pmix_buffer_t *buffer, void *dest, } -pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_status(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { - pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, + pmix_status_t ret; + + pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix20_bfrop_unpack_status * %d\n", (int)*num_vals); /* check to see if there's enough data in buffer */ if (pmix_bfrop_too_small(buffer, (*num_vals)*(sizeof(pmix_status_t)))) { @@ -565,7 +553,8 @@ pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, } /* unpack the data */ - return pmix20_bfrop_unpack_int32(buffer, dest, num_vals, PMIX_INT32); + PMIX_BFROPS_UNPACK_TYPE(ret, buffer, dest, num_vals, PMIX_INT32, regtypes); + return ret; } @@ -574,8 +563,9 @@ pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, /* * PMIX_VALUE */ - static pmix_status_t unpack_val(pmix_buffer_t *buffer, pmix_value_t *val) - { +static pmix_status_t unpack_val(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, pmix_value_t *val) +{ int32_t m; pmix_status_t ret; @@ -584,102 +574,102 @@ pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, case PMIX_UNDEF: break; case PMIX_BOOL: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.flag, &m, PMIX_BOOL))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.flag, &m, PMIX_BOOL))) { return ret; } break; case PMIX_BYTE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.byte, &m, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.byte, &m, PMIX_BYTE))) { return ret; } break; case PMIX_STRING: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.string, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.string, &m, PMIX_STRING))) { return ret; } break; case PMIX_SIZE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.size, &m, PMIX_SIZE))) { return ret; } break; case PMIX_PID: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.pid, &m, PMIX_PID))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.pid, &m, PMIX_PID))) { return ret; } break; case PMIX_INT: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.integer, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.integer, &m, PMIX_INT))) { return ret; } break; case PMIX_INT8: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.int8, &m, PMIX_INT8))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.int8, &m, PMIX_INT8))) { return ret; } break; case PMIX_INT16: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.int16, &m, PMIX_INT16))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.int16, &m, PMIX_INT16))) { return ret; } break; case PMIX_INT32: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.int32, &m, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.int32, &m, PMIX_INT32))) { return ret; } break; case PMIX_INT64: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.int64, &m, PMIX_INT64))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.int64, &m, PMIX_INT64))) { return ret; } break; case PMIX_UINT: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.uint, &m, PMIX_UINT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint, &m, PMIX_UINT))) { return ret; } break; case PMIX_UINT8: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.uint8, &m, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint8, &m, PMIX_UINT8))) { return ret; } break; case PMIX_UINT16: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.uint16, &m, PMIX_UINT16))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint16, &m, PMIX_UINT16))) { return ret; } break; case PMIX_UINT32: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.uint32, &m, PMIX_UINT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint32, &m, PMIX_UINT32))) { return ret; } break; case PMIX_UINT64: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.uint64, &m, PMIX_UINT64))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.uint64, &m, PMIX_UINT64))) { return ret; } break; case PMIX_FLOAT: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.fval, &m, PMIX_FLOAT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.fval, &m, PMIX_FLOAT))) { return ret; } break; case PMIX_DOUBLE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.dval, &m, PMIX_DOUBLE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.dval, &m, PMIX_DOUBLE))) { return ret; } break; case PMIX_TIMEVAL: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.tv, &m, PMIX_TIMEVAL))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.tv, &m, PMIX_TIMEVAL))) { return ret; } break; case PMIX_TIME: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.time, &m, PMIX_TIME))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.time, &m, PMIX_TIME))) { return ret; } break; case PMIX_STATUS: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.status, &m, PMIX_STATUS))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.status, &m, PMIX_STATUS))) { return ret; } break; @@ -689,43 +679,43 @@ pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, if (NULL == val->data.proc) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, val->data.proc, &m, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, val->data.proc, &m, PMIX_PROC))) { return ret; } break; case PMIX_PROC_RANK: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.rank, &m, PMIX_PROC_RANK))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.rank, &m, PMIX_PROC_RANK))) { return ret; } break; case PMIX_BYTE_OBJECT: case PMIX_COMPRESSED_STRING: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.bo, &m, PMIX_BYTE_OBJECT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.bo, &m, PMIX_BYTE_OBJECT))) { return ret; } break; case PMIX_PERSIST: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.proc, &m, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.proc, &m, PMIX_PROC))) { return ret; } break; case PMIX_POINTER: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.ptr, &m, PMIX_POINTER))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.ptr, &m, PMIX_POINTER))) { return ret; } break; case PMIX_SCOPE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.scope, &m, PMIX_SCOPE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.scope, &m, PMIX_SCOPE))) { return ret; } break; case PMIX_DATA_RANGE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.range, &m, PMIX_DATA_RANGE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.range, &m, PMIX_DATA_RANGE))) { return ret; } break; case PMIX_PROC_STATE: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.state, &m, PMIX_PROC_STATE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.state, &m, PMIX_PROC_STATE))) { return ret; } break; @@ -735,7 +725,7 @@ pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, if (NULL == val->data.pinfo) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, val->data.pinfo, &m, PMIX_PROC_INFO))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, val->data.pinfo, &m, PMIX_PROC_INFO))) { return ret; } break; @@ -745,12 +735,12 @@ pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, if (NULL == val->data.darray) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, val->data.darray, &m, PMIX_DATA_ARRAY))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, val->data.darray, &m, PMIX_DATA_ARRAY))) { return ret; } break; case PMIX_QUERY: - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, val->data.darray, &m, PMIX_QUERY))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, val->data.darray, &m, PMIX_QUERY))) { return ret; } break; @@ -762,7 +752,7 @@ pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, val->data.darray->type = PMIX_INFO_ARRAY; val->data.darray->size = m; /* unpack into it */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, &val->data.darray->array, &m, PMIX_INFO_ARRAY))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, &val->data.darray->array, &m, PMIX_INFO_ARRAY))) { return ret; } break; @@ -775,8 +765,9 @@ pmix_status_t pmix20_bfrop_unpack_status(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_value(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_value(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_value_t *ptr; int32_t i, n; @@ -787,19 +778,20 @@ pmix_status_t pmix20_bfrop_unpack_value(pmix_buffer_t *buffer, void *dest, for (i = 0; i < n; ++i) { /* unpack the type */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_get_data_type(buffer, &ptr[i].type))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_get_data_type(regtypes, buffer, &ptr[i].type))) { return ret; } /* unpack value */ - if (PMIX_SUCCESS != (ret = unpack_val(buffer, &ptr[i])) ) { + if (PMIX_SUCCESS != (ret = unpack_val(regtypes, buffer, &ptr[i])) ) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_info(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_info_t *ptr; int32_t i, n, m; @@ -818,7 +810,7 @@ pmix_status_t pmix20_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, /* unpack key */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { PMIX_ERROR_LOG(ret); return ret; } @@ -830,7 +822,7 @@ pmix_status_t pmix20_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, free(tmp); /* unpack the flags */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_infodirs(buffer, &ptr[i].flags, &m, PMIX_INFO_DIRECTIVES))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_infodirs(regtypes, buffer, &ptr[i].flags, &m, PMIX_INFO_DIRECTIVES))) { PMIX_ERROR_LOG(ret); return ret; } @@ -838,14 +830,14 @@ pmix_status_t pmix20_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, * instead of a pointer in this struct, we directly unpack it to * avoid the malloc */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int(buffer, &ptr[i].value.type, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int(regtypes, buffer, &ptr[i].value.type, &m, PMIX_INT))) { PMIX_ERROR_LOG(ret); return ret; } pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix20_bfrop_unpack: info type %d", ptr[i].value.type); m=1; - if (PMIX_SUCCESS != (ret = unpack_val(buffer, &ptr[i].value))) { + if (PMIX_SUCCESS != (ret = unpack_val(regtypes, buffer, &ptr[i].value))) { PMIX_ERROR_LOG(ret); return ret; } @@ -853,8 +845,9 @@ pmix_status_t pmix20_bfrop_unpack_info(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_pdata(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_pdata_t *ptr; int32_t i, n, m; @@ -871,13 +864,13 @@ pmix_status_t pmix20_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, PMIX_PDATA_CONSTRUCT(&ptr[i]); /* unpack the proc */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_proc(buffer, &ptr[i].proc, &m, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_proc(regtypes, buffer, &ptr[i].proc, &m, PMIX_PROC))) { return ret; } /* unpack key */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -889,21 +882,22 @@ pmix_status_t pmix20_bfrop_unpack_pdata(pmix_buffer_t *buffer, void *dest, * instead of a pointer in this struct, we directly unpack it to * avoid the malloc */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int(buffer, &ptr[i].value.type, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int(regtypes, buffer, &ptr[i].value.type, &m, PMIX_INT))) { return ret; } pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output, "pmix20_bfrop_unpack: pdata type %d", ptr[i].value.type); m=1; - if (PMIX_SUCCESS != (ret = unpack_val(buffer, &ptr[i].value))) { + if (PMIX_SUCCESS != (ret = unpack_val(regtypes, buffer, &ptr[i].value))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_buf(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_buffer_t *ptr; int32_t i, n, m; @@ -916,7 +910,7 @@ pmix_status_t pmix20_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, for (i = 0; i < n; ++i) { /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(buffer, &nbytes, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(regtypes, buffer, &nbytes, &m, PMIX_SIZE))) { return ret; } m = nbytes; @@ -924,7 +918,7 @@ pmix_status_t pmix20_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, if (0 < nbytes) { ptr[i].base_ptr = (char*)malloc(nbytes); /* unpack the bytes */ - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_byte(buffer, ptr[i].base_ptr, &m, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_byte(regtypes, buffer, ptr[i].base_ptr, &m, PMIX_BYTE))) { return ret; } } @@ -936,8 +930,9 @@ pmix_status_t pmix20_bfrop_unpack_buf(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_proc(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_proc_t *ptr; int32_t i, n, m; @@ -957,7 +952,7 @@ pmix_status_t pmix20_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, /* unpack nspace */ m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -967,15 +962,16 @@ pmix_status_t pmix20_bfrop_unpack_proc(pmix_buffer_t *buffer, void *dest, free(tmp); /* unpack the rank */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_rank(buffer, &ptr[i].rank, &m, PMIX_PROC_RANK))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_rank(regtypes, buffer, &ptr[i].rank, &m, PMIX_PROC_RANK))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_app(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_app_t *ptr; int32_t i, k, n, m; @@ -994,19 +990,19 @@ pmix_status_t pmix20_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, PMIX_APP_CONSTRUCT(&ptr[i]); /* unpack cmd */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &ptr[i].cmd, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &ptr[i].cmd, &m, PMIX_STRING))) { return ret; } /* unpack argc */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int(buffer, &nval, &m, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int(regtypes, buffer, &nval, &m, PMIX_INT32))) { return ret; } /* unpack argv */ for (k=0; k < nval; k++) { m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -1017,13 +1013,13 @@ pmix_status_t pmix20_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, } /* unpack env */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int32(buffer, &nval, &m, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int32(regtypes, buffer, &nval, &m, PMIX_INT32))) { return ret; } for (k=0; k < nval; k++) { m=1; tmp = NULL; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &tmp, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &tmp, &m, PMIX_STRING))) { return ret; } if (NULL == tmp) { @@ -1034,23 +1030,23 @@ pmix_status_t pmix20_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, } /* unpack cwd */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &ptr[i].cwd, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &ptr[i].cwd, &m, PMIX_STRING))) { return ret; } /* unpack maxprocs */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int(buffer, &ptr[i].maxprocs, &m, PMIX_INT))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int(regtypes, buffer, &ptr[i].maxprocs, &m, PMIX_INT))) { return ret; } /* unpack info array */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(buffer, &ptr[i].ninfo, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].ninfo, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].ninfo) { PMIX_INFO_CREATE(ptr[i].info, ptr[i].ninfo); m = ptr[i].ninfo; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_info(buffer, ptr[i].info, &m, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_info(regtypes, buffer, ptr[i].info, &m, PMIX_INFO))) { return ret; } } @@ -1058,8 +1054,9 @@ pmix_status_t pmix20_bfrop_unpack_app(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_kval(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_kval_t *ptr; int32_t i, n, m; @@ -1075,7 +1072,7 @@ pmix_status_t pmix20_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, PMIX_CONSTRUCT(&ptr[i], pmix_kval_t); /* unpack the key */ m = 1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &ptr[i].key, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &ptr[i].key, &m, PMIX_STRING))) { PMIX_ERROR_LOG(ret); return ret; } @@ -1083,7 +1080,7 @@ pmix_status_t pmix20_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, ptr[i].value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); /* unpack the value */ m = 1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_value(buffer, ptr[i].value, &m, PMIX_VALUE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_value(regtypes, buffer, ptr[i].value, &m, PMIX_VALUE))) { PMIX_ERROR_LOG(ret); return ret; } @@ -1091,8 +1088,9 @@ pmix_status_t pmix20_bfrop_unpack_kval(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_modex_data_t *ptr; int32_t i, n, m; @@ -1108,13 +1106,13 @@ pmix_status_t pmix20_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_modex_data_t)); /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].blob = (uint8_t*)malloc(ptr[i].size * sizeof(uint8_t)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_byte(buffer, ptr[i].blob, &m, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_byte(regtypes, buffer, ptr[i].blob, &m, PMIX_UINT8))) { return ret; } } @@ -1122,38 +1120,44 @@ pmix_status_t pmix20_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_persist(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix20_bfrop_unpack_persist(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) +{ + return pmix20_bfrop_unpack_byte(regtypes, buffer, dest, num_vals, PMIX_UINT8); +} + +pmix_status_t pmix20_bfrop_unpack_scope(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix20_bfrop_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + return pmix20_bfrop_unpack_byte(regtypes, buffer, dest, num_vals, PMIX_UINT8); } -pmix_status_t pmix20_bfrop_unpack_scope(pmix_buffer_t *buffer, void *dest, +pmix_status_t pmix20_bfrop_unpack_range(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) +{ + return pmix20_bfrop_unpack_byte(regtypes, buffer, dest, num_vals, PMIX_UINT8); +} + +pmix_status_t pmix20_bfrop_unpack_cmd(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { - return pmix20_bfrop_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + return pmix20_bfrop_unpack_byte(regtypes, buffer, dest, num_vals, PMIX_UINT8); } -pmix_status_t pmix20_bfrop_unpack_range(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_infodirs(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { - return pmix20_bfrop_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + return pmix20_bfrop_unpack_int32(regtypes, buffer, dest, num_vals, PMIX_UINT32); } -pmix_status_t pmix20_bfrop_unpack_cmd(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) -{ - return pmix20_bfrop_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); -} - -pmix_status_t pmix20_bfrop_unpack_infodirs(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) -{ - return pmix20_bfrop_unpack_int32(buffer, dest, num_vals, PMIX_UINT32); -} - -pmix_status_t pmix20_bfrop_unpack_bo(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_bo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_byte_object_t *ptr; int32_t i, n, m; @@ -1169,13 +1173,13 @@ pmix_status_t pmix20_bfrop_unpack_bo(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_byte_object_t)); /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].bytes = (char*)malloc(ptr[i].size * sizeof(char)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_byte(buffer, ptr[i].bytes, &m, PMIX_BYTE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_byte(regtypes, buffer, ptr[i].bytes, &m, PMIX_BYTE))) { return ret; } } @@ -1183,26 +1187,29 @@ pmix_status_t pmix20_bfrop_unpack_bo(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_ptr(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_ptr(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { uint8_t foo=1; int32_t cnt=1; /* it obviously makes no sense to pack a pointer and * send it somewhere else, so we just unpack the sentinel */ - return pmix20_bfrop_unpack_byte(buffer, &foo, &cnt, PMIX_UINT8); + return pmix20_bfrop_unpack_byte(regtypes, buffer, &foo, &cnt, PMIX_UINT8); } -pmix_status_t pmix20_bfrop_unpack_pstate(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_pstate(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { - return pmix20_bfrop_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + return pmix20_bfrop_unpack_byte(regtypes, buffer, dest, num_vals, PMIX_UINT8); } -pmix_status_t pmix20_bfrop_unpack_pinfo(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_pinfo(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_proc_info_t *ptr; int32_t i, n, m; @@ -1218,35 +1225,36 @@ pmix_status_t pmix20_bfrop_unpack_pinfo(pmix_buffer_t *buffer, void *dest, PMIX_PROC_INFO_CONSTRUCT(&ptr[i]); /* unpack the proc */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_proc(buffer, &ptr[i].proc, &m, PMIX_PROC))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_proc(regtypes, buffer, &ptr[i].proc, &m, PMIX_PROC))) { return ret; } /* unpack the hostname */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &ptr[i].hostname, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &ptr[i].hostname, &m, PMIX_STRING))) { return ret; } /* unpack the executable */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, &ptr[i].executable_name, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, &ptr[i].executable_name, &m, PMIX_STRING))) { return ret; } /* unpack pid */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_pid(buffer, &ptr[i].pid, &m, PMIX_PID))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_pid(regtypes, buffer, &ptr[i].pid, &m, PMIX_PID))) { return ret; } /* unpack state */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_pstate(buffer, &ptr[i].state, &m, PMIX_PROC_STATE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_pstate(regtypes, buffer, &ptr[i].state, &m, PMIX_PROC_STATE))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_darray(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_darray(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_data_array_t *ptr; int32_t i, n, m; @@ -1263,12 +1271,12 @@ pmix_status_t pmix20_bfrop_unpack_darray(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_data_array_t)); /* unpack the type */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_datatype(buffer, &ptr[i].type, &m, PMIX_DATA_TYPE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_datatype(regtypes, buffer, &ptr[i].type, &m, PMIX_DATA_TYPE))) { return ret; } /* unpack the number of array elements */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 == ptr[i].size || PMIX_UNDEF == ptr[i].type) { @@ -1359,21 +1367,23 @@ pmix_status_t pmix20_bfrop_unpack_darray(pmix_buffer_t *buffer, void *dest, if (NULL == (ptr[i].array = malloc(m * nbytes))) { return PMIX_ERR_NOMEM; } - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(buffer, ptr[i].array, &m, ptr[i].type))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_buffer(regtypes, buffer, ptr[i].array, &m, ptr[i].type))) { return ret; } } return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_rank(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_rank(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { - return pmix20_bfrop_unpack_int32(buffer, dest, num_vals, PMIX_UINT32); + return pmix20_bfrop_unpack_int32(regtypes, buffer, dest, num_vals, PMIX_UINT32); } -pmix_status_t pmix20_bfrop_unpack_query(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_query(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_query_t *ptr; int32_t i, n, m; @@ -1390,7 +1400,7 @@ pmix_status_t pmix20_bfrop_unpack_query(pmix_buffer_t *buffer, void *dest, PMIX_QUERY_CONSTRUCT(&ptr[i]); /* unpack the number of keys */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int32(buffer, &nkeys, &m, PMIX_INT32))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_int32(regtypes, buffer, &nkeys, &m, PMIX_INT32))) { return ret; } if (0 < nkeys) { @@ -1400,20 +1410,20 @@ pmix_status_t pmix20_bfrop_unpack_query(pmix_buffer_t *buffer, void *dest, } /* unpack keys */ m=nkeys; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(buffer, ptr[i].keys, &m, PMIX_STRING))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_string(regtypes, buffer, ptr[i].keys, &m, PMIX_STRING))) { return ret; } } /* unpack the number of qualifiers */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(buffer, &ptr[i].nqual, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].nqual, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].nqual) { /* unpack the qualifiers */ PMIX_INFO_CREATE(ptr[i].qualifiers, ptr[i].nqual); m = ptr[i].nqual; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_info(buffer, ptr[i].qualifiers, &m, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_info(regtypes, buffer, ptr[i].qualifiers, &m, PMIX_INFO))) { return ret; } } @@ -1421,16 +1431,18 @@ pmix_status_t pmix20_bfrop_unpack_query(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -pmix_status_t pmix20_bfrop_unpack_alloc_directive(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_alloc_directive(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { - return pmix20_bfrop_unpack_byte(buffer, dest, num_vals, PMIX_UINT8); + return pmix20_bfrop_unpack_byte(regtypes, buffer, dest, num_vals, PMIX_UINT8); } /**** DEPRECATED ****/ -pmix_status_t pmix20_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +pmix_status_t pmix20_bfrop_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_info_array_t *ptr; int32_t i, n, m; @@ -1448,13 +1460,13 @@ pmix_status_t pmix20_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_info_array_t)); /* unpack the size of this array */ m=1; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].array = (pmix_info_t*)malloc(ptr[i].size * sizeof(pmix_info_t)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_value(buffer, ptr[i].array, &m, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix20_bfrop_unpack_value(regtypes, buffer, ptr[i].array, &m, PMIX_INFO))) { return ret; } } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v21/bfrop_pmix21.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v21/bfrop_pmix21.c index 8100b70ed6..a3ae3ffc50 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v21/bfrop_pmix21.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v21/bfrop_pmix21.c @@ -14,6 +14,8 @@ * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -75,14 +77,18 @@ typedef struct pmix_modex_data { size_t size; } pmix_modex_data_t; -static pmix_status_t pmix21_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, +static pmix_status_t pmix21_bfrop_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -static pmix_status_t pmix21_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, +static pmix_status_t pmix21_bfrop_pack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -static pmix_status_t pmix21_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, +static pmix_status_t pmix21_bfrop_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +static pmix_status_t pmix21_bfrop_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -static pmix_status_t pmix21_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type); static pmix_status_t pmix21_bfrop_copy_array(pmix_info_array_t **dest, pmix_info_array_t *src, pmix_data_type_t type); @@ -479,7 +485,8 @@ static const char* data_type_string(pmix_data_type_t type) } /**** DEPRECATED ****/ -static pmix_status_t pmix21_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, +static pmix_status_t pmix21_bfrop_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_info_array_t *ptr; @@ -490,12 +497,12 @@ static pmix_status_t pmix21_bfrop_pack_array(pmix_buffer_t *buffer, const void * for (i = 0; i < num_vals; ++i) { /* pack the size */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &ptr[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { /* pack the values */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(regtypes, buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) { return ret; } } @@ -504,8 +511,9 @@ static pmix_status_t pmix21_bfrop_pack_array(pmix_buffer_t *buffer, const void * return PMIX_SUCCESS; } -static pmix_status_t pmix21_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, - int32_t num_vals, pmix_data_type_t type) +static pmix_status_t pmix21_bfrop_pack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, + int32_t num_vals, pmix_data_type_t type) { pmix_modex_data_t *ptr; int32_t i; @@ -514,11 +522,11 @@ static pmix_status_t pmix21_bfrop_pack_modex(pmix_buffer_t *buffer, const void * ptr = (pmix_modex_data_t *) src; for (i = 0; i < num_vals; ++i) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &ptr[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) { return ret; } if( 0 < ptr[i].size){ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(regtypes, buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) { return ret; } } @@ -529,7 +537,8 @@ static pmix_status_t pmix21_bfrop_pack_modex(pmix_buffer_t *buffer, const void * /********************/ /**** DEPRECATED ****/ -static pmix_status_t pmix21_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, +static pmix_status_t pmix21_bfrop_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_info_array_t *ptr; @@ -548,13 +557,15 @@ static pmix_status_t pmix21_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest memset(&ptr[i], 0, sizeof(pmix_info_array_t)); /* unpack the size of this array */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(regtypes, buffer, + &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].array = (pmix_info_t*)malloc(ptr[i].size * sizeof(pmix_info_t)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_value(buffer, ptr[i].array, &m, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_value(regtypes, buffer, + ptr[i].array, &m, PMIX_INFO))) { return ret; } } @@ -562,8 +573,9 @@ static pmix_status_t pmix21_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest return PMIX_SUCCESS; } -static pmix_status_t pmix21_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, - int32_t *num_vals, pmix_data_type_t type) +static pmix_status_t pmix21_bfrop_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) { pmix_modex_data_t *ptr; int32_t i, n, m; @@ -579,13 +591,13 @@ static pmix_status_t pmix21_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest memset(&ptr[i], 0, sizeof(pmix_modex_data_t)); /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].blob = (uint8_t*)malloc(ptr[i].size * sizeof(uint8_t)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, ptr[i].blob, &m, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(regtypes, buffer, ptr[i].blob, &m, PMIX_UINT8))) { return ret; } } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v3/bfrop_pmix3.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v3/bfrop_pmix3.c index eac138a80d..c9c33e8deb 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v3/bfrop_pmix3.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v3/bfrop_pmix3.c @@ -14,6 +14,8 @@ * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -75,13 +77,17 @@ typedef struct pmix_modex_data { size_t size; } pmix_modex_data_t; -static pmix_status_t pmix3_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, +static pmix_status_t pmix3_bfrop_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -static pmix_status_t pmix3_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, +static pmix_status_t pmix3_bfrop_pack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type); -static pmix_status_t pmix3_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, +static pmix_status_t pmix3_bfrop_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); -static pmix_status_t pmix3_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, +static pmix_status_t pmix3_bfrop_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type); static pmix_status_t pmix3_bfrop_copy_array(pmix_info_array_t **dest, pmix_info_array_t *src, @@ -495,7 +501,8 @@ static const char* data_type_string(pmix_data_type_t type) } /**** DEPRECATED ****/ -static pmix_status_t pmix3_bfrop_pack_array(pmix_buffer_t *buffer, const void *src, +static pmix_status_t pmix3_bfrop_pack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_info_array_t *ptr; @@ -506,12 +513,12 @@ static pmix_status_t pmix3_bfrop_pack_array(pmix_buffer_t *buffer, const void *s for (i = 0; i < num_vals; ++i) { /* pack the size */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &ptr[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { /* pack the values */ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(regtypes, buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) { return ret; } } @@ -520,7 +527,8 @@ static pmix_status_t pmix3_bfrop_pack_array(pmix_buffer_t *buffer, const void *s return PMIX_SUCCESS; } -static pmix_status_t pmix3_bfrop_pack_modex(pmix_buffer_t *buffer, const void *src, +static pmix_status_t pmix3_bfrop_pack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, const void *src, int32_t num_vals, pmix_data_type_t type) { pmix_modex_data_t *ptr; @@ -530,11 +538,11 @@ static pmix_status_t pmix3_bfrop_pack_modex(pmix_buffer_t *buffer, const void *s ptr = (pmix_modex_data_t *) src; for (i = 0; i < num_vals; ++i) { - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(buffer, &ptr[i].size, 1, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) { return ret; } if( 0 < ptr[i].size){ - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(regtypes, buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) { return ret; } } @@ -546,7 +554,8 @@ static pmix_status_t pmix3_bfrop_pack_modex(pmix_buffer_t *buffer, const void *s /********************/ /**** DEPRECATED ****/ -static pmix_status_t pmix3_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, +static pmix_status_t pmix3_bfrop_unpack_array(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_info_array_t *ptr; @@ -565,13 +574,13 @@ static pmix_status_t pmix3_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_info_array_t)); /* unpack the size of this array */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].array = (pmix_info_t*)malloc(ptr[i].size * sizeof(pmix_info_t)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_value(buffer, ptr[i].array, &m, PMIX_INFO))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_value(regtypes, buffer, ptr[i].array, &m, PMIX_INFO))) { return ret; } } @@ -579,7 +588,8 @@ static pmix_status_t pmix3_bfrop_unpack_array(pmix_buffer_t *buffer, void *dest, return PMIX_SUCCESS; } -static pmix_status_t pmix3_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, +static pmix_status_t pmix3_bfrop_unpack_modex(pmix_pointer_array_t *regtypes, + pmix_buffer_t *buffer, void *dest, int32_t *num_vals, pmix_data_type_t type) { pmix_modex_data_t *ptr; @@ -596,13 +606,13 @@ static pmix_status_t pmix3_bfrop_unpack_modex(pmix_buffer_t *buffer, void *dest, memset(&ptr[i], 0, sizeof(pmix_modex_data_t)); /* unpack the number of bytes */ m=1; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(buffer, &ptr[i].size, &m, PMIX_SIZE))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) { return ret; } if (0 < ptr[i].size) { ptr[i].blob = (uint8_t*)malloc(ptr[i].size * sizeof(uint8_t)); m=ptr[i].size; - if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(buffer, ptr[i].blob, &m, PMIX_UINT8))) { + if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(regtypes, buffer, ptr[i].blob, &m, PMIX_UINT8))) { return ret; } } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/Makefile.am b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/Makefile.am new file mode 100644 index 0000000000..997fd20dd5 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/Makefile.am @@ -0,0 +1,50 @@ +# -*- 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) 2013-2019 Intel, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +headers = bfrop_pmix4.h +sources = \ + bfrop_pmix4_component.c \ + bfrop_pmix4.c + +# Make the output library in this directory, and name it either +# mca__.la (for DSO builds) or libmca__.la +# (for static builds). + +if MCA_BUILD_pmix_bfrops_v4_DSO +lib = +lib_sources = +component = mca_bfrops_v4.la +component_sources = $(headers) $(sources) +else +lib = libmca_bfrops_v4.la +lib_sources = $(headers) $(sources) +component = +component_sources = +endif + +mcacomponentdir = $(pmixlibdir) +mcacomponent_LTLIBRARIES = $(component) +mca_bfrops_v4_la_SOURCES = $(component_sources) +mca_bfrops_v4_la_LDFLAGS = -module -avoid-version + +noinst_LTLIBRARIES = $(lib) +libmca_bfrops_v4_la_SOURCES = $(lib_sources) +libmca_bfrops_v4_la_LDFLAGS = -module -avoid-version diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4.c new file mode 100644 index 0000000000..87e3e66b30 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4.c @@ -0,0 +1,463 @@ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved. + * Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2011-2014 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + */ + +#include + +#include "src/mca/bfrops/base/base.h" +#include "bfrop_pmix4.h" + +static pmix_status_t init(void); +static void finalize(void); +static pmix_status_t pmix4_pack(pmix_buffer_t *buffer, + const void *src, int num_vals, + pmix_data_type_t type); +static pmix_status_t pmix4_unpack(pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type); +static pmix_status_t pmix4_copy(void **dest, void *src, + pmix_data_type_t type); +static pmix_status_t pmix4_print(char **output, char *prefix, + void *src, pmix_data_type_t type); +static pmix_status_t register_type(const char *name, + pmix_data_type_t type, + pmix_bfrop_pack_fn_t pack, + pmix_bfrop_unpack_fn_t unpack, + pmix_bfrop_copy_fn_t copy, + pmix_bfrop_print_fn_t print); +static const char* data_type_string(pmix_data_type_t type); + +pmix_bfrops_module_t pmix_bfrops_pmix4_module = { + .version = "v4", + .init = init, + .finalize = finalize, + .pack = pmix4_pack, + .unpack = pmix4_unpack, + .copy = pmix4_copy, + .print = pmix4_print, + .copy_payload = pmix_bfrops_base_copy_payload, + .value_xfer = pmix_bfrops_base_value_xfer, + .value_load = pmix_bfrops_base_value_load, + .value_unload = pmix_bfrops_base_value_unload, + .value_cmp = pmix_bfrops_base_value_cmp, + .register_type = register_type, + .data_type_string = data_type_string +}; + +static pmix_status_t init(void) +{ + /* some standard types don't require anything special */ + PMIX_REGISTER_TYPE("PMIX_BOOL", PMIX_BOOL, + pmix_bfrops_base_pack_bool, + pmix_bfrops_base_unpack_bool, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_bool, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_BYTE", PMIX_BYTE, + pmix_bfrops_base_pack_byte, + pmix_bfrops_base_unpack_byte, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_byte, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_STRING", PMIX_STRING, + pmix_bfrops_base_pack_string, + pmix_bfrops_base_unpack_string, + pmix_bfrops_base_copy_string, + pmix_bfrops_base_print_string, + &mca_bfrops_v4_component.types); + + /* Register the rest of the standard generic types to point to internal functions */ + PMIX_REGISTER_TYPE("PMIX_SIZE", PMIX_SIZE, + pmix_bfrops_base_pack_sizet, + pmix_bfrops_base_unpack_sizet, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_size, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_PID", PMIX_PID, + pmix_bfrops_base_pack_pid, + pmix_bfrops_base_unpack_pid, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_pid, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_INT", PMIX_INT, + pmix_bfrops_base_pack_int, + pmix_bfrops_base_unpack_int, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_int, + &mca_bfrops_v4_component.types); + + /* Register all the standard fixed types to point to base functions */ + PMIX_REGISTER_TYPE("PMIX_INT8", PMIX_INT8, + pmix_bfrops_base_pack_byte, + pmix_bfrops_base_unpack_byte, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_int8, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_INT16", PMIX_INT16, + pmix_bfrops_base_pack_int16, + pmix_bfrops_base_unpack_int16, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_int16, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_INT32", PMIX_INT32, + pmix_bfrops_base_pack_int32, + pmix_bfrops_base_unpack_int32, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_int32, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_INT64", PMIX_INT64, + pmix_bfrops_base_pack_int64, + pmix_bfrops_base_unpack_int64, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_int64, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_UINT", PMIX_UINT, + pmix_bfrops_base_pack_int, + pmix_bfrops_base_unpack_int, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_uint, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_UINT8", PMIX_UINT8, + pmix_bfrops_base_pack_byte, + pmix_bfrops_base_unpack_byte, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_uint8, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_UINT16", PMIX_UINT16, + pmix_bfrops_base_pack_int16, + pmix_bfrops_base_unpack_int16, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_uint16, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_UINT32", PMIX_UINT32, + pmix_bfrops_base_pack_int32, + pmix_bfrops_base_unpack_int32, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_uint32, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_UINT64", PMIX_UINT64, + pmix_bfrops_base_pack_int64, + pmix_bfrops_base_unpack_int64, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_uint64, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_FLOAT", PMIX_FLOAT, + pmix_bfrops_base_pack_float, + pmix_bfrops_base_unpack_float, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_float, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_DOUBLE", PMIX_DOUBLE, + pmix_bfrops_base_pack_double, + pmix_bfrops_base_unpack_double, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_double, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_TIMEVAL", PMIX_TIMEVAL, + pmix_bfrops_base_pack_timeval, + pmix_bfrops_base_unpack_timeval, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_timeval, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_TIME", PMIX_TIME, + pmix_bfrops_base_pack_time, + pmix_bfrops_base_unpack_time, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_time, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_STATUS", PMIX_STATUS, + pmix_bfrops_base_pack_status, + pmix_bfrops_base_unpack_status, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_status, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_VALUE", PMIX_VALUE, + pmix_bfrops_base_pack_value, + pmix_bfrops_base_unpack_value, + pmix_bfrops_base_copy_value, + pmix_bfrops_base_print_value, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_PROC", PMIX_PROC, + pmix_bfrops_base_pack_proc, + pmix_bfrops_base_unpack_proc, + pmix_bfrops_base_copy_proc, + pmix_bfrops_base_print_proc, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_APP", PMIX_APP, + pmix_bfrops_base_pack_app, + pmix_bfrops_base_unpack_app, + pmix_bfrops_base_copy_app, + pmix_bfrops_base_print_app, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_INFO", PMIX_INFO, + pmix_bfrops_base_pack_info, + pmix_bfrops_base_unpack_info, + pmix_bfrops_base_copy_info, + pmix_bfrops_base_print_info, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_PDATA", PMIX_PDATA, + pmix_bfrops_base_pack_pdata, + pmix_bfrops_base_unpack_pdata, + pmix_bfrops_base_copy_pdata, + pmix_bfrops_base_print_pdata, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_BUFFER", PMIX_BUFFER, + pmix_bfrops_base_pack_buf, + pmix_bfrops_base_unpack_buf, + pmix_bfrops_base_copy_buf, + pmix_bfrops_base_print_buf, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_BYTE_OBJECT", PMIX_BYTE_OBJECT, + pmix_bfrops_base_pack_bo, + pmix_bfrops_base_unpack_bo, + pmix_bfrops_base_copy_bo, + pmix_bfrops_base_print_bo, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_KVAL", PMIX_KVAL, + pmix_bfrops_base_pack_kval, + pmix_bfrops_base_unpack_kval, + pmix_bfrops_base_copy_kval, + pmix_bfrops_base_print_kval, + &mca_bfrops_v4_component.types); + + /* these are fixed-sized values and can be done by base */ + PMIX_REGISTER_TYPE("PMIX_PERSIST", PMIX_PERSIST, + pmix_bfrops_base_pack_persist, + pmix_bfrops_base_unpack_persist, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_persist, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_POINTER", PMIX_POINTER, + pmix_bfrops_base_pack_ptr, + pmix_bfrops_base_unpack_ptr, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_ptr, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_SCOPE", PMIX_SCOPE, + pmix_bfrops_base_pack_scope, + pmix_bfrops_base_unpack_scope, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_std_copy, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_DATA_RANGE", PMIX_DATA_RANGE, + pmix_bfrops_base_pack_range, + pmix_bfrops_base_unpack_range, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_ptr, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_COMMAND", PMIX_COMMAND, + pmix_bfrops_base_pack_cmd, + pmix_bfrops_base_unpack_cmd, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_cmd, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_INFO_DIRECTIVES", PMIX_INFO_DIRECTIVES, + pmix_bfrops_base_pack_info_directives, + pmix_bfrops_base_unpack_info_directives, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_info_directives, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_DATA_TYPE", PMIX_DATA_TYPE, + pmix_bfrops_base_pack_datatype, + pmix_bfrops_base_unpack_datatype, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_datatype, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_PROC_STATE", PMIX_PROC_STATE, + pmix_bfrops_base_pack_pstate, + pmix_bfrops_base_unpack_pstate, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_pstate, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_PROC_INFO", PMIX_PROC_INFO, + pmix_bfrops_base_pack_pinfo, + pmix_bfrops_base_unpack_pinfo, + pmix_bfrops_base_copy_pinfo, + pmix_bfrops_base_print_pinfo, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_DATA_ARRAY", PMIX_DATA_ARRAY, + pmix_bfrops_base_pack_darray, + pmix_bfrops_base_unpack_darray, + pmix_bfrops_base_copy_darray, + pmix_bfrops_base_print_darray, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_PROC_RANK", PMIX_PROC_RANK, + pmix_bfrops_base_pack_rank, + pmix_bfrops_base_unpack_rank, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_rank, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_QUERY", PMIX_QUERY, + pmix_bfrops_base_pack_query, + pmix_bfrops_base_unpack_query, + pmix_bfrops_base_copy_query, + pmix_bfrops_base_print_query, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_COMPRESSED_STRING", + PMIX_COMPRESSED_STRING, + pmix_bfrops_base_pack_bo, + pmix_bfrops_base_unpack_bo, + pmix_bfrops_base_copy_bo, + pmix_bfrops_base_print_bo, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_ALLOC_DIRECTIVE", + PMIX_ALLOC_DIRECTIVE, + pmix_bfrops_base_pack_alloc_directive, + pmix_bfrops_base_unpack_alloc_directive, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_alloc_directive, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_IOF_CHANNEL", + PMIX_IOF_CHANNEL, + pmix_bfrops_base_pack_iof_channel, + pmix_bfrops_base_unpack_iof_channel, + pmix_bfrops_base_std_copy, + pmix_bfrops_base_print_iof_channel, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_ENVAR", + PMIX_ENVAR, + pmix_bfrops_base_pack_envar, + pmix_bfrops_base_unpack_envar, + pmix_bfrops_base_copy_envar, + pmix_bfrops_base_print_envar, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_COORD", + PMIX_COORD, + pmix_bfrops_base_pack_coord, + pmix_bfrops_base_unpack_coord, + pmix_bfrops_base_copy_coord, + pmix_bfrops_base_print_coord, + &mca_bfrops_v4_component.types); + + PMIX_REGISTER_TYPE("PMIX_REGATTR", + PMIX_REGATTR, + pmix_bfrops_base_pack_regattr, + pmix_bfrops_base_unpack_regattr, + pmix_bfrops_base_copy_regattr, + pmix_bfrops_base_print_regattr, + &mca_bfrops_v4_component.types); + + return PMIX_SUCCESS; +} + +static void finalize(void) +{ + int n; + pmix_bfrop_type_info_t *info; + + for (n=0; n < mca_bfrops_v4_component.types.size; n++) { + if (NULL != (info = (pmix_bfrop_type_info_t*)pmix_pointer_array_get_item(&mca_bfrops_v4_component.types, n))) { + PMIX_RELEASE(info); + pmix_pointer_array_set_item(&mca_bfrops_v4_component.types, n, NULL); + } + } +} + +static pmix_status_t pmix4_pack(pmix_buffer_t *buffer, + const void *src, int num_vals, + pmix_data_type_t type) +{ + /* kick the process off by passing this in to the base */ + return pmix_bfrops_base_pack(&mca_bfrops_v4_component.types, + buffer, src, num_vals, type); +} + +static pmix_status_t pmix4_unpack(pmix_buffer_t *buffer, void *dest, + int32_t *num_vals, pmix_data_type_t type) +{ + /* kick the process off by passing this in to the base */ + return pmix_bfrops_base_unpack(&mca_bfrops_v4_component.types, + buffer, dest, num_vals, type); +} + +static pmix_status_t pmix4_copy(void **dest, void *src, + pmix_data_type_t type) +{ + return pmix_bfrops_base_copy(&mca_bfrops_v4_component.types, + dest, src, type); +} + +static pmix_status_t pmix4_print(char **output, char *prefix, + void *src, pmix_data_type_t type) +{ + return pmix_bfrops_base_print(&mca_bfrops_v4_component.types, + output, prefix, src, type); +} + +static pmix_status_t register_type(const char *name, pmix_data_type_t type, + pmix_bfrop_pack_fn_t pack, + pmix_bfrop_unpack_fn_t unpack, + pmix_bfrop_copy_fn_t copy, + pmix_bfrop_print_fn_t print) +{ + PMIX_REGISTER_TYPE(name, type, + pack, unpack, + copy, print, + &mca_bfrops_v4_component.types); + return PMIX_SUCCESS; +} + +static const char* data_type_string(pmix_data_type_t type) +{ + return pmix_bfrops_base_data_type_string(&mca_bfrops_v4_component.types, type); +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4.h b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4.h new file mode 100644 index 0000000000..0c41692cc7 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2004-2008 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) 2016-2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#ifndef PMIX_BFROPS_PMIX4_H +#define PMIX_BFROPS_PMIX4_H + +#include "src/mca/bfrops/bfrops.h" + +BEGIN_C_DECLS + +/* the component must be visible data for the linker to find it */ + PMIX_EXPORT extern pmix_bfrops_base_component_t mca_bfrops_v4_component; + +extern pmix_bfrops_module_t pmix_bfrops_pmix4_module; + +END_C_DECLS + +#endif /* PMIX_BFROPS_PMIX4_H */ diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4_component.c b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4_component.c new file mode 100644 index 0000000000..5067c40d24 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/v4/bfrop_pmix4_component.c @@ -0,0 +1,99 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennbfropsee and The University + * of Tennbfropsee 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) 2015 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + * These symbols are in a file by themselves to provide nice linker + * semantics. Since linkers generally pull in symbols by object + * files, keeping these symbols as the only symbols in this file + * prevents utility programs such as "ompi_info" from having to import + * entire components just to query their version and parameters. + */ + +#include +#include +#include "src/include/types.h" +#include "src/include/pmix_globals.h" + +#include "src/util/error.h" +#include "src/server/pmix_server_ops.h" +#include "src/mca/bfrops/base/base.h" +#include "bfrop_pmix4.h" + +extern pmix_bfrops_module_t pmix_bfrops_pmix4_module; + +static pmix_status_t component_open(void); +static pmix_status_t component_query(pmix_mca_base_module_t **module, int *priority); +static pmix_status_t component_close(void); +static pmix_bfrops_module_t* assign_module(void); + +/* + * Instantiate the public struct with all of our public information + * and pointers to our public functions in it + */ +pmix_bfrops_base_component_t mca_bfrops_v4_component = { + .base = { + PMIX_BFROPS_BASE_VERSION_1_0_0, + + /* Component name and version */ + .pmix_mca_component_name = "v4", + PMIX_MCA_BASE_MAKE_VERSION(component, PMIX_MAJOR_VERSION, PMIX_MINOR_VERSION, + PMIX_RELEASE_VERSION), + + /* Component open and close functions */ + .pmix_mca_open_component = component_open, + .pmix_mca_close_component = component_close, + .pmix_mca_query_component = component_query, + }, + .priority = 50, + .assign_module = assign_module +}; + + +pmix_status_t component_open(void) +{ + /* setup the types array */ + PMIX_CONSTRUCT(&mca_bfrops_v4_component.types, pmix_pointer_array_t); + pmix_pointer_array_init(&mca_bfrops_v4_component.types, 42, INT_MAX, 16); + + return PMIX_SUCCESS; +} + + +pmix_status_t component_query(pmix_mca_base_module_t **module, int *priority) +{ + + *priority = mca_bfrops_v4_component.priority; + *module = (pmix_mca_base_module_t *)&pmix_bfrops_pmix4_module; + return PMIX_SUCCESS; +} + + +pmix_status_t component_close(void) +{ + PMIX_DESTRUCT(&mca_bfrops_v4_component.types); + return PMIX_SUCCESS; +} + +static pmix_bfrops_module_t* assign_module(void) +{ + pmix_output_verbose(10, pmix_bfrops_base_framework.framework_output, + "bfrops:pmix4x assigning module"); + return &pmix_bfrops_pmix4_module; +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_base.c b/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_base.c index 5568c94347..143c84a761 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_base.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_base.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * Copyright (c) 2016-2018 IBM Corporation. All rights reserved. - * Copyright (c) 2016-2018 Mellanox Technologies, Inc. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2018-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -42,7 +42,7 @@ #include "src/client/pmix_client_ops.h" #include "src/server/pmix_server_ops.h" #include "src/util/argv.h" -#include "src/util/compress.h" +#include "src/mca/pcompress/pcompress.h" #include "src/util/error.h" #include "src/util/output.h" #include "src/util/pmix_environ.h" @@ -108,9 +108,8 @@ static inline pmix_peer_t * _client_peer(pmix_common_dstore_ctx_t *ds_ctx); static inline int _my_client(const char *nspace, pmix_rank_t rank); static pmix_status_t _dstor_store_modex_cb(pmix_common_dstore_ctx_t *ds_ctx, - struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_byte_object_t *bo); + pmix_proc_t *proc, + pmix_buffer_t *pbkt); static pmix_status_t _dstore_store_nolock(pmix_common_dstore_ctx_t *ds_ctx, ns_map_data_t *ns_map, @@ -2520,9 +2519,9 @@ static inline int _my_client(const char *nspace, pmix_rank_t rank) * always contains data solely from remote procs, and we * shall store it accordingly */ PMIX_EXPORT pmix_status_t pmix_common_dstor_store_modex(pmix_common_dstore_ctx_t *ds_ctx, - struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_buffer_t *buf) + struct pmix_namespace_t *nspace, + pmix_buffer_t *buf, + void *cbdata) { pmix_status_t rc = PMIX_SUCCESS; pmix_status_t rc1 = PMIX_SUCCESS; @@ -2542,7 +2541,9 @@ PMIX_EXPORT pmix_status_t pmix_common_dstor_store_modex(pmix_common_dstore_ctx_t return rc; } - rc = pmix_gds_base_store_modex(nspace, cbs, buf, (pmix_gds_base_store_modex_cb_fn_t)_dstor_store_modex_cb, ds_ctx); + rc = pmix_gds_base_store_modex(nspace, buf, ds_ctx, + (pmix_gds_base_store_modex_cb_fn_t)_dstor_store_modex_cb, + cbdata); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); } @@ -2560,15 +2561,11 @@ PMIX_EXPORT pmix_status_t pmix_common_dstor_store_modex(pmix_common_dstore_ctx_t } static pmix_status_t _dstor_store_modex_cb(pmix_common_dstore_ctx_t *ds_ctx, - struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_byte_object_t *bo) + pmix_proc_t *proc, + pmix_buffer_t *pbkt) { - pmix_namespace_t *ns = (pmix_namespace_t*)nspace; pmix_status_t rc = PMIX_SUCCESS; int32_t cnt; - pmix_buffer_t pbkt; - pmix_proc_t proc; pmix_kval_t *kv; ns_map_data_t *ns_map; pmix_buffer_t tmp; @@ -2576,7 +2573,7 @@ static pmix_status_t _dstor_store_modex_cb(pmix_common_dstore_ctx_t *ds_ctx, pmix_output_verbose(2, pmix_gds_base_framework.framework_output, "[%s:%d] gds:dstore:store_modex for nspace %s", pmix_globals.myid.nspace, pmix_globals.myid.rank, - ns->nspace); + proc->nspace); /* NOTE: THE BYTE OBJECT DELIVERED HERE WAS CONSTRUCTED * BY A SERVER, AND IS THEREFORE PACKED USING THE SERVER'S @@ -2588,28 +2585,8 @@ static pmix_status_t _dstor_store_modex_cb(pmix_common_dstore_ctx_t *ds_ctx, * the rank followed by pmix_kval_t's. The list of callbacks * contains all local participants. */ - /* setup the byte object for unpacking */ - PMIX_CONSTRUCT(&pbkt, pmix_buffer_t); - /* the next step unfortunately NULLs the byte object's - * entries, so we need to ensure we restore them! */ - PMIX_LOAD_BUFFER(pmix_globals.mypeer, &pbkt, bo->bytes, bo->size); - /* unload the proc that provided this data */ - cnt = 1; - PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, &pbkt, &proc, &cnt, PMIX_PROC); - if (PMIX_SUCCESS != rc) { - PMIX_ERROR_LOG(rc); - bo->bytes = pbkt.base_ptr; - bo->size = pbkt.bytes_used; // restore the incoming data - pbkt.base_ptr = NULL; - PMIX_DESTRUCT(&pbkt); - return rc; - } /* don't store blobs to the sm dstore from local clients */ - if (_my_client(proc.nspace, proc.rank)) { - bo->bytes = pbkt.base_ptr; - bo->size = pbkt.bytes_used; // restore the incoming data - pbkt.base_ptr = NULL; - PMIX_DESTRUCT(&pbkt); + if (_my_client(proc->nspace, proc->rank)) { return PMIX_SUCCESS; } @@ -2619,16 +2596,12 @@ static pmix_status_t _dstor_store_modex_cb(pmix_common_dstore_ctx_t *ds_ctx, /* unpack the remaining values until we hit the end of the buffer */ cnt = 1; kv = PMIX_NEW(pmix_kval_t); - PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, &pbkt, kv, &cnt, PMIX_KVAL); + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, pbkt, kv, &cnt, PMIX_KVAL); while (PMIX_SUCCESS == rc) { /* store this in the hash table */ - PMIX_GDS_STORE_KV(rc, pmix_globals.mypeer, &proc, PMIX_REMOTE, kv); + PMIX_GDS_STORE_KV(rc, pmix_globals.mypeer, proc, PMIX_REMOTE, kv); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); - bo->bytes = pbkt.base_ptr; - bo->size = pbkt.bytes_used; // restore the incoming data - pbkt.base_ptr = NULL; - PMIX_DESTRUCT(&pbkt); return rc; } @@ -2642,7 +2615,7 @@ static pmix_status_t _dstor_store_modex_cb(pmix_common_dstore_ctx_t *ds_ctx, /* proceed to the next element */ kv = PMIX_NEW(pmix_kval_t); cnt = 1; - PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, &pbkt, kv, &cnt, PMIX_KVAL); + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, pbkt, kv, &cnt, PMIX_KVAL); } /* Release the kv that didn't received the value @@ -2662,18 +2635,14 @@ static pmix_status_t _dstor_store_modex_cb(pmix_common_dstore_ctx_t *ds_ctx, PMIX_UNLOAD_BUFFER(&tmp, kv->value->data.bo.bytes, kv->value->data.bo.size); /* Get the namespace map element for the process "proc" */ - if (NULL == (ns_map = ds_ctx->session_map_search(ds_ctx, proc.nspace))) { + if (NULL == (ns_map = ds_ctx->session_map_search(ds_ctx, proc->nspace))) { rc = PMIX_ERROR; PMIX_ERROR_LOG(rc); - bo->bytes = pbkt.base_ptr; - bo->size = pbkt.bytes_used; // restore the incoming data - pbkt.base_ptr = NULL; - PMIX_DESTRUCT(&pbkt); return rc; } /* Store all keys at once */ - rc = _dstore_store_nolock(ds_ctx, ns_map, proc.rank, kv); + rc = _dstore_store_nolock(ds_ctx, ns_map, proc->rank, kv); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); } @@ -2682,12 +2651,6 @@ static pmix_status_t _dstor_store_modex_cb(pmix_common_dstore_ctx_t *ds_ctx, PMIX_RELEASE(kv); PMIX_DESTRUCT(&tmp); - /* Reset the input buffer */ - bo->bytes = pbkt.base_ptr; - bo->size = pbkt.bytes_used; - pbkt.base_ptr = NULL; - PMIX_DESTRUCT(&pbkt); - return rc; } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_common.h b/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_common.h index 446039abd7..a88418f148 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_common.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Mellanox Technologies, Inc. + * Copyright (c) 2018-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2018 Intel, Inc. All rights reserved. * Copyright (c) 2018 IBM Corporation. All rights reserved. @@ -75,6 +75,6 @@ PMIX_EXPORT pmix_status_t pmix_common_dstor_fetch(pmix_common_dstore_ctx_t *ds_c pmix_list_t *kvs); PMIX_EXPORT pmix_status_t pmix_common_dstor_store_modex(pmix_common_dstore_ctx_t *ds_ctx, struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_buffer_t *buff); + pmix_buffer_t *buff, + void *cbdata); #endif diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_segment.c b/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_segment.c index a219bed9c0..ca4ba76634 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_segment.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/common/dstore/dstore_segment.c @@ -3,7 +3,7 @@ * Copyright (c) 2016 IBM Corporation. All rights reserved. * Copyright (c) 2016-2017 Mellanox Technologies, Inc. * All rights reserved. - * Copyright (c) 2018 Research Organization for Information Science + * Copyright (c) 2018-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * * $COPYRIGHT$ @@ -30,6 +30,11 @@ #ifdef HAVE_SYS_AUXV_H #include +#if PMIX_HAVE_LIBEV +/* EV_NONE is macro-defined in that is included by + * and used in an enum in from libev, so #undef it to fix an issue*/ +#undef EV_NONE +#endif #endif #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/base.h b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/base.h index 242fc4dabd..a5d7953ec8 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/base.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/base.h @@ -15,6 +15,8 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2018 IBM Corporation. All rights reserved. + * Copyright (c) 2019 Mellanox Technologies, Inc. + * All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -77,11 +79,10 @@ struct pmix_gds_globals_t { }; typedef struct pmix_gds_globals_t pmix_gds_globals_t; -typedef void * pmix_gds_base_store_modex_cbdata_t; -typedef pmix_status_t (*pmix_gds_base_store_modex_cb_fn_t)(pmix_gds_base_store_modex_cbdata_t cbdata, - struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_byte_object_t *bo); +typedef void * pmix_gds_base_ctx_t; +typedef pmix_status_t (*pmix_gds_base_store_modex_cb_fn_t)(pmix_gds_base_ctx_t ctx, + pmix_proc_t *proc, + pmix_buffer_t *pbkt); PMIX_EXPORT extern pmix_gds_globals_t pmix_gds_globals; @@ -106,10 +107,10 @@ PMIX_EXPORT pmix_status_t pmix_gds_base_setup_fork(const pmix_proc_t *proc, char ***env); PMIX_EXPORT pmix_status_t pmix_gds_base_store_modex(struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_buffer_t *xfer, - pmix_gds_base_store_modex_cb_fn_t cb_fn, - pmix_gds_base_store_modex_cbdata_t cbdata); + pmix_buffer_t * buff, + pmix_gds_base_ctx_t ctx, + pmix_gds_base_store_modex_cb_fn_t cb_fn, + void *cbdata); END_C_DECLS diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/gds_base_fns.c b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/gds_base_fns.c index b9f8533c0e..2ac2692a15 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/gds_base_fns.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/base/gds_base_fns.c @@ -1,7 +1,7 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. - * Copyright (c) 2016 Mellanox Technologies, Inc. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2018 IBM Corporation. All rights reserved. * Copyright (c) 2018 Research Organization for Information Science @@ -24,6 +24,7 @@ #include "src/util/error.h" #include "src/mca/gds/base/base.h" +#include "src/server/pmix_server_ops.h" char* pmix_gds_base_get_available_modules(void) @@ -88,19 +89,24 @@ pmix_status_t pmix_gds_base_setup_fork(const pmix_proc_t *proc, } pmix_status_t pmix_gds_base_store_modex(struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_buffer_t * buff, - pmix_gds_base_store_modex_cb_fn_t cb_fn, - pmix_gds_base_store_modex_cbdata_t cbdata) + pmix_buffer_t * buff, + pmix_gds_base_ctx_t ctx, + pmix_gds_base_store_modex_cb_fn_t cb_fn, + void *cbdata) { pmix_status_t rc = PMIX_SUCCESS; - pmix_namespace_t * ns = (pmix_namespace_t *)nspace; pmix_buffer_t bkt; pmix_byte_object_t bo, bo2; int32_t cnt = 1; char byte; pmix_collect_t ctype; bool have_ctype = false; + pmix_server_trkr_t *trk = (pmix_server_trkr_t*)cbdata; + pmix_proc_t proc; + pmix_buffer_t pbkt; + pmix_rank_t rel_rank; + pmix_nspace_caddy_t *nm; + bool found; /* Loop over the enclosed byte object envelopes and * store them in our GDS module */ @@ -129,7 +135,7 @@ pmix_status_t pmix_gds_base_store_modex(struct pmix_namespace_t *nspace, if (have_ctype) { if (ctype != (pmix_collect_t)byte) { rc = PMIX_ERR_INVALID_ARG; - PMIX_DESTRUCT(&bkt); + pbkt.base_ptr = NULL; goto error; } } @@ -149,11 +155,54 @@ pmix_status_t pmix_gds_base_store_modex(struct pmix_namespace_t *nspace, * shared memory region, then the data may be available * right away - but the client still has to be notified * of its presence. */ - rc = cb_fn(cbdata, (struct pmix_namespace_t *)ns, cbs, &bo2); + + /* setup the byte object for unpacking */ + PMIX_CONSTRUCT(&pbkt, pmix_buffer_t); + PMIX_LOAD_BUFFER(pmix_globals.mypeer, &pbkt, bo2.bytes, bo2.size); + /* unload the proc that provided this data */ + cnt = 1; + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, &pbkt, &rel_rank, &cnt, + PMIX_PROC_RANK); if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + pbkt.base_ptr = NULL; + PMIX_DESTRUCT(&pbkt); PMIX_DESTRUCT(&bkt); goto error; } + found = false; + /* calculate proc form the relative rank */ + if (pmix_list_get_size(&trk->nslist) == 1) { + found = true; + nm = (pmix_nspace_caddy_t*)pmix_list_get_first(&trk->nslist); + } else { + PMIX_LIST_FOREACH(nm, &trk->nslist, pmix_nspace_caddy_t) { + if (rel_rank < nm->ns->nprocs) { + found = true; + break; + } + rel_rank -= nm->ns->nprocs; + } + } + if (false == found) { + rc = PMIX_ERR_NOT_FOUND; + PMIX_ERROR_LOG(rc); + pbkt.base_ptr = NULL; + PMIX_DESTRUCT(&pbkt); + PMIX_DESTRUCT(&bkt); + goto error; + } + PMIX_PROC_LOAD(&proc, nm->ns->nspace, rel_rank); + + rc = cb_fn(ctx, &proc, &pbkt); + if (PMIX_SUCCESS != rc) { + pbkt.base_ptr = NULL; + PMIX_DESTRUCT(&pbkt); + PMIX_DESTRUCT(&bkt); + goto error; + } + pbkt.base_ptr = NULL; + PMIX_DESTRUCT(&pbkt); PMIX_BYTE_OBJECT_DESTRUCT(&bo2); /* get the next blob */ cnt = 1; diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds12/gds_ds12_base.c b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds12/gds_ds12_base.c index cdfcb25270..f47851a8f2 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds12/gds_ds12_base.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds12/gds_ds12_base.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016-2018 IBM Corporation. All rights reserved. - * Copyright (c) 2016-2018 Mellanox Technologies, Inc. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -119,10 +119,10 @@ static pmix_status_t ds12_store(const pmix_proc_t *proc, * always contains data solely from remote procs, and we * shall store it accordingly */ static pmix_status_t ds12_store_modex(struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_buffer_t *buf) + pmix_buffer_t *buf, + void *cbdata) { - return pmix_common_dstor_store_modex(ds12_ctx, nspace, cbs, buf); + return pmix_common_dstor_store_modex(ds12_ctx, nspace, buf, cbdata); } static pmix_status_t ds12_fetch(const pmix_proc_t *proc, diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_base.c b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_base.c index a3f32c9c26..deac1a30e5 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_base.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_base.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016-2018 IBM Corporation. All rights reserved. - * Copyright (c) 2016-2018 Mellanox Technologies, Inc. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -107,10 +107,10 @@ static pmix_status_t ds21_store(const pmix_proc_t *proc, * always contains data solely from remote procs, and we * shall store it accordingly */ static pmix_status_t ds21_store_modex(struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_buffer_t *buf) + pmix_buffer_t *buf, + void *cbdata) { - return pmix_common_dstor_store_modex(ds21_ctx, nspace, cbs, buf); + return pmix_common_dstor_store_modex(ds21_ctx, nspace, buf, cbdata); } static pmix_status_t ds21_fetch(const pmix_proc_t *proc, diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_file.c b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_file.c index 51276846d7..7a23edd206 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_file.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_file.c @@ -3,7 +3,6 @@ * All rights reserved. * Copyright (c) 2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/gds.h b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/gds.h index 9ced4788aa..573fd03b6b 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/gds.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/gds.h @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2016-2018 Mellanox Technologies, Inc. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. * Copyright (c) 2018 IBM Corporation. All rights reserved. @@ -234,17 +234,14 @@ typedef pmix_status_t (*pmix_gds_base_module_store_fn_t)(const pmix_proc_t *proc * ranks - a list of pmix_rank_info_t for the local ranks from this * nspace - this is to be used to filter the cbs list * - * cbs - a list of pmix_server_caddy_t's that contain the pmix_peer_t - * pointers of the local participants. The list can be used to - * identify those participants corresponding to this nspace - * (and thus, GDS component) + * cbdata - pointer to modex callback data * * bo - pointer to the byte object containing the data * */ typedef pmix_status_t (*pmix_gds_base_module_store_modex_fn_t)(struct pmix_namespace_t *ns, - pmix_list_t *cbs, - pmix_buffer_t *buff); + pmix_buffer_t *buff, + void *cbdata); /** * define a convenience macro for storing modex byte objects @@ -253,17 +250,16 @@ typedef pmix_status_t (*pmix_gds_base_module_store_modex_fn_t)(struct pmix_names * * n - pointer to the pmix_namespace_t this blob is to be stored for * - * l - pointer to pmix_list_t containing pmix_server_caddy_t objects - * of the local_cbs of the collective tracker - * * b - pointer to pmix_byte_object_t containing the data + * + * t - pointer to the modex server tracker */ -#define PMIX_GDS_STORE_MODEX(r, n, l, b) \ +#define PMIX_GDS_STORE_MODEX(r, n, b, t) \ do { \ pmix_output_verbose(1, pmix_gds_base_output, \ "[%s:%d] GDS STORE MODEX WITH %s", \ __FILE__, __LINE__, (n)->compat.gds->name); \ - (r) = (n)->compat.gds->store_modex((struct pmix_namespace_t*)n, l, b); \ + (r) = (n)->compat.gds->store_modex((struct pmix_namespace_t*)n, b, t); \ } while (0) /** diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/hash/gds_hash.c b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/hash/gds_hash.c index 4b02d8faf2..53e44423bd 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/gds/hash/gds_hash.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/gds/hash/gds_hash.c @@ -1,9 +1,9 @@ /* - * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * Copyright (c) 2016-2018 IBM Corporation. All rights reserved. * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2018 Mellanox Technologies, Inc. + * Copyright (c) 2018-2019 Mellanox Technologies, Inc. * All rights reserved. * * $COPYRIGHT$ @@ -37,7 +37,7 @@ #include "src/client/pmix_client_ops.h" #include "src/server/pmix_server_ops.h" #include "src/util/argv.h" -#include "src/util/compress.h" +#include "src/mca/pcompress/base/base.h" #include "src/util/error.h" #include "src/util/hash.h" #include "src/util/output.h" @@ -67,13 +67,12 @@ static pmix_status_t hash_store(const pmix_proc_t *proc, pmix_kval_t *kv); static pmix_status_t hash_store_modex(struct pmix_namespace_t *ns, - pmix_list_t *cbs, - pmix_buffer_t *buff); + pmix_buffer_t *buff, + void *cbdata); -static pmix_status_t _hash_store_modex(void * cbdata, - struct pmix_namespace_t *ns, - pmix_list_t *cbs, - pmix_byte_object_t *bo); +static pmix_status_t _hash_store_modex(pmix_gds_base_ctx_t ctx, + pmix_proc_t *proc, + pmix_buffer_t *pbkt); static pmix_status_t hash_fetch(const pmix_proc_t *proc, pmix_scope_t scope, bool copy, @@ -487,7 +486,7 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns, /* if the value contains a string that is longer than the * limit, then compress it */ if (PMIX_STRING_SIZE_CHECK(kp2->value)) { - if (pmix_util_compress_string(kp2->value->data.string, &tmp, &len)) { + if (pmix_compress.compress_string(kp2->value->data.string, &tmp, &len)) { if (NULL == tmp) { PMIX_ERROR_LOG(PMIX_ERR_NOMEM); rc = PMIX_ERR_NOMEM; @@ -524,7 +523,7 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns, /* if the value contains a string that is longer than the * limit, then compress it */ if (PMIX_STRING_SIZE_CHECK(kp2->value)) { - if (pmix_util_compress_string(kp2->value->data.string, &tmp, &len)) { + if (pmix_compress.compress_string(kp2->value->data.string, &tmp, &len)) { if (NULL == tmp) { rc = PMIX_ERR_NOMEM; PMIX_ERROR_LOG(rc); @@ -852,7 +851,7 @@ static pmix_status_t hash_store_job_info(const char *nspace, /* if the value contains a string that is longer than the * limit, then compress it */ if (PMIX_STRING_SIZE_CHECK(kp2->value)) { - if (pmix_util_compress_string(kp2->value->data.string, &tmp, &len)) { + if (pmix_compress.compress_string(kp2->value->data.string, &tmp, &len)) { if (NULL == tmp) { PMIX_ERROR_LOG(PMIX_ERR_NOMEM); rc = PMIX_ERR_NOMEM; @@ -1032,7 +1031,7 @@ static pmix_status_t hash_store_job_info(const char *nspace, /* if the value contains a string that is longer than the * limit, then compress it */ if (PMIX_STRING_SIZE_CHECK(kptr->value)) { - if (pmix_util_compress_string(kptr->value->data.string, &tmp, &len)) { + if (pmix_compress.compress_string(kptr->value->data.string, &tmp, &len)) { if (NULL == tmp) { PMIX_ERROR_LOG(PMIX_ERR_NOMEM); rc = PMIX_ERR_NOMEM; @@ -1190,33 +1189,30 @@ static pmix_status_t hash_store(const pmix_proc_t *proc, * always contains data solely from remote procs, and we * shall store it accordingly */ static pmix_status_t hash_store_modex(struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_buffer_t *buf) { - return pmix_gds_base_store_modex(nspace, cbs, buf, _hash_store_modex, NULL); + pmix_buffer_t *buf, + void *cbdata) { + return pmix_gds_base_store_modex(nspace, buf, NULL, + _hash_store_modex, cbdata); } -static pmix_status_t _hash_store_modex(void * cbdata, - struct pmix_namespace_t *nspace, - pmix_list_t *cbs, - pmix_byte_object_t *bo) +static pmix_status_t _hash_store_modex(pmix_gds_base_ctx_t ctx, + pmix_proc_t *proc, + pmix_buffer_t *pbkt) { - pmix_namespace_t *ns = (pmix_namespace_t*)nspace; pmix_hash_trkr_t *trk, *t; pmix_status_t rc = PMIX_SUCCESS; int32_t cnt; - pmix_buffer_t pbkt; - pmix_proc_t proc; pmix_kval_t *kv; pmix_output_verbose(2, pmix_gds_base_framework.framework_output, "[%s:%d] gds:hash:store_modex for nspace %s", pmix_globals.myid.nspace, pmix_globals.myid.rank, - ns->nspace); + proc->nspace); /* find the hash table for this nspace */ trk = NULL; PMIX_LIST_FOREACH(t, &myhashes, pmix_hash_trkr_t) { - if (0 == strcmp(ns->nspace, t->ns)) { + if (0 == strcmp(proc->nspace, t->ns)) { trk = t; break; } @@ -1224,7 +1220,7 @@ static pmix_status_t _hash_store_modex(void * cbdata, if (NULL == trk) { /* create one */ trk = PMIX_NEW(pmix_hash_trkr_t); - trk->ns = strdup(ns->nspace); + trk->ns = strdup(proc->nspace); pmix_list_append(&myhashes, &trk->super); } @@ -1234,41 +1230,26 @@ static pmix_status_t _hash_store_modex(void * cbdata, * the rank followed by pmix_kval_t's. The list of callbacks * contains all local participants. */ - /* setup the byte object for unpacking */ - PMIX_CONSTRUCT(&pbkt, pmix_buffer_t); - /* the next step unfortunately NULLs the byte object's - * entries, so we need to ensure we restore them! */ - PMIX_LOAD_BUFFER(pmix_globals.mypeer, &pbkt, bo->bytes, bo->size); - /* unload the proc that provided this data */ - cnt = 1; - PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, &pbkt, &proc, &cnt, PMIX_PROC); + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, pbkt, proc, &cnt, PMIX_PROC); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); - bo->bytes = pbkt.base_ptr; - bo->size = pbkt.bytes_used; // restore the incoming data - pbkt.base_ptr = NULL; - PMIX_DESTRUCT(&pbkt); return rc; } /* unpack the remaining values until we hit the end of the buffer */ cnt = 1; kv = PMIX_NEW(pmix_kval_t); - PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, &pbkt, kv, &cnt, PMIX_KVAL); + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, pbkt, kv, &cnt, PMIX_KVAL); while (PMIX_SUCCESS == rc) { /* store this in the hash table */ - if (PMIX_SUCCESS != (rc = pmix_hash_store(&trk->remote, proc.rank, kv))) { + if (PMIX_SUCCESS != (rc = pmix_hash_store(&trk->remote, proc->rank, kv))) { PMIX_ERROR_LOG(rc); - bo->bytes = pbkt.base_ptr; - bo->size = pbkt.bytes_used; // restore the incoming data - pbkt.base_ptr = NULL; - PMIX_DESTRUCT(&pbkt); return rc; } PMIX_RELEASE(kv); // maintain accounting as the hash increments the ref count /* continue along */ kv = PMIX_NEW(pmix_kval_t); cnt = 1; - PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, &pbkt, kv, &cnt, PMIX_KVAL); + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, pbkt, kv, &cnt, PMIX_KVAL); } PMIX_RELEASE(kv); // maintain accounting if (PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER != rc) { @@ -1276,10 +1257,6 @@ static pmix_status_t _hash_store_modex(void * cbdata, } else { rc = PMIX_SUCCESS; } - bo->bytes = pbkt.base_ptr; - bo->size = pbkt.bytes_used; // restore the incoming data - pbkt.base_ptr = NULL; - PMIX_DESTRUCT(&pbkt); return rc; } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/Makefile.am b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/Makefile.am new file mode 100644 index 0000000000..4b9a894bda --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/Makefile.am @@ -0,0 +1,37 @@ +# +# Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2019 Intel, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# main library setup +noinst_LTLIBRARIES = libmca_pcompress.la +libmca_pcompress_la_SOURCES = + +# local files +headers = pcompress.h +libmca_pcompress_la_SOURCES += $(headers) + +# Ensure that the man pages are rebuilt if the pmix_config.h file +# changes; a "good enough" way to know if configure was run again (and +# therefore the release date or version may have changed) +$(nodist_man_MANS): $(top_builddir)/pmix/include/pmix_config.h + +# Conditionally install the header files +if WANT_INSTALL_HEADERS +pmixdir = $(pmixincludedir)/$(subdir) +nobase_pmix_HEADERS = $(headers) +endif + +include base/Makefile.am + +distclean-local: + rm -f base/static-components.h + rm -f $(nodist_man_MANS) diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/Makefile.am b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/Makefile.am new file mode 100644 index 0000000000..8a6f205723 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/Makefile.am @@ -0,0 +1,20 @@ +# +# Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. 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$ +# + +headers += \ + base/base.h + +libmca_pcompress_la_SOURCES += \ + base/pcompress_base_frame.c \ + base/pcompress_base_select.c \ + base/pcompress_base_fns.c diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/base.h b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/base.h new file mode 100644 index 0000000000..6270d81319 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/base.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * + * Copyright (c) 2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +#ifndef PMIX_COMPRESS_BASE_H +#define PMIX_COMPRESS_BASE_H + +#include "pmix_config.h" +#include "src/mca/pcompress/pcompress.h" +#include "src/util/pmix_environ.h" + +#include "src/mca/base/base.h" + +/* + * Global functions for MCA overall COMPRESS + */ + +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif + +/* define a macro for quickly checking if a string exceeds the + * compression limit */ +#define PMIX_STRING_SIZE_CHECK(s) \ + (PMIX_STRING == (s)->type && NULL != (s)->data.string && pmix_compress_base.compress_limit < strlen((s)->data.string)) + +#define PMIX_VALUE_COMPRESSED_STRING_UNPACK(s) \ + do { \ + char *tmp; \ + /* if this is a compressed string, then uncompress it */ \ + if (PMIX_COMPRESSED_STRING == (s)->type) { \ + pmix_compress.decompress_string(&tmp, (uint8_t*)(s)->data.bo.bytes, \ + (s)->data.bo.size); \ + if (NULL == tmp) { \ + PMIX_ERROR_LOG(PMIX_ERR_NOMEM); \ + rc = PMIX_ERR_NOMEM; \ + PMIX_VALUE_RELEASE(s); \ + val = NULL; \ + } else { \ + PMIX_VALUE_DESTRUCT(s); \ + (s)->data.string = tmp; \ + (s)->type = PMIX_STRING; \ + } \ + } \ + } while(0) + +typedef struct { + size_t compress_limit; +} pmix_compress_base_t; + +PMIX_EXPORT extern pmix_compress_base_t pmix_compress_base; + + /** + * Select an available component. + * + * @retval OPAL_SUCCESS Upon Success + * @retval OPAL_NOT_FOUND If no component can be selected + * @retval OPAL_ERROR Upon other failure + * + */ + PMIX_EXPORT int pmix_compress_base_select(void); + + /** + * Globals + */ + PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pcompress_base_framework; + PMIX_EXPORT extern pmix_compress_base_module_t pmix_compress; + + /** + * + */ + PMIX_EXPORT int pmix_compress_base_tar_create(char ** target); + PMIX_EXPORT int pmix_compress_base_tar_extract(char ** target); + +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif + +#endif /* PMIX_COMPRESS_BASE_H */ diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_fns.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_fns.c new file mode 100644 index 0000000000..75a931c17f --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_fns.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2015 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) 2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "pmix_config.h" + +#include +#include +#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif /* HAVE_FCNTL_H */ +#ifdef HAVE_SYS_STAT_H +#include +#endif + +#include "pmix_common.h" +#include "src/mca/mca.h" +#include "src/mca/base/base.h" +#include "src/util/os_dirpath.h" +#include "src/util/output.h" +#include "src/util/argv.h" +#include "src/util/printf.h" + +#include "src/mca/pcompress/pcompress.h" +#include "src/mca/pcompress/base/base.h" + +/****************** + * Local Function Defs + ******************/ + +/****************** + * Object stuff + ******************/ + +int pmix_compress_base_tar_create(char ** target) +{ + int exit_status = PMIX_SUCCESS; + char *tar_target = NULL; + char **argv = NULL; + pid_t child_pid = 0; + int status = 0; + + pmix_asprintf(&tar_target, "%s.tar", *target); + + child_pid = fork(); + if( 0 == child_pid ) { /* Child */ + char *cmd; + pmix_asprintf(&cmd, "tar -cf %s %s", tar_target, *target); + + argv = pmix_argv_split(cmd, ' '); + status = execvp(argv[0], argv); + + pmix_output(0, "compress:base: Tar:: Failed to exec child [%s] status = %d\n", cmd, status); + exit(PMIX_ERROR); + } + else if(0 < child_pid) { + waitpid(child_pid, &status, 0); + + if( !WIFEXITED(status) ) { + exit_status = PMIX_ERROR; + goto cleanup; + } + + free(*target); + *target = strdup(tar_target); + } + else { + exit_status = PMIX_ERROR; + goto cleanup; + } + + cleanup: + if( NULL != tar_target ) { + free(tar_target); + } + + return exit_status; +} + +int pmix_compress_base_tar_extract(char ** target) +{ + int exit_status = PMIX_SUCCESS; + char **argv = NULL; + pid_t child_pid = 0; + int status = 0; + + child_pid = fork(); + if( 0 == child_pid ) { /* Child */ + char *cmd; + pmix_asprintf(&cmd, "tar -xf %s", *target); + + argv = pmix_argv_split(cmd, ' '); + status = execvp(argv[0], argv); + + pmix_output(0, "compress:base: Tar:: Failed to exec child [%s] status = %d\n", cmd, status); + exit(PMIX_ERROR); + } + else if(0 < child_pid) { + waitpid(child_pid, &status, 0); + + if( !WIFEXITED(status) ) { + exit_status = PMIX_ERROR; + goto cleanup; + } + + /* Strip off the '.tar' */ + (*target)[strlen(*target)-4] = '\0'; + } + else { + exit_status = PMIX_ERROR; + goto cleanup; + } + + cleanup: + + return exit_status; +} + +/****************** + * Local Functions + ******************/ diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_frame.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_frame.c new file mode 100644 index 0000000000..fdf3f01ab2 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_frame.c @@ -0,0 +1,89 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2011-2013 Los Alamos National Security, LLC. + * All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "pmix_config.h" + +#include "src/mca/base/base.h" +#include "src/mca/pcompress/base/base.h" + +#include "src/mca/pcompress/base/static-components.h" + +/* + * Globals + */ +static bool compress_block(char *instring, + uint8_t **outbytes, + size_t *nbytes) +{ + return false; +} + +static bool decompress_block(char **outstring, + uint8_t *inbytes, size_t len) +{ + return false; +} + +pmix_compress_base_module_t pmix_compress = { + NULL, /* init */ + NULL, /* finalize */ + NULL, /* compress */ + NULL, /* compress_nb */ + NULL, /* decompress */ + NULL, /* decompress_nb */ + compress_block, + decompress_block +}; +pmix_compress_base_t pmix_compress_base = {0}; + +pmix_compress_base_component_t pmix_compress_base_selected_component = {{0}}; + +static int pmix_compress_base_register(pmix_mca_base_register_flag_t flags) +{ + pmix_compress_base.compress_limit = 4096; + (void) pmix_mca_base_var_register("pmix", "compress", "base", "limit", + "Threshold beyond which data will be compressed", + PMIX_MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0, PMIX_INFO_LVL_3, + PMIX_MCA_BASE_VAR_SCOPE_READONLY, &pmix_compress_base.compress_limit); + + return PMIX_SUCCESS; +} + +/** + * Function for finding and opening either all MCA components, + * or the one that was specifically requested via a MCA parameter. + */ +static int pmix_compress_base_open(pmix_mca_base_open_flag_t flags) +{ + /* Open up all available components */ + return pmix_mca_base_framework_components_open(&pmix_pcompress_base_framework, flags); +} + +static int pmix_compress_base_close(void) +{ + /* Call the component's finalize routine */ + if( NULL != pmix_compress.finalize ) { + pmix_compress.finalize(); + } + + /* Close all available modules that are open */ + return pmix_mca_base_framework_components_close (&pmix_pcompress_base_framework, NULL); +} + +PMIX_MCA_BASE_FRAMEWORK_DECLARE(pmix, pcompress, "PCOMPRESS MCA", + pmix_compress_base_register, pmix_compress_base_open, + pmix_compress_base_close, mca_pcompress_base_static_components, 0); + diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_select.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_select.c new file mode 100644 index 0000000000..3f1a058d45 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/pcompress_base_select.c @@ -0,0 +1,58 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "pmix_config.h" + +#ifdef HAVE_UNISTD_H +#include "unistd.h" +#endif + +#include "pmix_common.h" +#include "src/util/output.h" +#include "src/mca/mca.h" +#include "src/mca/base/base.h" +#include "src/mca/pcompress/base/base.h" + +int pmix_compress_base_select(void) +{ + int ret = PMIX_SUCCESS; + pmix_compress_base_component_t *best_component = NULL; + pmix_compress_base_module_t *best_module = NULL; + + /* + * Select the best component + */ + if( PMIX_SUCCESS != pmix_mca_base_select("pcompress", pmix_pcompress_base_framework.framework_output, + &pmix_pcompress_base_framework.framework_components, + (pmix_mca_base_module_t **) &best_module, + (pmix_mca_base_component_t **) &best_component, NULL) ) { + /* This will only happen if no component was selected, + * in which case we use the default one */ + goto cleanup; + } + + /* Initialize the winner */ + if (NULL != best_module) { + if (PMIX_SUCCESS != (ret = best_module->init()) ) { + goto cleanup; + } + pmix_compress = *best_module; + } + + cleanup: + return ret; +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/pcompress.h b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/pcompress.h new file mode 100644 index 0000000000..52046540c9 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/pcompress.h @@ -0,0 +1,155 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. + * + * Copyright (c) 2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +/** + * @file + * + * Compression Framework + * + * General Description: + * + * The PMIX Compress framework has been created to provide an abstract interface + * to the compression agent library on the host machine. This fromework is useful + * when distributing files that can be compressed before sending to dimish the + * load on the network. + * + */ + +#ifndef PMIX_MCA_COMPRESS_H +#define PMIX_MCA_COMPRESS_H + +#include "pmix_config.h" +#include "src/mca/mca.h" +#include "src/mca/base/base.h" +#include "src/class/pmix_object.h" + +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif + +/** + * Module initialization function. + * Returns PMIX_SUCCESS + */ +typedef int (*pmix_compress_base_module_init_fn_t) + (void); + +/** + * Module finalization function. + * Returns PMIX_SUCCESS + */ +typedef int (*pmix_compress_base_module_finalize_fn_t) + (void); + +/** + * Compress the file provided + * + * Arguments: + * fname = Filename to compress + * cname = Compressed filename + * postfix = postfix added to filename to create compressed filename + * Returns: + * PMIX_SUCCESS on success, ow PMIX_ERROR + */ +typedef int (*pmix_compress_base_module_compress_fn_t) + (char * fname, char **cname, char **postfix); + +typedef int (*pmix_compress_base_module_compress_nb_fn_t) + (char * fname, char **cname, char **postfix, pid_t *child_pid); + +/** + * Decompress the file provided + * + * Arguments: + * fname = Filename to compress + * cname = Compressed filename + * Returns: + * PMIX_SUCCESS on success, ow PMIX_ERROR + */ +typedef int (*pmix_compress_base_module_decompress_fn_t) + (char * cname, char **fname); +typedef int (*pmix_compress_base_module_decompress_nb_fn_t) + (char * cname, char **fname, pid_t *child_pid); + +/** + * Compress a string + * + * Arguments: + * + */ +typedef bool (*pmix_compress_base_module_compress_string_fn_t)(char *instring, + uint8_t **outbytes, + size_t *nbytes); +typedef bool (*pmix_compress_base_module_decompress_string_fn_t)(char **outstring, + uint8_t *inbytes, size_t len); + + +/** + * Structure for COMPRESS components. + */ +struct pmix_compress_base_component_2_0_0_t { + /** PMIX_MCA base component */ + pmix_mca_base_component_t base_version; + /** PMIX_MCA base data */ + pmix_mca_base_component_data_t base_data; + + /** Verbosity Level */ + int verbose; + /** Output Handle for pmix_output */ + int output_handle; + /** Default Priority */ + int priority; +}; +typedef struct pmix_compress_base_component_2_0_0_t pmix_compress_base_component_2_0_0_t; +typedef struct pmix_compress_base_component_2_0_0_t pmix_compress_base_component_t; + +/** + * Structure for COMPRESS modules + */ +struct pmix_compress_base_module_1_0_0_t { + /** Initialization Function */ + pmix_compress_base_module_init_fn_t init; + /** Finalization Function */ + pmix_compress_base_module_finalize_fn_t finalize; + + /** Compress interface */ + pmix_compress_base_module_compress_fn_t compress; + pmix_compress_base_module_compress_nb_fn_t compress_nb; + + /** Decompress Interface */ + pmix_compress_base_module_decompress_fn_t decompress; + pmix_compress_base_module_decompress_nb_fn_t decompress_nb; + + /* COMPRESS STRING */ + pmix_compress_base_module_compress_string_fn_t compress_string; + pmix_compress_base_module_decompress_string_fn_t decompress_string; +}; +typedef struct pmix_compress_base_module_1_0_0_t pmix_compress_base_module_1_0_0_t; +typedef struct pmix_compress_base_module_1_0_0_t pmix_compress_base_module_t; + +PMIX_EXPORT extern pmix_compress_base_module_t pmix_compress; + +/** + * Macro for use in components that are of type COMPRESS + */ +#define PMIX_COMPRESS_BASE_VERSION_2_0_0 \ + PMIX_MCA_BASE_VERSION_1_0_0("pcompress", 2, 0, 0) + +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif + +#endif /* PMIX_COMPRESS_H */ + diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/Makefile.am b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/Makefile.am new file mode 100644 index 0000000000..2fda76a39e --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/Makefile.am @@ -0,0 +1,42 @@ +# +# Copyright (c) 2004-2010 The Trustees of Indiana University. +# All rights reserved. +# Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2017 IBM Corporation. All rights reserved. +# Copyright (c) 2019 Intel, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +AM_CPPFLAGS = $(pcompress_zlib_CPPFLAGS) + +sources = \ + compress_zlib.h \ + compress_zlib_component.c \ + compress_zlib.c + +# Make the output library in this directory, and name it either +# mca__.la (for DSO builds) or libmca__.la +# (for static builds). + +if MCA_BUILD_pmix_pcompress_zlib_DSO +component_noinst = +component_install = mca_pcompress_zlib.la +else +component_noinst = libmca_pcompress_zlib.la +component_install = +endif + +mcacomponentdir = $(pmixlibdir) +mcacomponent_LTLIBRARIES = $(component_install) +mca_pcompress_zlib_la_SOURCES = $(sources) +mca_pcompress_zlib_la_LDFLAGS = -module -avoid-version $(pcompress_zlib_LDFLAGS) +mca_pcompress_zlib_la_LIBADD = $(pcompress_zlib_LIBS) + +noinst_LTLIBRARIES = $(component_noinst) +libmca_pcompress_zlib_la_SOURCES = $(sources) +libmca_pcompress_zlib_la_LDFLAGS = -module -avoid-version $(pcompress_zlib_LDFLAGS) +libmca_pcompress_zlib_la_LIBADD = $(pcompress_zlib_LIBS) diff --git a/opal/mca/pmix/pmix4x/pmix/src/util/compress.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib.c similarity index 59% rename from opal/mca/pmix/pmix4x/pmix/src/util/compress.c rename to opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib.c index 867a3d5e57..cc1b987d4f 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/util/compress.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib.c @@ -1,6 +1,13 @@ /* - * Copyright (c) 2016 Intel, Inc. All rights reserved. - * Copyright (c) 2017 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2004-2010 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. + * + * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. + * Copyright (c) 2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -8,24 +15,43 @@ * $HEADER$ */ -#include +#include "pmix_config.h" - -#include -#ifdef HAVE_STRING_H #include -#endif -#ifdef HAVE_ZLIB_H +#include +#include +#include +#if HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ #include -#endif -#include "src/include/pmix_globals.h" -#include "src/util/compress.h" +#include "src/util/pmix_environ.h" +#include "src/util/output.h" +#include "src/util/argv.h" +#include "src/util/pmix_environ.h" +#include "src/util/printf.h" -#if PMIX_HAVE_ZLIB -bool pmix_util_compress_string(char *instring, - uint8_t **outbytes, - size_t *nbytes) +#include "pmix_common.h" +#include "src/util/basename.h" + +#include "src/mca/pcompress/base/base.h" + +#include "compress_zlib.h" + +int pmix_compress_zlib_module_init(void) +{ + return PMIX_SUCCESS; +} + +int pmix_compress_zlib_module_finalize(void) +{ + return PMIX_SUCCESS; +} + +bool pmix_compress_zlib_compress_block(char *instring, + uint8_t **outbytes, + size_t *nbytes) { z_stream strm; size_t len, outlen; @@ -75,23 +101,14 @@ bool pmix_util_compress_string(char *instring, /* bring over the compressed data */ memcpy(ptr, tmp, outlen-sizeof(uint32_t)); free(tmp); - pmix_output_verbose(10, pmix_globals.debug_output, - "JOBDATA COMPRESS INPUT STRING OF LEN %d OUTPUT SIZE %lu", + pmix_output_verbose(2, pmix_pcompress_base_framework.framework_output, + "COMPRESS INPUT STRING OF LEN %d OUTPUT SIZE %lu", inlen, outlen-sizeof(uint32_t)); return true; // we did the compression } -#else -bool pmix_util_compress_string(char *instring, - uint8_t **outbytes, - size_t *nbytes) -{ - return false; // we did not compress -} -#endif -#if PMIX_HAVE_ZLIB -void pmix_util_uncompress_string(char **outstring, - uint8_t *inbytes, size_t len) +bool pmix_compress_zlib_uncompress_block(char **outstring, + uint8_t *inbytes, size_t len) { uint8_t *dest; int32_t len2; @@ -104,21 +121,21 @@ void pmix_util_uncompress_string(char **outstring, /* the first 4 bytes contains the uncompressed size */ memcpy(&len2, inbytes, sizeof(uint32_t)); - pmix_output_verbose(10, pmix_globals.debug_output, + pmix_output_verbose(2, pmix_pcompress_base_framework.framework_output, "DECOMPRESSING INPUT OF LEN %lu OUTPUT %d", len, len2); /* setting destination to the fully decompressed size, +1 to * hold the NULL terminator */ dest = (uint8_t*)malloc(len2+1); if (NULL == dest) { - return; + return false; } memset(dest, 0, len2+1); memset (&strm, 0, sizeof (strm)); if (Z_OK != inflateInit(&strm)) { free(dest); - return; + return false; } strm.avail_in = len; strm.next_in = (uint8_t*)(inbytes + sizeof(uint32_t)); @@ -130,19 +147,7 @@ void pmix_util_uncompress_string(char **outstring, /* ensure this is NULL terminated! */ dest[len2] = '\0'; *outstring = (char*)dest; - pmix_output_verbose(10, pmix_globals.debug_output, + pmix_output_verbose(2, pmix_pcompress_base_framework.framework_output, "\tFINAL LEN: %lu CODE: %d", strlen(*outstring), rc); - return; + return true; } -#else -/* this can never actually be used - there is no way we should - * receive a PMIX_COMPRESSED_STRING unless we compressed it, - * which means PMIX_HAVE_ZLIB must have been true. Still, we - * include the stub just to avoid requiring #if's in the rest - * of the code */ -void pmix_util_uncompress_string(char **outstring, - uint8_t *inbytes, size_t len) -{ - *outstring = NULL; -} -#endif diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib.h b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib.h new file mode 100644 index 0000000000..309cd451b0 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +/** + * @file + * + * ZLIB COMPRESS component + * + * Uses the zlib library + */ + +#ifndef MCA_COMPRESS_ZLIB_EXPORT_H +#define MCA_COMPRESS_ZLIB_EXPORT_H + +#include "pmix_config.h" + +#include "src/util/output.h" + +#include "src/mca/mca.h" +#include "src/mca/pcompress/pcompress.h" + +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif + + extern pmix_mca_base_component_t mca_pcompress_zlib_component; + + /* + * Module functions + */ + int pmix_compress_zlib_module_init(void); + int pmix_compress_zlib_module_finalize(void); + + /* + * Actual funcationality + */ + bool pmix_compress_zlib_compress_block(char *instring, + uint8_t **outbytes, + size_t *nbytes); + bool pmix_compress_zlib_uncompress_block(char **outstring, + uint8_t *inbytes, size_t len); + +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif + +#endif /* MCA_COMPRESS_ZLIB_EXPORT_H */ diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib_component.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib_component.c new file mode 100644 index 0000000000..cc8b6a572d --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/compress_zlib_component.c @@ -0,0 +1,88 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University. + * All rights reserved. + * Copyright (c) 2015 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "pmix_config.h" + +#include "pmix_common.h" +#include "src/mca/pcompress/base/base.h" +#include "compress_zlib.h" + +/* + * Public string for version number + */ +const char *pmix_compress_zlib_component_version_string = +"PMIX COMPRESS zlib MCA component version " PMIX_VERSION; + +/* + * Local functionality + */ +static int compress_zlib_open(void); +static int compress_zlib_close(void); +static int compress_zlib_query(pmix_mca_base_module_t **module, int *priority); + +/* + * Instantiate the public struct with all of our public information + * and pointer to our public functions in it + */ +PMIX_EXPORT pmix_mca_base_component_t mca_pcompress_zlib_component = { + /* Handle the general mca_component_t struct containing + * meta information about the component zlib + */ + PMIX_COMPRESS_BASE_VERSION_2_0_0, + + /* Component name and version */ + .pmix_mca_component_name = "zlib", + PMIX_MCA_BASE_MAKE_VERSION(component, PMIX_MAJOR_VERSION, PMIX_MINOR_VERSION, + PMIX_RELEASE_VERSION), + + /* Component open and close functions */ + .pmix_mca_open_component = compress_zlib_open, + .pmix_mca_close_component = compress_zlib_close, + .pmix_mca_query_component = compress_zlib_query +}; + +/* + * Zlib module + */ +static pmix_compress_base_module_t loc_module = { + /** Initialization Function */ + .init = pmix_compress_zlib_module_init, + /** Finalization Function */ + .finalize = pmix_compress_zlib_module_finalize, + + /** Compress Function */ + .compress_string = pmix_compress_zlib_compress_block, + + /** Decompress Function */ + .decompress_string = pmix_compress_zlib_uncompress_block, +}; + +static int compress_zlib_open(void) +{ + return PMIX_SUCCESS; +} + +static int compress_zlib_close(void) +{ + return PMIX_SUCCESS; +} + +static int compress_zlib_query(pmix_mca_base_module_t **module, int *priority) +{ + *module = (pmix_mca_base_module_t *)&loc_module; + *priority = 50; + + return PMIX_SUCCESS; +} + diff --git a/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_zlib.m4 b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/configure.m4 similarity index 68% rename from opal/mca/pmix/pmix4x/pmix/config/pmix_setup_zlib.m4 rename to opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/configure.m4 index 5440999eb1..db32144cef 100644 --- a/opal/mca/pmix/pmix4x/pmix/config/pmix_setup_zlib.m4 +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/zlib/configure.m4 @@ -2,7 +2,7 @@ # # Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved. -# Copyright (c) 2013-2017 Intel, Inc. All rights reserved. +# Copyright (c) 2013-2019 Intel, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -10,10 +10,13 @@ # $HEADER$ # -# MCA_zlib_CONFIG([action-if-found], [action-if-not-found]) -# -------------------------------------------------------------------- -AC_DEFUN([PMIX_ZLIB_CONFIG],[ - PMIX_VAR_SCOPE_PUSH([pmix_zlib_dir pmix_zlib_libdir pmix_zlib_standard_lib_location pmix_zlib_standard_header_location]) +# MCA_pcompress_zlib_CONFIG([action-if-can-compile], +# [action-if-cant-compile]) +# ------------------------------------------------ +AC_DEFUN([MCA_pmix_pcompress_zlib_CONFIG],[ + AC_CONFIG_FILES([src/mca/pcompress/zlib/Makefile]) + + PMIX_VAR_SCOPE_PUSH([pmix_zlib_dir pmix_zlib_libdir pmix_zlib_standard_lib_location pmix_zlib_standard_header_location pmix_check_zlib_save_CPPFLAGS pmix_check_zlib_save_LDFLAGS pmix_check_zlib_save_LIBS]) AC_ARG_WITH([zlib], [AC_HELP_STRING([--with-zlib=DIR], @@ -23,12 +26,17 @@ AC_DEFUN([PMIX_ZLIB_CONFIG],[ [AC_HELP_STRING([--with-zlib-libdir=DIR], [Search for zlib libraries in DIR ])]) + pmix_check_zlib_save_CPPFLAGS="$CPPFLAGS" + pmix_check_zlib_save_LDFLAGS="$LDFLAGS" + pmix_check_zlib_save_LIBS="$LIBS" + pmix_zlib_support=0 if test "$with_zlib" != "no"; then AC_MSG_CHECKING([for zlib in]) if test ! -z "$with_zlib" && test "$with_zlib" != "yes"; then pmix_zlib_dir=$with_zlib + pmix_zlib_source=$with_zlib pmix_zlib_standard_header_location=no pmix_zlib_standard_lib_location=no AS_IF([test -z "$with_zlib_libdir" || test "$with_zlib_libdir" = "yes"], @@ -44,6 +52,7 @@ AC_DEFUN([PMIX_ZLIB_CONFIG],[ [AC_MSG_RESULT([$with_zlib_libdir])]) else AC_MSG_RESULT([(default search paths)]) + pmix_zlib_source=standard pmix_zlib_standard_header_location=yes pmix_zlib_standard_lib_location=yes fi @@ -51,7 +60,7 @@ AC_DEFUN([PMIX_ZLIB_CONFIG],[ [pmix_zlib_libdir="$with_zlib_libdir" pmix_zlib_standard_lib_location=no]) - PMIX_CHECK_PACKAGE([pmix_zlib], + PMIX_CHECK_PACKAGE([pcompress_zlib], [zlib.h], [z], [deflate], @@ -60,18 +69,6 @@ AC_DEFUN([PMIX_ZLIB_CONFIG],[ [$pmix_zlib_libdir], [pmix_zlib_support=1], [pmix_zlib_support=0]) - if test $pmix_zlib_support = "1"; then - LIBS="$LIBS -lz" - PMIX_EMBEDDED_LIBS="$PMIX_EMBEDDED_LIBS -lz" - if test "$pmix_zlib_standard_header_location" != "yes"; then - PMIX_EMBEDDED_CPPFLAGS="$PMIX_EMBEDDED_CPPFLAGS $pmix_zlib_CPPFLAGS" - CPPFLAGS="$CPPFLAGS $pmix_zlib_CPPFLAGS" - fi - if test "$pmix_zlib_standard_lib_location" != "yes"; then - PMIX_EMBEDDED_LDFLAGS="$PMIX_EMBEDDED_LDFLAGS $pmix_zlib_LDFLAGS" - LDFLAGS="$LDFLAGS $pmix_zlib_LDFLAGS" - fi - fi fi if test ! -z "$with_zlib" && test "$with_zlib" != "no" && test "$pmix_zlib_support" != "1"; then @@ -86,7 +83,20 @@ AC_DEFUN([PMIX_ZLIB_CONFIG],[ AC_MSG_RESULT([yes]) fi - AC_DEFINE_UNQUOTED([PMIX_HAVE_ZLIB], [$pmix_zlib_support], - [Whether or not we have zlib support]) + CPPFLAGS="$pmix_check_zlib_save_CPPFLAGS" + LDFLAGS="$pmix_check_zlib_save_LDFLAGS" + LIBS="$pmix_check_zlib_save_LIBS" + + AS_IF([test "$pmix_zlib_support" = "1"], + [$1 + PMIX_SUMMARY_ADD([[External Packages]],[[ZLIB]], [pmix_zlib], [yes ($pmix_zlib_source)])], + [$2]) + + # substitute in the things needed to build psm2 + AC_SUBST([pcompress_zlib_CFLAGS]) + AC_SUBST([pcompress_zlib_CPPFLAGS]) + AC_SUBST([pcompress_zlib_LDFLAGS]) + AC_SUBST([pcompress_zlib_LIBS]) + PMIX_VAR_SCOPE_POP ])dnl diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/base/pnet_base_fns.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/base/pnet_base_fns.c index c4869da529..e4a78b0b91 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/base/pnet_base_fns.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/base/pnet_base_fns.c @@ -101,16 +101,14 @@ pmix_status_t pmix_pnet_base_allocate(char *nspace, } } /* process the allocation request */ - for (n=0; n < ninfo; n++) { - PMIX_LIST_FOREACH(active, &pmix_pnet_globals.actives, pmix_pnet_base_active_module_t) { - if (NULL != active->module->allocate) { - if (PMIX_SUCCESS == (rc = active->module->allocate(nptr, &info[n], ilist))) { - break; - } - if (PMIX_ERR_TAKE_NEXT_OPTION != rc) { - /* true error */ - return rc; - } + PMIX_LIST_FOREACH(active, &pmix_pnet_globals.actives, pmix_pnet_base_active_module_t) { + if (NULL != active->module->allocate) { + if (PMIX_SUCCESS == (rc = active->module->allocate(nptr, info, ninfo, ilist))) { + break; + } + if (PMIX_ERR_TAKE_NEXT_OPTION != rc) { + /* true error */ + return rc; } } } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa.c index b313b8d779..6deb3487c5 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. * * $COPYRIGHT$ @@ -53,7 +53,7 @@ static pmix_status_t opa_init(void); static void opa_finalize(void); static pmix_status_t allocate(pmix_namespace_t *nptr, - pmix_info_t *info, + pmix_info_t info[], size_t ninfo, pmix_list_t *ilist); static pmix_status_t setup_local_network(pmix_namespace_t *nptr, pmix_info_t info[], @@ -230,19 +230,22 @@ static char* transports_print(uint64_t *unique_key) * this function MUST pack it for transport as the host will * not know how to do so */ static pmix_status_t allocate(pmix_namespace_t *nptr, - pmix_info_t *info, + pmix_info_t info[], size_t ninfo, pmix_list_t *ilist) { uint64_t unique_key[2]; char *string_key, *cs_env; int fd_rand; - size_t bytes_read; + size_t bytes_read, n, m, p; pmix_kval_t *kv; - bool envars, seckeys; + bool envars = false, seckeys = false, netalloc = false; pmix_status_t rc; - - envars = false; - seckeys = false; + pmix_proc_t pname; + pmix_coord_t coord; + pmix_buffer_t bucket; + pmix_info_t *iptr; + pmix_pnet_node_t *nd; + pmix_pnet_local_procs_t *lp; pmix_output_verbose(2, pmix_pnet_base_framework.framework_output, "pnet:opa:allocate for nspace %s", nptr->nspace); @@ -251,14 +254,33 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, return PMIX_ERR_TAKE_NEXT_OPTION; } - if (PMIX_CHECK_KEY(info, PMIX_SETUP_APP_ENVARS)) { - envars = PMIX_INFO_TRUE(info); - } else if (PMIX_CHECK_KEY(info, PMIX_SETUP_APP_ALL)) { - envars = PMIX_INFO_TRUE(info); - seckeys = PMIX_INFO_TRUE(info); - } else if (PMIX_CHECK_KEY(info, PMIX_SETUP_APP_NONENVARS) || - PMIX_CHECK_KEY(info, PMIX_ALLOC_NETWORK_SEC_KEY)) { - seckeys = PMIX_INFO_TRUE(info); + for (n=0; n < ninfo; n++) { + if (PMIX_CHECK_KEY(&info[n], PMIX_SETUP_APP_ENVARS)) { + envars = PMIX_INFO_TRUE(&info[n]); + } else if (PMIX_CHECK_KEY(&info[n], PMIX_SETUP_APP_ALL)) { + envars = PMIX_INFO_TRUE(&info[n]); + seckeys = PMIX_INFO_TRUE(&info[n]); + } else if (PMIX_CHECK_KEY(&info[n], PMIX_SETUP_APP_NONENVARS)) { + seckeys = PMIX_INFO_TRUE(&info[n]); + } else if (PMIX_CHECK_KEY(&info[n], PMIX_ALLOC_NETWORK)) { + iptr = (pmix_info_t*)info[n].value.data.darray->array; + m = info[n].value.data.darray->size; + for (p=0; p < m; p++) { + if (PMIX_CHECK_KEY(&iptr[p], PMIX_ALLOC_NETWORK_SEC_KEY)) { + seckeys = PMIX_INFO_TRUE(&iptr[p]); + } else if (PMIX_CHECK_KEY(&iptr[p], PMIX_ALLOC_NETWORK_ID)) { + /* need to track the request by this ID */ + } else if (PMIX_CHECK_KEY(&iptr[p], PMIX_SETUP_APP_ENVARS)) { + envars = PMIX_INFO_TRUE(&iptr[p]); + } else if (PMIX_CHECK_KEY(&iptr[p], PMIX_SETUP_APP_ALL)) { + envars = PMIX_INFO_TRUE(&iptr[p]); + seckeys = PMIX_INFO_TRUE(&iptr[p]); + } else if (PMIX_CHECK_KEY(&iptr[p], PMIX_SETUP_APP_NONENVARS)) { + seckeys = PMIX_INFO_TRUE(&iptr[p]); + } + } + netalloc = true; + } } if (seckeys) { @@ -307,10 +329,6 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, pmix_list_append(ilist, &kv->super); free(cs_env); free(string_key); - if (!envars) { - /* providing envars does not constitute allocating resources */ - return PMIX_ERR_TAKE_NEXT_OPTION; - } } if (envars) { @@ -323,13 +341,70 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, rc = pmix_pnet_base_harvest_envars(mca_pnet_opa_component.include, mca_pnet_opa_component.exclude, ilist); - if (PMIX_SUCCESS == rc) { - return PMIX_ERR_TAKE_NEXT_OPTION; + if (PMIX_SUCCESS != rc) { + return rc; } - return rc; } } + if (netalloc) { + /* assign a simulated coordinate to each process. For now, we + * assume there is one device per node. Thus, the coordinate of + * all procs on a node will be the network coord of the device + * on that node. We'll assign device coordinates with a simple + * round-robin algo */ + coord.y = 0; + coord.z = 0; + PMIX_LOAD_NSPACE(pname.nspace, nptr->nspace); + PMIX_CONSTRUCT(&bucket, pmix_buffer_t); + PMIX_LIST_FOREACH(nd, &pmix_pnet_globals.nodes, pmix_pnet_node_t) { + /* find the job on this node */ + PMIX_LIST_FOREACH(lp, &nd->local_jobs, pmix_pnet_local_procs_t) { + if (0 == strcmp(nptr->nspace, lp->nspace)) { + /* assign the coord for each proc - in our case, + * we shall assign an x-coord based on local rank + * and the y-coord will represent the node */ + for (n=0; n < lp->np; n++) { + coord.x = n; + pname.rank = lp->ranks[n]; + /* pack this value */ + PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, &bucket, &pname, 1, PMIX_PROC); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_DESTRUCT(&bucket); + return rc; + } + PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, &bucket, &coord, 1, PMIX_COORD); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_DESTRUCT(&bucket); + return rc; + } + } + break; + } + } + coord.y++; + } + /* pass that up */ + kv = PMIX_NEW(pmix_kval_t); + if (NULL == kv) { + PMIX_DESTRUCT(&bucket); + return PMIX_ERR_OUT_OF_RESOURCE; + } + kv->key = strdup(PMIX_PNET_OPA_BLOB); + kv->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + if (NULL == kv->value) { + PMIX_DESTRUCT(&bucket); + PMIX_RELEASE(kv); + return PMIX_ERR_OUT_OF_RESOURCE; + } + kv->value->type = PMIX_BYTE_OBJECT; + /* unload the buffer into a byte object */ + PMIX_UNLOAD_BUFFER(&bucket, kv->value->data.bo.bytes, kv->value->data.bo.size); + pmix_list_append(ilist, &kv->super); + } + /* we don't currently manage OPA resources */ return PMIX_ERR_TAKE_NEXT_OPTION; } @@ -343,15 +418,14 @@ static pmix_status_t setup_local_network(pmix_namespace_t *nptr, pmix_output_verbose(2, pmix_pnet_base_framework.framework_output, - "pnet: opa setup_local_network"); + "pnet: opa setup_local_network for nspace %s", nptr->nspace); if (NULL != info) { for (n=0; n < ninfo; n++) { if (0 == strncmp(info[n].key, PMIX_PNET_OPA_BLOB, PMIX_MAX_KEYLEN)) { /* the byte object contains a packed blob that needs to be * cached until we determine we have local procs for this - * nspace, and then delivered to the local OPA driver when - * we have a means for doing so */ + * nspace */ kv = PMIX_NEW(pmix_kval_t); if (NULL == kv) { return PMIX_ERR_NOMEM; @@ -384,9 +458,16 @@ static pmix_status_t setup_fork(pmix_namespace_t *nptr, char ***env) { pmix_kval_t *kv, *next; + pmix_data_array_t dinfo; + pmix_info_t info[2], stinfo; + int cnt; + pmix_status_t rc; + pmix_buffer_t bkt; + pmix_proc_t pname; + pmix_coord_t coord; pmix_output_verbose(2, pmix_pnet_base_framework.framework_output, - "pnet: opa setup fork"); + "pnet: opa setup fork for nspace: %s", nptr->nspace); /* if there are any cached nspace prep blobs, execute them, * ensuring that we only do so once per nspace - note that @@ -395,8 +476,44 @@ static pmix_status_t setup_fork(pmix_namespace_t *nptr, PMIX_LIST_FOREACH_SAFE(kv, next, &nptr->setup_data, pmix_kval_t) { if (0 == strcmp(kv->key, PMIX_PNET_OPA_BLOB)) { pmix_list_remove_item(&nptr->setup_data, &kv->super); - /* deliver to the local lib */ + /* setup to unpack the blob */ + PMIX_CONSTRUCT(&bkt,pmix_buffer_t); + PMIX_LOAD_BUFFER(pmix_globals.mypeer, &bkt, + kv->value->data.bo.bytes, + kv->value->data.bo.size); + /* there will be an entry for each proc in the nspace */ + PMIX_INFO_CONSTRUCT(&stinfo); + PMIX_LOAD_KEY(stinfo.key, PMIX_PROC_DATA); + stinfo.value.type = PMIX_DATA_ARRAY; + stinfo.value.data.darray = &dinfo; + dinfo.type = PMIX_INFO; + dinfo.size = 2; + dinfo.array = info; + /* unpack all the entries */ + cnt = 1; + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, + &bkt, &pname, &cnt, PMIX_PROC); + while (PMIX_SUCCESS == rc) { + /* unpack the coord of this proc */ + cnt = 1; + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, + &bkt, &coord, &cnt, PMIX_COORD); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + break; + } + /* cache the info on the job */ + PMIX_INFO_LOAD(&info[0], PMIX_RANK, &pname.rank, PMIX_PROC_RANK); + PMIX_INFO_LOAD(&info[1], PMIX_NETWORK_COORDINATE, &coord, PMIX_COORD); + PMIX_GDS_CACHE_JOB_INFO(rc, pmix_globals.mypeer, nptr, + &stinfo, 1); + /* unpack next entry */ + cnt = 1; + PMIX_BFROPS_UNPACK(rc, pmix_globals.mypeer, + &bkt, &pname, &cnt, PMIX_PROC); + } PMIX_RELEASE(kv); + break; } } return PMIX_SUCCESS; diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa.h b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa.h index c7a56a8a30..5fe18a4de8 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * * $COPYRIGHT$ * @@ -24,6 +24,7 @@ typedef struct { char *excparms; char **include; char **exclude; + int radix; } pmix_pnet_opa_component_t; /* the component must be visible data for the linker to find it */ diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa_component.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa_component.c index c7a7e9b6f8..4fb38a50e7 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa_component.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/opa/pnet_opa_component.c @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2016-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -66,7 +66,8 @@ pmix_pnet_opa_component_t mca_pnet_opa_component = { } }, .include = NULL, - .exclude = NULL + .exclude = NULL, + .radix = 64 }; static pmix_status_t component_register(void) @@ -95,6 +96,13 @@ static pmix_status_t component_register(void) mca_pnet_opa_component.exclude = pmix_argv_split(mca_pnet_opa_component.excparms, ','); } + (void)pmix_mca_base_component_var_register(component, "radix", + "Radix for simulating the network coordinates", + PMIX_MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, + PMIX_INFO_LVL_2, + PMIX_MCA_BASE_VAR_SCOPE_LOCAL, + &mca_pnet_opa_component.radix); + return PMIX_SUCCESS; } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/pnet.h b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/pnet.h index fb5cc7d363..92f102e81e 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/pnet.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/pnet.h @@ -4,7 +4,7 @@ * * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2018 Intel, Inc. All rights reserved. + * Copyright (c) 2018-2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -61,7 +61,7 @@ typedef void (*pmix_pnet_base_module_fini_fn_t)(void); * for forwarding to compute nodes, or allocation of static endpts */ typedef pmix_status_t (*pmix_pnet_base_module_allocate_fn_t)(pmix_namespace_t *nptr, - pmix_info_t *info, + pmix_info_t info[], size_t ninfo, pmix_list_t *ilist); /** diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/tcp/pnet_tcp.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/tcp/pnet_tcp.c index fecec01424..1672b81ac1 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/tcp/pnet_tcp.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/tcp/pnet_tcp.c @@ -50,7 +50,7 @@ static pmix_status_t tcp_init(void); static void tcp_finalize(void); static pmix_status_t allocate(pmix_namespace_t *nptr, - pmix_info_t *info, + pmix_info_t info[], size_t ninfo, pmix_list_t *ilist); static pmix_status_t setup_local_network(pmix_namespace_t *nptr, pmix_info_t info[], @@ -298,7 +298,7 @@ static inline void generate_key(uint64_t* unique_key) { * undoubtedly be vastly improved/optimized */ static pmix_status_t allocate(pmix_namespace_t *nptr, - pmix_info_t *info, + pmix_info_t info[], size_t ninfo, pmix_list_t *ilist) { uint64_t unique_key[2]; @@ -308,7 +308,7 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, pmix_status_t rc; pmix_info_t *requests = NULL; char **reqs, *cptr; - bool allocated = false, seckey = false; + bool allocated = false, seckey = false, envars = false; tcp_port_tracker_t *trk; tcp_available_ports_t *avail, *aptr; pmix_list_t mylist; @@ -330,41 +330,49 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, /* check directives to see if a crypto key and/or * network resource allocations requested */ - PMIX_CONSTRUCT(&mylist, pmix_list_t); - if (PMIX_CHECK_KEY(info, PMIX_SETUP_APP_ENVARS) || - PMIX_CHECK_KEY(info, PMIX_SETUP_APP_ALL)) { + for (n=0; n < ninfo; n++) { + if (PMIX_CHECK_KEY(&info[n], PMIX_SETUP_APP_ENVARS) || + PMIX_CHECK_KEY(&info[n], PMIX_SETUP_APP_ALL)) { + envars = PMIX_INFO_TRUE(&info[n]); + } else if (PMIX_CHECK_KEY(info, PMIX_ALLOC_NETWORK)) { + /* this info key includes an array of pmix_info_t, each providing + * a key (that is to be used as the key for the allocated ports) and + * a number of ports to allocate for that key */ + if (PMIX_DATA_ARRAY != info->value.type || + NULL == info->value.data.darray || + PMIX_INFO != info->value.data.darray->type || + NULL == info->value.data.darray->array) { + /* they made an error */ + PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); + return PMIX_ERR_BAD_PARAM; + } + requests = (pmix_info_t*)info->value.data.darray->array; + nreqs = info->value.data.darray->size; + } + } + + if (envars) { if (NULL != mca_pnet_tcp_component.include) { - pmix_output_verbose(2, pmix_pnet_base_framework.framework_output, - "pnet: tcp harvesting envars %s excluding %s", - (NULL == mca_pnet_tcp_component.incparms) ? "NONE" : mca_pnet_tcp_component.incparms, - (NULL == mca_pnet_tcp_component.excparms) ? "NONE" : mca_pnet_tcp_component.excparms); + pmix_output_verbose(2, pmix_pnet_base_framework.framework_output, + "pnet: tcp harvesting envars %s excluding %s", + (NULL == mca_pnet_tcp_component.incparms) ? "NONE" : mca_pnet_tcp_component.incparms, + (NULL == mca_pnet_tcp_component.excparms) ? "NONE" : mca_pnet_tcp_component.excparms); rc = pmix_pnet_base_harvest_envars(mca_pnet_tcp_component.include, mca_pnet_tcp_component.exclude, ilist); - return rc; + if (PMIX_SUCCESS != rc) { + return rc; + } } - return PMIX_SUCCESS; - } else if (!PMIX_CHECK_KEY(info, PMIX_ALLOC_NETWORK)) { - /* not a network allocation request */ - return PMIX_SUCCESS; + } + + if (NULL == requests) { + return PMIX_ERR_TAKE_NEXT_OPTION; } pmix_output_verbose(2, pmix_pnet_base_framework.framework_output, "pnet:tcp:allocate alloc_network for nspace %s", nptr->nspace); - /* this info key includes an array of pmix_info_t, each providing - * a key (that is to be used as the key for the allocated ports) and - * a number of ports to allocate for that key */ - if (PMIX_DATA_ARRAY != info->value.type || - NULL == info->value.data.darray || - PMIX_INFO != info->value.data.darray->type || - NULL == info->value.data.darray->array) { - /* they made an error */ - PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); - return PMIX_ERR_BAD_PARAM; - } - requests = (pmix_info_t*)info->value.data.darray->array; - nreqs = info->value.data.darray->size; /* cycle thru the provided array and see if this refers to * tcp/udp-based resources - there is no required ordering * of the keys, so just have to do a search */ @@ -408,6 +416,7 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, return PMIX_ERR_BAD_PARAM; } + PMIX_CONSTRUCT(&mylist, pmix_list_t); /* must include the idkey */ kv = PMIX_NEW(pmix_kval_t); if (NULL == kv) { diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/test/pnet_test.c b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/test/pnet_test.c index 830e0c02e5..a00cff1c35 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/test/pnet_test.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/pnet/test/pnet_test.c @@ -47,7 +47,7 @@ static pmix_status_t test_init(void); static void test_finalize(void); static pmix_status_t allocate(pmix_namespace_t *nptr, - pmix_info_t *info, + pmix_info_t info[], size_t ninfo, pmix_list_t *ilist); static pmix_status_t setup_local_network(pmix_namespace_t *nptr, pmix_info_t info[], @@ -95,11 +95,11 @@ static void test_finalize(void) * this function MUST pack it for transport as the host will * not know how to do so */ static pmix_status_t allocate(pmix_namespace_t *nptr, - pmix_info_t *info, + pmix_info_t info[], size_t ninfo, pmix_list_t *ilist) { pmix_kval_t *kv; - bool seckey = false; + bool seckey = false, envars = false; pmix_list_t mylist; size_t n, nreqs=0; pmix_info_t *requests = NULL; @@ -126,9 +126,27 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, } /* check directives to see if a crypto key and/or * network resource allocations requested */ - PMIX_CONSTRUCT(&mylist, pmix_list_t); - if (0 == strncmp(info->key, PMIX_SETUP_APP_ENVARS, PMIX_MAX_KEYLEN) || - 0 == strncmp(info->key, PMIX_SETUP_APP_ALL, PMIX_MAX_KEYLEN)) { + for (n=0; n < ninfo; n++) { + if (PMIX_CHECK_KEY(&info[n], PMIX_SETUP_APP_ENVARS) || + PMIX_CHECK_KEY(&info[n], PMIX_SETUP_APP_ALL)) { + envars = PMIX_INFO_TRUE(&info[n]); + } else if (PMIX_CHECK_KEY(&info[n], PMIX_ALLOC_NETWORK_ID)) { + /* this info key includes an array of pmix_info_t, each providing + * a key (that is to be used as the key for the allocated ports) and + * a number of ports to allocate for that key */ + if (PMIX_DATA_ARRAY != info->value.type || + NULL == info->value.data.darray || + PMIX_INFO != info->value.data.darray->type || + NULL == info->value.data.darray->array) { + /* just process something for test */ + goto process; + } + requests = (pmix_info_t*)info->value.data.darray->array; + nreqs = info->value.data.darray->size; + } + } + + if (envars) { kv = PMIX_NEW(pmix_kval_t); if (NULL == kv) { return PMIX_ERR_NOMEM; @@ -142,27 +160,16 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, kv->value->type = PMIX_ENVAR; PMIX_ENVAR_LOAD(&kv->value->data.envar, "PMIX_TEST_ENVAR", "1", ':'); pmix_list_append(ilist, &kv->super); - return PMIX_SUCCESS; - } else if (0 != strncmp(info->key, PMIX_ALLOC_NETWORK_ID, PMIX_MAX_KEYLEN)) { - return PMIX_SUCCESS; + } + + if (NULL == requests) { + return PMIX_ERR_TAKE_NEXT_OPTION; } pmix_output_verbose(2, pmix_pnet_base_framework.framework_output, "pnet:test:allocate alloc_network for nspace %s", nptr->nspace); - /* this info key includes an array of pmix_info_t, each providing - * a key (that is to be used as the key for the allocated ports) and - * a number of ports to allocate for that key */ - if (PMIX_DATA_ARRAY != info->value.type || - NULL == info->value.data.darray || - PMIX_INFO != info->value.data.darray->type || - NULL == info->value.data.darray->array) { - /* just process something for test */ - goto process; - } - requests = (pmix_info_t*)info->value.data.darray->array; - nreqs = info->value.data.darray->size; /* cycle thru the provided array and get the ID key */ for (n=0; n < nreqs; n++) { if (0 == strncmp(requests[n].key, PMIX_ALLOC_NETWORK_ID, PMIX_MAX_KEYLEN)) { @@ -183,6 +190,7 @@ static pmix_status_t allocate(pmix_namespace_t *nptr, if (NULL == idkey) { idkey = "TESTKEY"; } + PMIX_CONSTRUCT(&mylist, pmix_list_t); /* must include the idkey */ kv = PMIX_NEW(pmix_kval_t); diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/preg/base/preg_base_frame.c b/opal/mca/pmix/pmix4x/pmix/src/mca/preg/base/preg_base_frame.c index 5f6c5afce7..706c2bc8aa 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/preg/base/preg_base_frame.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/preg/base/preg_base_frame.c @@ -11,7 +11,7 @@ * 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-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. * Copyright (c) 2015-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2019 IBM Corporation. All rights reserved. diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/preg/native/preg_native.c b/opal/mca/pmix/pmix4x/pmix/src/mca/preg/native/preg_native.c index 502663cfdf..0d31f96435 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/preg/native/preg_native.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/preg/native/preg_native.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. * Copyright (c) 2016-2019 IBM Corporation. All rights reserved. * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/preg/preg_types.h b/opal/mca/pmix/pmix4x/pmix/src/mca/preg/preg_types.h index 572b321b04..932d8e552c 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/preg/preg_types.h +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/preg/preg_types.h @@ -12,7 +12,7 @@ * 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-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. * Copyright (c) 2019 IBM Corporation. All rights reserved. * $COPYRIGHT$ * diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/psensor/file/psensor_file.c b/opal/mca/pmix/pmix4x/pmix/src/mca/psensor/file/psensor_file.c index 3a050823c2..4b4ccd913b 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/psensor/file/psensor_file.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/psensor/file/psensor_file.c @@ -7,6 +7,8 @@ * All rights reserved. * * Copyright (c) 2017-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -15,7 +17,6 @@ */ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_listener.c b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_listener.c index 3a5ab90263..ddc284f8ab 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_listener.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_listener.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014-2015 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_sendrecv.c b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_sendrecv.c index 0b465340be..9857bc8a11 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_sendrecv.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/base/ptl_base_sendrecv.c @@ -2,8 +2,8 @@ * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. - * Copyright (c) 2015-2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. @@ -15,7 +15,6 @@ */ #include -#include #include #include @@ -55,13 +54,6 @@ static void _notify_complete(pmix_status_t status, void *cbdata) PMIX_RELEASE(chain); } -static void _timeout(int sd, short args, void *cbdata) -{ - pmix_server_trkr_t *trk = (pmix_server_trkr_t*)cbdata; - - PMIX_RELEASE(trk); -} - static void lcfn(pmix_status_t status, void *cbdata) { pmix_peer_t *peer = (pmix_peer_t*)cbdata; @@ -76,7 +68,6 @@ void pmix_ptl_base_lost_connection(pmix_peer_t *peer, pmix_status_t err) pmix_ptl_posted_recv_t *rcv; pmix_buffer_t buf; pmix_ptl_hdr_t hdr; - struct timeval tv = {1200, 0}; pmix_proc_t proc; pmix_status_t rc; @@ -114,59 +105,60 @@ void pmix_ptl_base_lost_connection(pmix_peer_t *peer, pmix_status_t err) /* remove it from the list */ pmix_list_remove_item(&trk->local_cbs, &rinfo->super); PMIX_RELEASE(rinfo); - trk->lost_connection = true; // mark that a peer's connection was lost - if (0 == pmix_list_get_size(&trk->local_cbs)) { - /* this tracker is complete, so release it - there - * is nobody waiting for a response */ - pmix_list_remove_item(&pmix_server_globals.collectives, &trk->super); - /* do NOT release the tracker here as the host may - * have a copy they will return later. However, they - * might never call back, so set a LONG timeout to - * we avoid a memory leak if they don't */ - pmix_event_evtimer_set(pmix_globals.evbase, &trk->ev, - _timeout, trk); - pmix_event_evtimer_add(&trk->ev, &tv); - trk->event_active = true; - break; + /* if the host has already been called for this tracker, + * then do nothing here - just wait for the host to return + * from the operation */ + if (trk->host_called) { + continue; } - /* if there are other participants waiting for a response, - * we need to let them know that this proc has disappeared - * as otherwise the collective will never complete */ - if (PMIX_FENCENB_CMD == trk->type) { - if (NULL != trk->modexcbfunc) { - /* do NOT release the tracker here as the host may - * have a copy they will return later. However, they - * might never call back, so set a LONG timeout to - * we avoid a memory leak if they don't */ - pmix_event_evtimer_set(pmix_globals.evbase, &trk->ev, - _timeout, trk); - pmix_event_evtimer_add(&trk->ev, &tv); - trk->event_active = true; - trk->modexcbfunc(PMIX_ERR_LOST_CONNECTION_TO_CLIENT, NULL, 0, trk, NULL, NULL); - } - } else if (PMIX_CONNECTNB_CMD == trk->type) { - if (NULL != trk->op_cbfunc) { - /* do NOT release the tracker here as the host may - * have a copy they will return later. However, they - * might never call back, so set a LONG timeout to - * we avoid a memory leak if they don't */ - pmix_event_evtimer_set(pmix_globals.evbase, &trk->ev, - _timeout, trk); - pmix_event_evtimer_add(&trk->ev, &tv); - trk->event_active = true; - trk->op_cbfunc(PMIX_ERR_LOST_CONNECTION_TO_CLIENT, trk); - } - } else if (PMIX_DISCONNECTNB_CMD == trk->type) { - if (NULL != trk->op_cbfunc) { - /* do NOT release the tracker here as the host may - * have a copy they will return later. However, they - * might never call back, so set a LONG timeout to - * we avoid a memory leak if they don't */ - pmix_event_evtimer_set(pmix_globals.evbase, &trk->ev, - _timeout, trk); - pmix_event_evtimer_add(&trk->ev, &tv); - trk->event_active = true; - trk->op_cbfunc(PMIX_ERR_LOST_CONNECTION_TO_CLIENT, trk); + if (trk->def_complete && trk->nlocal == pmix_list_get_size(&trk->local_cbs)) { + /* if this is a local-only collective, then resolve it now */ + if (trk->local) { + /* everyone else has called in - we need to let them know + * that this proc has disappeared + * as otherwise the collective will never complete */ + if (PMIX_FENCENB_CMD == trk->type) { + if (NULL != trk->modexcbfunc) { + trk->modexcbfunc(PMIX_ERR_LOST_CONNECTION_TO_CLIENT, NULL, 0, trk, NULL, NULL); + } + } else if (PMIX_CONNECTNB_CMD == trk->type) { + if (NULL != trk->op_cbfunc) { + trk->op_cbfunc(PMIX_ERR_LOST_CONNECTION_TO_CLIENT, trk); + } + } else if (PMIX_DISCONNECTNB_CMD == trk->type) { + if (NULL != trk->op_cbfunc) { + trk->op_cbfunc(PMIX_ERR_LOST_CONNECTION_TO_CLIENT, trk); + } + } + } else { + /* if the host has not been called, then we need to see if + * the collective is locally complete without this lost + * participant. If so, then we need to pass the call + * up to the host as otherwise the global collective will hang */ + if (PMIX_FENCENB_CMD == trk->type) { + trk->host_called = true; + rc = pmix_host_server.fence_nb(trk->pcs, trk->npcs, + trk->info, trk->ninfo, + NULL, 0, trk->modexcbfunc, trk); + if (PMIX_SUCCESS != rc) { + pmix_list_remove_item(&pmix_server_globals.collectives, &trk->super); + PMIX_RELEASE(trk); + } + } else if (PMIX_CONNECTNB_CMD == trk->type) { + trk->host_called = true; + rc = pmix_host_server.connect(trk->pcs, trk->npcs, trk->info, trk->ninfo, trk->op_cbfunc, trk); + if (PMIX_SUCCESS != rc) { + pmix_list_remove_item(&pmix_server_globals.collectives, &trk->super); + PMIX_RELEASE(trk); + } + } else if (PMIX_DISCONNECTNB_CMD == trk->type) { + trk->host_called = true; + rc = pmix_host_server.disconnect(trk->pcs, trk->npcs, trk->info, trk->ninfo, trk->op_cbfunc, trk); + if (PMIX_SUCCESS != rc) { + pmix_list_remove_item(&pmix_server_globals.collectives, &trk->super); + PMIX_RELEASE(trk); + } + } } } } diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/tcp/ptl_tcp.c b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/tcp/ptl_tcp.c index e921cd599c..b5e9b0a899 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/tcp/ptl_tcp.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/tcp/ptl_tcp.c @@ -24,6 +24,7 @@ */ #include +#include "src/include/pmix_globals.h" #ifdef HAVE_FCNTL_H #include @@ -50,7 +51,6 @@ #include #endif -#include "src/include/pmix_globals.h" #include "src/include/pmix_socket_errno.h" #include "src/client/pmix_client_ops.h" #include "src/server/pmix_server_ops.h" @@ -152,7 +152,17 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, /* if I am a client, then we need to look for the appropriate * connection info in the environment */ if (PMIX_PROC_IS_CLIENT(pmix_globals.mypeer)) { - if (NULL != (evar = getenv("PMIX_SERVER_URI3"))) { + if (NULL != (evar = getenv("PMIX_SERVER_URI4"))) { + /* we are talking to a v3 server */ + pmix_client_globals.myserver->proc_type = PMIX_PROC_SERVER | PMIX_PROC_V3; + pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, + "V3 SERVER DETECTED"); + /* must use the v3 bfrops module */ + pmix_globals.mypeer->nptr->compat.bfrops = pmix_bfrops_base_assign_module(NULL); + if (NULL == pmix_globals.mypeer->nptr->compat.bfrops) { + return PMIX_ERR_INIT; + } + } else if (NULL != (evar = getenv("PMIX_SERVER_URI3"))) { /* we are talking to a v3 server */ pmix_client_globals.myserver->proc_type = PMIX_PROC_SERVER | PMIX_PROC_V3; pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, @@ -251,14 +261,8 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, continue; } /* otherwise, we don't know which one to use */ - free(server_nspace); - if (NULL != suri) { - free(suri); - } - if (NULL != rendfile) { - free(rendfile); - } - return PMIX_ERR_BAD_PARAM; + rc = PMIX_ERR_BAD_PARAM; + goto cleanup; } server_nspace = strdup(info[n].value.data.string); } else if (PMIX_CHECK_KEY(&info[n], PMIX_SERVER_URI)) { @@ -269,14 +273,8 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, continue; } /* otherwise, we don't know which one to use */ - free(suri); - if (NULL != server_nspace) { - free(server_nspace); - } - if (NULL != rendfile) { - free(rendfile); - } - return PMIX_ERR_BAD_PARAM; + rc = PMIX_ERR_BAD_PARAM; + goto cleanup; } suri = strdup(info[n].value.data.string); } else if (PMIX_CHECK_KEY(&info[n], PMIX_CONNECT_RETRY_DELAY)) { @@ -327,13 +325,16 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1) { fprintf(stderr, "sysctl() argmax failed\n"); - return -1; + rc = PMIX_ERR_NO_PERMISSIONS; + goto cleanup; } /* Allocate space for the arguments. */ procargs = (char *)malloc(argmax); - if (procargs == NULL) - return -1; + if (procargs == NULL) { + rc = -1; + goto cleanup; + } /* Make a sysctl() call to get the raw argument space of the process. */ mib[0] = CTL_KERN; @@ -344,7 +345,8 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, if (sysctl(mib, 3, procargs, &size, NULL, 0) == -1) { fprintf(stderr, "Lacked permissions\n");; - return 0; + rc = PMIX_ERR_NO_PERMISSIONS; + goto cleanup; } memcpy(&nargs, procargs, sizeof(nargs)); @@ -417,10 +419,6 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, gethostname(myhost, sizeof(myhost)); /* if we were given a URI via MCA param, then look no further */ if (NULL != suri) { - if (NULL != server_nspace) { - free(server_nspace); - server_nspace = NULL; - } /* if the string starts with "file:", then they are pointing * us to a file we need to read to get the URI itself */ if (0 == strncmp(suri, "file:", 5)) { @@ -430,13 +428,8 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, rc = parse_uri_file(&suri[5], &suri2, &nspace, &rank); if (PMIX_SUCCESS != rc) { free(suri); - if (NULL != rendfile) { - free(rendfile); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_UNREACH; + rc = PMIX_ERR_UNREACH; + goto cleanup; } free(suri); suri = suri2; @@ -445,13 +438,8 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, p = strchr(suri, ';'); if (NULL == p) { free(suri); - if (NULL != rendfile) { - free(rendfile); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_BAD_PARAM; + rc = PMIX_ERR_BAD_PARAM; + goto cleanup; } *p = '\0'; p++; @@ -462,13 +450,8 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, if (NULL == p) { free(suri2); free(suri); - if (NULL != rendfile) { - free(rendfile); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_BAD_PARAM; + rc = PMIX_ERR_BAD_PARAM; + goto cleanup; } *p = '\0'; p++; @@ -485,24 +468,9 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, if (NULL != nspace) { free(nspace); } - free(suri); - if (NULL != rendfile) { - free(rendfile); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return rc; + goto cleanup; } /* cleanup */ - free(suri); - suri = NULL; - if (NULL != rendfile) { - free(rendfile); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } goto complete; } @@ -527,29 +495,17 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, goto complete; } } - /* cleanup */ - if (NULL != nspace) { - free(nspace); - } - if (NULL != suri) { - free(suri); - } - free(rendfile); - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } /* since they gave us a specific rendfile and we couldn't * connect to it, return an error */ - return PMIX_ERR_UNREACH; + rc = PMIX_ERR_UNREACH; + goto cleanup; } /* if they asked for system-level first or only, we start there */ if (system_level || system_level_only) { if (0 > asprintf(&filename, "%s/pmix.sys.%s", mca_ptl_tcp_component.system_tmpdir, myhost)) { - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_NOMEM; + rc = PMIX_ERR_NOMEM; + goto cleanup; } pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "ptl:tcp:tool looking for system server at %s", @@ -563,9 +519,6 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, /* go ahead and try to connect */ if (PMIX_SUCCESS == try_connect(suri, &sd, iptr, niptr)) { /* don't free nspace - we will use it below */ - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } goto complete; } free(nspace); @@ -578,26 +531,15 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, if (system_level_only) { pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "ptl:tcp: connecting to system failed"); - if (NULL != suri) { - free(suri); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_UNREACH; + rc = PMIX_ERR_UNREACH; + goto cleanup; } /* if they gave us a pid, then look for it */ if (0 != pid) { - if (NULL != server_nspace) { - free(server_nspace); - server_nspace = NULL; - } if (0 > asprintf(&filename, "pmix.%s.tool.%d", myhost, pid)) { - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_NOMEM; + rc = PMIX_ERR_NOMEM; + goto cleanup; } pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "ptl:tcp:tool searching for given session server %s", @@ -609,28 +551,17 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, if (PMIX_SUCCESS == rc) { goto complete; } - if (NULL != suri) { - free(suri); - } - if (NULL != nspace) { - free(nspace); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } /* since they gave us a specific pid and we couldn't * connect to it, return an error */ - return PMIX_ERR_UNREACH; + rc = PMIX_ERR_UNREACH; + goto cleanup; } /* if they gave us an nspace, then look for it */ if (NULL != server_nspace) { if (0 > asprintf(&filename, "pmix.%s.tool.%s", myhost, server_nspace)) { - free(server_nspace); - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_NOMEM; + rc = PMIX_ERR_NOMEM; + goto cleanup; } free(server_nspace); server_nspace = NULL; @@ -644,18 +575,10 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, if (PMIX_SUCCESS == rc) { goto complete; } - if (NULL != suri) { - free(suri); - } - if (NULL != nspace) { - free(nspace); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } /* since they gave us a specific nspace and we couldn't * connect to it, return an error */ - return PMIX_ERR_UNREACH; + rc = PMIX_ERR_UNREACH; + goto cleanup; } /* they didn't give us a pid, so we will search to see what session-level @@ -664,13 +587,8 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, * one session per user on a node */ if (0 > asprintf(&filename, "pmix.%s.tool", myhost)) { - if (NULL != suri) { - free(suri); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_NOMEM; + rc = PMIX_ERR_NOMEM; + goto cleanup; } pmix_output_verbose(2, pmix_ptl_base_framework.framework_output, "ptl:tcp:tool searching for session server %s", @@ -680,19 +598,8 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, filename, iptr, niptr, &sd, &nspace, &rank, &suri); free(filename); if (PMIX_SUCCESS != rc) { - if (NULL != nspace){ - free(nspace); - } - if (NULL != suri) { - free(suri); - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); - } - return PMIX_ERR_UNREACH; - } - if (NULL != iptr) { - PMIX_INFO_FREE(iptr, niptr); + rc = PMIX_ERR_UNREACH; + goto cleanup; } complete: @@ -701,14 +608,9 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, /* do a final bozo check */ if (NULL == nspace || PMIX_RANK_WILDCARD == rank) { - if (NULL != nspace) { - free(nspace); - } - if (NULL != suri) { - free(suri); - } CLOSE_THE_SOCKET(sd); - return PMIX_ERR_UNREACH; + rc = PMIX_ERR_UNREACH; + goto cleanup; } /* mark the connection as made */ pmix_globals.connected = true; @@ -766,11 +668,24 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, pmix_ptl_base_send_handler, pmix_client_globals.myserver); pmix_client_globals.myserver->send_ev_active = false; - free(nspace); + cleanup: + if (NULL != nspace) { + free(nspace); + } + if (NULL != iptr) { + PMIX_INFO_FREE(iptr, niptr); + } + if (NULL != rendfile) { + free(rendfile); + } if (NULL != suri) { free(suri); } - return PMIX_SUCCESS; + if (NULL != server_nspace) { + free(server_nspace); + server_nspace = NULL; + } + return rc; } static pmix_status_t send_recv(struct pmix_peer_t *peer, diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c index 7f3138d52c..27313f6099 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c @@ -15,7 +15,7 @@ * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. * Copyright (c) 2017-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2018 IBM Corporation. All rights reserved. + * Copyright (c) 2018-2019 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -555,7 +555,7 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, } lt = PMIX_NEW(pmix_listener_t); - lt->varname = strdup("PMIX_SERVER_URI3:PMIX_SERVER_URI2:PMIX_SERVER_URI21"); + lt->varname = strdup("PMIX_SERVER_URI4:PMIX_SERVER_URI3:PMIX_SERVER_URI2:PMIX_SERVER_URI21"); lt->protocol = PMIX_PROTOCOL_V2; lt->ptl = (struct pmix_ptl_module_t*)&pmix_ptl_tcp_module; lt->cbfunc = connection_handler; @@ -1880,7 +1880,7 @@ static void process_cbfunc(int sd, short args, void *cbdata) /* probably cannot send an error reply if we are out of memory */ return; } - info->peerid = peer->index; + peer->info->peerid = peer->index; /* start the events for this tool */ pmix_event_assign(&peer->recv_event, pmix_globals.evbase, peer->sd, diff --git a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/usock/ptl_usock.c b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/usock/ptl_usock.c index fc7b6da1c4..41e6ce3e5f 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/usock/ptl_usock.c +++ b/opal/mca/pmix/pmix4x/pmix/src/mca/ptl/usock/ptl_usock.c @@ -14,6 +14,8 @@ * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -611,7 +613,7 @@ void pmix_usock_send_handler(int sd, short flags, void *cbdata) return; } else { // report the error - event_del(&peer->send_event); + pmix_event_del(&peer->send_event); peer->send_ev_active = false; PMIX_RELEASE(msg); peer->send_msg = NULL; diff --git a/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_finalize.c b/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_finalize.c index 87a1456f4d..89f96ed3cd 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_finalize.c +++ b/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_finalize.c @@ -12,7 +12,7 @@ * Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2010-2015 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2016-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ @@ -28,12 +28,14 @@ #include "src/class/pmix_object.h" #include "src/client/pmix_client_ops.h" +#include "src/common/pmix_attributes.h" #include "src/util/output.h" #include "src/util/keyval_parse.h" #include "src/util/show_help.h" #include "src/mca/base/base.h" #include "src/mca/base/pmix_mca_base_var.h" #include "src/mca/bfrops/base/base.h" +#include "src/mca/pcompress/base/base.h" #include "src/mca/gds/base/base.h" #include "src/mca/pif/base/base.h" #include "src/mca/pinstalldirs/base/base.h" @@ -63,6 +65,8 @@ void pmix_rte_finalize(void) return; } + /* release the attribute support trackers */ + pmix_release_registered_attrs(); /* close plog */ (void)pmix_mca_base_framework_close(&pmix_plog_base_framework); @@ -79,6 +83,9 @@ void pmix_rte_finalize(void) /* close bfrops */ (void)pmix_mca_base_framework_close(&pmix_bfrops_base_framework); + /* close compress */ + (void)pmix_mca_base_framework_close(&pmix_pcompress_base_framework); + /* close GDS */ (void)pmix_mca_base_framework_close(&pmix_gds_base_framework); @@ -116,6 +123,7 @@ void pmix_rte_finalize(void) } PMIX_DESTRUCT(&pmix_globals.notifications); PMIX_LIST_DESTRUCT(&pmix_globals.iof_requests); + PMIX_LIST_DESTRUCT(&pmix_globals.stdin_targets); /* now safe to release the event base */ if (!pmix_globals.external_evbase) { diff --git a/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_init.c b/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_init.c index d1803de704..020b602f44 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_init.c +++ b/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_init.c @@ -32,16 +32,16 @@ #ifdef HAVE_UNISTD_H #include #endif -#include PMIX_EVENT_HEADER -#include "event2/thread.h" #include +#include "src/include/pmix_globals.h" #include "src/util/output.h" #include "src/util/show_help.h" #include "src/mca/base/base.h" #include "src/mca/base/pmix_mca_base_var.h" #include "src/mca/bfrops/base/base.h" +#include "src/mca/pcompress/base/base.h" #include "src/mca/gds/base/base.h" #include "src/mca/pif/base/base.h" #include "src/mca/pinstalldirs/base/base.h" @@ -52,6 +52,7 @@ #include "src/mca/ptl/base/base.h" #include "src/client/pmix_client_ops.h" +#include "src/common/pmix_attributes.h" #include "src/event/pmix_event.h" #include "src/include/types.h" #include "src/util/error.h" @@ -66,7 +67,10 @@ PMIX_EXPORT int pmix_initialized = 0; PMIX_EXPORT bool pmix_init_called = false; /* we have to export the pmix_globals object so * all plugins can access it. However, it is included - * in the pmix_rename.h file for external protection */ + * in the pmix_rename.h file for external protection. + * Initialize only those entries that are not covered + * by MCA params or are complex structures initialized + * below */ PMIX_EXPORT pmix_globals_t pmix_globals = { .init_cntr = 0, .mypeer = NULL, @@ -78,7 +82,8 @@ PMIX_EXPORT pmix_globals_t pmix_globals = { .debug_output = -1, .connected = false, .commits_pending = false, - .mygds = NULL + .mygds = NULL, + .pushstdin = false }; @@ -176,9 +181,10 @@ int pmix_rte_init(pmix_proc_type_t type, error = "notification hotel init"; goto return_error; } - /* and setup the iof request tracking list */ PMIX_CONSTRUCT(&pmix_globals.iof_requests, pmix_list_t); + /* setup the stdin forwarding target list */ + PMIX_CONSTRUCT(&pmix_globals.stdin_targets, pmix_list_t); /* Setup client verbosities as all procs are allowed to * access client APIs */ @@ -285,6 +291,16 @@ int pmix_rte_init(pmix_proc_type_t type, goto return_error; } + /* open and select the compress framework */ + if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_pcompress_base_framework, 0)) ) { + error = "pmix_pcompress_base_open"; + goto return_error; + } + if (PMIX_SUCCESS != (ret = pmix_compress_base_select()) ) { + error = "pmix_pcompress_base_select"; + goto return_error; + } + /* open the ptl and select the active plugins */ if (PMIX_SUCCESS != (ret = pmix_mca_base_framework_open(&pmix_ptl_base_framework, 0)) ) { error = "pmix_ptl_base_open"; @@ -346,6 +362,9 @@ int pmix_rte_init(pmix_proc_type_t type, goto return_error; } + /* initialize the attribute support system */ + pmix_init_registered_attrs(); + /* if an external event base wasn't provide, create one */ if (!pmix_globals.external_evbase) { /* tell libevent that we need thread support */ diff --git a/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_params.c b/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_params.c index 8d49e8bdaa..9772a9674e 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_params.c +++ b/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_params.c @@ -17,8 +17,8 @@ * Copyright (c) 2010-2014 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2014 Hochschule Esslingen. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2015-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2015-2018 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. @@ -31,7 +31,6 @@ #include "pmix_config.h" -#include "src/include/types.h" #include "src/mca/base/pmix_mca_base_var.h" #include "src/runtime/pmix_rte.h" #include "src/util/timings.h" diff --git a/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_progress_threads.c b/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_progress_threads.c index df0af87c28..83b1582c00 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_progress_threads.c +++ b/opal/mca/pmix/pmix4x/pmix/src/runtime/pmix_progress_threads.c @@ -1,8 +1,8 @@ /* * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2017 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2017-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -11,7 +11,6 @@ */ #include -#include "src/include/types.h" #ifdef HAVE_UNISTD_H #include @@ -47,6 +46,12 @@ typedef struct { bool engine_constructed; pmix_thread_t engine; +#if PMIX_HAVE_LIBEV + ev_async async; + pthread_mutex_t mutex; + pthread_cond_t cond; + pmix_list_t list; +#endif } pmix_progress_tracker_t; static void tracker_constructor(pmix_progress_tracker_t *p) @@ -56,6 +61,10 @@ static void tracker_constructor(pmix_progress_tracker_t *p) p->ev_base = NULL; p->ev_active = false; p->engine_constructed = false; +#if PMIX_HAVE_LIBEV + pthread_mutex_init(&p->mutex, NULL); + PMIX_CONSTRUCT(&p->list, pmix_list_t); +#endif } static void tracker_destructor(pmix_progress_tracker_t *p) @@ -71,6 +80,10 @@ static void tracker_destructor(pmix_progress_tracker_t *p) if (p->engine_constructed) { PMIX_DESTRUCT(&p->engine); } +#if PMIX_HAVE_LIBEV + pthread_mutex_destroy(&p->mutex); + PMIX_LIST_DESTRUCT(&p->list); +#endif } static PMIX_CLASS_INSTANCE(pmix_progress_tracker_t, @@ -78,6 +91,114 @@ static PMIX_CLASS_INSTANCE(pmix_progress_tracker_t, tracker_constructor, tracker_destructor); +#if PMIX_HAVE_LIBEV + +typedef enum { + PMIX_EVENT_ACTIVE, + PMIX_EVENT_ADD, + PMIX_EVENT_DEL +} pmix_event_type_t; + +typedef struct { + pmix_list_item_t super; + struct event *ev; + struct timeval *tv; + int res; + short ncalls; + pmix_event_type_t type; +} pmix_event_caddy_t; + +static PMIX_CLASS_INSTANCE(pmix_event_caddy_t, + pmix_list_item_t, + NULL, NULL); + +static pmix_progress_tracker_t* pmix_progress_tracker_get_by_base(struct event_base *); + +static void pmix_libev_ev_async_cb (EV_P_ ev_async *w, int revents) +{ + pmix_progress_tracker_t *trk = pmix_progress_tracker_get_by_base((struct event_base *)EV_A); + assert(NULL != trk); + pthread_mutex_lock (&trk->mutex); + pmix_event_caddy_t *cd, *next; + PMIX_LIST_FOREACH_SAFE(cd, next, &trk->list, pmix_event_caddy_t) { + switch (cd->type) { + case PMIX_EVENT_ADD: + (void)event_add(cd->ev, cd->tv); + break; + case PMIX_EVENT_DEL: + (void)event_del(cd->ev); + break; + case PMIX_EVENT_ACTIVE: + (void)event_active(cd->ev, cd->res, cd->ncalls); + break; + } + pmix_list_remove_item(&trk->list, &cd->super); + PMIX_RELEASE(cd); + } + pthread_mutex_unlock (&trk->mutex); +} + +int pmix_event_add(struct event *ev, struct timeval *tv) { + int res; + pmix_progress_tracker_t *trk = pmix_progress_tracker_get_by_base(ev->ev_base); + if ((NULL != trk) && !pthread_equal(pthread_self(), trk->engine.t_handle)) { + pmix_event_caddy_t *cd = PMIX_NEW(pmix_event_caddy_t); + cd->type = PMIX_EVENT_ADD; + cd->ev = ev; + cd->tv = tv; + pthread_mutex_lock(&trk->mutex); + pmix_list_append(&trk->list, &cd->super); + ev_async_send ((struct ev_loop *)trk->ev_base, &trk->async); + pthread_mutex_unlock(&trk->mutex); + res = PMIX_SUCCESS; + } else { + res = event_add(ev, tv); + } + return res; +} + +int pmix_event_del(struct event *ev) { + int res; + pmix_progress_tracker_t *trk = pmix_progress_tracker_get_by_base(ev->ev_base); + if ((NULL != trk) && !pthread_equal(pthread_self(), trk->engine.t_handle)) { + pmix_event_caddy_t *cd = PMIX_NEW(pmix_event_caddy_t); + cd->type = PMIX_EVENT_DEL; + cd->ev = ev; + pthread_mutex_lock(&trk->mutex); + pmix_list_append(&trk->list, &cd->super); + ev_async_send ((struct ev_loop *)trk->ev_base, &trk->async); + pthread_mutex_unlock(&trk->mutex); + res = PMIX_SUCCESS; + } else { + res = event_del(ev); + } + return res; +} + +void pmix_event_active (struct event *ev, int res, short ncalls) { + pmix_progress_tracker_t *trk = pmix_progress_tracker_get_by_base(ev->ev_base); + if ((NULL != trk) && !pthread_equal(pthread_self(), trk->engine.t_handle)) { + pmix_event_caddy_t *cd = PMIX_NEW(pmix_event_caddy_t); + cd->type = PMIX_EVENT_ACTIVE; + cd->ev = ev; + cd->res = res; + cd->ncalls = ncalls; + pthread_mutex_lock(&trk->mutex); + pmix_list_append(&trk->list, &cd->super); + ev_async_send ((struct ev_loop *)trk->ev_base, &trk->async); + pthread_mutex_unlock(&trk->mutex); + } else { + event_active(ev, res, ncalls); + } +} + +void pmix_event_base_loopbreak (pmix_event_base_t *ev_base) { + pmix_progress_tracker_t *trk = pmix_progress_tracker_get_by_base(ev_base); + assert(NULL != trk); + ev_async_send ((struct ev_loop *)trk->ev_base, &trk->async); +} +#endif + static bool inited = false; static pmix_list_t tracking; static struct timeval long_timeout = { @@ -116,7 +237,6 @@ static void stop_progress_engine(pmix_progress_tracker_t *trk) { assert(trk->ev_active); trk->ev_active = false; - /* break the event loop - this will cause the loop to exit upon completion of any current event */ pmix_event_base_loopbreak(trk->ev_base); @@ -190,6 +310,11 @@ pmix_event_base_t *pmix_progress_thread_init(const char *name) dummy_timeout_cb, trk); pmix_event_add(&trk->block, &long_timeout); +#if PMIX_HAVE_LIBEV + ev_async_init (&trk->async, pmix_libev_ev_async_cb); + ev_async_start((struct ev_loop *)trk->ev_base, &trk->async); +#endif + /* construct the thread object */ PMIX_CONSTRUCT(&trk->engine, pmix_thread_t); trk->engine_constructed = true; @@ -300,6 +425,21 @@ int pmix_progress_thread_pause(const char *name) return PMIX_ERR_NOT_FOUND; } +#if PMIX_HAVE_LIBEV +static pmix_progress_tracker_t* pmix_progress_tracker_get_by_base(pmix_event_base_t *base) { + pmix_progress_tracker_t *trk; + + if (inited) { + PMIX_LIST_FOREACH(trk, &tracking, pmix_progress_tracker_t) { + if(trk->ev_base == base) { + return trk; + } + } + } + return NULL; +} +#endif + int pmix_progress_thread_resume(const char *name) { pmix_progress_tracker_t *trk; diff --git a/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server.c b/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server.c index bf3b95f01c..cbb0681774 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server.c +++ b/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server.c @@ -1,11 +1,11 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2018 Research Organization for Information Science + * Copyright (c) 2014-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014-2015 Artem Y. Polyakov . * All rights reserved. - * Copyright (c) 2016 Mellanox Technologies, Inc. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016-2018 IBM Corporation. All rights reserved. * Copyright (c) 2018 Cisco Systems, Inc. All rights reserved @@ -18,7 +18,6 @@ #include -#include #include #include @@ -49,9 +48,9 @@ #endif #include #include -#include PMIX_EVENT_HEADER -#include PMIX_EVENT2_THREAD_HEADER + +#include "src/common/pmix_attributes.h" #include "src/util/argv.h" #include "src/util/error.h" #include "src/util/name_fns.h" @@ -408,6 +407,12 @@ PMIX_EXPORT pmix_status_t PMIx_server_init(pmix_server_module_t *module, 2, PMIX_FWD_STDERR_CHANNEL, pmix_iof_write_handler); } + /* register our attributes */ + if (PMIX_SUCCESS != (rc = pmix_register_server_attrs())) { + PMIX_RELEASE_THREAD(&pmix_global_lock); + return rc; + } + /* start listening for connections */ if (PMIX_SUCCESS != pmix_ptl_base_start_listening(info, ninfo)) { pmix_show_help("help-pmix-server.txt", "listener-thread-start", true); @@ -504,7 +509,6 @@ PMIX_EXPORT pmix_status_t PMIx_server_finalize(void) /* close the pnet framework */ (void)pmix_mca_base_framework_close(&pmix_pnet_base_framework); - PMIX_RELEASE_THREAD(&pmix_global_lock); PMIX_DESTRUCT_LOCK(&pmix_global_lock); @@ -2299,11 +2303,6 @@ static void _mdxcbfunc(int sd, short argc, void *cbdata) /* if we get here, then there are processes waiting * for a response */ - /* if the timer is active, clear it */ - if (tracker->event_active) { - pmix_event_del(&tracker->ev); - } - /* pass the blobs being returned */ PMIX_CONSTRUCT(&xfer, pmix_buffer_t); PMIX_LOAD_BUFFER(pmix_globals.mypeer, &xfer, scd->data, scd->ndata); @@ -2345,7 +2344,7 @@ static void _mdxcbfunc(int sd, short argc, void *cbdata) } PMIX_LIST_FOREACH(nptr, &nslist, pmix_nspace_caddy_t) { - PMIX_GDS_STORE_MODEX(rc, nptr->ns, &tracker->local_cbs, &xfer); + PMIX_GDS_STORE_MODEX(rc, nptr->ns, &xfer, tracker); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); break; @@ -2388,12 +2387,7 @@ static void _mdxcbfunc(int sd, short argc, void *cbdata) xfer.bytes_used = 0; PMIX_DESTRUCT(&xfer); - if (!tracker->lost_connection) { - /* if this tracker has gone thru the "lost_connection" procedure, - * then it has already been removed from the list - otherwise, - * remove it now */ - pmix_list_remove_item(&pmix_server_globals.collectives, &tracker->super); - } + pmix_list_remove_item(&pmix_server_globals.collectives, &tracker->super); PMIX_RELEASE(tracker); PMIX_LIST_DESTRUCT(&nslist); @@ -2646,12 +2640,7 @@ static void _cnct(int sd, short args, void *cbdata) if (NULL != nspaces) { pmix_argv_free(nspaces); } - if (!tracker->lost_connection) { - /* if this tracker has gone thru the "lost_connection" procedure, - * then it has already been removed from the list - otherwise, - * remove it now */ - pmix_list_remove_item(&pmix_server_globals.collectives, &tracker->super); - } + pmix_list_remove_item(&pmix_server_globals.collectives, &tracker->super); PMIX_RELEASE(tracker); /* we are done */ @@ -2728,12 +2717,7 @@ static void _discnct(int sd, short args, void *cbdata) cleanup: /* cleanup the tracker -- the host RM is responsible for * telling us when to remove the nspace from our data */ - if (!tracker->lost_connection) { - /* if this tracker has gone thru the "lost_connection" procedure, - * then it has already been removed from the list - otherwise, - * remove it now */ - pmix_list_remove_item(&pmix_server_globals.collectives, &tracker->super); - } + pmix_list_remove_item(&pmix_server_globals.collectives, &tracker->super); PMIX_RELEASE(tracker); /* we are done */ @@ -2886,7 +2870,7 @@ static void query_cbfunc(pmix_status_t status, pmix_status_t rc; pmix_output_verbose(2, pmix_server_globals.base_output, - "pmix:query callback with status %d", status); + "pmix:query callback with status %s", PMIx_Error_string(status)); reply = PMIX_NEW(pmix_buffer_t); if (NULL == reply) { diff --git a/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server_get.c b/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server_get.c index 56c0530801..d13ef91164 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server_get.c +++ b/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server_get.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014-2015 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include diff --git a/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server_ops.c b/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server_ops.c index 691b868e5e..fff768a0ae 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server_ops.c +++ b/opal/mca/pmix/pmix4x/pmix/src/server/pmix_server_ops.c @@ -1,11 +1,11 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2018 Research Organization for Information Science + * Copyright (c) 2014-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014-2015 Artem Y. Polyakov . * All rights reserved. - * Copyright (c) 2016-2017 Mellanox Technologies, Inc. + * Copyright (c) 2016-2019 Mellanox Technologies, Inc. * All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ @@ -17,7 +17,6 @@ #include -#include #include #include @@ -53,6 +52,7 @@ #include "src/class/pmix_hotel.h" #include "src/class/pmix_list.h" +#include "src/common/pmix_attributes.h" #include "src/mca/bfrops/bfrops.h" #include "src/mca/plog/plog.h" #include "src/mca/psensor/psensor.h" @@ -375,6 +375,7 @@ static pmix_server_trkr_t* new_tracker(char *id, pmix_proc_t *procs, bool all_def; pmix_namespace_t *nptr, *ns; pmix_rank_info_t *info; + pmix_nspace_caddy_t *nm; pmix_output_verbose(5, pmix_server_globals.base_output, "new_tracker called with %d procs", (int)nprocs); @@ -437,6 +438,19 @@ static pmix_server_trkr_t* new_tracker(char *id, pmix_proc_t *procs, procs[i].nspace); continue; } + /* check and add uniq ns into trk nslist */ + PMIX_LIST_FOREACH(nm, &trk->nslist, pmix_nspace_caddy_t) { + if (0 == strcmp(nptr->nspace, nm->ns->nspace)) { + break; + } + } + if ((pmix_nspace_caddy_t*)pmix_list_get_end(&trk->nslist) == nm) { + nm = PMIX_NEW(pmix_nspace_caddy_t); + PMIX_RETAIN(nptr); + nm->ns = nptr; + pmix_list_append(&trk->nslist, &nm->super); + } + /* have all the clients for this nspace been defined? */ if (!nptr->all_registered) { /* nope, so no point in going further on this one - we'll @@ -500,6 +514,9 @@ static pmix_status_t _collect_data(pmix_server_trkr_t *trk, pmix_server_caddy_t *scd; pmix_proc_t pcs; pmix_status_t rc; + pmix_rank_t rel_rank; + pmix_nspace_caddy_t *nm; + bool found; PMIX_CONSTRUCT(&bucket, pmix_buffer_t); /* mark the collection type so we can check on the @@ -510,6 +527,7 @@ static pmix_status_t _collect_data(pmix_server_trkr_t *trk, if (PMIX_COLLECT_YES == trk->collect_type) { pmix_output_verbose(2, pmix_server_globals.fence_output, "fence - assembling data"); + PMIX_LIST_FOREACH(scd, &trk->local_cbs, pmix_server_caddy_t) { /* get any remote contribution - note that there * may not be a contribution */ @@ -521,10 +539,33 @@ static pmix_status_t _collect_data(pmix_server_trkr_t *trk, cb.copy = true; PMIX_GDS_FETCH_KV(rc, pmix_globals.mypeer, &cb); if (PMIX_SUCCESS == rc) { + /* calculate the throughout rank */ + rel_rank = 0; + found = false; + if (pmix_list_get_size(&trk->nslist) == 1) { + found = true; + } else { + PMIX_LIST_FOREACH(nm, &trk->nslist, pmix_nspace_caddy_t) { + if (0 == strcmp(nm->ns->nspace, pcs.nspace)) { + found = true; + break; + } + rel_rank += nm->ns->nprocs; + } + } + if (false == found) { + rc = PMIX_ERR_NOT_FOUND; + PMIX_ERROR_LOG(rc); + PMIX_DESTRUCT(&cb); + PMIX_DESTRUCT(&pbkt); + goto cleanup; + } + rel_rank += pcs.rank; + + /* pack the relative rank */ PMIX_CONSTRUCT(&pbkt, pmix_buffer_t); - /* pack the proc so we know the source */ PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, &pbkt, - &pcs, 1, PMIX_PROC); + &rel_rank, 1, PMIX_PROC_RANK); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); PMIX_DESTRUCT(&cb); @@ -797,6 +838,7 @@ pmix_status_t pmix_server_fence(pmix_server_caddy_t *cd, /* now unload the blob and pass it upstairs */ PMIX_UNLOAD_BUFFER(&bucket, data, sz); PMIX_DESTRUCT(&bucket); + trk->host_called = true; rc = pmix_host_server.fence_nb(trk->pcs, trk->npcs, trk->info, trk->ninfo, data, sz, trk->modexcbfunc, trk); @@ -1449,6 +1491,7 @@ pmix_status_t pmix_server_disconnect(pmix_server_caddy_t *cd, * across all participants has been completed */ if (trk->def_complete && pmix_list_get_size(&trk->local_cbs) == trk->nlocal) { + trk->host_called = true; rc = pmix_host_server.disconnect(trk->pcs, trk->npcs, trk->info, trk->ninfo, cbfunc, trk); if (PMIX_SUCCESS != rc) { /* remove this contributor from the list - they will be notified @@ -1598,6 +1641,7 @@ pmix_status_t pmix_server_connect(pmix_server_caddy_t *cd, * across all participants has been completed */ if (trk->def_complete && pmix_list_get_size(&trk->local_cbs) == trk->nlocal) { + trk->host_called = true; rc = pmix_host_server.connect(trk->pcs, trk->npcs, trk->info, trk->ninfo, cbfunc, trk); if (PMIX_SUCCESS != rc) { /* remove this contributor from the list - they will be notified @@ -2237,6 +2281,7 @@ pmix_status_t pmix_server_event_recvd_from_client(pmix_peer_t *peer, return rc; } + pmix_status_t pmix_server_query(pmix_peer_t *peer, pmix_buffer_t *buf, pmix_info_cbfunc_t cbfunc, @@ -2295,6 +2340,15 @@ pmix_status_t pmix_server_query(pmix_peer_t *peer, PMIX_CONSTRUCT(&results, pmix_list_t); for (n=0; n < cd->nqueries; n++) { + /* if they are asking for information on support, then go get it */ + if (0 == strcmp(cd->queries[n].keys[0], PMIX_QUERY_ATTRIBUTE_SUPPORT)) { + /* we are already in an event, but shift it as the handler expects to */ + cd->cbfunc = cbfunc; + PMIX_RETAIN(cd); // protect against early release + PMIX_THREADSHIFT(cd, pmix_attrs_query_support); + PMIX_LIST_DESTRUCT(&results); + return PMIX_SUCCESS; + } for (p=0; p < cd->queries[n].nqual; p++) { if (PMIX_CHECK_KEY(&cd->queries[n].qualifiers[p], PMIX_QUERY_REFRESH_CACHE)) { if (PMIX_INFO_TRUE(&cd->queries[n].qualifiers[p])) { @@ -3366,7 +3420,10 @@ pmix_status_t pmix_server_iofstdin(pmix_peer_t *peer, cnt = 1; PMIX_BFROPS_UNPACK(rc, peer, buf, cd->bo, &cnt, PMIX_BYTE_OBJECT); - if (PMIX_SUCCESS != rc) { + if (PMIX_ERR_UNPACK_READ_PAST_END_OF_BUFFER == rc) { + /* it is okay for them to not send data */ + PMIX_BYTE_OBJECT_FREE(cd->bo, 1); + } else if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); goto error; } @@ -3377,9 +3434,11 @@ pmix_status_t pmix_server_iofstdin(pmix_peer_t *peer, if (PMIX_SUCCESS != (rc = pmix_host_server.push_stdin(&source, cd->procs, cd->nprocs, cd->info, cd->ninfo, cd->bo, stdcbfunc, cd))) { - goto error; + if (PMIX_OPERATION_SUCCEEDED != rc) { + goto error; + } } - return PMIX_SUCCESS; + return rc; error: PMIX_RELEASE(cd); @@ -3502,7 +3561,7 @@ static void _grpcbfunc(int sd, short argc, void *cbdata) } PMIX_LIST_FOREACH(nptr, &nslist, pmix_nspace_caddy_t) { - PMIX_GDS_STORE_MODEX(ret, nptr->ns, &trk->local_cbs, &xfer); + PMIX_GDS_STORE_MODEX(ret, nptr->ns, &xfer, trk); if (PMIX_SUCCESS != ret) { PMIX_ERROR_LOG(ret); break; @@ -4077,13 +4136,14 @@ pmix_status_t pmix_server_grpdestruct(pmix_server_caddy_t *cd, static void tcon(pmix_server_trkr_t *t) { t->event_active = false; - t->lost_connection = false; + t->host_called = false; t->local = false; t->id = NULL; memset(t->pname.nspace, 0, PMIX_MAX_NSLEN+1); t->pname.rank = PMIX_RANK_UNDEF; t->pcs = NULL; t->npcs = 0; + PMIX_CONSTRUCT(&t->nslist, pmix_list_t); PMIX_CONSTRUCT_LOCK(&t->lock); t->def_complete = false; PMIX_CONSTRUCT(&t->local_cbs, pmix_list_t); @@ -4111,6 +4171,7 @@ static void tdes(pmix_server_trkr_t *t) if (NULL != t->info) { PMIX_INFO_FREE(t->info, t->ninfo); } + PMIX_DESTRUCT(&t->nslist); } PMIX_CLASS_INSTANCE(pmix_server_trkr_t, pmix_list_item_t, @@ -4188,7 +4249,7 @@ PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_setup_caddy_t, static void ncon(pmix_notify_caddy_t *p) { PMIX_CONSTRUCT_LOCK(&p->lock); -#if defined(__linux__) && OPAL_HAVE_CLOCK_GETTIME +#if defined(__linux__) && PMIX_HAVE_CLOCK_GETTIME struct timespec tp; (void) clock_gettime(CLOCK_MONOTONIC, &tp); p->ts = tp.tv_sec; diff --git a/opal/mca/pmix/pmix4x/pmix/src/tool/pmix_tool.c b/opal/mca/pmix/pmix4x/pmix/src/tool/pmix_tool.c index effa1190ff..238cbbdab7 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/tool/pmix_tool.c +++ b/opal/mca/pmix/pmix4x/pmix/src/tool/pmix_tool.c @@ -1,8 +1,8 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. - * Copyright (c) 2014-2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . * All rights reserved. * Copyright (c) 2016 Mellanox Technologies, Inc. @@ -17,7 +17,6 @@ #include -#include #include #include "src/client/pmix_client_ops.h" @@ -49,9 +48,6 @@ #include #endif /* HAVE_DIRENT_H */ -#include PMIX_EVENT_HEADER -#include PMIX_EVENT2_THREAD_HEADER - #include "src/class/pmix_list.h" #include "src/util/argv.h" #include "src/util/error.h" @@ -67,6 +63,7 @@ #include "src/mca/ptl/base/base.h" #include "src/mca/psec/psec.h" #include "src/include/pmix_globals.h" +#include "src/common/pmix_attributes.h" #include "src/common/pmix_iof.h" #include "src/server/pmix_server_ops.h" @@ -993,7 +990,11 @@ PMIX_EXPORT int PMIx_tool_init(pmix_proc_t *proc, * and load it from there */ /* hostname */ - gethostname(hostname, PMIX_MAX_NSLEN); + if (NULL != pmix_globals.hostname) { + pmix_strncpy(hostname, pmix_globals.hostname, PMIX_MAX_NSLEN); + } else { + gethostname(hostname, PMIX_MAX_NSLEN); + } kptr = PMIX_NEW(pmix_kval_t); kptr->key = strdup(PMIX_HOSTNAME); PMIX_VALUE_CREATE(kptr->value, 1); @@ -1058,6 +1059,8 @@ PMIX_EXPORT int PMIx_tool_init(pmix_proc_t *proc, } } + /* register the tool supported attrs */ + rc = pmix_register_tool_attrs(); return rc; } diff --git a/opal/mca/pmix/pmix4x/pmix/src/tools/Makefile.include b/opal/mca/pmix/pmix4x/pmix/src/tools/Makefile.include index 58bfa148fd..0dbfe6e1d9 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/tools/Makefile.include +++ b/opal/mca/pmix/pmix4x/pmix/src/tools/Makefile.include @@ -13,7 +13,7 @@ # Copyright (c) 2006-2008 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights # reserved. -# Copyright (c) 2014-2018 Intel, Inc. All rights reserved. +# Copyright (c) 2014-2019 Intel, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -28,10 +28,12 @@ SUBDIRS += \ tools/pevent \ tools/pmix_info \ tools/plookup \ - tools/pps + tools/pps \ + tools/pattrs DIST_SUBDIRS += \ tools/pevent \ tools/pmix_info \ tools/plookup \ - tools/pps + tools/pps \ + tools/pattrs diff --git a/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/Makefile.am b/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/Makefile.am new file mode 100644 index 0000000000..3f6c669ea5 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/Makefile.am @@ -0,0 +1,33 @@ +# +# 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-2009 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2008-2014 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. +# Copyright (c) 2017-2019 Intel, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +if PMIX_INSTALL_BINARIES + +bin_PROGRAMS = pattrs + +dist_pmixdata_DATA = help-pattrs.txt + +endif # PMIX_INSTALL_BINARIES + +pattrs_SOURCES = pattrs.c +pattrs_LDADD = \ + $(PMIX_EXTRA_LTLIB) \ + $(top_builddir)/src/libpmix.la diff --git a/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/help-pattrs.txt b/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/help-pattrs.txt new file mode 100644 index 0000000000..299fee6ea6 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/help-pattrs.txt @@ -0,0 +1,27 @@ +# -*- text -*- +# +# 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 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2017-2019 Intel, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# +# This is the US/English help file for pattrs +# +[usage] +pattrs [OPTIONS] + PMIx Supported Attributes and Functions tool + +%s diff --git a/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/pattrs.c b/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/pattrs.c new file mode 100644 index 0000000000..a8441d827b --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/tools/pattrs/pattrs.c @@ -0,0 +1,492 @@ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 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) 2006-2013 Los Alamos National Security, LLC. + * All rights reserved. + * Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + */ + +#include "pmix_config.h" +#include "pmix_common.h" + +#include +#include +#include +#include +#include + +#include +#include "src/common/pmix_attributes.h" +#include "src/mca/base/base.h" +#include "src/mca/pinstalldirs/base/base.h" +#include "src/threads/threads.h" +#include "src/util/cmd_line.h" +#include "src/util/keyval_parse.h" +#include "src/util/show_help.h" +#include "src/runtime/pmix_rte.h" + +typedef struct { + pmix_lock_t lock; + pmix_status_t status; +} mylock_t; + +static pmix_proc_t myproc; + +/* define a structure for collecting returned + * info from a query */ +typedef struct { + pmix_lock_t lock; + pmix_status_t status; + pmix_info_t *info; + size_t ninfo; +} myquery_data_t; + + +/* this is a callback function for the PMIx_Query + * API. The query will callback with a status indicating + * if the request could be fully satisfied, partially + * satisfied, or completely failed. The info parameter + * contains an array of the returned data, with the + * info->key field being the key that was provided in + * the query call. Thus, you can correlate the returned + * data in the info->value field to the requested key. + * + * Once we have dealt with the returned data, we must + * call the release_fn so that the PMIx library can + * cleanup */ +static void cbfunc(pmix_status_t status, + pmix_info_t *info, size_t ninfo, + void *cbdata, + pmix_release_cbfunc_t release_fn, + void *release_cbdata) +{ + myquery_data_t *mq = (myquery_data_t*)cbdata; + size_t n; + + mq->status = status; + /* save the returned info - the PMIx library "owns" it + * and will release it and perform other cleanup actions + * when release_fn is called */ + if (0 < ninfo) { + PMIX_INFO_CREATE(mq->info, ninfo); + mq->ninfo = ninfo; + for (n=0; n < ninfo; n++) { + PMIX_INFO_XFER(&mq->info[n], &info[n]); + } + } + + /* let the library release the data and cleanup from + * the operation */ + if (NULL != release_fn) { + release_fn(release_cbdata); + } + + /* release the block */ + PMIX_WAKEUP_THREAD(&mq->lock); +} + +/* this is the event notification function we pass down below + * when registering for general events - i.e.,, the default + * handler. We don't technically need to register one, but it + * is usually good practice to catch any events that occur */ +static void notification_fn(size_t evhdlr_registration_id, + pmix_status_t status, + const pmix_proc_t *source, + pmix_info_t info[], size_t ninfo, + pmix_info_t results[], size_t nresults, + pmix_event_notification_cbfunc_fn_t cbfunc, + void *cbdata) +{ + /* this example doesn't do anything with default events */ + if (NULL != cbfunc) { + cbfunc(PMIX_EVENT_ACTION_COMPLETE, NULL, 0, NULL, NULL, cbdata); + } +} + +/* event handler registration is done asynchronously because it + * may involve the PMIx server registering with the host RM for + * external events. So we provide a callback function that returns + * the status of the request (success or an error), plus a numerical index + * to the registered event. The index is used later on to deregister + * an event handler - if we don't explicitly deregister it, then the + * PMIx server will do so when it see us exit */ +static void evhandler_reg_callbk(pmix_status_t status, + size_t evhandler_ref, + void *cbdata) +{ + mylock_t *lock = (mylock_t*)cbdata; + + if (PMIX_SUCCESS != status) { + fprintf(stderr, "Client %s:%d EVENT HANDLER REGISTRATION FAILED WITH STATUS %d, ref=%lu\n", + myproc.nspace, myproc.rank, status, (unsigned long)evhandler_ref); + } + lock->status = status; + PMIX_WAKEUP_THREAD(&lock->lock); +} + +/***************************************** + * Global Vars for Command line Arguments + *****************************************/ +typedef struct { + bool help; + bool verbose; + pid_t pid; + char *nspace; + char *uri; + bool sysfirst; + bool system; + char *client; + char *server; + char *tool; + char *host; + bool clientfns; + bool serverfns; + bool toolfns; + bool hostfns; +} pmix_pattrs_globals_t; + +pmix_pattrs_globals_t pmix_pattrs_globals = {0}; + +pmix_cmd_line_init_t cmd_line_opts[] = { + { NULL, + 'h', NULL, "help", + 0, + &pmix_pattrs_globals.help, PMIX_CMD_LINE_TYPE_BOOL, + "This help message" }, + + { NULL, + 'v', NULL, "verbose", + 0, + &pmix_pattrs_globals.verbose, PMIX_CMD_LINE_TYPE_BOOL, + "Be Verbose" }, + + { NULL, + 'p', NULL, "pid", + 1, + &pmix_pattrs_globals.pid, PMIX_CMD_LINE_TYPE_INT, + "Specify server pid to connect to" }, + + { NULL, + 'n', NULL, "nspace", + 1, + &pmix_pattrs_globals.nspace, PMIX_CMD_LINE_TYPE_STRING, + "Specify server nspace to connect to" }, + + { NULL, + '\0', NULL, "uri", + 1, + &pmix_pattrs_globals.uri, PMIX_CMD_LINE_TYPE_STRING, + "Specify URI of server to connect to" }, + + { NULL, + '\0', NULL, "system-server-first", + 0, + &pmix_pattrs_globals.sysfirst, PMIX_CMD_LINE_TYPE_BOOL, + "Look for the system server first" }, + + { NULL, + '\0', NULL, "system-server", + 0, + &pmix_pattrs_globals.system, PMIX_CMD_LINE_TYPE_BOOL, + "Specifically connect to the system server" }, + + { NULL, + 'c', NULL, "client", + 1, + &pmix_pattrs_globals.client, PMIX_CMD_LINE_TYPE_STRING, + "Comma-delimited list of client function whose attributes are to be printed (function or all)" }, + + { NULL, + 's', NULL, "server", + 1, + &pmix_pattrs_globals.server, PMIX_CMD_LINE_TYPE_STRING, + "Comma-delimited list of server function whose attributes are to be printed (function or all)" }, + + { NULL, + 't', NULL, "tool", + 1, + &pmix_pattrs_globals.tool, PMIX_CMD_LINE_TYPE_STRING, + "Comma-delimited list of tool function whose attributes are to be printed (function or all)" }, + + { NULL, + 'h', NULL, "host", + 1, + &pmix_pattrs_globals.host, PMIX_CMD_LINE_TYPE_STRING, + "Comma-delimited list of host function whose attributes are to be printed (function or all)" }, + + { NULL, + '\0', NULL, "client-fns", + 0, + &pmix_pattrs_globals.clientfns, PMIX_CMD_LINE_TYPE_BOOL, + "List the functions supported in this client library" }, + + { NULL, + '\0', NULL, "server-fns", + 0, + &pmix_pattrs_globals.serverfns, PMIX_CMD_LINE_TYPE_BOOL, + "List the functions supported in this server library" }, + + { NULL, + '\0', NULL, "tool-fns", + 0, + &pmix_pattrs_globals.toolfns, PMIX_CMD_LINE_TYPE_BOOL, + "List the functions supported in this tool library" }, + + { NULL, + '\0', NULL, "host-fns", + 0, + &pmix_pattrs_globals.hostfns, PMIX_CMD_LINE_TYPE_BOOL, + "List the functions supported by this host environment" }, + + + /* End of list */ + { NULL, + '\0', NULL, NULL, + 0, + NULL, PMIX_CMD_LINE_TYPE_NULL, + NULL } +}; + +int main(int argc, char **argv) +{ + pmix_status_t rc; + pmix_info_t *info; + mylock_t mylock; + pmix_cmd_line_t cmd_line; + char **fns; + size_t n, m; + myquery_data_t mq; + pmix_query_t query; + pmix_regattr_t *reg; + char **ans = NULL; + + /* protect against problems if someone passes us thru a pipe + * and then abnormally terminates the pipe early */ + signal(SIGPIPE, SIG_IGN); + + /* initialize the output system */ + if (!pmix_output_init()) { + return PMIX_ERROR; + } + + /* initialize install dirs code */ + if (PMIX_SUCCESS != (rc = pmix_mca_base_framework_open(&pmix_pinstalldirs_base_framework, 0))) { + fprintf(stderr, "pmix_pinstalldirs_base_open() failed -- process will likely abort (%s:%d, returned %d instead of PMIX_SUCCESS)\n", + __FILE__, __LINE__, rc); + return rc; + } + + /* initialize the help system */ + pmix_show_help_init(); + + /* keyval lex-based parser */ + if (PMIX_SUCCESS != (rc = pmix_util_keyval_parse_init())) { + fprintf(stderr, "pmix_util_keyval_parse_init failed with %d\n", rc); + return PMIX_ERROR; + } + + /* Setup the parameter system */ + if (PMIX_SUCCESS != (rc = pmix_mca_base_var_init())) { + fprintf(stderr, "pmix_mca_base_var_init failed with %d\n", rc); + return PMIX_ERROR; + } + + /* register params for pmix */ + if (PMIX_SUCCESS != (rc = pmix_register_params())) { + fprintf(stderr, "pmix_register_params failed with %d\n", rc); + return PMIX_ERROR; + } + + /* Parse the command line options */ + pmix_cmd_line_create(&cmd_line, cmd_line_opts); + + rc = pmix_cmd_line_parse(&cmd_line, false, false, argc, argv); + + if (PMIX_SUCCESS != rc) { + if (PMIX_ERR_SILENT != rc) { + fprintf(stderr, "%s: command line error (%s)\n", argv[0], + PMIx_Error_string(rc)); + } + return rc; + } + + if (pmix_pattrs_globals.help) { + char *str, *args = NULL; + args = pmix_cmd_line_get_usage_msg(&cmd_line); + str = pmix_show_help_string("help-pattrs.txt", "usage", true, + args); + if (NULL != str) { + printf("%s", str); + free(str); + } + free(args); + /* If we show the help message, that should be all we do */ + exit(0); + } + + /* cannot list functions and get attributes at same time */ + if ((pmix_pattrs_globals.clientfns || pmix_pattrs_globals.serverfns || pmix_pattrs_globals.toolfns || pmix_pattrs_globals.hostfns) + && (pmix_pattrs_globals.client || pmix_pattrs_globals.server || pmix_pattrs_globals.tool || NULL != pmix_pattrs_globals.host)) { + fprintf(stderr, "Cannot request both a list of functions and attributes at same time\n"); + exit(1); + } + + /* if they are asking for client, server, or tool attrs, then + * we don't need to connect to anyone - just register the + * attrs and report */ + if (pmix_pattrs_globals.clientfns || pmix_pattrs_globals.serverfns || pmix_pattrs_globals.toolfns || + pmix_pattrs_globals.client || pmix_pattrs_globals.server || pmix_pattrs_globals.tool) { + PMIX_INFO_CREATE(info, 1); + PMIX_INFO_LOAD(&info[0], PMIX_TOOL_DO_NOT_CONNECT, NULL, PMIX_BOOL); + PMIx_tool_init(&myproc, info, 1); + if (pmix_pattrs_globals.clientfns) { + pmix_register_client_attrs(); + fns = pmix_attributes_print_functions(PMIX_CLIENT_FUNCTIONS); + } else if (pmix_pattrs_globals.serverfns) { + pmix_register_server_attrs(); + fns = pmix_attributes_print_functions(PMIX_SERVER_FUNCTIONS); + } else if (pmix_pattrs_globals.toolfns) { + pmix_register_tool_attrs(); + fns = pmix_attributes_print_functions(PMIX_TOOL_FUNCTIONS); + } else if (NULL != pmix_pattrs_globals.client) { + pmix_register_client_attrs(); + fns = pmix_attributes_print_attr(PMIX_CLIENT_ATTRIBUTES, pmix_pattrs_globals.client); + } else if (NULL != pmix_pattrs_globals.server) { + pmix_register_server_attrs(); + fns = pmix_attributes_print_attr(PMIX_SERVER_ATTRIBUTES, pmix_pattrs_globals.server); + } else if (NULL != pmix_pattrs_globals.tool) { + pmix_register_tool_attrs(); + fns = pmix_attributes_print_attr(PMIX_TOOL_ATTRIBUTES, pmix_pattrs_globals.tool); + } + if (NULL != fns) { + for (n=0; NULL != fns[n]; n++) { + fprintf(stderr, "%s\n", fns[n]); + } + } + goto done; + } + + /* if they didn't give us an option, then we can't do anything */ + if (!pmix_pattrs_globals.hostfns && NULL == pmix_pattrs_globals.host) { + char *str, *args = NULL; + args = pmix_cmd_line_get_usage_msg(&cmd_line); + str = pmix_show_help_string("help-pattrs.txt", "usage", true, + args); + if (NULL != str) { + printf("%s", str); + free(str); + } + free(args); + exit(1); + } + + /* if we were given the pid of a starter, then direct that + * we connect to it */ + n = 1; + PMIX_INFO_CREATE(info, n); + if (0 < pmix_pattrs_globals.pid) { + PMIX_INFO_LOAD(&info[0], PMIX_SERVER_PIDINFO, &pmix_pattrs_globals.pid, PMIX_PID); + } else if (NULL != pmix_pattrs_globals.nspace) { + PMIX_INFO_LOAD(&info[0], PMIX_SERVER_NSPACE, pmix_pattrs_globals.nspace, PMIX_STRING); + } else if (NULL != pmix_pattrs_globals.uri) { + PMIX_INFO_LOAD(&info[0], PMIX_SERVER_URI, pmix_pattrs_globals.uri, PMIX_STRING); + } else if (pmix_pattrs_globals.sysfirst) { + /* otherwise, use the system connection first, if available */ + PMIX_INFO_LOAD(&info[0], PMIX_CONNECT_SYSTEM_FIRST, NULL, PMIX_BOOL); + } else if (pmix_pattrs_globals.system) { + PMIX_INFO_LOAD(&info[0], PMIX_CONNECT_TO_SYSTEM, NULL, PMIX_BOOL); + } else { + PMIX_INFO_FREE(info, 1); + n = 0; + } + /* init as a tool */ + if (PMIX_SUCCESS != (rc = PMIx_tool_init(&myproc, info, n))) { + fprintf(stderr, "PMIx_tool_init failed: %s\n", PMIx_Error_string(rc)); + exit(rc); + } + PMIX_INFO_FREE(info, 1); + + /* register a default event handler */ + PMIX_CONSTRUCT_LOCK(&mylock.lock); + PMIx_Register_event_handler(NULL, 0, NULL, 0, + notification_fn, evhandler_reg_callbk, (void*)&mylock); + PMIX_WAIT_THREAD(&mylock.lock); + if (PMIX_SUCCESS != mylock.status) { + fprintf(stderr, "PMIx_Register_event_handler returned bad status: %d\n", rc); + PMIX_DESTRUCT_LOCK(&mylock.lock); + goto done; + } + PMIX_DESTRUCT_LOCK(&mylock.lock); + + /* generate the query */ + PMIX_QUERY_CONSTRUCT(&query); + pmix_argv_append_nosize(&query.keys, PMIX_QUERY_ATTRIBUTE_SUPPORT); + PMIX_QUERY_QUALIFIERS_CREATE(&query, 1); + if (pmix_pattrs_globals.hostfns) { + PMIX_INFO_LOAD(&query.qualifiers[0], PMIX_HOST_FUNCTIONS, NULL, PMIX_BOOL); + } else { + PMIX_INFO_LOAD(&query.qualifiers[0], PMIX_HOST_ATTRIBUTES, pmix_pattrs_globals.host, PMIX_STRING); + } + PMIX_CONSTRUCT_LOCK(&mq.lock); + rc = PMIx_Query_info_nb(&query, 1, cbfunc,(void*)&mq); + if (PMIX_SUCCESS != rc) { + fprintf(stderr, "PMIx_Notify_event failed: %d\n", rc); + goto done; + } + PMIX_WAIT_THREAD(&mq.lock); + PMIX_DESTRUCT_LOCK(&mq.lock); + if (PMIX_SUCCESS != mq.status) { + fprintf(stderr, "PMIx_Query returned: %s\n", PMIx_Error_string(mq.status)); + } else { + /* print out the returned value(s) */ + for (n=0; n < mq.ninfo; n++) { + if (PMIX_CHECK_KEY(&mq.info[n], PMIX_HOST_FUNCTIONS)) { + fns = pmix_argv_split(mq.info[n].value.data.string, ','); + fprintf(stderr, "HOST SUPPORTED FUNCTIONS:\n"); + for (m=0; NULL != fns[m]; m++) { + fprintf(stderr, "\t%s\n", fns[m]); + } + pmix_argv_free(fns); + } else { + pmix_attributes_print_headers(&ans, PMIX_HOST_ATTRIBUTES); + if (PMIX_DATA_ARRAY == mq.info[n].value.type) { + info = (pmix_info_t*)mq.info[n].value.data.darray->array; + for (m=0; m < mq.info[n].value.data.darray->size; m++) { + reg = (pmix_regattr_t*)info[m].value.data.darray->array; + pmix_attributes_print_attrs(&ans, info[m].key, reg, info[0].value.data.darray->size); + } + } else { + reg = (pmix_regattr_t*)mq.info[n].value.data.ptr; + pmix_attributes_print_attrs(&ans, mq.info[n].key, reg, 1); + } + for (m=0; NULL != ans[m]; m++) { + fprintf(stderr, "%s\n", ans[m]); + } + pmix_argv_free(ans); + ans = NULL; + } + } + } + + done: + PMIx_tool_finalize(); + + return(rc); +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/util/Makefile.include b/opal/mca/pmix/pmix4x/pmix/src/util/Makefile.include index 771b59bc52..95ac91d95b 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/util/Makefile.include +++ b/opal/mca/pmix/pmix4x/pmix/src/util/Makefile.include @@ -12,7 +12,7 @@ # All rights reserved. # Copyright (c) 2007-2016 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2013 NVIDIA Corporation. All rights reserved. -# Copyright (c) 2013-2018 Intel, Inc. All rights reserved. +# Copyright (c) 2013-2019 Intel, Inc. All rights reserved. # Copyright (c) 2016 Research Organization for Information Science # and Technology (RIST). All rights reserved. # $COPYRIGHT$ @@ -38,6 +38,7 @@ headers += \ util/crc.h \ util/fd.h \ util/timings.h \ + util/os_dirpath.h \ util/os_path.h \ util/basename.h \ util/keyval_parse.h \ @@ -50,8 +51,7 @@ headers += \ util/name_fns.h \ util/net.h \ util/pif.h \ - util/parse_options.h \ - util/compress.h + util/parse_options.h sources += \ util/alfg.c \ @@ -64,6 +64,7 @@ sources += \ util/crc.c \ util/fd.c \ util/timings.c \ + util/os_dirpath.c \ util/os_path.c \ util/basename.c \ util/keyval_parse.c \ @@ -75,8 +76,7 @@ sources += \ util/name_fns.c \ util/net.c \ util/pif.c \ - util/parse_options.c \ - util/compress.c + util/parse_options.c libpmix_la_LIBADD += \ util/keyval/libpmixutilkeyval.la diff --git a/opal/mca/pmix/pmix4x/pmix/src/util/cmd_line.c b/opal/mca/pmix/pmix4x/pmix/src/util/cmd_line.c index 15a2b61207..c3367f9c1d 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/util/cmd_line.c +++ b/opal/mca/pmix/pmix4x/pmix/src/util/cmd_line.c @@ -15,7 +15,7 @@ * Copyright (c) 2012-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -726,11 +726,6 @@ char *pmix_cmd_line_get_usage_msg(pmix_cmd_line_t *cmd) } } } - if(otype == PMIX_CMD_LINE_OTYPE_NULL || otype == PMIX_CMD_LINE_OTYPE_GENERAL) { - char *argument_line = "\nFor additional mpirun arguments, run 'mpirun --help '\n\nThe following categories exist: general (Defaults to this option), debug,\n output, input, mapping, ranking, binding, devel (arguments useful to PMIX\n Developers), compatibility (arguments supported for backwards compatibility),\n launch (arguments to modify launch options), and dvm (Distributed Virtual\n Machine arguments)."; - - pmix_argv_append(&argc, &argv, argument_line); - } if (NULL != argv) { ret = pmix_argv_join(argv, '\n'); pmix_argv_free(argv); diff --git a/opal/mca/pmix/pmix4x/pmix/src/util/compress.h b/opal/mca/pmix/pmix4x/pmix/src/util/compress.h deleted file mode 100644 index b07b0d2ea7..0000000000 --- a/opal/mca/pmix/pmix4x/pmix/src/util/compress.h +++ /dev/null @@ -1,57 +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) 2015-2016 Intel, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -/** - * @file - * - * Compress/decompress long strings - */ - -#ifndef PMIX_COMPRESS_H -#define PMIX_COMPRESS_H - -#include - - -BEGIN_C_DECLS - -/* define a limit for storing raw strings */ -#define PMIX_STRING_LIMIT 512 - -/* define a macro for quickly checking if a string exceeds the - * compression limit */ -#define PMIX_STRING_SIZE_CHECK(s) \ - (PMIX_STRING == (s)->type && NULL != (s)->data.string && PMIX_STRING_LIMIT < strlen((s)->data.string)) - -/** - * Compress a string into a byte object using Zlib - */ -PMIX_EXPORT bool pmix_util_compress_string(char *instring, - uint8_t **outbytes, - size_t *nbytes); - -/** - * Decompress a byte object into a string using Zlib - */ -PMIX_EXPORT void pmix_util_uncompress_string(char **outstring, - uint8_t *inbytes, size_t len); - -END_C_DECLS - -#endif /* PMIX_COMPRESS_H */ diff --git a/opal/mca/pmix/pmix4x/pmix/src/util/error.c b/opal/mca/pmix/pmix4x/pmix/src/util/error.c index a098260bb2..a4848c6cf9 100644 --- a/opal/mca/pmix/pmix4x/pmix/src/util/error.c +++ b/opal/mca/pmix/pmix4x/pmix/src/util/error.c @@ -11,7 +11,7 @@ * All rights reserved. * Copyright (c) 2007-2012 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -151,7 +151,10 @@ PMIX_EXPORT const char* PMIx_Error_string(pmix_status_t errnum) return "UNPACK-PAST-END"; case PMIX_ERR_CONFLICTING_CLEANUP_DIRECTIVES: return "PMIX CONFLICTING CLEANUP DIRECTIVES"; - + case PMIX_ERR_IOF_FAILURE: + return "IOF FAILURE"; + case PMIX_ERR_IOF_COMPLETE: + return "IOF COMPLETE"; case PMIX_ERR_LOST_CONNECTION_TO_SERVER: return "LOST_CONNECTION_TO_SERVER"; @@ -231,6 +234,9 @@ PMIX_EXPORT const char* PMIx_Error_string(pmix_status_t errnum) case PMIX_GROUP_CONTEXT_ID_ASSIGNED: return "GROUP-CONTEXT-ID-ASSIGNED"; + case PMIX_ERR_REPEAT_ATTR_REGISTRATION: + return "REPEAT-ATTRIBUTE-REGISTRATION"; + case PMIX_ERR_NODE_DOWN: return "NODE-DOWN"; case PMIX_ERR_NODE_OFFLINE: diff --git a/opal/mca/pmix/pmix4x/pmix/src/util/os_dirpath.c b/opal/mca/pmix/pmix4x/pmix/src/util/os_dirpath.c new file mode 100644 index 0000000000..c77bc5bb92 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/util/os_dirpath.c @@ -0,0 +1,312 @@ +/* + * 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) 2015-2017 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + + +#include "pmix_config.h" + +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ +#include +#if HAVE_SYS_STAT_H +#include +#endif /* HAVE_SYS_STAT_H */ +#ifdef HAVE_SYS_TYPES_H +#include +#endif /* HAVE_SYS_TYPES_H */ +#ifdef HAVE_DIRENT_H +#include +#endif /* HAVE_DIRENT_H */ + +#include "src/util/error.h" +#include "src/util/output.h" +#include "src/util/os_dirpath.h" +#include "src/util/show_help.h" +#include "src/util/argv.h" +#include "src/util/os_path.h" +#include "pmix_common.h" + +static const char path_sep[] = PMIX_PATH_SEP; + +int pmix_os_dirpath_create(const char *path, const mode_t mode) +{ + struct stat buf; + char **parts, *tmp; + int i, len; + int ret; + + if (NULL == path) { /* protect ourselves from errors */ + return(PMIX_ERR_BAD_PARAM); + } + + if (0 == (ret = stat(path, &buf))) { /* already exists */ + if (mode == (mode & buf.st_mode)) { /* has correct mode */ + return(PMIX_SUCCESS); + } + if (0 == (ret = chmod(path, (buf.st_mode | mode)))) { /* successfully change mode */ + return(PMIX_SUCCESS); + } + pmix_show_help("help-pmix-util.txt", "dir-mode", true, + path, mode, strerror(errno)); + return(PMIX_ERR_PERM); /* can't set correct mode */ + } + + /* quick -- try to make directory */ + if (0 == mkdir(path, mode)) { + return(PMIX_SUCCESS); + } + + /* didnt work, so now have to build our way down the tree */ + /* Split the requested path up into its individual parts */ + + parts = pmix_argv_split(path, path_sep[0]); + + /* Ensure to allocate enough space for tmp: the strlen of the + incoming path + 1 (for \0) */ + + tmp = (char*)malloc(strlen(path) + 1); + tmp[0] = '\0'; + + /* Iterate through all the subdirectory names in the path, + building up a directory name. Check to see if that dirname + exists. If it doesn't, create it. */ + + len = pmix_argv_count(parts); + for (i = 0; i < len; ++i) { + if (i == 0) { + /* If in POSIX-land, ensure that we never end a directory + name with path_sep */ + + if ('/' == path[0]) { + strcat(tmp, path_sep); + } + strcat(tmp, parts[i]); + } + + /* If it's not the first part, ensure that there's a + preceeding path_sep and then append this part */ + + else { + if (path_sep[0] != tmp[strlen(tmp) - 1]) { + strcat(tmp, path_sep); + } + strcat(tmp, parts[i]); + } + + /* Now that we have the name, try to create it */ + mkdir(tmp, mode); + ret = errno; // save the errno for an error msg, if needed + if (0 != stat(tmp, &buf)) { + pmix_show_help("help-pmix-util.txt", "mkdir-failed", true, + tmp, strerror(ret)); + pmix_argv_free(parts); + free(tmp); + return PMIX_ERROR; + } else if (i == (len-1) && (mode != (mode & buf.st_mode)) && (0 > chmod(tmp, (buf.st_mode | mode)))) { + pmix_show_help("help-pmix-util.txt", "dir-mode", true, + tmp, mode, strerror(errno)); + pmix_argv_free(parts); + free(tmp); + return(PMIX_ERR_PERM); /* can't set correct mode */ + } + } + + /* All done */ + + pmix_argv_free(parts); + free(tmp); + return PMIX_SUCCESS; +} + +/** + * This function attempts to remove a directory along with all the + * files in it. If the recursive variable is non-zero, then it will + * try to recursively remove all directories. If provided, the + * callback function is executed prior to the directory or file being + * removed. If the callback returns non-zero, then no removal is + * done. + */ +int pmix_os_dirpath_destroy(const char *path, + bool recursive, + pmix_os_dirpath_destroy_callback_fn_t cbfunc) +{ + int rc, exit_status = PMIX_SUCCESS; + bool is_dir = false; + DIR *dp; + struct dirent *ep; + char *filenm; + struct stat buf; + + if (NULL == path) { /* protect against error */ + return PMIX_ERROR; + } + + /* + * Make sure we have access to the the base directory + */ + if (PMIX_SUCCESS != (rc = pmix_os_dirpath_access(path, 0))) { + exit_status = rc; + goto cleanup; + } + + /* Open up the directory */ + dp = opendir(path); + if (NULL == dp) { + return PMIX_ERROR; + } + + while (NULL != (ep = readdir(dp))) { + /* skip: + * - . and .. + */ + if ((0 == strcmp(ep->d_name, ".")) || + (0 == strcmp(ep->d_name, ".."))) { + continue; + } + + /* Check to see if it is a directory */ + is_dir = false; + + /* Create a pathname. This is not always needed, but it makes + * for cleaner code just to create it here. Note that we are + * allocating memory here, so we need to free it later on. + */ + filenm = pmix_os_path(false, path, ep->d_name, NULL); + + rc = stat(filenm, &buf); + if (0 > rc) { + /* Handle a race condition. filenm might have been deleted by an + * other process running on the same node. That typically occurs + * when one task is removing the job_session_dir and an other task + * is still removing its proc_session_dir. + */ + free(filenm); + continue; + } + if (S_ISDIR(buf.st_mode)) { + is_dir = true; + } + + /* + * If not recursively decending, then if we find a directory then fail + * since we were not told to remove it. + */ + if (is_dir && !recursive) { + /* Set the error indicating that we found a directory, + * but continue removing files + */ + exit_status = PMIX_ERROR; + free(filenm); + continue; + } + + /* Will the caller allow us to remove this file/directory? */ + if (NULL != cbfunc) { + /* + * Caller does not wish to remove this file/directory, + * continue with the rest of the entries + */ + if (!(cbfunc(path, ep->d_name))) { + free(filenm); + continue; + } + } + /* Directories are recursively destroyed */ + if (is_dir) { + rc = pmix_os_dirpath_destroy(filenm, recursive, cbfunc); + free(filenm); + if (PMIX_SUCCESS != rc) { + exit_status = rc; + closedir(dp); + goto cleanup; + } + } else { + /* Files are removed right here */ + if (0 != (rc = unlink(filenm))) { + exit_status = PMIX_ERROR; + } + free(filenm); + } + } + + /* Done with this directory */ + closedir(dp); + + cleanup: + + /* + * If the directory is empty, them remove it + */ + if(pmix_os_dirpath_is_empty(path)) { + rmdir(path); + } + + return exit_status; +} + +bool pmix_os_dirpath_is_empty(const char *path ) { + DIR *dp; + struct dirent *ep; + + if (NULL != path) { /* protect against error */ + dp = opendir(path); + if (NULL != dp) { + while ((ep = readdir(dp))) { + if ((0 != strcmp(ep->d_name, ".")) && + (0 != strcmp(ep->d_name, ".."))) { + closedir(dp); + return false; + } + } + closedir(dp); + return true; + } + return false; + } + + return true; +} + +int pmix_os_dirpath_access(const char *path, const mode_t in_mode ) { + struct stat buf; + mode_t loc_mode = S_IRWXU; /* looking for full rights */ + + /* + * If there was no mode specified, use the default mode + */ + if (0 != in_mode) { + loc_mode = in_mode; + } + + if (0 == stat(path, &buf)) { /* exists - check access */ + if ((buf.st_mode & loc_mode) == loc_mode) { /* okay, I can work here */ + return(PMIX_SUCCESS); + } else { + /* Don't have access rights to the existing path */ + return(PMIX_ERROR); + } + } else { + /* We could not find the path */ + return( PMIX_ERR_NOT_FOUND ); + } +} diff --git a/opal/mca/pmix/pmix4x/pmix/src/util/os_dirpath.h b/opal/mca/pmix/pmix4x/pmix/src/util/os_dirpath.h new file mode 100644 index 0000000000..a282cc1626 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/src/util/os_dirpath.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2019 Intel, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +/** @file: + * Creates a directory tree set to the specified permissions. + * + * The pmix_os_dirpath_create() function creates a directory + * tree, with each directory that is created in the tree having the specified + * access permissions. Existing directories within the tree are left + * untouched - however, if they do not permit the user to create a directory + * within them, the function will return an error condition. + * + * If the specified full path name already exists, the + * pmix_os_dirpath_create() function will check to ensure that + * the final directory in the tree has at least the specified access permission. In other + * words, if the directory has read-write-execute for all, and the user + * has requested read-write access for just the user, then the function + * will consider the directory acceptable. If the minimal permissions are + * not currently provided, the function will attempt to change the + * access permissions of the directory to add the specified + * permissions. The function will return PMIX_ERROR if this cannot + * be done. + **/ + +#ifndef PMIX_OS_DIRPATH_CREATE_H +#define PMIX_OS_DIRPATH_CREATE_H + +#include "pmix_config.h" +#ifdef HAVE_SYS_STAT_H +#include +#endif + +BEGIN_C_DECLS + +/** + * @param path A pointer to a string that contains the path name to be built. + * @param mode A mode_t bit mask that specifies the access permissions for the + * directories being constructed. + * @retval PMIX_SUCCESS If the directory tree has been successfully created with + * the specified access permissions. + * @retval PMIX_ERROR If the directory tree could not be created with the + * specified access permissions. + */ + +PMIX_EXPORT int pmix_os_dirpath_create(const char *path, const mode_t mode); + +/** + * Check to see if a directory is empty + * + * @param path A pointer to a string that contains the path name to be checked. + * + * @retval true If the directory is empty + * @retval false If the directory is not empty + */ +PMIX_EXPORT bool pmix_os_dirpath_is_empty(const char *path); + +/** + * Check access to the directory + * + * @param path A pointer to a string that contains the path name to be checked. + * @param mode A mode_t bit mask that specifies the access permissions for the + * directory to be accessed. + * + * @retval PMIX_SUCCESS If directory exists, and permissions match + * @retval PMIX_ERR_NOT_FOUND If directory does not exist + * @retval PMIX_ERROR If directory exists, and permissions do not match + */ +PMIX_EXPORT int pmix_os_dirpath_access(const char *path, const mode_t mode ); + +/** + * Callback for pmix_os_dirpath_destroy(). Call for every file/directory before + * taking action to remove/unlink it. + * + * @param root A pointer to a string that contains the base path name (e.g., /tmp/foo from /tmp/foo/bar) + * @param path A pointer to a string that contains the file or directory (e.g., bar from /tmp/foo/bar) + * + * @retval true Allow the program to remove the file/directory + * @retval false Do not allow the program to remove the file/directory + */ +typedef bool (*pmix_os_dirpath_destroy_callback_fn_t)(const char *root, const char *path); + +/** + * Destroy a directory + * + * @param path A pointer to a string that contains the path name to be destroyed + * @param recursive Recursively desend the directory removing all files and directories. + * if set to 'false' then the directory must be empty to succeed. + * @param cbfunc A function that will be called before removing a file or directory. + * If NULL, then assume all remove. + * + * @retval PMIX_SUCCESS If the directory was successfully removed or removed to the + * specification of the user (i.e., obeyed the callback function). + * @retval PMIX_ERR_NOT_FOUND If directory does not exist. + * @retval PMIX_ERROR If the directory cannnot be removed, accessed properly, or contains + * directories that could not be removed.. + */ +PMIX_EXPORT int pmix_os_dirpath_destroy(const char *path, + bool recursive, + pmix_os_dirpath_destroy_callback_fn_t cbfunc); + +END_C_DECLS + +#endif diff --git a/opal/mca/pmix/pmix4x/pmix/test/cli_stages.c b/opal/mca/pmix/pmix4x/pmix/test/cli_stages.c index ecd41c2bd4..f8ccae92c4 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/cli_stages.c +++ b/opal/mca/pmix/pmix4x/pmix/test/cli_stages.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015-2018 Mellanox Technologies, Inc. @@ -58,7 +58,7 @@ void cli_init(int nprocs) } } -void cli_connect(cli_info_t *cli, int sd, struct event_base * ebase, event_callback_fn callback) +void cli_connect(cli_info_t *cli, int sd, pmix_event_base_t * ebase, event_callback_fn callback) { if( CLI_CONNECTED != cli->next_state[cli->state] ){ TEST_ERROR(("Rank %d has bad next state: expect %d have %d!", @@ -68,9 +68,9 @@ void cli_connect(cli_info_t *cli, int sd, struct event_base * ebase, event_callb } cli->sd = sd; - cli->ev = event_new(ebase, sd, + cli->ev = pmix_event_new(ebase, sd, EV_READ|EV_PERSIST, callback, cli); - event_add(cli->ev,NULL); + pmix_event_add(cli->ev,NULL); pmix_ptl_base_set_nonblocking(sd); TEST_VERBOSE(("Connection accepted from rank %d", cli_rank(cli) )); cli->state = CLI_CONNECTED; @@ -109,8 +109,8 @@ void cli_disconnect(cli_info_t *cli) test_abort = true; } else { TEST_VERBOSE(("remove event of rank %d from event queue", cli_rank(cli))); - event_del(cli->ev); - event_free(cli->ev); + pmix_event_del(cli->ev); + pmix_event_free(cli->ev); cli->ev = NULL; } diff --git a/opal/mca/pmix/pmix4x/pmix/test/cli_stages.h b/opal/mca/pmix/pmix4x/pmix/test/cli_stages.h index b716480b0a..cf505c65d4 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/cli_stages.h +++ b/opal/mca/pmix/pmix4x/pmix/test/cli_stages.h @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2015-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015-2018 Mellanox Technologies, Inc. @@ -25,7 +25,6 @@ #include #include #include -#include PMIX_EVENT_HEADER #include #include "src/include/pmix_globals.h" #include "pmix_server.h" diff --git a/opal/mca/pmix/pmix4x/pmix/test/simple/Makefile.am b/opal/mca/pmix/pmix4x/pmix/test/simple/Makefile.am index 3a723a0de4..359c688741 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/simple/Makefile.am +++ b/opal/mca/pmix/pmix4x/pmix/test/simple/Makefile.am @@ -11,7 +11,7 @@ # All rights reserved. # Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved. -# Copyright (c) 2013-2018 Intel, Inc. All rights reserved. +# Copyright (c) 2013-2019 Intel, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -25,7 +25,7 @@ headers = simptest.h noinst_PROGRAMS = simptest simpclient simppub simpdyn simpft simpdmodex \ test_pmix simptool simpdie simplegacy simptimeout \ - gwtest gwclient stability quietclient simpjctrl + gwtest gwclient stability quietclient simpjctrl simpio simptest_SOURCES = \ simptest.c @@ -122,3 +122,9 @@ simpjctrl_SOURCES = \ simpjctrl_LDFLAGS = $(PMIX_PKG_CONFIG_LDFLAGS) simpjctrl_LDADD = \ $(top_builddir)/src/libpmix.la + +simpio_SOURCES = \ + simpio.c +simpio_LDFLAGS = $(PMIX_PKG_CONFIG_LDFLAGS) +simpio_LDADD = \ + $(top_builddir)/src/libpmix.la diff --git a/opal/mca/pmix/pmix4x/pmix/test/simple/gwtest.c b/opal/mca/pmix/pmix4x/pmix/test/simple/gwtest.c index 2f1fae4701..158ccfee3a 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/simple/gwtest.c +++ b/opal/mca/pmix/pmix4x/pmix/test/simple/gwtest.c @@ -13,7 +13,7 @@ * All rights reserved. * Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. @@ -38,7 +38,6 @@ #include #include #include -#include PMIX_EVENT_HEADER #include "src/class/pmix_list.h" #include "src/util/pmix_environ.h" @@ -392,9 +391,9 @@ int main(int argc, char **argv) /* setup to see sigchld on the forked tests */ PMIX_CONSTRUCT(&children, pmix_list_t); - event_assign(&handler, pmix_globals.evbase, SIGCHLD, - EV_SIGNAL|EV_PERSIST,wait_signal_callback, &handler); - event_add(&handler, NULL); + pmix_event_assign(&handler, pmix_globals.evbase, SIGCHLD, + EV_SIGNAL|EV_PERSIST,wait_signal_callback, &handler); + pmix_event_add(&handler, NULL); /* we have a single namespace for all clients */ atmp = NULL; @@ -1023,7 +1022,7 @@ static void wait_signal_callback(int fd, short event, void *arg) pid_t pid; wait_tracker_t *t2; - if (SIGCHLD != event_get_signal(sig)) { + if (SIGCHLD != pmix_event_get_signal(sig)) { return; } diff --git a/opal/mca/pmix/pmix4x/pmix/test/simple/simpclient.c b/opal/mca/pmix/pmix4x/pmix/test/simple/simpclient.c index cde1d4f3f6..cf80d62c6c 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/simple/simpclient.c +++ b/opal/mca/pmix/pmix4x/pmix/test/simple/simpclient.c @@ -15,6 +15,8 @@ * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. + * Copyright (c) 2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -113,7 +115,7 @@ static void model_registration_callback(pmix_status_t status, size_t evhandler_ref, void *cbdata) { - volatile int *active = (volatile int*)cbdata; + volatile bool *active = (volatile bool*)cbdata; fprintf(stderr, "simpclient EVENT HANDLER REGISTRATION RETURN STATUS %d, ref=%lu\n", status, (unsigned long)evhandler_ref); diff --git a/opal/mca/pmix/pmix4x/pmix/test/simple/simpio.c b/opal/mca/pmix/pmix4x/pmix/test/simple/simpio.c new file mode 100644 index 0000000000..6dc1710043 --- /dev/null +++ b/opal/mca/pmix/pmix4x/pmix/test/simple/simpio.c @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2011 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) 2006-2013 Los Alamos National Security, LLC. + * All rights reserved. + * Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + */ + +#include +#include + +#include +#include +#include +#include + +#include "src/class/pmix_object.h" +#include "src/util/output.h" +#include "src/util/printf.h" + +#define MAXCNT 1 + +static volatile bool completed = false; +static pmix_proc_t myproc; + +static void notification_fn(size_t evhdlr_registration_id, + pmix_status_t status, + const pmix_proc_t *source, + pmix_info_t info[], size_t ninfo, + pmix_info_t results[], size_t nresults, + pmix_event_notification_cbfunc_fn_t cbfunc, + void *cbdata) +{ + pmix_output(0, "Client %s:%d NOTIFIED with status %s", myproc.nspace, myproc.rank, PMIx_Error_string(status)); + if (NULL != cbfunc) { + cbfunc(PMIX_SUCCESS, NULL, 0, NULL, NULL, cbdata); + } + completed = true; +} + +static void errhandler_reg_callbk(pmix_status_t status, + size_t errhandler_ref, + void *cbdata) +{ + volatile bool *active = (volatile bool*)cbdata; + + pmix_output(0, "Client: ERRHANDLER REGISTRATION CALLBACK CALLED WITH STATUS %d, ref=%lu", + status, (unsigned long)errhandler_ref); + *active = false; +} + +#define SIMPIO_MSG_MAX 8192 + +int main(int argc, char **argv) +{ + pmix_status_t rc; + volatile bool active; + int msgsize; + char msg[SIMPIO_MSG_MAX]; + pmix_proc_t proc; + int cnt = 0; + + /* init us */ + if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, NULL, 0))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Init failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); + exit(rc); + } + pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank); + + /* register our errhandler */ + active = true; + PMIx_Register_event_handler(NULL, 0, NULL, 0, + notification_fn, errhandler_reg_callbk, (void*)&active); + while (active) { + usleep(10); + } + + /* if we are rank=0, read our stdin */ + if (0 == myproc.rank) { + while (0 < (msgsize = read(0, msg, SIMPIO_MSG_MAX))) { + cnt += msgsize; + fprintf(stderr, "Rank %d: read %d bytes\n", myproc.rank, cnt); + } + } + + /* call fence to sync */ + PMIX_PROC_CONSTRUCT(&proc); + (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); + proc.rank = PMIX_RANK_WILDCARD; + if (PMIX_SUCCESS != (rc = PMIx_Fence(&proc, 1, NULL, 0))) { + pmix_output(0, "Client ns %s rank %d PMIx_Fence failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); + } + + /* finalize us */ + pmix_output(0, "Client ns %s rank %d: Finalizing", myproc.nspace, myproc.rank); + if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) { + fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %s\n", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); + } else { + fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n", myproc.nspace, myproc.rank); + } + fflush(stderr); + return(rc); +} diff --git a/opal/mca/pmix/pmix4x/pmix/test/simple/simptest.c b/opal/mca/pmix/pmix4x/pmix/test/simple/simptest.c index 8aeb187438..1473a277fd 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/simple/simptest.c +++ b/opal/mca/pmix/pmix4x/pmix/test/simple/simptest.c @@ -38,7 +38,6 @@ #include #include #include -#include PMIX_EVENT_HEADER #if PMIX_HAVE_HWLOC #include @@ -513,9 +512,9 @@ int main(int argc, char **argv) /* setup to see sigchld on the forked tests */ PMIX_CONSTRUCT(&children, pmix_list_t); - event_assign(&handler, pmix_globals.evbase, SIGCHLD, - EV_SIGNAL|EV_PERSIST,wait_signal_callback, &handler); - event_add(&handler, NULL); + pmix_event_assign(&handler, pmix_globals.evbase, SIGCHLD, + EV_SIGNAL|EV_PERSIST,wait_signal_callback, &handler); + pmix_event_add(&handler, NULL); /* we have a single namespace for all clients */ atmp = NULL; @@ -1224,7 +1223,7 @@ static void wait_signal_callback(int fd, short event, void *arg) pid_t pid; wait_tracker_t *t2; - if (SIGCHLD != event_get_signal(sig)) { + if (SIGCHLD != pmix_event_get_signal(sig)) { return; } diff --git a/opal/mca/pmix/pmix4x/pmix/test/simple/stability.c b/opal/mca/pmix/pmix4x/pmix/test/simple/stability.c index d67b6f8410..7964775023 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/simple/stability.c +++ b/opal/mca/pmix/pmix4x/pmix/test/simple/stability.c @@ -13,7 +13,7 @@ * All rights reserved. * Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2013-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 IBM Corporation. All rights reserved. @@ -38,7 +38,6 @@ #include #include #include -#include PMIX_EVENT_HEADER #if PMIX_HAVE_HWLOC #include @@ -304,9 +303,9 @@ int main(int argc, char **argv) /* setup to see sigchld on the forked tests */ PMIX_CONSTRUCT(&children, pmix_list_t); - event_assign(&handler, pmix_globals.evbase, SIGCHLD, - EV_SIGNAL|EV_PERSIST,wait_signal_callback, &handler); - event_add(&handler, NULL); + pmix_event_assign(&handler, pmix_globals.evbase, SIGCHLD, + EV_SIGNAL|EV_PERSIST,wait_signal_callback, &handler); + pmix_event_add(&handler, NULL); for (m=0; m < ncycles; m++) { fprintf(stderr, "Running cycle %d\n", m); @@ -852,7 +851,7 @@ static void wait_signal_callback(int fd, short event, void *arg) pid_t pid; wait_tracker_t *t2; - if (SIGCHLD != event_get_signal(sig)) { + if (SIGCHLD != pmix_event_get_signal(sig)) { return; } diff --git a/opal/mca/pmix/pmix4x/pmix/test/test_server.c b/opal/mca/pmix/pmix4x/pmix/test/test_server.c index caa862b725..f99df44c5b 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/test_server.c +++ b/opal/mca/pmix/pmix4x/pmix/test/test_server.c @@ -2,8 +2,8 @@ * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015-2018 Mellanox Technologies, Inc. * All rights reserved. - * Copyright (c) 2016 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2016-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -38,7 +38,7 @@ static void sdes(server_info_t *s) close(s->rd_fd); close(s->wr_fd); if (s->evread) { - event_del(s->evread); + pmix_event_del(s->evread); } s->evread = NULL; } @@ -77,7 +77,7 @@ PMIX_CLASS_INSTANCE(server_nspace_t, nscon, nsdes); static int server_send_procs(void); -static void server_read_cb(evutil_socket_t fd, short event, void *arg); +static void server_read_cb(int fd, short event, void *arg); static int srv_wait_all(double timeout); static int server_fwd_msg(msg_hdr_t *msg_hdr, char *buf, size_t size); static int server_send_msg(msg_hdr_t *msg_hdr, char *data, size_t size); @@ -459,7 +459,7 @@ static void _libpmix_cb(void *cbdata) } } -static void server_read_cb(evutil_socket_t fd, short event, void *arg) +static void server_read_cb(int fd, short event, void *arg) { server_info_t *server = (server_info_t*)arg; msg_hdr_t msg_hdr; @@ -790,9 +790,9 @@ int server_init(test_params *params) if (params->nservers && pmix_list_get_size(server_list)) { server_info_t *server; PMIX_LIST_FOREACH(server, server_list, server_info_t) { - server->evread = event_new(pmix_globals.evbase, server->rd_fd, - EV_READ|EV_PERSIST, server_read_cb, server); - event_add(server->evread, NULL); + server->evread = pmix_event_new(pmix_globals.evbase, server->rd_fd, + EV_READ|EV_PERSIST, server_read_cb, server); + pmix_event_add(server->evread, NULL); } } diff --git a/opal/mca/pmix/pmix4x/pmix/test/test_server.h b/opal/mca/pmix/pmix4x/pmix/test/test_server.h index 4d9db8807e..fbf1b2bbd4 100644 --- a/opal/mca/pmix/pmix4x/pmix/test/test_server.h +++ b/opal/mca/pmix/pmix4x/pmix/test/test_server.h @@ -2,7 +2,6 @@ * Copyright (c) 2018 Mellanox Technologies, Inc. * All rights reserved. * - * Copyright (c) 2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow