From 167ca31a311f6542a06011d25dba60e10d4114b2 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Fri, 9 Aug 2019 13:13:45 -0700 Subject: [PATCH] Update PMIx to official v3.1.4 release Signed-off-by: Ralph Castain --- opal/mca/pmix/pmix3x/pmix/NEWS | 61 + opal/mca/pmix/pmix3x/pmix/VERSION | 12 +- .../pmix3x/pmix/config/c_get_alignment.m4 | 8 +- opal/mca/pmix/pmix3x/pmix/config/pmix.m4 | 16 +- .../config/pmix_check_compiler_version.m4 | 7 +- .../pmix/pmix3x/pmix/config/pmix_check_icc.m4 | 7 +- .../pmix3x/pmix/config/pmix_setup_libev.m4 | 96 ++ .../pmix3x/pmix/config/pmix_setup_libevent.m4 | 187 +-- opal/mca/pmix/pmix3x/pmix/configure.ac | 1 - opal/mca/pmix/pmix3x/pmix/contrib/pmix.spec | 2 +- opal/mca/pmix/pmix3x/pmix/examples/client.c | 3 + opal/mca/pmix/pmix3x/pmix/examples/dynamic.c | 86 +- opal/mca/pmix/pmix3x/pmix/src/client/pmi1.c | 20 +- .../pmix/pmix3x/pmix/src/client/pmix_client.c | 4 +- .../pmix/src/client/pmix_client_fence.c | 18 +- .../pmix3x/pmix/src/client/pmix_client_get.c | 95 +- .../pmix/pmix3x/pmix/src/common/pmix_log.c | 14 +- .../pmix/pmix3x/pmix/src/common/pmix_query.c | 46 +- .../pmix/src/event/pmix_event_notification.c | 2 +- .../pmix3x/pmix/src/include/pmix_globals.c | 31 + .../pmix3x/pmix/src/include/pmix_globals.h | 13 + opal/mca/pmix/pmix3x/pmix/src/include/types.h | 60 +- .../mca/base/pmix_mca_base_component_find.c | 6 +- .../pmix/src/mca/base/pmix_mca_base_open.c | 6 +- .../pmix3x/pmix/src/mca/bfrops/v20/copy.c | 26 +- .../src/mca/common/dstore/dstore_segment.c | 9 +- .../pmix3x/pmix/src/mca/gds/hash/gds_hash.c | 1181 +++++++++++++++-- .../pmix/src/mca/pif/bsdx_ipv4/pif_bsdx.c | 4 +- .../src/mca/pif/bsdx_ipv6/pif_bsdx_ipv6.c | 4 +- .../src/mca/pif/linux_ipv6/pif_linux_ipv6.c | 17 +- opal/mca/pmix/pmix3x/pmix/src/mca/pif/pif.h | 4 +- .../mca/pif/solaris_ipv6/pif_solaris_ipv6.c | 4 +- .../pmix/src/mca/plog/base/plog_base_stubs.c | 12 +- .../pmix/src/mca/plog/stdfd/plog_stdfd.c | 6 +- .../pmix/src/mca/pnet/base/pnet_base_fns.c | 14 +- .../pmix3x/pmix/src/mca/pnet/opa/pnet_opa.c | 4 +- .../pmix3x/pmix/src/mca/pnet/tcp/pnet_tcp.c | 11 +- .../pmix/src/mca/pshmem/mmap/pshmem_mmap.c | 6 +- .../pmix3x/pmix/src/mca/ptl/tcp/ptl_tcp.c | 6 +- .../pmix/src/mca/ptl/tcp/ptl_tcp_component.c | 28 +- .../pmix3x/pmix/src/mca/ptl/usock/ptl_usock.c | 4 +- .../src/mca/ptl/usock/ptl_usock_component.c | 2 +- .../pmix3x/pmix/src/runtime/pmix_finalize.c | 8 +- .../pmix/pmix3x/pmix/src/runtime/pmix_init.c | 10 +- .../pmix/src/runtime/pmix_progress_threads.c | 148 ++- .../pmix/pmix3x/pmix/src/server/pmix_server.c | 35 +- .../pmix3x/pmix/src/server/pmix_server_get.c | 83 +- .../pmix3x/pmix/src/server/pmix_server_ops.c | 32 +- .../mca/pmix/pmix3x/pmix/src/tool/pmix_tool.c | 9 +- opal/mca/pmix/pmix3x/pmix/src/util/compress.c | 10 +- opal/mca/pmix/pmix3x/pmix/src/util/name_fns.c | 46 +- opal/mca/pmix/pmix3x/pmix/src/util/output.c | 6 +- opal/mca/pmix/pmix3x/pmix/src/util/pif.h | 6 +- .../pmix/pmix3x/pmix/src/util/pmix_environ.c | 78 +- opal/mca/pmix/pmix3x/pmix/test/cli_stages.c | 16 +- opal/mca/pmix/pmix3x/pmix/test/cli_stages.h | 4 +- opal/mca/pmix/pmix3x/pmix/test/pmi_client.c | 61 +- .../pmix/pmix3x/pmix/test/simple/Makefile.am | 4 +- .../mca/pmix/pmix3x/pmix/test/simple/gwtest.c | 10 +- .../pmix3x/pmix/test/simple/quietclient.c | 121 +- .../pmix/pmix3x/pmix/test/simple/simpclient.c | 132 +- .../pmix/pmix3x/pmix/test/simple/simpdie.c | 11 +- .../pmix/pmix3x/pmix/test/simple/simpdmodex.c | 78 +- .../pmix/pmix3x/pmix/test/simple/simpdyn.c | 37 +- .../mca/pmix/pmix3x/pmix/test/simple/simpft.c | 11 +- .../pmix/pmix3x/pmix/test/simple/simpjctrl.c | 13 +- .../pmix/pmix3x/pmix/test/simple/simplegacy.c | 248 +--- .../pmix/pmix3x/pmix/test/simple/simppub.c | 11 +- .../pmix/pmix3x/pmix/test/simple/simptest.c | 252 +++- .../pmix3x/pmix/test/simple/simptimeout.c | 10 +- .../pmix/pmix3x/pmix/test/simple/stability.c | 327 ++++- opal/mca/pmix/pmix3x/pmix/test/test_common.h | 6 +- opal/mca/pmix/pmix3x/pmix/test/test_error.c | 6 +- opal/mca/pmix/pmix3x/pmix/test/test_server.c | 36 +- 74 files changed, 2962 insertions(+), 1046 deletions(-) create mode 100644 opal/mca/pmix/pmix3x/pmix/config/pmix_setup_libev.m4 diff --git a/opal/mca/pmix/pmix3x/pmix/NEWS b/opal/mca/pmix/pmix3x/pmix/NEWS index 6445b18275..f18016dd7f 100644 --- a/opal/mca/pmix/pmix3x/pmix/NEWS +++ b/opal/mca/pmix/pmix3x/pmix/NEWS @@ -21,6 +21,28 @@ example, a bug might be fixed in the master, and then moved to multiple release branches. +3.1.4 -- 9 Aug 2019 +---------------------- +- PR #1342: Fix if_linux_ipv6_open interface filter +- PR #1344: Remove unnecessary libtool init for c++ +- PR #1346: Fix incorrect pointer casts/deref +- PR #1347/#1348: Fix use of gethostname +- PR #1353/#1357: util/environ: use setenv() if available +- PR #1354: Plug a misc memory leak in the pmix_query_caddy_t destructor +- PR #1356: Fix another pointer cast/deref in test suite +- PR #1358: Implement support for class-based info arrays +- PR #1359: Plug misc minor memory leaks +- PR #1368: Backport support for libev +- PR #1369: Fix legacy support for PMI-1 +- PR #1370: Cleanup handling of data requests for different nspaces +- PR #1193: Resolve get of proc-specific job-level info from another nspace +- PR #1376: Fix problems in the Log code path, updates to simple test suite +- PR #1377: Skip fastpath/dstore for NULL keys +- PR #1379: Change IF_NAMESIZE to PMIX_IF_NAMESIZE and set to safe size +- PR #1385: Check for EINVAL return from posix_fallocate +- PR #1389: Plug misc memory leaks in configure + + 3.1.3 -- 2 July 2019 ---------------------- - PR #1096: Restore PMIX_NUM_SLOTS for backward compatibility @@ -120,6 +142,45 @@ multiple release branches. - Fix a bug when registering default event handlers +3.1.0 -- 17 Jan 2019 +---------------------- +**** THIS RELEASE MARKS THE STARTING POINT FOR FULL COMPLIANCE +**** WITH THE PMIX v3 STANDARD. ALL API BEHAVIORS AND ATTRIBUTE +**** DEFINITIONS MEET THE v3 STANDARD SPECIFICATIONS. + - Add a new, faster dstore GDS component 'ds21' + - Performance optimizations for the dstore GDS components. + - Plug miscellaneous memory leaks + - Silence an unnecessary warning message when checking connection + to a non-supporting server + - Ensure lost-connection events get delivered to default event + handlers + - Correctly handle cache refresh for queries + - Protect against race conditions between host and internal library + when dealing with async requests + - Cleanup tool operations and add support for connections to + remote servers. Initial support for debugger direct/indirect + launch verified with PRRTE. Cleanup setting of tmpdir options. + Drop rendezvous files when acting as a launcher + - Automatically store the server URI for easy access by client + - Provide MCA parameter to control TCP connect retry/timeout + - Update event notification system to properly evict oldest events + when more space is needed + - Fix a number of error paths + - Update IOF cache code to properly drop oldest message. Provide + MCA parameter for setting cache size. + - Handle setsockopt(SO_RCVTIMEO) not being supported + - Ensure that epilogs get run even when connections unexpectedly + terminate. Properly split epilog strings to process multiple + paths + - Pass the tool's command line to the server so it can be returned + in queries + - Add support for C11 atomics + - Support collection and forwarding of fabric-specific envars + - Improve handling of hwloc configure option + - Fix PMIx_server_generate_regex to preserve node ordering + - Fix a bug when registering default event handlers + + 3.0.2 -- 18 Sept 2018 ---------------------- - Ensure we cleanup any active sensors when a peer departs. Allow the diff --git a/opal/mca/pmix/pmix3x/pmix/VERSION b/opal/mca/pmix/pmix3x/pmix/VERSION index 13511b92a5..8d2b40af3e 100644 --- a/opal/mca/pmix/pmix3x/pmix/VERSION +++ b/opal/mca/pmix/pmix3x/pmix/VERSION @@ -15,7 +15,7 @@ major=3 minor=1 -release=3 +release=4 # greek is used for alpha or beta release tags. If it is non-empty, # it will be appended to the version number. It does not have to be @@ -30,7 +30,7 @@ greek= # command, or with the date (if "git describe" fails) in the form of # "date". -repo_rev=gitc10fd1d4 +repo_rev=gite6837057 # 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="Jul 02, 2019" +date="Aug 09, 2019" # The shared library version of each of PMIx's public libraries. # These versions are maintained in accordance with the "Library @@ -75,8 +75,8 @@ date="Jul 02, 2019" # Version numbers are described in the Libtool current:revision:age # format. -libpmix_so_version=4:23:2 -libpmi_so_version=1:0:0 +libpmix_so_version=4:24:2 +libpmi_so_version=1:1:0 libpmi2_so_version=1:0:0 # "Common" components install standalone libraries that are run-time @@ -84,4 +84,4 @@ libpmi2_so_version=1:0:0 # # well. Yuck; this somewhat breaks the # # components-don't-affect-the-build-system abstraction. # -libmca_common_dstore_so_version=1:0:0 +libmca_common_dstore_so_version=1:1:0 diff --git a/opal/mca/pmix/pmix3x/pmix/config/c_get_alignment.m4 b/opal/mca/pmix/pmix3x/pmix/config/c_get_alignment.m4 index db37910099..6596c0ae88 100644 --- a/opal/mca/pmix/pmix3x/pmix/config/c_get_alignment.m4 +++ b/opal/mca/pmix/pmix3x/pmix/config/c_get_alignment.m4 @@ -11,9 +11,9 @@ 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) 2009 Sun Microsystems, Inc. All rights reserved. -dnl Copyright (c) 2014-2015 Intel, Inc. All rights reserved. -dnl Copyright (c) 2015 Research Organization for Information Science -dnl and Technology (RIST). All rights reserved. +dnl Copyright (c) 2014-2019 Intel, Inc. All rights reserved. +dnl Copyright (c) 2015-2019 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -44,7 +44,9 @@ AC_DEFUN([PMIX_C_GET_ALIGNMENT],[ FILE *f=fopen("conftestval", "w"); if (!f) exit(1); diff = ((char *)&p->x) - ((char *)&p->c); + free(p); fprintf(f, "%d\n", (diff >= 0) ? diff : -diff); + fclose(f); ]])], [AS_TR_SH([pmix_cv_c_align_$1])=`cat conftestval`], [AC_MSG_WARN([*** Problem running configure test!]) AC_MSG_WARN([*** See config.log for details.]) diff --git a/opal/mca/pmix/pmix3x/pmix/config/pmix.m4 b/opal/mca/pmix/pmix3x/pmix/config/pmix.m4 index e0585256c4..1d37089f8a 100644 --- a/opal/mca/pmix/pmix3x/pmix/config/pmix.m4 +++ b/opal/mca/pmix/pmix3x/pmix/config/pmix.m4 @@ -663,7 +663,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[ # -lrt might be needed for clock_gettime PMIX_SEARCH_LIBS_CORE([clock_gettime], [rt]) - AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid getpeerucred strnlen posix_fallocate tcgetpgrp]) + AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid getpeerucred strnlen posix_fallocate tcgetpgrp setpgid ptsname openpty setenv]) # On some hosts, htonl is a define, so the AC_CHECK_FUNC will get # confused. On others, it's in the standard library, but stubbed with @@ -754,8 +754,22 @@ AC_DEFUN([PMIX_SETUP_CORE],[ ################################## pmix_show_title "Libevent" + 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 ################################## diff --git a/opal/mca/pmix/pmix3x/pmix/config/pmix_check_compiler_version.m4 b/opal/mca/pmix/pmix3x/pmix/config/pmix_check_compiler_version.m4 index eca2013be8..da822b0481 100644 --- a/opal/mca/pmix/pmix3x/pmix/config/pmix_check_compiler_version.m4 +++ b/opal/mca/pmix/pmix3x/pmix/config/pmix_check_compiler_version.m4 @@ -1,7 +1,9 @@ dnl -*- shell-script -*- dnl dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. -dnl Copyright (c) 2013-2017 Intel, Inc. All rights reserved. +dnl Copyright (c) 2013-2019 Intel, Inc. All rights reserved. +dnl Copyright (c) 2019 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. dnl dnl $COPYRIGHT$ dnl @@ -43,6 +45,7 @@ int main (int argc, char * argv[]) f=fopen("conftestval", "w"); if (!f) exit(1); fprintf (f, "%d", PLATFORM_COMPILER_$1); + fclose(f); return 0; } ], [ @@ -75,6 +78,7 @@ int main (int argc, char * argv[]) f=fopen("conftestval", "w"); if (!f) exit(1); fprintf (f, "%s", PLATFORM_COMPILER_$1); + fclose(f); return 0; } ], [ @@ -110,6 +114,7 @@ int main (int argc, char * argv[]) f=fopen("conftestval", "w"); if (!f) exit(1); fprintf (f, "%s", _STRINGIFY(PLATFORM_COMPILER_$1)); + fclose(f); return 0; } ], [ diff --git a/opal/mca/pmix/pmix3x/pmix/config/pmix_check_icc.m4 b/opal/mca/pmix/pmix3x/pmix/config/pmix_check_icc.m4 index e8a06b2514..05ce9431bd 100644 --- a/opal/mca/pmix/pmix3x/pmix/config/pmix_check_icc.m4 +++ b/opal/mca/pmix/pmix3x/pmix/config/pmix_check_icc.m4 @@ -10,9 +10,9 @@ dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, dnl University of Stuttgart. All rights reserved. dnl Copyright (c) 2004-2005 The Regents of the University of California. dnl All rights reserved. -dnl Copyright (c) 2014 Intel, Inc. All rights reserved. -dnl Copyright (c) 2016 Research Organization for Information Science -dnl and Technology (RIST). All rights reserved. +dnl Copyright (c) 2014-2019 Intel, Inc. All rights reserved. +dnl Copyright (c) 2016-2019 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -45,6 +45,7 @@ int main () func (4711, "Help %d [%s]\n", 10, "ten"); f=fopen ("conftestval", "w"); if (!f) exit (1); + fclose(f); return 0; } diff --git a/opal/mca/pmix/pmix3x/pmix/config/pmix_setup_libev.m4 b/opal/mca/pmix/pmix3x/pmix/config/pmix_setup_libev.m4 new file mode 100644 index 0000000000..494cc2a2c3 --- /dev/null +++ b/opal/mca/pmix/pmix3x/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/pmix3x/pmix/config/pmix_setup_libevent.m4 b/opal/mca/pmix/pmix3x/pmix/config/pmix_setup_libevent.m4 index 949af1cfd5..28e3a41227 100644 --- a/opal/mca/pmix/pmix3x/pmix/config/pmix_setup_libevent.m4 +++ b/opal/mca/pmix/pmix3x/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/pmix3x/pmix/configure.ac b/opal/mca/pmix/pmix3x/pmix/configure.ac index 3cbd07e891..4bab86e668 100644 --- a/opal/mca/pmix/pmix3x/pmix/configure.ac +++ b/opal/mca/pmix/pmix3x/pmix/configure.ac @@ -201,7 +201,6 @@ AS_IF([test "$pmix_debug" = "1"], LT_INIT() LT_LANG([C]) -LT_LANG([C++]) ############################################################################ # Setup the core diff --git a/opal/mca/pmix/pmix3x/pmix/contrib/pmix.spec b/opal/mca/pmix/pmix3x/pmix/contrib/pmix.spec index 6a47f05480..ae488781f7 100644 --- a/opal/mca/pmix/pmix3x/pmix/contrib/pmix.spec +++ b/opal/mca/pmix/pmix3x/pmix/contrib/pmix.spec @@ -192,7 +192,7 @@ Summary: An extended/exascale implementation of PMI Name: %{?_name:%{_name}}%{!?_name:pmix} -Version: 3.1.3 +Version: 3.1.4 Release: 1%{?dist} License: BSD Group: Development/Libraries diff --git a/opal/mca/pmix/pmix3x/pmix/examples/client.c b/opal/mca/pmix/pmix3x/pmix/examples/client.c index 519ef649d6..49e471fb25 100644 --- a/opal/mca/pmix/pmix3x/pmix/examples/client.c +++ b/opal/mca/pmix/pmix3x/pmix/examples/client.c @@ -254,6 +254,9 @@ int main(int argc, char **argv) fprintf(stderr, "Client ns %s rank %d: PMIx_Commit failed: %d\n", myproc.nspace, myproc.rank, rc); goto done; } + if (0 == myproc.rank) { + sleep(2); + } /* call fence to synchronize with our peers - instruct * the fence operation to collect and return all "put" diff --git a/opal/mca/pmix/pmix3x/pmix/examples/dynamic.c b/opal/mca/pmix/pmix3x/pmix/examples/dynamic.c index d7c0d3701f..6b929420b7 100644 --- a/opal/mca/pmix/pmix3x/pmix/examples/dynamic.c +++ b/opal/mca/pmix/pmix3x/pmix/examples/dynamic.c @@ -49,9 +49,7 @@ int main(int argc, char **argv) char nsp2[PMIX_MAX_NSLEN+1]; pmix_app_t *app; char hostname[1024], dir[1024]; - pmix_proc_t *peers; - size_t npeers, ntmp=0; - char *nodelist; + size_t ntmp=0; if (0 > gethostname(hostname, sizeof(hostname))) { exit(1); @@ -71,14 +69,14 @@ int main(int argc, char **argv) (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - /* get our universe size */ - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get universe size failed: %d\n", myproc.nspace, myproc.rank, rc); + /* get our job size */ + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get job size failed: %d\n", myproc.nspace, myproc.rank, rc); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - fprintf(stderr, "Client %s:%d universe size %d\n", myproc.nspace, myproc.rank, nprocs); + fprintf(stderr, "Client %s:%d job size %d\n", myproc.nspace, myproc.rank, nprocs); /* call fence to sync */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); @@ -103,13 +101,6 @@ int main(int argc, char **argv) app->env = (char**)malloc(2 * sizeof(char*)); app->env[0] = strdup("PMIX_ENV_VALUE=3"); app->env[1] = NULL; - PMIX_INFO_CREATE(app->info, 2); - (void)strncpy(app->info[0].key, "DARTH", PMIX_MAX_KEYLEN); - app->info[0].value.type = PMIX_INT8; - app->info[0].value.data.int8 = 12; - (void)strncpy(app->info[1].key, "VADER", PMIX_MAX_KEYLEN); - app->info[1].value.type = PMIX_DOUBLE; - app->info[1].value.data.dval = 12.34; fprintf(stderr, "Client ns %s rank %d: calling PMIx_Spawn\n", myproc.nspace, myproc.rank); if (PMIX_SUCCESS != (rc = PMIx_Spawn(NULL, 0, app, 1, nsp2))) { @@ -122,65 +113,28 @@ int main(int argc, char **argv) val = NULL; (void)strncpy(proc.nspace, nsp2, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val)) || + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val)) || NULL == val) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get universe size failed: %d\n", myproc.nspace, myproc.rank, rc); + fprintf(stderr, "Client ns %s rank %d: PMIx_Get job size failed: %d\n", myproc.nspace, myproc.rank, rc); goto done; } ntmp = val->data.uint32; PMIX_VALUE_RELEASE(val); - fprintf(stderr, "Client %s:%d universe %s size %d\n", myproc.nspace, myproc.rank, nsp2, (int)ntmp); - } + fprintf(stderr, "Client %s:%d job %s size %d\n", myproc.nspace, myproc.rank, nsp2, (int)ntmp); - /* just cycle the connect/disconnect functions */ - (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); - proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Connect(&proc, 1, NULL, 0))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Connect failed: %d\n", myproc.nspace, myproc.rank, rc); - goto done; + /* get a proc-specific value */ + val = NULL; + (void)strncpy(proc.nspace, nsp2, PMIX_MAX_NSLEN); + proc.rank = 1; + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_LOCAL_RANK, NULL, 0, &val)) || + NULL == val) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get local rank failed: %d\n", myproc.nspace, myproc.rank, rc); + goto done; + } + ntmp = (int)val->data.uint16; + PMIX_VALUE_RELEASE(val); + fprintf(stderr, "Client %s:%d job %s local rank %d\n", myproc.nspace, myproc.rank, nsp2, (int)ntmp); } - fprintf(stderr, "Client ns %s rank %d: PMIx_Connect succeeded\n", - myproc.nspace, myproc.rank); - if (PMIX_SUCCESS != (rc = PMIx_Disconnect(&proc, 1, NULL, 0))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Disonnect failed: %d\n", myproc.nspace, myproc.rank, rc); - goto done; - } - fprintf(stderr, "Client ns %s rank %d: PMIx_Disconnect succeeded\n", myproc.nspace, myproc.rank); - - /* finally, test the resolve functions */ - if (0 == myproc.rank) { - if (PMIX_SUCCESS != (rc = PMIx_Resolve_peers(hostname, NULL, &peers, &npeers))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_peers failed for nspace %s: %d\n", myproc.nspace, myproc.rank, nsp2, rc); - goto done; - } - if ((nprocs+ntmp) != npeers) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_peers returned incorrect npeers: %d vs %d\n", myproc.nspace, myproc.rank, (int)(nprocs+ntmp), (int)npeers); - goto done; - } - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_peers returned %d npeers\n", myproc.nspace, myproc.rank, (int)npeers); - if (PMIX_SUCCESS != (rc = PMIx_Resolve_nodes(nsp2, &nodelist))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_nodes failed for nspace %s: %d\n", myproc.nspace, myproc.rank, nsp2, rc); - goto done; - } - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_nodes %s", myproc.nspace, myproc.rank, nodelist); - } else { - if (PMIX_SUCCESS != (rc = PMIx_Resolve_peers(hostname, myproc.nspace, &peers, &npeers))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_peers failed for nspace %s: %d\n", myproc.nspace, myproc.rank, myproc.nspace, rc); - goto done; - } - if (nprocs != npeers) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_peers returned incorrect npeers: %d vs %d\n", myproc.nspace, myproc.rank, nprocs, (int)npeers); - goto done; - } - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_peers returned %d npeers\n", myproc.nspace, myproc.rank, (int)npeers); - if (PMIX_SUCCESS != (rc = PMIx_Resolve_nodes(myproc.nspace, &nodelist))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_nodes failed: %d\n", myproc.nspace, myproc.rank, rc); - goto done; - } - fprintf(stderr, "Client ns %s rank %d: PMIx_Resolve_nodes %s\n", myproc.nspace, myproc.rank, nodelist); - } - PMIX_PROC_FREE(peers, npeers); - free(nodelist); done: /* call fence to sync */ diff --git a/opal/mca/pmix/pmix3x/pmix/src/client/pmi1.c b/opal/mca/pmix/pmix3x/pmix/src/client/pmi1.c index dd5cb66e7d..56774e4fb2 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/client/pmi1.c +++ b/opal/mca/pmix/pmix3x/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 Intel, Inc. 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$ @@ -85,7 +85,7 @@ PMIX_EXPORT int PMI_Init(int *spawned) /* getting internal key requires special rank value */ memcpy(&proc, &myproc, sizeof(myproc)); - proc.rank = PMIX_RANK_UNDEF; + proc.rank = PMIX_RANK_WILDCARD; /* set controlling parameters * PMIX_OPTIONAL - expect that these keys should be available on startup @@ -394,8 +394,6 @@ PMIX_EXPORT int PMI_Get_appnum(int *appnum) pmix_value_t *val; pmix_info_t info[1]; bool val_optinal = 1; - pmix_proc_t proc = myproc; - proc.rank = PMIX_RANK_WILDCARD; PMI_CHECK(); @@ -414,11 +412,11 @@ PMIX_EXPORT int PMI_Get_appnum(int *appnum) PMIX_INFO_CONSTRUCT(&info[0]); PMIX_INFO_LOAD(&info[0], PMIX_OPTIONAL, &val_optinal, PMIX_BOOL); - rc = PMIx_Get(&proc, PMIX_APPNUM, info, 1, &val); + rc = PMIx_Get(&myproc, PMIX_APPNUM, info, 1, &val); if (PMIX_SUCCESS == rc) { rc = convert_int(appnum, val); PMIX_VALUE_RELEASE(val); - } else if( PMIX_ERR_NOT_FOUND == rc ){ + } else { /* this is optional value, set to 0 */ *appnum = 0; rc = PMIX_SUCCESS; @@ -445,7 +443,7 @@ PMIX_EXPORT int PMI_Publish_name(const char service_name[], const char port[]) } /* pass the service/port */ - pmix_strncpy(info.key, service_name, PMIX_MAX_KEYLEN); + pmix_strncpy(info.key, service_name, PMIX_MAX_KEYLEN); info.value.type = PMIX_STRING; info.value.data.string = (char*) port; @@ -497,7 +495,7 @@ PMIX_EXPORT int PMI_Lookup_name(const char service_name[], char port[]) PMIX_PDATA_CONSTRUCT(&pdata); /* pass the service */ - pmix_strncpy(pdata.key, service_name, PMIX_MAX_KEYLEN); + pmix_strncpy(pdata.key, service_name, PMIX_MAX_KEYLEN); /* PMI-1 doesn't want the nspace back */ if (PMIX_SUCCESS != (rc = PMIx_Lookup(&pdata, 1, NULL, 0))) { @@ -514,7 +512,7 @@ PMIX_EXPORT int PMI_Lookup_name(const char service_name[], char port[]) * potential we could overrun it. As this feature * isn't widely supported in PMI-1, try being * conservative */ - pmix_strncpy(port, pdata.value.data.string, PMIX_MAX_KEYLEN); + pmix_strncpy(port, pdata.value.data.string, PMIX_MAX_KEYLEN); PMIX_PDATA_DESTRUCT(&pdata); return PMIX_SUCCESS; diff --git a/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client.c b/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client.c index a99f714192..8d522e7a4f 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client.c +++ b/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client.c @@ -1,6 +1,6 @@ /* -*- 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) 2014-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . @@ -50,7 +50,9 @@ #include #endif #include PMIX_EVENT_HEADER +#if ! PMIX_HAVE_LIBEV #include PMIX_EVENT2_THREAD_HEADER +#endif static const char pmix_version_string[] = PMIX_VERSION; static pmix_status_t pmix_init_result = PMIX_ERR_INIT; diff --git a/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client_fence.c b/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client_fence.c index 7a587dcad4..adac9bbf4d 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client_fence.c +++ b/opal/mca/pmix/pmix3x/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 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 Mellanox Technologies, Inc. @@ -73,7 +73,7 @@ PMIX_EXPORT pmix_status_t PMIx_Fence(const pmix_proc_t procs[], size_t nprocs, PMIX_ACQUIRE_THREAD(&pmix_global_lock); - pmix_output_verbose(2, pmix_globals.debug_output, + pmix_output_verbose(2, pmix_client_globals.fence_output, "pmix: executing fence"); if (pmix_globals.init_cntr <= 0) { @@ -106,7 +106,7 @@ PMIX_EXPORT pmix_status_t PMIx_Fence(const pmix_proc_t procs[], size_t nprocs, rc = cb->status; PMIX_RELEASE(cb); - pmix_output_verbose(2, pmix_globals.debug_output, + pmix_output_verbose(2, pmix_client_globals.fence_output, "pmix: fence released"); return rc; @@ -125,7 +125,7 @@ PMIX_EXPORT pmix_status_t PMIx_Fence_nb(const pmix_proc_t procs[], size_t nprocs PMIX_ACQUIRE_THREAD(&pmix_global_lock); - pmix_output_verbose(2, pmix_globals.debug_output, + pmix_output_verbose(2, pmix_client_globals.fence_output, "pmix: fence_nb called"); if (pmix_globals.init_cntr <= 0) { @@ -185,7 +185,7 @@ static pmix_status_t unpack_return(pmix_buffer_t *data) pmix_status_t ret; int32_t cnt; - pmix_output_verbose(2, pmix_globals.debug_output, + pmix_output_verbose(2, pmix_client_globals.fence_output, "client:unpack fence called"); /* unpack the status code */ @@ -196,7 +196,7 @@ static pmix_status_t unpack_return(pmix_buffer_t *data) PMIX_ERROR_LOG(rc); return rc; } - pmix_output_verbose(2, pmix_globals.debug_output, + pmix_output_verbose(2, pmix_client_globals.fence_output, "client:unpack fence received status %d", ret); return ret; } @@ -255,7 +255,7 @@ static void wait_cbfunc(struct pmix_peer_t *pr, pmix_ptl_hdr_t *hdr, pmix_cb_t *cb = (pmix_cb_t*)cbdata; pmix_status_t rc; - pmix_output_verbose(2, pmix_globals.debug_output, + pmix_output_verbose(2, pmix_client_globals.fence_output, "pmix: fence_nb callback recvd"); if (NULL == cb) { diff --git a/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client_get.c b/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client_get.c index 46d6c62db8..48cee715af 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client_get.c +++ b/opal/mca/pmix/pmix3x/pmix/src/client/pmix_client_get.c @@ -1,6 +1,6 @@ /* -*- 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) 2014-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2014 Artem Y. Polyakov . @@ -57,6 +57,7 @@ #include "src/util/compress.h" #include "src/util/error.h" #include "src/util/hash.h" +#include "src/util/name_fns.h" #include "src/util/output.h" #include "src/mca/gds/gds.h" #include "src/mca/ptl/ptl.h" @@ -99,14 +100,15 @@ PMIX_EXPORT pmix_status_t PMIx_Get(const pmix_proc_t *proc, PMIX_RELEASE_THREAD(&pmix_global_lock); pmix_output_verbose(2, pmix_client_globals.get_output, - "pmix:client get for %s:%d key %s", - (NULL == proc) ? "NULL" : proc->nspace, - (NULL == proc) ? PMIX_RANK_UNDEF : proc->rank, + "pmix:client get for %s key %s", + (NULL == proc) ? "NULL" : PMIX_NAME_PRINT(proc), (NULL == key) ? "NULL" : key); /* try to get data directly, without threadshift */ - if (PMIX_SUCCESS == (rc = _getfn_fastpath(proc, key, info, ninfo, val))) { - goto done; + if (PMIX_RANK_UNDEF != proc->rank && NULL != key) { + if (PMIX_SUCCESS == (rc = _getfn_fastpath(proc, key, info, ninfo, val))) { + goto done; + } } /* create a callback object as we need to pass it to the @@ -329,9 +331,14 @@ static void _getnb_cbfunc(struct pmix_peer_t *pr, } if (PMIX_SUCCESS != ret) { + PMIX_ERROR_LOG(ret); goto done; } - PMIX_GDS_ACCEPT_KVS_RESP(rc, pmix_client_globals.myserver, buf); + if (PMIX_RANK_UNDEF == proc.rank) { + PMIX_GDS_ACCEPT_KVS_RESP(rc, pmix_globals.mypeer, buf); + } else { + PMIX_GDS_ACCEPT_KVS_RESP(rc, pmix_client_globals.myserver, buf); + } if (PMIX_SUCCESS != rc) { goto done; } @@ -350,7 +357,11 @@ static void _getnb_cbfunc(struct pmix_peer_t *pr, /* fetch the data from server peer module - since it is passing * it back to the user, we need a copy of it */ cb->copy = true; - PMIX_GDS_FETCH_KV(rc, pmix_client_globals.myserver, cb); + if (PMIX_RANK_UNDEF == proc.rank) { + PMIX_GDS_FETCH_KV(rc, pmix_globals.mypeer, cb); + } else { + PMIX_GDS_FETCH_KV(rc, pmix_client_globals.myserver, cb); + } if (PMIX_SUCCESS == rc) { if (1 != pmix_list_get_size(&cb->kvs)) { rc = PMIX_ERR_INVALID_VAL; @@ -496,9 +507,15 @@ static pmix_status_t _getfn_fastpath(const pmix_proc_t *proc, const pmix_key_t k /* scan the incoming directives */ if (NULL != info) { for (n=0; n < ninfo; n++) { - if (0 == strncmp(info[n].key, PMIX_DATA_SCOPE, PMIX_MAX_KEYLEN)) { + if (PMIX_CHECK_KEY(&info[n], PMIX_DATA_SCOPE)) { cb->scope = info[n].value.data.scope; - break; + } else if (PMIX_CHECK_KEY(&info[n], PMIX_OPTIONAL) || + PMIX_CHECK_KEY(&info[n], PMIX_IMMEDIATE)) { + continue; + } else { + /* we cannot handle any other directives via this path */ + PMIX_RELEASE(cb); + return PMIX_ERR_NOT_SUPPORTED; } } } @@ -508,16 +525,16 @@ static pmix_status_t _getfn_fastpath(const pmix_proc_t *proc, const pmix_key_t k cb->info = (pmix_info_t*)info; cb->ninfo = ninfo; - PMIX_GDS_FETCH_IS_TSAFE(rc, pmix_globals.mypeer); + PMIX_GDS_FETCH_IS_TSAFE(rc, pmix_client_globals.myserver); if (PMIX_SUCCESS == rc) { - PMIX_GDS_FETCH_KV(rc, pmix_globals.mypeer, cb); + PMIX_GDS_FETCH_KV(rc, pmix_client_globals.myserver, cb); if (PMIX_SUCCESS == rc) { goto done; } } - PMIX_GDS_FETCH_IS_TSAFE(rc, pmix_client_globals.myserver); + PMIX_GDS_FETCH_IS_TSAFE(rc, pmix_globals.mypeer); if (PMIX_SUCCESS == rc) { - PMIX_GDS_FETCH_KV(rc, pmix_client_globals.myserver, cb); + PMIX_GDS_FETCH_KV(rc, pmix_globals.mypeer, cb); if (PMIX_SUCCESS == rc) { goto done; } @@ -551,23 +568,23 @@ static void _getnbfn(int fd, short flags, void *cbdata) /* cb was passed to us from another thread - acquire it */ PMIX_ACQUIRE_OBJECT(cb); - pmix_output_verbose(2, pmix_client_globals.get_output, - "pmix: getnbfn value for proc %s:%u key %s", - cb->pname.nspace, cb->pname.rank, - (NULL == cb->key) ? "NULL" : cb->key); - /* set the proc object identifier */ pmix_strncpy(proc.nspace, cb->pname.nspace, PMIX_MAX_NSLEN); proc.rank = cb->pname.rank; + pmix_output_verbose(2, pmix_client_globals.get_output, + "pmix: getnbfn value for proc %s key %s", + PMIX_NAME_PRINT(&proc), + (NULL == cb->key) ? "NULL" : cb->key); + /* scan the incoming directives */ if (NULL != cb->info) { for (n=0; n < cb->ninfo; n++) { - if (0 == strncmp(cb->info[n].key, PMIX_OPTIONAL, PMIX_MAX_KEYLEN)) { + if (PMIX_CHECK_KEY(&cb->info[n], PMIX_OPTIONAL)) { optional = PMIX_INFO_TRUE(&cb->info[n]); - } else if (0 == strncmp(cb->info[n].key, PMIX_IMMEDIATE, PMIX_MAX_KEYLEN)) { + } else if (PMIX_CHECK_KEY(&cb->info[n], PMIX_IMMEDIATE)) { immediate = PMIX_INFO_TRUE(&cb->info[n]); - } else if (0 == strncmp(cb->info[n].key, PMIX_TIMEOUT, PMIX_MAX_KEYLEN)) { + } else if (PMIX_CHECK_KEY(&cb->info[n], PMIX_TIMEOUT)) { /* set a timer to kick us out if we don't * have an answer within their window */ if (0 < cb->info[n].value.data.integer) { @@ -578,8 +595,16 @@ static void _getnbfn(int fd, short flags, void *cbdata) pmix_event_evtimer_add(&cb->ev, &tv); cb->timer_running = true; } - } else if (0 == strncmp(cb->info[n].key, PMIX_DATA_SCOPE, PMIX_MAX_KEYLEN)) { + } else if (PMIX_CHECK_KEY(&cb->info[n], PMIX_DATA_SCOPE)) { cb->scope = cb->info[n].value.data.scope; + } else if (PMIX_CHECK_KEY(&cb->info[n], PMIX_SESSION_INFO)) { + cb->level = PMIX_LEVEL_SESSION; + } else if (PMIX_CHECK_KEY(&cb->info[n], PMIX_JOB_INFO)) { + cb->level = PMIX_LEVEL_JOB; + } else if (PMIX_CHECK_KEY(&cb->info[n], PMIX_APP_INFO)) { + cb->level = PMIX_LEVEL_APP; + } else if (PMIX_CHECK_KEY(&cb->info[n], PMIX_NODE_INFO)) { + cb->level = PMIX_LEVEL_NODE; } } } @@ -604,7 +629,13 @@ static void _getnbfn(int fd, short flags, void *cbdata) /* fetch the data from my server's module - since we are passing * it back to the user, we need a copy of it */ cb->copy = true; - PMIX_GDS_FETCH_KV(rc, pmix_client_globals.myserver, cb); + /* if the peer and server GDS component are the same, then no + * point in trying it again */ + if (0 != strcmp(pmix_globals.mypeer->nptr->compat.gds->name, pmix_client_globals.myserver->nptr->compat.gds->name)) { + PMIX_GDS_FETCH_KV(rc, pmix_client_globals.myserver, cb); + } else { + rc = PMIX_ERR_TAKE_NEXT_OPTION; + } if (PMIX_SUCCESS != rc) { pmix_output_verbose(5, pmix_client_globals.get_output, "pmix:client job-level data NOT found"); @@ -653,7 +684,17 @@ static void _getnbfn(int fd, short flags, void *cbdata) "pmix:client job-level data NOT found"); rc = process_values(&val, cb); goto respond; + } else if (PMIX_RANK_UNDEF == proc.rank) { + /* the data would have to be stored on our own peer, so + * we need to go request it */ + goto request; } else { + /* if the peer and server GDS component are the same, then no + * point in trying it again */ + if (0 == strcmp(pmix_globals.mypeer->nptr->compat.gds->name, pmix_client_globals.myserver->nptr->compat.gds->name)) { + val = NULL; + goto request; + } cb->proc = &proc; cb->copy = true; PMIX_GDS_FETCH_KV(rc, pmix_client_globals.myserver, cb); @@ -722,9 +763,9 @@ static void _getnbfn(int fd, short flags, void *cbdata) } pmix_output_verbose(2, pmix_client_globals.get_output, - "%s:%d REQUESTING DATA FROM SERVER FOR %s:%d KEY %s", - pmix_globals.myid.nspace, pmix_globals.myid.rank, - cb->pname.nspace, cb->pname.rank, cb->key); + "%s REQUESTING DATA FROM SERVER FOR %s KEY %s", + PMIX_NAME_PRINT(&pmix_globals.myid), + PMIX_NAME_PRINT(cb->proc), cb->key); /* track the callback object */ pmix_list_append(&pmix_client_globals.pending_requests, &cb->super); diff --git a/opal/mca/pmix/pmix3x/pmix/src/common/pmix_log.c b/opal/mca/pmix/pmix3x/pmix/src/common/pmix_log.c index 582a64e4ea..0c5aa760fc 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/common/pmix_log.c +++ b/opal/mca/pmix/pmix3x/pmix/src/common/pmix_log.c @@ -1,6 +1,6 @@ /* -*- 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. @@ -82,14 +82,18 @@ PMIX_EXPORT pmix_status_t PMIx_Log(const pmix_info_t data[], size_t ndata, * recv routine so we know which callback to use when * the return message is recvd */ PMIX_CONSTRUCT(&cb, pmix_cb_t); - if (PMIX_SUCCESS != (rc = PMIx_Log_nb(data, ndata, directives, - ndirs, opcbfunc, &cb))) { + rc = PMIx_Log_nb(data, ndata, directives, ndirs, opcbfunc, &cb); + if (PMIX_SUCCESS == rc) { + /* wait for the operation to complete */ + PMIX_WAIT_THREAD(&cb.lock); + } else { PMIX_DESTRUCT(&cb); + if (PMIX_OPERATION_SUCCEEDED == rc) { + rc = PMIX_SUCCESS; + } return rc; } - /* wait for the operation to complete */ - PMIX_WAIT_THREAD(&cb.lock); rc = cb.status; PMIX_DESTRUCT(&cb); diff --git a/opal/mca/pmix/pmix3x/pmix/src/common/pmix_query.c b/opal/mca/pmix/pmix3x/pmix/src/common/pmix_query.c index c40f08b6a0..1f217d18a5 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/common/pmix_query.c +++ b/opal/mca/pmix/pmix3x/pmix/src/common/pmix_query.c @@ -144,6 +144,7 @@ PMIX_EXPORT pmix_status_t PMIx_Query_info_nb(pmix_query_t queries[], size_t nque pmix_list_t results; pmix_kval_t *kv, *kvnxt; pmix_proc_t proc; + bool rank_given; PMIX_ACQUIRE_THREAD(&pmix_global_lock); @@ -190,6 +191,7 @@ PMIX_EXPORT pmix_status_t PMIx_Query_info_nb(pmix_query_t queries[], size_t nque memset(proc.nspace, 0, PMIX_MAX_NSLEN+1); proc.rank = PMIX_RANK_INVALID; for (n=0; n < nqueries; n++) { + rank_given = false; 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])) { @@ -199,37 +201,41 @@ PMIX_EXPORT pmix_status_t PMIx_Query_info_nb(pmix_query_t queries[], size_t nque } else if (PMIX_CHECK_KEY(&queries[n].qualifiers[p], PMIX_PROCID)) { PMIX_LOAD_NSPACE(proc.nspace, queries[n].qualifiers[p].value.data.proc->nspace); proc.rank = queries[n].qualifiers[p].value.data.proc->rank; + rank_given = true; } else if (PMIX_CHECK_KEY(&queries[n].qualifiers[p], PMIX_NSPACE)) { PMIX_LOAD_NSPACE(proc.nspace, queries[n].qualifiers[p].value.data.string); } else if (PMIX_CHECK_KEY(&queries[n].qualifiers[p], PMIX_RANK)) { proc.rank = queries[n].qualifiers[p].value.data.rank; - } else if (PMIX_CHECK_KEY(&queries[n].qualifiers[p], PMIX_HOSTNAME)) { - if (0 != strcmp(queries[n].qualifiers[p].value.data.string, pmix_globals.hostname)) { - /* asking about a different host, so ask for the info */ - PMIX_LIST_DESTRUCT(&results); - goto query; - } + rank_given = true; } } /* we get here if a refresh isn't required - first try a local * "get" on the data to see if we already have it */ PMIX_CONSTRUCT(&cb, pmix_cb_t); cb.copy = false; - /* set the proc */ - if (PMIX_RANK_INVALID == proc.rank && - 0 == strlen(proc.nspace)) { - /* use our id */ - cb.proc = &pmix_globals.myid; - } else { - if (0 == strlen(proc.nspace)) { - /* use our nspace */ - PMIX_LOAD_NSPACE(cb.proc->nspace, pmix_globals.myid.nspace); - } - if (PMIX_RANK_INVALID == proc.rank) { - /* user the wildcard rank */ - proc.rank = PMIX_RANK_WILDCARD; - } + /* if they are querying about node or app values not directly + * associated with a proc (i.e., they didn't specify the proc), + * then we obtain those by leaving the proc info as undefined */ + if (!rank_given) { + proc.rank = PMIX_RANK_UNDEF; cb.proc = &proc; + } else { + /* set the proc */ + if (PMIX_RANK_INVALID == proc.rank && + 0 == strlen(proc.nspace)) { + /* use our id */ + cb.proc = &pmix_globals.myid; + } else { + if (0 == strlen(proc.nspace)) { + /* use our nspace */ + PMIX_LOAD_NSPACE(cb.proc->nspace, pmix_globals.myid.nspace); + } + if (PMIX_RANK_INVALID == proc.rank) { + /* user the wildcard rank */ + proc.rank = PMIX_RANK_WILDCARD; + } + cb.proc = &proc; + } } for (p=0; NULL != queries[n].keys[p]; p++) { cb.key = queries[n].keys[p]; diff --git a/opal/mca/pmix/pmix3x/pmix/src/event/pmix_event_notification.c b/opal/mca/pmix/pmix3x/pmix/src/event/pmix_event_notification.c index 574607ec4b..c667489394 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/event/pmix_event_notification.c +++ b/opal/mca/pmix/pmix3x/pmix/src/event/pmix_event_notification.c @@ -883,7 +883,7 @@ static void _notify_client_event(int sd, short args, void *cbdata) } else { /* look up the nspace for this proc */ nptr = NULL; - PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(tmp, &pmix_globals.nspaces, pmix_namespace_t) { if (PMIX_CHECK_NSPACE(tmp->nspace, cd->targets[n].nspace)) { nptr = tmp; break; diff --git a/opal/mca/pmix/pmix3x/pmix/src/include/pmix_globals.c b/opal/mca/pmix/pmix3x/pmix/src/include/pmix_globals.c index 8959ba5684..df8a6b6e5b 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/include/pmix_globals.c +++ b/opal/mca/pmix/pmix3x/pmix/src/include/pmix_globals.c @@ -306,6 +306,7 @@ static void cbcon(pmix_cb_t *p) PMIX_CONSTRUCT(&p->kvs, pmix_list_t); p->copy = false; p->timer_running = false; + p->level = PMIX_LEVEL_UNDEF; } static void cbdes(pmix_cb_t *p) { @@ -342,6 +343,7 @@ static void qcon(pmix_query_caddy_t *p) p->relcbfunc = NULL; p->credcbfunc = NULL; p->validcbfunc = NULL; + PMIX_CONSTRUCT(&p->results, pmix_list_t); } static void qdes(pmix_query_caddy_t *p) { @@ -349,6 +351,8 @@ 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_QUERY_FREE(p->queries, p->nqueries); } PMIX_EXPORT PMIX_CLASS_INSTANCE(pmix_query_caddy_t, pmix_object_t, @@ -566,3 +570,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/pmix3x/pmix/src/include/pmix_globals.h b/opal/mca/pmix/pmix3x/pmix/src/include/pmix_globals.h index 202679cc4e..113cd48faa 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/include/pmix_globals.h +++ b/opal/mca/pmix/pmix3x/pmix/src/include/pmix_globals.h @@ -122,6 +122,16 @@ typedef enum { PMIX_COLLECT_MAX } pmix_collect_t; +/* define a set of flags indicating the level + * of information being stored/requested */ +typedef enum { + PMIX_LEVEL_UNDEF, + PMIX_LEVEL_SESSION, + PMIX_LEVEL_JOB, + PMIX_LEVEL_APP, + PMIX_LEVEL_NODE +} pmix_level_t; + /**** PEER STRUCTURES ****/ /* clients can only talk to their server, and servers are @@ -268,6 +278,7 @@ typedef struct { pmix_info_t *info; size_t ninfo; pmix_byte_object_t bo; + pmix_list_t results; pmix_info_cbfunc_t cbfunc; pmix_value_cbfunc_t valcbfunc; pmix_release_cbfunc_t relcbfunc; @@ -388,6 +399,7 @@ typedef struct { pmix_list_t kvs; bool copy; bool timer_running; + pmix_level_t level; } pmix_cb_t; PMIX_CLASS_DECLARATION(pmix_cb_t); @@ -481,6 +493,7 @@ typedef struct { bool xml_output; bool timestamp_output; size_t output_limit; + pmix_list_t nspaces; } pmix_globals_t; /* provide access to a function to cleanup epilogs */ diff --git a/opal/mca/pmix/pmix3x/pmix/src/include/types.h b/opal/mca/pmix/pmix3x/pmix/src/include/types.h index cf8d082c34..6b52843ee4 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/include/types.h +++ b/opal/mca/pmix/pmix3x/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,17 @@ #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 +#include + /* * portable assignment of pointer to int @@ -137,6 +145,18 @@ static inline uint64_t pmix_ntoh64(uint64_t val) #endif } +/* Convert size_t value from host to network byte order and back */ +#if SIZEOF_SIZE_T == 4 + +#define pmix_htonsizet(x) htonl(x) +#define pmix_ntohsizet(x) ntohl(x) + +#elif SIZEOF_SIZE_T == 8 + +#define pmix_htonsizet(x) pmix_hton64(x) +#define pmix_ntohsizet(x) pmix_ntoh64(x) + +#endif /** * Convert between a local representation of pointer and a 64 bits value. @@ -225,6 +245,8 @@ static inline uint64_t pmix_swap_bytes8(uint64_t val) #define PMIX_EVLOOP_ONCE EVLOOP_ONCE /**< Block at most once. */ #define PMIX_EVLOOP_NONBLOCK EVLOOP_NONBLOCK /**< Do not block. */ +#define PMIX_EVENT_SIGNAL(ev) pmix_event_get_signal(ev) + typedef struct event_base pmix_event_base_t; typedef struct event pmix_event_t; @@ -232,42 +254,52 @@ 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_loopexit (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_loopexit(b) event_base_loopexit(b, NULL) +#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/pmix3x/pmix/src/mca/base/pmix_mca_base_component_find.c b/opal/mca/pmix/pmix3x/pmix/src/mca/base/pmix_mca_base_component_find.c index fed38f988f..7d96e21c36 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/base/pmix_mca_base_component_find.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/base/pmix_mca_base_component_find.c @@ -16,7 +16,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2014-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 @@ -339,8 +339,8 @@ static int component_find_check (pmix_mca_base_framework_t *framework, char **re } if (!found) { - char h[MAXHOSTNAMELEN]; - gethostname(h, sizeof(h)); + char h[PMIX_MAXHOSTNAMELEN] = {0}; + gethostname(h, sizeof(h)-1); pmix_show_help("help-pmix-mca-base.txt", "find-available:not-valid", true, h, framework->framework_name, requested_component_names[i]); diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/base/pmix_mca_base_open.c b/opal/mca/pmix/pmix3x/pmix/src/mca/base/pmix_mca_base_open.c index f152f2c2a9..fbb55dcb35 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/base/pmix_mca_base_open.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/base/pmix_mca_base_open.c @@ -13,7 +13,7 @@ * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -68,7 +68,7 @@ int pmix_mca_base_open(void) { char *value; pmix_output_stream_t lds; - char hostname[64]; + char hostname[PMIX_MAXHOSTNAMELEN] = {0}; int var_id; int rc; @@ -155,7 +155,7 @@ int pmix_mca_base_open(void) } else { set_defaults(&lds); } - gethostname(hostname, 64); + gethostname(hostname, PMIX_MAXHOSTNAMELEN-1); rc = asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid()); if (0 > rc) { return PMIX_ERR_OUT_OF_RESOURCE; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/bfrops/v20/copy.c b/opal/mca/pmix/pmix3x/pmix/src/mca/bfrops/v20/copy.c index 06720cf32e..fbdbae3eff 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/bfrops/v20/copy.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/bfrops/v20/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 (c) 2016 IBM Corporation. All rights reserved. @@ -431,10 +431,15 @@ pmix_status_t pmix20_bfrop_value_xfer(pmix_value_t *p, const pmix_value_t *src) memcpy(&p->data.status, &src->data.status, sizeof(pmix_status_t)); break; case PMIX_PROC: - memcpy(&p->data.proc, &src->data.proc, sizeof(pmix_proc_t)); + /* create the storage */ + p->data.proc = (pmix_proc_t*)malloc(sizeof(pmix_proc_t)); + if (NULL == p->data.proc) { + return PMIX_ERR_NOMEM; + } + memcpy(p->data.proc, src->data.proc, sizeof(pmix_proc_t)); break; case PMIX_PROC_RANK: - memcpy(&p->data.proc, &src->data.rank, sizeof(pmix_rank_t)); + memcpy(&p->data.rank, &src->data.rank, sizeof(pmix_rank_t)); break; case PMIX_BYTE_OBJECT: case PMIX_COMPRESSED_STRING: @@ -653,7 +658,12 @@ pmix_status_t pmix20_bfrop_value_xfer(pmix_value_t *p, const pmix_value_t *src) p1 = (pmix_info_t*)p->data.darray->array; s1 = (pmix_info_t*)src->data.darray->array; for (n=0; n < src->data.darray->size; n++) { - PMIX_INFO_LOAD(&p1[n], s1[n].key, &s1[n].value.data.flag, s1[n].value.type); + PMIX_LOAD_KEY(p1[n].key, s1[n].key); + rc = pmix_value_xfer(&p1[n].value, &s1[n].value); + if (PMIX_SUCCESS != rc) { + PMIX_INFO_FREE(p1, src->data.darray->size); + return rc; + } } break; case PMIX_PDATA: @@ -664,7 +674,13 @@ pmix_status_t pmix20_bfrop_value_xfer(pmix_value_t *p, const pmix_value_t *src) pd = (pmix_pdata_t*)p->data.darray->array; sd = (pmix_pdata_t*)src->data.darray->array; for (n=0; n < src->data.darray->size; n++) { - PMIX_PDATA_LOAD(&pd[n], &sd[n].proc, sd[n].key, &sd[n].value.data.flag, sd[n].value.type); + memcpy(&pd[n].proc, &sd[n].proc, sizeof(pmix_proc_t)); + PMIX_LOAD_KEY(pd[n].key, sd[n].key); + rc = pmix_value_xfer(&pd[n].value, &sd[n].value); + if (PMIX_SUCCESS != rc) { + PMIX_INFO_FREE(pd, src->data.darray->size); + return rc; + } } break; case PMIX_BUFFER: diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/common/dstore/dstore_segment.c b/opal/mca/pmix/pmix3x/pmix/src/mca/common/dstore/dstore_segment.c index a219bed9c0..69ec1ba577 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/common/dstore/dstore_segment.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/common/dstore/dstore_segment.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 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/pmix3x/pmix/src/mca/gds/hash/gds_hash.c b/opal/mca/pmix/pmix3x/pmix/src/mca/gds/hash/gds_hash.c index 4e092fc5a6..5e6a5341bd 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/gds/hash/gds_hash.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/gds/hash/gds_hash.c @@ -38,11 +38,12 @@ #include "src/server/pmix_server_ops.h" #include "src/util/argv.h" #include "src/util/compress.h" +#include "src/mca/preg/preg.h" #include "src/util/error.h" #include "src/util/hash.h" #include "src/util/output.h" +#include "src/util/name_fns.h" #include "src/util/pmix_environ.h" -#include "src/mca/preg/preg.h" #include "src/mca/gds/base/base.h" #include "gds_hash.h" @@ -115,6 +116,24 @@ pmix_gds_base_module_t pmix_hash_module = { .accept_kvs_resp = accept_kvs_resp }; +/* Define a bitmask to track what information may not have + * been provided but is computable from other info */ +#define PMIX_HASH_PROC_DATA 0x00000001 +#define PMIX_HASH_JOB_SIZE 0x00000002 +#define PMIX_HASH_MAX_PROCS 0x00000004 +#define PMIX_HASH_NUM_NODES 0x00000008 +#define PMIX_HASH_PROC_MAP 0x00000010 +#define PMIX_HASH_NODE_MAP 0x00000020 + +/**********************************************/ +/* struct definitions */ +typedef struct { + pmix_list_item_t super; + uint32_t session; + pmix_list_t sessioninfo; + pmix_list_t nodeinfo; +} pmix_session_t; + typedef struct { pmix_list_item_t super; char *ns; @@ -123,12 +142,49 @@ typedef struct { pmix_hash_table_t remote; pmix_hash_table_t local; bool gdata_added; -} pmix_hash_trkr_t; + pmix_list_t jobinfo; + pmix_list_t apps; + pmix_list_t nodeinfo; + pmix_session_t *session; +} pmix_job_t; -static void htcon(pmix_hash_trkr_t *p) +typedef struct { + pmix_list_item_t super; + uint32_t appnum; + pmix_list_t appinfo; + pmix_list_t nodeinfo; + pmix_job_t *job; +} pmix_apptrkr_t; + +typedef struct { + pmix_list_item_t super; + uint32_t nodeid; + char *hostname; + pmix_list_t info; +} pmix_nodeinfo_t; + +/**********************************************/ +/* class instantiations */ +static void scon(pmix_session_t *s) +{ + s->session = UINT32_MAX; + PMIX_CONSTRUCT(&s->sessioninfo, pmix_list_t); + PMIX_CONSTRUCT(&s->nodeinfo, pmix_list_t); +} +static void sdes(pmix_session_t *s) +{ + PMIX_LIST_DESTRUCT(&s->sessioninfo); + PMIX_LIST_DESTRUCT(&s->nodeinfo); +} +static PMIX_CLASS_INSTANCE(pmix_session_t, + pmix_list_item_t, + scon, sdes); + +static void htcon(pmix_job_t *p) { p->ns = NULL; p->nptr = NULL; + PMIX_CONSTRUCT(&p->jobinfo, pmix_list_t); PMIX_CONSTRUCT(&p->internal, pmix_hash_table_t); pmix_hash_table_init(&p->internal, 256); PMIX_CONSTRUCT(&p->remote, pmix_hash_table_t); @@ -136,8 +192,11 @@ static void htcon(pmix_hash_trkr_t *p) PMIX_CONSTRUCT(&p->local, pmix_hash_table_t); pmix_hash_table_init(&p->local, 256); p->gdata_added = false; + PMIX_CONSTRUCT(&p->apps, pmix_list_t); + PMIX_CONSTRUCT(&p->nodeinfo, pmix_list_t); + p->session = NULL; } -static void htdes(pmix_hash_trkr_t *p) +static void htdes(pmix_job_t *p) { if (NULL != p->ns) { free(p->ns); @@ -145,25 +204,411 @@ static void htdes(pmix_hash_trkr_t *p) if (NULL != p->nptr) { PMIX_RELEASE(p->nptr); } + PMIX_LIST_DESTRUCT(&p->jobinfo); pmix_hash_remove_data(&p->internal, PMIX_RANK_WILDCARD, NULL); PMIX_DESTRUCT(&p->internal); pmix_hash_remove_data(&p->remote, PMIX_RANK_WILDCARD, NULL); PMIX_DESTRUCT(&p->remote); pmix_hash_remove_data(&p->local, PMIX_RANK_WILDCARD, NULL); PMIX_DESTRUCT(&p->local); + PMIX_LIST_DESTRUCT(&p->apps); + PMIX_LIST_DESTRUCT(&p->nodeinfo); + if (NULL != p->session) { + PMIX_RELEASE(p->session); + } } -static PMIX_CLASS_INSTANCE(pmix_hash_trkr_t, +static PMIX_CLASS_INSTANCE(pmix_job_t, pmix_list_item_t, htcon, htdes); -static pmix_list_t myhashes; +static void apcon(pmix_apptrkr_t *p) +{ + p->appnum = 0; + PMIX_CONSTRUCT(&p->appinfo, pmix_list_t); + PMIX_CONSTRUCT(&p->nodeinfo, pmix_list_t); + p->job = NULL; +} +static void apdes(pmix_apptrkr_t *p) +{ + PMIX_LIST_DESTRUCT(&p->appinfo); + PMIX_LIST_DESTRUCT(&p->nodeinfo); + if (NULL != p->job) { + PMIX_RELEASE(p->job); + } +} +static PMIX_CLASS_INSTANCE(pmix_apptrkr_t, + pmix_list_item_t, + apcon, apdes); + +static void ndinfocon(pmix_nodeinfo_t *p) +{ + p->nodeid = 0; + p->hostname = NULL; + PMIX_CONSTRUCT(&p->info, pmix_list_t); +} +static void ndinfodes(pmix_nodeinfo_t *p) +{ + if (NULL != p->hostname) { + free(p->hostname); + } + PMIX_LIST_DESTRUCT(&p->info); +} +static PMIX_CLASS_INSTANCE(pmix_nodeinfo_t, + pmix_list_item_t, + ndinfocon, ndinfodes); + +/**********************************************/ + +/* process a node array - contains an array of + * node-level info for a single node. Either the + * nodeid, hostname, or both must be included + * in the array to identify the node */ +static pmix_status_t process_node_array(pmix_info_t *info, + pmix_list_t *tgt) +{ + size_t size, j; + pmix_info_t *iptr; + pmix_status_t rc = PMIX_SUCCESS; + pmix_kval_t *kp2, *k1, *knext; + pmix_list_t cache; + pmix_nodeinfo_t *nd = NULL, *ndptr; + bool update; + + pmix_output_verbose(2, pmix_gds_base_framework.framework_output, + "PROCESSING NODE ARRAY"); + + /* array of node-level info for a specific node */ + if (PMIX_DATA_ARRAY != info->value.type) { + PMIX_ERROR_LOG(PMIX_ERR_TYPE_MISMATCH); + return PMIX_ERR_TYPE_MISMATCH; + } + + /* setup arrays */ + size = info->value.data.darray->size; + iptr = (pmix_info_t*)info->value.data.darray->array; + PMIX_CONSTRUCT(&cache, pmix_list_t); + + /* cache the values while searching for the nodeid + * and/or hostname */ + for (j=0; j < size; j++) { + if (PMIX_CHECK_KEY(&iptr[j], PMIX_NODEID)) { + if (NULL == nd) { + nd = PMIX_NEW(pmix_nodeinfo_t); + } + PMIX_VALUE_GET_NUMBER(rc, &iptr[j].value, nd->nodeid, uint32_t); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(nd); + PMIX_LIST_DESTRUCT(&cache); + return rc; + } + } else if (PMIX_CHECK_KEY(&iptr[j], PMIX_HOSTNAME)) { + if (NULL == nd) { + nd = PMIX_NEW(pmix_nodeinfo_t); + } + nd->hostname = strdup(iptr[j].value.data.string); + } else { + kp2 = PMIX_NEW(pmix_kval_t); + kp2->key = strdup(iptr[j].key); + kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + PMIX_VALUE_XFER(rc, kp2->value, &iptr[j].value); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + if (NULL != nd) { + PMIX_RELEASE(nd); + } + PMIX_LIST_DESTRUCT(&cache); + return rc; + } + pmix_list_append(&cache, &kp2->super); + } + } + + if (NULL == nd) { + /* they forgot to pass us the ident for the node */ + PMIX_LIST_DESTRUCT(&cache); + return PMIX_ERR_BAD_PARAM; + } + + /* see if we already have this node on the + * provided list */ + update = false; + PMIX_LIST_FOREACH(ndptr, tgt, pmix_nodeinfo_t) { + if (ndptr->nodeid == nd->nodeid || + (NULL != ndptr->hostname && NULL != nd->hostname && 0 == strcmp(ndptr->hostname, nd->hostname))) { + /* we assume that the data is updating the current + * values */ + if (NULL == ndptr->hostname && NULL != nd->hostname) { + ndptr->hostname = strdup(nd->hostname); + } + PMIX_RELEASE(nd); + nd = ndptr; + update = true; + break; + } + } + + /* transfer the cached items to the nodeinfo list */ + kp2 = (pmix_kval_t*)pmix_list_remove_first(&cache); + while (NULL != kp2) { + /* if this is an update, we have to ensure each data + * item only appears once on the list */ + if (update) { + PMIX_LIST_FOREACH_SAFE(k1, knext, &nd->info, pmix_kval_t) { + if (PMIX_CHECK_KEY(k1, kp2->key)) { + pmix_list_remove_item(&nd->info, &k1->super); + PMIX_RELEASE(k1); + break; + } + } + } + pmix_list_append(&nd->info, &kp2->super); + kp2 = (pmix_kval_t*)pmix_list_remove_first(&cache); + } + PMIX_LIST_DESTRUCT(&cache); + + pmix_list_append(tgt, &nd->super); + return PMIX_SUCCESS; +} + +/* process an app array - contains an array of + * app-level info for a single app. If the + * appnum is not included in the array, then + * it is assumed that only app is in the job. + * This assumption is checked and generates + * an error if violated */ +static pmix_status_t process_app_array(pmix_info_t *info, + pmix_job_t *trk) +{ + pmix_list_t cache, ncache; + size_t size, j; + pmix_info_t *iptr; + pmix_status_t rc = PMIX_SUCCESS; + uint32_t appnum; + pmix_apptrkr_t *app = NULL, *apptr; + pmix_kval_t *kp2, *k1, *knext; + pmix_nodeinfo_t *nd; + bool update; + + pmix_output_verbose(2, pmix_gds_base_framework.framework_output, + "PROCESSING APP ARRAY"); + + /* apps have to belong to a job */ + if (NULL == trk) { + return PMIX_ERR_BAD_PARAM; + } + + /* array of app-level info */ + if (PMIX_DATA_ARRAY != info->value.type) { + PMIX_ERROR_LOG(PMIX_ERR_TYPE_MISMATCH); + return PMIX_ERR_TYPE_MISMATCH; + } + + /* setup arrays and lists */ + PMIX_CONSTRUCT(&cache, pmix_list_t); + PMIX_CONSTRUCT(&ncache, pmix_list_t); + size = info->value.data.darray->size; + iptr = (pmix_info_t*)info->value.data.darray->array; + + for (j=0; j < size; j++) { + if (PMIX_CHECK_KEY(&iptr[j], PMIX_APPNUM)) { + PMIX_VALUE_GET_NUMBER(rc, &iptr[j].value, appnum, uint32_t); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + goto release; + } + if (NULL != app) { + /* this is an error - there can be only one app + * described in this array */ + PMIX_RELEASE(app); + PMIX_LIST_DESTRUCT(&cache); + PMIX_LIST_DESTRUCT(&ncache); + return PMIX_ERR_BAD_PARAM; + } + app = PMIX_NEW(pmix_apptrkr_t); + app->appnum = appnum; + } else if (PMIX_CHECK_KEY(&iptr[j], PMIX_NODE_INFO_ARRAY)) { + if (PMIX_SUCCESS != (rc = process_node_array(&iptr[j], &ncache))) { + PMIX_ERROR_LOG(rc); + goto release; + } + } else { + kp2 = PMIX_NEW(pmix_kval_t); + kp2->key = strdup(iptr[j].key); + kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + PMIX_VALUE_XFER(rc, kp2->value, &iptr[j].value); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + goto release; + } + pmix_list_append(&cache, &kp2->super); + } + } + if (NULL == app) { + /* per the standard, they don't have to provide us with + * an appnum so long as only one app is in the job */ + if (0 == pmix_list_get_size(&trk->apps)) { + app = PMIX_NEW(pmix_apptrkr_t); + } else { + /* this is not allowed to happen - they are required + * to provide us with an app number per the standard */ + rc = PMIX_ERR_BAD_PARAM; + PMIX_ERROR_LOG(rc); + goto release; + } + } + /* see if we already have this app on the + * provided list */ + update = false; + PMIX_LIST_FOREACH(apptr, &trk->apps, pmix_apptrkr_t) { + if (apptr->appnum == app->appnum) { + /* we assume that the data is updating the current + * values */ + PMIX_RELEASE(app); + app = apptr; + update = true; + break; + } + } + + /* point the app at its job */ + if (NULL == app->job) { + PMIX_RETAIN(trk); + app->job = trk; + } + + /* transfer the app-level data across */ + kp2 = (pmix_kval_t*)pmix_list_remove_first(&cache); + while (NULL != kp2) { + /* if this is an update, we have to ensure each data + * item only appears once on the list */ + if (update) { + PMIX_LIST_FOREACH_SAFE(k1, knext, &app->appinfo, pmix_kval_t) { + if (PMIX_CHECK_KEY(k1, kp2->key)) { + pmix_list_remove_item(&app->appinfo, &k1->super); + PMIX_RELEASE(k1); + break; + } + } + } + pmix_list_append(&app->appinfo, &kp2->super); + kp2 = (pmix_kval_t*)pmix_list_remove_first(&cache); + } + /* transfer the associated node-level data across */ + nd = (pmix_nodeinfo_t*)pmix_list_remove_first(&ncache); + while (NULL != nd) { + pmix_list_append(&app->nodeinfo, &nd->super); + nd = (pmix_nodeinfo_t*)pmix_list_remove_first(&ncache); + } + + release: + PMIX_LIST_DESTRUCT(&cache); + PMIX_LIST_DESTRUCT(&ncache); + + return rc; +} + +/* process a job array */ +static pmix_status_t process_job_array(pmix_info_t *info, + pmix_job_t *trk, + uint32_t *flags, + char ***procs, + char ***nodes) +{ + pmix_list_t cache; + size_t j, size; + pmix_info_t *iptr; + pmix_kval_t *kp2; + pmix_status_t rc; + + pmix_output_verbose(2, pmix_gds_base_framework.framework_output, + "PROCESSING JOB ARRAY"); + + /* array of job-level info */ + if (PMIX_DATA_ARRAY != info->value.type) { + PMIX_ERROR_LOG(PMIX_ERR_TYPE_MISMATCH); + return PMIX_ERR_TYPE_MISMATCH; + } + size = info->value.data.darray->size; + iptr = (pmix_info_t*)info->value.data.darray->array; + PMIX_CONSTRUCT(&cache, pmix_list_t); + for (j=0; j < size; j++) { + if (PMIX_CHECK_KEY(&iptr[j], PMIX_APP_INFO_ARRAY)) { + if (PMIX_SUCCESS != (rc = process_app_array(&iptr[j], trk))) { + return rc; + } + } else if (PMIX_CHECK_KEY(&iptr[j], PMIX_NODE_INFO_ARRAY)) { + if (PMIX_SUCCESS != (rc = process_node_array(&iptr[j], &trk->nodeinfo))) { + PMIX_ERROR_LOG(rc); + return rc; + } + } else if (PMIX_CHECK_KEY(&iptr[j], PMIX_PROC_MAP)) { + /* not allowed to get this more than once */ + if (*flags & PMIX_HASH_PROC_MAP) { + PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); + return PMIX_ERR_BAD_PARAM; + } + /* parse the regex to get the argv array containing proc ranks on each node */ + if (PMIX_SUCCESS != (rc = pmix_preg.parse_procs(iptr[j].value.data.string, procs))) { + PMIX_ERROR_LOG(rc); + return rc; + } + /* mark that we got the map */ + *flags |= PMIX_HASH_PROC_MAP; + } else if (PMIX_CHECK_KEY(&iptr[j], PMIX_NODE_MAP)) { + /* not allowed to get this more than once */ + if (*flags & PMIX_HASH_NODE_MAP) { + PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); + return PMIX_ERR_BAD_PARAM; + } + /* store the node map itself since that is + * what v3 uses */ + kp2 = PMIX_NEW(pmix_kval_t); + kp2->key = strdup(PMIX_NODE_MAP); + kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + kp2->value->type = PMIX_STRING; + kp2->value->data.string = strdup(iptr[j].value.data.string); + if (PMIX_SUCCESS != (rc = pmix_hash_store(&trk->internal, PMIX_RANK_WILDCARD, kp2))) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + return rc; + } + PMIX_RELEASE(kp2); // maintain acctg + + /* parse the regex to get the argv array of node names */ + if (PMIX_SUCCESS != (rc = pmix_preg.parse_nodes(iptr[j].value.data.string, nodes))) { + PMIX_ERROR_LOG(rc); + return rc; + } + /* mark that we got the map */ + *flags |= PMIX_HASH_NODE_MAP; + } else { + kp2 = PMIX_NEW(pmix_kval_t); + kp2->key = strdup(iptr[j].key); + kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + PMIX_VALUE_XFER(rc, kp2->value, &iptr[j].value); + if (PMIX_SUCCESS != rc) { + PMIX_RELEASE(kp2); + PMIX_LIST_DESTRUCT(&cache); + return rc; + } + pmix_list_append(&trk->jobinfo, &kp2->super); + } + } + return PMIX_SUCCESS; +} + +static pmix_list_t mysessions, myjobs; static pmix_status_t hash_init(pmix_info_t info[], size_t ninfo) { pmix_output_verbose(2, pmix_gds_base_framework.framework_output, "gds: hash init"); - PMIX_CONSTRUCT(&myhashes, pmix_list_t); + PMIX_CONSTRUCT(&mysessions, pmix_list_t); + PMIX_CONSTRUCT(&myjobs, pmix_list_t); return PMIX_SUCCESS; } @@ -172,7 +617,8 @@ static void hash_finalize(void) pmix_output_verbose(2, pmix_gds_base_framework.framework_output, "gds: hash finalize"); - PMIX_LIST_DESTRUCT(&myhashes); + PMIX_LIST_DESTRUCT(&mysessions); + PMIX_LIST_DESTRUCT(&myjobs); } static pmix_status_t hash_assign_module(pmix_info_t *info, size_t ninfo, @@ -201,13 +647,6 @@ static pmix_status_t hash_assign_module(pmix_info_t *info, size_t ninfo, return PMIX_SUCCESS; } -/* Define a bitmask to track what information may not have - * been provided but is computable from other info */ -#define PMIX_HASH_PROC_DATA 0x00000001 -#define PMIX_HASH_JOB_SIZE 0x00000002 -#define PMIX_HASH_MAX_PROCS 0x00000004 -#define PMIX_HASH_NUM_NODES 0x00000008 - static pmix_status_t store_map(pmix_hash_table_t *ht, char **nodes, char **ppn, uint32_t flags) @@ -496,16 +935,20 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns, pmix_info_t info[], size_t ninfo) { pmix_namespace_t *nptr = (pmix_namespace_t*)ns; - pmix_hash_trkr_t *trk, *t; + pmix_job_t *trk, *t; + pmix_session_t *s = NULL, *sptr; pmix_hash_table_t *ht; pmix_kval_t *kp2, *kvptr; pmix_info_t *iptr; char **nodes=NULL, **procs=NULL; uint8_t *tmp; + uint32_t sid=UINT32_MAX; pmix_rank_t rank; pmix_status_t rc=PMIX_SUCCESS; size_t n, j, size, len; uint32_t flags = 0; + pmix_list_t cache, ncache; + pmix_nodeinfo_t *nd; pmix_output_verbose(2, pmix_gds_base_framework.framework_output, "[%s:%d] gds:hash:cache_job_info for nspace %s", @@ -514,7 +957,7 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns, /* find the hash table for this nspace */ trk = NULL; - PMIX_LIST_FOREACH(t, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(t, &myjobs, pmix_job_t) { if (0 == strcmp(nptr->nspace, t->ns)) { trk = t; break; @@ -522,14 +965,14 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns, } if (NULL == trk) { /* create a tracker as we will likely need it */ - trk = PMIX_NEW(pmix_hash_trkr_t); + trk = PMIX_NEW(pmix_job_t); if (NULL == trk) { return PMIX_ERR_NOMEM; } PMIX_RETAIN(nptr); trk->nptr = nptr; trk->ns = strdup(nptr->nspace); - pmix_list_append(&myhashes, &trk->super); + pmix_list_append(&myjobs, &trk->super); } /* if there isn't any data, then be content with just @@ -541,7 +984,141 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns, /* cache the job info on the internal hash table for this nspace */ ht = &trk->internal; for (n=0; n < ninfo; n++) { - if (0 == strcmp(info[n].key, PMIX_NODE_MAP)) { + if (PMIX_CHECK_KEY(&info[n], PMIX_SESSION_ID)) { + PMIX_VALUE_GET_NUMBER(rc, &info[n].value, sid, uint32_t); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + goto release; + } + /* see if we have this session */ + s = NULL; + PMIX_LIST_FOREACH(sptr, &mysessions, pmix_session_t) { + if (sptr->session == sid) { + s = sptr; + break; + } + } + if (NULL == s) { + s = PMIX_NEW(pmix_session_t); + s->session = sid; + pmix_list_append(&mysessions, &s->super); + } + /* point the job at it */ + if (NULL == trk->session) { + PMIX_RETAIN(s); + trk->session = s; + } + } else if (PMIX_CHECK_KEY(&info[n], PMIX_SESSION_INFO_ARRAY)) { + /* array of session-level info */ + if (PMIX_DATA_ARRAY != info[n].value.type) { + PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); + rc = PMIX_ERR_TYPE_MISMATCH; + goto release; + } + size = info[n].value.data.darray->size; + iptr = (pmix_info_t*)info[n].value.data.darray->array; + PMIX_CONSTRUCT(&cache, pmix_list_t); + PMIX_CONSTRUCT(&ncache, pmix_list_t); + for (j=0; j < size; j++) { + if (PMIX_CHECK_KEY(&iptr[j], PMIX_SESSION_ID)) { + PMIX_VALUE_GET_NUMBER(rc, &iptr[j].value, sid, uint32_t); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_LIST_DESTRUCT(&cache); + return rc; + } + /* setup a session object */ + if (NULL != s) { + /* does this match the one we were previously given? */ + if (sid != s->session) { + /* no - see if we already have this session */ + PMIX_LIST_FOREACH(sptr, &mysessions, pmix_session_t) { + if (sptr->session == sid) { + s = sptr; + break; + } + } + if (sid != s->session) { + /* wasn't found, so create one */ + s = PMIX_NEW(pmix_session_t); + s->session = sid; + pmix_list_append(&mysessions, &s->super); + } + } + } else { + s = PMIX_NEW(pmix_session_t); + s->session = sid; + pmix_list_append(&mysessions, &s->super); + } + } else if (PMIX_CHECK_KEY(&iptr[j], PMIX_NODE_INFO_ARRAY)) { + if (PMIX_SUCCESS != (rc = process_node_array(&iptr[j], &ncache))) { + PMIX_ERROR_LOG(rc); + PMIX_LIST_DESTRUCT(&cache); + PMIX_LIST_DESTRUCT(&ncache); + goto release; + } + } else { + kp2 = PMIX_NEW(pmix_kval_t); + kp2->key = strdup(iptr[j].key); + kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + PMIX_VALUE_XFER(rc, kp2->value, &iptr[j].value); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + PMIX_LIST_DESTRUCT(&cache); + PMIX_LIST_DESTRUCT(&ncache); + goto release; + } + pmix_list_append(&cache, &kp2->super); + } + } + if (NULL == s) { + /* this is not allowed to happen - they are required + * to provide us with a session ID per the standard */ + PMIX_LIST_DESTRUCT(&cache); + rc = PMIX_ERR_BAD_PARAM; + PMIX_ERROR_LOG(rc); + goto release; + } + /* point the job at it */ + if (NULL == trk->session) { + PMIX_RETAIN(s); + trk->session = s; + } + /* transfer the data across */ + kp2 = (pmix_kval_t*)pmix_list_remove_first(&cache); + while (NULL != kp2) { + pmix_list_append(&s->sessioninfo, &kp2->super); + kp2 = (pmix_kval_t*)pmix_list_remove_first(&cache); + } + PMIX_LIST_DESTRUCT(&cache); + nd = (pmix_nodeinfo_t*)pmix_list_remove_first(&ncache); + while (NULL != nd) { + pmix_list_append(&s->nodeinfo, &nd->super); + nd = (pmix_nodeinfo_t*)pmix_list_remove_first(&ncache); + } + PMIX_LIST_DESTRUCT(&ncache); + } else if (PMIX_CHECK_KEY(&info[n], PMIX_JOB_INFO_ARRAY)) { + if (PMIX_SUCCESS != (rc = process_job_array(&info[n], trk, &flags, &procs, &nodes))) { + PMIX_ERROR_LOG(rc); + goto release; + } + } else if (PMIX_CHECK_KEY(&info[n], PMIX_APP_INFO_ARRAY)) { + if (PMIX_SUCCESS != (rc = process_app_array(&info[n], trk))) { + PMIX_ERROR_LOG(rc); + goto release; + } + } else if (PMIX_CHECK_KEY(&info[n], PMIX_NODE_INFO_ARRAY)) { + if (PMIX_SUCCESS != (rc = process_node_array(&info[n], &trk->nodeinfo))) { + PMIX_ERROR_LOG(rc); + goto release; + } + } else if (PMIX_CHECK_KEY(&info[n], PMIX_NODE_MAP)) { + /* not allowed to get this more than once */ + if (flags & PMIX_HASH_NODE_MAP) { + PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); + return PMIX_ERR_BAD_PARAM; + } /* store the node map itself since that is * what v3 uses */ kp2 = PMIX_NEW(pmix_kval_t); @@ -561,12 +1138,21 @@ pmix_status_t hash_cache_job_info(struct pmix_namespace_t *ns, PMIX_ERROR_LOG(rc); goto release; } - } else if (0 == strcmp(info[n].key, PMIX_PROC_MAP)) { + /* mark that we got the map */ + flags |= PMIX_HASH_NODE_MAP; + } else if (PMIX_CHECK_KEY(&info[n], PMIX_PROC_MAP)) { + /* not allowed to get this more than once */ + if (flags & PMIX_HASH_PROC_MAP) { + PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); + return PMIX_ERR_BAD_PARAM; + } /* parse the regex to get the argv array containing proc ranks on each node */ if (PMIX_SUCCESS != (rc = pmix_preg.parse_procs(info[n].value.data.string, &procs))) { PMIX_ERROR_LOG(rc); goto release; } + /* mark that we got the map */ + flags |= PMIX_HASH_PROC_MAP; } else if (0 == strcmp(info[n].key, PMIX_PROC_DATA)) { flags |= PMIX_HASH_PROC_DATA; /* an array of data pertaining to a specific proc */ @@ -723,18 +1309,18 @@ static pmix_status_t register_info(pmix_peer_t *peer, pmix_namespace_t *ns, pmix_buffer_t *reply) { - pmix_hash_trkr_t *trk, *t; + pmix_job_t *trk, *t; pmix_hash_table_t *ht; pmix_value_t *val, blob; pmix_status_t rc = PMIX_SUCCESS; pmix_info_t *info; size_t ninfo, n; - pmix_kval_t kv; + pmix_kval_t kv, *kvptr; pmix_buffer_t buf; pmix_rank_t rank; trk = NULL; - PMIX_LIST_FOREACH(t, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(t, &myjobs, pmix_job_t) { if (0 == strcmp(ns->nspace, t->ns)) { trk = t; break; @@ -773,6 +1359,12 @@ static pmix_status_t register_info(pmix_peer_t *peer, PMIX_VALUE_RELEASE(val); } + /* add all values in the jobinfo list */ + PMIX_LIST_FOREACH(kvptr, &trk->jobinfo, pmix_kval_t) { + PMIX_BFROPS_PACK(rc, peer, reply, kvptr, 1, PMIX_KVAL); + } + + /* get the proc-level data for each proc in the job */ for (rank=0; rank < ns->nprocs; rank++) { val = NULL; rc = pmix_hash_fetch(ht, rank, NULL, &val); @@ -820,7 +1412,7 @@ static pmix_status_t hash_register_job_info(struct pmix_peer_t *pr, pmix_namespace_t *ns = peer->nptr; char *msg; pmix_status_t rc; - pmix_hash_trkr_t *trk, *t2; + pmix_job_t *trk, *t2; if (!PMIX_PROC_IS_SERVER(pmix_globals.mypeer) && !PMIX_PROC_IS_LAUNCHER(pmix_globals.mypeer)) { @@ -857,7 +1449,7 @@ static pmix_status_t hash_register_job_info(struct pmix_peer_t *pr, /* setup a tracker for this nspace as we will likely * need it again */ trk = NULL; - PMIX_LIST_FOREACH(t2, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(t2, &myjobs, pmix_job_t) { if (ns == t2->nptr) { trk = t2; if (NULL == trk->ns) { @@ -867,11 +1459,11 @@ static pmix_status_t hash_register_job_info(struct pmix_peer_t *pr, } } if (NULL == trk) { - trk = PMIX_NEW(pmix_hash_trkr_t); + trk = PMIX_NEW(pmix_job_t); trk->ns = strdup(ns->nspace); PMIX_RETAIN(ns); trk->nptr = ns; - pmix_list_append(&myhashes, &trk->super); + pmix_list_append(&myjobs, &trk->super); } /* the job info for the specified nspace has @@ -914,10 +1506,11 @@ static pmix_status_t hash_store_job_info(const char *nspace, pmix_byte_object_t *bo; pmix_buffer_t buf2; int rank; - pmix_hash_trkr_t *htptr; + pmix_job_t *htptr; pmix_hash_table_t *ht; char **nodelist = NULL; pmix_info_t *info, *iptr; + pmix_namespace_t *ns, *nptr; pmix_output_verbose(2, pmix_gds_base_framework.framework_output, "[%s:%u] pmix:gds:hash store job info for nspace %s", @@ -937,9 +1530,27 @@ static pmix_status_t hash_store_job_info(const char *nspace, return rc; } + /* see if we already have this nspace */ + nptr = NULL; + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { + if (0 == strcmp(ns->nspace, nspace)) { + nptr = ns; + break; + } + } + if (NULL == nptr) { + nptr = PMIX_NEW(pmix_namespace_t); + if (NULL == nptr) { + rc = PMIX_ERR_NOMEM; + return rc; + } + nptr->nspace = strdup(nspace); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); + } + /* see if we already have a hash table for this nspace */ ht = NULL; - PMIX_LIST_FOREACH(htptr, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(htptr, &myjobs, pmix_job_t) { if (0 == strcmp(htptr->ns, nspace)) { ht = &htptr->internal; break; @@ -947,9 +1558,11 @@ static pmix_status_t hash_store_job_info(const char *nspace, } if (NULL == ht) { /* nope - create one */ - htptr = PMIX_NEW(pmix_hash_trkr_t); + htptr = PMIX_NEW(pmix_job_t); htptr->ns = strdup(nspace); - pmix_list_append(&myhashes, &htptr->super); + PMIX_RETAIN(nptr); + htptr->nptr = nptr; + pmix_list_append(&myjobs, &htptr->super); ht = &htptr->internal; } @@ -961,7 +1574,7 @@ static pmix_status_t hash_store_job_info(const char *nspace, pmix_output_verbose(2, pmix_gds_base_framework.framework_output, "[%s:%u] pmix:gds:hash store job info working key %s", pmix_globals.myid.nspace, pmix_globals.myid.rank, kptr->key); - if (0 == strcmp(kptr->key, PMIX_PROC_BLOB)) { + if (PMIX_CHECK_KEY(kptr, PMIX_PROC_BLOB)) { bo = &(kptr->value->data.bo); PMIX_CONSTRUCT(&buf2, pmix_buffer_t); PMIX_LOAD_BUFFER(pmix_client_globals.myserver, &buf2, bo->bytes, bo->size); @@ -1012,7 +1625,7 @@ static pmix_status_t hash_store_job_info(const char *nspace, /* cleanup */ PMIX_DESTRUCT(&buf2); // releases the original kptr data PMIX_RELEASE(kp2); - } else if (0 == strcmp(kptr->key, PMIX_MAP_BLOB)) { + } else if (PMIX_CHECK_KEY(kptr, PMIX_MAP_BLOB)) { /* transfer the byte object for unpacking */ bo = &(kptr->value->data.bo); PMIX_CONSTRUCT(&buf2, pmix_buffer_t); @@ -1183,6 +1796,11 @@ static pmix_status_t hash_store_job_info(const char *nspace, PMIX_RELEASE(kptr); return rc; } + /* if this is the job size, then store it in + * the nptr tracker */ + if (0 == nptr->nprocs && PMIX_CHECK_KEY(kptr, PMIX_JOB_SIZE)) { + nptr->nprocs = kptr->value->data.uint32; + } } PMIX_RELEASE(kptr); kptr = PMIX_NEW(pmix_kval_t); @@ -1205,14 +1823,15 @@ static pmix_status_t hash_store(const pmix_proc_t *proc, pmix_scope_t scope, pmix_kval_t *kv) { - pmix_hash_trkr_t *trk, *t; + pmix_job_t *trk, *t; pmix_status_t rc; pmix_kval_t *kp; + pmix_namespace_t *ns, *nptr; pmix_output_verbose(2, pmix_gds_base_framework.framework_output, - "[%s:%d] gds:hash:hash_store for proc [%s:%d] key %s type %s scope %s", - pmix_globals.myid.nspace, pmix_globals.myid.rank, - proc->nspace, proc->rank, kv->key, + "%s gds:hash:hash_store for proc %s key %s type %s scope %s", + PMIX_NAME_PRINT(&pmix_globals.myid), + PMIX_NAME_PRINT(proc), kv->key, PMIx_Data_type_string(kv->value->type), PMIx_Scope_string(scope)); if (NULL == kv->key) { @@ -1221,7 +1840,7 @@ static pmix_status_t hash_store(const pmix_proc_t *proc, /* find the hash table for this nspace */ trk = NULL; - PMIX_LIST_FOREACH(t, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(t, &myjobs, pmix_job_t) { if (0 == strcmp(proc->nspace, t->ns)) { trk = t; break; @@ -1229,9 +1848,29 @@ static pmix_status_t hash_store(const pmix_proc_t *proc, } if (NULL == trk) { /* create one */ - trk = PMIX_NEW(pmix_hash_trkr_t); + trk = PMIX_NEW(pmix_job_t); trk->ns = strdup(proc->nspace); - pmix_list_append(&myhashes, &trk->super); + /* see if we already have this nspace */ + nptr = NULL; + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { + if (0 == strcmp(ns->nspace, proc->nspace)) { + nptr = ns; + break; + } + } + if (NULL == nptr) { + nptr = PMIX_NEW(pmix_namespace_t); + if (NULL == nptr) { + rc = PMIX_ERR_NOMEM; + PMIX_RELEASE(trk); + return rc; + } + nptr->nspace = strdup(proc->nspace); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); + } + PMIX_RETAIN(nptr); + trk->nptr = nptr; + pmix_list_append(&myjobs, &trk->super); } /* see if the proc is me */ @@ -1264,6 +1903,11 @@ static pmix_status_t hash_store(const pmix_proc_t *proc, } } + /* if the number of procs for the nspace object is new, then update it */ + if (0 == trk->nptr->nprocs && PMIX_CHECK_KEY(kv, PMIX_JOB_SIZE)) { + trk->nptr->nprocs = kv->value->data.uint32; + } + /* store it in the corresponding hash table */ if (PMIX_INTERNAL == scope) { if (PMIX_SUCCESS != (rc = pmix_hash_store(&trk->internal, proc->rank, kv))) { @@ -1332,12 +1976,13 @@ static pmix_status_t _hash_store_modex(void * cbdata, pmix_byte_object_t *bo) { pmix_namespace_t *ns = (pmix_namespace_t*)nspace; - pmix_hash_trkr_t *trk, *t; + pmix_job_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_namespace_t *ns2, *nptr; pmix_output_verbose(2, pmix_gds_base_framework.framework_output, "[%s:%d] gds:hash:store_modex for nspace %s", @@ -1346,7 +1991,7 @@ static pmix_status_t _hash_store_modex(void * cbdata, /* find the hash table for this nspace */ trk = NULL; - PMIX_LIST_FOREACH(t, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(t, &myjobs, pmix_job_t) { if (0 == strcmp(ns->nspace, t->ns)) { trk = t; break; @@ -1354,9 +1999,29 @@ static pmix_status_t _hash_store_modex(void * cbdata, } if (NULL == trk) { /* create one */ - trk = PMIX_NEW(pmix_hash_trkr_t); + trk = PMIX_NEW(pmix_job_t); trk->ns = strdup(ns->nspace); - pmix_list_append(&myhashes, &trk->super); + /* see if we already have this nspace */ + nptr = NULL; + PMIX_LIST_FOREACH(ns2, &pmix_globals.nspaces, pmix_namespace_t) { + if (0 == strcmp(ns->nspace, ns2->nspace)) { + nptr = ns2; + break; + } + } + if (NULL == nptr) { + nptr = PMIX_NEW(pmix_namespace_t); + if (NULL == nptr) { + rc = PMIX_ERR_NOMEM; + PMIX_RELEASE(trk); + return rc; + } + nptr->nspace = strdup(ns->nspace); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); + } + PMIX_RETAIN(nptr); + trk->nptr = nptr; + pmix_list_append(&myjobs, &trk->super); } /* this is data returned via the PMIx_Fence call when @@ -1386,14 +2051,20 @@ static pmix_status_t _hash_store_modex(void * cbdata, kv = PMIX_NEW(pmix_kval_t); 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))) { - 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; + if (PMIX_RANK_UNDEF == proc.rank) { + /* if the rank is undefined, then we store it on the + * remote table of rank=0 as we know that rank must + * always exist */ + if (PMIX_SUCCESS != (rc = pmix_hash_store(&trk->remote, 0, kv))) { + PMIX_ERROR_LOG(rc); + return rc; + } + } else { + /* store this in the hash table */ + if (PMIX_SUCCESS != (rc = pmix_hash_store(&trk->remote, proc.rank, kv))) { + PMIX_ERROR_LOG(rc); + return rc; + } } PMIX_RELEASE(kv); // maintain accounting as the hash increments the ref count /* continue along */ @@ -1415,25 +2086,257 @@ static pmix_status_t _hash_store_modex(void * cbdata, } +static pmix_status_t dohash(pmix_hash_table_t *ht, + const char *key, + pmix_rank_t rank, + bool skip_genvals, + pmix_list_t *kvs) +{ + pmix_status_t rc; + pmix_value_t *val; + pmix_kval_t *kv, *k2; + pmix_info_t *info; + size_t n, ninfo; + bool found; + + rc = pmix_hash_fetch(ht, rank, key, &val); + if (PMIX_SUCCESS == rc) { + /* if the key was NULL, then all found keys will be + * returned as a pmix_data_array_t in the value */ + if (NULL == key) { + if (NULL == val->data.darray || + PMIX_INFO != val->data.darray->type || + 0 == val->data.darray->size) { + PMIX_ERROR_LOG(PMIX_ERR_NOT_FOUND); + PMIX_RELEASE(val); + return PMIX_ERR_NOT_FOUND; + } + info = (pmix_info_t*)val->data.darray->array; + ninfo = val->data.darray->size; + for (n=0; n < ninfo; n++) { + /* if the rank is UNDEF, then we don't want + * anything that starts with "pmix" */ + if (skip_genvals && + 0 == strncmp(info[n].key, "pmix", 4)) { + continue; + } + /* see if we already have this on the list */ + found = false; + PMIX_LIST_FOREACH(k2, kvs, pmix_kval_t) { + if (PMIX_CHECK_KEY(&info[n], k2->key)) { + found = true; + break; + } + } + if (found) { + continue; + } + kv = PMIX_NEW(pmix_kval_t); + if (NULL == kv) { + PMIX_VALUE_RELEASE(val); + return PMIX_ERR_NOMEM; + } + kv->key = strdup(info[n].key); + kv->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + if (NULL == kv->value) { + PMIX_VALUE_RELEASE(val); + PMIX_RELEASE(kv); + return PMIX_ERR_NOMEM; + } + PMIX_BFROPS_VALUE_XFER(rc, pmix_globals.mypeer, + kv->value, &info[n].value); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_VALUE_RELEASE(val); + PMIX_RELEASE(kv); + return rc; + } + pmix_list_append(kvs, &kv->super); + } + PMIX_VALUE_RELEASE(val); + } else { + kv = PMIX_NEW(pmix_kval_t); + if (NULL == kv) { + PMIX_VALUE_RELEASE(val); + return PMIX_ERR_NOMEM; + } + kv->key = strdup(key); + kv->value = val; + pmix_list_append(kvs, &kv->super); + } + } + return rc; +} + +static pmix_status_t fetch_nodeinfo(const char *key, pmix_list_t *tgt, + pmix_info_t *info, size_t ninfo, + pmix_list_t *kvs) +{ + size_t n; + pmix_status_t rc; + uint32_t nid=0; + char *hostname = NULL; + bool found = false; + pmix_nodeinfo_t *nd, *ndptr; + pmix_kval_t *kv, *kp2; + + pmix_output_verbose(2, pmix_gds_base_framework.framework_output, + "FETCHING NODE INFO"); + + /* scan for the nodeID or hostname to identify + * which node they are asking about */ + for (n=0; n < ninfo; n++) { + if (PMIX_CHECK_KEY(&info[n], PMIX_NODEID)) { + PMIX_VALUE_GET_NUMBER(rc, &info[n].value, nid, uint32_t); + if (PMIX_SUCCESS != rc) { + return rc; + } + found = true; + break; + } else if (PMIX_CHECK_KEY(&info[n], PMIX_HOSTNAME)) { + hostname = info[n].value.data.string; + found = true; + break; + } + } + if (!found) { + return PMIX_ERR_DATA_VALUE_NOT_FOUND; + } + + /* scan the list of nodes to find the matching entry */ + nd = NULL; + PMIX_LIST_FOREACH(ndptr, tgt, pmix_nodeinfo_t) { + if (NULL != hostname && 0 == strcmp(ndptr->hostname, hostname)) { + nd = ndptr; + break; + } + if (NULL == hostname && nid == ndptr->nodeid) { + nd = ndptr; + break; + } + } + if (NULL == nd) { + return PMIX_ERR_NOT_FOUND; + } + /* scan the info list of this node to generate the results */ + rc = PMIX_ERR_NOT_FOUND; + PMIX_LIST_FOREACH(kv, &nd->info, pmix_kval_t) { + if (NULL == key || PMIX_CHECK_KEY(kv, key)) { + kp2 = PMIX_NEW(pmix_kval_t); + kp2->key = strdup(kv->key); + kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + PMIX_VALUE_XFER(rc, kp2->value, kv->value); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + return rc; + } + pmix_list_append(kvs, &kp2->super); + rc = PMIX_SUCCESS; + if (NULL != key) { + break; + } + } + } + + return rc; +} + +static pmix_status_t fetch_appinfo(const char *key, pmix_list_t *tgt, + pmix_info_t *info, size_t ninfo, + pmix_list_t *kvs) +{ + size_t n; + pmix_status_t rc; + uint32_t appnum; + bool found = false; + pmix_apptrkr_t *app, *apptr; + pmix_kval_t *kv, *kp2; + + pmix_output_verbose(2, pmix_gds_base_framework.framework_output, + "FETCHING APP INFO"); + + /* scan for the appnum to identify + * which app they are asking about */ + for (n=0; n < ninfo; n++) { + if (PMIX_CHECK_KEY(&info[n], PMIX_APPNUM)) { + PMIX_VALUE_GET_NUMBER(rc, &info[n].value, appnum, uint32_t); + if (PMIX_SUCCESS != rc) { + return rc; + } + found = true; + break; + } + } + if (!found) { + return PMIX_ERR_DATA_VALUE_NOT_FOUND; + } + + /* scan the list of apps to find the matching entry */ + app = NULL; + PMIX_LIST_FOREACH(apptr, tgt, pmix_apptrkr_t) { + if (appnum == apptr->appnum) { + app = apptr; + break; + } + } + if (NULL == app) { + return PMIX_ERR_NOT_FOUND; + } + + /* see if they wanted to know something about a node that + * is associated with this app */ + rc = fetch_nodeinfo(key, &app->nodeinfo, info, ninfo, kvs); + if (PMIX_ERR_DATA_VALUE_NOT_FOUND != rc) { + return rc; + } + + /* scan the info list of this app to generate the results */ + rc = PMIX_ERR_NOT_FOUND; + PMIX_LIST_FOREACH(kv, &app->appinfo, pmix_kval_t) { + if (NULL == key || PMIX_CHECK_KEY(kv, key)) { + kp2 = PMIX_NEW(pmix_kval_t); + kp2->key = strdup(kv->key); + kp2->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + PMIX_VALUE_XFER(rc, kp2->value, kv->value); + if (PMIX_SUCCESS != rc) { + PMIX_ERROR_LOG(rc); + PMIX_RELEASE(kp2); + return rc; + } + pmix_list_append(kvs, &kp2->super); + rc = PMIX_SUCCESS; + if (NULL != key) { + break; + } + } + } + + return rc; +} + static pmix_status_t hash_fetch(const pmix_proc_t *proc, pmix_scope_t scope, bool copy, const char *key, pmix_info_t qualifiers[], size_t nqual, pmix_list_t *kvs) { - pmix_hash_trkr_t *trk, *t; + pmix_job_t *trk, *t; pmix_status_t rc; pmix_value_t *val; - pmix_kval_t *kv; + pmix_kval_t *kv, *kvptr; pmix_info_t *info; size_t n, ninfo; pmix_hash_table_t *ht; + pmix_session_t *sptr; + uint32_t sid; + pmix_rank_t rnk; pmix_output_verbose(2, pmix_gds_base_framework.framework_output, - "[%s:%u] pmix:gds:hash fetch %s for proc %s:%u on scope %s", - pmix_globals.myid.nspace, pmix_globals.myid.rank, + "%s pmix:gds:hash fetch %s for proc %s on scope %s", + PMIX_NAME_PRINT(&pmix_globals.myid), (NULL == key) ? "NULL" : key, - proc->nspace, proc->rank, PMIx_Scope_string(scope)); + PMIX_NAME_PRINT(proc), PMIx_Scope_string(scope)); /* if the rank is wildcard and the key is NULL, then * they are asking for a complete copy of the job-level @@ -1442,7 +2345,7 @@ static pmix_status_t hash_fetch(const pmix_proc_t *proc, /* see if we have a tracker for this nspace - we will * if we already cached the job info for it */ trk = NULL; - PMIX_LIST_FOREACH(t, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(t, &myjobs, pmix_job_t) { if (0 == strcmp(proc->nspace, t->ns)) { trk = t; break; @@ -1497,9 +2400,58 @@ static pmix_status_t hash_fetch(const pmix_proc_t *proc, return PMIX_SUCCESS; } + /* if the nspace and rank are undefined, then they are asking + * for session-level information. */ + if (0 == strlen(proc->nspace) && PMIX_RANK_UNDEF == proc->rank) { + /* they must have included something identifying the info + * class they are querying */ + for (n=0; n < nqual; n++) { + if (PMIX_CHECK_KEY(&qualifiers[n], PMIX_SESSION_ID)) { + /* they want session-level info - see if we have + * that session */ + PMIX_VALUE_GET_NUMBER(rc, &qualifiers[n].value, sid, uint32_t); + if (PMIX_SUCCESS != rc) { + /* didn't provide a correct value */ + PMIX_ERROR_LOG(rc); + return rc; + } + PMIX_LIST_FOREACH(sptr, &mysessions, pmix_session_t) { + if (sptr->session == sid) { + /* see if they want info for a specific node */ + rc = fetch_nodeinfo(key, &sptr->nodeinfo, qualifiers, nqual, kvs); + /* if they did, then we are done */ + if (PMIX_ERR_DATA_VALUE_NOT_FOUND != rc) { + return rc; + } + /* check the session info */ + PMIX_LIST_FOREACH(kvptr, &sptr->sessioninfo, pmix_kval_t) { + if (NULL == key || PMIX_CHECK_KEY(kvptr, key)) { + kv = PMIX_NEW(pmix_kval_t); + kv->key = strdup(kvptr->key); + kv->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); + PMIX_VALUE_XFER(rc, kv->value, kvptr->value); + if (PMIX_SUCCESS != rc) { + PMIX_RELEASE(kv); + return rc; + } + pmix_list_append(kvs, &kv->super); + if (NULL != key) { + /* we are done */ + return PMIX_SUCCESS; + } + } + } + } + } + /* if we get here, then the session wasn't found */ + return PMIX_ERR_NOT_FOUND; + } + } + } + /* find the hash table for this nspace */ trk = NULL; - PMIX_LIST_FOREACH(t, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(t, &myjobs, pmix_job_t) { if (0 == strcmp(proc->nspace, t->ns)) { trk = t; break; @@ -1509,6 +2461,24 @@ static pmix_status_t hash_fetch(const pmix_proc_t *proc, return PMIX_ERR_INVALID_NAMESPACE; } + /* if the rank isn't specified, check to see if they + * are looking for app-level or node-level info for + * this job */ + if (PMIX_RANK_UNDEF == proc->rank) { + /* see if they want info for a specific node */ + rc = fetch_nodeinfo(key, &trk->nodeinfo, qualifiers, nqual, kvs); + /* if they did, then we are done */ + if (PMIX_ERR_DATA_VALUE_NOT_FOUND != rc) { + return rc; + } + /* see if they want info for a specific app */ + rc = fetch_appinfo(key, &trk->apps, qualifiers, nqual, kvs); + /* if they did, then we are done */ + if (PMIX_ERR_DATA_VALUE_NOT_FOUND != rc) { + return rc; + } + } + /* fetch from the corresponding hash table - note that * we always provide a copy as we don't support * shared memory */ @@ -1528,59 +2498,56 @@ static pmix_status_t hash_fetch(const pmix_proc_t *proc, } doover: - rc = pmix_hash_fetch(ht, proc->rank, key, &val); - if (PMIX_SUCCESS == rc) { - /* if the key was NULL, then all found keys will be - * returned as a pmix_data_array_t in the value */ - if (NULL == key) { - if (NULL == val->data.darray || - PMIX_INFO != val->data.darray->type || - 0 == val->data.darray->size) { - PMIX_ERROR_LOG(PMIX_ERR_NOT_FOUND); - return PMIX_ERR_NOT_FOUND; + /* if rank=PMIX_RANK_UNDEF, then we need to search all + * known ranks for this nspace as any one of them could + * be the source */ + if (PMIX_RANK_UNDEF == proc->rank) { + for (rnk=0; rnk < trk->nptr->nprocs; rnk++) { + rc = dohash(ht, key, rnk, true, kvs); + if (PMIX_ERR_NOMEM == rc) { + return rc; } - info = (pmix_info_t*)val->data.darray->array; - ninfo = val->data.darray->size; - for (n=0; n < ninfo; n++) { + if (PMIX_SUCCESS == rc && NULL != key) { + return rc; + } + } + /* also need to check any job-level info */ + PMIX_LIST_FOREACH(kvptr, &trk->jobinfo, pmix_kval_t) { + if (NULL == key || PMIX_CHECK_KEY(kvptr, key)) { kv = PMIX_NEW(pmix_kval_t); - if (NULL == kv) { - PMIX_VALUE_RELEASE(val); - return PMIX_ERR_NOMEM; - } - kv->key = strdup(info[n].key); + kv->key = strdup(kvptr->key); kv->value = (pmix_value_t*)malloc(sizeof(pmix_value_t)); - if (NULL == kv->value) { - PMIX_VALUE_RELEASE(val); - PMIX_RELEASE(kv); - return PMIX_ERR_NOMEM; - } - PMIX_BFROPS_VALUE_XFER(rc, pmix_globals.mypeer, - kv->value, &info[n].value); + PMIX_VALUE_XFER(rc, kv->value, kvptr->value); if (PMIX_SUCCESS != rc) { - PMIX_ERROR_LOG(rc); - PMIX_VALUE_RELEASE(val); PMIX_RELEASE(kv); return rc; } pmix_list_append(kvs, &kv->super); + if (NULL != key) { + break; + } } - PMIX_VALUE_RELEASE(val); - if (PMIX_GLOBAL == scope && ht == &trk->local) { + } + if (NULL == key) { + /* and need to add all job info just in case that was + * passed via a different GDS component */ + dohash(&trk->internal, NULL, PMIX_RANK_WILDCARD, false, kvs); + } + } else { + rc = dohash(ht, key, proc->rank, false, kvs); + } + if (PMIX_SUCCESS == rc) { + if (PMIX_GLOBAL == scope) { + if (ht == &trk->local) { /* need to do this again for the remote data */ ht = &trk->remote; goto doover; + } else if (ht == &trk->internal) { + /* check local */ + ht = &trk->local; + goto doover; } - return PMIX_SUCCESS; } - /* just return the value */ - kv = PMIX_NEW(pmix_kval_t); - if (NULL == kv) { - PMIX_VALUE_RELEASE(val); - return PMIX_ERR_NOMEM; - } - kv->key = strdup(key); - kv->value = val; - pmix_list_append(kvs, &kv->super); } else { if (PMIX_GLOBAL == scope || PMIX_SCOPE_UNDEF == scope) { @@ -1595,6 +2562,9 @@ static pmix_status_t hash_fetch(const pmix_proc_t *proc, } } } + if (0 == pmix_list_get_size(kvs)) { + rc = PMIX_ERR_NOT_FOUND; + } return rc; } @@ -1615,13 +2585,13 @@ static pmix_status_t nspace_add(const char *nspace, static pmix_status_t nspace_del(const char *nspace) { - pmix_hash_trkr_t *t; + pmix_job_t *t; /* find the hash table for this nspace */ - PMIX_LIST_FOREACH(t, &myhashes, pmix_hash_trkr_t) { + PMIX_LIST_FOREACH(t, &myjobs, pmix_job_t) { if (0 == strcmp(nspace, t->ns)) { /* release it */ - pmix_list_remove_item(&myhashes, &t->super); + pmix_list_remove_item(&myjobs, &t->super); PMIX_RELEASE(t); break; } @@ -1685,6 +2655,12 @@ static pmix_status_t accept_kvs_resp(pmix_buffer_t *buf) PMIX_ERROR_LOG(rc); return rc; } + /* if the rank is UNDEF, then we store this on our own + * rank tables */ + if (PMIX_RANK_UNDEF == proct.rank) { + proct.rank = pmix_globals.myid.rank; + } + cnt = 1; kv = PMIX_NEW(pmix_kval_t); PMIX_BFROPS_UNPACK(rc, pmix_client_globals.myserver, @@ -1694,7 +2670,6 @@ static pmix_status_t accept_kvs_resp(pmix_buffer_t *buf) * the kval contains shmem connection info, then the * component will know what to do about it (or else * we selected the wrong component for this peer!) */ - PMIX_GDS_STORE_KV(rc, pmix_globals.mypeer, &proct, PMIX_INTERNAL, kv); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/bsdx_ipv4/pif_bsdx.c b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/bsdx_ipv4/pif_bsdx.c index 800923c34f..1d48b46277 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/bsdx_ipv4/pif_bsdx.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/bsdx_ipv4/pif_bsdx.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. 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 @@ -158,7 +158,7 @@ static int if_bsdx_open(void) /* fill values into the pmix_pif_t */ memcpy(&a4, &(sin_addr->sin_addr), sizeof(struct in_addr)); - pmix_strncpy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE-1); + pmix_strncpy(intf->if_name, cur_ifaddrs->ifa_name, PMIX_IF_NAMESIZE-1); intf->if_index = pmix_list_get_size(&pmix_if_list) + 1; ((struct sockaddr_in*) &intf->if_addr)->sin_addr = a4; ((struct sockaddr_in*) &intf->if_addr)->sin_family = AF_INET; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/bsdx_ipv6/pif_bsdx_ipv6.c b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/bsdx_ipv6/pif_bsdx_ipv6.c index 5954f1580c..ff30d73500 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/bsdx_ipv6/pif_bsdx_ipv6.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/bsdx_ipv6/pif_bsdx_ipv6.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. 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 @@ -183,7 +183,7 @@ static int if_bsdx_ipv6_open(void) return PMIX_ERR_OUT_OF_RESOURCE; } intf->af_family = AF_INET6; - pmix_strncpy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE-1); + pmix_strncpy(intf->if_name, cur_ifaddrs->ifa_name, PMIX_IF_NAMESIZE-1); intf->if_index = pmix_list_get_size(&pmix_if_list) + 1; ((struct sockaddr_in6*) &intf->if_addr)->sin6_addr = a6; ((struct sockaddr_in6*) &intf->if_addr)->sin6_family = AF_INET6; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/linux_ipv6/pif_linux_ipv6.c b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/linux_ipv6/pif_linux_ipv6.c index f0bb2db9f5..53bec6fb04 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/linux_ipv6/pif_linux_ipv6.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/linux_ipv6/pif_linux_ipv6.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. 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 @@ -80,12 +80,17 @@ static int if_linux_ipv6_open(void) { FILE *f; if ((f = fopen("/proc/net/if_inet6", "r"))) { - char ifname[IF_NAMESIZE]; + /* IF_NAMESIZE is normally 16 on Linux, + but the next scanf allows up to 21 bytes */ + char ifname[PMIX_IF_NAMESIZE]; unsigned int idx, pfxlen, scope, dadstat; struct in6_addr a6; int iter; uint32_t flag; - unsigned int addrbyte[16]; + unsigned int addrbyte[PMIX_IF_NAMESIZE]; + + memset(addrbyte, 0, PMIX_IF_NAMESIZE*sizeof(unsigned int)); + memset(ifname, 0, PMIX_IF_NAMESIZE*sizeof(char)); while (fscanf(f, "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x %x %x %x %x %20s\n", &addrbyte[0], &addrbyte[1], &addrbyte[2], &addrbyte[3], @@ -102,8 +107,8 @@ static int if_linux_ipv6_open(void) addrbyte[8], addrbyte[9], addrbyte[10], addrbyte[11], addrbyte[12], addrbyte[13], addrbyte[14], addrbyte[15], scope); - /* we don't want any other scope less than link-local */ - if (scope < 0x20) { + /* Only interested in global (0x00) scope */ + if (scope != 0x00) { pmix_output_verbose(1, pmix_pif_base_framework.framework_output, "skipping interface %2x%2x:%2x%2x:%2x%2x:%2x%2x:%2x%2x:%2x%2x:%2x%2x:%2x%2x scope %x\n", addrbyte[0], addrbyte[1], addrbyte[2], addrbyte[3], @@ -127,7 +132,7 @@ static int if_linux_ipv6_open(void) } /* now construct the pmix_pif_t */ - pmix_strncpy(intf->if_name, ifname, IF_NAMESIZE-1); + pmix_strncpy(intf->if_name, ifname, PMIX_IF_NAMESIZE-1); intf->if_index = pmix_list_get_size(&pmix_if_list)+1; intf->if_kernel_index = (uint16_t) idx; ((struct sockaddr_in6*) &intf->if_addr)->sin6_addr = a6; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/pif.h b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/pif.h index e43de4707d..9d23fdf1ff 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/pif.h +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/pif.h @@ -3,7 +3,7 @@ * Copyright (c) 2010-2013 Cisco Systems, Inc. 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 @@ -73,7 +73,7 @@ BEGIN_C_DECLS typedef struct pmix_pif_t { pmix_list_item_t super; - char if_name[IF_NAMESIZE+1]; + char if_name[PMIX_IF_NAMESIZE+1]; int if_index; uint16_t if_kernel_index; uint16_t af_family; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/solaris_ipv6/pif_solaris_ipv6.c b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/solaris_ipv6/pif_solaris_ipv6.c index a7d94f7908..c9895cb661 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pif/solaris_ipv6/pif_solaris_ipv6.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pif/solaris_ipv6/pif_solaris_ipv6.c @@ -3,7 +3,7 @@ * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016 Research Organization for Information Science * and Technology (RIST). 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 @@ -190,7 +190,7 @@ static int if_solaris_ipv6_open(void) } intf->af_family = AF_INET6; - pmix_strncpy (intf->if_name, lifreq->lifr_name, IF_NAMESIZE-1); + pmix_strncpy (intf->if_name, lifreq->lifr_name, PMIX_IF_NAMESIZE-1); intf->if_index = pmix_list_get_size(&pmix_if_list)+1; memcpy(&intf->if_addr, my_addr, sizeof (*my_addr)); intf->if_mask = 64; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/plog/base/plog_base_stubs.c b/opal/mca/pmix/pmix3x/pmix/src/mca/plog/base/plog_base_stubs.c index 226db25b27..221ec775f8 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/plog/base/plog_base_stubs.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/plog/base/plog_base_stubs.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2018 Intel, Inc. All rights reserved. + * Copyright (c) 2018-2019 Intel, Inc. All rights reserved. * * $COPYRIGHT$ * @@ -109,8 +109,8 @@ pmix_status_t pmix_plog_base_log(const pmix_proc_t *source, * channel that can successfully handle this request, * and any channel directives */ for (n=0; n < ndirs; n++) { - if (0 == strncmp(directives[n].key, PMIX_LOG_ONCE, PMIX_MAX_KEYLEN)) { - logonce = true; + if (PMIX_CHECK_KEY(&directives[n], PMIX_LOG_ONCE)) { + logonce = PMIX_INFO_TRUE(&directives[n]); break; } } @@ -237,14 +237,10 @@ pmix_status_t pmix_plog_base_log(const pmix_proc_t *source, rc = mycount->status; // save the status as it could change when the lock is released if (0 == mycount->nreqs) { - /* execute their callback */ - if (NULL != mycount->cbfunc) { - mycount->cbfunc(mycount->status, mycount->cbdata); - } PMIX_RELEASE_THREAD(&mycount->lock); PMIX_RELEASE(mycount); PMIX_RELEASE_THREAD(&pmix_plog_globals.lock); - return PMIX_SUCCESS; + return PMIX_OPERATION_SUCCEEDED; } PMIX_RELEASE_THREAD(&mycount->lock); PMIX_RELEASE_THREAD(&pmix_plog_globals.lock); diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/plog/stdfd/plog_stdfd.c b/opal/mca/pmix/pmix3x/pmix/src/mca/plog/stdfd/plog_stdfd.c index 619dc38f70..2aceac179a 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/plog/stdfd/plog_stdfd.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/plog/stdfd/plog_stdfd.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007 Sun Microsystems, Inc. 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 @@ -101,6 +101,9 @@ static pmix_status_t mylog(const pmix_proc_t *source, /* check to see if there are any stdfd entries */ rc = PMIX_ERR_TAKE_NEXT_OPTION; for (n=0; n < ndata; n++) { + if (PMIX_INFO_OP_IS_COMPLETE(&data[n])) { + continue; + } if (0 == strncmp(data[n].key, PMIX_LOG_STDERR, PMIX_MAX_KEYLEN)) { bo.bytes = data[n].value.data.string; bo.size = strlen(bo.bytes); @@ -117,6 +120,5 @@ static pmix_status_t mylog(const pmix_proc_t *source, rc = PMIX_SUCCESS; } } - return rc; } diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/base/pnet_base_fns.c b/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/base/pnet_base_fns.c index d62268dbd5..447a8e1ca1 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/base/pnet_base_fns.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/base/pnet_base_fns.c @@ -60,7 +60,7 @@ pmix_status_t pmix_pnet_base_allocate(char *nspace, nptr = NULL; /* find this nspace - note that it may not have * been registered yet */ - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(ns->nspace, nspace)) { nptr = ns; break; @@ -73,7 +73,7 @@ pmix_status_t pmix_pnet_base_allocate(char *nspace, return PMIX_ERR_NOMEM; } nptr->nspace = strdup(nspace); - pmix_list_append(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); } if (NULL != info) { @@ -146,7 +146,7 @@ pmix_status_t pmix_pnet_base_setup_local_network(char *nspace, /* find this proc's nspace object */ nptr = NULL; - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(ns->nspace, nspace)) { nptr = ns; break; @@ -159,7 +159,7 @@ pmix_status_t pmix_pnet_base_setup_local_network(char *nspace, return PMIX_ERR_NOMEM; } nptr->nspace = strdup(nspace); - pmix_list_append(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); } PMIX_LIST_FOREACH(active, &pmix_pnet_globals.actives, pmix_pnet_base_active_module_t) { @@ -191,7 +191,7 @@ pmix_status_t pmix_pnet_base_setup_fork(const pmix_proc_t *proc, char ***env) /* find this proc's nspace object */ nptr = NULL; - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(ns->nspace, proc->nspace)) { nptr = ns; break; @@ -204,7 +204,7 @@ pmix_status_t pmix_pnet_base_setup_fork(const pmix_proc_t *proc, char ***env) return PMIX_ERR_NOMEM; } nptr->nspace = strdup(proc->nspace); - pmix_list_append(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); } PMIX_LIST_FOREACH(active, &pmix_pnet_globals.actives, pmix_pnet_base_active_module_t) { @@ -282,7 +282,7 @@ void pmix_pnet_base_deregister_nspace(char *nspace) /* find this nspace object */ nptr = NULL; - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(ns->nspace, nspace)) { nptr = ns; break; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/opa/pnet_opa.c b/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/opa/pnet_opa.c index d795c8bc48..712b164421 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/opa/pnet_opa.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/opa/pnet_opa.c @@ -435,7 +435,7 @@ static pmix_status_t collect_inventory(pmix_info_t directives[], size_t ndirs, pmix_buffer_t bucket, pbkt; bool found = false; pmix_byte_object_t pbo; - char nodename[PMIX_MAXHOSTNAMELEN], *foo; + char nodename[PMIX_MAXHOSTNAMELEN] = {0}, *foo; pmix_output_verbose(2, pmix_pnet_base_framework.framework_output, "pnet:opa collect inventory"); @@ -443,7 +443,7 @@ static pmix_status_t collect_inventory(pmix_info_t directives[], size_t ndirs, /* setup the bucket - we will pass the results as a blob */ PMIX_CONSTRUCT(&bucket, pmix_buffer_t); /* pack our node name */ - gethostname(nodename, sizeof(nodename)); + gethostname(nodename, sizeof(nodename)-1); foo = &nodename[0]; PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, &bucket, &foo, 1, PMIX_STRING); if (PMIX_SUCCESS != rc) { diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/tcp/pnet_tcp.c b/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/tcp/pnet_tcp.c index fecec01424..81e823ad24 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/tcp/pnet_tcp.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pnet/tcp/pnet_tcp.c @@ -737,6 +737,7 @@ static pmix_status_t setup_local_network(pmix_namespace_t *nptr, "pnet:tcp:setup_local_network"); if (NULL != info) { + idkey = strdup("default"); for (n=0; n < ninfo; n++) { /* look for my key */ if (0 == strncmp(info[n].key, PMIX_TCP_SETUP_APP_KEY, PMIX_MAX_KEYLEN)) { @@ -866,8 +867,8 @@ static pmix_status_t collect_inventory(pmix_info_t directives[], size_t ndirs, pmix_inventory_cbfunc_t cbfunc, void *cbdata) { pmix_inventory_rollup_t *cd = (pmix_inventory_rollup_t*)cbdata; - char *prefix, myhost[PMIX_MAXHOSTNAMELEN]; - char myconnhost[PMIX_MAXHOSTNAMELEN]; + char *prefix, myhost[PMIX_MAXHOSTNAMELEN] = {0}; + char myconnhost[PMIX_MAXHOSTNAMELEN] = {0}; char name[32], uri[2048]; struct sockaddr_storage my_ss; char *foo; @@ -884,7 +885,7 @@ static pmix_status_t collect_inventory(pmix_info_t directives[], size_t ndirs, /* setup the bucket - we will pass the results as a blob */ PMIX_CONSTRUCT(&bucket, pmix_buffer_t); /* add our hostname */ - gethostname(myhost, sizeof(myhost)); + gethostname(myhost, sizeof(myhost)-1); foo = &myhost[0]; PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, &bucket, &foo, 1, PMIX_STRING); if (PMIX_SUCCESS != rc) { @@ -919,11 +920,11 @@ static pmix_status_t collect_inventory(pmix_info_t directives[], size_t ndirs, if (AF_INET == my_ss.ss_family) { prefix = "tcp4://"; inet_ntop(AF_INET, &((struct sockaddr_in*) &my_ss)->sin_addr, - myconnhost, PMIX_MAXHOSTNAMELEN); + myconnhost, PMIX_MAXHOSTNAMELEN-1); } else if (AF_INET6 == my_ss.ss_family) { prefix = "tcp6://"; inet_ntop(AF_INET6, &((struct sockaddr_in6*) &my_ss)->sin6_addr, - myconnhost, PMIX_MAXHOSTNAMELEN); + myconnhost, PMIX_MAXHOSTNAMELEN-1); } else { continue; } diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/pshmem/mmap/pshmem_mmap.c b/opal/mca/pmix/pmix3x/pmix/src/mca/pshmem/mmap/pshmem_mmap.c index 09c377cd8b..6529c1fa4a 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/pshmem/mmap/pshmem_mmap.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/pshmem/mmap/pshmem_mmap.c @@ -3,7 +3,7 @@ * All rights reserved. * Copyright (c) 2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. - * Copyright (c) 2017-2018 Intel, Inc. All rights reserved. + * Copyright (c) 2017-2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -82,9 +82,9 @@ static int _mmap_segment_create(pmix_pshmem_seg_t *sm_seg, const char *file_name if (ENOSPC == rc) { rc = PMIX_ERR_OUT_OF_RESOURCE; goto out; - } else if ((ENOTSUP != rc) + } else if (EINVAL != rc && ENOTSUP != rc #ifdef EOPNOTSUPP - && (EOPNOTSUPP != rc) + && EOPNOTSUPP != rc #endif ){ rc = PMIX_ERROR; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/tcp/ptl_tcp.c b/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/tcp/ptl_tcp.c index 0252eed51c..e86a412640 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/tcp/ptl_tcp.c +++ b/opal/mca/pmix/pmix3x/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" @@ -131,7 +131,7 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, char *p, *p2, *server_nspace = NULL, *rendfile = NULL; int sd, rc; size_t n; - char myhost[PMIX_MAXHOSTNAMELEN]; + char myhost[PMIX_MAXHOSTNAMELEN] = {0}; bool system_level = false; bool system_level_only = false; bool reconnect = false; @@ -414,7 +414,7 @@ static pmix_status_t connect_to_peer(struct pmix_peer_t *peer, /* mark that we are using the V2 protocol */ pmix_globals.mypeer->protocol = PMIX_PROTOCOL_V2; - gethostname(myhost, sizeof(myhost)); + gethostname(myhost, sizeof(myhost)-1); /* if we were given a URI via MCA param, then look no further */ if (NULL != suri) { if (NULL != server_nspace) { diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c b/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c index 61eb18ec30..cb800a6fdf 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/tcp/ptl_tcp_component.c @@ -360,8 +360,8 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, bool session_tool = false; bool system_tool = false; pmix_socklen_t addrlen; - char *prefix, myhost[PMIX_MAXHOSTNAMELEN]; - char myconnhost[PMIX_MAXHOSTNAMELEN]; + char *prefix, myhost[PMIX_MAXHOSTNAMELEN] = {0}; + char myconnhost[PMIX_MAXHOSTNAMELEN] = {0}; int myport; pmix_kval_t *urikv; @@ -624,17 +624,17 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo, goto sockerror; } - gethostname(myhost, sizeof(myhost)); + gethostname(myhost, sizeof(myhost)-1); if (AF_INET == mca_ptl_tcp_component.connection.ss_family) { prefix = "tcp4://"; myport = ntohs(((struct sockaddr_in*) &mca_ptl_tcp_component.connection)->sin_port); inet_ntop(AF_INET, &((struct sockaddr_in*) &mca_ptl_tcp_component.connection)->sin_addr, - myconnhost, PMIX_MAXHOSTNAMELEN); + myconnhost, PMIX_MAXHOSTNAMELEN-1); } else if (AF_INET6 == mca_ptl_tcp_component.connection.ss_family) { prefix = "tcp6://"; myport = ntohs(((struct sockaddr_in6*) &mca_ptl_tcp_component.connection)->sin6_port); inet_ntop(AF_INET6, &((struct sockaddr_in6*) &mca_ptl_tcp_component.connection)->sin6_addr, - myconnhost, PMIX_MAXHOSTNAMELEN); + myconnhost, PMIX_MAXHOSTNAMELEN-1); } else { goto sockerror; } @@ -898,7 +898,7 @@ static char **split_and_resolve(char **orig_str, char *name) { int i, ret, save, if_index; char **argv, *str, *tmp; - char if_name[IF_NAMESIZE]; + char if_name[PMIX_IF_NAMESIZE]; struct sockaddr_storage argv_inaddr, if_inaddr; uint32_t argv_prefix; @@ -1384,7 +1384,7 @@ static void connection_handler(int sd, short args, void *cbdata) * of local clients. So let's start by searching for * the nspace object */ nptr = NULL; - PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(tmp, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(tmp->nspace, nspace)) { nptr = tmp; break; @@ -1534,7 +1534,7 @@ static void connection_handler(int sd, short args, void *cbdata) /* see if we know this nspace */ nptr = NULL; - PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(tmp, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(tmp->nspace, nspace)) { nptr = tmp; break; @@ -1838,7 +1838,7 @@ static void process_cbfunc(int sd, short args, void *cbdata) if (5 != pnd->flag && 8 != pnd->flag) { PMIX_RETAIN(nptr); nptr->nspace = strdup(cd->proc.nspace); - pmix_list_append(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); info = PMIX_NEW(pmix_rank_info_t); info->pname.nspace = strdup(nptr->nspace); info->pname.rank = cd->proc.rank; @@ -1866,7 +1866,7 @@ static void process_cbfunc(int sd, short args, void *cbdata) peer->nptr->compat.psec = pmix_psec_base_assign_module(pnd->psec); if (NULL == peer->nptr->compat.psec) { PMIX_RELEASE(peer); - pmix_list_remove_item(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_remove_item(&pmix_globals.nspaces, &nptr->super); PMIX_RELEASE(nptr); // will release the info object CLOSE_THE_SOCKET(pnd->sd); goto done; @@ -1881,7 +1881,7 @@ static void process_cbfunc(int sd, short args, void *cbdata) PMIX_INFO_DESTRUCT(&ginfo); if (NULL == peer->nptr->compat.gds) { PMIX_RELEASE(peer); - pmix_list_remove_item(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_remove_item(&pmix_globals.nspaces, &nptr->super); PMIX_RELEASE(nptr); // will release the info object CLOSE_THE_SOCKET(pnd->sd); goto done; @@ -1900,7 +1900,7 @@ static void process_cbfunc(int sd, short args, void *cbdata) req = PMIX_NEW(pmix_iof_req_t); if (NULL == req) { PMIX_RELEASE(peer); - pmix_list_remove_item(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_remove_item(&pmix_globals.nspaces, &nptr->super); PMIX_RELEASE(nptr); // will release the info object CLOSE_THE_SOCKET(pnd->sd); goto done; @@ -1936,7 +1936,7 @@ static void process_cbfunc(int sd, short args, void *cbdata) "validation of tool credentials failed: %s", PMIx_Error_string(rc)); PMIX_RELEASE(peer); - pmix_list_remove_item(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_remove_item(&pmix_globals.nspaces, &nptr->super); PMIX_RELEASE(nptr); // will release the info object CLOSE_THE_SOCKET(pnd->sd); goto done; @@ -1949,7 +1949,7 @@ static void process_cbfunc(int sd, short args, void *cbdata) PMIX_RELEASE(pnd); PMIX_RELEASE(cd); PMIX_RELEASE(peer); - pmix_list_remove_item(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_remove_item(&pmix_globals.nspaces, &nptr->super); PMIX_RELEASE(nptr); // will release the info object /* probably cannot send an error reply if we are out of memory */ return; diff --git a/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/usock/ptl_usock.c b/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/usock/ptl_usock.c index fc7b6da1c4..51417f3e03 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/usock/ptl_usock.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/usock/ptl_usock.c @@ -13,7 +13,7 @@ * Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2013 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$ * * Additional copyrights may follow @@ -611,7 +611,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/pmix3x/pmix/src/mca/ptl/usock/ptl_usock_component.c b/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/usock/ptl_usock_component.c index ef33e766f9..36637cc988 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/usock/ptl_usock_component.c +++ b/opal/mca/pmix/pmix3x/pmix/src/mca/ptl/usock/ptl_usock_component.c @@ -552,7 +552,7 @@ static void connection_handler(int sd, short args, void *cbdata) /* see if we know this nspace */ nptr = NULL; - PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(tmp, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(tmp->nspace, nspace)) { nptr = tmp; break; diff --git a/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_finalize.c b/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_finalize.c index 87a1456f4d..c083ad645f 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_finalize.c +++ b/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_finalize.c @@ -12,9 +12,9 @@ * 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) 2016-2018 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -116,6 +116,8 @@ void pmix_rte_finalize(void) } PMIX_DESTRUCT(&pmix_globals.notifications); PMIX_LIST_DESTRUCT(&pmix_globals.iof_requests); + free(pmix_globals.hostname); + PMIX_LIST_DESTRUCT(&pmix_globals.nspaces); /* now safe to release the event base */ if (!pmix_globals.external_evbase) { diff --git a/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_init.c b/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_init.c index d1803de704..b3255e4e5d 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_init.c +++ b/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_init.c @@ -33,7 +33,9 @@ #include #endif #include PMIX_EVENT_HEADER -#include "event2/thread.h" +#if ! PMIX_HAVE_LIBEV +#include PMIX_EVENT2_THREAD_HEADER +#endif #include @@ -98,7 +100,7 @@ int pmix_rte_init(pmix_proc_type_t type, int ret, debug_level; char *error = NULL, *evar; size_t n; - char hostname[PMIX_MAXHOSTNAMELEN]; + char hostname[PMIX_MAXHOSTNAMELEN] = {0}; if( ++pmix_initialized != 1 ) { if( pmix_initialized < 1 ) { @@ -159,7 +161,7 @@ int pmix_rte_init(pmix_proc_type_t type, } /* setup the globals structure */ - gethostname(hostname, PMIX_MAXHOSTNAMELEN); + gethostname(hostname, PMIX_MAXHOSTNAMELEN-1); pmix_globals.hostname = strdup(hostname); memset(&pmix_globals.myid.nspace, 0, PMIX_MAX_NSLEN+1); pmix_globals.myid.rank = PMIX_RANK_INVALID; @@ -172,6 +174,8 @@ int pmix_rte_init(pmix_proc_type_t type, ret = pmix_hotel_init(&pmix_globals.notifications, pmix_globals.max_events, pmix_globals.evbase, pmix_globals.event_eviction_time, _notification_eviction_cbfunc); + PMIX_CONSTRUCT(&pmix_globals.nspaces, pmix_list_t); + if (PMIX_SUCCESS != ret) { error = "notification hotel init"; goto return_error; diff --git a/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_progress_threads.c b/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_progress_threads.c index a66e4d0a76..7e40422a0b 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_progress_threads.c +++ b/opal/mca/pmix/pmix3x/pmix/src/runtime/pmix_progress_threads.c @@ -1,8 +1,8 @@ /* * Copyright (c) 2014-2019 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 (c) 2019 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ @@ -13,7 +13,6 @@ */ #include -#include "src/include/types.h" #ifdef HAVE_UNISTD_H #include @@ -49,6 +48,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) @@ -58,6 +63,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) @@ -73,6 +82,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, @@ -80,6 +93,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_loopexit (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 = { @@ -118,7 +239,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_loopexit(trk->ev_base); @@ -192,6 +312,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; @@ -302,6 +427,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/pmix3x/pmix/src/server/pmix_server.c b/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server.c index f827018d71..2ea33a056c 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server.c +++ b/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server.c @@ -50,7 +50,9 @@ #include #include #include PMIX_EVENT_HEADER +#if ! PMIX_HAVE_LIBEV #include PMIX_EVENT2_THREAD_HEADER +#endif #include "src/util/argv.h" #include "src/util/error.h" @@ -97,7 +99,6 @@ pmix_status_t pmix_server_initialize(void) PMIX_CONSTRUCT(&pmix_server_globals.gdata, pmix_list_t); PMIX_CONSTRUCT(&pmix_server_globals.events, pmix_list_t); PMIX_CONSTRUCT(&pmix_server_globals.local_reqs, pmix_list_t); - PMIX_CONSTRUCT(&pmix_server_globals.nspaces, pmix_list_t); PMIX_CONSTRUCT(&pmix_server_globals.iof, pmix_list_t); pmix_output_verbose(2, pmix_server_globals.base_output, @@ -361,7 +362,7 @@ PMIX_EXPORT pmix_status_t PMIx_server_init(pmix_server_module_t *module, pmix_globals.mypeer->nptr = PMIX_NEW(pmix_namespace_t); /* ensure our own nspace is first on the list */ PMIX_RETAIN(pmix_globals.mypeer->nptr); - pmix_list_prepend(&pmix_server_globals.nspaces, &pmix_globals.mypeer->nptr->super); + pmix_list_prepend(&pmix_globals.nspaces, &pmix_globals.mypeer->nptr->super); } pmix_globals.mypeer->nptr->nspace = strdup(pmix_globals.myid.nspace); rinfo->pname.nspace = strdup(pmix_globals.mypeer->nptr->nspace); @@ -474,13 +475,12 @@ PMIX_EXPORT pmix_status_t PMIx_server_finalize(void) PMIX_LIST_DESTRUCT(&pmix_server_globals.local_reqs); PMIX_LIST_DESTRUCT(&pmix_server_globals.gdata); PMIX_LIST_DESTRUCT(&pmix_server_globals.events); - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { /* ensure that we do the specified cleanup - if this is an * abnormal termination, then the nspace object may not be * at zero refcount */ pmix_execute_epilog(&ns->epilog); } - PMIX_LIST_DESTRUCT(&pmix_server_globals.nspaces); PMIX_LIST_DESTRUCT(&pmix_server_globals.iof); pmix_hwloc_cleanup(); @@ -547,7 +547,7 @@ static void _register_nspace(int sd, short args, void *cbdata) /* see if we already have this nspace */ nptr = NULL; - PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(tmp, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(tmp->nspace, cd->proc.nspace)) { nptr = tmp; break; @@ -560,7 +560,7 @@ static void _register_nspace(int sd, short args, void *cbdata) goto release; } nptr->nspace = strdup(cd->proc.nspace); - pmix_list_append(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); } nptr->nlocalprocs = cd->nlocalprocs; @@ -764,12 +764,12 @@ static void _deregister_nspace(int sd, short args, void *cbdata) pmix_server_purge_events(NULL, &cd->proc); /* release this nspace */ - PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(tmp, &pmix_globals.nspaces, pmix_namespace_t) { if (PMIX_CHECK_NSPACE(tmp->nspace, cd->proc.nspace)) { /* perform any nspace-level epilog */ pmix_execute_epilog(&tmp->epilog); /* remove and release it */ - pmix_list_remove_item(&pmix_server_globals.nspaces, &tmp->super); + pmix_list_remove_item(&pmix_globals.nspaces, &tmp->super); PMIX_RELEASE(tmp); break; } @@ -997,7 +997,7 @@ static void _register_client(int sd, short args, void *cbdata) /* see if we already have this nspace */ nptr = NULL; - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(ns->nspace, cd->proc.nspace)) { nptr = ns; break; @@ -1010,7 +1010,7 @@ static void _register_client(int sd, short args, void *cbdata) goto cleanup; } nptr->nspace = strdup(cd->proc.nspace); - pmix_list_append(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); } /* setup a peer object for this client - since the host server * only deals with the original processes and not any clones, @@ -1051,7 +1051,7 @@ static void _register_client(int sd, short args, void *cbdata) * if the nspaces are all defined */ if (all_def) { /* so far, they have all been defined - check this one */ - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 < ns->nlocalprocs && 0 == strcmp(trk->pcs[i].nspace, ns->nspace)) { all_def = ns->all_registered; @@ -1166,7 +1166,7 @@ static void _deregister_client(int sd, short args, void *cbdata) /* see if we already have this nspace */ nptr = NULL; - PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(tmp, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(tmp->nspace, cd->proc.nspace)) { nptr = tmp; break; @@ -1368,15 +1368,15 @@ static void _dmodex_req(int sd, short args, void *cbdata) PMIX_ACQUIRE_OBJECT(cd); pmix_output_verbose(2, pmix_server_globals.base_output, - "DMODX LOOKING FOR %s:%d", - cd->proc.nspace, cd->proc.rank); + "DMODX LOOKING FOR %s", + PMIX_NAME_PRINT(&cd->proc)); /* this should be one of my clients, but a race condition * could cause this request to arrive prior to us having * been informed of it - so first check to see if we know * about this nspace yet */ nptr = NULL; - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(ns->nspace, cd->proc.nspace)) { nptr = ns; break; @@ -1502,8 +1502,9 @@ PMIX_EXPORT pmix_status_t PMIx_server_dmodex_request(const pmix_proc_t *proc, } pmix_output_verbose(2, pmix_server_globals.base_output, - "pmix:server dmodex request%s:%d", - proc->nspace, proc->rank); + "%s pmix:server dmodex request for proc %s", + PMIX_NAME_PRINT(&pmix_globals.myid), + PMIX_NAME_PRINT(proc)); cd = PMIX_NEW(pmix_setup_caddy_t); pmix_strncpy(cd->proc.nspace, proc->nspace, PMIX_MAX_NSLEN); diff --git a/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server_get.c b/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server_get.c index 56c0530801..c8fe13cdd6 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server_get.c +++ b/opal/mca/pmix/pmix3x/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 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 Mellanox Technologies, Inc. @@ -51,6 +51,7 @@ #include "src/mca/gds/gds.h" #include "src/util/argv.h" #include "src/util/error.h" +#include "src/util/name_fns.h" #include "src/util/output.h" #include "src/util/pmix_environ.h" @@ -126,6 +127,7 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, pmix_dmdx_request_t *req; bool local; bool localonly = false; + bool diffnspace = false; struct timeval tv = {0, 0}; pmix_buffer_t pbkt, pkt; pmix_byte_object_t bo; @@ -133,10 +135,10 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, pmix_proc_t proc; char *data; size_t sz, n; - pmix_peer_t *peer; pmix_output_verbose(2, pmix_server_globals.get_output, - "recvd GET"); + "%s recvd GET", + PMIX_NAME_PRINT(&pmix_globals.myid)); /* setup */ memset(nspace, 0, sizeof(nspace)); @@ -191,13 +193,19 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, /* find the nspace object for this client */ nptr = NULL; - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(nspace, ns->nspace)) { nptr = ns; break; } } + /* check if the nspace of the requestor is different from + * the nspace of the target process */ + if (!PMIX_CHECK_NSPACE(nspace, cd->peer->info->pname.nspace)) { + diffnspace = true; + } + pmix_output_verbose(2, pmix_server_globals.get_output, "%s:%d EXECUTE GET FOR %s:%d ON BEHALF OF %s:%d", pmix_globals.myid.nspace, @@ -294,10 +302,10 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, return PMIX_SUCCESS; } - /* this nspace is known, so we can process the request. - * if the rank is wildcard, then they are asking for the - * job-level info for this nspace - provide it */ - if (PMIX_RANK_WILDCARD == rank) { + /* the target nspace is known, so we can process the request. + * if the rank is wildcard, or the nspace is different, then + * they are asking for the job-level info for this nspace - provide it */ + if (PMIX_RANK_WILDCARD == rank || diffnspace) { /* see if we have the job-level info - we won't have it * if we have no local procs and haven't already asked * for it, so there is no guarantee we have it */ @@ -309,21 +317,32 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, * can retrieve the info from that GDS. Otherwise, * we need to retrieve it from our own */ PMIX_CONSTRUCT(&cb, pmix_cb_t); - peer = pmix_globals.mypeer; /* this data is for a local client, so give the gds the * option of returning a complete copy of the data, * or returning a pointer to local storage */ cb.proc = &proc; cb.scope = PMIX_SCOPE_UNDEF; cb.copy = false; - PMIX_GDS_FETCH_KV(rc, peer, &cb); + PMIX_GDS_FETCH_KV(rc, pmix_globals.mypeer, &cb); if (PMIX_SUCCESS != rc) { PMIX_DESTRUCT(&cb); return rc; } + /* if the requested rank is not WILDCARD, then retrieve the + * job-specific data for that rank - a scope of UNDEF + * will direct the GDS to provide it. Anything found will + * simply be added to the cb.kvs list */ + if (PMIX_RANK_WILDCARD != rank) { + proc.rank = rank; + PMIX_GDS_FETCH_KV(rc, pmix_globals.mypeer, &cb); + if (PMIX_SUCCESS != rc) { + PMIX_DESTRUCT(&cb); + return rc; + } + } PMIX_CONSTRUCT(&pkt, pmix_buffer_t); /* assemble the provided data into a byte object */ - PMIX_GDS_ASSEMB_KVS_REQ(rc, peer, &proc, &cb.kvs, &pkt, cd); + PMIX_GDS_ASSEMB_KVS_REQ(rc, pmix_globals.mypeer, &proc, &cb.kvs, &pkt, cd); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); PMIX_DESTRUCT(&cb); @@ -333,7 +352,7 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf, PMIX_DESTRUCT(&pkt); /* pack it into the payload */ PMIX_CONSTRUCT(&pbkt, pmix_buffer_t); - PMIX_BFROPS_PACK(rc, cd->peer, &pbkt, &bo, 1, PMIX_BYTE_OBJECT); + PMIX_BFROPS_PACK(rc, pmix_globals.mypeer, &pbkt, &bo, 1, PMIX_BYTE_OBJECT); free(bo.bytes); if (PMIX_SUCCESS != rc) { PMIX_ERROR_LOG(rc); @@ -604,6 +623,7 @@ static pmix_status_t _satisfy_request(pmix_namespace_t *nptr, pmix_rank_t rank, char *data = NULL; size_t sz = 0; pmix_scope_t scope = PMIX_SCOPE_UNDEF; + bool diffnspace = false; pmix_output_verbose(2, pmix_server_globals.get_output, "%s:%d SATISFY REQUEST CALLED", @@ -617,10 +637,18 @@ static pmix_status_t _satisfy_request(pmix_namespace_t *nptr, pmix_rank_t rank, PMIX_CONSTRUCT(&pbkt, pmix_buffer_t); pmix_strncpy(proc.nspace, nptr->nspace, PMIX_MAX_NSLEN); - /* if we have local clients of this nspace, then we use - * the corresponding GDS to retrieve the data. Otherwise, - * the data will have been stored under our GDS */ - if (0 < nptr->nlocalprocs) { + if (!PMIX_CHECK_NSPACE(nptr->nspace, cd->peer->info->pname.nspace)) { + diffnspace = true; + } + + /* if rank is PMIX_RANK_UNDEF, then it was stored in our GDS */ + if (PMIX_RANK_UNDEF == rank) { + scope = PMIX_GLOBAL; // we have to search everywhere + peer = pmix_globals.mypeer; + } else if (0 < nptr->nlocalprocs) { + /* if we have local clients of this nspace, then we use + * the corresponding GDS to retrieve the data. Otherwise, + * the data will have been stored under our GDS */ if (local) { *local = true; } @@ -660,8 +688,7 @@ static pmix_status_t _satisfy_request(pmix_namespace_t *nptr, pmix_rank_t rank, /* if they are asking about a rank from an nspace different * from their own, or they gave a rank of "wildcard", then * include a copy of the job-level info */ - if (PMIX_RANK_WILDCARD == rank || - 0 != strncmp(nptr->nspace, cd->peer->info->pname.nspace, PMIX_MAX_NSLEN)) { + if (PMIX_RANK_WILDCARD == rank || diffnspace) { proc.rank = PMIX_RANK_WILDCARD; PMIX_CONSTRUCT(&cb, pmix_cb_t); /* this data is requested by a local client, so give the gds the option @@ -674,7 +701,7 @@ static pmix_status_t _satisfy_request(pmix_namespace_t *nptr, pmix_rank_t rank, if (PMIX_SUCCESS == rc) { PMIX_CONSTRUCT(&pkt, pmix_buffer_t); /* assemble the provided data into a byte object */ - PMIX_GDS_ASSEMB_KVS_REQ(rc, cd->peer, &proc, &cb.kvs, &pkt, cd); + PMIX_GDS_ASSEMB_KVS_REQ(rc, pmix_globals.mypeer, &proc, &cb.kvs, &pkt, cd); if (rc != PMIX_SUCCESS) { PMIX_ERROR_LOG(rc); PMIX_DESTRUCT(&pkt); @@ -720,7 +747,8 @@ static pmix_status_t _satisfy_request(pmix_namespace_t *nptr, pmix_rank_t rank, /* retrieve the data for the specific rank they are asking about */ if (PMIX_RANK_WILDCARD != rank) { - if (!PMIX_PROC_IS_SERVER(peer) && !peer->commit_cnt) { + if (!PMIX_PROC_IS_SERVER(peer) && 0 == peer->commit_cnt) { + PMIX_ERROR_LOG(PMIX_ERR_NOT_FOUND); /* this condition works only for local requests, server does * count commits for local ranks, and check this count when * local request. @@ -743,7 +771,11 @@ static pmix_status_t _satisfy_request(pmix_namespace_t *nptr, pmix_rank_t rank, found = true; PMIX_CONSTRUCT(&pkt, pmix_buffer_t); /* assemble the provided data into a byte object */ - PMIX_GDS_ASSEMB_KVS_REQ(rc, cd->peer, &proc, &cb.kvs, &pkt, cd); + if (PMIX_RANK_UNDEF == rank || diffnspace) { + PMIX_GDS_ASSEMB_KVS_REQ(rc, pmix_globals.mypeer, &proc, &cb.kvs, &pkt, cd); + } else { + PMIX_GDS_ASSEMB_KVS_REQ(rc, cd->peer, &proc, &cb.kvs, &pkt, cd); + } if (rc != PMIX_SUCCESS) { PMIX_ERROR_LOG(rc); PMIX_DESTRUCT(&pkt); @@ -789,6 +821,7 @@ static pmix_status_t _satisfy_request(pmix_namespace_t *nptr, pmix_rank_t rank, } PMIX_DESTRUCT(&cb); } + PMIX_UNLOAD_BUFFER(&pbkt, data, sz); PMIX_DESTRUCT(&pbkt); @@ -896,7 +929,7 @@ static void _process_dmdx_reply(int fd, short args, void *cbdata) /* find the nspace object for the proc whose data is being received */ nptr = NULL; - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(caddy->lcd->proc.nspace, ns->nspace)) { nptr = ns; break; @@ -910,7 +943,7 @@ static void _process_dmdx_reply(int fd, short args, void *cbdata) nptr = PMIX_NEW(pmix_namespace_t); nptr->nspace = strdup(caddy->lcd->proc.nspace); /* add to the list */ - pmix_list_append(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); } /* if the request was successfully satisfied, then store the data. diff --git a/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server_ops.c b/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server_ops.c index 5f7ad645f8..37ec6c5b41 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server_ops.c +++ b/opal/mca/pmix/pmix3x/pmix/src/server/pmix_server_ops.c @@ -425,7 +425,7 @@ static pmix_server_trkr_t* new_tracker(char *id, pmix_proc_t *procs, } /* is this nspace known to us? */ nptr = NULL; - PMIX_LIST_FOREACH(ns, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(ns, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(procs[i].nspace, ns->nspace)) { nptr = ns; break; @@ -583,10 +583,15 @@ pmix_status_t pmix_server_fence(pmix_server_caddy_t *cd, /* see if we are to collect data or enforce a timeout - we don't internally care * about any other directives */ for (n=0; n < ninfo; n++) { - if (0 == strcmp(info[n].key, PMIX_COLLECT_DATA)) { - collect_data = true; - } else if (0 == strncmp(info[n].key, PMIX_TIMEOUT, PMIX_MAX_KEYLEN)) { - tv.tv_sec = info[n].value.data.uint32; + if (PMIX_CHECK_KEY(&info[n], PMIX_COLLECT_DATA)) { + collect_data = PMIX_INFO_TRUE(&info[n]); + } else if (PMIX_CHECK_KEY(&info[n], PMIX_TIMEOUT)) { + PMIX_VALUE_GET_NUMBER(rc, &info[n].value, tv.tv_sec, uint32_t); + if (PMIX_SUCCESS != rc) { + PMIX_PROC_FREE(procs, nprocs); + PMIX_INFO_FREE(info, ninfo); + return rc; + } } } } @@ -2738,7 +2743,7 @@ pmix_status_t pmix_server_job_ctrl(pmix_peer_t *peer, for (n=0; n < cd->ntargets; n++) { /* find the nspace of this proc */ nptr = NULL; - PMIX_LIST_FOREACH(tmp, &pmix_server_globals.nspaces, pmix_namespace_t) { + PMIX_LIST_FOREACH(tmp, &pmix_globals.nspaces, pmix_namespace_t) { if (0 == strcmp(tmp->nspace, cd->targets[n].nspace)) { nptr = tmp; break; @@ -2751,7 +2756,7 @@ pmix_status_t pmix_server_job_ctrl(pmix_peer_t *peer, goto exit; } nptr->nspace = strdup(cd->targets[n].nspace); - pmix_list_append(&pmix_server_globals.nspaces, &nptr->super); + pmix_list_append(&pmix_globals.nspaces, &nptr->super); } /* if the rank is wildcard, then we use the epilog for the nspace */ if (PMIX_RANK_WILDCARD == cd->targets[n].rank) { @@ -2805,7 +2810,7 @@ pmix_status_t pmix_server_job_ctrl(pmix_peer_t *peer, cnt = 0; // track how many infos are cleanup related for (n=0; n < cd->ninfo; n++) { - if (0 == strncmp(cd->info[n].key, PMIX_REGISTER_CLEANUP, PMIX_MAX_KEYLEN)) { + if (PMIX_CHECK_KEY(&cd->info[n], PMIX_REGISTER_CLEANUP)) { ++cnt; if (PMIX_STRING != cd->info[n].value.type || NULL == cd->info[n].value.data.string) { @@ -2821,7 +2826,7 @@ pmix_status_t pmix_server_job_ctrl(pmix_peer_t *peer, } cf->path = strdup(cd->info[n].value.data.string); pmix_list_append(&cachefiles, &cf->super); - } else if (0 == strncmp(cd->info[n].key, PMIX_REGISTER_CLEANUP_DIR, PMIX_MAX_KEYLEN)) { + } else if (PMIX_CHECK_KEY(&cd->info[n], PMIX_REGISTER_CLEANUP_DIR)) { ++cnt; if (PMIX_STRING != cd->info[n].value.type || NULL == cd->info[n].value.data.string) { @@ -2837,10 +2842,10 @@ pmix_status_t pmix_server_job_ctrl(pmix_peer_t *peer, } cdir->path = strdup(cd->info[n].value.data.string); pmix_list_append(&cachedirs, &cdir->super); - } else if (0 == strncmp(cd->info[n].key, PMIX_CLEANUP_RECURSIVE, PMIX_MAX_KEYLEN)) { + } else if (PMIX_CHECK_KEY(&cd->info[n], PMIX_CLEANUP_RECURSIVE)) { recurse = PMIX_INFO_TRUE(&cd->info[n]); ++cnt; - } else if (0 == strncmp(cd->info[n].key, PMIX_CLEANUP_IGNORE, PMIX_MAX_KEYLEN)) { + } else if (PMIX_CHECK_KEY(&cd->info[n], PMIX_CLEANUP_IGNORE)) { if (PMIX_STRING != cd->info[n].value.type || NULL == cd->info[n].value.data.string) { /* return an error */ @@ -2856,7 +2861,7 @@ pmix_status_t pmix_server_job_ctrl(pmix_peer_t *peer, cf->path = strdup(cd->info[n].value.data.string); pmix_list_append(&ignorefiles, &cf->super); ++cnt; - } else if (0 == strncmp(cd->info[n].key, PMIX_CLEANUP_LEAVE_TOPDIR, PMIX_MAX_KEYLEN)) { + } else if (PMIX_CHECK_KEY(&cd->info[n], PMIX_CLEANUP_LEAVE_TOPDIR)) { leave_topdir = PMIX_INFO_TRUE(&cd->info[n]); ++cnt; } @@ -3274,8 +3279,7 @@ pmix_status_t pmix_server_iofreg(pmix_peer_t *peer, continue; } /* do we already have this source for this peer? */ - if (0 == strncmp(cd->procs[n].nspace, req->pname.nspace, PMIX_MAX_NSLEN) && - (PMIX_RANK_WILDCARD == req->pname.rank || cd->procs[n].rank == req->pname.rank)) { + if (PMIX_CHECK_PROCID(&cd->procs[n], &req->pname)) { match = true; if ((req->channels & cd->channels) != cd->channels) { /* this is a channel update */ diff --git a/opal/mca/pmix/pmix3x/pmix/src/tool/pmix_tool.c b/opal/mca/pmix/pmix3x/pmix/src/tool/pmix_tool.c index d2b9c9acbe..585ea08fe4 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/tool/pmix_tool.c +++ b/opal/mca/pmix/pmix3x/pmix/src/tool/pmix_tool.c @@ -50,7 +50,9 @@ #endif /* HAVE_DIRENT_H */ #include PMIX_EVENT_HEADER +#if ! PMIX_HAVE_LIBEV #include PMIX_EVENT2_THREAD_HEADER +#endif #include "src/class/pmix_list.h" #include "src/util/argv.h" @@ -789,7 +791,7 @@ pmix_status_t pmix_tool_init_info(void) pmix_kval_t *kptr; pmix_status_t rc; pmix_proc_t wildcard; - char hostname[PMIX_MAX_NSLEN]; + char hostname[PMIX_MAXHOSTNAMELEN] = {0}; pmix_strncpy(wildcard.nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN); wildcard.rank = pmix_globals.myid.rank; @@ -1027,9 +1029,9 @@ pmix_status_t pmix_tool_init_info(void) /* hostname */ if (NULL != pmix_globals.hostname) { - pmix_strncpy(hostname, pmix_globals.hostname, PMIX_MAX_NSLEN); + pmix_strncpy(hostname, pmix_globals.hostname, PMIX_MAXHOSTNAMELEN); } else { - gethostname(hostname, PMIX_MAX_NSLEN); + gethostname(hostname, PMIX_MAXHOSTNAMELEN-1); } kptr = PMIX_NEW(pmix_kval_t); kptr->key = strdup(PMIX_HOSTNAME); @@ -1227,7 +1229,6 @@ PMIX_EXPORT pmix_status_t PMIx_tool_finalize(void) PMIX_LIST_DESTRUCT(&pmix_server_globals.local_reqs); PMIX_LIST_DESTRUCT(&pmix_server_globals.gdata); PMIX_LIST_DESTRUCT(&pmix_server_globals.events); - PMIX_LIST_DESTRUCT(&pmix_server_globals.nspaces); PMIX_LIST_DESTRUCT(&pmix_server_globals.iof); } diff --git a/opal/mca/pmix/pmix3x/pmix/src/util/compress.c b/opal/mca/pmix/pmix3x/pmix/src/util/compress.c index 867a3d5e57..d71cdf37c6 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/util/compress.c +++ b/opal/mca/pmix/pmix3x/pmix/src/util/compress.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. * Copyright (c) 2017 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * @@ -31,6 +31,7 @@ bool pmix_util_compress_string(char *instring, size_t len, outlen; uint8_t *tmp, *ptr; uint32_t inlen; + int rc; /* set default output */ *outbytes = NULL; @@ -43,7 +44,6 @@ bool pmix_util_compress_string(char *instring, /* get an upper bound on the required output storage */ len = deflateBound(&strm, inlen); if (NULL == (tmp = (uint8_t*)malloc(len))) { - *outbytes = NULL; return false; } strm.next_in = (uint8_t*)instring; @@ -54,8 +54,12 @@ bool pmix_util_compress_string(char *instring, strm.avail_out = len; strm.next_out = tmp; - deflate (&strm, Z_FINISH); + rc = deflate (&strm, Z_FINISH); deflateEnd (&strm); + if (Z_OK != rc) { + free(tmp); + return false; + } /* allocate 4 bytes beyond the size reqd by zlib so we * can pass the size of the uncompressed string to the diff --git a/opal/mca/pmix/pmix3x/pmix/src/util/name_fns.c b/opal/mca/pmix/pmix3x/pmix/src/util/name_fns.c index 14f19aef02..96b46ea9d5 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/util/name_fns.c +++ b/opal/mca/pmix/pmix3x/pmix/src/util/name_fns.c @@ -12,7 +12,7 @@ * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014-2016 Research Organization for Information Science * and Technology (RIST). 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 @@ -98,6 +98,7 @@ char* pmix_util_print_name_args(const pmix_proc_t *name) { pmix_print_args_buffers_t *ptr; char *rank; + int index; /* get the next buffer */ ptr = get_print_name_buffer(); @@ -105,29 +106,36 @@ char* pmix_util_print_name_args(const pmix_proc_t *name) PMIX_ERROR_LOG(PMIX_ERR_OUT_OF_RESOURCE); return pmix_print_args_null; } - /* cycle around the ring */ - if (PMIX_PRINT_NAME_ARG_NUM_BUFS == ptr->cntr) { - ptr->cntr = 0; - } /* protect against NULL names */ if (NULL == name) { - snprintf(ptr->buffers[ptr->cntr++], PMIX_PRINT_NAME_ARGS_MAX_SIZE, "[NO-NAME]"); - return ptr->buffers[ptr->cntr-1]; + index = ptr->cntr; + snprintf(ptr->buffers[index], PMIX_PRINT_NAME_ARGS_MAX_SIZE, "[NO-NAME]"); + ptr->cntr++; + if (PMIX_PRINT_NAME_ARG_NUM_BUFS == ptr->cntr) { + ptr->cntr = 0; + } + return ptr->buffers[index]; } rank = pmix_util_print_rank(name->rank); - snprintf(ptr->buffers[ptr->cntr++], + index = ptr->cntr; + snprintf(ptr->buffers[index], PMIX_PRINT_NAME_ARGS_MAX_SIZE, - "[%s,%s]", name->nspace, rank); + "[%s:%s]", name->nspace, rank); + ptr->cntr++; + if (PMIX_PRINT_NAME_ARG_NUM_BUFS == ptr->cntr) { + ptr->cntr = 0; + } - return ptr->buffers[ptr->cntr-1]; + return ptr->buffers[index]; } char* pmix_util_print_rank(const pmix_rank_t vpid) { pmix_print_args_buffers_t *ptr; + int index; ptr = get_print_name_buffer(); @@ -136,19 +144,19 @@ char* pmix_util_print_rank(const pmix_rank_t vpid) return pmix_print_args_null; } - /* cycle around the ring */ - if (PMIX_PRINT_NAME_ARG_NUM_BUFS == ptr->cntr) { - ptr->cntr = 0; - } - + index = ptr->cntr; if (PMIX_RANK_UNDEF == vpid) { - snprintf(ptr->buffers[ptr->cntr++], PMIX_PRINT_NAME_ARGS_MAX_SIZE, "UNDEF"); + snprintf(ptr->buffers[index], PMIX_PRINT_NAME_ARGS_MAX_SIZE, "UNDEF"); } else if (PMIX_RANK_WILDCARD == vpid) { - snprintf(ptr->buffers[ptr->cntr++], PMIX_PRINT_NAME_ARGS_MAX_SIZE, "WILDCARD"); + snprintf(ptr->buffers[index], PMIX_PRINT_NAME_ARGS_MAX_SIZE, "WILDCARD"); } else { - snprintf(ptr->buffers[ptr->cntr++], + snprintf(ptr->buffers[index], PMIX_PRINT_NAME_ARGS_MAX_SIZE, "%ld", (long)vpid); } - return ptr->buffers[ptr->cntr-1]; + ptr->cntr++; + if (PMIX_PRINT_NAME_ARG_NUM_BUFS == ptr->cntr) { + ptr->cntr = 0; + } + return ptr->buffers[index]; } diff --git a/opal/mca/pmix/pmix3x/pmix/src/util/output.c b/opal/mca/pmix/pmix3x/pmix/src/util/output.c index cf73f50700..4e90280c8a 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/util/output.c +++ b/opal/mca/pmix/pmix3x/pmix/src/util/output.c @@ -125,7 +125,7 @@ PMIX_CLASS_INSTANCE(pmix_output_stream_t, pmix_object_t, construct, destruct); bool pmix_output_init(void) { int i; - char hostname[PMIX_MAXHOSTNAMELEN]; + char hostname[PMIX_MAXHOSTNAMELEN] = {0}; char *str; if (initialized) { @@ -176,7 +176,7 @@ bool pmix_output_init(void) } else { verbose.lds_want_stderr = true; } - gethostname(hostname, sizeof(hostname)); + gethostname(hostname, sizeof(hostname)-1); hostname[sizeof(hostname)-1] = '\0'; if (0 > asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid())) { return PMIX_ERR_NOMEM; @@ -256,7 +256,7 @@ bool pmix_output_switch(int output_id, bool enable) void pmix_output_reopen_all(void) { char *str; - char hostname[PMIX_MAXHOSTNAMELEN]; + char hostname[PMIX_MAXHOSTNAMELEN] = {0}; str = getenv("PMIX_OUTPUT_STDERR_FD"); if (NULL != str) { diff --git a/opal/mca/pmix/pmix3x/pmix/src/util/pif.h b/opal/mca/pmix/pmix3x/pmix/src/util/pif.h index fb9f1b79a2..57ed1bfd74 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/util/pif.h +++ b/opal/mca/pmix/pmix3x/pmix/src/util/pif.h @@ -13,7 +13,7 @@ * reserved. * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2016 Intel, Inc. All rights reserved. + * Copyright (c) 2016-2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -38,9 +38,7 @@ #include #endif -#ifndef IF_NAMESIZE -#define IF_NAMESIZE 32 -#endif +#define PMIX_IF_NAMESIZE 256 BEGIN_C_DECLS diff --git a/opal/mca/pmix/pmix3x/pmix/src/util/pmix_environ.c b/opal/mca/pmix/pmix3x/pmix/src/util/pmix_environ.c index 1e1cfaaa88..2662a86bff 100644 --- a/opal/mca/pmix/pmix3x/pmix/src/util/pmix_environ.c +++ b/opal/mca/pmix/pmix3x/pmix/src/util/pmix_environ.c @@ -12,8 +12,10 @@ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2019 Intel, 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 @@ -30,10 +32,12 @@ #include #include "src/util/printf.h" +#include "src/util/error.h" #include "src/util/argv.h" #include "src/util/pmix_environ.h" #define PMIX_DEFAULT_TMPDIR "/tmp" +#define PMIX_MAX_ENVAR_LENGTH 100000 /* * Merge two environ-like char arrays, ensuring that there are no @@ -74,7 +78,7 @@ char **pmix_environ_merge(char **minor, char **major) pmix_setenv(minor[i], NULL, false, &ret); } else { - /* strdup minor[i] in case it's a constat string */ + /* strdup minor[i] in case it's a constant string */ name = strdup(minor[i]); value = name + (value - minor[i]); @@ -99,9 +103,60 @@ char **pmix_environ_merge(char **minor, char **major) int i; char *newvalue, *compare; size_t len; + bool valid; + + /* Check the bozo case */ + if( NULL == env ) { + return PMIX_ERR_BAD_PARAM; + } + + if (NULL != value) { + /* check the string for unacceptable length - i.e., ensure + * it is NULL-terminated */ + valid = false; + for (i=0; i < PMIX_MAX_ENVAR_LENGTH; i++) { + if ('\0' == value[i]) { + valid = true; + break; + } + } + if (!valid) { + PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); + return PMIX_ERR_BAD_PARAM; + } + } + + /* If this is the "environ" array, use putenv or setenv */ + if (*env == environ) { + /* THIS IS POTENTIALLY A MEMORY LEAK! But I am doing it + because so that we don't violate the law of least + astonishmet for PMIX developers (i.e., those that don't + check the return code of pmix_setenv() and notice that we + returned an error if you passed in the real environ) */ +#if defined (HAVE_SETENV) + if (NULL == value) { + /* this is actually an unsetenv request */ + unsetenv(name); + } else { + setenv(name, value, overwrite); + } +#else + /* Make the new value */ + if (NULL == value) { + i = asprintf(&newvalue, "%s=", name); + } else { + i = asprintf(&newvalue, "%s=%s", name, value); + } + if (NULL == newvalue || 0 > i) { + return PMIX_ERR_OUT_OF_RESOURCE; + } + putenv(newvalue); + /* cannot free it as putenv doesn't copy the value */ +#endif + return PMIX_SUCCESS; + } /* Make the new value */ - if (NULL == value) { i = asprintf(&newvalue, "%s=", name); } else { @@ -111,28 +166,13 @@ char **pmix_environ_merge(char **minor, char **major) return PMIX_ERR_OUT_OF_RESOURCE; } - /* Check the bozo case */ - - if( NULL == env ) { - return PMIX_ERR_BAD_PARAM; - } else if (NULL == *env) { + if (NULL == *env) { i = 0; pmix_argv_append(&i, env, newvalue); free(newvalue); return PMIX_SUCCESS; } - /* If this is the "environ" array, use putenv */ - if( *env == environ ) { - /* THIS IS POTENTIALLY A MEMORY LEAK! But I am doing it - because so that we don't violate the law of least - astonishmet for PMIX developers (i.e., those that don't - check the return code of pmix_setenv() and notice that we - returned an error if you passed in the real environ) */ - putenv(newvalue); - return PMIX_SUCCESS; - } - /* Make something easy to compare to */ i = asprintf(&compare, "%s=", name); diff --git a/opal/mca/pmix/pmix3x/pmix/test/cli_stages.c b/opal/mca/pmix/pmix3x/pmix/test/cli_stages.c index ecd41c2bd4..5fbfec419d 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/cli_stages.c +++ b/opal/mca/pmix/pmix3x/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, - EV_READ|EV_PERSIST, callback, cli); - event_add(cli->ev,NULL); + cli->ev = pmix_event_new(ebase, sd, + EV_READ|EV_PERSIST, callback, cli); + 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; @@ -105,12 +105,12 @@ void cli_disconnect(cli_info_t *cli) } if( NULL == cli->ev ){ - TEST_ERROR(("Bad ev = NULL of rank = %d ", cli->sd, cli_rank(cli))); + TEST_ERROR(("Bad ev = NULL of rank = %d ", cli_rank(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/pmix3x/pmix/test/cli_stages.h b/opal/mca/pmix/pmix3x/pmix/test/cli_stages.h index b716480b0a..011023d7a7 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/cli_stages.h +++ b/opal/mca/pmix/pmix3x/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. @@ -56,7 +56,7 @@ extern bool test_abort; int cli_rank(cli_info_t *cli); 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); void cli_finalize(cli_info_t *cli); void cli_disconnect(cli_info_t *cli); void cli_terminate(cli_info_t *cli); diff --git a/opal/mca/pmix/pmix3x/pmix/test/pmi_client.c b/opal/mca/pmix/pmix3x/pmix/test/pmi_client.c index ad21f6db3c..819429b4fd 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/pmi_client.c +++ b/opal/mca/pmix/pmix3x/pmix/test/pmi_client.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ @@ -24,6 +24,9 @@ static int _legacy = 0; /* Verbose level 0-silent, 1-fatal, 2-error, 3+ debug*/ static int _verbose = 1; +static int spawned, size, rank=-1, appnum; +static char jobid[255]; + static void log_fatal(const char *format, ...) { va_list arglist; @@ -36,7 +39,7 @@ static void log_fatal(const char *format, ...) va_end(arglist); return; } - fprintf(stderr, "FATAL: %s", output); + fprintf(stderr, "%d:FATAL: %s", rank, output); free(output); } va_end(arglist); @@ -54,7 +57,7 @@ static void log_error(const char *format, ...) va_end(arglist); return; } - fprintf(stderr, "ERROR: %s", output); + fprintf(stderr, "%d:ERROR: %s", rank, output); free(output); } va_end(arglist); @@ -72,7 +75,7 @@ static void log_info(const char *format, ...) va_end(arglist); return; } - fprintf(stderr, "INFO: %s", output); + fprintf(stderr, "%d:INFO: %s", rank, output); free(output); } va_end(arglist); @@ -81,7 +84,7 @@ static void log_info(const char *format, ...) #define log_assert(e, msg) \ do { \ if (!(e)) { \ - log_fatal("%s at %s:%d\n", msg, __func__, __LINE__); \ + log_fatal("%d:%s at %s:%d\n", rank, msg, __func__, __LINE__); \ rc = -1; \ } \ } while (0) @@ -99,10 +102,6 @@ static int test_item5(void); static int test_item6(void); static int test_item7(void); -static int spawned, size, rank, appnum; -static char jobid[255]; - - int main(int argc, char **argv) { int ret = 0; @@ -372,21 +371,24 @@ static int test_item6(void) { int rc = 0; char val[100]; - const char *tkey = __func__; + char *tkey; const char *tval = __FILE__; + asprintf(&tkey, "%d:%s", rank, __func__); if (PMI_SUCCESS != (rc = PMI_KVS_Put(jobid, tkey, tval))) { log_fatal("PMI_KVS_Put %d\n", rc); + free(tkey); return rc; } if (PMI_SUCCESS != (rc = PMI_KVS_Get(jobid, tkey, val, sizeof(val)))) { log_fatal("PMI_KVS_Get %d\n", rc); + free(tkey); return rc; } log_info("tkey=%s tval=%s val=%s\n", tkey, tval, val); - + free(tkey); log_assert(!strcmp(tval, val), "value does not meet expectation"); return rc; @@ -398,16 +400,16 @@ static int test_item7(void) char tkey[100]; char tval[100]; char val[100]; - int i = 0; + int i = 0, j; + +log_info("TEST7\n"); for (i = 0; i < size; i++) { - sprintf(tkey, "KEY-%d", i); + sprintf(tkey, "%d:KEY-%d", rank, i); sprintf(tval, "VALUE-%d", i); - if (i == rank) { - if (PMI_SUCCESS != (rc = PMI_KVS_Put(jobid, tkey, tval))) { - log_fatal("PMI_KVS_Put [%s=%s] %d\n", tkey, tval, rc); - return rc; - } + if (PMI_SUCCESS != (rc = PMI_KVS_Put(jobid, tkey, tval))) { + log_fatal("PMI_KVS_Put [%s=%s] %d\n", tkey, tval, rc); + return rc; } } @@ -416,22 +418,27 @@ static int test_item7(void) return rc; } + + log_info("BARRIER\n"); if (PMI_SUCCESS != (rc = PMI_Barrier())) { log_fatal("PMI_Barrier %d\n", rc); return rc; } for (i = 0; i < size; i++) { - sprintf(tkey, "KEY-%d", i); - sprintf(tval, "VALUE-%d", i); - if (PMI_SUCCESS != (rc = PMI_KVS_Get(jobid, tkey, val, sizeof(val)))) { - log_fatal("PMI_KVS_Get [%s=?] %d\n", tkey, rc); - return rc; + for (j=0; j < size; j++) { + sprintf(tkey, "%d:KEY-%d", i, j); + sprintf(tval, "VALUE-%d", j); + log_info("Get key %s\n", tkey); + if (PMI_SUCCESS != (rc = PMI_KVS_Get(jobid, tkey, val, sizeof(val)))) { + log_fatal("PMI_KVS_Get [%s=?] %d\n", tkey, rc); + return rc; + } + + log_info("tkey=%s tval=%s val=%s\n", tkey, tval, val); + + log_assert(!strcmp(tval, val), "value does not meet expectation"); } - - log_info("tkey=%s tval=%s val=%s\n", tkey, tval, val); - - log_assert(!strcmp(tval, val), "value does not meet expectation"); } return rc; diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/Makefile.am b/opal/mca/pmix/pmix3x/pmix/test/simple/Makefile.am index 8ee50d6ca8..5ab9f568bb 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/Makefile.am +++ b/opal/mca/pmix/pmix3x/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 @@ -85,7 +85,7 @@ simplegacy_SOURCES = $(headers) \ simplegacy.c simplegacy_LDFLAGS = $(PMIX_PKG_CONFIG_LDFLAGS) simplegacy_LDADD = \ - $(top_builddir)/src/libpmix.la + $(top_builddir)/src/libpmi.la simptimeout_SOURCES = $(headers) \ simptimeout.c diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/gwtest.c b/opal/mca/pmix/pmix3x/pmix/test/simple/gwtest.c index 2f1fae4701..3d9f8ee8d7 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/gwtest.c +++ b/opal/mca/pmix/pmix3x/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. @@ -392,9 +392,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 +1023,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/pmix3x/pmix/test/simple/quietclient.c b/opal/mca/pmix/pmix3x/pmix/test/simple/quietclient.c index 428ba4e341..d91e7e58e3 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/quietclient.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/quietclient.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 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -103,12 +103,15 @@ int main(int argc, char **argv) pmix_value_t *val = &value; char *tmp; pmix_proc_t proc; - uint32_t nprocs, n; + uint32_t nprocs, n, k, nlocal; int cnt, j; volatile bool active; pmix_info_t *iptr; size_t ninfo; pmix_status_t code; + char **peers; + bool all_local, local; + pmix_rank_t *locals = NULL; /* init us and declare we are a test programming model */ PMIX_INFO_CREATE(iptr, 2); @@ -152,11 +155,11 @@ int main(int argc, char **argv) usleep(10); } - /* get our universe size */ + /* get our job size */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %s", + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get job size failed: %s", myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } @@ -173,6 +176,27 @@ int main(int argc, char **argv) goto done; } + /* get a list of our local peers */ + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_LOCAL_PEERS, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get local peers failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); + goto done; + } + /* split the returned string to get the rank of each local peer */ + peers = pmix_argv_split(val->data.string, ','); + PMIX_VALUE_RELEASE(val); + nlocal = pmix_argv_count(peers); + if (nprocs == nlocal) { + all_local = true; + } else { + all_local = false; + locals = (pmix_rank_t*)malloc(pmix_argv_count(peers) * sizeof(pmix_rank_t)); + for (cnt=0; NULL != peers[cnt]; cnt++) { + locals[cnt] = strtoul(peers[cnt], NULL, 10); + } + } + pmix_argv_free(peers); + for (cnt=0; cnt < MAXCNT; cnt++) { (void)asprintf(&tmp, "%s-%d-local-%d", myproc.nspace, myproc.rank, cnt); value.type = PMIX_UINT64; @@ -213,43 +237,68 @@ int main(int argc, char **argv) for (j=0; j <= cnt; j++) { for (n=0; n < nprocs; n++) { proc.rank = n; - (void)asprintf(&tmp, "%s-%d-local-%d", myproc.nspace, n, j); - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s failed: %s", - myproc.nspace, myproc.rank, j, tmp, PMIx_Error_string(rc)); - continue; + if (all_local) { + local = true; + } else { + local = false; + /* see if this proc is local to us */ + for (k=0; k < nlocal; k++) { + if (proc.rank == locals[k]) { + local = true; + break; + } + } } - if (NULL == val) { - pmix_output(0, "Client ns %s rank %d: NULL value returned", - myproc.nspace, myproc.rank); - break; - } - if (PMIX_UINT64 != val->type) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong type: %d", myproc.nspace, myproc.rank, j, tmp, val->type); - PMIX_VALUE_RELEASE(val); - free(tmp); - continue; - } - if (1234 != val->data.uint64) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong value: %d", myproc.nspace, myproc.rank, j, tmp, (int)val->data.uint64); - PMIX_VALUE_RELEASE(val); - free(tmp); - continue; - } - PMIX_VALUE_RELEASE(val); - free(tmp); - - if (n != myproc.rank) { - (void)asprintf(&tmp, "%s-%d-remote-%d", proc.nspace, n, j); + if (local) { + (void)asprintf(&tmp, "%s-%d-local-%d", myproc.nspace, n, j); if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { - /* this data should _not_ be found as we are on the same node - * and the data was "put" with a PMIX_REMOTE scope */ + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s failed: %s", + myproc.nspace, myproc.rank, j, tmp, PMIx_Error_string(rc)); + continue; + } + if (NULL == val) { + pmix_output(0, "Client ns %s rank %d: NULL value returned", + myproc.nspace, myproc.rank); + break; + } + if (PMIX_UINT64 != val->type) { + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong type: %d", myproc.nspace, myproc.rank, j, tmp, val->type); + PMIX_VALUE_RELEASE(val); + free(tmp); + continue; + } + if (1234 != val->data.uint64) { + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong value: %d", myproc.nspace, myproc.rank, j, tmp, (int)val->data.uint64); + PMIX_VALUE_RELEASE(val); + free(tmp); continue; } - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned remote data for a local proc", - myproc.nspace, myproc.rank, j, tmp); PMIX_VALUE_RELEASE(val); free(tmp); + + /* now check that we don't get data for a remote proc - note that we + * always can get our own remote data as we published it */ + if (proc.rank != myproc.rank) { + (void)asprintf(&tmp, "%s-%d-remote-%d", proc.nspace, n, j); + if (PMIX_SUCCESS == (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { + /* this data should _not_ be found as we are on the same node + * and the data was "put" with a PMIX_REMOTE scope */ + pmix_output(0, "ERROR: Client ns %s rank %d cnt %d: PMIx_Get %s returned remote data for a local proc", + myproc.nspace, myproc.rank, j, tmp); + } + PMIX_VALUE_RELEASE(val); + free(tmp); + } + } else { + (void)asprintf(&tmp, "%s-%d-remote-%d", proc.nspace, n, j); + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s failed for remote proc", + myproc.nspace, myproc.rank, j, tmp); + } + if (NULL != val) { + PMIX_VALUE_RELEASE(val); + } + free(tmp); } } } diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simpclient.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simpclient.c index ae5b4ababc..80aea14308 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simpclient.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simpclient.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 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -127,13 +127,16 @@ int main(int argc, char **argv) pmix_value_t *val = &value; char *tmp; pmix_proc_t proc; - uint32_t nprocs, n; + uint32_t nprocs, n, k, nlocal; int cnt, j; bool doabort = false; volatile bool active; pmix_info_t info, *iptr; size_t ninfo; pmix_status_t code; + char **peers; + bool all_local, local; + pmix_rank_t *locals = NULL; if (1 < argc) { if (0 == strcmp("-abort", argv[1])) { @@ -185,17 +188,17 @@ int main(int argc, char **argv) } - /* get our universe size */ + /* get our job size */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %s", + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get job size failed: %s", myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs); + pmix_output(0, "Client %s:%d job size %d", myproc.nspace, myproc.rank, nprocs); /* put a few values */ (void)asprintf(&tmp, "%s-%d-internal", myproc.nspace, myproc.rank); @@ -207,6 +210,27 @@ int main(int argc, char **argv) goto done; } + /* get a list of our local peers */ + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_LOCAL_PEERS, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get local peers failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); + goto done; + } + /* split the returned string to get the rank of each local peer */ + peers = pmix_argv_split(val->data.string, ','); + PMIX_VALUE_RELEASE(val); + nlocal = pmix_argv_count(peers); + if (nprocs == nlocal) { + all_local = true; + } else { + all_local = false; + locals = (pmix_rank_t*)malloc(pmix_argv_count(peers) * sizeof(pmix_rank_t)); + for (cnt=0; NULL != peers[cnt]; cnt++) { + locals[cnt] = strtoul(peers[cnt], NULL, 10); + } + } + pmix_argv_free(peers); + for (cnt=0; cnt < MAXCNT; cnt++) { (void)asprintf(&tmp, "%s-%d-local-%d", myproc.nspace, myproc.rank, cnt); value.type = PMIX_UINT64; @@ -247,43 +271,71 @@ int main(int argc, char **argv) for (j=0; j <= cnt; j++) { for (n=0; n < nprocs; n++) { proc.rank = n; - (void)asprintf(&tmp, "%s-%d-local-%d", myproc.nspace, n, j); - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s failed: %s", - myproc.nspace, myproc.rank, j, tmp, PMIx_Error_string(rc)); - continue; + if (all_local) { + local = true; + } else { + local = false; + /* see if this proc is local to us */ + for (k=0; k < nlocal; k++) { + if (proc.rank == locals[k]) { + local = true; + break; + } + } } - if (NULL == val) { - pmix_output(0, "Client ns %s rank %d: NULL value returned", - myproc.nspace, myproc.rank); - break; - } - if (PMIX_UINT64 != val->type) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong type: %d", myproc.nspace, myproc.rank, j, tmp, val->type); - PMIX_VALUE_RELEASE(val); - free(tmp); - continue; - } - if (1234 != val->data.uint64) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong value: %d", myproc.nspace, myproc.rank, j, tmp, (int)val->data.uint64); - PMIX_VALUE_RELEASE(val); - free(tmp); - continue; - } - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned correct", myproc.nspace, myproc.rank, j, tmp); - PMIX_VALUE_RELEASE(val); - free(tmp); - - if (n != myproc.rank) { - (void)asprintf(&tmp, "%s-%d-remote-%d", proc.nspace, n, j); + if (local) { + (void)asprintf(&tmp, "%s-%d-local-%d", myproc.nspace, n, j); if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { - /* this data should _not_ be found as we are on the same node - * and the data was "put" with a PMIX_REMOTE scope */ - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned correct", myproc.nspace, myproc.rank, j, tmp); + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s failed: %s", + myproc.nspace, myproc.rank, j, tmp, PMIx_Error_string(rc)); continue; } - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned remote data for a local proc", - myproc.nspace, myproc.rank, j, tmp); + if (NULL == val) { + pmix_output(0, "Client ns %s rank %d: NULL value returned", + myproc.nspace, myproc.rank); + break; + } + if (PMIX_UINT64 != val->type) { + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong type: %d", myproc.nspace, myproc.rank, j, tmp, val->type); + PMIX_VALUE_RELEASE(val); + free(tmp); + continue; + } + if (1234 != val->data.uint64) { + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong value: %d", myproc.nspace, myproc.rank, j, tmp, (int)val->data.uint64); + PMIX_VALUE_RELEASE(val); + free(tmp); + continue; + } + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned correct", myproc.nspace, myproc.rank, j, tmp); + PMIX_VALUE_RELEASE(val); + free(tmp); + + /* now check that we don't get data for a remote proc - note that we + * always can get our own remote data as we published it */ + if (proc.rank != myproc.rank) { + (void)asprintf(&tmp, "%s-%d-remote-%d", proc.nspace, n, j); + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { + /* this data should _not_ be found as we are on the same node + * and the data was "put" with a PMIX_REMOTE scope */ + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned correct", myproc.nspace, myproc.rank, j, tmp); + } else { + pmix_output(0, "ERROR: Client ns %s rank %d cnt %d: PMIx_Get %s returned remote data for a local proc", + myproc.nspace, myproc.rank, j, tmp); + } + if (NULL != val) { + PMIX_VALUE_RELEASE(val); + } + free(tmp); + } + } else { + (void)asprintf(&tmp, "%s-%d-remote-%d", proc.nspace, n, j); + if (PMIX_SUCCESS == (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned correct", myproc.nspace, myproc.rank, j, tmp); + } else { + pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s failed for remote proc", + myproc.nspace, myproc.rank, j, tmp); + } PMIX_VALUE_RELEASE(val); free(tmp); } @@ -321,7 +373,7 @@ int main(int argc, char **argv) /* log something */ PMIX_INFO_CONSTRUCT(&info); - PMIX_INFO_LOAD(&info, PMIX_LOG_STDERR, "test log msg", PMIX_STRING); + PMIX_INFO_LOAD(&info, PMIX_LOG_STDERR, "test log msg\n", PMIX_STRING); active = true; rc = PMIx_Log_nb(&info, 1, NULL, 0, opcbfunc, (void*)&active); if (PMIX_SUCCESS != rc) { diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simpdie.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simpdie.c index fd6a61eba4..cb0ae49022 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simpdie.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simpdie.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 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -97,16 +97,17 @@ int main(int argc, char **argv) } pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank); - /* get our universe size */ + /* get our job size */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %d", myproc.nspace, myproc.rank, rc); + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get job size failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs); + pmix_output(0, "Client %s:%d job size %d", myproc.nspace, myproc.rank, nprocs); completed = false; /* register our errhandler */ diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simpdmodex.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simpdmodex.c index c042f1948a..2a7e067d14 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simpdmodex.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simpdmodex.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 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -98,9 +98,12 @@ int main(int argc, char **argv) pmix_value_t *val = &value; char *tmp; pmix_proc_t proc; - uint32_t n, num_gets; + uint32_t n, num_gets, k, nlocal; bool active; bool dofence = true; + bool local, all_local; + char **peers; + pmix_rank_t *locals; if (NULL != getenv("PMIX_SIMPDMODEX_ASYNC")) { dofence = false; @@ -113,16 +116,17 @@ int main(int argc, char **argv) } pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank); - /* get our universe size */ + /* get our job size */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %d", myproc.nspace, myproc.rank, rc); + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get job size failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs); + pmix_output(0, "Client %s:%d job size %d", myproc.nspace, myproc.rank, nprocs); /* put a few values */ (void)asprintf(&tmp, "%s-%d-internal", myproc.nspace, myproc.rank); @@ -174,24 +178,60 @@ int main(int argc, char **argv) } } + /* get a list of our local peers */ + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_LOCAL_PEERS, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get local peers failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); + goto done; + } + /* split the returned string to get the rank of each local peer */ + peers = pmix_argv_split(val->data.string, ','); + PMIX_VALUE_RELEASE(val); + nlocal = pmix_argv_count(peers); + if (nprocs == nlocal) { + all_local = true; + } else { + all_local = false; + locals = (pmix_rank_t*)malloc(pmix_argv_count(peers) * sizeof(pmix_rank_t)); + for (n=0; NULL != peers[n]; n++) { + locals[n] = strtoul(peers[n], NULL, 10); + } + } + pmix_argv_free(peers); + /* get the committed data - ask for someone who doesn't exist as well */ num_gets = 0; for (n=0; n < nprocs; n++) { - (void)asprintf(&tmp, "%s-%d-local", myproc.nspace, n); - proc.rank = n; - if (PMIX_SUCCESS != (rc = PMIx_Get_nb(&proc, tmp, - NULL, 0, valcbfunc, tmp))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get %s failed: %d", myproc.nspace, n, tmp, rc); - goto done; + if (all_local) { + local = true; + } else { + local = false; + /* see if this proc is local to us */ + for (k=0; k < nlocal; k++) { + if (proc.rank == locals[k]) { + local = true; + break; + } + } } - ++num_gets; - (void)asprintf(&tmp, "%s-%d-remote", myproc.nspace, n); - if (PMIX_SUCCESS != (rc = PMIx_Get_nb(&proc, tmp, - NULL, 0, valcbfunc, tmp))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get %s failed: %d", myproc.nspace, n, tmp, rc); - goto done; + if (local) { + (void)asprintf(&tmp, "%s-%d-local", myproc.nspace, n); + proc.rank = n; + if (PMIX_SUCCESS != (rc = PMIx_Get_nb(&proc, tmp, + NULL, 0, valcbfunc, tmp))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get %s failed: %d", myproc.nspace, n, tmp, rc); + goto done; + } + ++num_gets; + } else { + (void)asprintf(&tmp, "%s-%d-remote", myproc.nspace, n); + if (PMIX_SUCCESS != (rc = PMIx_Get_nb(&proc, tmp, + NULL, 0, valcbfunc, tmp))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get %s failed: %d", myproc.nspace, n, tmp, rc); + goto done; + } + ++num_gets; } - ++num_gets; } if (dofence) { diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simpdyn.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simpdyn.c index a20b8418a4..ef5286dd6e 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simpdyn.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simpdyn.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 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -62,16 +62,17 @@ int main(int argc, char **argv) } pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank); - /* get our universe size */ + /* get our job size */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %d", myproc.nspace, myproc.rank, rc); + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get job size failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs); + pmix_output(0, "Client %s:%d job size %d", myproc.nspace, myproc.rank, nprocs); /* call fence to sync */ PMIX_PROC_CONSTRUCT(&proc); @@ -85,19 +86,12 @@ int main(int argc, char **argv) /* rank=0 calls spawn */ if (0 == myproc.rank) { PMIX_APP_CREATE(app, 1); - app->cmd = strdup("gumby"); + app->cmd = strdup("./simpclient"); app->maxprocs = 2; - pmix_argv_append_nosize(&app->argv, "gumby"); + pmix_argv_append_nosize(&app->argv, "simpclient"); pmix_argv_append_nosize(&app->argv, "-n"); pmix_argv_append_nosize(&app->argv, "2"); pmix_setenv("PMIX_ENV_VALUE", "3", true, &app->env); - PMIX_INFO_CREATE(app->info, 2); - (void)strncpy(app->info[0].key, "DARTH", PMIX_MAX_KEYLEN); - app->info[0].value.type = PMIX_INT8; - app->info[0].value.data.int8 = 12; - (void)strncpy(app->info[1].key, "VADER", PMIX_MAX_KEYLEN); - app->info[1].value.type = PMIX_DOUBLE; - app->info[1].value.data.dval = 12.34; pmix_output(0, "Client ns %s rank %d: calling PMIx_Spawn", myproc.nspace, myproc.rank); if (PMIX_SUCCESS != (rc = PMIx_Spawn(NULL, 0, app, 1, nsp2))) { @@ -106,25 +100,18 @@ int main(int argc, char **argv) } PMIX_APP_FREE(app, 1); - /* check to see if we got the expected info back */ - if (0 != strncmp(nsp2, "DYNSPACE", PMIX_MAX_NSLEN)) { - pmix_output(0, "Client ns %s rank %d: PMIx_Spawn returned incorrect nspace: %s", myproc.nspace, myproc.rank, nsp2); - goto done; - } else { - pmix_output(0, "Client ns %s rank %d: PMIx_Spawn succeeded returning nspace: %s", myproc.nspace, myproc.rank, nsp2); - } - /* get their universe size */ + /* get their job size */ (void)strncpy(proc.nspace, nsp2, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; val = NULL; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val)) || + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val)) || NULL == val) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %d", myproc.nspace, myproc.rank, rc); + pmix_output(0, "Client ns %s rank %d: PMIx_Get job %s size failed: %d", myproc.nspace, myproc.rank, nsp2, rc); goto done; } ntmp = val->data.uint32; PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe %s size %d", myproc.nspace, myproc.rank, nsp2, (int)ntmp); + pmix_output(0, "Client %s:%d job %s size %d", myproc.nspace, myproc.rank, nsp2, (int)ntmp); } /* just cycle the connect/disconnect functions */ diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simpft.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simpft.c index 57a6bfc8c6..a6acf5f89c 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simpft.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simpft.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-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -83,16 +83,17 @@ int main(int argc, char **argv) } pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank); - /* get our universe size */ + /* get our job size */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %d", myproc.nspace, myproc.rank, rc); + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get job size failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs); + pmix_output(0, "Client %s:%d job size %d", myproc.nspace, myproc.rank, nprocs); completed = false; /* register our errhandler */ diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simpjctrl.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simpjctrl.c index c9ac506520..037f7eae38 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simpjctrl.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simpjctrl.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 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -133,14 +133,17 @@ int main(int argc, char **argv) (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - /* get our universe size */ - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - fprintf(stderr, "Client ns %s rank %d: PMIx_Get universe size failed: %d\n", myproc.nspace, myproc.rank, rc); + /* get our job size */ + (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); + proc.rank = PMIX_RANK_WILDCARD; + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + fprintf(stderr, "Client ns %s rank %d: PMIx_Get job size failed: %s\n", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - fprintf(stderr, "Client %s:%d universe size %d\n", myproc.nspace, myproc.rank, nprocs); + fprintf(stderr, "Client %s:%d job size %d\n", myproc.nspace, myproc.rank, nprocs); /* inform the RM that we are preemptible, and that our checkpoint methods are * "signal" on SIGUSR2 and event on PMIX_JCTRL_CHECKPOINT */ diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simplegacy.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simplegacy.c index 1b15366cd4..98f40a15dd 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simplegacy.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simplegacy.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-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -24,230 +24,90 @@ */ #include -#include +#include #include #include #include #include -#include "src/class/pmix_object.h" -#include "src/util/output.h" -#include "src/util/printf.h" - #define MAXCNT 3 -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; -} - -/* this is an event notification function that we explicitly request - * be called when the PMIX_MODEL_DECLARED notification is issued. - * We could catch it in the general event notification function and test - * the status to see if the status matched, but it often is simpler - * to declare a use-specific notification callback point. In this case, - * we are asking to know whenever a model is declared as a means - * of testing server self-notification */ -static void model_callback(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) -{ - size_t n; - - /* just let us know it was received */ - fprintf(stderr, "%s:%d Model event handler called with status %d(%s)\n", - myproc.nspace, myproc.rank, status, PMIx_Error_string(status)); - for (n=0; n < ninfo; n++) { - if (PMIX_STRING == info[n].value.type) { - fprintf(stderr, "%s:%d\t%s:\t%s\n", - myproc.nspace, myproc.rank, - info[n].key, info[n].value.data.string); - } - } - - /* we must NOT tell the event handler state machine that we - * are the last step as that will prevent it from notifying - * anyone else that might be listening for declarations */ - if (NULL != cbfunc) { - cbfunc(PMIX_SUCCESS, NULL, 0, NULL, NULL, cbdata); - } -} - -/* event handler registration is done asynchronously */ -static void model_registration_callback(pmix_status_t status, - size_t evhandler_ref, - void *cbdata) -{ - volatile int *active = (volatile int*)cbdata; - - fprintf(stderr, "simpclient EVENT HANDLER REGISTRATION RETURN STATUS %d, ref=%lu\n", - status, (unsigned long)evhandler_ref); - *active = false; -} - int main(int argc, char **argv) { - int rc; - pmix_value_t value; - pmix_value_t *val = &value; + int rc, j, n; char *tmp; - pmix_proc_t proc; - uint32_t nprocs, n; - int cnt, j; - volatile bool active; - pmix_info_t info, *iptr; - size_t ninfo; - pmix_status_t code; + int spawned; + int rank; + int nprocs; + char value[1024]; - /* init us and declare we are a test programming model */ - PMIX_INFO_CREATE(iptr, 2); - PMIX_INFO_LOAD(&iptr[0], PMIX_PROGRAMMING_MODEL, "TEST", PMIX_STRING); - PMIX_INFO_LOAD(&iptr[1], PMIX_MODEL_LIBRARY_NAME, "PMIX", PMIX_STRING); - if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, iptr, 2))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Init failed: %s", - myproc.nspace, myproc.rank, PMIx_Error_string(rc)); + fprintf(stderr, "Client calling init\n"); + if (PMI_SUCCESS != (rc = PMI_Init(&spawned))) { + fprintf(stderr, "Client PMI_Init failed: %d\n", rc); exit(rc); } - PMIX_INFO_FREE(iptr, 2); - pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank); + fprintf(stderr, "Client Running\n"); /* test something */ - (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); - proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get failed: %s", - myproc.nspace, myproc.rank, PMIx_Error_string(rc)); + if (PMI_SUCCESS != (rc = PMI_Get_rank(&rank))) { + fprintf(stderr, "Client PMI_Get_rank failed: %d\n", rc); exit(rc); } - nprocs = val->data .uint32; - PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs); - - /* register a handler specifically for when models declare */ - active = true; - ninfo = 1; - PMIX_INFO_CREATE(iptr, ninfo); - PMIX_INFO_LOAD(&iptr[0], PMIX_EVENT_HDLR_NAME, "SIMPCLIENT-MODEL", PMIX_STRING); - code = PMIX_MODEL_DECLARED; - PMIx_Register_event_handler(&code, 1, iptr, ninfo, - model_callback, model_registration_callback, (void*)&active); - while (active) { - usleep(10); + if (PMI_SUCCESS != (rc = PMI_Get_universe_size(&nprocs))) { + fprintf(stderr, "Client %d: PMI_Get_universe_size failed: %d\n", rank, rc); + exit(rc); } - PMIX_INFO_FREE(iptr, ninfo); + fprintf(stderr, "Client %d job size %d\n", rank, nprocs); - /* register our errhandler */ - active = true; - PMIx_Register_event_handler(NULL, 0, NULL, 0, - notification_fn, errhandler_reg_callbk, (void*)&active); - while (active) { - usleep(10); + for (j=0; j < 10; j++) { + (void)asprintf(&tmp, "%d-gasnet-0-%d", rank, j); + if (PMI_SUCCESS != (rc = PMI_KVS_Put("foobar", tmp, "myvalue"))) { + fprintf(stderr, "Client %d: j %d PMI_KVS_Put failed: %d\n", + rank, j, rc); + goto done; + } + free(tmp); } - memset(&info, 0, sizeof(pmix_info_t)); - (void)strncpy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); - info.value.type = PMIX_UNDEF; - info.value.data.flag = 1; + if (PMIX_SUCCESS != (rc = PMI_KVS_Commit("foobar"))) { + fprintf(stderr, "Client %d: PMI_KVS_Commit failed: %d\n", rank, rc); + goto done; + } - for (cnt=0; cnt < MAXCNT; cnt++) { - pmix_output(0, "EXECUTING LOOP %d", cnt); - for (j=0; j < 10; j++) { - (void)asprintf(&tmp, "%s-%d-gasnet-%d-%d", myproc.nspace, myproc.rank, cnt, j); - value.type = PMIX_UINT64; - value.data.uint64 = 1234; - if (PMIX_SUCCESS != (rc = PMIx_Put(PMIX_GLOBAL, tmp, &value))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Put failed: %s", - myproc.nspace, myproc.rank, PMIx_Error_string(rc)); - goto done; + fprintf(stderr, "Client rank %d: CALLING PMI_Barrier\n", rank); + + /* call fence to ensure the data is received */ + if (PMI_SUCCESS != (rc = PMI_Barrier())) { + fprintf(stderr, "Client %d: PMI_Barrier failed: %d\n", rank, rc); + goto done; + } + + /* check the returned data */ + for (j=0; j < 10; j++) { + for (n=0; n < nprocs; n++) { + (void)asprintf(&tmp, "%d-gasnet-0-%d", n, j); + fprintf(stderr, "Client %d: Calling get\n", rank); + if (PMI_SUCCESS != (rc = PMI_KVS_Get("foobar", tmp, value, 1024))) { + fprintf(stderr, "Client %d: PMI_Get failed: %d\n", rank, rc); + continue; + } + if (0 == strcmp(value, "myvalue")) { + fprintf(stderr, "Client %d: PMI_Get returned correct value\n", rank); + } else { + fprintf(stderr, "Client %d: PMI_Get returned incorrect value\n", rank); } free(tmp); } - - if (PMIX_SUCCESS != (rc = PMIx_Commit())) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Commit failed: %s", - myproc.nspace, myproc.rank, cnt, PMIx_Error_string(rc)); - goto done; - } - - /* call fence to ensure the data is received */ - if (PMIX_SUCCESS != (rc = PMIx_Fence(NULL, 0, &info, 1))) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Fence failed: %s", - myproc.nspace, myproc.rank, cnt, PMIx_Error_string(rc)); - goto done; - } - - /* check the returned data */ - (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); - proc.rank = PMIX_RANK_UNDEF; - for (j=0; j < 10; j++) { - for (n=0; n < nprocs; n++) { - (void)asprintf(&tmp, "%s-%d-gasnet-%d-%d", myproc.nspace, n, cnt, j); - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, tmp, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s failed: %s", - myproc.nspace, myproc.rank, j, tmp, PMIx_Error_string(rc)); - continue; - } - if (NULL == val) { - pmix_output(0, "Client ns %s rank %d: NULL value returned", - myproc.nspace, myproc.rank); - break; - } - if (PMIX_UINT64 != val->type) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong type: %d", myproc.nspace, myproc.rank, j, tmp, val->type); - PMIX_VALUE_RELEASE(val); - free(tmp); - continue; - } - if (1234 != val->data.uint64) { - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned wrong value: %d", myproc.nspace, myproc.rank, j, tmp, (int)val->data.uint64); - PMIX_VALUE_RELEASE(val); - free(tmp); - continue; - } - pmix_output(0, "Client ns %s rank %d cnt %d: PMIx_Get %s returned correct", myproc.nspace, myproc.rank, j, tmp); - PMIX_VALUE_RELEASE(val); - free(tmp); - } - } } done: /* 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)); + fprintf(stderr, "Client rank %d: Finalizing\n", rank); + if (PMI_SUCCESS != (rc = PMI_Finalize())) { + fprintf(stderr, "Client rank %d: finalize failed %d\n", rank, rc); } else { - fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n", myproc.nspace, myproc.rank); + fprintf(stderr, "Client %d:PMI_Finalize successfully completed\n", rank); } fflush(stderr); return(rc); diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simppub.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simppub.c index 12d6c68735..2ccf9b258f 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simppub.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simppub.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-2017 Intel, Inc. All rights reserved. + * Copyright (c) 2013-2019 Intel, Inc. All rights reserved. * Copyright (c) 2015 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -54,16 +54,17 @@ int main(int argc, char **argv) } pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank); - /* get our universe size */ + /* get our job size */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %d", myproc.nspace, myproc.rank, rc); + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get job size failed: %s", + myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs); + pmix_output(0, "Client %s:%d job size %d", myproc.nspace, myproc.rank, nprocs); /* call fence to ensure the data is received */ PMIX_PROC_CONSTRUCT(&proc); diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/simptest.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simptest.c index e31f4211b9..b78165f704 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simptest.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simptest.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-2019 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 @@ -230,8 +229,6 @@ static void dlcbfunc(int sd, short flags, void *cbdata) { myxfer_t *x = (myxfer_t*)cbdata; - pmix_output(0, "INVENTORY READY FOR DELIVERY"); - PMIx_server_deliver_inventory(x->info, x->ninfo, NULL, 0, opcbfunc, (void*)x); } @@ -245,8 +242,6 @@ static void infocbfunc(pmix_status_t status, myxfer_t *x; size_t n; - pmix_output(0, "INVENTORY RECEIVED"); - /* we don't have any place to send this, so for test * purposes only, let's push it back down for processing. * Note: it must be thread-shifted first as we are in @@ -343,12 +338,14 @@ int main(int argc, char **argv) pmix_info_t *info; size_t ninfo; bool cross_version = false; + bool usock = true; bool hwloc = false; #if PMIX_HAVE_HWLOC char *hwloc_file = NULL; #endif mylock_t mylock; pmix_status_t code; + sigset_t unblock; /* smoke test */ if (PMIX_SUCCESS != 0) { @@ -378,6 +375,25 @@ int main(int argc, char **argv) /* cross-version test - we will set one child to * run at a different version. Requires -n >= 2 */ cross_version = true; + usock = false; + } else if (0 == strcmp("-u", argv[n])) { + /* enable usock */ + usock = false; +#if PMIX_HAVE_HWLOC + } else if (0 == strcmp("-hwloc", argv[n]) || + 0 == strcmp("--hwloc", argv[n])) { + /* test hwloc support */ + hwloc = true; + } else if (0 == strcmp("-hwloc-file", argv[n]) || + 0 == strcmp("--hwloc-file", argv[n])) { + if (NULL == argv[n+1]) { + fprintf(stderr, "The --hwloc-file option requires an argument\n"); + exit(1); + } + hwloc_file = strdup(argv[n+1]); + hwloc = true; + ++n; +#endif } else if (0 == strcmp("-h", argv[n])) { /* print the options and exit */ fprintf(stderr, "usage: simptest \n"); @@ -393,6 +409,12 @@ int main(int argc, char **argv) if (NULL == executable) { executable = strdup("./simpclient"); } + /* check for executable existence and permissions */ + if (0 != access(executable, X_OK)) { + fprintf(stderr, "Executable %s not found or missing executable permissions\n", executable); + exit(1); + } + if (cross_version && nprocs < 2) { fprintf(stderr, "Cross-version testing requires at least two clients\n"); exit(1); @@ -407,6 +429,21 @@ int main(int argc, char **argv) fprintf(stderr, "Testing version %s\n", PMIx_Get_version()); + /* ensure that SIGCHLD is unblocked as we need to capture it */ + if (0 != sigemptyset(&unblock)) { + fprintf(stderr, "SIGEMPTYSET FAILED\n"); + exit(1); + } + if (0 != sigaddset(&unblock, SIGCHLD)) { + fprintf(stderr, "SIGADDSET FAILED\n"); + exit(1); + } + if (0 != sigprocmask(SIG_UNBLOCK, &unblock, NULL)) { + fprintf(stderr, "SIG_UNBLOCK FAILED\n"); + exit(1); + } + + /* setup the server library and tell it to support tool connections */ #if PMIX_HAVE_HWLOC if (hwloc) { @@ -477,9 +514,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; @@ -539,6 +576,9 @@ int main(int argc, char **argv) } else { pmix_setenv("PMIX_MCA_ptl", "usock", true, &client_env); } + } else if (!usock) { + /* don't disable usock => enable it on client */ + pmix_setenv("PMIX_MCA_ptl", "usock", true, &client_env); } x = PMIX_NEW(myxfer_t); if (PMIX_SUCCESS != (rc = PMIx_server_register_client(&proc, myuid, mygid, @@ -616,6 +656,24 @@ int main(int argc, char **argv) DEBUG_DESTRUCT_LOCK(&globallock); PMIX_INFO_FREE(info, ninfo); +#if 0 + fprintf(stderr, "TEST NONDEFAULT NOTIFICATION\n"); + /* verify that notifications don't recirculate */ + ninfo = 1; + PMIX_INFO_CREATE(info, ninfo); + /* mark that it is not to go to any default handlers */ + PMIX_INFO_LOAD(&info[0], PMIX_EVENT_NON_DEFAULT, NULL, PMIX_BOOL); + PMIx_Notify_event(PMIX_ERR_DEBUGGER_RELEASE, + &pmix_globals.myid, PMIX_RANGE_LOCAL, + info, ninfo, NULL, NULL); + PMIX_INFO_FREE(info, ninfo); + /* wait a little in case we get notified */ + for (ninfo=0; ninfo < 100000; ninfo++) { + struct timespec t = {0, 100}; + nanosleep(&t, NULL); + } +#endif + done: /* deregister the event handlers */ PMIx_Deregister_event_handler(0, NULL, NULL); @@ -645,42 +703,132 @@ static void set_namespace(int nprocs, char *ranks, char *nspace, pmix_op_cbfunc_t cbfunc, myxfer_t *x) { char *regex, *ppn; - char hostname[PMIX_MAXHOSTNAMELEN]; + int n, m, k; + pmix_info_t *info; + pmix_data_array_t *array; - gethostname(hostname, sizeof(hostname)); - x->ninfo = 7; + x->ninfo = 16 + nprocs; PMIX_INFO_CREATE(x->info, x->ninfo); - (void)strncpy(x->info[0].key, PMIX_UNIV_SIZE, PMIX_MAX_KEYLEN); - x->info[0].value.type = PMIX_UINT32; - x->info[0].value.data.uint32 = nprocs; + n = 0; - (void)strncpy(x->info[1].key, PMIX_SPAWNED, PMIX_MAX_KEYLEN); - x->info[1].value.type = PMIX_UINT32; - x->info[1].value.data.uint32 = 0; + PMIx_generate_regex("test000,test001,test002", ®ex); + PMIx_generate_ppn("0;1;2", &ppn); - (void)strncpy(x->info[2].key, PMIX_LOCAL_SIZE, PMIX_MAX_KEYLEN); - x->info[2].value.type = PMIX_UINT32; - x->info[2].value.data.uint32 = nprocs; + (void)strncpy(x->info[n].key, PMIX_NODE_MAP, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_STRING; + x->info[n].value.data.string = regex; + ++n; - (void)strncpy(x->info[3].key, PMIX_LOCAL_PEERS, PMIX_MAX_KEYLEN); - x->info[3].value.type = PMIX_STRING; - x->info[3].value.data.string = strdup(ranks); + /* if we have some empty nodes, then fill their spots */ + (void)strncpy(x->info[n].key, PMIX_PROC_MAP, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_STRING; + x->info[n].value.data.string = ppn; + ++n; - PMIx_generate_regex(hostname, ®ex); - (void)strncpy(x->info[4].key, PMIX_NODE_MAP, PMIX_MAX_KEYLEN); - x->info[4].value.type = PMIX_STRING; - x->info[4].value.data.string = regex; + (void)strncpy(x->info[n].key, PMIX_UNIV_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; - PMIx_generate_ppn(ranks, &ppn); - (void)strncpy(x->info[5].key, PMIX_PROC_MAP, PMIX_MAX_KEYLEN); - x->info[5].value.type = PMIX_STRING; - x->info[5].value.data.string = ppn; + (void)strncpy(x->info[n].key, PMIX_SPAWNED, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 0; + ++n; - (void)strncpy(x->info[6].key, PMIX_JOB_SIZE, PMIX_MAX_KEYLEN); - x->info[6].value.type = PMIX_UINT32; - x->info[6].value.data.uint32 = nprocs; + (void)strncpy(x->info[n].key, PMIX_LOCAL_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + (void)strncpy(x->info[n].key, PMIX_LOCAL_PEERS, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_STRING; + x->info[n].value.data.string = strdup(ranks); + ++n; + + (void)strncpy(x->info[n].key, PMIX_JOB_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_JOBID, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_STRING; + x->info[n].value.data.string = strdup("1234"); + ++n; + + (void)strncpy(x->info[n].key, PMIX_NPROC_OFFSET, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 0; + ++n; + + (void)strncpy(x->info[n].key, PMIX_NODEID, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 0; + ++n; + + (void)strncpy(x->info[n].key, PMIX_NODE_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_NUM_NODES, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 1; + ++n; + + (void)strncpy(x->info[n].key, PMIX_UNIV_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_MAX_PROCS, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_JOB_NUM_APPS, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 1; + ++n; + + (void)strncpy(x->info[n].key, PMIX_LOCALLDR, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_PROC_RANK; + x->info[n].value.data.uint32 = 0; + ++n; + + /* add the proc-specific data */ + for (m=0; m < nprocs; m++) { + (void)strncpy(x->info[n].key, PMIX_PROC_DATA, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_DATA_ARRAY; + PMIX_DATA_ARRAY_CREATE(array, 5, PMIX_INFO); + x->info[n].value.data.darray = array; + info = (pmix_info_t*)array->array; + k = 0; + (void)strncpy(info[k].key, PMIX_RANK, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_PROC_RANK; + info[k].value.data.rank = m; + ++k; + (void)strncpy(info[k].key, PMIX_GLOBAL_RANK, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_PROC_RANK; + info[k].value.data.rank = m; + ++k; + (void)strncpy(info[k].key, PMIX_LOCAL_RANK, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_UINT16; + info[k].value.data.uint16 = m; + ++k; + + (void)strncpy(info[k].key, PMIX_NODE_RANK, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_UINT16; + info[k].value.data.uint16 = m; + ++k; + + (void)strncpy(info[k].key, PMIX_NODEID, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_UINT32; + info[k].value.data.uint32 = 0; + ++k; + /* move to next proc */ + ++n; + } PMIx_server_register_nspace(nspace, nprocs, x->info, x->ninfo, cbfunc, x); } @@ -694,6 +842,12 @@ static void errhandler(size_t evhdlr_registration_id, void *cbdata) { pmix_output(0, "SERVER: ERRHANDLER CALLED WITH STATUS %d", status); + /* we must NOT tell the event handler state machine that we + * are the last step as that will prevent it from notifying + * anyone else that might be listening for declarations */ + if (NULL != cbfunc) { + cbfunc(PMIX_SUCCESS, NULL, 0, NULL, NULL, cbdata); + } } static void errhandler_reg_callbk (pmix_status_t status, @@ -702,8 +856,6 @@ static void errhandler_reg_callbk (pmix_status_t status, { mylock_t *lock = (mylock_t*)cbdata; - pmix_output(0, "SERVER: ERRHANDLER REGISTRATION CALLBACK CALLED WITH STATUS %d, ref=%lu", - status, (unsigned long)errhandler_ref); lock->status = status; DEBUG_WAKEUP_THREAD(lock); } @@ -716,8 +868,6 @@ static pmix_status_t connected(const pmix_proc_t *proc, void *server_object, static pmix_status_t finalized(const pmix_proc_t *proc, void *server_object, pmix_op_cbfunc_t cbfunc, void *cbdata) { - pmix_output(0, "SERVER: FINALIZED %s:%d WAKEUP %d", - proc->nspace, proc->rank, wakeup); return PMIX_OPERATION_SUCCEEDED; } @@ -793,7 +943,6 @@ static pmix_status_t fencenb_fn(const pmix_proc_t procs[], size_t nprocs, { pmix_shift_caddy_t *scd; - pmix_output(0, "SERVER: FENCENB"); scd = PMIX_NEW(pmix_shift_caddy_t); scd->status = PMIX_SUCCESS; scd->data = data; @@ -811,8 +960,6 @@ static pmix_status_t dmodex_fn(const pmix_proc_t *proc, { pmix_shift_caddy_t *scd; - pmix_output(0, "SERVER: DMODEX"); - /* if this is a timeout test, then do nothing */ if (istimeouttest) { return PMIX_SUCCESS; @@ -835,8 +982,6 @@ static pmix_status_t publish_fn(const pmix_proc_t *proc, pmix_locdat_t *p; size_t n; - pmix_output(0, "SERVER: PUBLISH"); - for (n=0; n < ninfo; n++) { p = PMIX_NEW(pmix_locdat_t); (void)strncpy(p->pdata.proc.nspace, proc->nspace, PMIX_MAX_NSLEN); @@ -877,8 +1022,6 @@ static pmix_status_t lookup_fn(const pmix_proc_t *proc, char **keys, pmix_status_t ret = PMIX_ERR_NOT_FOUND; lkobj_t *lk; - pmix_output(0, "SERVER: LOOKUP"); - PMIX_CONSTRUCT(&results, pmix_list_t); for (n=0; NULL != keys[n]; n++) { @@ -928,8 +1071,6 @@ static pmix_status_t unpublish_fn(const pmix_proc_t *proc, char **keys, pmix_locdat_t *p, *p2; size_t n; - pmix_output(0, "SERVER: UNPUBLISH"); - for (n=0; NULL != keys[n]; n++) { PMIX_LIST_FOREACH_SAFE(p, p2, &pubdata, pmix_locdat_t) { if (0 == strncmp(keys[n], p->pdata.key, PMIX_MAX_KEYLEN)) { @@ -961,8 +1102,6 @@ static pmix_status_t spawn_fn(const pmix_proc_t *proc, pmix_proc_t *pptr; bool spawned; - pmix_output(0, "SERVER: SPAWN"); - /* check the job info for parent and spawned keys */ for (n=0; n < ninfo; n++) { if (0 == strncmp(job_info[n].key, PMIX_PARENT_ID, PMIX_MAX_KEYLEN)) { @@ -996,8 +1135,6 @@ static pmix_status_t connect_fn(const pmix_proc_t procs[], size_t nprocs, const pmix_info_t info[], size_t ninfo, pmix_op_cbfunc_t cbfunc, void *cbdata) { - pmix_output(0, "SERVER: CONNECT"); - /* in practice, we would pass this request to the local * resource manager for handling */ @@ -1011,8 +1148,6 @@ static pmix_status_t disconnect_fn(const pmix_proc_t procs[], size_t nprocs, const pmix_info_t info[], size_t ninfo, pmix_op_cbfunc_t cbfunc, void *cbdata) { - pmix_output(0, "SERVER: DISCONNECT"); - return PMIX_OPERATION_SUCCEEDED; } @@ -1035,7 +1170,6 @@ static pmix_status_t notify_event(pmix_status_t code, pmix_info_t info[], size_t ninfo, pmix_op_cbfunc_t cbfunc, void *cbdata) { - pmix_output(0, "SERVER: NOTIFY EVENT"); return PMIX_OPERATION_SUCCEEDED; } @@ -1064,8 +1198,6 @@ static pmix_status_t query_fn(pmix_proc_t *proct, pmix_info_t *info; query_data_t qd; - pmix_output(0, "SERVER: QUERY"); - if (NULL == cbfunc) { return PMIX_ERROR; } @@ -1093,8 +1225,6 @@ static void tool_connect_fn(pmix_info_t *info, size_t ninfo, { pmix_proc_t proc; - pmix_output(0, "SERVER: TOOL CONNECT"); - /* just pass back an arbitrary nspace */ (void)strncpy(proc.nspace, "TOOL", PMIX_MAX_NSLEN); proc.rank = 0; @@ -1122,8 +1252,6 @@ static void log_fn(const pmix_proc_t *client, { mylog_t *lg = (mylog_t *)malloc(sizeof(mylog_t)); - pmix_output(0, "SERVER: LOG"); - lg->cbfunc = cbfunc; lg->cbdata = cbdata; PMIX_THREADSHIFT(lg, foobar); @@ -1161,7 +1289,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/pmix3x/pmix/test/simple/simptimeout.c b/opal/mca/pmix/pmix3x/pmix/test/simple/simptimeout.c index f545402988..10835d68ab 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/simptimeout.c +++ b/opal/mca/pmix/pmix3x/pmix/test/simple/simptimeout.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 Mellanox Technologies, Inc. All rights reserved. * $COPYRIGHT$ * @@ -103,17 +103,17 @@ int main(int argc, char **argv) usleep(10); } - /* get our universe size */ + /* get our job size */ (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN); proc.rank = PMIX_RANK_WILDCARD; - if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) { - pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %s", + if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_JOB_SIZE, NULL, 0, &val))) { + pmix_output(0, "Client ns %s rank %d: PMIx_Get job size failed: %s", myproc.nspace, myproc.rank, PMIx_Error_string(rc)); goto done; } nprocs = val->data.uint32; PMIX_VALUE_RELEASE(val); - pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs); + pmix_output(0, "Client %s:%d job size %d", myproc.nspace, myproc.rank, nprocs); /* if we are rank=0, then do a fence with timeout */ if (0 == myproc.rank) { diff --git a/opal/mca/pmix/pmix3x/pmix/test/simple/stability.c b/opal/mca/pmix/pmix3x/pmix/test/simple/stability.c index d67b6f8410..c97df8c74f 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/simple/stability.c +++ b/opal/mca/pmix/pmix3x/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. @@ -183,6 +183,8 @@ static pmix_list_t pubdata; static pmix_event_t handler; static pmix_list_t children; static bool istimeouttest = false; +static bool nettest = false; +static bool arrays = false; static void set_namespace(int nprocs, char *ranks, char *nspace, pmix_op_cbfunc_t cbfunc, myxfer_t *x); @@ -209,6 +211,32 @@ static void opcbfunc(pmix_status_t status, void *cbdata) DEBUG_WAKEUP_THREAD(&x->lock); } +static void setup_cbfunc(pmix_status_t status, + pmix_info_t info[], size_t ninfo, + void *provided_cbdata, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + myxfer_t *x = (myxfer_t*)provided_cbdata; + size_t n; + + /* transfer it to the caddy for return to the main thread */ + if (0 < ninfo) { + PMIX_INFO_CREATE(x->info, ninfo); + x->ninfo = ninfo; + for (n=0; n < ninfo; n++) { + PMIX_INFO_XFER(&x->info[n], &info[n]); + } + } + + /* let the library release the data and cleanup from + * the operation */ + if (NULL != cbfunc) { + cbfunc(PMIX_SUCCESS, cbdata); + } + + DEBUG_WAKEUP_THREAD(&x->lock); +} + int main(int argc, char **argv) { char **client_env=NULL; @@ -225,6 +253,11 @@ int main(int argc, char **argv) size_t ninfo; mylock_t mylock; int ncycles=1, m, delay=0; + bool hwloc = false; +#if PMIX_HAVE_HWLOC + char *hwloc_file = NULL; +#endif + sigset_t unblock; /* smoke test */ if (PMIX_SUCCESS != 0) { @@ -260,30 +293,115 @@ int main(int argc, char **argv) 0 == strcmp("--sleep", argv[n])) && NULL != argv[n+1]) { delay = strtol(argv[n+1], NULL, 10); +#if PMIX_HAVE_HWLOC + } else if (0 == strcmp("-hwloc", argv[n]) || + 0 == strcmp("--hwloc", argv[n])) { + /* test hwloc support */ + hwloc = true; + } else if (0 == strcmp("-hwloc-file", argv[n]) || + 0 == strcmp("--hwloc-file", argv[n])) { + if (NULL == argv[n+1]) { + fprintf(stderr, "The --hwloc-file option requires an argument\n"); + exit(1); + } + hwloc_file = strdup(argv[n+1]); + hwloc = true; + ++n; +#endif } else if (0 == strcmp("-h", argv[n])) { /* print the options and exit */ fprintf(stderr, "usage: simptest \n"); fprintf(stderr, " -n N Number of clients to run\n"); fprintf(stderr, " -e foo Name of the client executable to run (default: simpclient\n"); fprintf(stderr, " -reps N Cycle for N repetitions"); + fprintf(stderr, " -hwloc Test hwloc support\n"); + fprintf(stderr, " -hwloc-file FILE Use file to import topology\n"); + fprintf(stderr, " -net-test Test network endpt assignments\n"); + fprintf(stderr, " -arrays Use the job session array to pass registration info\n"); exit(0); + } else if (0 == strcmp("-net-test", argv[n]) || + 0 == strcmp("--net-test", argv[n])) { + /* test network support */ + nettest = true; + } else if (0 == strcmp("-arrays", argv[n]) || + 0 == strcmp("--arrays", argv[n])) { + /* test network support */ + arrays = true; } } if (NULL == executable) { - executable = strdup("./quietclient"); + if (nettest) { + executable = strdup("./simpcoord"); + } else { + executable = strdup("./quietclient"); + } } + /* check for executable existence and permissions */ + if (0 != access(executable, X_OK)) { + fprintf(stderr, "Executable %s not found or missing executable permissions\n", executable); + exit(1); + } + + /* ensure that SIGCHLD is unblocked as we need to capture it */ + if (0 != sigemptyset(&unblock)) { + fprintf(stderr, "SIGEMPTYSET FAILED\n"); + exit(1); + } + if (0 != sigaddset(&unblock, SIGCHLD)) { + fprintf(stderr, "SIGADDSET FAILED\n"); + exit(1); + } + if (0 != sigprocmask(SIG_UNBLOCK, &unblock, NULL)) { + fprintf(stderr, "SIG_UNBLOCK FAILED\n"); + exit(1); + } + /* setup the server library and tell it to support tool connections */ +#if PMIX_HAVE_HWLOC + if (hwloc) { +#if HWLOC_API_VERSION < 0x20000 + ninfo = 4; +#else + ninfo = 5; +#endif + } else { + ninfo = 4; + } +#else ninfo = 3; +#endif PMIX_INFO_CREATE(info, ninfo); PMIX_INFO_LOAD(&info[0], PMIX_SERVER_TOOL_SUPPORT, NULL, PMIX_BOOL); PMIX_INFO_LOAD(&info[1], PMIX_USOCK_DISABLE, NULL, PMIX_BOOL); PMIX_INFO_LOAD(&info[2], PMIX_SERVER_GATEWAY, NULL, PMIX_BOOL); +#if PMIX_HAVE_HWLOC + if (hwloc) { + if (NULL != hwloc_file) { + PMIX_INFO_LOAD(&info[3], PMIX_TOPOLOGY_FILE, hwloc_file, PMIX_STRING); + } else { + PMIX_INFO_LOAD(&info[3], PMIX_TOPOLOGY, NULL, PMIX_STRING); + } +#if HWLOC_API_VERSION >= 0x20000 + PMIX_INFO_LOAD(&info[4], PMIX_HWLOC_SHARE_TOPO, NULL, PMIX_BOOL); +#endif + } +#endif + if (nettest) { + /* set a known network configuration for the pnet/test component */ + putenv("PMIX_MCA_pnet_test_nverts=nodes:5;plane:d:3;plane:s:2;plane:d:5"); + putenv("PMIX_MCA_pnet=test"); + } + if (PMIX_SUCCESS != (rc = PMIx_server_init(&mymodule, info, ninfo))) { fprintf(stderr, "Init failed with error %d\n", rc); return rc; } PMIX_INFO_FREE(info, ninfo); + if (nettest) { + unsetenv("PMIX_MCA_pnet"); + unsetenv("PMIX_MCA_pnet_test_nverts"); + } /* register the default errhandler */ DEBUG_CONSTRUCT_LOCK(&mylock); @@ -304,9 +422,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); @@ -445,43 +563,186 @@ int main(int argc, char **argv) static void set_namespace(int nprocs, char *ranks, char *nspace, pmix_op_cbfunc_t cbfunc, myxfer_t *x) { - char *regex, *ppn; - char hostname[PMIX_MAXHOSTNAMELEN]; + char *regex, *ppn, *rks; + int n, m, k; + pmix_data_array_t *array; + pmix_info_t *info, *iptr, *ip; + myxfer_t cd, lock; + pmix_status_t rc; - gethostname(hostname, sizeof(hostname)); - x->ninfo = 7; + if (arrays) { + x->ninfo = 15 + nprocs; + } else { + x->ninfo = 16 + nprocs; + } PMIX_INFO_CREATE(x->info, x->ninfo); - (void)strncpy(x->info[0].key, PMIX_UNIV_SIZE, PMIX_MAX_KEYLEN); - x->info[0].value.type = PMIX_UINT32; - x->info[0].value.data.uint32 = nprocs; + n = 0; - (void)strncpy(x->info[1].key, PMIX_SPAWNED, PMIX_MAX_KEYLEN); - x->info[1].value.type = PMIX_UINT32; - x->info[1].value.data.uint32 = 0; + PMIx_generate_regex("test000,test001,test002", ®ex); + PMIx_generate_ppn("0;1;2", &ppn); - (void)strncpy(x->info[2].key, PMIX_LOCAL_SIZE, PMIX_MAX_KEYLEN); - x->info[2].value.type = PMIX_UINT32; - x->info[2].value.data.uint32 = nprocs; + if (arrays) { + (void)strncpy(x->info[n].key, PMIX_JOB_INFO_ARRAY, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_DATA_ARRAY; + PMIX_DATA_ARRAY_CREATE(x->info[n].value.data.darray, 2, PMIX_INFO); + iptr = (pmix_info_t*)x->info[n].value.data.darray->array; + (void)strncpy(iptr[0].key, PMIX_NODE_MAP, PMIX_MAX_KEYLEN); + iptr[0].value.type = PMIX_STRING; + iptr[0].value.data.string = regex; + (void)strncpy(iptr[1].key, PMIX_PROC_MAP, PMIX_MAX_KEYLEN); + iptr[1].value.type = PMIX_STRING; + iptr[1].value.data.string = ppn; + ++n; + } else { + (void)strncpy(x->info[n].key, PMIX_NODE_MAP, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_STRING; + x->info[n].value.data.string = regex; + ++n; - (void)strncpy(x->info[3].key, PMIX_LOCAL_PEERS, PMIX_MAX_KEYLEN); - x->info[3].value.type = PMIX_STRING; - x->info[3].value.data.string = strdup(ranks); + /* if we have some empty nodes, then fill their spots */ + (void)strncpy(x->info[n].key, PMIX_PROC_MAP, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_STRING; + x->info[n].value.data.string = ppn; + ++n; + } - PMIx_generate_regex(hostname, ®ex); - (void)strncpy(x->info[4].key, PMIX_NODE_MAP, PMIX_MAX_KEYLEN); - x->info[4].value.type = PMIX_STRING; - x->info[4].value.data.string = regex; + /* we have the required info to run setup_app, so do that now */ + PMIX_INFO_CREATE(iptr, 4); + PMIX_INFO_XFER(&iptr[0], &x->info[0]); + PMIX_INFO_XFER(&iptr[1], &x->info[1]); + PMIX_INFO_LOAD(&iptr[2], PMIX_SETUP_APP_ENVARS, NULL, PMIX_BOOL); + PMIX_LOAD_KEY(iptr[3].key, PMIX_ALLOC_NETWORK); + iptr[3].value.type = PMIX_DATA_ARRAY; + PMIX_DATA_ARRAY_CREATE(iptr[3].value.data.darray, 2, PMIX_INFO); + ip = (pmix_info_t*)iptr[3].value.data.darray->array; + asprintf(&rks, "%s.net", nspace); + PMIX_INFO_LOAD(&ip[0], PMIX_ALLOC_NETWORK_ID, rks, PMIX_STRING); + free(rks); + PMIX_INFO_LOAD(&ip[1], PMIX_ALLOC_NETWORK_SEC_KEY, NULL, PMIX_BOOL); + PMIX_CONSTRUCT(&cd, myxfer_t); + if (PMIX_SUCCESS != (rc = PMIx_server_setup_application(nspace, iptr, 4, + setup_cbfunc, &cd))) { + pmix_output(0, "[%s:%d] PMIx_server_setup_application failed: %s", __FILE__, __LINE__, PMIx_Error_string(rc)); + DEBUG_DESTRUCT_LOCK(&cd.lock); + } else { + DEBUG_WAIT_THREAD(&cd.lock); + } - PMIx_generate_ppn(ranks, &ppn); - (void)strncpy(x->info[5].key, PMIX_PROC_MAP, PMIX_MAX_KEYLEN); - x->info[5].value.type = PMIX_STRING; - x->info[5].value.data.string = ppn; + /* use the results to setup the local subsystems */ + PMIX_CONSTRUCT(&lock, myxfer_t); + if (PMIX_SUCCESS != (rc = PMIx_server_setup_local_support(nspace, cd.info, cd.ninfo, + opcbfunc, &lock))) { + pmix_output(0, "[%s:%d] PMIx_server_setup_local_support failed: %s", __FILE__, __LINE__, PMIx_Error_string(rc)); + } else { + DEBUG_WAIT_THREAD(&lock.lock); + } + PMIX_DESTRUCT(&lock); + PMIX_DESTRUCT(&cd); - (void)strncpy(x->info[6].key, PMIX_JOB_SIZE, PMIX_MAX_KEYLEN); - x->info[6].value.type = PMIX_UINT32; - x->info[6].value.data.uint32 = nprocs; + (void)strncpy(x->info[n].key, PMIX_UNIV_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + (void)strncpy(x->info[n].key, PMIX_SPAWNED, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 0; + ++n; + + (void)strncpy(x->info[n].key, PMIX_LOCAL_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_LOCAL_PEERS, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_STRING; + x->info[n].value.data.string = strdup(ranks); + ++n; + + (void)strncpy(x->info[n].key, PMIX_JOB_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_JOBID, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_STRING; + x->info[n].value.data.string = strdup("1234"); + ++n; + + (void)strncpy(x->info[n].key, PMIX_NPROC_OFFSET, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 0; + ++n; + + (void)strncpy(x->info[n].key, PMIX_NODEID, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 0; + ++n; + + (void)strncpy(x->info[n].key, PMIX_NODE_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_NUM_NODES, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 1; + ++n; + + (void)strncpy(x->info[n].key, PMIX_UNIV_SIZE, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_MAX_PROCS, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = nprocs; + ++n; + + (void)strncpy(x->info[n].key, PMIX_JOB_NUM_APPS, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_UINT32; + x->info[n].value.data.uint32 = 1; + ++n; + + (void)strncpy(x->info[n].key, PMIX_LOCALLDR, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_PROC_RANK; + x->info[n].value.data.uint32 = 0; + ++n; + + /* add the proc-specific data */ + for (m=0; m < nprocs; m++) { + (void)strncpy(x->info[n].key, PMIX_PROC_DATA, PMIX_MAX_KEYLEN); + x->info[n].value.type = PMIX_DATA_ARRAY; + PMIX_DATA_ARRAY_CREATE(array, 5, PMIX_INFO); + x->info[n].value.data.darray = array; + info = (pmix_info_t*)array->array; + k = 0; + (void)strncpy(info[k].key, PMIX_RANK, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_PROC_RANK; + info[k].value.data.rank = m; + ++k; + (void)strncpy(info[k].key, PMIX_GLOBAL_RANK, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_PROC_RANK; + info[k].value.data.rank = m; + ++k; + (void)strncpy(info[k].key, PMIX_LOCAL_RANK, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_UINT16; + info[k].value.data.uint16 = m; + ++k; + + (void)strncpy(info[k].key, PMIX_NODE_RANK, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_UINT16; + info[k].value.data.uint16 = m; + ++k; + + (void)strncpy(info[k].key, PMIX_NODEID, PMIX_MAX_KEYLEN); + info[k].value.type = PMIX_UINT32; + info[k].value.data.uint32 = 0; + ++k; + /* move to next proc */ + ++n; + } PMIx_server_register_nspace(nspace, nprocs, x->info, x->ninfo, cbfunc, x); } @@ -852,7 +1113,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/pmix3x/pmix/test/test_common.h b/opal/mca/pmix/pmix3x/pmix/test/test_common.h index 10b180e659..490f68323b 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/test_common.h +++ b/opal/mca/pmix/pmix3x/pmix/test/test_common.h @@ -289,9 +289,9 @@ typedef struct { } \ if (PMIX_SUCCESS == rc) { \ if( PMIX_SUCCESS != cbdata.status ){ \ - if( !( (cbdata.status == PMIX_ERR_NOT_FOUND || cbdata.status == PMIX_ERR_PROC_ENTRY_NOT_FOUND) && ok_notfnd ) ){ \ - TEST_ERROR(("%s:%d: PMIx_Get_nb failed: %d from %s:%d, key=%s", \ - my_nspace, my_rank, rc, my_nspace, r)); \ + if( !( (cbdata.status == PMIX_ERR_NOT_FOUND || cbdata.status == PMIX_ERR_PROC_ENTRY_NOT_FOUND) && ok_notfnd ) ){ \ + TEST_ERROR(("%s:%d: PMIx_Get_nb failed: %d from %s:%d, key=%s", \ + my_nspace, my_rank, rc, my_nspace, r, key)); \ } \ rc = PMIX_ERROR; \ } else if (NULL == val) { \ diff --git a/opal/mca/pmix/pmix3x/pmix/test/test_error.c b/opal/mca/pmix/pmix3x/pmix/test/test_error.c index f5217f0657..24a63da491 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/test_error.c +++ b/opal/mca/pmix/pmix3x/pmix/test/test_error.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2015-2019 Intel, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -38,7 +38,7 @@ static void timeout_errhandler(size_t evhdlr_registration_id, void *cbdata) { TEST_ERROR(("timeout errhandler called for error status = %d ninfo = %d", - status, ninfo)); + status, (int)ninfo)); if (NULL != cbfunc) { cbfunc(PMIX_SUCCESS, NULL, 0, NULL, NULL, cbdata); } @@ -58,7 +58,7 @@ static void errhandler_reg_callbk1 (pmix_status_t status, size_t *ref = (size_t*) cbdata; *ref = errhandler_ref; TEST_VERBOSE(("PMIX client ERRHANDLER REGISTRATION CALLED WITH STATUS %d, ref=%lu", - status, *ref, (unsigned long)errhandler_ref)); + status, (unsigned long)errhandler_ref)); } diff --git a/opal/mca/pmix/pmix3x/pmix/test/test_server.c b/opal/mca/pmix/pmix3x/pmix/test/test_server.c index 426014149e..30d174a956 100644 --- a/opal/mca/pmix/pmix3x/pmix/test/test_server.c +++ b/opal/mca/pmix/pmix3x/pmix/test/test_server.c @@ -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); @@ -187,7 +187,7 @@ static void server_unpack_procs(char *buf, size_t size) char *nspace; while ((size_t)(ptr - buf) < size) { - ns_count = (size_t)*ptr; + ns_count = *(size_t *)ptr; ptr += sizeof(size_t); for (i = 0; i < ns_count; i++) { @@ -195,16 +195,16 @@ static void server_unpack_procs(char *buf, size_t size) size_t ltasks, ntasks; int server_id; - server_id = *ptr; + server_id = *(int *)ptr; ptr += sizeof(int); nspace = ptr; ptr += PMIX_MAX_NSLEN+1; - ntasks = (size_t)*ptr; + ntasks = *(size_t *)ptr; ptr += sizeof(size_t); - ltasks = (size_t)*ptr; + ltasks = *(size_t *)ptr; ptr += sizeof(size_t); PMIX_LIST_FOREACH(tmp, server_nspace, server_nspace_t) { @@ -226,7 +226,7 @@ static void server_unpack_procs(char *buf, size_t size) } size_t i; for (i = 0; i < ltasks; i++) { - int rank = (int)*ptr; + int rank = *(int *)ptr; ptr += sizeof(int); if (ns_item->task_map[rank] >= 0) { continue; @@ -473,7 +473,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; @@ -505,8 +505,8 @@ static void server_read_cb(evutil_socket_t fd, short event, void *arg) switch(msg_hdr.cmd) { case CMD_BARRIER_REQUEST: barrier_cnt++; - TEST_VERBOSE(("CMD_BARRIER_REQ req from %d cnt %d", msg_hdr.src_id, - barrier_cnt)); + TEST_VERBOSE(("CMD_BARRIER_REQ req from %d cnt %lu", msg_hdr.src_id, + (unsigned long)barrier_cnt)); if (pmix_list_get_size(server_list) == barrier_cnt) { barrier_cnt = 0; /* reset barrier counter */ server_info_t *tmp_server; @@ -535,8 +535,8 @@ static void server_read_cb(evutil_socket_t fd, short event, void *arg) msg_buf = NULL; } - TEST_VERBOSE(("CMD_FENCE_CONTRIB req from %d cnt %d size %d", - msg_hdr.src_id, contrib_cnt, msg_hdr.size)); + TEST_VERBOSE(("CMD_FENCE_CONTRIB req from %d cnt %lu size %d", + msg_hdr.src_id, (unsigned long)contrib_cnt, msg_hdr.size)); if (pmix_list_get_size(server_list) == contrib_cnt) { server_info_t *tmp_server; PMIX_LIST_FOREACH(tmp_server, server_list, server_info_t) { @@ -547,8 +547,8 @@ static void server_read_cb(evutil_socket_t fd, short event, void *arg) resp_hdr.size = fence_buf_offset; server_send_msg(&resp_hdr, fence_buf, fence_buf_offset); } - TEST_VERBOSE(("CMD_FENCE_CONTRIB complete, size %d", - fence_buf_offset)); + TEST_VERBOSE(("CMD_FENCE_CONTRIB complete, size %lu", + (unsigned long)fence_buf_offset)); if (fence_buf) { free(fence_buf); fence_buf = NULL; @@ -651,13 +651,13 @@ static void server_unpack_dmdx(char *buf, int *sender, pmix_proc_t *proc) { char *ptr = buf; - *sender = (int)*ptr; + *sender = *(int *)ptr; ptr += sizeof(int); memcpy(proc->nspace, ptr, PMIX_MAX_NSLEN +1); ptr += PMIX_MAX_NSLEN +1; - proc->rank = (int)*ptr; + proc->rank = *(int *)ptr; ptr += sizeof(int); } @@ -671,6 +671,8 @@ static void _dmdx_cb(int status, char *data, size_t sz, void *cbdata) msg_hdr.src_id = my_server_id; msg_hdr.size = sz; msg_hdr.dst_id = *sender_id; + TEST_VERBOSE(("srv #%d: DMDX RESPONSE: receiver=%d, size=%lu,", + my_server_id, *sender_id, (unsigned long)sz)); free(sender_id); server_send_msg(&msg_hdr, data, sz); @@ -804,9 +806,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, + server->evread = pmix_event_new(pmix_globals.evbase, server->rd_fd, EV_READ|EV_PERSIST, server_read_cb, server); - event_add(server->evread, NULL); + pmix_event_add(server->evread, NULL); } }