Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:35:30

0001 /*
0002  * Copyright (c) 2013-2020 Intel, Inc.  All rights reserved.
0003  * Copyright (c) 2016      Research Organization for Information Science
0004  *                         and Technology (RIST). All rights reserved.
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions are
0008  * met:
0009  *
0010  * - Redistributions of source code must retain the above copyright
0011  *   notice, this list of conditions and the following disclaimer.
0012  *
0013  * - Redistributions in binary form must reproduce the above copyright
0014  *   notice, this list of conditions and the following disclaimer listed
0015  *   in this license in the documentation and/or other materials
0016  *   provided with the distribution.
0017  *
0018  * - Neither the name of the copyright holders nor the names of its
0019  *   contributors may be used to endorse or promote products derived from
0020  *   this software without specific prior written permission.
0021  *
0022  * The copyright holders provide no reassurances that the source code
0023  * provided does not infringe any patent, copyright, or any other
0024  * intellectual property rights of third parties.  The copyright holders
0025  * disclaim any liability to any recipient for claims brought against
0026  * recipient by any third party for infringement of that parties
0027  * intellectual property rights.
0028  *
0029  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0030  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0031  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0032  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0033  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0034  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0035  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0036  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0037  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0038  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0039  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0040  *
0041  * Copyright (c) 2021-2026 Nanook Consulting  All rights reserved.
0042  * $COPYRIGHT$
0043  *
0044  * Additional copyrights may follow
0045  *
0046  * $HEADER$
0047  */
0048 
0049 #ifndef PMIx_H
0050 #define PMIx_H
0051 
0052 /* Structure and constant definitions */
0053 #include <pmix_common.h>
0054 
0055 #if defined(c_plusplus) || defined(__cplusplus)
0056 extern "C" {
0057 #endif
0058 
0059 /****    PMIX API    ****/
0060 
0061 /* Initialize the PMIx client, returning the process identifier assigned
0062  * to this client's application in the provided pmix_proc_t struct.
0063  * Passing a parameter of _NULL_ for this parameter is allowed if the user
0064  * wishes solely to initialize the PMIx system and does not require
0065  * return of the identifier at that time.
0066  *
0067  * When called the PMIx client will check for the required connection
0068  * information of the local PMIx server and will establish the connection.
0069  * If the information is not found, or the server connection fails, then
0070  * an appropriate error constant will be returned.
0071  *
0072  * If successful, the function will return PMIX_SUCCESS and will fill the
0073  * provided structure with the server-assigned namespace and rank of the
0074  * process within the application.
0075  *
0076  * Note that the PMIx client library is referenced counted, and so multiple
0077  * calls to PMIx_Init are allowed. Thus, one way to obtain the namespace and
0078  * rank of the process is to simply call PMIx_Init with a non-NULL parameter.
0079  *
0080  * The info array is used to pass user requests pertaining to the init
0081  * and subsequent operations. Pass a _NULL_ value for the array pointer
0082  * is supported if no directives are desired.
0083  */
0084 PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc,
0085                                     pmix_info_t info[], size_t ninfo);
0086 
0087 /* Finalize the PMIx client, closing the connection to the local server.
0088  * An error code will be returned if, for some reason, the connection
0089  * cannot be closed.
0090  *
0091  * The info array is used to pass user requests regarding the finalize
0092  * operation. This can include:
0093  *
0094  * (a) PMIX_EMBED_BARRIER - By default, PMIx_Finalize does not include an
0095  * internal barrier operation. This attribute directs PMIx_Finalize to
0096  * execute a barrier as part of the finalize operation.
0097  */
0098 PMIX_EXPORT pmix_status_t PMIx_Finalize(const pmix_info_t info[], size_t ninfo);
0099 
0100 
0101 /* Returns _true_ if the PMIx client has been successfully initialized,
0102  * returns _false_ otherwise. Note that the function only reports the
0103  * internal state of the PMIx client - it does not verify an active
0104  * connection with the server, nor that the server is functional. */
0105 PMIX_EXPORT int PMIx_Initialized(void);
0106 
0107 
0108 /* Request that the provided array of procs be aborted, returning the
0109  * provided _status_ and printing the provided message. A _NULL_
0110  * for the proc array indicates that all processes in the caller's
0111  * nspace are to be aborted.
0112  *
0113  * The response to this request is somewhat dependent on the specific resource
0114  * manager and its configuration (e.g., some resource managers will
0115  * not abort the application if the provided _status_ is zero unless
0116  * specifically configured to do so), and thus lies outside the control
0117  * of PMIx itself. However, the client will inform the RM of
0118  * the request that the application be aborted, regardless of the
0119  * value of the provided _status_.
0120  *
0121  * Passing a _NULL_ msg parameter is allowed. Note that race conditions
0122  * caused by multiple processes calling PMIx_Abort are left to the
0123  * server implementation to resolve with regard to which status is
0124  * returned and what messages (if any) are printed. */
0125 PMIX_EXPORT pmix_status_t PMIx_Abort(int status, const char msg[],
0126                                      pmix_proc_t procs[], size_t nprocs);
0127 
0128 
0129 /* Push a value into the client's namespace. The client library will cache
0130  * the information locally until _PMIx_Commit_ is called. The provided scope
0131  * value is passed to the local PMIx server, which will distribute the data
0132  * as directed. */
0133 PMIX_EXPORT pmix_status_t PMIx_Put(pmix_scope_t scope,
0134                                    const char key[],
0135                                    pmix_value_t *val);
0136 
0137 
0138 /* Push all previously _PMIx_Put_ values to the local PMIx server.
0139  * This is an asynchronous operation - the library will immediately
0140  * return to the caller while the data is transmitted to the local
0141  * server in the background */
0142 PMIX_EXPORT pmix_status_t PMIx_Commit(void);
0143 
0144 
0145 /* Execute a blocking barrier across the processes identified in the
0146  * specified array. Passing a _NULL_ pointer as the _procs_ parameter
0147  * indicates that the barrier is to span all processes in the client's
0148  * namespace. Each provided pmix_proc_t struct can pass PMIX_RANK_WILDCARD to
0149  * indicate that all processes in the given namespace are
0150  * participating.
0151  *
0152  * The info array is used to pass user requests regarding the fence
0153  * operation. This can include:
0154  *
0155  * (a) PMIX_COLLECT_DATA - a boolean indicating whether or not the barrier
0156  *     operation is to return the _put_ data from all participating processes.
0157  *     A value of _false_ indicates that the callback is just used as a release
0158  *     and no data is to be returned at that time. A value of _true_ indicates
0159  *     that all _put_ data is to be collected by the barrier. Returned data is
0160  *     cached at the server to reduce memory footprint, and can be retrieved
0161  *     as needed by calls to PMIx_Get(nb).
0162  *
0163  *     Note that for scalability reasons, the default behavior for PMIx_Fence
0164  *     is to _not_ collect the data.
0165  *
0166  * (b) PMIX_COLLECTIVE_ALGO - a comma-delimited string indicating the algos
0167  *     to be used for executing the barrier, in priority order.
0168  *
0169  * (c) PMIX_COLLECTIVE_ALGO_REQD - instructs the host RM that it should return
0170  *     an error if none of the specified algos are available. Otherwise, the RM
0171  *     is to use one of the algos if possible, but is otherwise free to use any
0172  *     of its available methods to execute the operation.
0173  *
0174  * (d) PMIX_TIMEOUT - maximum time for the fence to execute before declaring
0175  *     an error. By default, the RM shall terminate the operation and notify participants
0176  *     if one or more of the indicated procs fails during the fence. However,
0177  *     the timeout parameter can help avoid "hangs" due to programming errors
0178  *     that prevent one or more procs from reaching the "fence".
0179  */
0180 PMIX_EXPORT pmix_status_t PMIx_Fence(const pmix_proc_t procs[], size_t nprocs,
0181                                      const pmix_info_t info[], size_t ninfo);
0182 
0183 /* Non-blocking version of PMIx_Fence. Note that the function will return
0184  * an error if a _NULL_ callback function is given. */
0185 PMIX_EXPORT pmix_status_t PMIx_Fence_nb(const pmix_proc_t procs[], size_t nprocs,
0186                                         const pmix_info_t info[], size_t ninfo,
0187                                         pmix_op_cbfunc_t cbfunc, void *cbdata);
0188 
0189 
0190 /* Retrieve information for the specified _key_ as published by the process
0191  * identified in the given pmix_proc_t, returning a pointer to the value in the
0192  * given address.
0193  *
0194  * This is a blocking operation - the caller will block until
0195  * the specified data has been _PMIx_Put_ by the specified rank. The caller is
0196  * responsible for freeing all memory associated with the returned value when
0197  * no longer required.
0198  *
0199  * The info array is used to pass user requests regarding the get
0200  * operation. This can include:
0201  *
0202  * (a) PMIX_TIMEOUT - maximum time for the get to execute before declaring
0203  *     an error. The timeout parameter can help avoid "hangs" due to programming
0204  *     errors that prevent the target proc from ever exposing its data.
0205  */
0206 PMIX_EXPORT pmix_status_t PMIx_Get(const pmix_proc_t *proc, const char key[],
0207                                    const pmix_info_t info[], size_t ninfo,
0208                                    pmix_value_t **val);
0209 
0210 /* A non-blocking operation version of PMIx_Get - the callback function will
0211  * be executed once the specified data has been _PMIx_Put_
0212  * by the identified process and retrieved by the local server. The info
0213  * array is used as described above for the blocking form of this call. */
0214 PMIX_EXPORT pmix_status_t PMIx_Get_nb(const pmix_proc_t *proc, const char key[],
0215                                       const pmix_info_t info[], size_t ninfo,
0216                                       pmix_value_cbfunc_t cbfunc, void *cbdata);
0217 
0218 
0219 /* Publish the data in the info array for lookup. By default,
0220  * the data will be published into the PMIX_SESSION range and
0221  * with PMIX_PERSIST_APP persistence. Changes to those values,
0222  * and any additional directives, can be included in the pmix_info_t
0223  * array.
0224  *
0225  * Note that the keys must be unique within the specified
0226  * data range or else an error will be returned (first published
0227  * wins). Attempts to access the data by procs outside of
0228  * the provided data range will be rejected.
0229  *
0230  * The persistence parameter instructs the server as to how long
0231  * the data is to be retained.
0232  *
0233  * The blocking form will block until the server confirms that the
0234  * data has been posted and is available. The non-blocking form will
0235  * return immediately, executing the callback when the server confirms
0236  * availability of the data.
0237  */
0238 PMIX_EXPORT pmix_status_t PMIx_Publish(const pmix_info_t info[], size_t ninfo);
0239 PMIX_EXPORT pmix_status_t PMIx_Publish_nb(const pmix_info_t info[], size_t ninfo,
0240                                           pmix_op_cbfunc_t cbfunc, void *cbdata);
0241 
0242 
0243 /* Lookup information published by this or another process. By default,
0244  * the search will be conducted across the PMIX_SESSION range. Changes
0245  * to the range, and any additional directives, can be provided
0246  * in the pmix_info_t array. Note that the search is also constrained
0247  * to only data published by the current user ID - i.e., the search
0248  * will not return data published by an application being executed
0249  * by another user. There currently is no option to override this
0250  * behavior - such an option may become available later via an
0251  * appropriate pmix_info_t directive.
0252  *
0253  * The "data" parameter consists of an array of pmix_pdata_t struct with the
0254  * keys specifying the requested information. Data will be returned
0255  * for each key in the associated info struct - any key that cannot
0256  * be found will return with a data type of "PMIX_UNDEF". The function
0257  * will return SUCCESS if _any_ values can be found, so the caller
0258  * must check each data element to ensure it was returned.
0259  *
0260  * The proc field in each pmix_pdata_t struct will contain the
0261  * nspace/rank of the process that published the data.
0262  *
0263  * Note: although this is a blocking function, it will _not_ wait
0264  * by default for the requested data to be published. Instead, it
0265  * will block for the time required by the server to lookup its current
0266  * data and return any found items. Thus, the caller is responsible for
0267  * ensuring that data is published prior to executing a lookup, or
0268  * for retrying until the requested data is found
0269  *
0270  * Optionally, the info array can be used to modify this behavior
0271  * by including:
0272  *
0273  * (a) PMIX_WAIT - wait for the requested data to be published. The
0274  *     server is to wait until all data has become available.
0275  *
0276  * (b) PMIX_TIMEOUT - max time to wait for data to become available.
0277  *
0278  */
0279 PMIX_EXPORT pmix_status_t PMIx_Lookup(pmix_pdata_t data[], size_t ndata,
0280                                       const pmix_info_t info[], size_t ninfo);
0281 
0282 /* Non-blocking form of the _PMIx_Lookup_ function. Data for
0283  * the provided NULL-terminated keys array will be returned
0284  * in the provided callback function. As above, the default
0285  * behavior is to _not_ wait for data to be published. The
0286  * info keys can be used to modify the behavior as previously
0287  * described */
0288 PMIX_EXPORT pmix_status_t PMIx_Lookup_nb(char **keys, const pmix_info_t info[], size_t ninfo,
0289                                          pmix_lookup_cbfunc_t cbfunc, void *cbdata);
0290 
0291 
0292 /* Unpublish data posted by this process using the given keys.
0293  * The function will block until the data has been removed by
0294  * the server. A value of _NULL_ for the keys parameter instructs
0295  * the server to remove _all_ data published by this process.
0296  *
0297  * By default, the range is assumed to be PMIX_SESSION. Changes
0298  * to the range, and any additional directives, can be provided
0299  * in the pmix_info_t array */
0300 PMIX_EXPORT pmix_status_t PMIx_Unpublish(char **keys,
0301                                          const pmix_info_t info[], size_t ninfo);
0302 
0303 /* Non-blocking form of the _PMIx_Unpublish_ function. The
0304  * callback function will be executed once the server confirms
0305  * removal of the specified data. */
0306 PMIX_EXPORT pmix_status_t PMIx_Unpublish_nb(char **keys,
0307                                             const pmix_info_t info[], size_t ninfo,
0308                                             pmix_op_cbfunc_t cbfunc, void *cbdata);
0309 
0310 
0311 /* Spawn a new job. The assigned namespace of the spawned applications
0312  * is returned in the nspace parameter - a _NULL_ value in that
0313  * location indicates that the caller doesn't wish to have the
0314  * namespace returned. The nspace array must be at least of size
0315  * PMIX_MAX_NSLEN+1. Behavior of individual resource managers
0316  * may differ, but it is expected that failure of any application
0317  * process to start will result in termination/cleanup of _all_
0318  * processes in the newly spawned job and return of an error
0319  * code to the caller.
0320  *
0321  * By default, the spawned processes will be PMIx "connected" to
0322  * the parent process upon successful launch (see PMIx_Connect
0323  * description for details). Note that this only means that the
0324  * parent process (a) will be given a copy of the  new job's
0325  * information so it can query job-level info without
0326  * incurring any communication penalties, and (b) will receive
0327  * notification of errors from process in the child job.
0328  *
0329  * Job-level directives can be specified in the job_info array. This
0330  * can include:
0331  *
0332  * (a) PMIX_NON_PMI - processes in the spawned job will
0333  *     not be calling PMIx_Init
0334  *
0335  * (b) PMIX_TIMEOUT - declare the spawn as having failed if the launched
0336  *     procs do not call PMIx_Init within the specified time
0337  *
0338  * (c) PMIX_NOTIFY_COMPLETION - notify the parent process when the
0339  *     child job terminates, either normally or with error
0340  */
0341 PMIX_EXPORT pmix_status_t PMIx_Spawn(const pmix_info_t job_info[], size_t ninfo,
0342                                      const pmix_app_t apps[], size_t napps,
0343                                      pmix_nspace_t nspace);
0344 
0345 
0346 /* Non-blocking form of the _PMIx_Spawn_ function. The callback
0347  * will be executed upon launch of the specified applications,
0348  * or upon failure to launch any of them. */
0349 PMIX_EXPORT pmix_status_t PMIx_Spawn_nb(const pmix_info_t job_info[], size_t ninfo,
0350                                         const pmix_app_t apps[], size_t napps,
0351                                         pmix_spawn_cbfunc_t cbfunc, void *cbdata);
0352 
0353 /* Record the specified processes as "connected". Both blocking and non-blocking
0354  * versions are provided. This means that the resource manager should treat the
0355  * failure of any process in the specified group as a reportable event, and take
0356  * appropriate action. Note that different resource managers may respond to
0357  * failures in different manners.
0358  *
0359  * The callback function is to be called once all participating processes have
0360  * called connect. The server is required to return any job-level info for the
0361  * connecting processes that might not already have - i.e., if the connect
0362  * request involves procs from different nspaces, then each proc shall receive
0363  * the job-level info from those nspaces other than their own.
0364  *
0365  * Note: a process can only engage in _one_ connect operation involving the identical
0366  * set of processes at a time. However, a process _can_ be simultaneously engaged
0367  * in multiple connect operations, each involving a different set of processes
0368  *
0369  * As in the case of the fence operation, the info array can be used to pass
0370  * user-level directives regarding the algorithm to be used for the collective
0371  * operation involved in the "connect", timeout constraints, and other options
0372  * available from the host RM */
0373 PMIX_EXPORT pmix_status_t PMIx_Connect(const pmix_proc_t procs[], size_t nprocs,
0374                                        const pmix_info_t info[], size_t ninfo);
0375 
0376 PMIX_EXPORT pmix_status_t PMIx_Connect_nb(const pmix_proc_t procs[], size_t nprocs,
0377                                           const pmix_info_t info[], size_t ninfo,
0378                                           pmix_op_cbfunc_t cbfunc, void *cbdata);
0379 
0380 /* Disconnect a previously connected set of processes. An error will be returned
0381  * if the specified set of procs was not previously "connected". As above, a process
0382  * may be involved in multiple simultaneous disconnect operations. However, a process
0383  * is not allowed to reconnect to a set of procs that has not fully completed
0384  * disconnect - i.e., you have to fully disconnect before you can reconnect to the
0385  * _same_ group of processes. The info array is used as above. */
0386 PMIX_EXPORT pmix_status_t PMIx_Disconnect(const pmix_proc_t procs[], size_t nprocs,
0387                                           const pmix_info_t info[], size_t ninfo);
0388 
0389 PMIX_EXPORT pmix_status_t PMIx_Disconnect_nb(const pmix_proc_t ranges[], size_t nprocs,
0390                                              const pmix_info_t info[], size_t ninfo,
0391                                              pmix_op_cbfunc_t cbfunc, void *cbdata);
0392 
0393 /* Given a node name, return an array of processes within the specified nspace
0394  * on that node. If the nspace is NULL, then all processes on the node will
0395  * be returned. If the specified node does not currently host any processes,
0396  * then the returned array will be NULL, and nprocs=0. The caller is responsible
0397  * for releasing the array when done with it - the PMIX_PROC_FREE macro is
0398  * provided for this purpose.
0399  */
0400 PMIX_EXPORT pmix_status_t PMIx_Resolve_peers(const char *nodename,
0401                                              const pmix_nspace_t nspace,
0402                                              pmix_proc_t **procs, size_t *nprocs);
0403 
0404 
0405 /* Given an nspace, return the list of nodes hosting processes within
0406  * that nspace. The returned string will contain a comma-delimited list
0407  * of nodenames. The caller is responsible for releasing the string
0408  * when done with it */
0409 PMIX_EXPORT pmix_status_t PMIx_Resolve_nodes(const pmix_nspace_t nspace, char **nodelist);
0410 
0411 /* Query information about the system in general - can include
0412  * a list of active nspaces, network topology, etc. Also can be
0413  * used to query node-specific info such as the list of peers
0414  * executing on a given node. We assume that the host RM will
0415  * exercise appropriate access control on the information.
0416  *
0417  * The following return status codes are provided in the callback:
0418  *
0419  * PMIX_SUCCESS - all data has been returned
0420  * PMIX_ERR_NOT_FOUND - none of the requested data was available
0421  * PMIX_ERR_PARTIAL_SUCCESS - some of the data has been returned
0422  * PMIX_ERR_NOT_SUPPORTED - the host RM does not support this function
0423  */
0424 PMIX_EXPORT pmix_status_t PMIx_Query_info(pmix_query_t queries[], size_t nqueries,
0425                                           pmix_info_t **results, size_t *nresults);
0426 
0427 PMIX_EXPORT pmix_status_t PMIx_Query_info_nb(pmix_query_t queries[], size_t nqueries,
0428                                              pmix_info_cbfunc_t cbfunc, void *cbdata);
0429 
0430 /* Log data to a central data service/store, subject to the
0431  * services offered by the host resource manager. The data to
0432  * be logged is provided in the data array. The (optional) directives
0433  * can be used to request specific storage options and direct
0434  * the choice of storage option.
0435  *
0436  * The callback function will be executed when the log operation
0437  * has been completed. The data array must be maintained until
0438  * the callback is provided
0439  */
0440 PMIX_EXPORT pmix_status_t PMIx_Log(const pmix_info_t data[], size_t ndata,
0441                                    const pmix_info_t directives[], size_t ndirs);
0442 
0443 PMIX_EXPORT pmix_status_t PMIx_Log_nb(const pmix_info_t data[], size_t ndata,
0444                                       const pmix_info_t directives[], size_t ndirs,
0445                                       pmix_op_cbfunc_t cbfunc, void *cbdata);
0446 
0447 /* Request an allocation operation from the host scheduler.
0448  * Several broad categories are envisioned, including the ability to:
0449  *
0450  * - request allocation of additional resources, including memory,
0451  *   bandwidth, and compute. This should be accomplished in a
0452  *   non-blocking manner so that the application can continue to
0453  *   progress while waiting for resources to become available. Note
0454  *   that the new allocation will be disjoint from (i.e., not
0455  *   affiliated with) the allocation of the requestor - thus the
0456  *   termination of one allocation will not impact the other.
0457  *
0458  * - extend the reservation on currently allocated resources, subject
0459  *   to scheduling availability and priorities. This includes extending
0460  *   the time limit on current resources, and/or requesting additional
0461  *   resources be allocated to the requesting job. Any additional
0462  *   allocated resources will be considered as part of the current
0463  *   allocation, and thus will be released at the same time.
0464  *
0465  * - release currently allocated resources that are no longer required.
0466  *   This is intended to support partial release of resources since all
0467  *   resources are normally released upon termination of the job. The
0468  *   identified use-cases include resource variations across discrete steps
0469  *   of a workflow, as well as applications that spawn sub-jobs and/or
0470  *   dynamically grow/shrink over time
0471  *
0472  * - "lend" resources back to the scheduler with an expectation of getting
0473  *   them back at some later time in the job. This can be a proactive
0474  *   operation (e.g., to save on computing costs when resources are
0475  *   temporarily not required), or in response to scheduler requests in
0476  *   lieue of preemption. A corresponding ability to "reacquire" resources
0477  *   previously released is included.
0478  */
0479 PMIX_EXPORT pmix_status_t PMIx_Allocation_request(pmix_alloc_directive_t directive,
0480                                                   pmix_info_t *info, size_t ninfo,
0481                                                   pmix_info_t **results, size_t *nresults);
0482 
0483 PMIX_EXPORT pmix_status_t PMIx_Allocation_request_nb(pmix_alloc_directive_t directive,
0484                                                      pmix_info_t *info, size_t ninfo,
0485                                                      pmix_info_cbfunc_t cbfunc, void *cbdata);
0486 
0487 /* Define a resource "block" that can be used in allocation operations.
0488  * Include the ability to define/delete, remove/extend block definitions.
0489  * The provided block name must be unique within the requestor's current
0490  * session.
0491  */
0492 PMIX_EXPORT pmix_status_t PMIx_Resource_block(pmix_resource_block_directive_t directive,
0493                                               char *block,
0494                                               const pmix_resource_unit_t *res, size_t nres,
0495                                               const pmix_info_t *info, size_t ninfo);
0496 
0497 
0498 PMIX_EXPORT pmix_status_t PMIx_Resource_block_nb(pmix_resource_block_directive_t directive,
0499                                                  char *block,
0500                                                  const pmix_resource_unit_t *res, size_t nres,
0501                                                  const pmix_info_t *info, size_t ninfo,
0502                                                  pmix_op_cbfunc_t cbfunc, void *cbdata);
0503 
0504 
0505 /* Request a session control action. The sessionID identifies the session
0506  * to which the specified control action is to be applied. A UINT32_MAX
0507  * value can be used to indicate all sessions under the caller's control.
0508  *
0509  * The directives are provided as pmix_info_t structs in the directives
0510  * array. The callback function provides a status to indicate whether or
0511  * not the request was granted, and to provide some information as to the
0512  * reason for any denial in the pmix_info_cbfunc_t' array of pmix_info_t
0513  * structures. If non-NULL, then the specified release_fn must be called
0514  * when the callback function completes - this will be used to release any
0515  * provided pmix_info_t array.
0516 
0517  * Passing NULL as the cbfunc to this call indicates that it shall be treated
0518  * as a blocking operation, with the return status indicative of the overall
0519  * operation's completion.
0520  */
0521 PMIX_EXPORT pmix_status_t PMIx_Session_control(uint32_t sessionID,
0522                                                const pmix_info_t directives[], size_t ndirs,
0523                                                pmix_info_cbfunc_t cbfunc, void *cbdata);
0524 
0525 /* Request a job control action. The targets array identifies the
0526  * processes to which the requested job control action is to be applied.
0527  * A NULL value can be used to indicate all processes in the caller's
0528  * nspace. The use of PMIX_RANK_WILDARD can also be used to indicate
0529  * that all processes in the given nspace are to be included.
0530  *
0531  * The directives are provided as pmix_info_t structs in the directives
0532  * array. The callback function provides a status to indicate whether or
0533  * not the request was granted, and to provide some information as to
0534  * the reason for any denial in the pmix_info_cbfunc_t array of pmix_info_t
0535  * structures. If non-NULL, then the specified release_fn must be called
0536  * when the callback function completes - this will be used to release
0537  * any provided pmix_info_t array.
0538  */
0539 PMIX_EXPORT pmix_status_t PMIx_Job_control(const pmix_proc_t targets[], size_t ntargets,
0540                                            const pmix_info_t directives[], size_t ndirs,
0541                                            pmix_info_t **results, size_t *nresults);
0542 
0543 PMIX_EXPORT pmix_status_t PMIx_Job_control_nb(const pmix_proc_t targets[], size_t ntargets,
0544                                               const pmix_info_t directives[], size_t ndirs,
0545                                               pmix_info_cbfunc_t cbfunc, void *cbdata);
0546 
0547 /* Request that something be monitored - e.g., that the server monitor
0548  * this process for periodic heartbeats as an indication that the process
0549  * has not become "wedged". When a monitor detects the specified alarm
0550  * condition, it will generate an event notification using the provided
0551  * error code and passing along any available relevant information. It is
0552  * up to the caller to register a corresponding event handler.
0553  *
0554  * Params:
0555  *
0556  * monitor: attribute indicating the type of monitor being requested - e.g.,
0557  *          PMIX_MONITOR_FILE to indicate that the requestor is asking that
0558  *          a file be monitored.
0559  *
0560  * error: the status code to be used when generating an event notification
0561  *        alerting that the monitor has been triggered. The range of the
0562  *        notification defaults to PMIX_RANGE_NAMESPACE - this can be
0563  *        changed by providing a PMIX_RANGE directive
0564  *
0565  * directives: characterize the monitoring request (e.g., monitor file size)
0566  *             and frequency of checking to be done
0567  *
0568  * cbfunc: provides a status to indicate whether or not the request was granted,
0569  *         and to provide some information as to the reason for any denial in
0570  *         the pmix_info_cbfunc_t array of pmix_info_t structures.
0571  *
0572  * Note: a process can send a heartbeat to the server using the PMIx_Heartbeat
0573  * macro provided below*/
0574 PMIX_EXPORT pmix_status_t PMIx_Process_monitor(const pmix_info_t *monitor, pmix_status_t error,
0575                                                const pmix_info_t directives[], size_t ndirs,
0576                                                pmix_info_t **results, size_t *nresults);
0577 
0578 PMIX_EXPORT pmix_status_t PMIx_Process_monitor_nb(const pmix_info_t *monitor, pmix_status_t error,
0579                                                   const pmix_info_t directives[], size_t ndirs,
0580                                                   pmix_info_cbfunc_t cbfunc, void *cbdata);
0581 
0582 /* define a special function to simplify sending of a heartbeat */
0583 PMIX_EXPORT void PMIx_Heartbeat(void);
0584 
0585 /* Request a credential from the PMIx server/SMS.
0586  * Input values include:
0587  *
0588  * info - an array of pmix_info_t structures containing any directives the
0589  *        caller may wish to pass. Typical usage might include:
0590  *            PMIX_TIMEOUT - how long to wait (in seconds) for a credential
0591  *                           before timing out and returning an error
0592  *            PMIX_CRED_TYPE - a prioritized, comma-delimited list of desired
0593  *                             credential types for use in environments where
0594  *                             multiple authentication mechanisms may be
0595  *                             available
0596  *
0597  * ninfo - number of elements in the info array
0598  *
0599  * cbfunc - the pmix_credential_cbfunc_t function to be called upon completion
0600  *          of the request
0601  *
0602  * cbdata - pointer to an object to be returned when cbfunc is called
0603  *
0604  * Returned values:
0605  * PMIX_SUCCESS - indicates that the request has been successfully communicated to
0606  *                the local PMIx server. The response will be coming in the provided
0607  *                callback function.
0608  *
0609  * Any other value indicates an appropriate error condition. The callback function
0610  * will _not_ be called in such cases.
0611  */
0612 PMIX_EXPORT pmix_status_t PMIx_Get_credential(const pmix_info_t info[], size_t ninfo,
0613                                               pmix_byte_object_t *credential);
0614 
0615 PMIX_EXPORT pmix_status_t PMIx_Get_credential_nb(const pmix_info_t info[], size_t ninfo,
0616                                                  pmix_credential_cbfunc_t cbfunc, void *cbdata);
0617 
0618 /* Request validation of a credential by the PMIx server/SMS
0619  * Input values include:
0620  *
0621  * cred - pointer to a pmix_byte_object_t containing the credential
0622  *
0623  * info - an array of pmix_info_t structures containing any directives the
0624  *        caller may wish to pass. Typical usage might include:
0625  *            PMIX_TIMEOUT - how long to wait (in seconds) for validation
0626  *                           before timing out and returning an error
0627  *            PMIX_USERID - the expected effective userid of the credential
0628  *                          to be validated
0629  *            PMIX_GROUPID - the expected effective group id of the credential
0630  *                          to be validated
0631  *
0632  * ninfo - number of elements in the info array
0633  *
0634  * cbfunc - the pmix_validation_cbfunc_t function to be called upon completion
0635  *          of the request
0636  *
0637  * cbdata - pointer to an object to be returned when cbfunc is called
0638  *
0639  * Returned values:
0640  * PMIX_SUCCESS - indicates that the request has been successfully communicated to
0641  *                the local PMIx server. The response will be coming in the provided
0642  *                callback function.
0643  *
0644  * Any other value indicates an appropriate error condition. The callback function
0645  * will _not_ be called in such cases.
0646  */
0647 PMIX_EXPORT pmix_status_t PMIx_Validate_credential(const pmix_byte_object_t *cred,
0648                                                    const pmix_info_t info[], size_t ninfo,
0649                                                    pmix_info_t **results, size_t *nresults);
0650 
0651 PMIX_EXPORT pmix_status_t PMIx_Validate_credential_nb(const pmix_byte_object_t *cred,
0652                                                       const pmix_info_t info[], size_t ninfo,
0653                                                       pmix_validation_cbfunc_t cbfunc, void *cbdata);
0654 
0655 
0656 /* Construct a new group composed of the specified processes and identified with
0657  * the provided group identifier. Both blocking and non-blocking versions
0658  * are provided (the callback function for the non-blocking form will be called
0659  * once all specified processes have joined the group). The group identifier is
0660  * a user-defined, NULL-terminated character array of length less than or equal
0661  * to PMIX_MAX_NSLEN. Only characters accepted by standard string comparison
0662  * functions (e.g., strncmp) are supported.
0663  *
0664  * Processes may engage in multiple simultaneous group construct operations as
0665  * desired so long as each is provided with a unique group ID. The info array
0666  * can be used to pass user-level directives regarding timeout constraints and
0667  * other options available from the PMIx server.
0668  *
0669  * The construct leader (if PMIX_GROUP_LEADER is provided) or all participants
0670  * will receive events (if registered for the PMIX_GROUP_MEMBER_FAILED event)
0671  * whenever a process fails or terminates prior to calling
0672  * PMIx_Group_construct(_nb) – the events will contain the identifier of the
0673  * process that failed to join plus any other information that the resource
0674  * manager provided. This provides an opportunity for the leader to react to
0675  * the event – e.g., to invite an alternative member to the group or to decide
0676  * to proceed with a smaller group. The decision to proceed with a smaller group
0677  * is communicated to the PMIx library in the results array at the end of the
0678  * event handler. This allows PMIx to properly adjust accounting for procedure
0679  * completion. When construct is complete, the participating PMIx servers will
0680  * be alerted to any change in participants and each group member will (if
0681  * registered) receive a PMIX_GROUP_MEMBERSHIP_UPDATE event updating the group
0682  * membership.
0683  *
0684  * Processes in a group under construction are not allowed to leave the group
0685  * until group construction is complete. Upon completion of the construct
0686  * procedure, each group member will have access to the job-level information
0687  * of all nspaces represented in the group and the contact information for
0688  * every group member.
0689  *
0690  * Failure of the leader at any time will cause a PMIX_GROUP_LEADER_FAILED event
0691  * to be delivered to all participants so they can optionally declare a new leader.
0692  * A new leader is identified by providing the PMIX_GROUP_LEADER attribute in
0693  * the results array in the return of the event handler. Only one process is
0694  * allowed to return that attribute, declaring itself as the new leader. Results
0695  * of the leader selection will be communicated to all participants via a
0696  * PMIX_GROUP_LEADER_SELECTED event identifying the new leader. If no leader
0697  * was selected, then the status code provided in the event handler will provide
0698  * an error value so the participants can take appropriate action.
0699  *
0700  * Any participant that returns PMIX_GROUP_CONSTRUCT_ABORT from the leader failed
0701  * event handler will cause the construct process to abort. Those processes
0702  * engaged in the blocking construct will return from the call with the
0703  * PMIX_GROUP_CONSTRUCT_ABORT status. Non-blocking participants will have
0704  * their callback function executed with that status.
0705  *
0706  * Some relevant attributes for this operation:
0707  *    PMIX_GROUP_LEADER - declare this process to be the leader of the construction
0708  *                        procedure. If a process provides this attribute, then
0709  *                        failure notification for any participating process will
0710  *                        go only to that one process. In the absence of a
0711  *                        declared leader, failure events go to all participants.
0712  *    PMIX_GROUP_OPTIONAL - participation is optional - do not return an error if
0713  *                          any of the specified processes terminate
0714  *                          without having joined (default=false)
0715  *    PMIX_GROUP_NOTIFY_TERMINATION - notify remaining members when another member
0716  *                                    terminates without first leaving the
0717  *                                    group (default=false)
0718  *    PMIX_GROUP_ASSIGN_CONTEXT_ID - requests that the RM assign a unique context
0719  *                                   ID (size_t) to the group. The value is returned
0720  *                                   in the PMIX_GROUP_CONSTRUCT_COMPLETE event
0721  *    PMIX_TIMEOUT - return an error if the group doesn't assemble within the
0722  *                   specified number of seconds. Targets the scenario where a
0723  *                   process fails to call PMIx_Group_connect due to hanging
0724  *
0725  */
0726 PMIX_EXPORT pmix_status_t PMIx_Group_construct(const char grp[],
0727                                                const pmix_proc_t procs[], size_t nprocs,
0728                                                const pmix_info_t directives[], size_t ndirs,
0729                                                pmix_info_t **results, size_t *nresults);
0730 
0731 PMIX_EXPORT pmix_status_t PMIx_Group_construct_nb(const char grp[],
0732                                                   const pmix_proc_t procs[], size_t nprocs,
0733                                                   const pmix_info_t info[], size_t ninfo,
0734                                                   pmix_info_cbfunc_t cbfunc, void *cbdata);
0735 
0736 /* Explicitly invite specified processes to join a group.
0737  *
0738  * Each invited process will be notified of the invitation via the PMIX_GROUP_INVITED
0739  * event. The processes being invited must have registered for the PMIX_GROUP_INVITED
0740  * event in order to be notified of the invitation. When ready to respond, each invited
0741  * process provides a response using the appropriate form of PMIx_Group_join. This will
0742  * notify the inviting process that the invitation was either accepted (via the
0743  * PMIX_GROUP_INVITE_ACCEPTED event) or declined (via the PMIX_GROUP_INVITE_DECLINED event).
0744  * The inviting process will also receive PMIX_GROUP_MEMBER_FAILED events whenever a
0745  * process fails or terminates prior to responding to the invitation.
0746  *
0747  * Upon accepting the invitation, both the inviting and invited process will receive
0748  * access to the job-level information of each other’s nspaces and the contact
0749  * information of the other process.
0750  *
0751  * Some relevant attributes for this operation:
0752  *    PMIX_GROUP_ASSIGN_CONTEXT_ID - requests that the RM assign a unique context
0753  *                                   ID (size_t) to the group. The value is returned
0754  *                                   in the PMIX_GROUP_CONSTRUCT_COMPLETE event
0755  *    PMIX_TIMEOUT (int): return an error if the group doesn’t assemble within the
0756  *                        specified number of seconds. Targets the scenario where a
0757  *                        process fails to call PMIx_Group_connect due to hanging
0758  *
0759  * The inviting process is automatically considered the leader of the asynchronous
0760  * group construction procedure and will receive all failure or termination events
0761  * for invited members prior to completion. The inviting process is required to
0762  * provide a PMIX_GROUP_CONSTRUCT_COMPLETE event once the group has been fully
0763  * assembled – this event will be distributed to all participants along with the
0764  * final membership.
0765  *
0766  * Failure of the leader at any time will cause a PMIX_GROUP_LEADER_FAILED event
0767  * to be delivered to all participants so they can optionally declare a new leader.
0768  * A new leader is identified by providing the PMIX_GROUP_LEADER attribute in
0769  * the results array in the return of the event handler. Only one process is
0770  * allowed to return that attribute, declaring itself as the new leader. Results
0771  * of the leader selection will be communicated to all participants via a
0772  * PMIX_GROUP_LEADER_SELECTED event identifying the new leader. If no leader
0773  * was selected, then the status code provided in the event handler will provide
0774  * an error value so the participants can take appropriate action.
0775  *
0776  * Any participant that returns PMIX_GROUP_CONSTRUCT_ABORT from the event
0777  * handler will cause all participants to receive an event notifying them
0778  * of that status.
0779  */
0780 PMIX_EXPORT pmix_status_t PMIx_Group_invite(const char grp[],
0781                                             const pmix_proc_t procs[], size_t nprocs,
0782                                             const pmix_info_t info[], size_t ninfo,
0783                                             pmix_info_t **results, size_t *nresult);
0784 
0785 PMIX_EXPORT pmix_status_t PMIx_Group_invite_nb(const char grp[],
0786                                                const pmix_proc_t procs[], size_t nprocs,
0787                                                const pmix_info_t info[], size_t ninfo,
0788                                                pmix_info_cbfunc_t cbfunc, void *cbdata);
0789 
0790 /* Respond to an invitation to join a group that is being asynchronously constructed.
0791  *
0792  * The process must have registered for the PMIX_GROUP_INVITED event in order to be
0793  * notified of the invitation. When ready to respond, the process provides a response
0794  * using the appropriate form of PMIx_Group_join.
0795  *
0796  * Critical Note: Since the process is alerted to the invitation in a PMIx event handler,
0797  * the process must not use the blocking form of this call unless it first “thread shifts”
0798  * out of the handler and into its own thread context. Likewise, while it is safe to call
0799  * the non-blocking form of the API from the event handler, the process must not block
0800  * in the handler while waiting for the callback function to be called.
0801  *
0802  * Calling this function causes the group “leader” to be notified that the process has
0803  * either accepted or declined the request. The blocking form of the API will return
0804  * once the group has been completely constructed or the group’s construction has failed
0805  * (as determined by the leader) – likewise, the callback function of the non-blocking
0806  * form will be executed upon the same conditions.
0807  *
0808  * Failure of the leader at any time will cause a PMIX_GROUP_LEADER_FAILED event
0809  * to be delivered to all participants so they can optionally declare a new leader.
0810  * A new leader is identified by providing the PMIX_GROUP_LEADER attribute in
0811  * the results array in the return of the event handler. Only one process is
0812  * allowed to return that attribute, declaring itself as the new leader. Results
0813  * of the leader selection will be communicated to all participants via a
0814  * PMIX_GROUP_LEADER_SELECTED event identifying the new leader. If no leader
0815  * was selected, then the status code provided in the event handler will provide
0816  * an error value so the participants can take appropriate action.
0817  *
0818  * Any participant that returns PMIX_GROUP_CONSTRUCT_ABORT from the leader failed
0819  * event handler will cause all participants to receive an event notifying them
0820  * of that status. Similarly, the leader may elect to abort the procedure
0821  * by either returning PMIX_GROUP_CONSTRUCT_ABORT from the handler assigned
0822  * to the PMIX_GROUP_INVITE_ACCEPTED or PMIX_GROUP_INVITE_DECLINED codes, or
0823  * by generating an event for the abort code. Abort events will be sent to
0824  * all invited participants.
0825  */
0826 PMIX_EXPORT pmix_status_t PMIx_Group_join(const char grp[],
0827                                           const pmix_proc_t *leader,
0828                                           pmix_group_opt_t opt,
0829                                           const pmix_info_t info[], size_t ninfo,
0830                                           pmix_info_t **results, size_t *nresult);
0831 
0832 PMIX_EXPORT pmix_status_t PMIx_Group_join_nb(const char grp[],
0833                                              const pmix_proc_t *leader,
0834                                              pmix_group_opt_t opt,
0835                                              const pmix_info_t info[], size_t ninfo,
0836                                              pmix_info_cbfunc_t cbfunc, void *cbdata);
0837 
0838 /* Leave a PMIx Group. Calls to PMIx_Group_leave (or its non-blocking form) will cause
0839  * a PMIX_GROUP_LEFT event to be generated notifying all members of the group of the
0840  * caller’s departure. The function will return (or the non-blocking function will
0841  * execute the specified callback function) once the event has been locally generated
0842  * and is not indicative of remote receipt. All PMIx-based collectives such as
0843  * PMIx_Fence in action across the group will automatically be adjusted if the
0844  * collective was called with the PMIX_GROUP_FT_COLLECTIVE attribute (default is
0845  * false) – otherwise, the standard error return behavior will be provided.
0846  *
0847  * Critical Note: The PMIx_Group_leave API is intended solely for asynchronous
0848  * departures of individual processes from a group as it is not a scalable
0849  * operation – i.e., when a process determines it should no longer be a part of a
0850  * defined group, but the remainder of the group retains a valid reason to continue
0851  * in existence. Developers are advised to use PMIx_Group_destruct (or its
0852  * non-blocking form) for all other scenarios as it represents a more scalable
0853  * operation.
0854  */
0855 PMIX_EXPORT pmix_status_t PMIx_Group_leave(const char grp[],
0856                                            const pmix_info_t info[], size_t ninfo);
0857 
0858 PMIX_EXPORT pmix_status_t PMIx_Group_leave_nb(const char grp[],
0859                                               const pmix_info_t info[], size_t ninfo,
0860                                               pmix_op_cbfunc_t cbfunc, void *cbdata);
0861 
0862 /* Destruct a group identified by the provided group identifier. Both blocking and
0863  * non-blocking versions are provided (the callback function for the non-blocking
0864  * form will be called once all members of the group have called “destruct”).
0865  * Processes may engage in multiple simultaneous group destruct operations as
0866  * desired so long as each involves a unique group ID. The info array can be used
0867  * to pass user-level directives regarding timeout constraints and other options
0868  * available from the PMIx server.
0869  *
0870  * Some relevant attributes for this operation:
0871  *
0872  *    PMIX_TIMEOUT (int): return an error if the group doesn’t destruct within the
0873  *                        specified number of seconds. Targets the scenario where
0874  *                        a process fails to call PMIx_Group_destruct due to hanging
0875  *
0876  * The destruct API will return an error if any group process fails or terminates
0877  * prior to calling PMIx_Group_destruct or its non-blocking version unless the
0878  * PMIX_GROUP_NOTIFY_TERMINATION attribute was provided (with a value of true) at
0879  * time of group construction. If notification was requested, then a event will
0880  * be delivered (using PMIX_GROUP_MEMBER_FAILED) for each process that fails to
0881  * call destruct and the destruct tracker updated to account for the lack of
0882  * participation. The PMIx_Group_destruct operation will subsequently return
0883  * PMIX_SUCCESS when the remaining processes have all called destruct – i.e., the
0884  * event will serve in place of return of an error.
0885  */
0886 PMIX_EXPORT pmix_status_t PMIx_Group_destruct(const char grp[],
0887                                               const pmix_info_t info[], size_t ninfo);
0888 
0889 PMIX_EXPORT pmix_status_t PMIx_Group_destruct_nb(const char grp[],
0890                                                  const pmix_info_t info[], size_t ninfo,
0891                                                  pmix_op_cbfunc_t cbfunc, void *cbdata);
0892 
0893 /****************************************/
0894 /****    COMMON SUPPORT FUNCTIONS    ****/
0895 /****************************************/
0896 
0897 /******     EVENT NOTIFICATION SUPPORT      ******/
0898 /* Register an event handler to report events. Three types of events
0899  * can be reported:
0900  *
0901  * (a) those that occur within the client library, but are not
0902  *     reportable via the API itself (e.g., loss of connection to
0903  *     the server). These events typically occur during behind-the-scenes
0904  *     non-blocking operations.
0905  *
0906  * (b) job-related events such as the failure of another process in
0907  *     the job or in any connected job, impending failure of hardware
0908  *     within the job's usage footprint, etc.
0909  *
0910  * (c) system notifications that are made available by the local
0911  *     administrators
0912  *
0913  * By default, only events that directly affect the process and/or
0914  * any process to which it is connected (via the PMIx_Connect call)
0915  * will be reported. Options to modify that behavior can be provided
0916  * in the info array
0917  *
0918  * Both the client application and the resource manager can register
0919  * err handlers for specific events. PMIx client/server calls the registered
0920  * err handler upon receiving event notify notification (via PMIx_Notify_event)
0921  * from the other end (Resource Manager/Client application).
0922  *
0923  * Multiple err handlers can be registered for different events. PMIX returns
0924  * an integer reference to each register handler in the callback fn. The caller
0925  * must retain the reference in order to deregister the evhdlr.
0926  * Modification of the notification behavior can be accomplished by
0927  * deregistering the current evhdlr, and then registering it
0928  * using a new set of info values.
0929  *
0930  * If cbfunc is NULL, then this is treated as a BLOCKING call - a positive
0931  * return value represents the reference ID for the request, while
0932  * negative values indicate the corresponding error
0933  *
0934  * See pmix_common.h for a description of the notification function */
0935 PMIX_EXPORT pmix_status_t PMIx_Register_event_handler(pmix_status_t codes[], size_t ncodes,
0936                                                       pmix_info_t info[], size_t ninfo,
0937                                                       pmix_notification_fn_t evhdlr,
0938                                                       pmix_hdlr_reg_cbfunc_t cbfunc,
0939                                                       void *cbdata);
0940 
0941 /* Deregister an event handler
0942  * evhdlr_ref is the reference returned by PMIx from the call to
0943  * PMIx_Register_event_handler. If non-NULL, the provided cbfunc
0944  * will be called to confirm removal of the designated handler */
0945 PMIX_EXPORT pmix_status_t PMIx_Deregister_event_handler(size_t evhdlr_ref,
0946                                                         pmix_op_cbfunc_t cbfunc,
0947                                                         void *cbdata);
0948 
0949 /* Report an event for notification via any
0950  * registered evhdlr.
0951  *
0952  * This function allows the host server to direct the server
0953  * convenience library to notify all registered local procs of
0954  * an event. The event can be local, or anywhere in the cluster.
0955  * The status indicates the event being reported.
0956  *
0957  * The client application can also call this function to notify the
0958  * resource manager and/or other processes of an event it encountered.
0959  * It can also be used to asynchronously notify other parts of its
0960  * own internal process - e.g., for one library to notify another
0961  * when initialized inside the process.
0962  *
0963  * status - status code indicating the event being reported
0964  *
0965  * source - the process that generated the event
0966  *
0967  * range - the range in which the event is to be reported. For example,
0968  *         a value of PMIX_RANGE_LOCAL would instruct the system
0969  *         to only notify procs on the same local node as the
0970  *         event generator.
0971  *
0972  * info - an array of pmix_info_t structures provided by the event
0973  *        generator to pass any additional information about the
0974  *        event. This can include an array of pmix_proc_t structs
0975  *        describing the processes impacted by the event, the nature
0976  *        of the event and its severity, etc. The precise contents
0977  *        of the array will depend on the event generator.
0978  *
0979  * ninfo - number of elements in the info array
0980  *
0981  * cbfunc - callback function to be called upon completion of the
0982  *          notify_event function's actions. Note that any messages
0983  *          will have been queued, but may not have been transmitted
0984  *          by this time. Note that the caller is required to maintain
0985  *          the input data until the callback function has been executed!
0986  *          If cbfunc is NULL, then this is treated as a BLOCKING call and
0987  *          the result of the operation is provided in the returned
0988  *          status
0989  *
0990  * cbdata - the caller's provided void* object
0991  */
0992 PMIX_EXPORT pmix_status_t PMIx_Notify_event(pmix_status_t status,
0993                                             const pmix_proc_t *source,
0994                                             pmix_data_range_t range,
0995                                             const pmix_info_t info[], size_t ninfo,
0996                                             pmix_op_cbfunc_t cbfunc, void *cbdata);
0997 
0998 
0999 /******    FABRIC-RELATED APIS    ******/
1000 /* Register for access to fabric-related information, including
1001  * communication cost matrix. This call must be made prior to
1002  * requesting information from a fabric.
1003  *
1004  * fabric - address of a pmix_fabric_t (backed by storage). User
1005  *          may populate the "name" field at will - PMIx does not
1006  *          utilize this field
1007  *
1008  * directives - an optional array of values indicating desired
1009  *              behaviors and/or fabric to be accessed. If NULL,
1010  *              then the highest priority available fabric will
1011  *              be used
1012  *
1013  * ndirs - number of elements in the directives array
1014  *
1015  * Return values include:
1016  *
1017  * PMIX_SUCCESS - indicates success
1018  */
1019 PMIX_EXPORT pmix_status_t PMIx_Fabric_register(pmix_fabric_t *fabric,
1020                                                const pmix_info_t directives[],
1021                                                size_t ndirs);
1022 
1023 PMIX_EXPORT pmix_status_t PMIx_Fabric_register_nb(pmix_fabric_t *fabric,
1024                                                   const pmix_info_t directives[],
1025                                                   size_t ndirs,
1026                                                   pmix_op_cbfunc_t cbfunc, void *cbdata);
1027 
1028 
1029 /* Update fabric-related information. This call can be made at any time to request an update of the
1030  * fabric information contained in the provided pmix_fabric_t object. The caller is not allowed
1031  * to access the provided pmix_fabric_t until the call has returned.
1032  *
1033  * fabric - pointer to the pmix_fabric_t struct provided to
1034  *          the registration function
1035  *
1036  * Return values include:
1037  *
1038  * PMIX_SUCCESS - indicates successful update
1039  */
1040 PMIX_EXPORT pmix_status_t PMIx_Fabric_update(pmix_fabric_t *fabric);
1041 
1042 PMIX_EXPORT pmix_status_t PMIx_Fabric_update_nb(pmix_fabric_t *fabric,
1043                                                 pmix_op_cbfunc_t cbfunc, void *cbdata);
1044 
1045 
1046 /* Deregister a fabric object, providing an opportunity for
1047  * the PMIx server library to cleanup any information
1048  * (e.g., cost matrix) associated with it
1049  *
1050  * fabric - pointer to the pmix_fabric_t struct provided
1051  *          to the registration function
1052  */
1053 PMIX_EXPORT pmix_status_t PMIx_Fabric_deregister(pmix_fabric_t *fabric);
1054 
1055 PMIX_EXPORT pmix_status_t PMIx_Fabric_deregister_nb(pmix_fabric_t *fabric,
1056                                                     pmix_op_cbfunc_t cbfunc, void *cbdata);
1057 
1058 
1059 /* Compute the distance information for the current process
1060  * Returns an array of distances from the current process
1061  * location to each of the local devices of the specified type(s)
1062  *
1063  * topo - the topology to use for the computation. If NULL,
1064  *        then the local topology stored in PMIx itself will
1065  *        be used
1066  *
1067  * cpuset - the cpus to which the process is bound
1068  *
1069  * info - an array of attributes directing the computation.
1070  *
1071  * ninfo - number of info in the array
1072  *
1073  * distances - pointer to location where the array of
1074  *             distances is to be returned
1075  *
1076  * ndist - number of elements in the distances array
1077  *
1078  * Return values include:
1079  *
1080  * PMIX_SUCCESS - distance array was successfully returned
1081  * Other error
1082  */
1083 PMIX_EXPORT pmix_status_t PMIx_Compute_distances(pmix_topology_t *topo,
1084                                                  pmix_cpuset_t *cpuset,
1085                                                  pmix_info_t info[], size_t ninfo,
1086                                                  pmix_device_distance_t *distances[],
1087                                                  size_t *ndist);
1088 
1089 PMIX_EXPORT pmix_status_t PMIx_Compute_distances_nb(pmix_topology_t *topo,
1090                                                     pmix_cpuset_t *cpuset,
1091                                                     pmix_info_t info[], size_t ninfo,
1092                                                     pmix_device_dist_cbfunc_t cbfunc,
1093                                                     void *cbdata);
1094 
1095 /* Load the local hwardware topology description
1096  *
1097  * topo - pointer to a pmix_topology_t object. This object
1098  *        must be initialized! If the a particular "source"
1099  *        for the topology is required (e.g., "hwloc"), then
1100  *        the "source" field of the object must be set to
1101  *        that value
1102  *
1103  * Return values include:
1104  * PMIX_SUCCESS - indicates return of a valid value
1105  * PMIX_ERR_NOT_FOUND - provided source is not available
1106  * PMIX_ERR_NOT_SUPPORTED - current implementation does not support this option
1107  */
1108 PMIX_EXPORT pmix_status_t PMIx_Load_topology(pmix_topology_t *topo);
1109 
1110 /* Get the PU binding bitmap from its string representation
1111  *
1112  * cpuset_string - string representation of the binding bitmap
1113  *                 (as returned by PMIx_Get using the PMIX_CPUSET key)
1114  *
1115  * cpuset - pointer to a pmix_cpuset_t object where the result
1116  *          is to be stored
1117  *
1118  * Return values include:
1119  * PMIX_SUCCESS - indicates return of a valid value
1120  * PMIX_ERR_NOT_FOUND - provided source is not available
1121  * PMIX_ERR_NOT_SUPPORTED - current implementation does not support this option
1122  */
1123 PMIX_EXPORT pmix_status_t PMIx_Parse_cpuset_string(const char *cpuset_string,
1124                                                    pmix_cpuset_t *cpuset);
1125 
1126 PMIX_EXPORT pmix_status_t PMIx_Get_cpuset(pmix_cpuset_t *cpuset, pmix_bind_envelope_t ref);
1127 
1128 /* Get the relative locality of two local processes given their locality strings.
1129  *
1130  * locality1 - String returned by the PMIx_server_generate_locality_string API
1131  *
1132  * locality2 - String returned by the PMIx_server_generate_locality_string API
1133  *
1134  * locality - Pointer to the location where the relative locality bitmask is
1135  *            to be constructed
1136  *
1137  * Return values include:
1138  * PMIX_SUCCESS - indicates return of a valid value
1139  * other error constant
1140  */
1141 PMIX_EXPORT pmix_status_t PMIx_Get_relative_locality(const char *locality1,
1142                                                      const char *locality2,
1143                                                      pmix_locality_t *locality);
1144 
1145 /* Step the PMIx progress engine - can be used when the PMIx progress
1146  * thread has been disabled
1147  */
1148 PMIX_EXPORT void PMIx_Progress(void);
1149 
1150 
1151 /* Stop the PMIx progress thread - attributes can be used to tailor
1152  * this operation. For example, PMIX_PROGRESS_THREAD_FLUSH directs
1153  * that the progress thread complete all pending events prior to
1154  * stopping
1155  */
1156 PMIX_EXPORT void PMIx_Progress_thread_stop(const pmix_info_t *info, size_t ninfo);
1157 
1158 
1159 /******    PRETTY-PRINT DEFINED VALUE TYPES     ******/
1160 /* Provide a string representation for several types of value. Note
1161  * that the provided string is statically defined and must NOT be
1162  * free'd. Supported value types:
1163  *
1164  * - pmix_status_t (PMIX_STATUS)
1165  * - pmix_scope_t   (PMIX_SCOPE)
1166  * - pmix_persistence_t  (PMIX_PERSIST)
1167  * - pmix_data_range_t   (PMIX_DATA_RANGE)
1168  * - pmix_info_directives_t   (PMIX_INFO_DIRECTIVES)
1169  * - pmix_data_type_t   (PMIX_DATA_TYPE)
1170  * - pmix_alloc_directive_t  (PMIX_ALLOC_DIRECTIVE)
1171  * - pmix_iof_channel_t  (PMIX_IOF_CHANNEL)
1172  * - pmix_job_state_t  (PMIX_JOB_STATE)
1173  * - pmix_proc_state_t  (PMIX_PROC_STATE)
1174  * - attribute string value of provided name
1175  * - attribute name corresponding to provided string
1176  * - pmix_link_state_t (PMIX_LINK_STATE)
1177  * - pmix_device_type_t (PMIX_DEVTYPE)
1178  * - pmix_value_cmp_t (enum)
1179  * - pmix_info_t (PMIX_INFO)
1180  * - pmix_value_t (PMIX_VALUE)
1181  * - pmix_info_directives_t (PMIX_INFO_DIRECTIVES)
1182  * - pmix_app_t (PMIX_APP)
1183  */
1184 PMIX_EXPORT const char* PMIx_Error_string(pmix_status_t status);
1185 PMIX_EXPORT pmix_status_t PMIx_Error_code(const char *errname);
1186 PMIX_EXPORT const char* PMIx_Proc_state_string(pmix_proc_state_t state);
1187 PMIX_EXPORT const char* PMIx_Scope_string(pmix_scope_t scope);
1188 PMIX_EXPORT const char* PMIx_Persistence_string(pmix_persistence_t persist);
1189 PMIX_EXPORT const char* PMIx_Data_range_string(pmix_data_range_t range);
1190 PMIX_EXPORT const char* PMIx_Data_type_string(pmix_data_type_t type);
1191 PMIX_EXPORT const char* PMIx_Alloc_directive_string(pmix_alloc_directive_t directive);
1192 PMIX_EXPORT const char* PMIx_Resource_block_directive_string(pmix_resource_block_directive_t directive);
1193 PMIX_EXPORT const char* PMIx_IOF_channel_string(pmix_iof_channel_t channel);
1194 PMIX_EXPORT const char* PMIx_Job_state_string(pmix_job_state_t state);
1195 PMIX_EXPORT const char* PMIx_Get_attribute_string(const char *attribute);
1196 PMIX_EXPORT const char* PMIx_Get_attribute_name(const char *attrstring);
1197 PMIX_EXPORT const char* PMIx_Link_state_string(pmix_link_state_t state);
1198 PMIX_EXPORT const char* PMIx_Device_type_string(pmix_device_type_t type);
1199 PMIX_EXPORT const char* PMIx_Value_comparison_string(pmix_value_cmp_t cmp);
1200 PMIX_EXPORT const char* PMIx_Group_operation_string(pmix_group_operation_t op);
1201 
1202 /* the following print statements return ALLOCATED strings
1203  * that the user must release when done */
1204 PMIX_EXPORT char* PMIx_Info_string(const pmix_info_t *info);
1205 PMIX_EXPORT char* PMIx_Value_string(const pmix_value_t *value);
1206 PMIX_EXPORT char* PMIx_Info_directives_string(pmix_info_directives_t directives);
1207 PMIX_EXPORT char* PMIx_App_string(const pmix_app_t *app);
1208 PMIX_EXPORT char* PMIx_Proc_string(const pmix_proc_t *proc);
1209 PMIX_EXPORT char* PMIx_Resource_unit_string(const pmix_resource_unit_t *unit);
1210 
1211 /* Get the PMIx version string. Note that the provided string is
1212  * statically defined and must NOT be free'd  */
1213 PMIX_EXPORT const char* PMIx_Get_version(void);
1214 
1215 /* Store some data locally for retrieval by other areas of the
1216  * proc. This is data that has only internal scope - it will
1217  * never be "pushed" externally */
1218 PMIX_EXPORT pmix_status_t PMIx_Store_internal(const pmix_proc_t *proc,
1219                                               const char key[], pmix_value_t *val);
1220 
1221 
1222 /* Compute and return the size (in bytes) of the data
1223  * payload in a pmix_value_t structure. Returns:
1224  *
1225  * - PMIX_SUCCESS if the value could be computed
1226  *
1227  * - an appropriate error value (e.g., PMIX_ERR_UNKNOWN_DATA_TYPE
1228  *   if the data type is unknown) if the value could not be computed.
1229  */
1230 PMIX_EXPORT pmix_status_t PMIx_Value_get_size(const pmix_value_t *val,
1231                                               size_t *size);
1232 
1233 /* Compute and return the size (in bytes) of the data
1234  * payload in a pmix_info_t structure. Returns:
1235  *
1236  * - PMIX_SUCCESS if the value could be computed
1237  *
1238  * - an appropriate error value (e.g., PMIX_ERR_UNKNOWN_DATA_TYPE
1239  *   if the data type is unknown) if the value could not be computed.
1240  */
1241 PMIX_EXPORT pmix_status_t PMIx_Info_get_size(const pmix_info_t *val,
1242                                              size_t *size);
1243 
1244 
1245 /******    DATA BUFFER PACK/UNPACK SUPPORT    ******/
1246 /**
1247  * Top-level interface function to pack one or more values into a
1248  * buffer.
1249  *
1250  * The pack function packs one or more values of a specified type into
1251  * the specified buffer.  The buffer must have already been
1252  * initialized via the PMIX_DATA_BUFFER_CREATE or PMIX_DATA_BUFFER_CONSTRUCT
1253  * call - otherwise, the pack_value function will return an error.
1254  * Providing an unsupported type flag will likewise be reported as an error.
1255  *
1256  * Note that any data to be packed that is not hard type cast (i.e.,
1257  * not type cast to a specific size) may lose precision when unpacked
1258  * by a non-homogeneous recipient.  The PACK function will do its best to deal
1259  * with heterogeneity issues between the packer and unpacker in such
1260  * cases. Sending a number larger than can be handled by the recipient
1261  * will return an error code (generated upon unpacking) -
1262  * the error cannot be detected during packing.
1263  *
1264  * The identity of the intended recipient of the packed buffer (i.e., the
1265  * process that will be unpacking it) is used solely to resolve any data type
1266  * differences between PMIx versions. The recipient must, therefore, be
1267  * known to the user prior to calling the pack function so that the
1268  * PMIx library is aware of the version the recipient is using.
1269  *
1270  * @param *target Pointer to a pmix_proc_t structure containing the
1271  * nspace/rank of the process that will be unpacking the final buffer.
1272  * A NULL value may be used to indicate that the target is based on
1273  * the same PMIx version as the caller.
1274  *
1275  * @param *buffer A pointer to the buffer into which the value is to
1276  * be packed.
1277  *
1278  * @param *src A void* pointer to the data that is to be packed. Note
1279  * that strings are to be passed as (char **) - i.e., the caller must
1280  * pass the address of the pointer to the string as the void*. This
1281  * allows PMIx to use a single pack function, but still allow
1282  * the caller to pass multiple strings in a single call.
1283  *
1284  * @param num_values An int32_t indicating the number of values that are
1285  * to be packed, beginning at the location pointed to by src. A string
1286  * value is counted as a single value regardless of length. The values
1287  * must be contiguous in memory. Arrays of pointers (e.g., string
1288  * arrays) should be contiguous, although (obviously) the data pointed
1289  * to need not be contiguous across array entries.
1290  *
1291  * @param type The type of the data to be packed - must be one of the
1292  * PMIX defined data types.
1293  *
1294  * @retval PMIX_SUCCESS The data was packed as requested.
1295  *
1296  * @retval PMIX_ERROR(s) An appropriate PMIX error code indicating the
1297  * problem encountered. This error code should be handled
1298  * appropriately.
1299  *
1300  * @code
1301  * pmix_data_buffer_t *buffer;
1302  * int32_t src;
1303  *
1304  * PMIX_DATA_BUFFER_CREATE(buffer);
1305  * status_code = PMIx_Data_pack(buffer, &src, 1, PMIX_INT32);
1306  * @endcode
1307  */
1308 PMIX_EXPORT pmix_status_t PMIx_Data_pack(const pmix_proc_t *target,
1309                                          pmix_data_buffer_t *buffer,
1310                                          void *src, int32_t num_vals,
1311                                          pmix_data_type_t type);
1312 
1313 /**
1314  * Unpack values from a buffer.
1315  *
1316  * The unpack function unpacks the next value (or values) of a
1317  * specified type from the specified buffer.
1318  *
1319  * The buffer must have already been initialized via an PMIX_DATA_BUFFER_CREATE or
1320  * PMIX_DATA_BUFFER_CONSTRUCT call (and assumedly filled with some data) -
1321  * otherwise, the unpack_value function will return an
1322  * error. Providing an unsupported type flag will likewise be reported
1323  * as an error, as will specifying a data type that DOES NOT match the
1324  * type of the next item in the buffer. An attempt to read beyond the
1325  * end of the stored data held in the buffer will also return an
1326  * error.
1327  *
1328  * NOTE: it is possible for the buffer to be corrupted and that
1329  * PMIx will *think* there is a proper variable type at the
1330  * beginning of an unpack region - but that the value is bogus (e.g., just
1331  * a byte field in a string array that so happens to have a value that
1332  * matches the specified data type flag). Therefore, the data type error check
1333  * is NOT completely safe. This is true for ALL unpack functions.
1334  *
1335  *
1336  * Unpacking values is a "nondestructive" process - i.e., the values are
1337  * not removed from the buffer. It is therefore possible for the caller
1338  * to re-unpack a value from the same buffer by resetting the unpack_ptr.
1339  *
1340  * Warning: The caller is responsible for providing adequate memory
1341  * storage for the requested data. As noted below, the user
1342  * must provide a parameter indicating the maximum number of values that
1343  * can be unpacked into the allocated memory. If more values exist in the
1344  * buffer than can fit into the memory storage, then the function will unpack
1345  * what it can fit into that location and return an error code indicating
1346  * that the buffer was only partially unpacked.
1347  *
1348  * Note that any data that was not hard type cast (i.e., not type cast
1349  * to a specific size) when packed may lose precision when unpacked by
1350  * a non-homogeneous recipient.  PMIx will do its best to deal with
1351  * heterogeneity issues between the packer and unpacker in such
1352  * cases. Sending a number larger than can be handled by the recipient
1353  * will return an error code generated upon unpacking - these errors
1354  * cannot be detected during packing.
1355  *
1356  * The identity of the source of the packed buffer (i.e., the
1357  * process that packed it) is used solely to resolve any data type
1358  * differences between PMIx versions. The source must, therefore, be
1359  * known to the user prior to calling the unpack function so that the
1360  * PMIx library is aware of the version the source used.
1361  *
1362  * @param *source Pointer to a pmix_proc_t structure containing the
1363  * nspace/rank of the process that packed the provided buffer.
1364  * A NULL value may be used to indicate that the source is based on
1365  * the same PMIx version as the caller.
1366  *
1367  * @param *buffer A pointer to the buffer from which the value will be
1368  * extracted.
1369  *
1370  * @param *dest A void* pointer to the memory location into which the
1371  * data is to be stored. Note that these values will be stored
1372  * contiguously in memory. For strings, this pointer must be to (char
1373  * **) to provide a means of supporting multiple string
1374  * operations. The unpack function will allocate memory for each
1375  * string in the array - the caller must only provide adequate memory
1376  * for the array of pointers.
1377  *
1378  * @param type The type of the data to be unpacked - must be one of
1379  * the BFROP defined data types.
1380  *
1381  * @retval *max_num_values The number of values actually unpacked. In
1382  * most cases, this should match the maximum number provided in the
1383  * parameters - but in no case will it exceed the value of this
1384  * parameter.  Note that if you unpack fewer values than are actually
1385  * available, the buffer will be in an unpackable state - the function will
1386  * return an error code to warn of this condition.
1387  *
1388  * @note The unpack function will return the actual number of values
1389  * unpacked in this location.
1390  *
1391  * @retval PMIX_SUCCESS The next item in the buffer was successfully
1392  * unpacked.
1393  *
1394  * @retval PMIX_ERROR(s) The unpack function returns an error code
1395  * under one of several conditions: (a) the number of values in the
1396  * item exceeds the max num provided by the caller; (b) the type of
1397  * the next item in the buffer does not match the type specified by
1398  * the caller; or (c) the unpack failed due to either an error in the
1399  * buffer or an attempt to read past the end of the buffer.
1400  *
1401  * @code
1402  * pmix_data_buffer_t *buffer;
1403  * int32_t dest;
1404  * char **string_array;
1405  * int32_t num_values;
1406  *
1407  * num_values = 1;
1408  * status_code = PMIx_Data_unpack(buffer, (void*)&dest, &num_values, PMIX_INT32);
1409  *
1410  * num_values = 5;
1411  * string_array = pmix_malloc(num_values*sizeof(char *));
1412  * status_code = PMIx_Data_unpack(buffer, (void*)(string_array), &num_values, PMIX_STRING);
1413  *
1414  * @endcode
1415  */
1416 PMIX_EXPORT pmix_status_t PMIx_Data_unpack(const pmix_proc_t *source,
1417                                            pmix_data_buffer_t *buffer, void *dest,
1418                                            int32_t *max_num_values,
1419                                            pmix_data_type_t type);
1420 
1421 /**
1422  * Copy a data value from one location to another.
1423  *
1424  * Since registered data types can be complex structures, the system
1425  * needs some way to know how to copy the data from one location to
1426  * another (e.g., for storage in the registry). This function, which
1427  * can call other copy functions to build up complex data types, defines
1428  * the method for making a copy of the specified data type.
1429  *
1430  * @param **dest The address of a pointer into which the
1431  * address of the resulting data is to be stored.
1432  *
1433  * @param *src A pointer to the memory location from which the
1434  * data is to be copied.
1435  *
1436  * @param type The type of the data to be copied - must be one of
1437  * the PMIx defined data types.
1438  *
1439  * @retval PMIX_SUCCESS The value was successfully copied.
1440  *
1441  * @retval PMIX_ERROR(s) An appropriate error code.
1442  *
1443  */
1444 PMIX_EXPORT pmix_status_t PMIx_Data_copy(void **dest, void *src,
1445                                          pmix_data_type_t type);
1446 
1447 /**
1448  * Print a data value.
1449  *
1450  * Since registered data types can be complex structures, the system
1451  * needs some way to know how to print them (i.e., convert them to a string
1452  * representation). Provided for debug purposes.
1453  *
1454  * @retval PMIX_SUCCESS The value was successfully printed.
1455  *
1456  * @retval PMIX_ERROR(s) An appropriate error code.
1457  */
1458 PMIX_EXPORT pmix_status_t PMIx_Data_print(char **output, char *prefix,
1459                                           void *src, pmix_data_type_t type);
1460 
1461 /**
1462  * Copy a payload from one buffer to another
1463  *
1464  * This function will append a copy of the payload in one buffer into
1465  * another buffer.
1466  * NOTE: This is NOT a destructive procedure - the
1467  * source buffer's payload will remain intact, as will any pre-existing
1468  * payload in the destination's buffer.
1469  */
1470 PMIX_EXPORT pmix_status_t PMIx_Data_copy_payload(pmix_data_buffer_t *dest,
1471                                                  pmix_data_buffer_t *src);
1472 
1473 /**
1474  * Unload a buffer into a byte object
1475  *
1476  * The unload function provides the caller with a pointer to the data
1477  * payload within the buffer and the size of that payload. This allows
1478  * the user to directly access the payload.
1479  *
1480  * @note This is a destructive operation. While the payload is
1481  * undisturbed, the function will clear the buffer's pointers to the
1482  * payload. Thus, the buffer and the payload are completely separated,
1483  * leaving the caller free to release the buffer.
1484  *
1485  * @param buffer A pointer to the buffer whose payload is to be
1486  * unloaded.
1487  *
1488  * @param payload The address of a pmix_byte_object_t into which
1489  * the buffer is to be unloaded
1490  *
1491  * @retval PMIX_SUCCESS The request was successfully completed.
1492  *
1493  * @retval PMIX_ERROR(s) An appropriate error code indicating the
1494  * problem will be returned. This should be handled appropriately by
1495  * the caller.
1496  *
1497  * @code
1498  * pmix_data_buffer_t *buffer;
1499  * pmix_byte_object_t payload;
1500  *
1501  * status_code = PMIx_Data_unload(buffer, &payload);
1502  * @endcode
1503  */
1504 PMIX_EXPORT pmix_status_t PMIx_Data_unload(pmix_data_buffer_t *buffer,
1505                                            pmix_byte_object_t *payload);
1506 
1507 /**
1508  * Load a data payload into a buffer.
1509  *
1510  * The load function allows the caller to replace the payload in a
1511  * buffer with one provided by the caller. If a payload already exists
1512  * in the buffer, the function will "free" the existing data to
1513  * release it, and then replace the data payload with the one provided
1514  * by the caller.
1515  *
1516  * @note The buffer must be allocated in advance - failing to do so
1517  * will cause the load function to return an error code.
1518  *
1519  * @note The caller is responsible for pre-packing the provided
1520  * payload - the load function cannot convert to network byte order
1521  * any data contained in the provided payload.
1522  *
1523  * @note The "payload" object will be empty upon completion of
1524  * this operation.
1525  *
1526  * @param buffer A pointer to the buffer into which the payload is to
1527  * be loaded.
1528  *
1529  * @param payload A pointer to the pmix_byte_object_t .containing the
1530  * desired payload
1531  *
1532  * @retval PMIX_SUCCESS The request was successfully completed
1533  *
1534  * @retval PMIX_ERROR(s) An appropriate error code indicating the
1535  * problem will be returned. This should be handled appropriately by
1536  * the caller.
1537  *
1538  * @code
1539  * pmix_data_buffer_t *buffer;
1540  * pmix_byte_object_t payload;
1541  *
1542  * PMIX_DATA_BUFFER_CREATE(buffer);
1543  * status_code = PMIx_Data_load(buffer, &payload);
1544  * @endcode
1545  */
1546 PMIX_EXPORT pmix_status_t PMIx_Data_load(pmix_data_buffer_t *buffer,
1547                                          pmix_byte_object_t *payload);
1548 
1549 /**
1550 * Embed a data payload into a buffer.
1551 *
1552 * The embed function is identical in operation to PMIx_Data_load
1553 * except that it does NOT "clear" the payload upon completion.
1554 *
1555 * @note The buffer must be allocated in advance - failing to do so
1556 * will cause the function to return an error code.
1557 *
1558 * @note The caller is responsible for pre-packing the provided
1559 * payload - the load function cannot convert to network byte order
1560 * any data contained in the provided payload.
1561 *
1562 * @note The "payload" object is unaltered by this operation.
1563 *
1564 * @param buffer A pointer to the buffer into which the payload is to
1565 * be loaded.
1566 *
1567 * @param payload A pointer to the pmix_byte_object_t containing the
1568 * desired payload
1569 *
1570 * @retval PMIX_SUCCESS The request was successfully completed
1571 *
1572 * @retval PMIX_ERROR(s) An appropriate error code indicating the
1573 * problem will be returned. This should be handled appropriately by
1574 * the caller.
1575 *
1576 * @code
1577 * pmix_data_buffer_t *buffer;
1578 * pmix_byte_object_t payload;
1579 *
1580 * PMIX_DATA_BUFFER_CREATE(buffer);
1581 * status_code = PMIx_Data_embed(buffer, &payload);
1582 * @endcode
1583 */
1584 PMIX_EXPORT pmix_status_t PMIx_Data_embed(pmix_data_buffer_t *buffer,
1585                                           const pmix_byte_object_t *payload);
1586 
1587 /**
1588 * Compress data using loss-less compression algorithm.
1589 *
1590 * Compress the provided data block. Destination memory
1591 * will be allocated if successful operation is concluded. Caller
1592 * is responsible for release of the allocated region. The input
1593 * data block will remain unaltered.
1594 *
1595 * Note: the compress function will return "false" if the operation
1596 * would not result in a smaller data block.
1597 *
1598 * @param inbytes A pointer to the data to be compressed
1599 *
1600 * @param size Number of bytes in the input data region
1601 *
1602 * @param outbytes Address where a pointer to the compressed
1603 * data region is to be returned
1604 *
1605 * @param nbytes Address where the number of bytes in the
1606 * compressed data region is to be returned
1607 *
1608 * @retval true The input data was compressed.
1609 *
1610 * @retval false The input data was not compressed
1611 *
1612 */
1613 PMIX_EXPORT bool PMIx_Data_compress(const uint8_t *inbytes,
1614                                     size_t size,
1615                                     uint8_t **outbytes,
1616                                     size_t *nbytes);
1617 
1618 /**
1619 * Decompress data.
1620 *
1621 * Decompress the provided data block. Destination memory
1622 * will be allocated if successful operation is concluded. Caller
1623 * is responsible for release of the allocated region. The input
1624 * data block will remain unaltered.
1625 *
1626 * note: only data compressed using PMIx_Data_compress can
1627 * be input to this function
1628 *
1629 * @param inbytes A pointer to the data to be decompressed
1630 *
1631 * @param size Number of bytes in the input data region
1632 *
1633 * @param outbytes Address where a pointer to the decompressed
1634 * data region is to be returned
1635 *
1636 * @param nbytes Address where the number of bytes in the
1637 * decompressed data region is to be returned
1638 *
1639 * @retval true The input data was decompressed
1640 *
1641 * @retval false The input data was not decompressed
1642 *
1643 */
1644 PMIX_EXPORT bool PMIx_Data_decompress(const uint8_t *inbytes,
1645                                       size_t size,
1646                                       uint8_t **outbytes,
1647                                       size_t *nbytes);
1648 
1649 /************     UTILITY  FUNCTIONS      *************************************/
1650 
1651 /* We had to put some function definitions into pmix_deprecated.h for
1652  * now-deprecated macros that utilize them as there are people who only
1653  * included pmix_common.h if they were using macros but not APIs.
1654  * However, we really want those APIs here so people will
1655  * see them and know they exist. So include them here as well. */
1656 
1657 #ifndef PMIx_DEPRECATED_H
1658 
1659 
1660 /* load a key */
1661 PMIX_EXPORT void PMIx_Load_key(pmix_key_t key, const char *src);
1662 
1663 /* check a key */
1664 PMIX_EXPORT bool PMIx_Check_key(const char *key, const char *str);
1665 
1666 /* check to see if a key is a "reserved" key */
1667 PMIX_EXPORT bool PMIx_Check_reserved_key(const char *key);
1668 
1669 /* load a string into a pmix_nspace_t struct */
1670 PMIX_EXPORT void PMIx_Load_nspace(pmix_nspace_t nspace, const char *str);
1671 
1672 /* check two nspace structs for equality */
1673 PMIX_EXPORT bool PMIx_Check_nspace(const char *key1, const char *key2);
1674 
1675 /* check if a namespace is invalid */
1676 PMIX_EXPORT bool PMIx_Nspace_invalid(const char *nspace);
1677 
1678 /* load a process ID struct */
1679 PMIX_EXPORT void PMIx_Load_procid(pmix_proc_t *p,
1680                                   const char *ns,
1681                                   pmix_rank_t rk);
1682 
1683 /* transfer a process ID struct (non-destructive) */
1684 PMIX_EXPORT void PMIx_Xfer_procid(pmix_proc_t *dst,
1685                                   const pmix_proc_t *src);
1686 
1687 /* check two procIDs for equality */
1688 PMIX_EXPORT bool PMIx_Check_procid(const pmix_proc_t *a,
1689                                    const pmix_proc_t *b);
1690 
1691 /* check two ranks for equality */
1692 PMIX_EXPORT bool PMIx_Check_rank(pmix_rank_t a,
1693                                  pmix_rank_t b);
1694 
1695 PMIX_EXPORT bool PMIx_Rank_valid(pmix_rank_t a);
1696 
1697 /* check if procID is invalid */
1698 PMIX_EXPORT bool PMIx_Procid_invalid(const pmix_proc_t *p);
1699 
1700 /* count number of entries in an argv-style array */
1701 PMIX_EXPORT int PMIx_Argv_count(char **a);
1702 
1703 /* append a string to an argv-style array, without returning the count */
1704 PMIX_EXPORT pmix_status_t PMIx_Argv_append_nosize(char ***argv, const char *arg);
1705 
1706 /* prepend a string to an argv-style array, without returning the count */
1707 PMIX_EXPORT pmix_status_t PMIx_Argv_prepend_nosize(char ***argv, const char *arg);
1708 
1709 /* append a string to an argv-style array, avoiding duplication,
1710  * and without returning the count */
1711 PMIX_EXPORT pmix_status_t PMIx_Argv_append_unique_nosize(char ***argv, const char *arg);
1712 
1713 /* free an argv-style array */
1714 PMIX_EXPORT void PMIx_Argv_free(char **argv);
1715 
1716 
1717 /* split a string on given delimiter, returning the individual
1718  * strings in an argv-style array while ignoring any resulting
1719  * zero-length strings */
1720 PMIX_EXPORT char **PMIx_Argv_split(const char *src_string, int delimiter);
1721 
1722 /* split a string on the given delimiter, returning the individual
1723  * strings in an argv-style array and retaining any zero-length
1724  * strings in the array */
1725 PMIX_EXPORT char **PMIx_Argv_split_with_empty(const char *src_string, int delimiter);
1726 
1727 /* backing function for the above functions */
1728 PMIX_EXPORT char **PMIx_Argv_split_inter(const char *src_string,
1729                                          int delimiter,
1730                                          bool include_empty);
1731 
1732 /* join elements of the provided argv-style array into a single
1733  * string, joined by the given delimiter */
1734 PMIX_EXPORT char *PMIx_Argv_join(char **argv, int delimiter);
1735 
1736 /* copy an argv-style array */
1737 PMIX_EXPORT char **PMIx_Argv_copy(char **argv);
1738 
1739 /* set an environmental paramter */
1740 PMIX_EXPORT pmix_status_t PMIx_Setenv(const char *name,
1741                                       const char *value,
1742                                       bool overwrite,
1743                                       char ***env);
1744 
1745 /* initialize a value struct */
1746 PMIX_EXPORT void PMIx_Value_construct(pmix_value_t *val);
1747 
1748 /* free memory stored inside a value struct */
1749 PMIX_EXPORT void PMIx_Value_destruct(pmix_value_t *val);
1750 
1751 /* create and initialize an array of value structs */
1752 PMIX_EXPORT pmix_value_t* PMIx_Value_create(size_t n);
1753 
1754 /* free memory stored inside an array of coord structs
1755  * (frees the struct memory itself */
1756 PMIX_EXPORT void PMIx_Value_free(pmix_value_t *v, size_t n);
1757 
1758 /* Check the given value struct to determine if it includes
1759  * a boolean value (includes strings for "true" and "false",
1760  * including abbreviations such as "t" or "f"), and if so,
1761  * then its value. A value type of PMIX_UNDEF is taken to imply
1762  * a boolean "true". */
1763 PMIX_EXPORT pmix_boolean_t PMIx_Value_true(const pmix_value_t *v);
1764 
1765 /* Load data into a pmix_value_t structure. The data can be of any
1766  * PMIx data type - which means the load can be somewhat complex
1767  * to implement (e.g., in the case of a pmix_data_array_t). The
1768  * data is COPIED into the value struct
1769  */
1770 PMIX_EXPORT pmix_status_t PMIx_Value_load(pmix_value_t *val,
1771                                           const void *data,
1772                                           pmix_data_type_t type);
1773 
1774 /* Unload data from a pmix_value_t structure. */
1775 PMIX_EXPORT pmix_status_t PMIx_Value_unload(pmix_value_t *val,
1776                                             void **data,
1777                                             size_t *sz);
1778 
1779 /* Transfer data from one pmix_value_t to another - this is actually
1780  * executed as a COPY operation, so the original data is not altered.
1781  */
1782 PMIX_EXPORT pmix_status_t PMIx_Value_xfer(pmix_value_t *dest,
1783                                           const pmix_value_t *src);
1784 
1785 /* Compare the contents of two pmix_value_t structures */
1786 PMIX_EXPORT pmix_value_cmp_t PMIx_Value_compare(pmix_value_t *v1,
1787                                                 pmix_value_t *v2);
1788 
1789 /* extract a numerical value from a pmix_value_t */
1790 PMIX_EXPORT pmix_status_t PMIx_Value_get_number(const pmix_value_t *value,
1791                                                 void *dest,
1792                                                 pmix_data_type_t type);
1793 
1794 /* retrieve a number stored in a pmix_value_t, checking to ensure
1795  * that the value will fit within the given destination (as specified
1796  * by the type parameter) without loss of precision and/or change of sign */
1797 PMIX_EXPORT pmix_status_t PMIx_Value_get_number(const pmix_value_t *value,
1798                                                 void *dest,
1799                                                 pmix_data_type_t type);
1800 
1801 /* initialize a pmix_data_array_t - i.e.., set all fields to zero */
1802 PMIX_EXPORT void PMIx_Data_array_init(pmix_data_array_t *p,
1803                                       pmix_data_type_t type);
1804 
1805 /* construct a data array containing the specified number of
1806  * elements of the given type */
1807 PMIX_EXPORT void PMIx_Data_array_construct(pmix_data_array_t *p,
1808                                            size_t num, pmix_data_type_t type);
1809 
1810 /* destruct a data array */
1811 PMIX_EXPORT void PMIx_Data_array_destruct(pmix_data_array_t *d);
1812 
1813 /* create an array of data arrays, each containing the specified number
1814  * of elements of the given type */
1815 PMIX_EXPORT pmix_data_array_t* PMIx_Data_array_create(size_t n, pmix_data_type_t type);
1816 
1817 /* free a data array, releasing the pmix_data_array_t object */
1818 PMIX_EXPORT void PMIx_Data_array_free(pmix_data_array_t *p);
1819 
1820 
1821 /* initialize an info struct */
1822 PMIX_EXPORT void PMIx_Info_construct(pmix_info_t *p);
1823 
1824 /* free memory stored inside an info struct */
1825 PMIX_EXPORT void PMIx_Info_destruct(pmix_info_t *p);
1826 
1827 /* create and initialize an array of info structs */
1828 PMIX_EXPORT pmix_info_t* PMIx_Info_create(size_t n);
1829 
1830 /* free memory stored inside an array of coord structs
1831  * (frees the struct memory itself */
1832 PMIX_EXPORT void PMIx_Info_free(pmix_info_t *p, size_t n);
1833 
1834 /* Check the given info struct to determine if it includes
1835  * a boolean value (includes strings for "true" and "false",
1836  * including abbreviations such as "t" or "f"), and if so,
1837  * then its value. A value type of PMIX_UNDEF is taken to imply
1838  * a boolean "true" as the presence of the key defaults to
1839  * indicating "true". */
1840 PMIX_EXPORT pmix_boolean_t PMIx_Info_true(const pmix_info_t *p);
1841 
1842 /* Load key/value data into a pmix_info_t struct. Note that this
1843  * effectively is a PMIX_LOAD_KEY operation to copy the key,
1844  * followed by a PMIx_Value_load to COPY the data into the
1845  * pmix_value_t in the provided info struct */
1846 PMIX_EXPORT pmix_status_t PMIx_Info_load(pmix_info_t *info,
1847                                          const char *key,
1848                                          const void *data,
1849                                          pmix_data_type_t type);
1850 
1851 /* Transfer data from one pmix_info_t to another - this is actually
1852  * executed as a COPY operation, so the original data is not altered */
1853 PMIX_EXPORT pmix_status_t PMIx_Info_xfer(pmix_info_t *dest,
1854                                          const pmix_info_t *src);
1855 
1856 /* mark the info struct as required */
1857 PMIX_EXPORT void PMIx_Info_required(pmix_info_t *p);
1858 
1859 /* mark the info struct as optional */
1860 PMIX_EXPORT void PMIx_Info_optional(pmix_info_t *p);
1861 
1862 /* check if the info struct is required */
1863 PMIX_EXPORT bool PMIx_Info_is_required(const pmix_info_t *p);
1864 
1865 /* check if the info struct is optional */
1866 PMIX_EXPORT bool PMIx_Info_is_optional(const pmix_info_t *p);
1867 
1868 /* mark the info struct as processed */
1869 PMIX_EXPORT void PMIx_Info_processed(pmix_info_t *p);
1870 
1871 /* check if the info struct has been processed */
1872 PMIX_EXPORT bool PMIx_Info_was_processed(const pmix_info_t *p);
1873 
1874 /* mark the info struct as the end of an array */
1875 PMIX_EXPORT void PMIx_Info_set_end(pmix_info_t *p);
1876 
1877 /* check if the info struct is the end of an array */
1878 PMIX_EXPORT bool PMIx_Info_is_end(const pmix_info_t *p);
1879 
1880 /* mark the info as a qualifier */
1881 PMIX_EXPORT void PMIx_Info_qualifier(pmix_info_t *p);
1882 
1883 /* check if the info struct is a qualifier */
1884 PMIX_EXPORT bool PMIx_Info_is_qualifier(const pmix_info_t *p);
1885 
1886 /* mark the info struct as persistent - do NOT release its contents */
1887 PMIX_EXPORT void PMIx_Info_persistent(pmix_info_t *p);
1888 
1889 /* check if the info struct is persistent */
1890 PMIX_EXPORT bool PMIx_Info_is_persistent(const pmix_info_t *p);
1891 
1892 /* Constructing arrays of pmix_info_t for passing to an API can
1893  * be tedious since the pmix_info_t itself is not a "list object".
1894  * Since this is a very frequent operation, a set of APIs has been
1895  * provided that opaquely manipulates internal PMIx list structures
1896  * for this purpose. The user only need provide a void* pointer to
1897  * act as the caddy for the internal list object.
1898  */
1899 
1900 /* Initialize a list of pmix_info_t structures */
1901 PMIX_EXPORT void* PMIx_Info_list_start(void);
1902 
1903 /* Add data to a list of pmix_info_t structs. The "ptr" passed
1904  * here is the pointer returned by PMIx_Info_list_start.
1905  */
1906 PMIX_EXPORT pmix_status_t PMIx_Info_list_add(void *ptr,
1907                                              const char *key,
1908                                              const void *value,
1909                                              pmix_data_type_t type);
1910 
1911 PMIX_EXPORT pmix_status_t PMIx_Info_list_add_unique(void *ptr,
1912                                                     const char *key,
1913                                                     const void *value,
1914                                                     pmix_data_type_t type,
1915                                                     bool overwrite);
1916 
1917 PMIX_EXPORT pmix_status_t PMIx_Info_list_add_value(void *ptr,
1918                                                    const char *key,
1919                                                    const pmix_value_t *value);
1920 
1921 PMIX_EXPORT pmix_status_t PMIx_Info_list_add_value_unique(void *ptr,
1922                                                           const char *key,
1923                                                           const pmix_value_t *value,
1924                                                           bool overwrite);
1925 
1926 PMIX_EXPORT pmix_status_t PMIx_Info_list_prepend(void *ptr,
1927                                                  const char *key,
1928                                                  const void *value,
1929                                                  pmix_data_type_t type);
1930 
1931 PMIX_EXPORT pmix_status_t PMIx_Info_list_insert(void *ptr, pmix_info_t *info);
1932 
1933 /* Transfer the data in an existing pmix_info_t struct to a list. This
1934  * is executed as a COPY operation, so the original data is not altered.
1935  * The "ptr" passed here is the pointer returned by PMIx_Info_list_start
1936  */
1937 PMIX_EXPORT pmix_status_t PMIx_Info_list_xfer(void *ptr,
1938                                               const pmix_info_t *info);
1939 
1940 PMIX_EXPORT pmix_status_t PMIx_Info_list_xfer_unique(void *ptr,
1941                                                      const pmix_info_t *info,
1942                                                      bool overwrite);
1943 
1944 /* Convert the constructed list of pmix_info_t structs to a pmix_data_array_t
1945  * of pmix_info_t. Data on the list is COPIED to the array elements.
1946  */
1947 PMIX_EXPORT pmix_status_t PMIx_Info_list_convert(void *ptr, pmix_data_array_t *par);
1948 
1949 /* Release all data on the list and destruct all internal tracking */
1950 PMIX_EXPORT void PMIx_Info_list_release(void *ptr);
1951 
1952 /* retrieve the next info on the list - passing a NULL
1953  * to the "prev" parameter will return the first pmix_info_t
1954  * on the list. A return of NULL indicates the end of the list
1955  */
1956 PMIX_EXPORT pmix_info_t* PMIx_Info_list_get_info(void *ptr, void *prev, void **next);
1957 
1958 /* get the size of the info list - i.e., the number of current entries on it */
1959 PMIX_EXPORT size_t PMIx_Info_list_get_size(void *ptr);
1960 
1961 
1962 /* initialize a coord struct */
1963 PMIX_EXPORT void PMIx_Coord_construct(pmix_coord_t *m);
1964 
1965 /* free memory stored inside a coord struct */
1966 PMIX_EXPORT void PMIx_Coord_destruct(pmix_coord_t *m);
1967 
1968 /* create and initialize an array of coord structs */
1969 PMIX_EXPORT pmix_coord_t* PMIx_Coord_create(size_t dims,
1970                                             size_t number);
1971 
1972 /* free memory stored inside an array of coord structs
1973 * (frees the struct memory itself */
1974 PMIX_EXPORT void PMIx_Coord_free(pmix_coord_t *m, size_t number);
1975 
1976 
1977 /* initialize a topology struct */
1978 PMIX_EXPORT void PMIx_Topology_construct(pmix_topology_t *t);
1979 
1980 /* free memory stored inside a topology struct */
1981 PMIX_EXPORT void PMIx_Topology_destruct(pmix_topology_t *topo);
1982 
1983 /* create and initialize an array of topology structs */
1984 PMIX_EXPORT pmix_topology_t* PMIx_Topology_create(size_t n);
1985 
1986 /* free memory stored inside an array of topology structs
1987  * (frees the struct memory itself */
1988 PMIX_EXPORT void PMIx_Topology_free(pmix_topology_t *t, size_t n);
1989 
1990 /* initialize a cpuset struct */
1991 PMIX_EXPORT void PMIx_Cpuset_construct(pmix_cpuset_t *cpuset);
1992 
1993 /* free memory stored inside a cpuset struct */
1994 PMIX_EXPORT void PMIx_Cpuset_destruct(pmix_cpuset_t *cpuset);
1995 
1996 /* create and initialize an array of cpuset structs */
1997 PMIX_EXPORT pmix_cpuset_t* PMIx_Cpuset_create(size_t n);
1998 
1999 /* free memory stored inside an array of cpuset structs
2000  * (frees the struct memory itself */
2001 PMIX_EXPORT void PMIx_Cpuset_free(pmix_cpuset_t *c, size_t n);
2002 
2003 /* initialize a geometry struct */
2004 PMIX_EXPORT void PMIx_Geometry_construct(pmix_geometry_t *g);
2005 
2006 /* free memory stored inside a cpuset struct */
2007 PMIX_EXPORT void PMIx_Geometry_destruct(pmix_geometry_t *g);
2008 
2009 /* create and initialize an array of cpuset structs */
2010 PMIX_EXPORT pmix_geometry_t* PMIx_Geometry_create(size_t n);
2011 
2012 /* free memory stored inside an array of cpuset structs
2013  * (frees the struct memory itself */
2014 PMIX_EXPORT void PMIx_Geometry_free(pmix_geometry_t *g, size_t n);
2015 
2016 /* initialize a device struct */
2017 PMIX_EXPORT void PMIx_Device_construct(pmix_device_t *d);
2018 
2019 /* free memory stored inside a device struct */
2020 PMIX_EXPORT void PMIx_Device_destruct(pmix_device_t *d);
2021 
2022 /* create and initialize an array of device structs */
2023 PMIX_EXPORT pmix_device_t* PMIx_Device_create(size_t n);
2024 
2025 /* free memory stored inside an array of device structs
2026  * (frees the struct memory itself) */
2027 PMIX_EXPORT void PMIx_Device_free(pmix_device_t *d, size_t n);
2028 
2029 /* initialize a node_pid struct */
2030 PMIX_EXPORT void PMIx_Node_pid_construct(pmix_node_pid_t *d);
2031 
2032 /* free memory stored inside a node_pid struct */
2033 PMIX_EXPORT void PMIx_Node_pid_destruct(pmix_node_pid_t *d);
2034 
2035 /* create and initialize an array of node_pid structs */
2036 PMIX_EXPORT pmix_node_pid_t* PMIx_Node_pid_create(size_t n);
2037 
2038 /* free memory stored inside an array of node_pid structs
2039  * (frees the struct memory itself) */
2040 PMIX_EXPORT void PMIx_Node_pid_free(pmix_node_pid_t *d, size_t n);
2041 
2042 /* initialize a resource unit struct */
2043 PMIX_EXPORT void PMIx_Resource_unit_construct(pmix_resource_unit_t *d);
2044 
2045 /* free memory stored inside a resource unit struct */
2046 PMIX_EXPORT void PMIx_Resource_unit_destruct(pmix_resource_unit_t *d);
2047 
2048 /* create and initialize an array of resource unit structs */
2049 PMIX_EXPORT pmix_resource_unit_t* PMIx_Resource_unit_create(size_t n);
2050 
2051 /* free memory stored inside an array of resource unit structs (does
2052  * not free the struct memory itself) */
2053 PMIX_EXPORT void PMIx_Resource_unit_free(pmix_resource_unit_t *d, size_t n);
2054 
2055 /* initialize a device distance struct */
2056 PMIX_EXPORT void PMIx_Device_distance_construct(pmix_device_distance_t *d);
2057 
2058 /* free memory stored inside a device distance struct */
2059 PMIX_EXPORT void PMIx_Device_distance_destruct(pmix_device_distance_t *d);
2060 
2061 /* create and initialize an array of device distance structs */
2062 PMIX_EXPORT pmix_device_distance_t* PMIx_Device_distance_create(size_t n);
2063 
2064 /* free memory stored inside an array of device distance structs
2065  * (frees the struct memory itself) */
2066 PMIX_EXPORT void PMIx_Device_distance_free(pmix_device_distance_t *d, size_t n);
2067 
2068 
2069 /* initialize a byte object struct */
2070 PMIX_EXPORT void PMIx_Byte_object_construct(pmix_byte_object_t *b);
2071 
2072 /* free memory stored inside a byte object struct */
2073 PMIX_EXPORT void PMIx_Byte_object_destruct(pmix_byte_object_t *g);
2074 
2075 /* create and initialize an array of byte object structs */
2076 PMIX_EXPORT pmix_byte_object_t* PMIx_Byte_object_create(size_t n);
2077 
2078 /* free memory stored inside an array of byte object structs
2079 * (frees the struct memory itself */
2080 PMIX_EXPORT void PMIx_Byte_object_free(pmix_byte_object_t *g, size_t n);
2081 
2082 /* load a byte object */
2083 PMIX_EXPORT void PMIx_Byte_object_load(pmix_byte_object_t *b,
2084                                        char *d, size_t sz);
2085 
2086 /* initialize an endpoint struct */
2087 PMIX_EXPORT void PMIx_Endpoint_construct(pmix_endpoint_t *e);
2088 
2089 /* free memory stored inside an endpoint struct */
2090 PMIX_EXPORT void PMIx_Endpoint_destruct(pmix_endpoint_t *e);
2091 
2092 /* create and initialize an array of endpoint structs */
2093 PMIX_EXPORT pmix_endpoint_t* PMIx_Endpoint_create(size_t n);
2094 
2095 /* free memory stored inside an array of endpoint structs (does
2096  * not free the struct memory itself */
2097 PMIX_EXPORT void PMIx_Endpoint_free(pmix_endpoint_t *e, size_t n);
2098 
2099 
2100 /* initialize an envar struct */
2101 PMIX_EXPORT void PMIx_Envar_construct(pmix_envar_t *e);
2102 
2103 /* free memory stored inside an envar struct */
2104 PMIX_EXPORT void PMIx_Envar_destruct(pmix_envar_t *e);
2105 
2106 /* create and initialize an array of envar structs */
2107 PMIX_EXPORT pmix_envar_t* PMIx_Envar_create(size_t n);
2108 
2109 /* free memory stored inside an array of envar structs
2110  * (frees the struct memory itself */
2111 PMIX_EXPORT void PMIx_Envar_free(pmix_envar_t *e, size_t n);
2112 
2113 /* load an envar struct */
2114 PMIX_EXPORT void PMIx_Envar_load(pmix_envar_t *e,
2115                                  char *var,
2116                                  char *value,
2117                                  char separator);
2118 
2119 /* initialize a data buffer struct */
2120 PMIX_EXPORT void PMIx_Data_buffer_construct(pmix_data_buffer_t *b);
2121 
2122 /* free memory stored inside a data buffer struct */
2123 PMIX_EXPORT void PMIx_Data_buffer_destruct(pmix_data_buffer_t *b);
2124 
2125 /* create a data buffer struct */
2126 PMIX_EXPORT pmix_data_buffer_t* PMIx_Data_buffer_create(void);
2127 
2128 /* free memory stored inside a data buffer struct */
2129 PMIX_EXPORT void PMIx_Data_buffer_release(pmix_data_buffer_t *b);
2130 
2131 /* load a data buffer struct */
2132 PMIX_EXPORT void PMIx_Data_buffer_load(pmix_data_buffer_t *b,
2133                                        char *bytes, size_t sz);
2134 
2135 /* unload a data buffer struct */
2136 PMIX_EXPORT void PMIx_Data_buffer_unload(pmix_data_buffer_t *b,
2137                                          char **bytes, size_t *sz);
2138 
2139 
2140 /* initialize a proc struct */
2141 PMIX_EXPORT void PMIx_Proc_construct(pmix_proc_t *p);
2142 
2143 /* clear memory inside a proc struct */
2144 PMIX_EXPORT void PMIx_Proc_destruct(pmix_proc_t *p);
2145 
2146 /* create and initialize an array of proc structs */
2147 PMIX_EXPORT pmix_proc_t* PMIx_Proc_create(size_t n);
2148 
2149 /* free memory stored inside an array of proc structs
2150  * (frees the struct memory itself */
2151 PMIX_EXPORT void PMIx_Proc_free(pmix_proc_t *p, size_t n);
2152 
2153 /* load a proc struct */
2154 PMIX_EXPORT void PMIx_Proc_load(pmix_proc_t *p,
2155                                 const char *nspace, pmix_rank_t rank);
2156 
2157 /* construct a multicluster nspace struct from cluster and nspace values */
2158 PMIX_EXPORT void PMIx_Multicluster_nspace_construct(pmix_nspace_t target,
2159                                                     pmix_nspace_t cluster,
2160                                                     pmix_nspace_t nspace);
2161 
2162 /* parse a multicluster nspace struct to separate out the cluster
2163  * and nspace portions */
2164 PMIX_EXPORT void PMIx_Multicluster_nspace_parse(pmix_nspace_t target,
2165                                                 pmix_nspace_t cluster,
2166                                                 pmix_nspace_t nspace);
2167 
2168 
2169 /* initialize a proc info struct */
2170 PMIX_EXPORT void PMIx_Proc_info_construct(pmix_proc_info_t *p);
2171 
2172 /* clear memory inside a proc info struct */
2173 PMIX_EXPORT void PMIx_Proc_info_destruct(pmix_proc_info_t *p);
2174 
2175 /* create and initialize an array of proc info structs */
2176 PMIX_EXPORT pmix_proc_info_t* PMIx_Proc_info_create(size_t n);
2177 
2178 /* free memory stored inside an array of proc info structs
2179  * (frees the struct memory itself */
2180 PMIX_EXPORT void PMIx_Proc_info_free(pmix_proc_info_t *p, size_t n);
2181 
2182 
2183 /* initialize a pdata struct */
2184 PMIX_EXPORT void PMIx_Pdata_construct(pmix_pdata_t *p);
2185 
2186 /* clear memory inside a pdata struct */
2187 PMIX_EXPORT void PMIx_Pdata_destruct(pmix_pdata_t *p);
2188 
2189 /* create and initialize an array of pdata structs */
2190 PMIX_EXPORT pmix_pdata_t* PMIx_Pdata_create(size_t n);
2191 
2192 /* free memory stored inside an array of pdata structs
2193  * (frees the struct memory itself */
2194 PMIX_EXPORT void PMIx_Pdata_free(pmix_pdata_t *p, size_t n);
2195 
2196 /* load data into a pdata struct - values are copied */
2197 PMIX_EXPORT void PMIx_Pdata_load(pmix_pdata_t *dest,
2198                                  const pmix_proc_t *p,
2199                                  const char *key,
2200                                  const void *data,
2201                                  pmix_data_type_t type);
2202 
2203 /* transfer data from one pdata to another - data is copied */
2204 PMIX_EXPORT void PMIx_Pdata_xfer(pmix_pdata_t *dest,
2205                                  pmix_pdata_t *src);
2206 
2207 /* initialize an app struct */
2208 PMIX_EXPORT void PMIx_App_construct(pmix_app_t *p);
2209 
2210 /* clear memory inside an app struct */
2211 PMIX_EXPORT void PMIx_App_destruct(pmix_app_t *p);
2212 
2213 /* create and initialize an array of app structs */
2214 PMIX_EXPORT pmix_app_t* PMIx_App_create(size_t n);
2215 
2216 /* create and initialize an array of pmix_info_t structs
2217  * for the app->info field */
2218 PMIX_EXPORT void PMIx_App_info_create(pmix_app_t *p, size_t n);
2219 
2220 /* free memory stored inside an array of app structs
2221  * (frees the struct memory itself */
2222 PMIX_EXPORT void PMIx_App_free(pmix_app_t *p, size_t n);
2223 
2224 /* release memory inside a single app struct (frees struct memory) */
2225 PMIX_EXPORT void PMIx_App_release(pmix_app_t *p);
2226 
2227 /* initialize a query struct */
2228 PMIX_EXPORT void PMIx_Query_construct(pmix_query_t *p);
2229 
2230 /* clear memory inside a query struct */
2231 PMIX_EXPORT void PMIx_Query_destruct(pmix_query_t *p);
2232 
2233 /* create and initialize an array of query structs */
2234 PMIX_EXPORT pmix_query_t* PMIx_Query_create(size_t n);
2235 
2236 /* create an array of pmix_info_t qualifiers in a query struct */
2237 PMIX_EXPORT void PMIx_Query_qualifiers_create(pmix_query_t *p, size_t n);
2238 
2239 /* free memory store inside an array of query structs
2240  * (frees the struct memory itself) */
2241 PMIX_EXPORT void PMIx_Query_free(pmix_query_t *p, size_t n);
2242 
2243 /* release memory inside a single query struct (frees struct memory) */
2244 PMIX_EXPORT void PMIx_Query_release(pmix_query_t *p);
2245 
2246 /* initialize a regattr struct */
2247 PMIX_EXPORT void PMIx_Regattr_construct(pmix_regattr_t *p);
2248 
2249 /* clear memory inside a regattr struct */
2250 PMIX_EXPORT void PMIx_Regattr_destruct(pmix_regattr_t *p);
2251 
2252 /* create and initialize an array of regattr structs */
2253 PMIX_EXPORT pmix_regattr_t* PMIx_Regattr_create(size_t n);
2254 
2255 /* free memory store inside an array of regattr structs
2256  * (frees the struct memory itself) */
2257 PMIX_EXPORT void PMIx_Regattr_free(pmix_regattr_t *p, size_t n);
2258 
2259 /* load the fields of a regattr struct with the provided data
2260  * (data is copied) */
2261 PMIX_EXPORT void PMIx_Regattr_load(pmix_regattr_t *info,
2262                                    const char *name,
2263                                    const char *key,
2264                                    pmix_data_type_t type,
2265                                    const char *description);
2266 
2267 /* copy the fields of one regattr struct to another */
2268 PMIX_EXPORT void PMIx_Regattr_xfer(pmix_regattr_t *dest,
2269                                    const pmix_regattr_t *src);
2270 
2271 /* initialize a fabric struct */
2272 PMIX_EXPORT void PMIx_Fabric_construct(pmix_fabric_t *p);
2273 
2274 #endif
2275 
2276 
2277 #if defined(c_plusplus) || defined(__cplusplus)
2278 }
2279 #endif
2280 
2281 #endif