diff --git a/.github/workflows/builds.yaml b/.github/workflows/builds.yaml index 126ee35..3d859da 100644 --- a/.github/workflows/builds.yaml +++ b/.github/workflows/builds.yaml @@ -15,13 +15,21 @@ jobs: uses: actions/checkout@v3 with: submodules: recursive + repository: openpmix/openpmix + path: openpmix/master + ref: master - name: Build OpenPMIx run: | + cd openpmix/master ./autogen.pl - ./configure --prefix=${PWD}/install + ./configure --prefix=$RUNNER_TEMP/pmixinstall make -j make install + - name: Git clone PMI shim + uses: actions/checkout@v3 + with: + clean: false - name: Build PMI shim run: | ./autogen.sh @@ -29,9 +37,9 @@ jobs: if test "${{ matrix.path }}" = vpath; then mkdir build cd build - ../configure --prefix=${PWD}/shim --with-pmix=${PWD}/install + ../configure --prefix=$RUNNER_TEMP/shim --with-pmix=$RUNNER_TEMP/pmixinstall else - ./configure --prefix=${PWD}/shim --with-pmix=${PWD}/install + ./configure --prefix=$RUNNER_TEMP/shim --with-pmix=$RUNNER_TEMP/pmixinstall fi make -j make install @@ -47,13 +55,24 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends software-properties-common libhwloc-dev libevent-dev + - name: Git clone OpenPMIx + uses: actions/checkout@v3 + with: + submodules: recursive + repository: openpmix/openpmix + path: openpmix/master + ref: master - name: Build OpenPMIx run: | + cd openpmix/master ./autogen.pl - - ./configure --prefix=${PWD}/install + ./configure --prefix=$RUNNER_TEMP/pmixinstall make -j make install + - name: Git clone PMI shim + uses: actions/checkout@v3 + with: + clean: false - name: Build PMI shim run: | ./autogen.sh @@ -61,9 +80,9 @@ jobs: if test "${{ matrix.path }}" = vpath; then mkdir build cd build - ../configure --prefix=${PWD}/shim --with-pmix=${PWD}/install + ../configure --prefix=$RUNNER_TEMP/shim --with-pmix=$RUNNER_TEMP/pmixinstall else - ./configure --prefix=${PWD}/shim --with-pmix=${PWD}/install + ./configure --prefix=$RUNNER_TEMP/shim --with-pmix=$RUNNER_TEMP/pmixinstall fi make -j make install diff --git a/.gitignore b/.gitignore index 418c777..1996d58 100644 --- a/.gitignore +++ b/.gitignore @@ -51,15 +51,15 @@ config/lt~obsolete.m4 config/missing configure libtool -src/include/pmishim_config.h.in Makefile config.status config/depcomp -include/version.h +include/pmishim_version.h src/.deps/ src/.libs/ src/Makefile src/include/pmishim_config.h +src/include/pmishim_config.h.in src/include/stamp-h1 src/include/version.h diff --git a/Makefile.am b/Makefile.am index dd94da0..bcf1850 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,4 +22,5 @@ EXTRA_DIST = \ README.md VERSION COPYING AUTHORS \ config/pmishim_get_version.sh -SUBDIRS = src +SUBDIRS = include src + diff --git a/VERSION b/VERSION index f9d87b0..9ab7486 100644 --- a/VERSION +++ b/VERSION @@ -16,7 +16,7 @@ release=0 # requirement is that it must be entirely printable ASCII characters # and have no white space. -greek=rc1 +greek=a1 # The date when this release was created @@ -39,4 +39,4 @@ snapshot_version=${major}.${minor}.${release}${greek}-git # 2. Version numbers are described in the Libtool current:revision:age # format. -libpmishim_so_version=0:0:0 +libpmishim_so_version=1:0:0 diff --git a/config/pmishim_check_visibility.m4 b/config/pmishim_check_visibility.m4 new file mode 100644 index 0000000..bc9e6a2 --- /dev/null +++ b/config/pmishim_check_visibility.m4 @@ -0,0 +1,94 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2007 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017 Intel, Inc. All rights reserved. +# Copyright (c) 2021-2023 Nanook Consulting. All rights reserved. +# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# PMISHIM_CHECK_VISIBILITY +# -------------------------------------------------------- +AC_DEFUN([PMISHIM_CHECK_VISIBILITY],[ + AC_REQUIRE([AC_PROG_GREP]) + + # Check if the compiler has support for visibility, like some + # versions of gcc, icc Sun Studio cc. + AC_ARG_ENABLE(visibility, + AS_HELP_STRING([--enable-visibility], + [enable visibility feature of certain compilers/linkers (default: enabled)])) + + WANT_VISIBILITY=0 + pmishim_msg="whether to enable symbol visibility" + + if test "$enable_visibility" = "no"; then + AC_MSG_CHECKING([$pmishim_msg]) + AC_MSG_RESULT([no (disabled)]) + else + CFLAGS_orig=$CFLAGS + + pmishim_add= + case "$oac_cv_c_compiler_vendor" in + sun) + # Check using Sun Studio -xldscope=hidden flag + pmishim_add=-xldscope=hidden + CFLAGS="$pmishim_add -errwarn=%all" + ;; + + *) + # Check using -fvisibility=hidden + pmishim_add=-fvisibility=hidden + CFLAGS="$pmishim_add -Werror" + ;; + esac + + AC_MSG_CHECKING([if $CC supports $pmishim_add]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + __attribute__((visibility("default"))) int foo; + ]],[[fprintf(stderr, "Hello, world\n");]])], + [AS_IF([test -s conftest.err], + [$GREP -iq visibility conftest.err + # If we find "visibility" in the stderr, then + # assume it doesn't work + AS_IF([test "$?" = "0"], [pmishim_add=])]) + ], [pmishim_add=]) + AS_IF([test "$pmishim_add" = ""], + [AC_MSG_RESULT([no])], + [AC_MSG_RESULT([yes])]) + + CFLAGS=$CFLAGS_orig + PMISHIM_VISIBILITY_CFLAGS=$pmishim_add + + if test "$pmishim_add" != "" ; then + WANT_VISIBILITY=1 + CFLAGS="$CFLAGS $PMISHIM_VISIBILITY_CFLAGS" + AC_MSG_CHECKING([$pmishim_msg]) + AC_MSG_RESULT([yes (via $pmishim_add)]) + elif test "$enable_visibility" = "yes"; then + AC_MSG_ERROR([Symbol visibility support requested but compiler does not seem to support it. Aborting]) + else + AC_MSG_CHECKING([$pmishim_msg]) + AC_MSG_RESULT([no (unsupported)]) + fi + unset pmishim_add + fi + + AC_DEFINE_UNQUOTED([PMISHIM_HAVE_VISIBILITY], [$WANT_VISIBILITY], + [Whether C compiler supports symbol visibility or not]) +]) diff --git a/configure.ac b/configure.ac index dafc390..df755a9 100644 --- a/configure.ac +++ b/configure.ac @@ -51,7 +51,7 @@ AC_LANG([C]) AC_INIT([pmi-shim],[m4_normalize(esyscmd([config/pmishim_get_version.sh VERSION --tarball]))], [https://github.com/openpmix/pmi-shim/issues],[pmishim]) -AC_PREREQ([2.71]) +AC_PREREQ([2.70]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(./config) @@ -92,8 +92,8 @@ pmishim_show_subtitle "Checking versions" # Get the version of PMI-SHIM that we are installing -PMISHIM_SAVE_VERSION([pmishim], [PMI-SHIM], [$srcdir/VERSION], - [include/version.h]) +PMISHIM_SAVE_VERSION([PMISHIM], [PMI-SHIM], [$srcdir/VERSION], + [include/pmishim_version.h]) # Get shared library version numbers @@ -152,7 +152,13 @@ AH_TOP([/* -*- c -*- #ifndef PMISHIM_CONFIG_H #define PMISHIM_CONFIG_H -#include "pmishim_config_top.h" +#undef PMISHIM_HAVE_VISIBILITY + +#if PMISHIM_HAVE_VISIBILITY == 1 +#define PMISHIM_EXPORT __attribute__((__visibility__("default"))) +#else +#define PMISHIM_EXPORT +#endif ]) AH_BOTTOM([ @@ -163,7 +169,7 @@ AH_BOTTOM([ # Other basic setup stuff PMISHIM_BASIC_SETUP - +PMISHIM_CHECK_VISIBILITY ############################################################################ # Configuration options @@ -292,6 +298,7 @@ AC_SUBST(CXXFLAGS) AC_CONFIG_FILES([ Makefile src/Makefile + include/Makefile ]) AC_MSG_CHECKING([final CPPFLAGS]) diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..ba8b64b --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,17 @@ +# +# Copyright (c) 2023 Nanook Consulting All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# Install the PMI headers + +include_HEADERS = \ + pmi.h \ + pmi2.h + +nodist_include_HEADERS = \ + pmishim_version.h diff --git a/include/pmi.h b/include/pmi.h index 7a2f528..3348faf 100644 --- a/include/pmi.h +++ b/include/pmi.h @@ -59,6 +59,11 @@ D*/ #define PMI_ERR_INVALID_NUM_PARSED 11 #define PMI_ERR_INVALID_KEYVALP 12 #define PMI_ERR_INVALID_SIZE 13 +#define PMI_ERR_INVALID_KVS 14 + +typedef int PMI_BOOL; +#define PMI_TRUE 1 +#define PMI_FALSE 0 /* PMI Group functions */ @@ -99,7 +104,7 @@ On successful output, initialized will either be 'PMI_TRUE' or 'PMI_FALSE'. - PMI_FALSE - initialize has not been called or previously failed. @*/ - int PMI_Initialized(int *initialized); + int PMI_Initialized(PMI_BOOL *initialized); /*@ PMI_Finalize - finalize the Process Manager Interface @@ -467,6 +472,322 @@ spawned processes through PMI implementation specific 'info_keyval' parameters. int preput_keyval_size, const PMI_keyval_t preput_keyval_vector[], int errors[]); + +/******* EXTENSIONS FOR BACKWARD COMPATIBILITY ******/ + +/*@ +PMI_Get_id - obtain the id of the process group + +Input Parameter: +. length - length of the id_str character array + +Output Parameter: +. id_str - character array that receives the id of the process group + +Return values: ++ PMI_SUCCESS - id successfully obtained +. PMI_ERR_INVALID_ARG - invalid rank argument +. PMI_ERR_INVALID_LENGTH - invalid length argument +- PMI_FAIL - unable to return the id + +Notes: +This function returns a string that uniquely identifies the process group +that the local process belongs to. The string passed in must be at least +as long as the number returned by 'PMI_Get_id_length_max()'. + +@*/ +int PMI_Get_id( char id_str[], int length ); + +/*@ +PMI_Get_kvs_domain_id - obtain the id of the PMI domain + +Input Parameter: +. length - length of id_str character array + +Output Parameter: +. id_str - character array that receives the id of the PMI domain + +Return values: ++ PMI_SUCCESS - id successfully obtained +. PMI_ERR_INVALID_ARG - invalid argument +. PMI_ERR_INVALID_LENGTH - invalid length argument +- PMI_FAIL - unable to return the id + +Notes: +This function returns a string that uniquely identifies the PMI domain +where keyval spaces can be shared. The string passed in must be at least +as long as the number returned by 'PMI_Get_id_length_max()'. + +@*/ +int PMI_Get_kvs_domain_id( char id_str[], int length ); + +/*@ +PMI_Get_id_length_max - obtain the maximum length of an id string + +Output Parameters: +. length - the maximum length of an id string + +Return values: ++ PMI_SUCCESS - length successfully set +. PMI_ERR_INVALID_ARG - invalid argument +- PMI_FAIL - unable to return the maximum length + +Notes: +This function returns the maximum length of a process group id string. + +@*/ +int PMI_Get_id_length_max( int *length ); + +/*@ +PMI_Get_clique_size - obtain the number of processes on the local node + +Output Parameters: +. size - pointer to an integer that receives the size of the clique + +Return values: ++ PMI_SUCCESS - size successfully obtained +. PMI_ERR_INVALID_ARG - invalid argument +- PMI_FAIL - unable to return the clique size + +Notes: +This function returns the number of processes in the local process group that +are on the local node along with the local process. This is a simple topology +function to distinguish between processes that can communicate through IPC +mechanisms (e.g., shared memory) and other network mechanisms. + +@*/ +int PMI_Get_clique_size( int *size ); + +/*@ +PMI_Get_clique_ranks - get the ranks of the local processes in the process group + +Input Parameters: +. length - length of the ranks array + +Output Parameters: +. ranks - pointer to an array of integers that receive the local ranks + +Return values: ++ PMI_SUCCESS - ranks successfully obtained +. PMI_ERR_INVALID_ARG - invalid argument +. PMI_ERR_INVALID_LENGTH - invalid length argument +- PMI_FAIL - unable to return the ranks + +Notes: +This function returns the ranks of the processes on the local node. The array +must be at least as large as the size returned by 'PMI_Get_clique_size()'. This +is a simple topology function to distinguish between processes that can +communicate through IPC mechanisms (e.g., shared memory) and other network +mechanisms. + +@*/ +int PMI_Get_clique_ranks( int ranks[], int length); + +/*@ +PMI_KVS_Create - create a new keyval space + +Input Parameter: +. length - length of the kvsname character array + +Output Parameters: +. kvsname - a string that receives the keyval space name + +Return values: ++ PMI_SUCCESS - keyval space successfully created +. PMI_ERR_INVALID_ARG - invalid argument +. PMI_ERR_INVALID_LENGTH - invalid length argument +- PMI_FAIL - unable to create a new keyval space + +Notes: +This function creates a new keyval space. Everyone in the same process group +can access this keyval space by the name returned by this function. The +function is not collective. Only one process calls this function. The output +parameter, kvsname, must be at least as long as the value returned by +'PMI_KVS_Get_name_length_max()'. + +@*/ +int PMI_KVS_Create( char kvsname[], int length ); + +/*@ +PMI_KVS_Destroy - destroy keyval space + +Input Parameters: +. kvsname - keyval space name + +Return values: ++ PMI_SUCCESS - keyval space successfully destroyed +. PMI_ERR_INVALID_ARG - invalid argument +- PMI_FAIL - unable to destroy the keyval space + +Notes: +This function destroys a keyval space created by 'PMI_KVS_Create()'. + +@*/ +int PMI_KVS_Destroy( const char kvsname[] ); + +/*@ +PMI_KVS_Iter_first - initialize the iterator and get the first value + +Input Parameters: ++ kvsname - keyval space name +. key_len - length of key character array +- val_len - length of val character array + +Output Parameters: ++ key - key +- value - value + +Return values: ++ PMI_SUCCESS - keyval pair successfully retrieved from the keyval space +. PMI_ERR_INVALID_KVS - invalid kvsname argument +. PMI_ERR_INVALID_KEY - invalid key argument +. PMI_ERR_INVALID_KEY_LENGTH - invalid key length argument +. PMI_ERR_INVALID_VAL - invalid val argument +. PMI_ERR_INVALID_VAL_LENGTH - invalid val length argument +- PMI_FAIL - failed to initialize the iterator and get the first keyval pair + +Notes: +This function initializes the iterator for the specified keyval space and +retrieves the first key/val pair. The end of the keyval space is specified +by returning an empty key string. key and val must be at least as long as +the values returned by 'PMI_KVS_Get_key_length_max()' and +'PMI_KVS_Get_value_length_max()'. + +@*/ +int PMI_KVS_Iter_first(const char kvsname[], char key[], int key_len, char val[], int val_len); + +/*@ +PMI_KVS_Iter_next - get the next keyval pair from the keyval space + +Input Parameters: ++ kvsname - keyval space name +. key_len - length of key character array +- val_len - length of val character array + +Output Parameters: ++ key - key +- value - value + +Return values: ++ PMI_SUCCESS - keyval pair successfully retrieved from the keyval space +. PMI_ERR_INVALID_KVS - invalid kvsname argument +. PMI_ERR_INVALID_KEY - invalid key argument +. PMI_ERR_INVALID_KEY_LENGTH - invalid key length argument +. PMI_ERR_INVALID_VAL - invalid val argument +. PMI_ERR_INVALID_VAL_LENGTH - invalid val length argument +- PMI_FAIL - failed to get the next keyval pair + +Notes: +This function retrieves the next keyval pair from the specified keyval space. +'PMI_KVS_Iter_first()' must have been previously called. The end of the keyval +space is specified by returning an empty key string. The output parameters, +key and val, must be at least as long as the values returned by +'PMI_KVS_Get_key_length_max()' and 'PMI_KVS_Get_value_length_max()'. + +@*/ +int PMI_KVS_Iter_next(const char kvsname[], char key[], int key_len, char val[], int val_len); + +/*@ +PMI_Parse_option - create keyval structures from a single command line argument + +Input Parameters: ++ num_args - length of args array +- args - array of command line arguments starting with the argument to be parsed + +Output Parameters: ++ num_parsed - number of elements of the argument array parsed +. keyvalp - pointer to an array of keyvals +- size - size of the allocated array + +Return values: ++ PMI_SUCCESS - success +. PMI_ERR_INVALID_NUM_ARGS - invalid number of arguments +. PMI_ERR_INVALID_ARGS - invalid args argument +. PMI_ERR_INVALID_NUM_PARSED - invalid num_parsed length argument +. PMI_ERR_INVALID_KEYVALP - invalid keyvalp argument +. PMI_ERR_INVALID_SIZE - invalid size argument +- PMI_FAIL - fail + +Notes: +This function removes one PMI specific argument from the command line and +creates the corresponding 'PMI_keyval_t' structure for it. It returns +an array and size to the caller. The array must be freed by 'PMI_Free_keyvals()'. +If the first element of the args array is not a PMI specific argument, the function +returns success and sets num_parsed to zero. If there are multiple PMI specific +arguments in the args array, this function may parse more than one argument as long +as the options are contiguous in the args array. + +@*/ +int PMI_Parse_option(int num_args, char *args[], int *num_parsed, PMI_keyval_t **keyvalp, int *size); + +/*@ +PMI_Args_to_keyval - create keyval structures from command line arguments + +Input Parameters: ++ argcp - pointer to argc +- argvp - pointer to argv + +Output Parameters: ++ keyvalp - pointer to an array of keyvals +- size - size of the allocated array + +Return values: ++ PMI_SUCCESS - success +. PMI_ERR_INVALID_ARG - invalid argument +- PMI_FAIL - fail + +Notes: +This function removes PMI specific arguments from the command line and +creates the corresponding 'PMI_keyval_t' structures for them. It returns +an array and size to the caller that can then be passed to 'PMI_Spawn_multiple()'. +The array can be freed by 'PMI_Free_keyvals()'. The routine 'free()' should +not be used to free this array as there is no requirement that the array be +allocated with 'malloc()'. + +@*/ +int PMI_Args_to_keyval(int *argcp, char *((*argvp)[]), PMI_keyval_t **keyvalp, int *size); + +/*@ +PMI_Free_keyvals - free the keyval structures created by PMI_Args_to_keyval + +Input Parameters: ++ keyvalp - array of keyvals +- size - size of the array + +Return values: ++ PMI_SUCCESS - success +. PMI_ERR_INVALID_ARG - invalid argument +- PMI_FAIL - fail + +Notes: + This function frees the data returned by 'PMI_Args_to_keyval' and 'PMI_Parse_option'. + Using this routine instead of 'free' allows the PMI package to track + allocation of storage or to use interal storage as it sees fit. +@*/ +int PMI_Free_keyvals(PMI_keyval_t keyvalp[], int size); + +/*@ +PMI_Get_options - get a string of command line argument descriptions that may be printed to the user + +Input Parameters: +. length - length of str + +Output Parameters: ++ str - description string +- length - length of string or necessary length if input is not large enough + +Return values: ++ PMI_SUCCESS - success +. PMI_ERR_INVALID_ARG - invalid argument +. PMI_ERR_INVALID_LENGTH - invalid length argument +. PMI_ERR_NOMEM - input length too small +- PMI_FAIL - fail + +Notes: + This function returns the command line options specific to the pmi implementation +@*/ +int PMI_Get_options(char *str, int *length); + #if defined(__cplusplus) } #endif diff --git a/include/pmi2.h b/include/pmi2.h index 448197e..76a0f68 100644 --- a/include/pmi2.h +++ b/include/pmi2.h @@ -233,6 +233,29 @@ S*/ @*/ int PMI2_Job_GetId(char jobid[], int jobid_size); +/*@ + PMI2_Job_GetRank - get rank of this job + + Output parameters: + . rank - the rank of this job + + Return values: + Returns 'PMI2_SUCCESS' on success and an PMI error code on failure. + +@*/ +int PMI2_Job_GetRank(int* rank); + +/*@ + PMI2_Info_GetSize - get the number of processes on the node + + Output parameters: + . size - the number of processes on the node + + Return values: + Returns 'PMI2_SUCCESS' on success and an PMI error code on failure. +@*/ +int PMI2_Info_GetSize(int* size); + /*@ PMI2_Job_Connect - connect to the parallel job with ID jobid diff --git a/include/version.h.in b/include/pmishim_version.h.in similarity index 96% rename from include/version.h.in rename to include/pmishim_version.h.in index 4e88f3a..4acddfa 100644 --- a/include/version.h.in +++ b/include/pmishim_version.h.in @@ -29,7 +29,6 @@ #define PMISHIM_MINOR_VERSION @PMISHIM_MINOR_VERSION@ #define PMISHIM_RELEASE_VERSION @PMISHIM_RELEASE_VERSION@ #define PMISHIM_GREEK_VERSION "@PMISHIM_GREEK_VERSION@" -#define PMISHIM_WANT_REPO_REV @PMISHIM_WANT_REPO_REV@ #define PMISHIM_REPO_REV "@PMISHIM_REPO_REV@" #ifdef PMISHIM_VERSION /* If we included version.h, we want the real version, not the diff --git a/src/Makefile.am b/src/Makefile.am index 5f6a0a9..a830466 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,8 +12,15 @@ AM_CPPFLAGS = -I$(top_builddir)/src/include # -# libpmishim[.so|.a] +# libpmi[.so|.a] # -lib_LTLIBRARIES = libpmishim.la -libpmishim_la_SOURCES = pmi1.c pmi2.c -libpmishim_la_LDFLAGS = $(pmix_LDFLAGS) -version-info $(libpmishim_so_version) +lib_LTLIBRARIES = libpmi.la +libpmi_la_SOURCES = pmi1.c +libpmi_la_LDFLAGS = $(pmix_LDFLAGS) -version-info $(libpmishim_so_version) + +# +# libpmi2[.so|.a] +# +lib_LTLIBRARIES += libpmi2.la +libpmi2_la_SOURCES = pmi2.c +libpmi2_la_LDFLAGS = $(pmix_LDFLAGS) -version-info $(libpmishim_so_version) diff --git a/src/include/pmishim_config_bottom.h b/src/include/pmishim_config_bottom.h new file mode 100644 index 0000000..ece91a9 --- /dev/null +++ b/src/include/pmishim_config_bottom.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2013-2015 Intel, Inc. All rights reserved + * Copyright (c) 2016 IBM Corporation. All rights reserved. + * Copyright (c) 2021-2023 Nanook Consulting. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + * This file is included at the bottom of pmishim_config.h, and is + * therefore a) before all the #define's that were output from + * configure, and b) included in most/all files in PMIshim. + * + * Since this file is *only* ever included by pmishim_config.h, and + * pmishim_config.h already has #ifndef/#endif protection, there is no + * need to #ifndef/#endif protection here. + */ + +#ifndef PMISHIM_CONFIG_H +# error "pmishim_config_bottom.h should only be included from config.h(.in)" +#endif + +/* The only purpose of this file is to undef the PACKAGE_ macros + that are put in by autoconf/automake projects. Specifically, if + you include a .h file from another project that defines these + macros (e.g., gmp.h) and then include PMISHIM's config.h, + you'll get a preprocessor conflict. So put these undef's here to + protect us from other package's PACKAGE_ macros. + + Note that we can't put them directly in pmishim_config.h (e.g., via + AH_TOP) because they will be turned into #define's by autoconf. */ + +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef PACKAGE_URL +#undef HAVE_CONFIG_H diff --git a/src/pmi1.c b/src/pmi1.c index c725c11..a079f9c 100644 --- a/src/pmi1.c +++ b/src/pmi1.c @@ -13,6 +13,7 @@ * $HEADER$ */ +#include "src/include/pmishim_config.h" #include "include/pmi.h" #include "pmix.h" @@ -48,7 +49,7 @@ static pmix_proc_t myproc; static int pmi_init = 0; static bool pmi_singleton = false; -PMIX_EXPORT int PMI_Init(int *spawned) +PMISHIM_EXPORT int PMI_Init(int *spawned) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -105,7 +106,7 @@ PMIX_EXPORT int PMI_Init(int *spawned) return convert_err(rc); } -PMIX_EXPORT int PMI_Initialized(int *initialized) +PMISHIM_EXPORT int PMI_Initialized(PMI_BOOL *initialized) { if (NULL == initialized) { return PMI_ERR_INVALID_ARG; @@ -120,7 +121,7 @@ PMIX_EXPORT int PMI_Initialized(int *initialized) return PMI_SUCCESS; } -PMIX_EXPORT int PMI_Finalize(void) +PMISHIM_EXPORT int PMI_Finalize(void) { pmix_status_t rc = PMIX_SUCCESS; @@ -135,7 +136,7 @@ PMIX_EXPORT int PMI_Finalize(void) return convert_err(rc); } -PMIX_EXPORT int PMI_Abort(int flag, const char msg[]) +PMISHIM_EXPORT int PMI_Abort(int flag, const char msg[]) { pmix_status_t rc = PMIX_SUCCESS; @@ -151,7 +152,7 @@ PMIX_EXPORT int PMI_Abort(int flag, const char msg[]) /* KVS_Put - we default to PMIX_GLOBAL scope and ignore the * provided kvsname as we only put into our own nspace */ -PMIX_EXPORT int PMI_KVS_Put(const char kvsname[], const char key[], const char value[]) +PMISHIM_EXPORT int PMI_KVS_Put(const char kvsname[], const char key[], const char value[]) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t val; @@ -178,7 +179,7 @@ PMIX_EXPORT int PMI_KVS_Put(const char kvsname[], const char key[], const char v } /* KVS_Commit */ -PMIX_EXPORT int PMI_KVS_Commit(const char kvsname[]) +PMISHIM_EXPORT int PMI_KVS_Commit(const char kvsname[]) { pmix_status_t rc = PMIX_SUCCESS; @@ -195,7 +196,7 @@ PMIX_EXPORT int PMI_KVS_Commit(const char kvsname[]) return convert_err(rc); } -PMIX_EXPORT int PMI_KVS_Get( const char kvsname[], const char key[], char value[], int length) +PMISHIM_EXPORT int PMI_KVS_Get( const char kvsname[], const char key[], char value[], int length) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -257,7 +258,7 @@ PMIX_EXPORT int PMI_KVS_Get( const char kvsname[], const char key[], char value[ /* Barrier only applies to our own nspace, and we want all * data to be collected upon completion */ -PMIX_EXPORT int PMI_Barrier(void) +PMISHIM_EXPORT int PMI_Barrier(void) { pmix_status_t rc = PMIX_SUCCESS; pmix_info_t buf; @@ -282,7 +283,7 @@ PMIX_EXPORT int PMI_Barrier(void) return convert_err(rc); } -PMIX_EXPORT int PMI_Get_size(int *size) +PMISHIM_EXPORT int PMI_Get_size(int *size) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -319,7 +320,7 @@ PMIX_EXPORT int PMI_Get_size(int *size) return convert_err(rc); } -PMIX_EXPORT int PMI_Get_rank(int *rk) +PMISHIM_EXPORT int PMI_Get_rank(int *rk) { PMI_CHECK(); @@ -331,7 +332,7 @@ PMIX_EXPORT int PMI_Get_rank(int *rk) return PMI_SUCCESS; } -PMIX_EXPORT int PMI_Get_universe_size(int *size) +PMISHIM_EXPORT int PMI_Get_universe_size(int *size) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -368,7 +369,7 @@ PMIX_EXPORT int PMI_Get_universe_size(int *size) return convert_err(rc); } -PMIX_EXPORT int PMI_Get_appnum(int *appnum) +PMISHIM_EXPORT int PMI_Get_appnum(int *appnum) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -407,7 +408,7 @@ PMIX_EXPORT int PMI_Get_appnum(int *appnum) return convert_err(rc); } -PMIX_EXPORT int PMI_Publish_name(const char service_name[], const char port[]) +PMISHIM_EXPORT int PMI_Publish_name(const char service_name[], const char port[]) { pmix_status_t rc = PMIX_SUCCESS; pmix_info_t info; @@ -434,7 +435,7 @@ PMIX_EXPORT int PMI_Publish_name(const char service_name[], const char port[]) return convert_err(rc); } -PMIX_EXPORT int PMI_Unpublish_name(const char service_name[]) +PMISHIM_EXPORT int PMI_Unpublish_name(const char service_name[]) { pmix_status_t rc = PMIX_SUCCESS; char *keys[2]; @@ -457,7 +458,7 @@ PMIX_EXPORT int PMI_Unpublish_name(const char service_name[]) return convert_err(rc); } -PMIX_EXPORT int PMI_Lookup_name(const char service_name[], char port[]) +PMISHIM_EXPORT int PMI_Lookup_name(const char service_name[], char port[]) { pmix_status_t rc = PMIX_SUCCESS; pmix_pdata_t pdata; @@ -498,7 +499,7 @@ PMIX_EXPORT int PMI_Lookup_name(const char service_name[], char port[]) return PMIX_SUCCESS; } -PMIX_EXPORT int PMI_Get_id(char id_str[], int length) +PMISHIM_EXPORT int PMI_Get_id(char id_str[], int length) { /* we already obtained our nspace during PMI_Init, * so all we have to do here is return it */ @@ -517,7 +518,7 @@ PMIX_EXPORT int PMI_Get_id(char id_str[], int length) return PMI_SUCCESS; } -PMIX_EXPORT int PMI_Get_kvs_domain_id(char id_str[], int length) +PMISHIM_EXPORT int PMI_Get_kvs_domain_id(char id_str[], int length) { PMI_CHECK(); @@ -525,7 +526,7 @@ PMIX_EXPORT int PMI_Get_kvs_domain_id(char id_str[], int length) return PMI_Get_id(id_str, length); } -PMIX_EXPORT int PMI_Get_id_length_max(int *length) +PMISHIM_EXPORT int PMI_Get_id_length_max(int *length) { PMI_CHECK(); @@ -537,7 +538,7 @@ PMIX_EXPORT int PMI_Get_id_length_max(int *length) return PMI_SUCCESS; } -PMIX_EXPORT int PMI_Get_clique_size(int *size) +PMISHIM_EXPORT int PMI_Get_clique_size(int *size) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -574,7 +575,7 @@ PMIX_EXPORT int PMI_Get_clique_size(int *size) return convert_err(rc); } -PMIX_EXPORT int PMI_Get_clique_ranks(int ranks[], int length) +PMISHIM_EXPORT int PMI_Get_clique_ranks(int ranks[], int length) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -609,7 +610,7 @@ PMIX_EXPORT int PMI_Get_clique_ranks(int ranks[], int length) return convert_err(rc); } -PMIX_EXPORT int PMI_KVS_Get_my_name(char kvsname[], int length) +PMISHIM_EXPORT int PMI_KVS_Get_my_name(char kvsname[], int length) { PMI_CHECK(); @@ -617,7 +618,7 @@ PMIX_EXPORT int PMI_KVS_Get_my_name(char kvsname[], int length) return PMI_Get_id(kvsname, length); } -PMIX_EXPORT int PMI_KVS_Get_name_length_max(int *length) +PMISHIM_EXPORT int PMI_KVS_Get_name_length_max(int *length) { PMI_CHECK(); @@ -629,7 +630,7 @@ PMIX_EXPORT int PMI_KVS_Get_name_length_max(int *length) return PMI_SUCCESS; } -PMIX_EXPORT int PMI_KVS_Get_key_length_max(int *length) +PMISHIM_EXPORT int PMI_KVS_Get_key_length_max(int *length) { PMI_CHECK(); @@ -641,7 +642,7 @@ PMIX_EXPORT int PMI_KVS_Get_key_length_max(int *length) return PMI_SUCCESS; } -PMIX_EXPORT int PMI_KVS_Get_value_length_max(int *length) +PMISHIM_EXPORT int PMI_KVS_Get_value_length_max(int *length) { PMI_CHECK(); @@ -657,33 +658,33 @@ PMIX_EXPORT int PMI_KVS_Get_value_length_max(int *length) /* nobody supports this call, which is why it was * dropped for PMI-2 */ -PMIX_EXPORT int PMI_KVS_Create(char kvsname[], int length) +PMISHIM_EXPORT int PMI_KVS_Create(char kvsname[], int length) { return PMI_FAIL; } /* nobody supports this call, which is why it was * dropped for PMI-2 */ -PMIX_EXPORT int PMI_KVS_Destroy(const char kvsname[]) +PMISHIM_EXPORT int PMI_KVS_Destroy(const char kvsname[]) { return PMI_FAIL; } /* nobody supports this call, which is why it was * dropped for PMI-2 */ -PMIX_EXPORT int PMI_KVS_Iter_first(const char kvsname[], char key[], int key_len, char val[], int val_len) +PMISHIM_EXPORT int PMI_KVS_Iter_first(const char kvsname[], char key[], int key_len, char val[], int val_len) { return PMI_FAIL; } /* nobody supports this call, which is why it was * dropped for PMI-2 */ -PMIX_EXPORT int PMI_KVS_Iter_next(const char kvsname[], char key[], int key_len, char val[], int val_len) +PMISHIM_EXPORT int PMI_KVS_Iter_next(const char kvsname[], char key[], int key_len, char val[], int val_len) { return PMI_FAIL; } -PMIX_EXPORT int PMI_Spawn_multiple(int count, +PMISHIM_EXPORT int PMI_Spawn_multiple(int count, const char * cmds[], const char ** argvs[], const int maxprocs[], @@ -755,28 +756,28 @@ PMIX_EXPORT int PMI_Spawn_multiple(int count, /* nobody supports this call, which is why it was * dropped for PMI-2 */ -PMIX_EXPORT int PMI_Parse_option(int num_args, char *args[], int *num_parsed, PMI_keyval_t **keyvalp, int *size) +PMISHIM_EXPORT int PMI_Parse_option(int num_args, char *args[], int *num_parsed, PMI_keyval_t **keyvalp, int *size) { return PMI_FAIL; } /* nobody supports this call, which is why it was * dropped for PMI-2 */ -PMIX_EXPORT int PMI_Args_to_keyval(int *argcp, char *((*argvp)[]), PMI_keyval_t **keyvalp, int *size) +PMISHIM_EXPORT int PMI_Args_to_keyval(int *argcp, char *((*argvp)[]), PMI_keyval_t **keyvalp, int *size) { return PMI_FAIL; } /* nobody supports this call, which is why it was * dropped for PMI-2 */ -PMIX_EXPORT int PMI_Free_keyvals(PMI_keyval_t keyvalp[], int size) +PMISHIM_EXPORT int PMI_Free_keyvals(PMI_keyval_t keyvalp[], int size) { return PMI_FAIL; } /* nobody supports this call, which is why it was * dropped for PMI-2 */ -PMIX_EXPORT int PMI_Get_options(char *str, int *length) +PMISHIM_EXPORT int PMI_Get_options(char *str, int *length) { return PMI_FAIL; } diff --git a/src/pmi2.c b/src/pmi2.c index 3ad1619..4e0eee4 100644 --- a/src/pmi2.c +++ b/src/pmi2.c @@ -13,6 +13,8 @@ * $HEADER$ */ +#include "src/include/pmishim_config.h" + #ifdef HAVE_STRING_H #include #endif @@ -43,7 +45,7 @@ static int pmi2_init = 0; static bool commit_reqd = false; static bool pmi2_singleton = false; -PMIX_EXPORT int PMI2_Init(int *spawned, int *size, int *rank, int *appnum) +PMISHIM_EXPORT int PMI2_Init(int *spawned, int *size, int *rank, int *appnum) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -141,7 +143,7 @@ PMIX_EXPORT int PMI2_Init(int *spawned, int *size, int *rank, int *appnum) return convert_err(rc); } -PMIX_EXPORT int PMI2_Initialized(void) +PMISHIM_EXPORT int PMI2_Initialized(void) { int initialized; if (pmi2_singleton) { @@ -152,7 +154,7 @@ PMIX_EXPORT int PMI2_Initialized(void) return initialized; } -PMIX_EXPORT int PMI2_Finalize(void) +PMISHIM_EXPORT int PMI2_Finalize(void) { pmix_status_t rc = PMIX_SUCCESS; @@ -167,7 +169,12 @@ PMIX_EXPORT int PMI2_Finalize(void) return convert_err(rc); } -PMIX_EXPORT int PMI2_Abort(int flag, const char msg[]) +PMISHIM_EXPORT int PMI2_Set_threaded(int is_threaded) +{ + return PMI2_FAIL; +} + +PMISHIM_EXPORT int PMI2_Abort(int flag, const char msg[]) { pmix_status_t rc = PMIX_SUCCESS; @@ -181,7 +188,7 @@ PMIX_EXPORT int PMI2_Abort(int flag, const char msg[]) return convert_err(rc); } -PMIX_EXPORT int PMI2_Job_Spawn(int count, const char * cmds[], +PMISHIM_EXPORT int PMI2_Job_Spawn(int count, const char * cmds[], int argcs[], const char ** argvs[], const int maxprocs[], const int info_keyval_sizes[], @@ -250,7 +257,7 @@ PMIX_EXPORT int PMI2_Job_Spawn(int count, const char * cmds[], return convert_err(rc); } -PMIX_EXPORT int PMI2_Job_GetId(char jobid[], int jobid_size) +PMISHIM_EXPORT int PMI2_Job_GetId(char jobid[], int jobid_size) { /* we already obtained our nspace during pmi2_init, * so all we have to do here is return it */ @@ -265,7 +272,7 @@ PMIX_EXPORT int PMI2_Job_GetId(char jobid[], int jobid_size) return PMI2_SUCCESS; } -PMIX_EXPORT int PMI2_Job_GetRank(int *rank) +PMISHIM_EXPORT int PMI2_Job_GetRank(int *rank) { PMI2_CHECK(); @@ -276,7 +283,7 @@ PMIX_EXPORT int PMI2_Job_GetRank(int *rank) return PMI2_SUCCESS; } -PMIX_EXPORT int PMI2_Info_GetSize(int *size) +PMISHIM_EXPORT int PMI2_Info_GetSize(int *size) { pmix_status_t rc = PMIX_ERROR; pmix_value_t *val; @@ -313,7 +320,7 @@ PMIX_EXPORT int PMI2_Info_GetSize(int *size) return convert_err(rc); } -PMIX_EXPORT int PMI2_Job_Connect(const char jobid[], PMI2_Connect_comm_t *conn) +PMISHIM_EXPORT int PMI2_Job_Connect(const char jobid[], PMI2_Connect_comm_t *conn) { pmix_status_t rc = PMIX_SUCCESS; pmix_proc_t proc; @@ -335,7 +342,7 @@ PMIX_EXPORT int PMI2_Job_Connect(const char jobid[], PMI2_Connect_comm_t *conn) return convert_err(rc); } -PMIX_EXPORT int PMI2_Job_Disconnect(const char jobid[]) +PMISHIM_EXPORT int PMI2_Job_Disconnect(const char jobid[]) { pmix_status_t rc = PMIX_SUCCESS; pmix_proc_t proc; @@ -354,7 +361,7 @@ PMIX_EXPORT int PMI2_Job_Disconnect(const char jobid[]) } /* KVS_Put - we default to PMIX_GLOBAL scope */ -PMIX_EXPORT int PMI2_KVS_Put(const char key[], const char value[]) +PMISHIM_EXPORT int PMI2_KVS_Put(const char key[], const char value[]) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t val; @@ -378,7 +385,7 @@ PMIX_EXPORT int PMI2_KVS_Put(const char key[], const char value[]) } /* KVS_Fence */ -PMIX_EXPORT int PMI2_KVS_Fence(void) +PMISHIM_EXPORT int PMI2_KVS_Fence(void) { pmix_status_t rc = PMIX_SUCCESS; @@ -416,7 +423,7 @@ PMIX_EXPORT int PMI2_KVS_Fence(void) * will use the local nspace, which matches the PMI2 spec. * The only type of value supported by PMI2 is a string, so * the return of anything else is an error */ -PMIX_EXPORT int PMI2_KVS_Get(const char *jobid, int src_pmi_id, +PMISHIM_EXPORT int PMI2_KVS_Get(const char *jobid, int src_pmi_id, const char key[], char value [], int maxvalue, int *vallen) { @@ -459,7 +466,7 @@ PMIX_EXPORT int PMI2_KVS_Get(const char *jobid, int src_pmi_id, return convert_err(rc); } -PMIX_EXPORT int PMI2_Info_GetNodeAttr(const char name[], +PMISHIM_EXPORT int PMI2_Info_GetNodeAttr(const char name[], char value[], int valuelen, int *found, int waitfor) { @@ -506,14 +513,14 @@ PMIX_EXPORT int PMI2_Info_GetNodeAttr(const char name[], return convert_err(rc); } -PMIX_EXPORT int PMI2_Info_GetNodeAttrIntArray(const char name[], int array[], +PMISHIM_EXPORT int PMI2_Info_GetNodeAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *found) { return PMI2_FAIL; } /* push info at the PMIX_LOCAL scope */ -PMIX_EXPORT int PMI2_Info_PutNodeAttr(const char name[], const char value[]) +PMISHIM_EXPORT int PMI2_Info_PutNodeAttr(const char name[], const char value[]) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t val; @@ -534,7 +541,7 @@ PMIX_EXPORT int PMI2_Info_PutNodeAttr(const char name[], const char value[]) return convert_err(rc); } -PMIX_EXPORT int PMI2_Info_GetJobAttr(const char name[], char value[], int valuelen, int *found) +PMISHIM_EXPORT int PMI2_Info_GetJobAttr(const char name[], char value[], int valuelen, int *found) { pmix_status_t rc = PMIX_SUCCESS; pmix_value_t *val; @@ -605,14 +612,14 @@ PMIX_EXPORT int PMI2_Info_GetJobAttr(const char name[], char value[], int valuel return convert_err(rc); } -PMIX_EXPORT int PMI2_Info_GetJobAttrIntArray(const char name[], +PMISHIM_EXPORT int PMI2_Info_GetJobAttrIntArray(const char name[], int array[], int arraylen, int *outlen, int *found) { return PMI2_FAIL; } -PMIX_EXPORT int PMI2_Nameserv_publish(const char service_name[], +PMISHIM_EXPORT int PMI2_Nameserv_publish(const char service_name[], const PMI2_keyval_t *info_ptr, const char port[]) { pmix_status_t rc = PMIX_SUCCESS; @@ -649,7 +656,7 @@ PMIX_EXPORT int PMI2_Nameserv_publish(const char service_name[], return convert_err(rc); } -PMIX_EXPORT int PMI2_Nameserv_lookup(const char service_name[], +PMISHIM_EXPORT int PMI2_Nameserv_lookup(const char service_name[], const PMI2_keyval_t *info_ptr, char port[], int portLen) { @@ -708,7 +715,7 @@ PMIX_EXPORT int PMI2_Nameserv_lookup(const char service_name[], return PMI2_SUCCESS; } -PMIX_EXPORT int PMI2_Nameserv_unpublish(const char service_name[], +PMISHIM_EXPORT int PMI2_Nameserv_unpublish(const char service_name[], const PMI2_keyval_t *info_ptr) { pmix_status_t rc = PMIX_SUCCESS;