Upgrade macos

This commit is contained in:
Bassem Girgis
2025-03-19 08:52:56 -05:00
parent 53580cb51f
commit d29ef955f5
8041 changed files with 1936720 additions and 130842 deletions

View File

@@ -0,0 +1,251 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2007 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_MCA_BASE_H
#define PMIX_MCA_BASE_H
#include "src/include/pmix_config.h"
#include "src/class/pmix_list.h"
#include "src/class/pmix_object.h"
/*
* These units are large enough to warrant their own .h files
*/
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/mca.h"
#include "src/util/pmix_cmd_line.h"
#include "src/util/pmix_output.h"
BEGIN_C_DECLS
/*
* Structure for making plain lists of components
*/
struct pmix_mca_base_component_list_item_t {
pmix_list_item_t super;
const pmix_mca_base_component_t *cli_component;
};
typedef struct pmix_mca_base_component_list_item_t pmix_mca_base_component_list_item_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_mca_base_component_list_item_t);
/*
* Structure for making priority lists of components
*/
struct pmix_mca_base_component_priority_list_item_t {
pmix_mca_base_component_list_item_t super;
int cpli_priority;
};
typedef struct pmix_mca_base_component_priority_list_item_t
pmix_mca_base_component_priority_list_item_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_mca_base_component_priority_list_item_t);
/*
* Public variables
*/
PMIX_EXPORT extern char *pmix_mca_base_component_path;
PMIX_EXPORT extern char *pmix_mca_base_component_show_load_errors;
PMIX_EXPORT extern bool pmix_mca_base_component_abort_on_load_error;
PMIX_EXPORT extern bool pmix_mca_base_component_track_load_errors;
PMIX_EXPORT extern bool pmix_mca_base_component_disable_dlopen;
PMIX_EXPORT extern char *pmix_mca_base_system_default_path;
PMIX_EXPORT extern char *pmix_mca_base_user_default_path;
/*
* Standard verbosity levels
*/
enum {
/** total silence */
PMIX_MCA_BASE_VERBOSE_NONE = -1,
/** only errors are printed */
PMIX_MCA_BASE_VERBOSE_ERROR = 0,
/** emit messages about component selection, open, and unloading */
PMIX_MCA_BASE_VERBOSE_COMPONENT = 10,
/** also emit warnings */
PMIX_MCA_BASE_VERBOSE_WARN = 20,
/** also emit general, user-relevant information, such as rationale as to why certain choices
* or code paths were taken, information gleaned from probing the local system, etc. */
PMIX_MCA_BASE_VERBOSE_INFO = 40,
/** also emit relevant tracing information (e.g., which functions were invoked /
* call stack entry/exit info) */
PMIX_MCA_BASE_VERBOSE_TRACE = 60,
/** also emit PMIX-developer-level (i.e,. highly detailed) information */
PMIX_MCA_BASE_VERBOSE_DEBUG = 80,
/** also output anything else that might be useful */
PMIX_MCA_BASE_VERBOSE_MAX = 100,
};
/*
* Public functions
*/
/**
* First function called in the MCA.
*
* @return PMIX_SUCCESS Upon success
* @return PMIX_ERROR Upon failure
*
* This function starts up the entire MCA. It initializes a bunch
* of built-in MCA parameters, and initialized the MCA component
* repository.
*
* It must be the first MCA function invoked. It is normally
* invoked during the initialization stage and specifically
* invoked in the special case of the *_info command.
*/
PMIX_EXPORT int pmix_mca_base_open(const char *add_path);
/**
* Last function called in the MCA
*
* @return PMIX_SUCCESS Upon success
* @return PMIX_ERROR Upon failure
*
* This function closes down the entire MCA. It clears all MCA
* parameters and closes down the MCA component repository.
*
* It must be the last MCA function invoked. It is normally invoked
* during the finalize stage.
*/
PMIX_EXPORT int pmix_mca_base_close(void);
/**
* A generic select function
*
*/
PMIX_EXPORT int pmix_mca_base_select(const char *type_name, int output_id,
pmix_list_t *components_available,
pmix_mca_base_module_t **best_module,
pmix_mca_base_component_t **best_component, int *priority_out);
/**
* A function for component query functions to discover if they have
* been explicitly required to or requested to be selected.
*
* exclusive: If the specified component is the only component that is
* available for selection.
*
*/
PMIX_EXPORT int pmix_mca_base_is_component_required(pmix_list_t *components_available,
pmix_mca_base_component_t *component,
bool exclusive, bool *is_required);
/* pmix_mca_base_component_compare.c */
PMIX_EXPORT int
pmix_mca_base_component_compare_priority(pmix_mca_base_component_priority_list_item_t *a,
pmix_mca_base_component_priority_list_item_t *b);
PMIX_EXPORT int pmix_mca_base_component_compare(const pmix_mca_base_component_t *a,
const pmix_mca_base_component_t *b);
PMIX_EXPORT int pmix_mca_base_component_compatible(const pmix_mca_base_component_t *a,
const pmix_mca_base_component_t *b);
PMIX_EXPORT char *pmix_mca_base_component_to_string(const pmix_mca_base_component_t *a);
/* pmix_mca_base_component_find.c */
PMIX_EXPORT int pmix_mca_base_component_find(const char *directory,
pmix_mca_base_framework_t *framework,
bool ignore_requested, bool open_dso_components);
/**
* Parse the requested component string and return an pmix_argv of the requested
* (or not requested) components.
*/
PMIX_EXPORT int pmix_mca_base_component_parse_requested(const char *requested, bool *include_mode,
char ***requested_component_names);
/**
* Filter a list of components based on a comma-delimted list of names
*
* @param[in] framework
*
* @returns PMIX_SUCCESS On success
* @returns PMIX_ERR_NOT_FOUND If some component in {filter_names} is not found in
* {components}. Does not apply to negated filters.
* @returns pmix error code On other error.
*
* This function closes and releases any components that do not match the filter_name and
* filter flags.
*/
PMIX_EXPORT int pmix_mca_base_components_filter(pmix_mca_base_framework_t *framework);
/* Safely release some memory allocated by pmix_mca_base_component_find()
(i.e., is safe to call even if you never called
pmix_mca_base_component_find()). */
PMIX_EXPORT int pmix_mca_base_component_find_finalize(void);
/* pmix_mca_base_components_register.c */
PMIX_EXPORT int
pmix_mca_base_framework_components_register(struct pmix_mca_base_framework_t *framework,
pmix_mca_base_register_flag_t flags);
/* pmix_mca_base_components_open.c */
PMIX_EXPORT int pmix_mca_base_show_load_errors_init(void);
PMIX_EXPORT int pmix_mca_base_show_load_errors_finalize(void);
PMIX_EXPORT bool pmix_mca_base_show_load_errors(const char *framework_name,
const char *component_name);
PMIX_EXPORT int pmix_mca_base_framework_components_open(struct pmix_mca_base_framework_t *framework,
pmix_mca_base_open_flag_t flags);
PMIX_EXPORT int pmix_mca_base_components_open(const char *type_name, int output_id,
const pmix_mca_base_component_t **static_components,
pmix_list_t *components_available,
bool open_dso_components);
/* pmix_mca_base_components_close.c */
/**
* Close and release a component.
*
* @param[in] component Component to close
* @param[in] output_id Output id for debugging output
*
* After calling this function the component may no longer be used.
*/
PMIX_EXPORT void pmix_mca_base_component_close(const pmix_mca_base_component_t *component,
int output_id);
/**
* Release a component without closing it.
* @param[in] component Component to close
* @param[in] output_id Output id for debugging output
*
* After calling this function the component may no longer be used.
*/
PMIX_EXPORT void pmix_mca_base_component_unload(const pmix_mca_base_component_t *component,
int output_id);
PMIX_EXPORT int pmix_mca_base_components_close(int output_id, pmix_list_t *components_available,
const pmix_mca_base_component_t *skip);
PMIX_EXPORT int
pmix_mca_base_framework_components_close(struct pmix_mca_base_framework_t *framework,
const pmix_mca_base_component_t *skip);
END_C_DECLS
#endif /* MCA_BASE_H */

View File

@@ -0,0 +1,87 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2020 Google, LLC. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_MCA_BASE_ALIAS_H
#define PMIX_MCA_BASE_ALIAS_H
#include "src/include/pmix_config.h"
#include "src/class/pmix_list.h"
BEGIN_C_DECLS
enum pmix_mca_base_alias_flags_t {
PMIX_MCA_BASE_ALIAS_FLAG_NONE = 0,
/** The aliased name has been deprecated. */
PMIX_MCA_BASE_ALIAS_FLAG_DEPRECATED = 1,
};
typedef enum pmix_mca_base_alias_flags_t pmix_mca_base_alias_flags_t;
struct pmix_mca_base_alias_item_t {
pmix_list_item_t super;
/** Name aias. */
char *component_alias;
/** Alias flags. */
uint32_t alias_flags;
};
typedef struct pmix_mca_base_alias_item_t pmix_mca_base_alias_item_t;
PMIX_CLASS_DECLARATION(pmix_mca_base_alias_item_t);
struct pmix_mca_base_alias_t {
pmix_object_t super;
/** List of name aliases. */
pmix_list_t component_aliases;
};
typedef struct pmix_mca_base_alias_t pmix_mca_base_alias_t;
PMIX_CLASS_DECLARATION(pmix_mca_base_alias_t);
/**
* @brief Create a alias for a component name.
*
* @param[in] project Project name (may be NULL)
* @param[in] framework Framework name (may be NULL)
* @param[in] component_name Name of component to alias (may not be NULL)
* @param[in] component_alias Aliased name (may not be NULL)
* @param[in] alias_flags Flags (see mca_base_alias_flags_t)
*
* This function aliases one component name to another. When aliased
* any variable registered with this project, framework, and
* component_name will have synonyms created. For example, if
* pmix_btl_vader is aliased to sm then registers a variable
* named btl_vader_flags then a synonym will be created with the
* name btl_sm_flags. If an alias is registered early enough
* (during framework registration for example) then the alias can
* also be used for component selection. In the previous example
* --mca btl vader and --mca btl sm would select the same
* component if the synonym is registered in the btl framework
* registration function.
*/
PMIX_EXPORT int pmix_mca_base_alias_register(const char *project, const char *framework,
const char *component_name,
const char *component_alias, uint32_t alias_flags);
/**
* @brief Check for aliases for a component.
*
* @param[in] project Project name (may be NULL)
* @param[in] frameworek Framework name (may be NULL)
* @param[in] component_name Component name (may not be NULL)
*/
PMIX_EXPORT const pmix_mca_base_alias_t *
pmix_mca_base_alias_lookup(const char *project, const char *framework, const char *component_name);
PMIX_EXPORT void pmix_mca_base_alias_cleanup(void);
#endif /* PMIX_MCA_BASE_ALIAS_H */

View File

@@ -0,0 +1,149 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file pmix_mca_base_component_repository.h
*
* This file provide the external interface to our base component
* module. Most of the components that depend on it, will use the
* retain_component() function to increase the reference count on a
* particular component (as opposed to the retain() function, which is
* internal to the pmix/mca/base). But it's convenient to have all
* the functions exported from one header file rather than to separate
* retain_component() and retain() into two separate header files
* (i.e., have a separate header file just for retain()).
*/
#ifndef PMIX_MCA_BASE_COMPONENT_REPOSITORY_H
#define PMIX_MCA_BASE_COMPONENT_REPOSITORY_H
#include "src/include/pmix_config.h"
#include "src/mca/pdl/base/base.h"
#include "src/mca/pdl/pdl.h"
BEGIN_C_DECLS
struct pmix_mca_base_component_repository_item_t {
pmix_list_item_t super;
char *ri_project;
char ri_type[PMIX_MCA_BASE_MAX_TYPE_NAME_LEN + 1];
char ri_name[PMIX_MCA_BASE_MAX_COMPONENT_NAME_LEN + 1];
char *ri_path;
char *ri_base;
pmix_pdl_handle_t *ri_dlhandle;
const pmix_mca_base_component_t *ri_component_struct;
int ri_refcnt;
};
typedef struct pmix_mca_base_component_repository_item_t pmix_mca_base_component_repository_item_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_mca_base_component_repository_item_t);
/*
* Structure to track information about why a component failed to load.
*/
struct pmix_mca_base_failed_component_t {
pmix_list_item_t super;
pmix_mca_base_component_repository_item_t *comp;
char *error_msg;
};
typedef struct pmix_mca_base_failed_component_t pmix_mca_base_failed_component_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_mca_base_failed_component_t);
/**
* @brief initialize the component repository
*
* This function must be called before any frameworks are registered or
* opened. It is responsible for setting up the repository of dynamically
* loaded components. The initial search path is taken from the
* pmix_mca_base_component_path MCA parameter. pmix_mca_base_open () is a
* prerequisite call as it registers the pmix_mca_base_component_path parameter.
*/
PMIX_EXPORT int pmix_mca_base_component_repository_init(void);
/**
* @brief add search path for dynamically loaded components
*
* @param[in] path delimited list of search paths to add
*/
PMIX_EXPORT int pmix_mca_base_component_repository_add(const char *project,
const char *path);
/**
* @brief return the list of components that match a given framework
*
* @param[in] framework framework to match
* @param[out] framework_components components that match this framework
*
* The list returned in {framework_components} is owned by the component
* repository and CAN NOT be modified by the caller.
*/
PMIX_EXPORT int
pmix_mca_base_component_repository_get_components(pmix_mca_base_framework_t *framework,
pmix_list_t **framework_components);
/**
* @brief finalize the mca component repository
*/
PMIX_EXPORT void pmix_mca_base_component_repository_finalize(void);
/**
* @brief open the repository item and add it to the framework's component
* list
*
* @param[in] framework framework that matches the component
* @param[in] ri dynamic component to open
*/
PMIX_EXPORT int
pmix_mca_base_component_repository_open(pmix_mca_base_framework_t *framework,
pmix_mca_base_component_repository_item_t *ri);
/**
* @brief Reduce the reference count of a component and dlclose it if necessary
*/
PMIX_EXPORT void
pmix_mca_base_component_repository_release(const pmix_mca_base_component_t *component);
/**
* @brief Increase the reference count of a component
*
* Each component repository item starts with a reference count of 0. This ensures that
* when a framework closes it's components the repository items are all correctly
* dlclosed. This function can be used to prevent the dlclose if a component is needed
* after its framework has closed the associated component. Users of this function
* should call pmix_mca_base_component_repository_release() once they are finished with the
* component.
*
* @note all components are automatically unloaded by the
* pmix_mca_base_component_repository_finalize() call.
*/
PMIX_EXPORT int pmix_mca_base_component_repository_retain_component(const char *type,
const char *name);
END_C_DECLS
#endif /* MCA_BASE_COMPONENT_REPOSITORY_H */

View File

@@ -0,0 +1,244 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#if !defined(PMIX_MCA_BASE_FRAMEWORK_H)
# define PMIX_MCA_BASE_FRAMEWORK_H
# include "src/include/pmix_config.h"
# include "src/class/pmix_list.h"
# include "src/mca/mca.h"
/*
* Register and open flags
*/
enum pmix_mca_base_register_flag_t {
PMIX_MCA_BASE_REGISTER_DEFAULT = 0,
/** Register all components (ignore selection MCA variables) */
PMIX_MCA_BASE_REGISTER_ALL = 1,
/** Do not register DSO components */
PMIX_MCA_BASE_REGISTER_STATIC_ONLY = 2
};
typedef enum pmix_mca_base_register_flag_t pmix_mca_base_register_flag_t;
enum pmix_mca_base_open_flag_t {
PMIX_MCA_BASE_OPEN_DEFAULT = 0,
/** Find components in pmix_mca_base_components_find. Used by
pmix_mca_base_framework_open() when NOREGISTER is specified
by the framework */
PMIX_MCA_BASE_OPEN_FIND_COMPONENTS = 1,
/** Do not open DSO components */
PMIX_MCA_BASE_OPEN_STATIC_ONLY = 2,
};
typedef enum pmix_mca_base_open_flag_t pmix_mca_base_open_flag_t;
/**
* Register the MCA framework parameters
*
* @param[in] flags Registration flags (see mca/base/pmix_base.h)
*
* @retval PMIX_SUCCESS on success
* @retval pmix error code on failure
*
* This function registers all framework MCA parameters. This
* function should not call pmix_mca_base_framework_components_register().
*
* Frameworks are NOT required to provide this function. It
* may be NULL.
*/
typedef int (*pmix_mca_base_framework_register_params_fn_t)(pmix_mca_base_register_flag_t flags);
/**
* Initialize the MCA framework
*
* @retval PMIX_SUCCESS Upon success
* @retval PMIX_ERROR Upon failure
*
* This must be the first function invoked in the MCA framework.
* It initializes the MCA framework, finds and opens components,
* populates the components list, etc.
*
* This function is invoked during pmix_init() and during the
* initialization of the special case of the ompi_info command.
*
* This function fills in the components framework value, which
* is a list of all components that were successfully opened.
* This variable should \em only be used by other framework base
* functions or by ompi_info -- it is not considered a public
* interface member -- and is only mentioned here for completeness.
*
* Any resources allocated by this function must be freed
* in the framework close function.
*
* Frameworks are NOT required to provide this function. It may
* be NULL. If a framework does not provide an open function the
* default behavior of pmix_mca_base_framework_open() is to call
* pmix_mca_base_framework_components_open(). If a framework provides
* an open function it will need to call pmix_mca_base_framework_components_open()
* if it needs to open any components.
*/
typedef int (*pmix_mca_base_framework_open_fn_t)(pmix_mca_base_open_flag_t flags);
/**
* Shut down the MCA framework.
*
* @retval PMIX_SUCCESS Always
*
* This function should shut downs everything in the MCA
* framework, and is called during pmix_finalize() and the
* special case of the ompi_info command.
*
* It must be the last function invoked on the MCA framework.
*
* Frameworks are NOT required to provide this function. It may
* be NULL. If a framework does not provide a close function the
* default behavior of pmix_mca_base_framework_close() is to call
* pmix_mca_base_framework_components_close(). If a framework provide
* a close function it will need to call pmix_mca_base_framework_components_close()
* if any components were opened.
*/
typedef int (*pmix_mca_base_framework_close_fn_t)(void);
typedef enum {
PMIX_MCA_BASE_FRAMEWORK_FLAG_DEFAULT = 0,
/** Don't register any variables for this framework */
PMIX_MCA_BASE_FRAMEWORK_FLAG_NOREGISTER = 1,
/** Internal. Don't set outside pmix_mca_base_framework.h */
PMIX_MCA_BASE_FRAMEWORK_FLAG_REGISTERED = 2,
/** Framework does not have any DSO components */
PMIX_MCA_BASE_FRAMEWORK_FLAG_NO_DSO = 4,
/** Internal. Don't set outside pmix_mca_base_framework.h */
PMIX_MCA_BASE_FRAMEWORK_FLAG_OPEN = 8,
/**
* The upper 16 bits are reserved for project specific flags.
*/
} pmix_mca_base_framework_flags_t;
typedef struct pmix_mca_base_framework_t {
/** Project name for this component (ex "pmix") */
char *framework_project;
/** Framework name */
char *framework_name;
/** Description of this framework or NULL */
const char *framework_description;
/** Framework register function or NULL if the framework
and all its components have nothing to register */
pmix_mca_base_framework_register_params_fn_t framework_register;
/** Framework open function or NULL */
pmix_mca_base_framework_open_fn_t framework_open;
/** Framework close function or NULL */
pmix_mca_base_framework_close_fn_t framework_close;
/** Framework flags (future use) set to 0 */
pmix_mca_base_framework_flags_t framework_flags;
/** Framework open count */
int framework_refcnt;
/** List of static components */
const pmix_mca_base_component_t **framework_static_components;
/** Component selection. This will be registered with the MCA
variable system and should be either NULL (all components) or
a heap allocated, comma-delimited list of components. */
char *framework_selection;
/** Verbosity level (0-100) */
int framework_verbose;
/** Pmix output for this framework (or -1) */
int framework_output;
/** List of selected components (filled in by pmix_mca_base_framework_register()
or pmix_mca_base_framework_open() */
pmix_list_t framework_components;
/** List of components that failed to load */
pmix_list_t framework_failed_components;
} pmix_mca_base_framework_t;
/**
* Register a framework with MCA.
*
* @param[in] framework framework to register
*
* @retval PMIX_SUCCESS Upon success
* @retval PMIX_ERROR Upon failure
*
* Call a framework's register function.
*/
PMIX_EXPORT int pmix_mca_base_framework_register(pmix_mca_base_framework_t *framework,
pmix_mca_base_register_flag_t flags);
/**
* Open a framework
*
* @param[in] framework framework to open
*
* @retval PMIX_SUCCESS Upon success
* @retval PMIX_ERROR Upon failure
*
* Call a framework's open function.
*/
PMIX_EXPORT int pmix_mca_base_framework_open(pmix_mca_base_framework_t *framework,
pmix_mca_base_open_flag_t flags);
/**
* Close a framework
*
* @param[in] framework framework to close
*
* @retval PMIX_SUCCESS Upon success
* @retval PMIX_ERROR Upon failure
*
* Call a framework's close function.
*/
PMIX_EXPORT int pmix_mca_base_framework_close(pmix_mca_base_framework_t *framework);
/**
* Check if a framework is already registered
*
* @param[in] framework framework to query
*
* @retval true if the framework's mca variables are registered
* @retval false if not
*/
PMIX_EXPORT bool pmix_mca_base_framework_is_registered(struct pmix_mca_base_framework_t *framework);
/**
* Check if a framework is already open
*
* @param[in] framework framework to query
*
* @retval true if the framework is open
* @retval false if not
*/
PMIX_EXPORT bool pmix_mca_base_framework_is_open(struct pmix_mca_base_framework_t *framework);
/**
* Macro to declare an MCA framework
*
* Example:
* PMIX_MCA_BASE_FRAMEWORK_DECLARE(pmix, foo, NULL, pmix_foo_open, pmix_foo_close,
* MCA_BASE_FRAMEWORK_FLAG_LAZY)
*/
# define PMIX_MCA_BASE_FRAMEWORK_DECLARE(project, name, description, registerfn, openfn, \
closefn, static_components, flags) \
pmix_mca_base_framework_t project##_##name##_base_framework \
= {.framework_project = #project, \
.framework_name = #name, \
.framework_description = description, \
.framework_register = registerfn, \
.framework_open = openfn, \
.framework_close = closefn, \
.framework_flags = flags, \
.framework_refcnt = 0, \
.framework_static_components = static_components, \
.framework_selection = NULL, \
.framework_verbose = 0, \
.framework_output = -1}
#endif /* PMIX_MCA_BASE_FRAMEWORK_H */

View File

@@ -0,0 +1,594 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file
* This file presents the MCA variable interface.
*
* Note that there are two scopes for MCA variables: "normal" and
* attributes. Specifically, all MCA variables are "normal" -- some
* are special and may also be found on attributes on communicators,
* datatypes, or windows.
*
* In general, these functions are intended to be used as follows:
*
* - Creating MCA variables
* -# Register a variable, get an index back
* - Using MCA variables
* -# Lookup a "normal" variable value on a specific index, or
* -# Lookup an attribute variable on a specific index and
* communicator / datatype / window.
*
* MCA variables can be defined in multiple different places. As
* such, variables are \em resolved to find their value. The order
* of resolution is as follows:
*
* - An "override" location that is only available to be set via the
* pmix_mca_base_param API.
* - Look for an environment variable corresponding to the MCA
* variable.
* - See if a file contains the MCA variable (MCA variable files are
* read only once -- when the first time any mca_param_t function is
* invoked).
* - If nothing else was found, use the variable's default value.
*
* Note that there is a second header file (pmix_mca_base_vari.h)
* that contains several internal type declarations for the variable
* system. The internal file is only used within the variable system
* itself; it should not be required by any other PMIX entities.
*/
#ifndef PMIX_MCA_BASE_VAR_H
#define PMIX_MCA_BASE_VAR_H
#include "src/include/pmix_config.h"
#include "src/class/pmix_list.h"
#include "src/class/pmix_value_array.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var_enum.h"
#include "src/mca/base/pmix_mca_base_var_group.h"
#include "src/mca/mca.h"
/**
* The types of MCA variables.
*/
typedef enum {
/** The variable is of type int. */
PMIX_MCA_BASE_VAR_TYPE_INT,
/** The variable is of type unsigned int */
PMIX_MCA_BASE_VAR_TYPE_UNSIGNED_INT,
/** The variable is of type unsigned long */
PMIX_MCA_BASE_VAR_TYPE_UNSIGNED_LONG,
/** The variable is of type unsigned long long */
PMIX_MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG,
/** The variable is of type size_t */
PMIX_MCA_BASE_VAR_TYPE_SIZE_T,
/** The variable is of type string. */
PMIX_MCA_BASE_VAR_TYPE_STRING,
/** The variable is of type string and contains version. */
PMIX_MCA_BASE_VAR_TYPE_VERSION_STRING,
/** The variable is of type bool */
PMIX_MCA_BASE_VAR_TYPE_BOOL,
/** The variable is of type double */
PMIX_MCA_BASE_VAR_TYPE_DOUBLE,
/** Maximum variable type. */
PMIX_MCA_BASE_VAR_TYPE_MAX
} pmix_mca_base_var_type_t;
PMIX_EXPORT extern const char *pmix_var_type_names[];
/**
* Source of an MCA variable's value
*/
typedef enum {
/** The default value */
PMIX_MCA_BASE_VAR_SOURCE_DEFAULT,
/** The value came from the command line */
PMIX_MCA_BASE_VAR_SOURCE_COMMAND_LINE,
/** The value came from the environment */
PMIX_MCA_BASE_VAR_SOURCE_ENV,
/** The value came from a file */
PMIX_MCA_BASE_VAR_SOURCE_FILE,
/** The value came a "set" API call */
PMIX_MCA_BASE_VAR_SOURCE_SET,
/** The value came from the override file */
PMIX_MCA_BASE_VAR_SOURCE_OVERRIDE,
/** Maximum source type */
PMIX_MCA_BASE_VAR_SOURCE_MAX
} pmix_mca_base_var_source_t;
typedef enum {
PMIX_MCA_BASE_VAR_SYN_FLAG_DEPRECATED = 0x0001
} pmix_mca_base_var_syn_flag_t;
typedef enum {
PMIX_MCA_BASE_VAR_FLAG_NONE = 0x0000,
/** Variable is deprecated */
PMIX_MCA_BASE_VAR_FLAG_DEPRECATED = 0x0008,
/** Variable is valid */
PMIX_MCA_BASE_VAR_FLAG_VALID = 0x00010000,
/** Variable is a synonym */
PMIX_MCA_BASE_VAR_FLAG_SYNONYM = 0x00020000,
/** mbv_source_file needs to be freed */
PMIX_MCA_BASE_VAR_FLAG_SOURCE_FILE_NEEDS_FREE = 0x00040000
} pmix_mca_base_var_flag_internal_t;
/**
* Types for MCA parameters.
*/
typedef union {
/** integer value */
int intval;
/** unsigned int value */
unsigned int uintval;
/** string value */
char *stringval;
/** boolean value */
bool boolval;
/** unsigned long value */
unsigned long ulval;
/** unsigned long long value */
unsigned long long ullval;
/** size_t value */
size_t sizetval;
/** double value */
double lfval;
} pmix_mca_base_var_storage_t;
/**
* Entry for holding information about an MCA variable.
*/
struct pmix_mca_base_var_t {
/** Allow this to be an PMIX OBJ */
pmix_object_t super;
/** Variable index. This will remain constant until pmix_mca_base_var_finalize()
is called. */
int mbv_index;
/** Group index. This will remain constant until pmix_mca_base_var_finalize()
is called. This variable will be deregistered if the associated group
is deregistered with pmix_mca_base_var_group_deregister() */
int mbv_group_index;
/** Enum indicating the type of the variable (integer, string, boolean) */
pmix_mca_base_var_type_t mbv_type;
/** String of the variable name */
char *mbv_variable_name;
/** Full variable name, in case it is not <framework>_<component>_<param> */
char *mbv_full_name;
/** Long variable name <project>_<framework>_<component>_<name> */
char *mbv_long_name;
char *mbv_prefix;
/** List of synonym names for this variable. This *must* be a
pointer (vs. a plain pmix_list_t) because we copy this whole
struct into a new var for permanent storage
(pmix_vale_array_append_item()), and the internal pointers in
the pmix_list_t will be invalid when that happens. Hence, we
simply keep a pointer to an external pmix_list_t. Synonyms
are uncommon enough that this is not a big performance hit. */
pmix_value_array_t mbv_synonyms;
/** Variable flags */
pmix_mca_base_var_flag_internal_t mbv_flags;
/** Source of the current value */
pmix_mca_base_var_source_t mbv_source;
/** Synonym for */
int mbv_synonym_for;
/** Variable description */
char *mbv_description;
/** File the value came from */
char *mbv_source_file;
/** Value enumerator (only valid for integer variables) */
pmix_mca_base_var_enum_t *mbv_enumerator;
/** Bind value for this variable (0 - none) */
int mbv_bind;
/** Storage for this variable */
pmix_mca_base_var_storage_t *mbv_storage;
/** File value structure */
void *mbv_file_value;
};
/**
* Convenience typedef.
*/
typedef struct pmix_mca_base_var_t pmix_mca_base_var_t;
/*
* Global functions for MCA
*/
BEGIN_C_DECLS
/**
* Object declarayion for pmix_mca_base_var_t
*/
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_mca_base_var_t);
/**
* Initialize the MCA variable system.
*
* @retval PMIX_SUCCESS
*
* This function initializes the MCA variable system. It is
* invoked internally (by pmix_mca_base_open()) and is only documented
* here for completeness.
*/
PMIX_EXPORT int pmix_mca_base_var_init(void);
/**
* Register an MCA variable
*
* @param[in] project_name The name of the project associated with
* this variable
* @param[in] framework_name The name of the framework associated with
* this variable
* @param[in] component_name The name of the component associated with
* this variable
* @param[in] variable_name The name of this variable
* @param[in] description A string describing the use and valid
* values of the variable (string).
* @param[in] type The type of this variable (string, int, bool).
* @param[in] enumerator Enumerator describing valid values.
* @param[in] bind Hint for MPIT to specify type of binding (0 = none)
* @param[in] flags Flags for this variable.
* @param[in] info_lvl Info level of this variable
* @param[in] scope Indicates the scope of this variable
* @param[in,out] storage Pointer to the value's location.
*
* @retval index Index value representing this variable.
* @retval PMIX_ERR_OUT_OF_RESOURCE Upon failure to allocate memory.
* @retval PMIX_ERROR Upon failure to register the variable.
*
* This function registers an MCA variable and associates it
* with a specific group.
*
* {description} is a string of arbitrary length (verbose is good!)
* for explaining what the variable is for and what its valid values
* are. This message is used in help messages, such as the output
* from the ompi_info executable. The {description} string is copied
* internally; the caller can free {description} upon successful
* return.
*
* {enumerator} is either NULL or a handle that was created via
* pmix_mca_base_var_enum_create(), and describes the valid values of an
* integer variable (i.e., one with type MCA_BASE_VAR_TYPE_INT). When
* a non-NULL {enumerator} is used, the value set for this variable by
* the user will be compared against the values in the enumerator.
* The MCA variable system will allow the parameter to be set to
* either one of the enumerator values (0, 1, 2, etc) or a string
* representing one of those values. {enumerator} is retained until
* either the variable is deregistered using
* pmix_mca_base_var_deregister(), pmix_mca_base_var_group_deregister(), or
* pmix_mca_base_var_finalize(). {enumerator} should be NULL for
* parameters that do not support enumerated values.
*
* {flags} indicate attributes of this variable (internal, settable,
* default only, etc.), as listed below.
*
* If MCA_BASE_VAR_FLAG_INTERNAL is set in {flags}, this variable
* is not shown by default in the output of ompi_info. That is,
* this variable is considered internal to the PMIX implementation
* and is not supposed to be viewed / changed by the user.
*
* If MCA_BASE_VAR_FLAG_DEFAULT_ONLY is set in {flags}, then the value
* provided in storage will not be modified by the MCA variable system
* (i.e., users cannot set the value of this variable via CLI
* parameter, environment variable, file, etc.). It is up to the
* caller to specify (using the scope) if this value may change
* (MCA_BASE_VAR_SCOPE_READONLY) or remain constant
* (MCA_BASE_VAR_SCOPE_CONSTANT). MCA_BASE_VAR_FLAG_DEFAULT_ONLY must
* not be specified with MCA_BASE_VAR_FLAG_SETTABLE.
*
* Set MCA_BASE_VAR_FLAG_DEPRECATED in {flags} to indicate that
* this variable name is deprecated. The user will get a warning
* if they set this variable.
*
* {scope} is for informational purposes to indicate how this variable
* can be set, or if it is considered constant or readonly (which, by
* MPI_T's definitions, are different things). See the comments in
* the description of pmix_mca_base_var_scope_t for information about the
* different scope meanings.
*
* {storage} points to a (char *), (int), or (bool) where the value of
* this variable is stored ({type} indicates the type of this
* pointer). The location pointed to by {storage} must exist until
* the variable is deregistered. Note that the initial value in
* {storage} may be overwritten if the MCA_BASE_VAR_FLAG_DEFAULT_ONLY
* flag is not set (e.g., if the user sets this variable via CLI
* option, environment variable, or file value). If input value of
* {storage} points to a (char *), the pointed-to string will be
* duplicated and maintained internally by the MCA variable system;
* the caller may free the original string after this function returns
* successfully.
*/
PMIX_EXPORT int pmix_mca_base_var_register(const char *project_name, const char *framework_name,
const char *component_name, const char *variable_name,
const char *description, pmix_mca_base_var_type_t type,
void *storage);
/**
* Convenience function for registering a variable associated with a
* component.
*
* While quite similar to pmix_mca_base_var_register(), there is one key
* difference: vars registered this this function will automatically
* be unregistered / made unavailable when that component is closed by
* its framework.
*/
PMIX_EXPORT int pmix_mca_base_component_var_register(
const pmix_mca_base_component_t *component, const char *variable_name, const char *description,
pmix_mca_base_var_type_t type, void *storage);
/**
* Convenience function for registering a variable associated with a framework. This
* function is equivalent to pmix_mca_base_var_register with component_name = "base" and
* with the MCA_BASE_VAR_FLAG_DWG set. See pmix_mca_base_var_register().
*/
PMIX_EXPORT int pmix_mca_base_framework_var_register(
const pmix_mca_base_framework_t *framework, const char *variable_name, const char *help_msg,
pmix_mca_base_var_type_t type, void *storage);
/**
* Register a synonym name for an MCA variable.
*
* @param[in] synonym_for The index of the original variable. This index
* must not refer to a synonym.
* @param[in] project_name The project this synonym belongs to. Should
* not be NULL (except for legacy reasons).
* @param[in] framework_name The framework this synonym belongs to.
* @param[in] component_name The component this synonym belongs to.
* @param[in] synonym_name The synonym name.
* @param[in] flags Flags for this synonym.
*
* @returns index Variable index for new synonym on success.
* @returns PMIX_ERR_BAD_VAR If synonym_for does not reference a valid
* variable.
* @returns PMIX_ERR_OUT_OF_RESOURCE If memory could not be allocated.
* @returns PMIX_ERROR For all other errors.
*
* Upon success, this function creates a synonym MCA variable
* that will be treated almost exactly like the original. The
* type (int or string) is irrelevant; this function simply
* creates a new name that by which the same variable value is
* accessible.
*
* Note that the original variable name has precedence over all
* synonyms. For example, consider the case if variable is
* originally registered under the name "A" and is later
* registered with synonyms "B" and "C". If the user sets values
* for both MCA variable names "A" and "B", the value associated
* with the "A" name will be used and the value associated with
* the "B" will be ignored (and will not even be visible by the
* pmix_mca_base_var_*() API). If the user sets values for both MCA
* variable names "B" and "C" (and does *not* set a value for
* "A"), it is undefined as to which value will be used.
*/
PMIX_EXPORT int pmix_mca_base_var_register_synonym(int synonym_for, const char *project_name,
const char *framework_name,
const char *component_name,
const char *synonym_name,
pmix_mca_base_var_syn_flag_t flags);
/**
* Deregister a MCA variable or synonym
*
* @param vari Index returned from pmix_mca_base_var_register() or
* pmix_mca_base_var_register_synonym().
*
* Deregistering a variable does not free the variable or any memory associated
* with it. All memory will be freed and the variable index released when
* pmix_mca_base_var_finalize() is called.
*
* If an enumerator is associated with this variable it will be dereferenced.
*/
PMIX_EXPORT int pmix_mca_base_var_deregister(int vari);
/**
* Get the current value of an MCA variable.
*
* @param[in] vari Index of variable
* @param[in,out] value Pointer to copy the value to. Can be NULL.
* @param[in,out] value_size Size of memory pointed to by value.
* copied size will be returned in value_size.
* @param[out] source Source of current value. Can be NULL.
* @param[out] source_file Source file for the current value if
* it was set from a file.
*
* @return PMIX_ERROR Upon failure. The contents of value are
* undefined.
* @return PMIX_SUCCESS Upon success. value (if not NULL) will be filled
* with the variable's current value. value_size will contain the size
* copied. source (if not NULL) will contain the source of the variable.
*
* Note: The value can be changed by the registering code without using
* the pmix_mca_base_var_* interface so the source may be incorrect.
*/
PMIX_EXPORT int pmix_mca_base_var_get_value(int vari, void *value,
pmix_mca_base_var_source_t *source,
const char **source_file);
/**
* Find the index for an MCA variable based on its names.
*
* @param project_name Name of the project
* @param type_name Name of the type containing the variable.
* @param component_name Name of the component containing the variable.
* @param param_name Name of the variable.
*
* @retval PMIX_ERROR If the variable was not found.
* @retval vari If the variable was found.
*
* It is not always convenient to widely propagate a variable's index
* value, or it may be necessary to look up the variable from a
* different component. This function can be used to look up the index
* of any registered variable. The returned index can be used with
* pmix_mca_base_var_get() and pmix_mca_base_var_get_value().
*/
PMIX_EXPORT int pmix_mca_base_var_find(const char *project_name, const char *type_name,
const char *component_name, const char *param_name);
/**
* Find the index for a variable based on its full name
*
* @param full_name [in] Full name of the variable
* @param vari [out] Index of the variable
*
* See pmix_mca_base_var_find().
*/
PMIX_EXPORT int pmix_mca_base_var_find_by_name(const char *full_name, int *vari);
/**
* Check that two MCA variables were not both set to non-default
* values.
*
* @param type_a [in] Framework name of variable A (string).
* @param component_a [in] Component name of variable A (string).
* @param param_a [in] Variable name of variable A (string.
* @param type_b [in] Framework name of variable A (string).
* @param component_b [in] Component name of variable A (string).
* @param param_b [in] Variable name of variable A (string.
*
* This function is useful for checking that the user did not set both
* of 2 mutually-exclusive MCA variables.
*
* This function will print an pmix_show_help() message and return
* PMIX_ERR_BAD_VAR if it finds that the two variables both have
* value sources that are not MCA_BASE_VAR_SOURCE_DEFAULT. This
* means that both variables have been set by the user (i.e., they're
* not default values).
*
* Note that pmix_show_help() allows itself to be hooked, so if this
* happens after the aggregated pmix_show_help() system is
* initialized, the messages will be aggregated (w00t).
*
* @returns PMIX_ERR_BAD_VAR if the two variables have sources that
* are not MCA_BASE_VAR_SOURCE_DEFAULT.
* @returns PMIX_SUCCESS otherwise.
*/
PMIX_EXPORT int pmix_mca_base_var_check_exclusive(const char *project, const char *type_a,
const char *component_a, const char *param_a,
const char *type_b, const char *component_b,
const char *param_b);
/**
* Obtain basic info on a single variable (name, help message, etc)
*
* @param[in] vari Valid variable index.
* @param[out] var Storage for the variable pointer.
*
* @retval PMIX_SUCCESS Upon success.
* @retval pmix error code Upon failure.
*
* The returned pointer belongs to the MCA variable system. Do not
* modify/free/retain the pointer.
*/
PMIX_EXPORT int pmix_mca_base_var_get(int vari, const pmix_mca_base_var_t **var);
/**
* Obtain the number of variables that have been registered.
*
* @retval count on success
* @return pmix error code on error
*
* Note: This function does not return the number of valid MCA variables as
* pmix_mca_base_var_deregister() has no impact on the variable count. The count
* returned is equal to the number of calls to pmix_mca_base_var_register with
* unique names. ie. two calls with the same name will not affect the count.
*/
PMIX_EXPORT int pmix_mca_base_var_get_count(void);
/**
* Obtain a list of environment variables describing the all
* valid (non-default) MCA variables and their sources.
*
* @param[out] env A pointer to an argv-style array of key=value
* strings, suitable for use in an environment
* @param[out] num_env A pointer to an int, containing the length
* of the env array (not including the final NULL entry).
*
* @retval PMIX_SUCCESS Upon success.
* @retval PMIX_ERROR Upon failure.
*
* This function is similar to pmix_mca_base_var_dump() except that
* its output is in terms of an argv-style array of key=value
* strings, suitable for using in an environment.
*/
PMIX_EXPORT int pmix_mca_base_var_build_env(char ***env, int *num_env);
/**
* Shut down the MCA variable system (normally only invoked by the
* MCA framework itself).
*
* @returns PMIX_SUCCESS This function never fails.
*
* This function shuts down the MCA variable repository and frees all
* associated memory. No other pmix_mca_base_var*() functions can be
* invoked after this function.
*
* This function is normally only invoked by the MCA framework itself
* when the process is shutting down (e.g., during MPI_FINALIZE). It
* is only documented here for completeness.
*/
PMIX_EXPORT int pmix_mca_base_var_finalize(void);
typedef enum {
/* Dump human-readable strings */
PMIX_MCA_BASE_VAR_DUMP_READABLE = 0,
/* Dump easily parsable strings */
PMIX_MCA_BASE_VAR_DUMP_PARSABLE = 1,
/* Dump simple name=value string */
PMIX_MCA_BASE_VAR_DUMP_SIMPLE = 2
} pmix_mca_base_var_dump_type_t;
/**
* Dump strings describing the MCA variable at an index.
*
* @param[in] vari Variable index
* @param[out] out Array of strings describing this variable
* @param[in] output_type Type of output desired
*
* This function returns an array of strings describing the variable. All strings
* and the array must be freed by the caller.
*/
PMIX_EXPORT int pmix_mca_base_var_dump(int vari, char ***out,
pmix_mca_base_var_dump_type_t output_type);
#define MCA_COMPILETIME_VER "print_compiletime_version"
#define MCA_RUNTIME_VER "print_runtime_version"
PMIX_EXPORT int pmix_mca_base_var_cache_files(bool rel_path_search);
END_C_DECLS
#endif /* PMIX_MCA_BASE_VAR_H */

View File

@@ -0,0 +1,247 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#if !defined(PMIX_MCA_BASE_VAR_ENUM_H)
# define PMIX_MCA_BASE_VAR_ENUM_H
# include "src/include/pmix_config.h"
# include "pmix_common.h"
# include "src/class/pmix_object.h"
typedef struct pmix_mca_base_var_enum_t pmix_mca_base_var_enum_t;
/**
* Get the number of values in the enumerator
*
* @param[in] self the enumerator
* @param[out] count the number of values in the enumerator
*/
typedef int (*pmix_mca_base_var_enum_get_count_fn_t)(pmix_mca_base_var_enum_t *self, int *count);
/**
* Get the value and its string representation for an index 0..get_count()
*
* @param[in] self the enumerator
* @param[in] index the index to get the value of
* @param[out] value integer value
* @param[out] string_value string value
*/
typedef int (*pmix_mca_base_var_enum_get_value_fn_t)(pmix_mca_base_var_enum_t *self, int index,
int *value, const char **string_value);
/**
* Look up the integer value of a string
*
* @param[in] self the enumerator
* @param[in] string_value string to lookup
* @param[out] value integer value for the string
*
* @retval PMIX_SUCCESS if found
* @retval PMIX_ERR_VALUE_OUT_OF_BOUNDS if not
*/
typedef int (*pmix_mca_base_var_enum_vfs_fn_t)(pmix_mca_base_var_enum_t *self,
const char *string_value, int *value);
/**
* Dump a textual representation of all the values in an enumerator
*
* @param[in] self the enumerator
* @param[out] out the string representation
*
* @retval PMIX_SUCCESS on success
* @retval pmix error on error
*/
typedef int (*pmix_mca_base_var_enum_dump_fn_t)(pmix_mca_base_var_enum_t *self, char **out);
/**
* Get the string representation for an enumerator value
*
* @param[in] self the enumerator
* @param[in] value integer value
* @param[out] string_value string value for value
*
* @retval PMIX_SUCCESS on success
* @retval PMIX_ERR_VALUE_OUT_OF_BOUNDS if not found
*
* @long This function returns the string value for a given integer value in the
* {string_value} parameter. The {string_value} parameter may be NULL in which case
* no string is returned. If a string is returned in {string_value} the caller
* must free the string with free().
*/
typedef int (*pmix_mca_base_var_enum_sfv_fn_t)(pmix_mca_base_var_enum_t *self, const int value,
char **string_value);
/**
* The default enumerator class takes in a list of integer-string pairs. If a
* string is read from an environment variable or a file value the matching
* integer value is used for the MCA variable.
*/
struct pmix_mca_base_var_enum_value_t {
int value;
const char *string;
};
typedef struct pmix_mca_base_var_enum_value_t pmix_mca_base_var_enum_value_t;
/**
* enumerator base class
*/
struct pmix_mca_base_var_enum_t {
pmix_object_t super;
/** Is the enumerator statically allocated */
bool enum_is_static;
/** Name of this enumerator. This value is duplicated from the argument provided to
pmix_mca_base_var_enum_create() */
char *enum_name;
/** Get the number of values this enumerator represents. Subclasses should override
the default function. */
pmix_mca_base_var_enum_get_count_fn_t get_count;
/** Get the value and string representation for a particular index. Subclasses should
override the default function */
pmix_mca_base_var_enum_get_value_fn_t get_value;
/** Given a string return corresponding integer value. If the string does not match a
valid value return PMIX_ERR_VALUE_OUT_OF_BOUNDS */
pmix_mca_base_var_enum_vfs_fn_t value_from_string;
/** Given an integer return the corresponding string value. If the integer does not
match a valid value return PMIX_ERR_VALUE_OUT_OF_BOUNDS */
pmix_mca_base_var_enum_sfv_fn_t string_from_value;
/** Dump a textual representation of the enumerator. The caller is responsible for
freeing the string */
pmix_mca_base_var_enum_dump_fn_t dump;
int enum_value_count;
/** Copy of the enumerators values (used by the default functions). This array and
and the strings it contains are freed by the destructor if not NULL. */
pmix_mca_base_var_enum_value_t *enum_values;
};
/**
* The default flag enumerator class takes in a list of integer-string pairs. If a
* string is read from an environment variable or a file value the matching
* flag value is used for the MCA variable. The conflicting_flag is used to
* indicate any flags that should conflict.
*/
struct pmix_mca_base_var_enum_value_flag_t {
/** flag value (must be power-of-two) */
int flag;
/** corresponding string name */
const char *string;
/** conflicting flag(s) if any */
int conflicting_flag;
};
typedef struct pmix_mca_base_var_enum_value_flag_t pmix_mca_base_var_enum_value_flag_t;
/**
* flag enumerator base class
*/
struct pmix_mca_base_var_enum_flag_t {
/** use the existing enumerator interface */
pmix_mca_base_var_enum_t super;
/** flag value(s) */
pmix_mca_base_var_enum_value_flag_t *enum_flags;
};
typedef struct pmix_mca_base_var_enum_flag_t pmix_mca_base_var_enum_flag_t;
/**
* Object declaration for pmix_mca_base_var_enum_t
*/
PMIX_CLASS_DECLARATION(pmix_mca_base_var_enum_t);
/**
* Create a new default enumerator
*
* @param[in] name Name for this enumerator
* @param[in] values List of values terminated with a NULL .string
* member.
* @param[out] enumerator Newly created enumerator.
*
* @retval PMIX_SUCCESS On success
* @retval pmix error code On error
*
* This function creates a value enumerator for integer variables. The
* OUT enumerator value will be a newly OBJ_NEW'ed object that should
* be released by the caller via OBJ_RELEASE.
*
* Note that the output enumerator can be OBJ_RELEASE'd after it has
* been used in a cvar or pvar registration, because the variable
* registration functions will OBJ_RETAIN the enumberator.
*
* Note that all the strings in the values[] array are strdup'ed into
* internal storage, meaning that the caller can free all of the
* strings passed in values[] after pmix_mca_base_var_enum_create()
* returns.
*/
int pmix_mca_base_var_enum_create(const char *name, const pmix_mca_base_var_enum_value_t values[],
pmix_mca_base_var_enum_t **enumerator);
/**
* Create a new default flag enumerator
*
* @param[in] name Name for this enumerator
* @param[in] flags List of flags terminated with a NULL .string
* member.
* @param[out] enumerator Newly created enumerator.
*
* @retval PMIX_SUCCESS On success
* @retval pmix error code On error
*
* This function creates a flag enumerator for integer variables. The
* OUT enumerator value will be a newly OBJ_NEW'ed object that should
* be released by the caller via OBJ_RELEASE.
*
* Note that the output enumerator can be OBJ_RELEASE'd after it has
* been used in a cvar or pvar registration, because the variable
* registration functions will OBJ_RETAIN the enumberator.
*
* Note that all the strings in the values[] array are strdup'ed into
* internal storage, meaning that the caller can free all of the
* strings passed in values[] after pmix_mca_base_var_enum_create()
* returns.
*/
int pmix_mca_base_var_enum_create_flag(const char *name,
const pmix_mca_base_var_enum_value_flag_t flags[],
pmix_mca_base_var_enum_flag_t **enumerator);
/* standard enumerators. it is invalid to call OBJ_RELEASE on any of these enumerators */
/**
* Boolean enumerator
*
* This enumerator maps:
* positive integer, true, yes, enabled, t -> 1
* 0, false, no, disabled, f -> 0
*/
extern pmix_mca_base_var_enum_t pmix_mca_base_var_enum_bool;
/**
* Verbosity level enumerator
*/
extern pmix_mca_base_var_enum_t pmix_mca_base_var_enum_verbose;
#endif /* !defined(MCA_BASE_VAR_ENUM_H) */

View File

@@ -0,0 +1,160 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_MCA_BASE_VAR_GROUP_H
#define PMIX_MCA_BASE_VAR_GROUP_H
#include "src/mca/mca.h"
struct pmix_mca_base_var_group_t {
pmix_list_item_t super;
/** Index of group */
int group_index;
/** Group is valid (registered) */
bool group_isvalid;
/** Group name */
char *group_full_name;
char *group_project;
char *group_framework;
char *group_component;
/** Group help message (description) */
char *group_description;
/** Integer value array of subgroup indices */
pmix_value_array_t group_subgroups;
/** Integer array of group variables */
pmix_value_array_t group_vars;
};
typedef struct pmix_mca_base_var_group_t pmix_mca_base_var_group_t;
/**
* Object declaration for pmix_mca_base_var_group_t
*/
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_mca_base_var_group_t);
/**
* Register an MCA variable group
*
* @param[in] project_name Project name for this group.
* @param[in] framework_name Framework name for this group.
* @param[in] component_name Component name for this group.
* @param[in] description Description of this group.
*
* @retval index Unique group index
* @return pmix error code on Error
*
* Create an MCA variable group. If the group already exists
* this call is equivalent to pmix_mca_base_ver_find_group().
*/
PMIX_EXPORT int pmix_mca_base_var_group_register(const char *project_name,
const char *framework_name,
const char *component_name,
const char *description);
/**
* Register an MCA variable group for a component
*
* @param[in] component [in] Pointer to the component for which the
* group is being registered.
* @param[in] description Description of this group.
*
* @retval index Unique group index
* @return pmix error code on Error
*/
PMIX_EXPORT int
pmix_mca_base_var_group_component_register(const pmix_mca_base_component_t *component,
const char *description);
/**
* Deregister an MCA param group
*
* @param group_index [in] Group index from pmix_mca_base_var_group_register (),
* pmix_mca_base_var_group_find().
*
* This call deregisters all associated variables and subgroups.
*/
PMIX_EXPORT int pmix_mca_base_var_group_deregister(int group_index);
/**
* Find an MCA group
*
* @param[in] project_name Project name
* @param[in] framework_name Framework name
* @param[in] component_name Component name
*
* @returns PMIX_SUCCESS if found
* @returns PMIX_ERR_NOT_FOUND if not found
*/
PMIX_EXPORT int pmix_mca_base_var_group_find(const char *project_name, const char *framework_name,
const char *component_name);
/**
* Find an MCA group by its full name
*
* @param[in] full_name Full name of MCA variable group. Ex: shmem_mmap
* @param[out] index Index of group if found
*
* @returns PMIX_SUCCESS if found
* @returns PMIX_ERR_NOT_FOUND if not found
*/
PMIX_EXPORT int pmix_mca_base_var_group_find_by_name(const char *full_name, int *index);
/**
* Get the group at a specified index
*
* @param[in] group_index Group index
* @param[out] group Storage for the group object pointer.
*
* @retval PMIX_ERR_NOT_FOUND If the group specified by group_index does not exist.
* @retval PMIX_SUCCESS If the group is found
*
* The returned pointer belongs to the MCA variable system. Do not modify/release/retain
* the pointer.
*/
PMIX_EXPORT int pmix_mca_base_var_group_get(const int group_index,
const pmix_mca_base_var_group_t **group);
/**
* Get the number of registered MCA groups
*
* @retval count Number of registered MCA groups
*/
PMIX_EXPORT int pmix_mca_base_var_group_get_count(void);
/**
* Get a relative timestamp for the MCA group system
*
* @retval stamp
*
* This value will change if groups or variables are either added or removed.
*/
PMIX_EXPORT int pmix_mca_base_var_group_get_stamp(void);
#endif /* PMIX_MCA_BASE_VAR_GROUP_H */

View File

@@ -0,0 +1,150 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* This is the private declarations for the MCA variable system.
* This file is internal to the MCA variable system and should not
* need to be used by any other elements in PMIX except the
* special case of the ompi_info command.
*
* All the rest of the doxygen documentation in this file is marked as
* "internal" and won't show up unless you specifically tell doxygen
* to generate internal documentation (by default, it is skipped).
*/
#ifndef PMIX_MCA_BASE_VAR_INTERNAL_H
#define PMIX_MCA_BASE_VAR_INTERNAL_H
#include "src/include/pmix_config.h"
#include "src/class/pmix_hash_table.h"
#include "src/class/pmix_list.h"
#include "src/class/pmix_object.h"
#include "src/class/pmix_pointer_array.h"
#include "src/class/pmix_value_array.h"
#include "src/mca/base/pmix_mca_base_var.h"
BEGIN_C_DECLS
/* Internal flags start at bit 16 */
#define PMIX_MCA_BASE_VAR_FLAG_EXTERNAL_MASK 0x0000ffff
#define PMIX_VAR_FLAG_ISSET(var, flag) (!!((var).mbp_flags & (flag)))
#define PMIX_VAR_IS_VALID(var) (!!((var).mbv_flags & PMIX_MCA_BASE_VAR_FLAG_VALID))
#define PMIX_VAR_IS_SYNONYM(var) (!!((var).mbv_flags & PMIX_MCA_BASE_VAR_FLAG_SYNONYM))
#define PMIX_VAR_IS_DEPRECATED(var) (!!((var).mbv_flags & PMIX_MCA_BASE_VAR_FLAG_DEPRECATED))
PMIX_EXPORT extern const char *pmix_var_type_names[];
PMIX_EXPORT extern const size_t pmix_var_type_sizes[];
PMIX_EXPORT extern bool pmix_mca_base_var_initialized;
PMIX_EXPORT extern pmix_list_t pmix_mca_base_var_file_values;
PMIX_EXPORT extern pmix_list_t pmix_mca_base_var_override_values;
/**
* \internal
*
* Structure for holding param names and values read in from files.
*/
struct pmix_mca_base_var_file_value_t {
/** Allow this to be an PMIX OBJ */
pmix_list_item_t super;
/** Parameter name */
char *mbvfv_var;
/** Parameter value */
char *mbvfv_value;
/** File it came from */
char *mbvfv_file;
/** Line it came from */
int mbvfv_lineno;
};
/**
* \internal
*
* Convenience typedef
*/
typedef struct pmix_mca_base_var_file_value_t pmix_mca_base_var_file_value_t;
/**
* Object declaration for pmix_mca_base_var_file_value_t
*/
PMIX_CLASS_DECLARATION(pmix_mca_base_var_file_value_t);
/**
* \internal
*
* Get a group
*
* @param[in] group_index Group index
* @param[out] group Returned group if it exists
* @param[in] invalidok Return group even if it has been deregistered
*/
PMIX_EXPORT int pmix_mca_base_var_group_get_internal(const int group_index,
pmix_mca_base_var_group_t **group,
bool invalidok);
/**
* \internal
*
* Parse a parameter file.
*/
PMIX_EXPORT int pmix_mca_base_parse_paramfile(const char *paramfile, pmix_list_t *list);
/**
* \internal
*
* Add a variable to a group
*/
PMIX_EXPORT int pmix_mca_base_var_group_add_var(const int group_index, const int param_index);
/**
* \internal
*
* Generate a full name with _ between all of the non-NULL arguments
*/
PMIX_EXPORT int pmix_mca_base_var_generate_full_name4(const char *project, const char *framework,
const char *component, const char *variable,
char **full_name);
/**
* \internal
*
* Call save_value callback for generated internal mca parameter storing env variables
*/
PMIX_EXPORT int pmix_mca_base_internal_env_store(void);
/**
* \internal
*
* Initialize/finalize MCA variable groups
*/
PMIX_EXPORT int pmix_mca_base_var_group_init(void);
PMIX_EXPORT int pmix_mca_base_var_group_finalize(void);
END_C_DECLS
#endif /* PMIX_MCA_BASE_VAR_INTERNAL_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,457 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Data packing subsystem.
*/
#ifndef PMIX_BFROP_H_
#define PMIX_BFROP_H_
#include "src/include/pmix_config.h"
#include "pmix_common.h"
#include "src/include/pmix_types.h"
#include "src/mca/mca.h"
#include "bfrops_types.h"
BEGIN_C_DECLS
/* The overall objective of this framework is to provide seamless
* cross-version support for communications by allowing a process
* to communicate with a peer:
*
* (a) using a different version of the buffer operations. We are
* allowing changes in the structure compositions and/or data
* type definitions between versions. This specifically affects
* our ability to pack/unpack across versions.
*
* (b) using a different buffer type (described vs non-described).
* This resolves conflicts when one side was compiled with a
* debug option, while the other side has been "optimized".
*
* This is a mult-select framework - i.e., multiple components
* are selected and "active" at the same time. The intent is
* to have one component for each data type variation, with the
* expectation that the community will do its best not to revise
* existing data type definitions. Thus, new variations should be
* rare, and only a few components will exist.
*
* The framework itself reflects the fact that any given peer
* will utilize only one variation of the data type definitions.
* Thus, once a peer is identified, it will pass its version string
* to this framework's "assign_module" function, which will then
* pass it to each component until one returns a module capable of
* processing the given version. This module is then "attached" to
* the pmix_peer_t object so it can be used for all subsequent
* communication to/from that peer.
*
* Buffer type is included in the buffer metadata. Unfortunately,
* the metadata is not communicated at each exchange. Thus, the
* peers will indicate during the connection handshake the type
* of buffer they will use for all subsequent communications. The
* peer must then utilize that same buffer type for all messages
* sent to that remote proc, so we provide new macros for creating
* and constructing buffers that ensures the correct buffer type
* is marked.
*
* Accordingly, there are two levels of APIs defined for this
* framework:
*
* (a) component level - these allow for init/finalize of the
* component, and assignment of a module to a given peer
* based on the version that peer is using
*
* (b) module level - implement pack/unpack/copy/recv/etc. of
* the various datatypes. Note that the module only needs
* to provide those functions that differ from the base
* functions - they don't need to duplicate all that code!
*/
/* The following functions are exposed to the user - they
* therefore are implemented in the bfrops/base functions
* as wrappers to the real functions.
*
* NOTE: THESE FUNCTIONS ARE NOT TO BE USED INTERNALLY -
* USE THE MACROS INSTEAD
*/
bool pmix_value_cmp(pmix_value_t *p, pmix_value_t *p1);
/**** MODULE INTERFACE DEFINITION ****/
/* initialize the module - the module is expected
* to register its datatype functions at this time */
typedef pmix_status_t (*pmix_bfrop_init_fn_t)(void);
/* finalize the module */
typedef void (*pmix_bfrop_finalize_fn_t)(void);
/**
* Pack one or more values into a buffer.
*
* The pack function packs one or more values of a specified type into
* the specified buffer. The buffer must have already been
* initialized via an PMIX_NEW or PMIX_CONSTRUCT call - otherwise, the
* pack_value function will return an error. Providing an unsupported
* type flag will likewise be reported as an error.
*
* Note that any data to be packed that is not hard type cast (i.e.,
* not type cast to a specific size) may lose precision when unpacked
* by a non-homogeneous recipient. The BFROP will do its best to deal
* with heterogeneity issues between the packer and unpacker in such
* cases. Sending a number larger than can be handled by the recipient
* will return an error code (generated by the BFROP upon unpacking) -
* the BFROP cannot detect such errors during packing.
*
* @param *buffer A pointer to the buffer into which the value is to
* be packed.
*
* @param *src A void* pointer to the data that is to be packed. This
* is interpreted as a pointer to an array of that data type containing
* length num_values. Note that strings are of data type char*, and so
* they are to be passed as (char **) - i.e., the caller must
* pass the address of the pointer to the string as the void*. This
* allows the BFROP to use a single interface function, but still allow
* the caller to pass multiple strings in a single call.
*
* @param num_values An int32_t indicating the number of values that are
* to be packed, beginning at the location pointed to by src. A string
* value is counted as a single value regardless of length. The values
* must be contiguous in memory. Arrays of pointers (e.g., string
* arrays) should be contiguous, although (obviously) the data pointed
* to need not be contiguous across array entries.
*
* @param type The type of the data to be packed - must be one of the
* PMIX defined data types.
*
* @retval PMIX_SUCCESS The data was packed as requested.
*
* @retval PMIX_ERROR(s) An appropriate PMIX error code indicating the
* problem encountered. This error code should be handled
* appropriately.
*
* @code
* pmix_buffer_t *buffer;
* int32_t src;
*
* status_code = pmix_bfrop.pack(buffer, &src, 1, PMIX_INT32);
* @endcode
*/
typedef pmix_status_t (*pmix_bfrop_pack_fn_t)(pmix_buffer_t *buffer, const void *src,
int32_t num_values, pmix_data_type_t type);
/**
* Unpack values from a buffer.
*
* The unpack function unpacks the next value (or values) of a
* specified type from the specified buffer.
*
* The buffer must have already been initialized via an PMIX_NEW or
* PMIX_CONSTRUCT call (and assumedly filled with some data) -
* otherwise, the unpack_value function will return an
* error. Providing an unsupported type flag will likewise be reported
* as an error, as will specifying a data type that DOES NOT match the
* type of the next item in the buffer. An attempt to read beyond the
* end of the stored data held in the buffer will also return an
* error.
*
* NOTE: it is possible for the buffer to be corrupted and that
* the BFROP will *think* there is a proper variable type at the
* beginning of an unpack region - but that the value is bogus (e.g., just
* a byte field in a string array that so happens to have a value that
* matches the specified data type flag). Therefore, the data type error check
* is NOT completely safe. This is true for ALL unpack functions.
*
* Warning: The caller is responsible for providing adequate memory
* storage for the requested data. As noted below, the user
* must provide a parameter indicating the maximum number of values that
* can be unpacked into the allocated memory. If more values exist in the
* buffer than can fit into the memory storage, then the bfrop will unpack
* what it can fit into that location and return an error code indicating
* that the buffer was only partially unpacked.
*
* Note that any data that was not hard type cast (i.e., not type cast
* to a specific size) when packed may lose precision when unpacked by
* a non-homogeneous recipient. The BFROP will do its best to deal with
* heterogeneity issues between the packer and unpacker in such
* cases. Sending a number larger than can be handled by the recipient
* will return an error code generated by the BFROP upon unpacking - the
* BFROP cannot detect such errors during packing.
*
* @param *buffer A pointer to the buffer from which the value will be
* extracted.
*
* @param *dest A void* pointer to the memory location into which the
* data is to be stored. Note that these values will be stored
* contiguously in memory. For strings, this pointer must be to (char
* **) to provide a means of supporting multiple string
* operations. The BFROP unpack function will allocate memory for each
* string in the array - the caller must only provide adequate memory
* for the array of pointers.
*
* @param type The type of the data to be unpacked - must be one of
* the BFROP defined data types.
*
* @retval *max_num_values The number of values actually unpacked. In
* most cases, this should match the maximum number provided in the
* parameters - but in no case will it exceed the value of this
* parameter. Note that if you unpack fewer values than are actually
* available, the buffer will be in an unpackable state - the bfrop will
* return an error code to warn of this condition.
*
* @note The unpack function will return the actual number of values
* unpacked in this location.
*
* @retval PMIX_SUCCESS The next item in the buffer was successfully
* unpacked.
*
* @retval PMIX_ERROR(s) The unpack function returns an error code
* under one of several conditions: (a) the number of values in the
* item exceeds the max num provided by the caller; (b) the type of
* the next item in the buffer does not match the type specified by
* the caller; or (c) the unpack failed due to either an error in the
* buffer or an attempt to read past the end of the buffer.
*
* @code
* pmix_buffer_t *buffer;
* int32_t dest;
* char **string_array;
* int32_t num_values;
*
* num_values = 1;
* status_code = pmix_bfrop.unpack(buffer, (void*)&dest, &num_values, PMIX_INT32);
*
* num_values = 5;
* string_array = malloc(num_values*sizeof(char *));
* status_code = pmix_bfrop.unpack(buffer, (void*)(string_array), &num_values, PMIX_STRING);
*
* @endcode
*/
typedef pmix_status_t (*pmix_bfrop_unpack_fn_t)(pmix_buffer_t *buffer, void *dest,
int32_t *max_num_values, pmix_data_type_t type);
/**
* Copy a payload from one buffer to another
* This function will append a copy of the payload in one buffer into
* another buffer. If the destination buffer is NOT empty, then the
* type of the two buffers MUST match or else an
* error will be returned. If the destination buffer IS empty, then
* its type will be set to that of the source buffer.
* NOTE: This is NOT a destructive procedure - the
* source buffer's payload will remain intact, as will any pre-existing
* payload in the destination's buffer.
*/
typedef pmix_status_t (*pmix_bfrop_copy_payload_fn_t)(pmix_buffer_t *dest, pmix_buffer_t *src);
/**
* Copy a data value from one location to another.
*
* Since registered data types can be complex structures, the system
* needs some way to know how to copy the data from one location to
* another (e.g., for storage in the registry). This function, which
* can call other copy functions to build up complex data types, defines
* the method for making a copy of the specified data type.
*
* @param **dest The address of a pointer into which the
* address of the resulting data is to be stored.
*
* @param *src A pointer to the memory location from which the
* data is to be copied.
*
* @param type The type of the data to be copied - must be one of
* the BFROP defined data types.
*
* @retval PMIX_SUCCESS The value was successfully copied.
*
* @retval PMIX_ERROR(s) An appropriate error code.
*
*/
typedef pmix_status_t (*pmix_bfrop_copy_fn_t)(void **dest, void *src, pmix_data_type_t type);
/**
* Print a data value.
*
* Since registered data types can be complex structures, the system
* needs some way to know how to print them (i.e., convert them to a string
* representation). Provided for debug purposes.
*
* @retval PMIX_SUCCESS The value was successfully printed.
*
* @retval PMIX_ERROR(s) An appropriate error code.
*/
typedef pmix_status_t (*pmix_bfrop_print_fn_t)(char **output, char *prefix, void *src,
pmix_data_type_t type);
/**
* Transfer a value from one pmix_value_t to another. Ordinarily,
* this would be executed as a base function. However, it is
* possible that future versions may add new data types, and
* thus the xfer function may differ
*
* @retval PMIX_SUCCESS The value was successfully transferred
*
* @retval PMIX_ERROR(s) An appropriate error code
*/
typedef pmix_status_t (*pmix_bfrop_value_xfer_fn_t)(pmix_value_t *dest, const pmix_value_t *src);
/**
* Load data into a pmix_value_t object. Again, this is provided
* as a component function to support different data types
*/
typedef void (*pmix_bfrop_value_load_fn_t)(pmix_value_t *v, const void *data,
pmix_data_type_t type);
/**
* Unload data from a pmix_value_t object
*
* @retval PMIX_SUCCESS The value was successfully unloaded
*
* @retval PMIX_ERROR(s) An appropriate error code
*/
typedef pmix_status_t (*pmix_bfrop_value_unload_fn_t)(pmix_value_t *kv, void **data, size_t *sz);
/**
* Compare two pmix_value_t structs
*/
typedef pmix_value_cmp_t (*pmix_bfrop_value_cmp_fn_t)(pmix_value_t *p1, pmix_value_t *p2);
/* return the string name of a provided data type */
typedef const char *(*pmix_bfrop_data_type_string_fn_t)(pmix_data_type_t type);
/**
* Base structure for a BFROP module
*/
typedef struct {
char *version;
pmix_bfrop_init_fn_t init;
pmix_bfrop_finalize_fn_t finalize;
pmix_bfrop_pack_fn_t pack;
pmix_bfrop_unpack_fn_t unpack;
pmix_bfrop_copy_fn_t copy;
pmix_bfrop_print_fn_t print;
pmix_bfrop_copy_payload_fn_t copy_payload;
pmix_bfrop_value_xfer_fn_t value_xfer;
pmix_bfrop_value_load_fn_t value_load;
pmix_bfrop_value_unload_fn_t value_unload;
pmix_bfrop_value_cmp_fn_t value_cmp;
pmix_bfrop_data_type_string_fn_t data_type_string;
} pmix_bfrops_module_t;
/* get a list of available versions - caller must free results
* when done */
PMIX_EXPORT char *pmix_bfrops_base_get_available_modules(void);
/* Select a bfrops module for a given version */
PMIX_EXPORT pmix_bfrops_module_t *pmix_bfrops_base_assign_module(const char *version);
/* provide a backdoor to access the framework debug output */
PMIX_EXPORT extern int pmix_bfrops_base_output;
/* MACROS FOR EXECUTING BFROPS FUNCTIONS */
#define PMIX_BFROPS_ASSIGN_TYPE(p, b) (b)->type = (p)->nptr->compat.type
#define PMIX_BFROPS_PACK(r, p, b, s, n, t) \
do { \
pmix_output_verbose(2, pmix_bfrops_base_output, "[%s:%d] PACK version %s type %s", \
__FILE__, __LINE__, (p)->nptr->compat.bfrops->version, \
PMIx_Data_type_string(t)); \
if (PMIX_BFROP_BUFFER_UNDEF == (b)->type) { \
(b)->type = (p)->nptr->compat.type; \
(r) = (p)->nptr->compat.bfrops->pack(b, s, n, t); \
} else if ((b)->type == (p)->nptr->compat.type) { \
(r) = (p)->nptr->compat.bfrops->pack(b, s, n, t); \
} else { \
(r) = PMIX_ERR_PACK_MISMATCH; \
} \
} while (0)
#define PMIX_BFROPS_UNPACK(r, p, b, d, m, t) \
do { \
pmix_output_verbose(2, pmix_bfrops_base_output, "[%s:%d] UNPACK version %s type %s", \
__FILE__, __LINE__, (p)->nptr->compat.bfrops->version, \
PMIx_Data_type_string(t)); \
if ((b)->type == (p)->nptr->compat.type) { \
(r) = (p)->nptr->compat.bfrops->unpack(b, d, m, t); \
} else { \
(r) = PMIX_ERR_UNPACK_FAILURE; \
} \
} while (0)
#define PMIX_BFROPS_COPY(r, p, d, s, t) (r) = (p)->nptr->compat.bfrops->copy(d, s, t)
#define PMIX_BFROPS_PRINT(r, p, o, pr, s, t) (r) = (p)->nptr->compat.bfrops->print(o, pr, s, t)
#define PMIX_BFROPS_COPY_PAYLOAD(r, p, d, s) \
do { \
if (PMIX_BFROP_BUFFER_UNDEF == (d)->type) { \
(d)->type = (p)->nptr->compat.type; \
(r) = (p)->nptr->compat.bfrops->copy_payload(d, s); \
} else if ((d)->type == (p)->nptr->compat.type) { \
(r) = (p)->nptr->compat.bfrops->copy_payload(d, s); \
} else { \
(r) = PMIX_ERR_PACK_MISMATCH; \
} \
} while (0)
#define PMIX_BFROPS_VALUE_XFER(r, p, d, s) (r) = (p)->nptr->compat.bfrops->value_xfer(d, s)
#define PMIX_BFROPS_VALUE_LOAD(p, v, d, t) (p)->nptr->compat.bfrops->value_load(v, d, t)
#define PMIX_BFROPS_VALUE_UNLOAD(r, p, k, d, s) \
(r) = (p)->nptr->compat.bfrops->value_unload(k, , d, s)
#define PMIX_BFROPS_VALUE_CMP(r, p, q, s) (r) = (p)->nptr->compat.bfrops->value_cmp(q, s)
#define PMIX_BFROPS_REGISTER(r, p, n, t, pk, u, c, pr) \
(r) = (p)->nptr->compat.bfrops->register_type(n, t, pk, u, c, pr)
#define PMIX_BFROPS_PRINT_TYPE(c, p, t) (c) = (p)->nptr->compat.bfrops->data_type_string(t)
/**** COMPONENT STRUCTURE DEFINITION ****/
/* define a component-level API for getting a module */
typedef pmix_bfrops_module_t *(*pmix_bfrop_base_component_assign_module_fn_t)(void);
/*
* the standard component data structure
*/
struct pmix_bfrops_base_component_t {
pmix_mca_base_component_t base;
int priority;
pmix_pointer_array_t types;
pmix_bfrop_base_component_assign_module_fn_t assign_module;
};
typedef struct pmix_bfrops_base_component_t pmix_bfrops_base_component_t;
/*
* Macro for use in components that are of type bfrops
*/
#define PMIX_BFROPS_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("bfrops", 1, 0, 0)
END_C_DECLS
#endif /* PMIX_BFROP_H */

View File

@@ -0,0 +1,191 @@
/* -*- C -*-
*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* Copyright (c) 2023 Triad National Security, LLC. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Buffer management types.
*/
#ifndef PMIX_MCA_BFROP_TYPES_H_
#define PMIX_MCA_BFROP_TYPES_H_
#include "src/include/pmix_config.h"
#include "pmix_common.h"
#include "src/class/pmix_list.h"
#include "src/class/pmix_object.h"
#include "src/class/pmix_pointer_array.h"
BEGIN_C_DECLS
/* set the bfrops module */
#define PMIX_BFROPS_SET_MODULE(r, mp, p, v) \
do { \
(mp)->nptr->compat.bfrops = pmix_bfrops_base_assign_module((v)); \
if (NULL == (mp)->nptr->compat.bfrops) { \
(r) = PMIX_ERR_INIT; \
} else { \
(p)->nptr->compat.bfrops = (mp)->nptr->compat.bfrops; \
(mp)->protocol = PMIX_PROTOCOL_V2; \
(r) = PMIX_SUCCESS; \
} \
} while (0)
/**
* buffer type
*/
typedef uint8_t pmix_bfrop_buffer_type_t;
#define PMIX_BFROP_BUFFER_UNDEF 0x00
#define PMIX_BFROP_BUFFER_NON_DESC 0x01
#define PMIX_BFROP_BUFFER_FULLY_DESC 0x02
#define PMIX_BFROP_BUFFER_TYPE_HTON(h)
#define PMIX_BFROP_BUFFER_TYPE_NTOH(h)
/* internally used object for transferring data
* to/from the server and for storing in the
* hash tables */
typedef struct {
pmix_list_item_t super;
char *key;
pmix_value_t *value;
} pmix_kval_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_kval_t);
static inline pmix_kval_t *
pmix_bfrop_tma_kval_new(
const char *key,
pmix_tma_t *tma
) {
pmix_kval_t *k = PMIX_NEW(pmix_kval_t, tma);
if (PMIX_LIKELY(NULL != k)) {
k->key = pmix_tma_strdup(tma, key);
k->value = (pmix_value_t *)pmix_tma_malloc(tma, sizeof(pmix_value_t));
if (PMIX_UNLIKELY(NULL == k->value)) {
PMIX_RELEASE(k);
k = NULL;
}
}
return k;
}
/* helpful macro extension of the usual PMIX_NEW */
#define PMIX_KVAL_NEW(k, s) \
do { \
(k) = pmix_bfrop_tma_kval_new((s), NULL); \
} while (0)
/**
* Structure for holding a buffer */
typedef struct {
/** First member must be the object's parent */
pmix_object_t parent;
/** type of buffer */
pmix_bfrop_buffer_type_t type;
/** Start of my memory */
char *base_ptr;
/** Where the next data will be packed to (within the allocated
memory starting at base_ptr) */
char *pack_ptr;
/** Where the next data will be unpacked from (within the
allocated memory starting as base_ptr) */
char *unpack_ptr;
/** Number of bytes allocated (starting at base_ptr) */
size_t bytes_allocated;
/** Number of bytes used by the buffer (i.e., amount of data --
including overhead -- packed in the buffer) */
size_t bytes_used;
} pmix_buffer_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_buffer_t);
/* Convenience macro for loading a data blob into a pmix_buffer_t
*
* p - the pmix_peer_t of the process that provided the blob. This
* is needed so we can set the buffer type for later unpacking
*
* b - pointer to pmix_buffer_t
*
* d - pointer to the data blob
*
* s - number of bytes in the blob
*
* NOTE: the macro does NOT copy the data, but simply assigns
* its address to the buffer. Accordingly, the macro will
* set the provided data blob pointer to NULL and the size
* to zero.
*/
#define PMIX_LOAD_BUFFER(p, b, d, s) \
do { \
(b)->type = (p)->nptr->compat.type; \
(b)->base_ptr = (char *) (d); \
(b)->bytes_used = (s); \
(b)->bytes_allocated = (s); \
(b)->pack_ptr = ((char *) (b)->base_ptr) + (s); \
(b)->unpack_ptr = (b)->base_ptr; \
(d) = NULL; \
(s) = 0; \
} while (0)
#define PMIX_LOAD_BUFFER_NON_DESTRUCT(p, b, d, s) \
do { \
(b)->type = (p)->nptr->compat.type; \
(b)->base_ptr = (char *) (d); \
(b)->bytes_used = (s); \
(b)->bytes_allocated = (s); \
(b)->pack_ptr = ((char *) (b)->base_ptr) + (s); \
(b)->unpack_ptr = (b)->base_ptr; \
} while (0)
/* Convenience macro for extracting a pmix_buffer_t's payload
* as a data blob
*
* b - pointer to the pmix_buffer_t
*
* d - char* pointer to the data blob
*
* s - number of bytes in the blob
*
* NOTE: the macro does NOT copy the data, but simply assigns
* the address of the buffer's payload to the provided pointer.
* Accordingly, the macro will set all pmix_buffer_t internal
* tracking pointers to NULL and all counters to zero */
#define PMIX_UNLOAD_BUFFER(b, d, s) \
do { \
(d) = (char *) (b)->unpack_ptr; \
(s) = (b)->bytes_used; \
(b)->base_ptr = NULL; \
(b)->bytes_used = 0; \
(b)->bytes_allocated = 0; \
(b)->pack_ptr = NULL; \
(b)->unpack_ptr = NULL; \
} while (0)
/* Convenience macro to check for empty buffer without
* exposing the internals */
#define PMIX_BUFFER_IS_EMPTY(b) (0 == (b)->bytes_used || (b)->pack_ptr == (b)->unpack_ptr)
END_C_DECLS
#endif /* PMIX_BFROP_TYPES_H */

View File

@@ -0,0 +1,137 @@
/* -*- C -*-
*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 IBM Corporation. All rights reserved.
* Copyright (c) 2019 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_GDS_BASE_H_
#define PMIX_GDS_BASE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for struct timeval */
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "src/class/pmix_list.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/mca/gds/gds.h"
BEGIN_C_DECLS
/*
* MCA Framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_gds_base_framework;
/**
* GDS select function
*
* Cycle across available components and construct the list
* of active modules
*/
PMIX_EXPORT pmix_status_t pmix_gds_base_select(pmix_info_t info[], size_t ninfo);
/**
* Track an active component / module
*/
struct pmix_gds_base_active_module_t {
pmix_list_item_t super;
int pri;
pmix_gds_base_module_t *module;
pmix_gds_base_component_t *component;
};
typedef struct pmix_gds_base_active_module_t pmix_gds_base_active_module_t;
PMIX_CLASS_DECLARATION(pmix_gds_base_active_module_t);
/* framework globals */
struct pmix_gds_globals_t {
pmix_list_t actives;
bool initialized;
bool selected;
char *all_mods;
};
typedef enum {
PMIX_MODEX_KEY_INVALID = -1,
PMIX_MODEX_KEY_NATIVE_FMT,
PMIX_MODEX_KEY_KEYMAP_FMT,
PMIX_MODEX_KEY_MAX
} pmix_gds_modex_key_fmt_t;
/* define a modex blob info */
typedef uint8_t pmix_gds_modex_blob_info_t;
#define PMIX_GDS_COLLECT_BIT 0x0001
#define PMIX_GDS_KEYMAP_BIT 0x0002
#define PMIX_GDS_KEYMAP_IS_SET(byte) (PMIX_GDS_KEYMAP_BIT & (byte))
#define PMIX_GDS_COLLECT_IS_SET(byte) (PMIX_GDS_COLLECT_BIT & (byte))
typedef struct pmix_gds_globals_t pmix_gds_globals_t;
typedef void *pmix_gds_base_ctx_t;
typedef pmix_status_t (*pmix_gds_base_store_modex_cb_fn_t)(pmix_gds_base_ctx_t ctx,
pmix_proc_t *proc,
pmix_gds_modex_key_fmt_t key_fmt,
char **kmap, pmix_buffer_t *pbkt);
PMIX_EXPORT extern pmix_gds_globals_t pmix_gds_globals;
/* get a list of available support - caller must free results
* when done. The list is returned as a comma-delimited string
* of available components in priority order */
PMIX_EXPORT char *pmix_gds_base_get_available_modules(void);
/* Select a gds module based on the provided directives */
PMIX_EXPORT pmix_gds_base_module_t *pmix_gds_base_assign_module(pmix_info_t *info, size_t ninfo);
/**
* Add any envars to a peer's environment that the module needs
* to communicate. The API stub will rotate across all active modules, giving
* each a chance to contribute
*
* @return PMIX_SUCCESS on success.
*/
PMIX_EXPORT pmix_status_t pmix_gds_base_setup_fork(const pmix_proc_t *proc, char ***env);
PMIX_EXPORT pmix_status_t pmix_gds_base_store_modex(struct pmix_namespace_t *nspace,
pmix_buffer_t *buff, pmix_gds_base_ctx_t ctx,
pmix_gds_base_store_modex_cb_fn_t cb_fn,
void *cbdata);
PMIX_EXPORT
pmix_status_t pmix_gds_base_modex_pack_kval(pmix_gds_modex_key_fmt_t key_fmt, pmix_buffer_t *buf,
char ***kmap, pmix_kval_t *kv);
PMIX_EXPORT
pmix_status_t pmix_gds_base_modex_unpack_kval(pmix_gds_modex_key_fmt_t key_fmt, pmix_buffer_t *buf,
char **kmap, pmix_kval_t *kv);
END_C_DECLS
#endif

View File

@@ -0,0 +1,491 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2016-2020 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2018 IBM Corporation. All rights reserved.
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
* Copyright (c) 2022 Triad National Security, LLC. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_GDS_H
#define PMIX_GDS_H
#include "src/include/pmix_config.h"
#include "pmix_common.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/bfrops/bfrops_types.h"
#include "src/mca/mca.h"
/* The client dictates the GDS module that will be used to interact
* with the server - this module is stored in pmix_globals.mypeer->compat.gds
* Because that is a long address to keep typing out, convenience macros
* are provided for when that module is to be used in an operation.
*
* However, an application can open any number of GDS modules for
* purposes other than exchanging info with the server. For example,
* an application may wish to utilize a DHT module for its own
* peer-to-peer data sharing. Thus, the public and private interfaces
* are deliberately designed to be generic. The macros should make
* things easier for the typical internal operations
*
* NOTE: ALTHOUGH SOME GDS COMPONENTS MAY UTILIZE THEIR OWN INTERNAL
* PROGRESS THREADS, THE GDS IS NOT GUARANTEED TO BE THREAD-SAFE.
* GDS FUNCTIONS SHOULD THEREFORE ALWAYS BE CALLED IN A THREAD-SAFE
* CONDITION - E.G., FROM WITHIN AN EVENT
*/
BEGIN_C_DECLS
/* forward declaration */
struct pmix_peer_t;
struct pmix_namespace_t;
/* backdoor to base verbosity */
PMIX_EXPORT extern int pmix_gds_base_output;
/**
* Initialize the module. Returns an error if the module cannot
* run, success if it can.
*/
typedef pmix_status_t (*pmix_gds_base_module_init_fn_t)(pmix_info_t info[], size_t ninfo);
/**
* Finalize the module. Tear down any allocated storage, disconnect
* from any system support.
*/
typedef void (*pmix_gds_base_module_fini_fn_t)(void);
/**
* Assign a module per the requested directives. Modules should
* review the provided directives to determine if they can support
* the request. Modules are "scanned" in component priority order
* and given an opportunity to respond. If a module offers itself,
* it will provide a priority (which can be based on the directives
* and therefore different from the component priority). The highest
* returned priority received from a responder will be selected
* and a pointer to its module returned */
typedef pmix_status_t (*pmix_gds_base_assign_module_fn_t)(pmix_info_t *info, size_t ninfo,
int *priority);
#define PMIX_GDS_CHECK_COMPONENT(p, s) (0 == strcmp((p)->nptr->compat.gds->name, (s)))
#define PMIX_GDS_CHECK_PEER_COMPONENT(p1, p2) \
(0 == strcmp((p1)->nptr->compat.gds->name, (p2)->nptr->compat.gds->name))
/* SERVER FN: assemble the keys buffer for server answer */
typedef pmix_status_t (*pmix_gds_base_module_assemb_kvs_req_fn_t)(const pmix_proc_t *proc,
pmix_list_t *kvs,
pmix_buffer_t *buf, void *cbdata);
/* define a macro for server keys answer based on peer */
#define PMIX_GDS_ASSEMB_KVS_REQ(s, p, r, k, b, c) \
do { \
pmix_gds_base_module_t *_g = (p)->nptr->compat.gds; \
(s) = PMIX_SUCCESS; \
if (NULL == _g->assemb_kvs_req) { \
if (0 == strcmp(_g->name, "hash")) { \
(s) = PMIX_ERR_NOT_SUPPORTED; \
} else { \
_g = pmix_globals.mypeer->nptr->compat.gds; \
} \
} \
if (NULL != _g->assemb_kvs_req) { \
pmix_output_verbose(1, pmix_gds_base_output, \
"[%s:%d] GDS ASSEMBLE REQ WITH %s", \
__FILE__, __LINE__, _g->name); \
(s) = _g->assemb_kvs_req(r, k, b, (void *) c); \
} \
} while (0)
/* CLIENT FN: unpack buffer and key processing */
typedef pmix_status_t (*pmix_gds_base_module_accept_kvs_resp_fn_t)(pmix_buffer_t *buf);
/* define a macro for client key processing from a server response based on peer */
#define PMIX_GDS_ACCEPT_KVS_RESP(s, p, b) \
do { \
pmix_gds_base_module_t *_g = (p)->nptr->compat.gds; \
(s) = PMIX_SUCCESS; \
if (NULL == _g->accept_kvs_resp) { \
if (0 == strcmp(_g->name, "hash")) { \
(s) = PMIX_ERR_NOT_SUPPORTED; \
} else { \
_g = pmix_globals.mypeer->nptr->compat.gds; \
} \
} \
if (NULL != _g->accept_kvs_resp) { \
pmix_output_verbose(1, pmix_gds_base_output, \
"[%s:%d] GDS ACCEPT RESP WITH %s", \
__FILE__, __LINE__, _g->name); \
(s) = _g->accept_kvs_resp(b); \
} \
} while (0)
/* SERVER FN: cache job-level info in the server's GDS until client
* procs connect and we discover which GDS module to use for them.
* Note that this is essentially the same function as store_job_info,
* only we don't have packed data on the server side, and don't want
* to incur the overhead of packing it just to unpack it in the function.
*/
typedef pmix_status_t (*pmix_gds_base_module_cache_job_info_fn_t)(struct pmix_namespace_t *ns,
pmix_info_t info[], size_t ninfo);
/* define a convenience macro for caching job info */
#define PMIX_GDS_CACHE_JOB_INFO(s, p, n, i, ni) \
do { \
pmix_gds_base_module_t *_g = (p)->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, "[%s:%d] GDS CACHE JOB INFO WITH %s", \
__FILE__, __LINE__, _g->name); \
(s) = _g->cache_job_info((struct pmix_namespace_t *) (n), (i), (ni)); \
} while (0)
/* register job-level info - this is provided as a special function
* to allow for optimization. Called solely by the server. We cannot
* prepare the job-level info provided at PMIx_Register_nspace, because
* we don't know the GDS component to use for that application until
* a local client contacts us. Thus, the module is required to process
* the job-level info cached in the pmix_namespace_t for this job and
* do whatever is necessary to support the client, packing any required
* return message into the provided buffer.
*
* This function will be called once for each local client of
* a given nspace. PMIx assumes that all peers of a given nspace
* will use the same GDS module. Thus, the module is free to perform
* any relevant optimizations (e.g., packing the data only once and
* then releasing the cached buffer once all local clients have
* been serviced, or storing it once in shared memory and simply
* returning the shared memory rendezvous information for subsequent
* calls).
*
* Info provided in the reply buffer will be given to the "store_job_info"
* API of the GDS module on the client. Since this should match the
* module used by the server, each module has full knowledge and control
* over what is in the reply buffer.
*
* The pmix_peer_t of the requesting client is provided here so that
* the module can access the job-level info cached on the corresponding
* pmix_namespace_t pointed to by the pmix_peer_t
*/
typedef pmix_status_t (*pmix_gds_base_module_register_job_info_fn_t)(struct pmix_peer_t *pr,
pmix_buffer_t *reply);
/* define a convenience macro for registering job info for
* a given peer */
#define PMIX_GDS_REGISTER_JOB_INFO(s, p, b) \
do { \
pmix_gds_base_module_t *_g = (p)->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, "[%s:%d] GDS REG JOB INFO WITH %s", __FILE__, \
__LINE__, _g->name); \
(s) = _g->register_job_info((struct pmix_peer_t *) (p), b); \
} while (0)
/* update job-level info - this is provided as a special function
* to allow for optimization. Called solely by the client. The buffer
* provided to this API is the same one given to the server by the
* corresponding "register_job_info" function
*/
typedef pmix_status_t (*pmix_gds_base_module_store_job_info_fn_t)(const char *nspace,
pmix_buffer_t *buf);
/* define a convenience macro for storing job info based on peer */
#define PMIX_GDS_STORE_JOB_INFO(s, p, n, b) \
do { \
pmix_gds_base_module_t *_g = (p)->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, "[%s:%d] GDS STORE JOB INFO WITH %s", \
__FILE__, __LINE__, _g->name); \
(s) = _g->store_job_info(n, b); \
} while (0)
/**
* store key/value pair - these will either be values committed by the peer
* and transmitted to the server, or values stored locally by the peer.
* The format of the data depends on the GDS module. Note that data stored
* with PMIX_INTERNAL scope should be stored solely within the process and
* is never shared.
*
* @param peer pointer to pmix_peer_t object of the peer that
* provided the data
*
* @param proc the proc that the data describes
*
* @param scope scope of the data
*
* @param kv key/value pair.
*
* @return PMIX_SUCCESS on success.
*/
typedef pmix_status_t (*pmix_gds_base_module_store_fn_t)(const pmix_proc_t *proc,
pmix_scope_t scope, pmix_kval_t *kv);
/* define a convenience macro for storing key-val pairs based on peer */
#define PMIX_GDS_STORE_KV(s, p, pc, sc, k) \
do { \
pmix_gds_base_module_t *_g = (p)->nptr->compat.gds; \
(s) = PMIX_SUCCESS; \
if (NULL == _g->store) { \
if (0 == strcmp(_g->name, "hash")) { \
(s) = PMIX_ERR_NOT_SUPPORTED; \
} else { \
_g = pmix_globals.mypeer->nptr->compat.gds; \
} \
} \
if (NULL != _g->store) { \
pmix_output_verbose(1, pmix_gds_base_output, \
"[%s:%d] GDS STORE KV WITH %s", \
__FILE__, __LINE__, _g->name); \
(s) = _g->store(pc, sc, k); \
} \
} while (0)
/**
* unpack and store a data "blob" from a peer so that the individual
* elements can later be retrieved. This is an optimization path to
* avoid repeatedly storing pmix_kval_t's for multiple local procs
* from the same nspace.
*
* ranks - a list of pmix_rank_info_t for the local ranks from this
* nspace - this is to be used to filter the cbs list
*
* cbdata - pointer to modex callback data
*
* bo - pointer to the byte object containing the data
*
*/
typedef pmix_status_t (*pmix_gds_base_module_store_modex_fn_t)(struct pmix_namespace_t *ns,
pmix_buffer_t *buff, void *cbdata);
/**
* define a convenience macro for storing modex byte objects
*
* r - return status code
*
* n - pointer to the pmix_namespace_t this blob is to be stored for
*
* b - pointer to pmix_buffer_t containing the data
*
* t - pointer to the modex server tracker
*/
#define PMIX_GDS_STORE_MODEX(r, n, b, t) \
do { \
pmix_gds_base_module_t *_g = pmix_globals.mypeer->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, \
"[%s:%d] GDS STORE MODEX WITH %s", __FILE__, \
__LINE__, _g->name); \
(r) = _g->store_modex((struct pmix_namespace_t *)n, b, t); \
} while (0)
typedef pmix_status_t (*pmix_gds_base_module_mark_modex_complete_fn_t)(struct pmix_peer_t *peer,
pmix_list_t *nslist,
pmix_buffer_t *buff);
#define PMIX_GDS_MARK_MODEX_COMPLETE(r, p, l, b) \
do { \
pmix_gds_base_module_t *_g = pmix_globals.mypeer->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, \
"[%s:%d] GDS MARK MODEX COMPLETE WITH %s", \
__FILE__, __LINE__, _g->name); \
(r) = _g->mark_modex_complete(p, l, b); \
} while (0)
typedef pmix_status_t (*pmix_gds_base_module_recv_modex_complete_fn_t)(pmix_buffer_t *buff);
#define PMIX_GDS_RECV_MODEX_COMPLETE(r, p, b) \
do { \
pmix_gds_base_module_t *_g = pmix_globals.mypeer->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, \
"[%s:%d] GDS RECV MODEX COMPLETE WITH %s", \
__FILE__, __LINE__, _g->name); \
(r) = _g->recv_modex_complete(b); \
} while (0)
/**
* fetch value corresponding to provided key from within the defined
* scope. A NULL key returns all values committed by the given peer
* for that scope.
*
* @param proc namespace and rank whose info is being requested
*
* @param key key.
*
* @param scope scope of the data to be considered
*
* @param copy true if the caller _requires_ a copy of the data. This
* is used when the requestor is off-node. If
* set to false, then the GDS component can provide
* either a copy of the data, or shmem contact info
* to the location of the data
*
* @param info array of pmix_info_t the caller provided as
* qualifiers to guide the request
*
* @param ninfo number of elements in the info array
*
* @param kvs pointer to a list that will be populated with the
* returned pmix_kval_t data
*
* @return PMIX_SUCCESS on success.
*
* Note: all available job-level data for a given nspace can be fetched
* by passing a proc with rank=PMIX_RANK_WILDCARD and a NULL key. Similarly,
* passing a NULL key for a non-wildcard rank will return all data "put"
* by that rank. Scope is ignored for job-level data requests.
*
* When a specific rank if provided with a NULL key, then data for only
* that rank is returned. If the scope is PMIX_LOCAL, then the returned
* data shall include only data that was specifically "put" to local scope,
* plus any data that was put to PMIX_GLOBAL scope. Similarly, a scope of
* PMIX_REMOTE will return data that was "put" to remote scope, plus
* any data that was put to PMIX_GLOBAL scope. A scope of PMIX_GLOBAL
* will return LOCAL, REMOTE, and GLOBAL data.
*
* Data stored with PMIX_INTERNAL scope can be retrieved with that scope.
*/
typedef pmix_status_t (*pmix_gds_base_module_fetch_fn_t)(const pmix_proc_t *proc,
pmix_scope_t scope, bool copy,
const char *key, pmix_info_t info[],
size_t ninfo, pmix_list_t *kvs);
/* define a convenience macro for fetch key-val pairs based on peer,
* passing a pmix_cb_t containing all the required info */
#define PMIX_GDS_FETCH_KV(s, p, c) \
do { \
pmix_gds_base_module_t *_g = (p)->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, "[%s:%d] GDS FETCH KV WITH %s", __FILE__, \
__LINE__, _g->name); \
(s) = _g->fetch((c)->proc, (c)->scope, (c)->copy, (c)->key, (c)->info, (c)->ninfo, \
&(c)->kvs); \
} while (0)
/**
* Add any envars to a peer's environment that the module needs
* to communicate. The API stub will rotate across all active modules, giving
* each a chance to contribute
*
* @return PMIX_SUCCESS on success.
*/
typedef pmix_status_t (*pmix_gds_base_module_setup_fork_fn_t)(const pmix_proc_t *proc, char ***env);
/**
* Define a new nspace in the GDS
*
* @param nspace namespace string
*
* @return PMIX_SUCCESS on success.
*/
typedef pmix_status_t (*pmix_gds_base_module_add_nspace_fn_t)(const char *nspace,
uint32_t nlocalprocs,
pmix_info_t info[], size_t ninfo);
/* define a convenience macro for add_nspace based on peer */
#define PMIX_GDS_ADD_NSPACE(s, n, ls, i, ni) \
do { \
pmix_gds_base_active_module_t *_g; \
pmix_status_t _s = PMIX_SUCCESS; \
(s) = PMIX_SUCCESS; \
pmix_output_verbose(1, pmix_gds_base_output, "[%s:%d] GDS ADD NSPACE %s", __FILE__, \
__LINE__, (n)); \
PMIX_LIST_FOREACH (_g, &pmix_gds_globals.actives, pmix_gds_base_active_module_t) { \
if (NULL != _g->module->add_nspace) { \
_s = _g->module->add_nspace(n, ls, i, ni); \
} \
if (PMIX_SUCCESS != _s) { \
(s) = PMIX_ERROR; \
} \
} \
} while (0)
/**
* Delete nspace and its associated data
*
* @param nspace namespace string
*
* @return PMIX_SUCCESS on success.
*/
typedef pmix_status_t (*pmix_gds_base_module_del_nspace_fn_t)(const char *nspace);
/* define a convenience macro for del_nspace based on peer */
#define PMIX_GDS_DEL_NSPACE(s, n) \
do { \
pmix_gds_base_active_module_t *_g; \
pmix_status_t _s = PMIX_SUCCESS; \
(s) = PMIX_SUCCESS; \
pmix_output_verbose(1, pmix_gds_base_output, "[%s:%d] GDS DEL NSPACE %s", __FILE__, \
__LINE__, (n)); \
PMIX_LIST_FOREACH (_g, &pmix_gds_globals.actives, pmix_gds_base_active_module_t) { \
if (NULL != _g->module->del_nspace) { \
_s = _g->module->del_nspace(n); \
} \
if (PMIX_SUCCESS != _s) { \
(s) = PMIX_ERROR; \
} \
} \
} while (0)
/* define a convenience macro for is_tsafe for fetch operation */
#define PMIX_GDS_FETCH_IS_TSAFE(s, p) \
do { \
pmix_gds_base_module_t *_g = (p)->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, \
"[%s:%d] GDS FETCH IS THREAD SAFE WITH %s", \
__FILE__, __LINE__, _g->name); \
if (true == _g->is_tsafe) { \
(s) = PMIX_SUCCESS; \
} else { \
(s) = PMIX_ERR_NOT_SUPPORTED; \
} \
} while(0)
typedef pmix_status_t (*pmix_gds_base_module_fetch_array_fn_t)(struct pmix_peer_t *pr,
pmix_buffer_t *reply);
/* define a convenience macro for fetching array info for
* a given peer */
#define PMIX_GDS_FETCH_INFO_ARRAYS(s, p, b) \
do { \
pmix_gds_base_module_t *_g = pmix_globals.mypeer->nptr->compat.gds; \
pmix_output_verbose(1, pmix_gds_base_output, \
"[%s:%d] GDS FETCH ARRAYS WITH %s", \
__FILE__, __LINE__, _g->name); \
(s) = _g->fetch_arrays((struct pmix_peer_t*)(p), b); \
} while(0)
/* structure for gds modules */
typedef struct {
const char *name;
const bool is_tsafe;
pmix_gds_base_module_init_fn_t init;
pmix_gds_base_module_fini_fn_t finalize;
pmix_gds_base_assign_module_fn_t assign_module;
pmix_gds_base_module_cache_job_info_fn_t cache_job_info;
pmix_gds_base_module_register_job_info_fn_t register_job_info;
pmix_gds_base_module_store_job_info_fn_t store_job_info;
pmix_gds_base_module_store_fn_t store;
pmix_gds_base_module_store_modex_fn_t store_modex;
pmix_gds_base_module_fetch_fn_t fetch;
pmix_gds_base_module_setup_fork_fn_t setup_fork;
pmix_gds_base_module_add_nspace_fn_t add_nspace;
pmix_gds_base_module_del_nspace_fn_t del_nspace;
pmix_gds_base_module_assemb_kvs_req_fn_t assemb_kvs_req;
pmix_gds_base_module_accept_kvs_resp_fn_t accept_kvs_resp;
pmix_gds_base_module_fetch_array_fn_t fetch_arrays;
pmix_gds_base_module_mark_modex_complete_fn_t mark_modex_complete;
pmix_gds_base_module_recv_modex_complete_fn_t recv_modex_complete;
} pmix_gds_base_module_t;
/* NOTE: there is no public GDS interface structure - all access is
* done directly to/from an assigned module */
/* define the component structure */
typedef pmix_mca_base_component_t pmix_gds_base_component_t;
/*
* Macro for use in components that are of type gds
*/
#define PMIX_GDS_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("gds", 1, 0, 0)
END_C_DECLS
#endif

View File

@@ -0,0 +1,314 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Top-level interface for all pmix MCA components.
*/
#ifndef PMIX_MCA_H
#define PMIX_MCA_H
#include "src/include/pmix_config.h"
/**
* Common type for all MCA modules.
*
* An instance of this type is always the first element in MCA
* modules, allowing the module to be associated with a
* particular version of a specific framework, and to publish its own
* name and version.
*/
struct pmix_mca_base_module_2_0_0_t {
int dummy_value;
};
/** Unversioned convenience typedef; use this name in
frameworks/components to stay forward source-compatible */
typedef struct pmix_mca_base_module_2_0_0_t pmix_mca_base_module_t;
/** Versioned convenience typedef */
typedef struct pmix_mca_base_module_2_0_0_t pmix_mca_base_module_2_0_0_t;
/**
* MCA component open function.
*
* @retval PMIX_SUCCESS This component can be used in the process.
*
* @retval PMIX_ERR_NOT_AVAILABLE Silently ignore this component for
* the duration of the process (it may even be unloaded from the
* process).
*
* @retval anything_else The MCA base will print an error message
* ignore this component for the duration of the process (it may even
* be unloaded from the process).
*
* All MCA components can have an "open" function that is invoked once
* per process, when the component is located and loaded.
*
* This function should avoid registering MCA parameters (use the
* component "register" function for that; i.e.,
* mca_base_register_component_params_2_0_0_fn_t for that). Legacy
* components still register MCA params in their component "open"
* function, but their authors should update them to use the component
* "register" function.
*
* This function can also be used to allocate any resources necessary
* for the component (e.g., heap memory).
*
* This function should return PMIX_SUCCESS if it wishes to remain
* loaded in the process. Any other return value will cause the MCA
* base to unload the component. Although most components do not use
* this mechanism to force themselves to be unloaded (because if they
* are immediately unloaded, ompi_info will not display them), the
* mechanism is available should the need arise.
*
* If the component a) has no MCA parameters to register, b) no
* resources to allocate, and c) can always be used in a process
* (albeit perhaps not selected), it may provide NULL for this
* function. In this cause, the MCA will act as if it called the open
* function and it returned PMIX_SUCCESS.
*/
typedef int (*pmix_mca_base_open_component_1_0_0_fn_t)(void);
/**
* MCA component close function.
*
* @retval PMIX_SUCCESS The component successfully shut down.
*
* @retval any_other_value Some error occurred, but is likely to be
* ignored.
*
* This function is invoked on a component after all of its modules
* have been finalized (according to the rules of its framework) and
* the component will never be used in the process again; the
* component may be unloaded from the process memory after the close
* function has been invoked.
*
* This function is typically used to release any resources still in
* use by the component.
*
* If the component has no resources to free, it may provide NULL for
* this function. In this case, the MCA will act as if it called the
* close function and it returned PMIX_SUCCESS.
*/
typedef int (*pmix_mca_base_close_component_1_0_0_fn_t)(void);
/**
* MCA component query function.
*
* @retval PMIX_SUCCESS The component successfully queried.
*
* @retval any_other_value Some error occurred, but is likely to be
* ignored.
*
* @param module The module to be used if this component is selected.
*
* @param priority The priority of this component.
*
* This function is used by the mca_base_select function to find the
* highest priority component to select. Frameworks are free to
* implement their own query function, but must also implement their
* own select function as a result.
*/
typedef int (*pmix_mca_base_query_component_2_0_0_fn_t)(pmix_mca_base_module_2_0_0_t **module,
int *priority);
/**
* MCA component parameter registration function.
*
* @retval PMIX_SUCCESS This component successfully registered its
* parameters and can be used in this process.
* @retval PMIX_ERR_BAD_PARAM Indicates that the register function
* failed because an MCA parameter got an invalid/incorrect value.
*
* @retval anything_else The MCA will ignore this component for the
* duration of the process.
*
* If a component has a non-NULL parameter registration function, it
* will be invoked to register all MCA parameters associated with the
* component. This function is invoked *before* the component "open"
* function is invoked.
*
* The registration function should not allocate any resources that
* need to be freed (aside from registering MCA parameters).
* Specifically, strings that are passed to the MCA parameter
* registration functions are all internally copied; there's no need
* for the caller to keep them after registering a parameter. Hence,
* it is possible that the registration function will be the *only*
* function invoked on a component; component authors should take care
* that no resources are leaked in this case.
*
* This function should return PMIX_SUCCESS if it wishes to remain
* loaded in the process. Any other return value will cause the MCA
* base to unload the component. Although most components do not use
* this mechanism to force themselves to be unloaded (because if they
* are immediately unloaded, ompi_info will not display them), the
* mechanism is available should the need arise.
*
* Note that if the function returns PMIX_ERR_BAD_PARAM, it is
* possible (likely?) that the component didn't register all of its
* parameters. When this happens, ompi_info (and friends) will stop
* execution and print out all existing registered parameters from the
* entire framework (since ompi_info doesn't track individual
* component register failures). This allows a user to know exactly
* what value is incorrect, and from where it was set (e.g., via an
* MCA params file).
*
* If the component a) has no MCA parameters to register, b) no
* resources to allocate, and c) can always be used in a process
* (albeit perhaps not selected), it may provide NULL for this
* function. In this cause, the MCA will act as if it called the
* registration function and it returned PMIX_SUCCESS.
*/
typedef int (*pmix_mca_base_register_component_params_2_0_0_fn_t)(void);
/**
* Maximum length of MCA project string names.
*/
#define PMIX_MCA_BASE_MAX_PROJECT_NAME_LEN 15
/**
* Maximum length of MCA framework string names.
*/
#define PMIX_MCA_BASE_MAX_TYPE_NAME_LEN 31
/**
* Maximum length of MCA component string names.
*/
#define PMIX_MCA_BASE_MAX_COMPONENT_NAME_LEN 63
/**
* Common type for all MCA components.
*
* An instance of this type is always the first element in MCA
* components, allowing the component to be associated with a
* particular version of a specific framework, and to publish its own
* name and version.
*/
struct pmix_mca_base_component_2_1_0_t {
int pmix_mca_major_version;
/**< Major number of the MCA. */
int pmix_mca_minor_version;
/**< Minor number of the MCA. */
int pmix_mca_release_version;
/**< Release number of the MCA. */
char pmix_mca_project_name[PMIX_MCA_BASE_MAX_PROJECT_NAME_LEN + 1];
/**< String name of the project that this component belongs to. */
int pmix_mca_project_major_version;
/**< Major version number of the project that this component
belongs to. */
int pmix_mca_project_minor_version;
/**< Minor version number of the project that this component
belongs to. */
int pmix_mca_project_release_version;
/**< Release version number of the project that this component
belongs to. */
char pmix_mca_type_name[PMIX_MCA_BASE_MAX_TYPE_NAME_LEN + 1];
/**< String name of the framework that this component belongs to. */
int pmix_mca_type_major_version;
/**< Major version number of the framework that this component
belongs to. */
int pmix_mca_type_minor_version;
/**< Minor version number of the framework that this component
belongs to. */
int pmix_mca_type_release_version;
/**< Release version number of the framework that this component
belongs to. */
char pmix_mca_component_name[PMIX_MCA_BASE_MAX_COMPONENT_NAME_LEN + 1];
/**< This comopnent's string name. */
int pmix_mca_component_major_version;
/**< This component's major version number. */
int pmix_mca_component_minor_version;
/**< This component's minor version number. */
int pmix_mca_component_release_version;
/**< This component's release version number. */
pmix_mca_base_open_component_1_0_0_fn_t pmix_mca_open_component;
/**< Method for opening this component. */
pmix_mca_base_close_component_1_0_0_fn_t pmix_mca_close_component;
/**< Method for closing this component. */
pmix_mca_base_query_component_2_0_0_fn_t pmix_mca_query_component;
/**< Method for querying this component. */
pmix_mca_base_register_component_params_2_0_0_fn_t pmix_mca_register_component_params;
/**< Method for registering the component's MCA parameters */
/** Extra space to allow for expansion in the future without
breaking older components. */
char reserved[32];
};
#define PMIX_BASE_COMPONENT_STATIC_INIT \
{ \
.pmix_mca_major_version = 0, \
.pmix_mca_minor_version = 0, \
.pmix_mca_release_version = 0, \
.pmix_mca_project_name = {0}, \
.pmix_mca_type_major_version = 0, \
.pmix_mca_type_minor_version = 0, \
.pmix_mca_type_release_version = 0, \
.pmix_mca_component_name = {0}, \
.pmix_mca_component_major_version = 0, \
.pmix_mca_component_minor_version = 0, \
.pmix_mca_component_release_version = 0, \
.pmix_mca_open_component = NULL, \
.pmix_mca_close_component = NULL, \
.pmix_mca_query_component = NULL, \
.pmix_mca_register_component_params = NULL, \
.reserved = {0} \
}
/** Unversioned convenience typedef; use this name in
frameworks/components to stay forward source-compatible */
typedef struct pmix_mca_base_component_2_1_0_t pmix_mca_base_component_t;
/** Versioned convenience typedef */
typedef struct pmix_mca_base_component_2_1_0_t pmix_mca_base_component_2_1_0_t;
/**
* Macro for framework author convenience.
*
* This macro is used by frameworks defining their component types,
* indicating that they subscribe to the MCA version 2.0.0. See
* component header files (e.g., coll.h) for examples of its usage.
*/
#define PMIX_MCA_BASE_VERSION_MAJOR 2
#define PMIX_MCA_BASE_VERSION_MINOR 1
#define PMIX_MCA_BASE_VERSION_RELEASE 0
#define PMIX_MCA_BASE_MAKE_VERSION(level, MAJOR, MINOR, RELEASE) \
.pmix_mca_##level##_major_version = MAJOR, .pmix_mca_##level##_minor_version = MINOR, \
.pmix_mca_##level##_release_version = RELEASE
#define PMIX_MCA_BASE_VERSION_2_1_0(PROJECT, project_major, project_minor, project_release, TYPE, \
type_major, type_minor, type_release) \
.pmix_mca_major_version = PMIX_MCA_BASE_VERSION_MAJOR, \
.pmix_mca_minor_version = PMIX_MCA_BASE_VERSION_MINOR, \
.pmix_mca_release_version = PMIX_MCA_BASE_VERSION_RELEASE, .pmix_mca_project_name = PROJECT, \
PMIX_MCA_BASE_MAKE_VERSION(project, project_major, project_minor, project_release), \
.pmix_mca_type_name = TYPE, \
PMIX_MCA_BASE_MAKE_VERSION(type, type_major, type_minor, type_release)
#define PMIX_MCA_BASE_VERSION_1_0_0(type, type_major, type_minor, type_release) \
PMIX_MCA_BASE_VERSION_2_1_0("pmix", PMIX_MAJOR_VERSION, PMIX_MINOR_VERSION, \
PMIX_RELEASE_VERSION, type, type_major, type_minor, type_release)
#endif /* PMIX_MCA_H */

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
*
* Copyright (c) 2019 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_COMPRESS_BASE_H
#define PMIX_COMPRESS_BASE_H
#include "pmix_config.h"
#include "src/mca/pcompress/pcompress.h"
#include "src/util/pmix_environ.h"
#include "src/mca/base/pmix_base.h"
/*
* Global functions for MCA overall COMPRESS
*/
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/* define a macro for quickly checking if a string exceeds the
* compression limit */
#define PMIX_STRING_SIZE_CHECK(s) \
(PMIX_STRING == (s)->type && NULL != (s)->data.string \
&& pmix_compress_base.compress_limit < strlen((s)->data.string))
#define PMIX_VALUE_COMPRESSED_STRING_UNPACK(s) \
do { \
char *tmp; \
/* if this is a compressed string, then uncompress it */ \
if (PMIX_COMPRESSED_STRING == (s)->type) { \
pmix_compress.decompress_string(&tmp, (uint8_t *) (s)->data.bo.bytes, \
(s)->data.bo.size); \
if (NULL == tmp) { \
PMIX_ERROR_LOG(PMIX_ERR_NOMEM); \
rc = PMIX_ERR_NOMEM; \
PMIX_VALUE_RELEASE(s); \
val = NULL; \
} else { \
PMIX_VALUE_DESTRUCT(s); \
(s)->data.string = tmp; \
(s)->type = PMIX_STRING; \
} \
} \
} while (0)
typedef struct {
size_t compress_limit;
bool selected;
bool silent;
} pmix_compress_base_t;
PMIX_EXPORT extern pmix_compress_base_t pmix_compress_base;
/**
* Select an available component.
*
* @retval OPAL_SUCCESS Upon Success
* @retval OPAL_NOT_FOUND If no component can be selected
* @retval OPAL_ERROR Upon other failure
*
*/
PMIX_EXPORT int pmix_compress_base_select(void);
/**
* Globals
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pcompress_base_framework;
PMIX_EXPORT extern pmix_compress_base_module_t pmix_compress;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* PMIX_COMPRESS_BASE_H */

View File

@@ -0,0 +1,119 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
*
* Copyright (c) 2019-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Compression Framework
*
* General Description:
*
* The PMIX Compress framework has been created to provide an abstract interface
* to the compression agent library on the host machine. This framework is useful
* when distributing files that can be compressed before sending to dimish the
* load on the network.
*
*/
#ifndef PMIX_MCA_COMPRESS_H
#define PMIX_MCA_COMPRESS_H
#include "pmix_config.h"
#include "src/class/pmix_object.h"
#include "src/mca/base/pmix_base.h"
#include "src/mca/mca.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/**
* Module initialization function.
* Returns PMIX_SUCCESS
*/
typedef int (*pmix_compress_base_module_init_fn_t)(void);
/**
* Module finalization function.
* Returns PMIX_SUCCESS
*/
typedef int (*pmix_compress_base_module_finalize_fn_t)(void);
/**
* Compress a string
*
* Arguments:
*
*/
typedef bool (*pmix_compress_base_module_compress_string_fn_t)(char *instring, uint8_t **outbytes,
size_t *nbytes);
typedef bool (*pmix_compress_base_module_decompress_string_fn_t)(char **outstring, uint8_t *inbytes,
size_t len);
typedef size_t (*pmix_compress_base_module_get_decompressed_strlen_fn_t)(const pmix_byte_object_t *bo);
/**
* Compress a block
*
* Arguments:
*
*/
typedef bool (*pmix_compress_base_module_compress_fn_t)(const uint8_t *inbytes, size_t size,
uint8_t **outbytes, size_t *nbytes);
typedef bool (*pmix_compress_base_module_decompress_fn_t)(uint8_t **outbytes, size_t *outlen,
const uint8_t *inbytes, size_t len);
typedef size_t (*pmix_compress_base_module_get_decompressed_size_fn_t)(const pmix_byte_object_t *bo);
/**
* Structure for COMPRESS components.
*/
typedef pmix_mca_base_component_t pmix_compress_base_component_t;
/**
* Structure for COMPRESS modules
*/
struct pmix_compress_base_module_1_0_0_t {
/** Initialization Function */
pmix_compress_base_module_init_fn_t init;
/** Finalization Function */
pmix_compress_base_module_finalize_fn_t finalize;
/** Compress interface */
pmix_compress_base_module_compress_fn_t compress;
/** Decompress Interface */
pmix_compress_base_module_decompress_fn_t decompress;
pmix_compress_base_module_get_decompressed_size_fn_t get_decompressed_size;
/* COMPRESS STRING */
pmix_compress_base_module_compress_string_fn_t compress_string;
pmix_compress_base_module_decompress_string_fn_t decompress_string;
pmix_compress_base_module_get_decompressed_strlen_fn_t get_decompressed_strlen;
};
typedef struct pmix_compress_base_module_1_0_0_t pmix_compress_base_module_1_0_0_t;
typedef struct pmix_compress_base_module_1_0_0_t pmix_compress_base_module_t;
PMIX_EXPORT extern pmix_compress_base_module_t pmix_compress;
/**
* Macro for use in components that are of type COMPRESS
*/
#define PMIX_COMPRESS_BASE_VERSION_2_0_0 PMIX_MCA_BASE_VERSION_1_0_0("pcompress", 2, 0, 0)
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* PMIX_COMPRESS_H */

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_PDL_BASE_H
#define PMIX_PDL_BASE_H
#include "src/include/pmix_config.h"
#include "src/mca/pdl/pdl.h"
#include "src/util/pmix_environ.h"
#include "src/mca/base/pmix_base.h"
BEGIN_C_DECLS
/**
* Globals
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pdl_base_framework;
extern pmix_pdl_base_component_t *pmix_pdl_base_selected_component;
extern pmix_pdl_base_module_t *pmix_pdl;
/**
* Initialize the PDL MCA framework
*
* @retval PMIX_SUCCESS Upon success
* @retval PMIX_ERROR Upon failures
*
* This function is invoked during pmix_init();
*/
int pmix_pdl_base_open(pmix_mca_base_open_flag_t flags);
/**
* Select an available component.
*
* @retval PMIX_SUCCESS Upon Success
* @retval PMIX_NOT_FOUND If no component can be selected
* @retval PMIX_ERROR Upon other failure
*
*/
int pmix_pdl_base_select(void);
/**
* Finalize the PDL MCA framework
*
* @retval PMIX_SUCCESS Upon success
* @retval PMIX_ERROR Upon failures
*
* This function is invoked during pmix_finalize();
*/
int pmix_pdl_base_close(void);
/**
* Open a DSO
*
* (see pmix_pdl_base_module_open_ft_t in pmix/mca/pdl/pdl.h for
* documentation of this function)
*/
int pmix_pdl_open(const char *fname, bool use_ext, bool private_namespace,
pmix_pdl_handle_t **handle, char **err_msg);
/**
* Lookup a symbol in a DSO
*
* (see pmix_pdl_base_module_lookup_ft_t in pmix/mca/pdl/pdl.h for
* documentation of this function)
*/
int pmix_pdl_lookup(pmix_pdl_handle_t *handle, const char *symbol, void **ptr, char **err_msg);
/**
* Close a DSO
*
* (see pmix_pdl_base_module_close_ft_t in pmix/mca/pdl/pdl.h for
* documentation of this function)
*/
int pmix_pdl_close(pmix_pdl_handle_t *handle);
/**
* Iterate over files in a path
*
* (see pmix_pdl_base_module_foreachfile_ft_t in pmix/mca/pdl/pdl.h for
* documentation of this function)
*/
int pmix_pdl_foreachfile(const char *search_path,
int (*cb_func)(const char *filename, void *context), void *context);
END_C_DECLS
#endif /* PMIX_PDL_BASE_H */

View File

@@ -0,0 +1,181 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Dynamic library framework
*
* General Description:
*
* This framework provides portable access to dlopen- and dlsym-like
* functionality, very similar to Libtool's libltdl. Indeed, one of
* the components in this framework will use libltdl, if it is
* present/available. However, on some common types systems where
* libltdl headers and libraries are *not* available, we can support
* plugins via this simple framework.
*
* This is a compile-time framework: a single component will be
* selected by the priority that its configure.m4 provides. All other
* components will be ignored (i.e., not built/not part of the
* installation). Meaning: the static_components of the pdl framework
* will always contain 0 or 1 components.
*
* SIDENOTE: PMIX used to embed libltdl. However, as of early
* 2015, this became problematic, for a variety of complex and
* uninteresting reasons (see the following if you care about the
* details: https://github.com/open-mpi/ompi/issues/311,
* http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19370,
* https://github.com/open-mpi/ompi/pull/366,
* https://github.com/open-mpi/ompi/pull/390). That being said, we,
* as a developer community, still wanted to be able to natively use
* DSOs by default. A small/simple framework for PDL functionality,
* along with a simple component that supports dlopen/dlsym on POSIX
* platforms and another component that natively uses libltdl seemed
* like a good solution.
*/
#ifndef PMIX_MCA_PDL_PDL_H
#define PMIX_MCA_PDL_PDL_H
#include "src/include/pmix_config.h"
#include "src/mca/base/pmix_base.h"
#include "src/mca/mca.h"
BEGIN_C_DECLS
/**
* Handle for an opened file
*/
struct pmix_pdl_handle_t;
typedef struct pmix_pdl_handle_t pmix_pdl_handle_t;
/**
* Dynamically open the file specified.
*
* Arguments:
* fname = Base filename to open. If NULL, open this process.
* use_ext = If true, try various filename suffixes that are
* relevant on this platform (e.g., .so, .dll, .dylib). If
* false, just use exactly whatever was passed as fname.
* private = If true, open the file in a private namespace.
* Otherwise, open the file in a global namespace.
* handle = Upon successful open, a handle to the opened file will
* be returned.
* err_msg= if non-NULL and !=PMIX_SUCCESS is returned, will point to a
* string error message
*
* Returns:
* PMIX_SUCCESS on success, or PMIX_ERROR
*
* Space for the handle must be allocated by the module (it can be
* freed during the call to pmix_pdl_base_module_dlclose_fn_t).
*
* The err_msg points to an internal string and should not be altered
* or freed by the caller. The contents of the err_msg string may
* change after successive calls to pmix_pdl API calls.
*/
typedef int (*pmix_pdl_base_module_open_fn_t)(const char *fname, bool use_ext,
bool private_namespace, pmix_pdl_handle_t **handle,
char **err_msg);
/**
* Lookup a symbol in an opened file.
*
* Arguments:
* handle = handle of a previously dynamically opened file
* symbol = name of the symbol to lookup
* ptr = if found, a pointer to the symbol. Otherwise, NULL.
* err_msg= if non-NULL and !=PMIX_SUCCESS is returned, will point to a
* string error message
* Returns:
* PMIX_SUCCESS on success, or PMIX_ERROR
*
*
* The err_msg points to an internal string and should not be altered
* or freed by the caller. The contents of the err_msg string may
* change after successive calls to pmix_pdl API calls.
*/
typedef int (*pmix_pdl_base_module_lookup_fn_t)(pmix_pdl_handle_t *handle, const char *symbol,
void **ptr, char **err_msg);
/**
* Dynamically close a previously dynamically-opened file.
*
* Arguments:
* handle = handle of a previously dynamically opened file.
* Returns:
* PMIX_SUCCESS on success, or PMIX_ERROR
*
* This function should close the file and free and resources
* associated with it (e.g., whatever is cached on the handle).
*/
typedef int (*pmix_pdl_base_module_close_fn_t)(pmix_pdl_handle_t *handle);
/**
* Search through a path of directories, invoking a callback on each
* unique regular (non-Libtool) file basename found (e.g., will only
* be invoked once for the files "foo.la" and "foo.so", with the
* parameter "foo").
*
* Arguments:
* path = PMIX_ENV_SEP-delimited list of directories
* cb_func= function to invoke on each filename found
* data = context for callback function
* Returns:
* PMIX_SUCESS on success, PMIX_ERR* otherwise
*/
typedef int (*pmix_pdl_base_module_foreachfile_fn_t)(
const char *search_path, int (*cb_func)(const char *filename, void *context), void *context);
/**
* Structure for PDL components.
*/
struct pmix_pdl_base_component_1_0_0_t {
/** MCA base component */
pmix_mca_base_component_t base_version;
/** Default priority */
int priority;
};
typedef struct pmix_pdl_base_component_1_0_0_t pmix_pdl_base_component_1_0_0_t;
typedef struct pmix_pdl_base_component_1_0_0_t pmix_pdl_base_component_t;
/**
* Structure for PDL modules
*/
struct pmix_pdl_base_module_1_0_0_t {
pmix_mca_base_module_2_0_0_t super;
/** Open / close */
pmix_pdl_base_module_open_fn_t open;
pmix_pdl_base_module_close_fn_t close;
/** Lookup a symbol */
pmix_pdl_base_module_lookup_fn_t lookup;
/** Iterate looking for files */
pmix_pdl_base_module_foreachfile_fn_t foreachfile;
};
typedef struct pmix_pdl_base_module_1_0_0_t pmix_pdl_base_module_1_0_0_t;
typedef struct pmix_pdl_base_module_1_0_0_t pmix_pdl_base_module_t;
/**
* Macro for use in components that are of type PDL
*/
#define PMIX_PDL_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("pdl", 1, 0, 0)
END_C_DECLS
#endif /* PMIX_MCA_PDL_PDL_H */

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2016 Intel, Inc. All rights reserved.
* Copyright (c) 2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PIF_BASE_H
#define PMIX_PIF_BASE_H
#include "src/include/pmix_config.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/pif/pif.h"
BEGIN_C_DECLS
/*
* Framework declaration
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pif_base_framework;
END_C_DECLS
#endif /* PMIX_BASE_PIF_H */

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2010-2013 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2019 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_MCA_PIF_PIF_H
#define PMIX_MCA_PIF_PIF_H
#include "src/include/pmix_config.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <errno.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
#endif
#include "src/mca/base/pmix_base.h"
#include "src/mca/mca.h"
#include "src/util/pmix_if.h"
BEGIN_C_DECLS
/*
* Define INADDR_NONE if we don't have it. Solaris is the only system
* where I have found that it does not exist, and the man page for
* inet_addr() says that it returns -1 upon failure. On Linux and
* other systems with INADDR_NONE, it's just a #define to -1 anyway.
* So just #define it to -1 here if it doesn't already exist.
*/
#if !defined(INADDR_NONE)
# define INADDR_NONE -1
#endif
#define DEFAULT_NUMBER_INTERFACES 10
#define MAX_PIFCONF_SIZE 10 * 1024 * 1024
/* "global" list of available interfaces */
extern pmix_list_t pmix_if_list;
/* global flags */
extern bool pmix_if_do_not_resolve;
extern bool pmix_if_retain_loopback;
/**
* Structure for if components.
*/
typedef pmix_mca_base_component_t pmix_pif_base_component_t;
/*
* Macro for use in components that are of type pif
*/
#define PMIX_PIF_BASE_VERSION_2_0_0 PMIX_MCA_BASE_VERSION_1_0_0("pif", 2, 0, 0)
END_C_DECLS
#endif /* PMIX_MCA_PIF_PIF_H */

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2006-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2010 Sandia National Laboratories. All rights reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PINSTALLDIRS_BASE_H
#define PMIX_PINSTALLDIRS_BASE_H
#include "src/include/pmix_config.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/pinstalldirs/pinstalldirs.h"
/*
* Global functions for MCA overall pinstalldirs open and close
*/
BEGIN_C_DECLS
/**
* Framework structure declaration
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pinstalldirs_base_framework;
/* Just like pmix_pinstall_dirs_expand() (see pinstalldirs.h), but will
also insert the value of the environment variable $PMIX_DESTDIR, if
it exists/is set. This function should *only* be used during the
setup routines of pinstalldirs. */
PMIX_EXPORT char *pmix_pinstall_dirs_expand_setup(const char *input);
PMIX_EXPORT int pmix_pinstall_dirs_base_init(pmix_info_t info[], size_t ninfo);
END_C_DECLS
#endif /* PMIX_BASE_PINSTALLDIRS_H */

View File

@@ -0,0 +1,57 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2006-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_MCA_PINSTALLDIRS_PINSTALLDIRS_H
#define PMIX_MCA_PINSTALLDIRS_PINSTALLDIRS_H
#include "src/include/pmix_config.h"
#include "pmix_common.h"
#include "src/mca/base/pmix_base.h"
#include "src/mca/mca.h"
#include "src/mca/pinstalldirs/pinstalldirs_types.h"
BEGIN_C_DECLS
/**
* Expand out path variables (such as ${prefix}) in the input string
* using the current pmix_pinstall_dirs structure */
PMIX_EXPORT char *pmix_pinstall_dirs_expand(const char *input);
/* optional initialization function */
typedef void (*pmix_install_dirs_init_fn_t)(pmix_info_t info[], size_t ninfo);
/**
* Structure for pinstalldirs components.
*/
struct pmix_pinstalldirs_base_component_2_0_0_t {
/** MCA base component */
pmix_mca_base_component_t component;
/** install directories provided by the given component */
pmix_pinstall_dirs_t install_dirs_data;
/* optional init function */
pmix_install_dirs_init_fn_t init;
};
/**
* Convenience typedef
*/
typedef struct pmix_pinstalldirs_base_component_2_0_0_t pmix_pinstalldirs_base_component_t;
/*
* Macro for use in components that are of type pinstalldirs
*/
#define PMIX_PINSTALLDIRS_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("pinstalldirs", 1, 0, 0)
END_C_DECLS
#endif /* PMIX_MCA_PINSTALLDIRS_PINSTALLDIRS_H */

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2006-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PMIX_MCA_PINSTALLDIRS_PINSTALLDIRS_TYPES_H
#define PMIX_MCA_PINSTALLDIRS_PINSTALLDIRS_TYPES_H
#include "src/include/pmix_config.h"
#include "pmix_common.h"
BEGIN_C_DECLS
/*
* Most of this file is just for pmix_info. The only public interface
* once pmix_init has been called is the pmix_pinstall_dirs structure
* and the pmix_pinstall_dirs_expand() call */
struct pmix_pinstall_dirs_t {
char *prefix;
char *exec_prefix;
char *bindir;
char *sbindir;
char *libexecdir;
char *datarootdir;
char *datadir;
char *sysconfdir;
char *sharedstatedir;
char *localstatedir;
char *libdir;
char *includedir;
char *infodir;
char *mandir;
/* Rather than using pkg{data,lib,includedir}, use our own
pmix{data,lib,includedir}, which is always set to
{datadir,libdir,includedir}/pmix.
Note that these field names match macros set by configure that
are used in Makefile.am files. E.g., project help files are
installed into $(pmixdatadir). */
char *pmixdatadir;
char *pmixlibdir;
char *pmixincludedir;
};
typedef struct pmix_pinstall_dirs_t pmix_pinstall_dirs_t;
/* Install directories. Only available after pmix_init() */
PMIX_EXPORT extern pmix_pinstall_dirs_t pmix_pinstall_dirs;
END_C_DECLS
#endif /* PMIX_MCA_PINSTALLDIRS_PINSTALLDIRS_TYPES_H */

View File

@@ -0,0 +1,91 @@
/* -*- C -*-
*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PLOG_BASE_H_
#define PMIX_PLOG_BASE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for struct timeval */
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "src/class/pmix_list.h"
#include "src/class/pmix_pointer_array.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/threads/pmix_threads.h"
#include "src/mca/plog/plog.h"
BEGIN_C_DECLS
/*
* MCA Framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_plog_base_framework;
/**
* PLOG select function
*
* Cycle across available components and construct the array
* of active modules
*/
PMIX_EXPORT pmix_status_t pmix_plog_base_select(void);
/**
* Track an active component / module
*/
struct pmix_plog_base_active_module_t {
pmix_list_item_t super;
bool reqd;
bool added;
int pri;
pmix_plog_module_t *module;
pmix_plog_base_component_t *component;
};
typedef struct pmix_plog_base_active_module_t pmix_plog_base_active_module_t;
PMIX_CLASS_DECLARATION(pmix_plog_base_active_module_t);
/* framework globals */
struct pmix_plog_globals_t {
pmix_lock_t lock;
pmix_pointer_array_t actives;
bool initialized;
bool selected;
char **channels;
};
typedef struct pmix_plog_globals_t pmix_plog_globals_t;
PMIX_EXPORT extern pmix_plog_globals_t pmix_plog_globals;
PMIX_EXPORT pmix_status_t pmix_plog_base_log(const pmix_proc_t *source, const pmix_info_t data[],
size_t ndata, const pmix_info_t directives[],
size_t ndirs, pmix_op_cbfunc_t cbfunc, void *cbdata);
END_C_DECLS
#endif

View File

@@ -0,0 +1,97 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015-2020 Intel, Inc. All rights reserved.
*
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* This interface is for use by PMIx servers to obtain network-related info
* such as security keys that need to be shared across applications, and to
* setup network support for applications prior to launch
*
* Available plugins may be defined at runtime via the typical MCA parameter
* syntax.
*/
#ifndef PMIX_PLOG_H
#define PMIX_PLOG_H
#include "src/include/pmix_config.h"
#include "pmix_common.h"
#include "src/class/pmix_list.h"
#include "src/include/pmix_globals.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/mca.h"
BEGIN_C_DECLS
/****** MODULE DEFINITION ******/
/**
* Initialize the module. Returns an error if the module cannot
* run, success if it can and wants to be used.
*/
typedef pmix_status_t (*pmix_plog_base_module_init_fn_t)(void);
/**
* Finalize the module
*/
typedef void (*pmix_plog_base_module_fini_fn_t)(void);
/**
* Log data to channel, if possible
*/
typedef pmix_status_t (*pmix_plog_base_module_log_fn_t)(const pmix_proc_t *source,
const pmix_info_t data[], size_t ndata,
const pmix_info_t directives[],
size_t ndirs, pmix_op_cbfunc_t cbfunc,
void *cbdata);
/**
* Base structure for a PLOG module
*/
typedef struct {
char *name;
char **channels;
/* init/finalize */
pmix_plog_base_module_init_fn_t init;
pmix_plog_base_module_fini_fn_t finalize;
pmix_plog_base_module_log_fn_t log;
} pmix_plog_module_t;
/**
* Base structure for a PLOG API
*/
typedef struct {
pmix_plog_base_module_log_fn_t log;
} pmix_plog_API_module_t;
/* declare the global APIs */
PMIX_EXPORT extern pmix_plog_API_module_t pmix_plog;
/*
* the standard component data structure
*/
typedef pmix_mca_base_component_t pmix_plog_base_component_t;
/*
* Macro for use in components that are of type plog
*/
#define PMIX_PLOG_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("plog", 1, 0, 0)
END_C_DECLS
#endif

View File

@@ -0,0 +1,96 @@
/* -*- C -*-
*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PMDL_BASE_H_
#define PMIX_PMDL_BASE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for struct timeval */
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "src/class/pmix_list.h"
#include "src/class/pmix_pointer_array.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/mca/pmdl/pmdl.h"
BEGIN_C_DECLS
/*
* MCA Framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pmdl_base_framework;
/**
* PMDL select function
*
* Cycle across available components and construct the list
* of active modules
*/
PMIX_EXPORT pmix_status_t pmix_pmdl_base_select(void);
/**
* Track an active component / module
*/
struct pmix_pmdl_base_active_module_t {
pmix_list_item_t super;
int pri;
pmix_pmdl_module_t *module;
pmix_pmdl_base_component_t *component;
};
typedef struct pmix_pmdl_base_active_module_t pmix_pmdl_base_active_module_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_pmdl_base_active_module_t);
/* framework globals */
struct pmix_pmdl_globals_t {
pmix_lock_t lock;
pmix_list_t actives;
bool initialized;
bool selected;
};
typedef struct pmix_pmdl_globals_t pmix_pmdl_globals_t;
PMIX_EXPORT extern pmix_pmdl_globals_t pmix_pmdl_globals;
PMIX_EXPORT pmix_status_t pmix_pmdl_base_harvest_envars(char *nspace, const pmix_info_t info[],
size_t ninfo, pmix_list_t *ilist);
PMIX_EXPORT void pmix_pmdl_base_parse_file_envars(pmix_list_t *ilist);
PMIX_EXPORT bool pmix_pmdl_base_check_prte_param(char *param);
PMIX_EXPORT bool pmix_pmdl_base_check_pmix_param(char *param);
PMIX_EXPORT pmix_status_t pmix_pmdl_base_setup_nspace(pmix_namespace_t *nptr, pmix_info_t *info);
PMIX_EXPORT pmix_status_t pmix_pmdl_base_setup_nspace_kv(pmix_namespace_t *nptr, pmix_kval_t *kv);
PMIX_EXPORT pmix_status_t pmix_pmdl_base_register_nspace(pmix_namespace_t *nptr);
PMIX_EXPORT pmix_status_t pmix_pmdl_base_setup_client(pmix_namespace_t *nptr, pmix_rank_t rank,
uint32_t appnum);
PMIX_EXPORT pmix_status_t pmix_pmdl_base_setup_fork(const pmix_proc_t *peer, char ***env);
PMIX_EXPORT void pmix_pmdl_base_deregister_nspace(const char *nptr);
END_C_DECLS
#endif

View File

@@ -0,0 +1,152 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
*
* Copyright (c) 2015-2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* This interface is for use by PMIx servers to obtain network-related info
* such as security keys that need to be shared across applications, and to
* setup network support for applications prior to launch
*
* Available plugins may be defined at runtime via the typical MCA parameter
* syntax.
*/
#ifndef PMIX_PMDL_H
#define PMIX_PMDL_H
#include "src/include/pmix_config.h"
#include "src/class/pmix_list.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/mca.h"
#include "src/server/pmix_server_ops.h"
BEGIN_C_DECLS
/****** MODULE DEFINITION ******/
/**
* Initialize the module. Returns an error if the module cannot
* run, success if it can and wants to be used.
*/
typedef pmix_status_t (*pmix_pmdl_base_module_init_fn_t)(void);
/**
* Finalize the module. Tear down any allocated storage, disconnect
* from any system support (e.g., LDAP server)
*/
typedef void (*pmix_pmdl_base_module_fini_fn_t)(void);
/* Harvest envars for this programming model so they can be forwarded
* to backend processes */
typedef pmix_status_t (*pmix_pmdl_base_module_harvest_envars_fn_t)(pmix_namespace_t *nptr,
const pmix_info_t info[],
size_t ninfo, pmix_list_t *ilist,
char ***priors);
/* Check a list of pmix_mca_base_var_file_value_t items that were
* read from a file to see if any belong to this programming
* model - if they do, then cache them for passing to any nspaces
* during harvest_envars */
typedef void (*pmix_pmdl_base_module_parse_file_envars_fn_t)(pmix_list_t *ilist);
/**
* Setup any programming model specific support for the given nspace
*/
typedef pmix_status_t (*pmix_pmdl_base_module_setup_ns_fn_t)(pmix_namespace_t *nptr,
pmix_info_t *info);
typedef pmix_status_t (*pmix_pmdl_base_module_setup_ns_kv_fn_t)(pmix_namespace_t *nptr,
pmix_kval_t *kv);
/* Allow programming models to add key-value pairs to the job-info - they
* can directly cache them in the GDS */
typedef pmix_status_t (*pmix_pmdl_base_module_reg_nspace_fn_t)(pmix_namespace_t *nptr);
/**
* Setup any programming model specific support for the given client */
typedef pmix_status_t (*pmix_pmdl_base_module_setup_client_fn_t)(pmix_namespace_t *nptr,
pmix_rank_t rank,
uint32_t apppnum);
/**
* Give the plugins an opportunity to add any envars to the
* environment of a local application process prior to fork/exec
*/
typedef pmix_status_t (*pmix_pmdl_base_module_setup_fork_fn_t)(const pmix_proc_t *peer, char ***env,
char ***priors);
/**
* Provide an opportunity for the fabric components to cleanup any
* resources they may have created to track the nspace
*/
typedef void (*pmix_pmdl_base_module_dregister_nspace_fn_t)(pmix_namespace_t *nptr);
/**
* Base structure for a PMDL module. Each component should malloc a
* copy of the module structure for each fabric plane they support.
*/
typedef struct {
char *name;
pmix_pmdl_base_module_init_fn_t init;
pmix_pmdl_base_module_fini_fn_t finalize;
pmix_pmdl_base_module_harvest_envars_fn_t harvest_envars;
pmix_pmdl_base_module_parse_file_envars_fn_t parse_file_envars;
pmix_pmdl_base_module_setup_ns_fn_t setup_nspace;
pmix_pmdl_base_module_setup_ns_kv_fn_t setup_nspace_kv;
pmix_pmdl_base_module_reg_nspace_fn_t register_nspace;
pmix_pmdl_base_module_setup_client_fn_t setup_client;
pmix_pmdl_base_module_setup_fork_fn_t setup_fork;
pmix_pmdl_base_module_dregister_nspace_fn_t deregister_nspace;
} pmix_pmdl_module_t;
/* define a public API */
typedef pmix_status_t (*pmix_pmdl_base_API_harvest_envars_fn_t)(char *nspace,
const pmix_info_t info[],
size_t ninfo, pmix_list_t *ilist);
typedef pmix_status_t (*pmix_pmdl_base_API_setup_fork_fn_t)(const pmix_proc_t *peer, char ***env);
typedef void (*pmix_pmdl_base_API_dregister_nspace_fn_t)(const char *nptr);
typedef struct {
char *name;
pmix_pmdl_base_module_init_fn_t init;
pmix_pmdl_base_module_fini_fn_t finalize;
pmix_pmdl_base_API_harvest_envars_fn_t harvest_envars;
pmix_pmdl_base_module_parse_file_envars_fn_t parse_file_envars;
pmix_pmdl_base_module_setup_ns_fn_t setup_nspace;
pmix_pmdl_base_module_setup_ns_kv_fn_t setup_nspace_kv;
pmix_pmdl_base_module_reg_nspace_fn_t register_nspace;
pmix_pmdl_base_module_setup_client_fn_t setup_client;
pmix_pmdl_base_API_setup_fork_fn_t setup_fork;
pmix_pmdl_base_API_dregister_nspace_fn_t deregister_nspace;
} pmix_pmdl_API_module_t;
/* declare the global APIs */
PMIX_EXPORT extern pmix_pmdl_API_module_t pmix_pmdl;
/*
* the standard component data structure
*/
typedef pmix_mca_base_component_t pmix_pmdl_base_component_t;
/*
* Macro for use in components that are of type pmdl
*/
#define PMIX_PMDL_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("pmdl", 1, 0, 0)
END_C_DECLS
#endif

View File

@@ -0,0 +1,119 @@
/* -*- C -*-
*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PNET_BASE_H_
#define PMIX_PNET_BASE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for struct timeval */
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "src/class/pmix_list.h"
#include "src/class/pmix_pointer_array.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/mca/pnet/pnet.h"
BEGIN_C_DECLS
/*
* MCA Framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pnet_base_framework;
/**
* PNET select function
*
* Cycle across available components and construct the list
* of active modules
*/
PMIX_EXPORT pmix_status_t pmix_pnet_base_select(void);
/**
* Track an active component / module
*/
struct pmix_pnet_base_active_module_t {
pmix_list_item_t super;
int pri;
pmix_pnet_module_t *module;
pmix_pnet_base_component_t *component;
};
typedef struct pmix_pnet_base_active_module_t pmix_pnet_base_active_module_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_pnet_base_active_module_t);
typedef struct {
pmix_list_item_t super;
char *name;
size_t index;
/* provide access to the component
* APIs that are managing this
* fabric plane */
pmix_pnet_module_t *module;
/* allow the component to add
* whatever structures it needs */
void *payload;
} pmix_pnet_fabric_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_pnet_fabric_t);
/* framework globals */
struct pmix_pnet_globals_t {
pmix_list_t actives;
pmix_list_t fabrics;
pmix_list_t nspaces;
bool selected;
};
typedef struct pmix_pnet_globals_t pmix_pnet_globals_t;
PMIX_EXPORT extern pmix_pnet_globals_t pmix_pnet_globals;
PMIX_EXPORT pmix_status_t pmix_pnet_base_allocate(char *nspace, pmix_info_t info[], size_t ninfo,
pmix_list_t *ilist);
PMIX_EXPORT pmix_status_t pmix_pnet_base_setup_local_network(char *nspace, pmix_info_t info[],
size_t ninfo);
PMIX_EXPORT pmix_status_t pmix_pnet_base_setup_fork(const pmix_proc_t *peer, char ***env);
PMIX_EXPORT void pmix_pnet_base_child_finalized(pmix_proc_t *peer);
PMIX_EXPORT void pmix_pnet_base_local_app_finalized(pmix_namespace_t *nptr);
PMIX_EXPORT void pmix_pnet_base_deregister_nspace(char *nspace);
PMIX_EXPORT pmix_status_t pmix_pnet_base_collect_inventory(pmix_info_t directives[], size_t ndirs,
pmix_list_t *inventory);
PMIX_EXPORT pmix_status_t pmix_pnet_base_deliver_inventory(pmix_info_t info[], size_t ninfo,
pmix_info_t directives[], size_t ndirs);
PMIX_EXPORT pmix_status_t pmix_pnet_base_harvest_envars(char **incvars, char **excvars,
pmix_list_t *ilist);
PMIX_EXPORT pmix_status_t pmix_pnet_base_register_fabric(pmix_fabric_t *fabric,
const pmix_info_t directives[],
size_t ndirs, pmix_op_cbfunc_t cbfunc,
void *cbdata);
PMIX_EXPORT pmix_status_t pmix_pnet_base_deregister_fabric(pmix_fabric_t *fabric);
PMIX_EXPORT pmix_status_t pmix_pnet_base_update_fabric(pmix_fabric_t *fabric);
END_C_DECLS
#endif

View File

@@ -0,0 +1,234 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
*
* Copyright (c) 2015-2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* This interface is for use by PMIx servers to obtain network-related info
* such as security keys that need to be shared across applications, and to
* setup network support for applications prior to launch
*
* Available plugins may be defined at runtime via the typical MCA parameter
* syntax.
*/
#ifndef PMIX_PNET_H
#define PMIX_PNET_H
#include "src/include/pmix_config.h"
#include "include/pmix.h"
#include "src/class/pmix_list.h"
#include "src/include/pmix_globals.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/mca.h"
#include "src/server/pmix_server_ops.h"
BEGIN_C_DECLS
/****** MODULE DEFINITION ******/
/**
* Initialize the module. Returns an error if the module cannot
* run, success if it can and wants to be used.
*/
typedef pmix_status_t (*pmix_pnet_base_module_init_fn_t)(void);
/**
* Finalize the module. Tear down any allocated storage, disconnect
* from any system support (e.g., LDAP server)
*/
typedef void (*pmix_pnet_base_module_fini_fn_t)(void);
/**
* Allocate network resources. This can be called either as a result
* of a call to PMIx_Allocate_resources, or by the scheduler to
* provide an opportunity for the network to define values that
* are to be passed to an application. This can include security
* tokens required for application processes to communicate with
* each other, environmental variables picked up at the login node
* for forwarding to compute nodes, or allocation of static endpts
*/
typedef pmix_status_t (*pmix_pnet_base_module_allocate_fn_t)(pmix_namespace_t *nptr,
pmix_info_t info[], size_t ninfo,
pmix_list_t *ilist);
/**
* Give the local network library an opportunity to setup address information
* for the application by passing in the layout type and a regex describing
* the layout */
typedef pmix_status_t (*pmix_pnet_base_module_setup_local_net_fn_t)(pmix_nspace_env_cache_t *nptr,
pmix_info_t info[],
size_t ninfo);
/**
* Provide an opportunity for the local network library to cleanup when a
* local application process terminates
*/
typedef void (*pmix_pnet_base_module_child_finalized_fn_t)(pmix_proc_t *peer);
/**
* Provide an opportunity for the local network library to cleanup after
* all local clients for a given application have terminated
*/
typedef void (*pmix_pnet_base_module_local_app_finalized_fn_t)(pmix_namespace_t *nptr);
/**
* Provide an opportunity for the fabric components to cleanup any
* resource allocations (e.g., static ports) they may have assigned
*/
typedef void (*pmix_pnet_base_module_dregister_nspace_fn_t)(pmix_namespace_t *nptr);
/**
* Request that the module report local inventory for its network type.
*
* If the operation can be performed immediately, then the module should just
* add the inventory (as pmix_kval_t's) to the provided object's list and
* return PMIX_SUCCESS.
*
* If the module needs to perform some non-atomic operation
* (e.g., query a fabric manager), then it should shift to its own internal
* thread, return PMIX_OPERATION_IN_PROGRESS, and execute the provided
* callback function when the operation is completed.
*
* If there is no inventory to report, then just return PMIX_SUCCESS.
*
* If the module should be providing inventory but encounters an error,
* then immediately return an error code if the error is immediately detected,
* or execute the callback function with an error code if it is detected later.
*/
typedef pmix_status_t (*pmix_pnet_base_module_collect_inventory_fn_t)(
pmix_info_t directives[], size_t ndirs, pmix_list_t *inventory);
/**
* Deliver inventory for archiving by corresponding modules
*
* Modules are to search the provided inventory to identify
* entries provided by their remote peers, and then store that
* information in a manner that can be queried/retrieved by
* the host RM and/or scheduler. If the operation can be
* performed immediately (e.g., storing the information in
* the local hash table), then the module should just perform
* that operation and return the appropriate status.
*
* If the module needs to perform some non-atomic operation
* (e.g., storing the information in a non-local DHT), then
* it should shift to its own internal thread, return
* PMIX_OPERATION_IN_PROGRESS, and execute the provided
* callback function when the operation is completed.
*
* If there is no relevant inventory to archive, then the module
* should just return PMIX_SUCCESS;
*/
typedef pmix_status_t (*pmix_pnet_base_module_deliver_inventory_fn_t)(
pmix_info_t info[], size_t ninfo, pmix_info_t directives[], size_t ndirs);
/* Register to provide cost information
*
* Scan the provided directives to identify if the module
* should service this request - directives could include
* ordered specification of fabric type or a direct request
* for a specific component
*/
typedef pmix_status_t (*pmix_pnet_base_module_register_fabric_fn_t)(pmix_fabric_t *fabric,
const pmix_info_t directives[],
size_t ndirs,
pmix_op_cbfunc_t cbfunc,
void *cbdata);
/* Update the fabric information */
typedef pmix_status_t (*pmix_pnet_base_module_update_fabric_fn_t)(pmix_fabric_t *fabric);
/* Deregister the fabric, giving the associated module a chance to cleanup */
typedef pmix_status_t (*pmix_pnet_base_module_deregister_fabric_fn_t)(pmix_fabric_t *fabric);
/**
* Base structure for a PNET module. Each component should malloc a
* copy of the module structure for each fabric plane they support.
*/
typedef struct {
char *name;
/* provide a pointer to plane-specific metadata */
void *plane;
/* init/finalize */
pmix_pnet_base_module_init_fn_t init;
pmix_pnet_base_module_fini_fn_t finalize;
pmix_pnet_base_module_allocate_fn_t allocate;
pmix_pnet_base_module_setup_local_net_fn_t setup_local_network;
pmix_pnet_base_module_child_finalized_fn_t child_finalized;
pmix_pnet_base_module_local_app_finalized_fn_t local_app_finalized;
pmix_pnet_base_module_dregister_nspace_fn_t deregister_nspace;
pmix_pnet_base_module_collect_inventory_fn_t collect_inventory;
pmix_pnet_base_module_deliver_inventory_fn_t deliver_inventory;
pmix_pnet_base_module_register_fabric_fn_t register_fabric;
pmix_pnet_base_module_update_fabric_fn_t update_fabric;
pmix_pnet_base_module_deregister_fabric_fn_t deregister_fabric;
} pmix_pnet_module_t;
/* define a few API versions of the functions - main difference is the
* string nspace parameter instead of a pointer to pmix_namespace_t. This
* is done as an optimization to avoid having every component look for
* that pointer */
typedef pmix_status_t (*pmix_pnet_base_API_allocate_fn_t)(char *nspace, pmix_info_t info[],
size_t ninfo, pmix_list_t *ilist);
typedef pmix_status_t (*pmix_pnet_base_API_setup_local_net_fn_t)(char *nspace, pmix_info_t info[],
size_t ninfo);
/**
* Give the network framework an opportunity to add any envars to the
* environment of a local application process prior to fork/exec
*/
typedef pmix_status_t (*pmix_pnet_base_API_setup_fork_fn_t)(const pmix_proc_t *peer, char ***env);
typedef void (*pmix_pnet_base_API_deregister_nspace_fn_t)(char *nspace);
/**
* Base structure for a PNET API
*/
typedef struct {
char *name;
/* init/finalize */
pmix_pnet_base_module_init_fn_t init;
pmix_pnet_base_module_fini_fn_t finalize;
pmix_pnet_base_API_allocate_fn_t allocate;
pmix_pnet_base_API_setup_local_net_fn_t setup_local_network;
pmix_pnet_base_API_setup_fork_fn_t setup_fork;
pmix_pnet_base_module_child_finalized_fn_t child_finalized;
pmix_pnet_base_module_local_app_finalized_fn_t local_app_finalized;
pmix_pnet_base_API_deregister_nspace_fn_t deregister_nspace;
pmix_pnet_base_module_collect_inventory_fn_t collect_inventory;
pmix_pnet_base_module_deliver_inventory_fn_t deliver_inventory;
pmix_pnet_base_module_register_fabric_fn_t register_fabric;
pmix_pnet_base_module_update_fabric_fn_t update_fabric;
pmix_pnet_base_module_deregister_fabric_fn_t deregister_fabric;
} pmix_pnet_API_module_t;
/* declare the global APIs */
PMIX_EXPORT extern pmix_pnet_API_module_t pmix_pnet;
/*
* the standard component data structure
*/
typedef pmix_mca_base_component_t pmix_pnet_base_component_t;
/*
* Macro for use in components that are of type pnet
*/
#define PMIX_PNET_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("pnet", 1, 0, 0)
END_C_DECLS
#endif

View File

@@ -0,0 +1,93 @@
/* -*- C -*-
*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PREG_BASE_H_
#define PMIX_PREG_BASE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for struct timeval */
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "src/class/pmix_pointer_array.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/mca/preg/preg.h"
BEGIN_C_DECLS
/*
* MCA Framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_preg_base_framework;
/**
* PREG select function
*
* Cycle across available components and construct the list
* of active modules
*/
PMIX_EXPORT pmix_status_t pmix_preg_base_select(void);
/**
* Track an active component / module
*/
struct pmix_preg_base_active_module_t {
pmix_list_item_t super;
int pri;
pmix_preg_module_t *module;
pmix_mca_base_component_t *component;
};
typedef struct pmix_preg_base_active_module_t pmix_preg_base_active_module_t;
PMIX_CLASS_DECLARATION(pmix_preg_base_active_module_t);
/* framework globals */
struct pmix_preg_globals_t {
pmix_list_t actives;
bool initialized;
bool selected;
};
typedef struct pmix_preg_globals_t pmix_preg_globals_t;
PMIX_EXPORT extern pmix_preg_globals_t pmix_preg_globals;
PMIX_EXPORT pmix_status_t pmix_preg_base_generate_node_regex(const char *input, char **regex);
PMIX_EXPORT pmix_status_t pmix_preg_base_generate_ppn(const char *input, char **ppn);
PMIX_EXPORT pmix_status_t pmix_preg_base_parse_nodes(const char *regexp, char ***names);
PMIX_EXPORT pmix_status_t pmix_preg_base_parse_procs(const char *regexp, char ***procs);
PMIX_EXPORT pmix_status_t pmix_preg_base_copy(char **dest, size_t *len, const char *input);
PMIX_EXPORT pmix_status_t pmix_preg_base_pack(pmix_buffer_t *buffer, const char *input);
PMIX_EXPORT pmix_status_t pmix_preg_base_unpack(pmix_buffer_t *buffer, char **regex);
PMIX_EXPORT pmix_status_t pmix_preg_base_release(char *regexp);
END_C_DECLS
#endif

View File

@@ -0,0 +1,114 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* This interface is for regex support. This is a multi-select framework.
*
* Available plugins may be defined at runtime via the typical MCA parameter
* syntax.
*/
#ifndef PMIX_PREG_H
#define PMIX_PREG_H
#include "src/include/pmix_config.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/bfrops/bfrops_types.h"
#include "src/mca/mca.h"
#include "src/mca/preg/preg_types.h"
BEGIN_C_DECLS
/****** MODULE DEFINITION ******/
#define PMIX_MAX_NODE_PREFIX 50
/* given a semicolon-separated list of input values, generate
* a regex that can be passed down to a client for parsing.
* The caller is responsible for free'ing the resulting
* string
*
* If values have leading zero's, then that is preserved.
* Example:
*
* Input: odin009;odin010;odin011;odin012;odin017;odin018;thor176
*
* Output:
* "foo:odin[009-012,017-018],thor176"
*
* Note that the "foo" at the beginning of the regex indicates
* that the "foo" regex component is to be used to parse the
* provided regex.
*/
typedef pmix_status_t (*pmix_preg_base_module_generate_node_regex_fn_t)(const char *input,
char **regex);
/* The input is expected to consist of a comma-separated list
* of ranges. Thus, an input of:
* "1-4;2-5;8,10,11,12;6,7,9"
* would generate a regex of
* "[pmix:2x(3);8,10-12;6-7,9]"
*
* Note that the "pmix" at the beginning of each regex indicates
* that the PMIx native parser is to be used by the client for
* parsing the provided regex. Other parsers may be supported - see
* the pmix_client.h header for a list.
*/
typedef pmix_status_t (*pmix_preg_base_module_generate_ppn_fn_t)(const char *input, char **ppn);
typedef pmix_status_t (*pmix_preg_base_module_parse_nodes_fn_t)(const char *regexp, char ***names);
typedef pmix_status_t (*pmix_preg_base_module_parse_procs_fn_t)(const char *regexp, char ***procs);
typedef pmix_status_t (*pmix_preg_base_module_copy_fn_t)(char **dest, size_t *len,
const char *input);
typedef pmix_status_t (*pmix_preg_base_module_pack_fn_t)(pmix_buffer_t *buffer, const char *regex);
typedef pmix_status_t (*pmix_preg_base_module_unpack_fn_t)(pmix_buffer_t *buffer, char **regex);
typedef pmix_status_t (*pmix_preg_base_module_release_fn_t)(char *regexp);
/**
* Base structure for a PREG module
*/
typedef struct {
char *name;
pmix_preg_base_module_generate_node_regex_fn_t generate_node_regex;
pmix_preg_base_module_generate_ppn_fn_t generate_ppn;
pmix_preg_base_module_parse_nodes_fn_t parse_nodes;
pmix_preg_base_module_parse_procs_fn_t parse_procs;
pmix_preg_base_module_copy_fn_t copy;
pmix_preg_base_module_pack_fn_t pack;
pmix_preg_base_module_unpack_fn_t unpack;
pmix_preg_base_module_release_fn_t release;
} pmix_preg_module_t;
/* we just use the standard component definition */
PMIX_EXPORT extern pmix_preg_module_t pmix_preg;
/*
* Macro for use in components that are of type preg
*/
#define PMIX_PREG_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("preg", 1, 0, 0)
END_C_DECLS
#endif

View File

@@ -0,0 +1,61 @@
/* -*- C -*-
*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2019 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Buffer management types.
*/
#ifndef PMIX_MCA_PREG_TYPES_H_
#define PMIX_MCA_PREG_TYPES_H_
#include "src/include/pmix_config.h"
#include "src/class/pmix_list.h"
#include "src/class/pmix_object.h"
BEGIN_C_DECLS
/* these classes are required by the regex code */
typedef struct {
pmix_list_item_t super;
int start;
int cnt;
} pmix_regex_range_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_regex_range_t);
typedef struct {
/* list object */
pmix_list_item_t super;
char *prefix;
char *suffix;
int num_digits;
pmix_list_t ranges;
bool skip;
} pmix_regex_value_t;
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_regex_value_t);
END_C_DECLS
#endif /* PMIX_PREG_TYPES_H */

View File

@@ -0,0 +1,84 @@
/* -*- C -*-
*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PSEC_BASE_H_
#define PMIX_PSEC_BASE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for struct timeval */
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "src/class/pmix_pointer_array.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/mca/psec/psec.h"
BEGIN_C_DECLS
/*
* MCA Framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_psec_base_framework;
/**
* PSEC select function
*
* Cycle across available components and construct the list
* of active modules
*/
PMIX_EXPORT pmix_status_t pmix_psec_base_select(void);
/**
* Track an active component / module
*/
struct pmix_psec_base_active_module_t {
pmix_list_item_t super;
int pri;
pmix_psec_module_t *module;
pmix_psec_base_component_t *component;
};
typedef struct pmix_psec_base_active_module_t pmix_psec_base_active_module_t;
PMIX_CLASS_DECLARATION(pmix_psec_base_active_module_t);
/* framework globals */
struct pmix_psec_globals_t {
pmix_list_t actives;
bool initialized;
bool selected;
};
typedef struct pmix_psec_globals_t pmix_psec_globals_t;
PMIX_EXPORT extern pmix_psec_globals_t pmix_psec_globals;
PMIX_EXPORT char *pmix_psec_base_get_available_modules(void);
PMIX_EXPORT pmix_psec_module_t *pmix_psec_base_assign_module(const char *options);
END_C_DECLS
#endif

View File

@@ -0,0 +1,209 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015-2020 Intel, Inc. All rights reserved.
*
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2019 Mellanox Technologies, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* This interface is for psecurity support. PMIx doesn't need much in
* this regard, but we do need a mechanism for authenticating connections.
*
* Only *one* plugin will be active in a client, but multiple plugins may
* be active in a server. Thus, this is a multi-select framework.
*
* Available plugins may be defined at runtime via the typical MCA parameter
* syntax.
*/
#ifndef PMIX_PSEC_H
#define PMIX_PSEC_H
#include "src/include/pmix_config.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/mca.h"
#include "src/mca/ptl/ptl_types.h"
BEGIN_C_DECLS
/* forward declaration */
struct pmix_peer_t;
/****** MODULE DEFINITION ******/
/**
* Initialize the module. Returns an error if the module cannot
* run, success if it can and wants to be used.
*/
typedef pmix_status_t (*pmix_psec_base_module_init_fn_t)(void);
/**
* Finalize the module. Tear down any allocated storage, disconnect
* from any system support (e.g., LDAP server)
*/
typedef void (*pmix_psec_base_module_fini_fn_t)(void);
/**** CLIENT-SIDE FUNCTIONS ****/
/**
* Create and return a credential for this client - this
* could be a string or a byte array, which is why we must
* also return the length. The directives contain info on
* desired credential type, or other directives used by
* the credential agent. The returned info array typically
* contains the name of the agent issuing the credential,
* plus any other info the agent chooses to return.
*/
typedef pmix_status_t (*pmix_psec_base_module_create_cred_fn_t)(struct pmix_peer_t *peer,
const pmix_info_t directives[],
size_t ndirs, pmix_info_t **info,
size_t *ninfo,
pmix_byte_object_t *cred);
/**
* Perform the client-side handshake. Note that it is not required
* (and indeed, would be rare) for a protocol to use both the
* credential and handshake interfaces. It is acceptable, therefore,
* for one of them to be NULL */
typedef pmix_status_t (*pmix_psec_base_module_client_hndshk_fn_t)(int sd);
/**** SERVER-SIDE FUNCTIONS ****/
/**
* Validate a client's credential - the credential could be a string
* or an array of bytes, which is why we include the length. The directives
* contain information provided by the requestor to aid in the validation
* process - e.g., the uid/gid of the process seeking validation, or
* the name of the agent being asked to perform the validation. The
* returned info array typically contains the name of the agent that
* actually performed the validation, plus any other info the agent
* chooses to return (e.g., the uid/gid contained in the credential)
*/
typedef pmix_status_t (*pmix_psec_base_module_validate_cred_fn_t)(struct pmix_peer_t *peer,
const pmix_info_t directives[],
size_t ndirs, pmix_info_t **info,
size_t *ninfo,
const pmix_byte_object_t *cred);
/**
* Perform the server-side handshake. Note that it is not required
* (and indeed, would be rare) for a protocol to use both the
* credential and handshake interfaces. It is acceptable, therefore,
* for one of them to be NULL */
typedef pmix_status_t (*pmix_psec_base_module_server_hndshk_fn_t)(int sd);
/**
* Base structure for a PSEC module
*/
typedef struct {
char *name;
/* init/finalize */
pmix_psec_base_module_init_fn_t init;
pmix_psec_base_module_fini_fn_t finalize;
/** Client-side */
pmix_psec_base_module_create_cred_fn_t create_cred;
pmix_psec_base_module_client_hndshk_fn_t client_handshake;
/** Server-side */
pmix_psec_base_module_validate_cred_fn_t validate_cred;
pmix_psec_base_module_server_hndshk_fn_t server_handshake;
} pmix_psec_module_t;
/* define an API module */
/* get a list of available options - caller must free results
* when done */
PMIX_EXPORT char *pmix_psec_base_get_available_modules(void);
/* Select a psec module for a given peer */
PMIX_EXPORT pmix_psec_module_t *pmix_psec_base_assign_module(const char *options);
/* MACROS FOR EXECUTING PSEC FUNCTIONS */
#define PMIX_PSEC_CREATE_CRED(r, p, d, nd, in, nin, c) \
(r) = (p)->nptr->compat.psec->create_cred((struct pmix_peer_t *) (p), (d), (nd), (in), (nin), c)
#define PMIX_PSEC_CLIENT_HANDSHAKE(r, p, sd) (r) = (p)->nptr->compat.psec->client_handshake(sd)
#define PMIX_PSEC_VALIDATE_CRED(r, p, d, nd, in, nin, c) \
(r) = (p)->nptr->compat.psec->validate_cred((struct pmix_peer_t *) (p), (d), (nd), (in), \
(nin), c)
#define PMIX_PSEC_VALIDATE_CONNECTION(r, p, d, nd, in, nin, c) \
do { \
int _r; \
/* if a credential is available, then check it */ \
if (NULL != (p)->nptr->compat.psec->validate_cred) { \
_r = (p)->nptr->compat.psec->validate_cred((struct pmix_peer_t *) (p), (d), (nd), \
(in), (nin), c); \
if (PMIX_SUCCESS != _r) { \
pmix_output_verbose(2, pmix_globals.debug_output, \
"validation of credential failed: %s", PMIx_Error_string(_r)); \
} else { \
pmix_output_verbose(2, pmix_globals.debug_output, "credential validated"); \
} \
(r) = _r; \
} else if (NULL != (p)->nptr->compat.psec->server_handshake) { \
/* request the handshake if the security mode calls for it */ \
pmix_output_verbose(2, pmix_globals.debug_output, "requesting handshake"); \
_r = PMIX_ERR_READY_FOR_HANDSHAKE; \
(r) = _r; \
} else { \
/* this is not allowed */ \
(r) = PMIX_ERR_NOT_SUPPORTED; \
} \
} while (0)
#define PMIX_PSEC_SERVER_HANDSHAKE_IFNEED(r, p, d, nd, in, nin, c) \
if (PMIX_ERR_READY_FOR_HANDSHAKE == r) { \
int _r; \
/* execute the handshake if the security mode calls for it */ \
pmix_output_verbose(2, pmix_globals.debug_output, "executing handshake"); \
if (PMIX_SUCCESS != (_r = p->nptr->compat.psec->server_handshake((p)->sd))) { \
PMIX_ERROR_LOG(_r); \
} \
/* Update the reply status */ \
(r) = _r; \
}
/**** COMPONENT STRUCTURE DEFINITION ****/
/* define a component-level API for initializing the component */
typedef pmix_status_t (*pmix_psec_base_component_init_fn_t)(void);
/* define a component-level API for finalizing the component */
typedef void (*pmix_psec_base_component_finalize_fn_t)(void);
/* define a component-level API for getting a module */
typedef pmix_psec_module_t *(*pmix_psec_base_component_assign_module_fn_t)(void);
/*
* the standard component data structure
*/
struct pmix_psec_base_component_t {
pmix_mca_base_component_t base;
int priority;
pmix_psec_base_component_init_fn_t init;
pmix_psec_base_component_finalize_fn_t finalize;
pmix_psec_base_component_assign_module_fn_t assign_module;
};
typedef struct pmix_psec_base_component_t pmix_psec_base_component_t;
/*
* Macro for use in components that are of type psec
*/
#define PMIX_PSEC_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("psec", 1, 0, 0)
END_C_DECLS
#endif

View File

@@ -0,0 +1,61 @@
/*
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved.
* Copyright (c) 2017-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*/
#ifndef PMIX_PSENSOR_BASE_H_
#define PMIX_PSENSOR_BASE_H_
#include "src/include/pmix_config.h"
#include "src/class/pmix_list.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/mca/psensor/psensor.h"
BEGIN_C_DECLS
/*
* MCA Framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_psensor_base_framework;
PMIX_EXPORT int pmix_psensor_base_select(void);
/* define a struct to hold framework-global values */
typedef struct {
pmix_list_t actives;
pmix_event_base_t *evbase;
bool selected;
} pmix_psensor_base_t;
typedef struct {
pmix_list_item_t super;
pmix_psensor_base_component_t *component;
pmix_psensor_base_module_t *module;
int priority;
} pmix_psensor_active_module_t;
PMIX_CLASS_DECLARATION(pmix_psensor_active_module_t);
PMIX_EXPORT extern pmix_psensor_base_t pmix_psensor_base;
PMIX_EXPORT pmix_status_t pmix_psensor_base_start(pmix_peer_t *requestor, pmix_status_t error,
const pmix_info_t *monitor,
const pmix_info_t directives[], size_t ndirs);
PMIX_EXPORT pmix_status_t pmix_psensor_base_stop(pmix_peer_t *requestor, char *id);
END_C_DECLS
#endif

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
*
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
* @file:
*
*/
#ifndef PMIX_PSENSOR_H_
#define PMIX_PSENSOR_H_
#include "src/include/pmix_config.h"
#include "src/class/pmix_list.h"
#include "src/include/pmix_globals.h"
#include "src/mca/mca.h"
BEGIN_C_DECLS
/*
* Component functions - all MUST be provided!
*/
/* start a sensor operation:
*
* requestor - the process requesting this operation
*
* monitor - a PMIx attribute specifying what is to be monitored
*
* directives - an array of pmix_info_t specifying relevant limits on values, and action
* to be taken when limits exceeded. Can include
* user-provided "id" string */
typedef pmix_status_t (*pmix_psensor_base_module_start_fn_t)(pmix_peer_t *requestor,
pmix_status_t error,
const pmix_info_t *monitor,
const pmix_info_t directives[],
size_t ndirs);
/* stop a sensor operation:
*
* requestor - the process requesting this operation
*
* id - the "id" string provided by the user at the time the
* affected monitoring operation was started. A NULL indicates
* that all operations started by this requestor are to
* be terminated */
typedef pmix_status_t (*pmix_psensor_base_module_stop_fn_t)(pmix_peer_t *requestor, char *id);
/* API module */
/*
* Ver 1.0
*/
typedef struct pmix_psensor_base_module_1_0_0_t {
pmix_psensor_base_module_start_fn_t start;
pmix_psensor_base_module_stop_fn_t stop;
} pmix_psensor_base_module_t;
/*
* the standard component data structure
*/
typedef pmix_mca_base_component_t pmix_psensor_base_component_t;
/*
* Macro for use in components that are of type sensor v1.0.0
*/
#define PMIX_PSENSOR_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("psensor", 1, 0, 0)
/* Global structure for accessing sensor functions
*/
PMIX_EXPORT extern pmix_psensor_base_module_t pmix_psensor; /* holds API function pointers */
END_C_DECLS
#endif /* MCA_SENSOR_H */

View File

@@ -0,0 +1,83 @@
/* -*- C -*-
*
* Copyright (c) 2019 IBM Corporation. All rights reserved.
* Copyright (c) 2019 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PSQUASH_BASE_H_
#define PMIX_PSQUASH_BASE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "src/class/pmix_pointer_array.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/mca/psquash/psquash.h"
BEGIN_C_DECLS
/**
* Sizeof by PMIx type integer values.
*
* r - return status code
* t - type (pmix_data_type_t) of integer value
* s - size of type in bytes
* (see a comment to `pmix_bfrops_pack_flex` for additional details)
*/
#define PMIX_SQUASH_TYPE_SIZEOF(r, t, s) \
do { \
(r) = PMIX_SUCCESS; \
switch (t) { \
case PMIX_INT16: \
case PMIX_UINT16: \
(s) = SIZEOF_SHORT; \
break; \
case PMIX_INT: \
case PMIX_INT32: \
case PMIX_UINT: \
case PMIX_UINT32: \
(s) = SIZEOF_INT; \
break; \
case PMIX_INT64: \
case PMIX_UINT64: \
(s) = SIZEOF_LONG; \
break; \
case PMIX_SIZE: \
(s) = SIZEOF_SIZE_T; \
break; \
default: \
(r) = PMIX_ERR_BAD_PARAM; \
} \
} while (0)
struct pmix_psquash_globals_t {
bool initialized;
bool selected;
};
typedef struct pmix_psquash_globals_t pmix_psquash_globals_t;
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_psquash_base_framework;
PMIX_EXPORT pmix_status_t pmix_psquash_base_select(void);
PMIX_EXPORT extern pmix_psquash_globals_t pmix_psquash_globals;
END_C_DECLS
#endif

View File

@@ -0,0 +1,118 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2019 IBM Corporation. All rights reserved.
* Copyright (c) 2019 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* This interface is for the encoding/decoding of basic types and the
* compression/decompression of larger blobs of data (i.e., modex).
*
* Available plugins may be defined at runtime via the typical MCA parameter
* syntax.
*/
#ifndef PMIX_PSQUASH_H
#define PMIX_PSQUASH_H
#include "src/include/pmix_config.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/mca.h"
BEGIN_C_DECLS
/****** MODULE DEFINITION ******/
/**
* Initialize the module
*/
typedef pmix_status_t (*pmix_psquash_base_module_init_fn_t)(void);
/**
* Finalize the module
*/
typedef void (*pmix_psquash_base_module_finalize_fn_t)(void);
/**
* Maximum size of the type.
*
* type - Type (PMIX_SIZE, PMIX_INT to PMIX_UINT64)
* size - size of the type
*/
typedef pmix_status_t (*pmix_psquash_get_max_size_fn_t)(pmix_data_type_t type, size_t *size);
/**
* Encode a basic integer type into a contiguous destination buffer.
*
* type - Type of the 'src' pointer (PMIX_SIZE, PMIX_INT to PMIX_UINT64)
* src - pointer to a single basic integer type
* dest - pointer to buffer to store data
* dst_len - pointer to the packed size of dest, in bytes
*/
typedef pmix_status_t (*pmix_psquash_encode_int_fn_t)(pmix_data_type_t type, void *src, void *dest,
size_t *dst_len);
/**
* Decode a basic a contiguous destination buffer into a basic integer type.
*
* type - Type of the 'dest' pointer (PMIX_SIZE, PMIX_INT to PMIX_UINT64)
* src - pointer to buffer where data was stored
* src_len - length, in bytes, of the src buffer
* dest - pointer to a single basic integer type
* dst_len - pointer to the unpacked size of dest, in bytes
*/
typedef pmix_status_t (*pmix_psquash_decode_int_fn_t)(pmix_data_type_t type, void *src,
size_t src_len, void *dest, size_t *dst_len);
/**
* Base structure for a PSQUASH module
*/
typedef struct {
const char *name;
/* flag indicating if the type is encoded within the value, otherwise, it is necessary to
* further pack the type with the value. */
bool int_type_is_encoded;
/** init/finalize */
pmix_psquash_base_module_init_fn_t init;
pmix_psquash_base_module_finalize_fn_t finalize;
pmix_psquash_get_max_size_fn_t get_max_size;
/** Integer compression */
pmix_psquash_encode_int_fn_t encode_int;
pmix_psquash_decode_int_fn_t decode_int;
} pmix_psquash_base_module_t;
/**
* Base structure for a PSQUASH component
*/
struct pmix_psquash_base_component_t {
pmix_mca_base_component_t base;
int priority;
};
typedef struct pmix_psquash_base_component_t pmix_psquash_base_component_t;
PMIX_EXPORT extern pmix_psquash_base_module_t pmix_psquash;
/*
* Macro for use in components that are of type psquash
*/
#define PMIX_PSQUASH_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("psquash", 1, 0, 0)
END_C_DECLS
#endif

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2020 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2019 Intel, Inc. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PSTAT_BASE_H
#define PMIX_PSTAT_BASE_H
#include "pmix_config.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/pstat/pstat.h"
/*
* Global functions for MCA overall pstat open and close
*/
BEGIN_C_DECLS
/**
* Framework structure declaration for this framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pstat_base_framework;
/**
* Select an available component.
*
* @return PMIX_SUCCESS Upon success.
* @return PMIX_NOT_FOUND If no component can be selected.
* @return PMIX_ERROR Upon other failure.
*
* At the end of this process, we'll either have a single
* component that is selected and initialized, or no component was
* selected. If no component was selected, subsequent invocation
* of the pstat functions will return an error indicating no data
* could be obtained
*/
PMIX_EXPORT int pmix_pstat_base_select(void);
PMIX_EXPORT extern pmix_pstat_base_component_t *pmix_pstat_base_component;
END_C_DECLS
#endif /* PMIX_BASE_PSTAT_H */

View File

@@ -0,0 +1,82 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2008 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
*
* Copyright (c) 2019 Intel, Inc. All rights reserved.
* Copyright (c) 2020 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* pstat (process statistics) framework component interface.
*
* Intent
*
* To support the ompi-top utility.
*
*/
#ifndef PMIX_MCA_PSTAT_H
#define PMIX_MCA_PSTAT_H
#include "pmix_config.h"
#include "pmix_common.h"
#include "src/mca/base/pmix_base.h"
#include "src/mca/mca.h"
BEGIN_C_DECLS
/**
* Module initialization function. Should return PMIX_SUCCESS.
*/
typedef int (*pmix_pstat_base_module_init_fn_t)(void);
typedef int (*pmix_pstat_base_module_query_fn_t)(pid_t pid, pmix_proc_stats_t *stats,
pmix_node_stats_t *nstats);
typedef int (*pmix_pstat_base_module_fini_fn_t)(void);
/**
* Structure for pstat components.
*/
typedef pmix_mca_base_component_t pmix_pstat_base_component_t;
/**
* Structure for pstat modules
*/
struct pmix_pstat_base_module_1_0_0_t {
pmix_pstat_base_module_init_fn_t init;
pmix_pstat_base_module_query_fn_t query;
pmix_pstat_base_module_fini_fn_t finalize;
};
/**
* Convenience typedef
*/
typedef struct pmix_pstat_base_module_1_0_0_t pmix_pstat_base_module_1_0_0_t;
typedef struct pmix_pstat_base_module_1_0_0_t pmix_pstat_base_module_t;
/**
* Macro for use in components that are of type pstat
*/
#define PMIX_PSTAT_BASE_VERSION_1_0_0 PMIX_MCA_BASE_VERSION_1_0_0("pstat", 1, 0, 0)
/* Global structure for accessing pstat functions */
PMIX_EXPORT extern pmix_pstat_base_module_t pmix_pstat;
END_C_DECLS
#endif /* PMIX_MCA_PSTAT_H */

View File

@@ -0,0 +1,184 @@
/* -*- C -*-
*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
* Copyright (c) 2023 Triad National Security, LLC. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PTL_BASE_H_
#define PMIX_PTL_BASE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for struct timeval */
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "src/class/pmix_pointer_array.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/mca.h"
#include "src/include/pmix_globals.h"
#include "src/include/pmix_stdatomic.h"
#include "src/mca/ptl/base/ptl_base_handshake.h"
#include "src/mca/ptl/ptl.h"
BEGIN_C_DECLS
/*
* MCA Framework
*/
PMIX_EXPORT extern pmix_mca_base_framework_t pmix_ptl_base_framework;
/**
* PTL select function
*
* Cycle across available components and construct the list
* of active modules
*/
PMIX_EXPORT pmix_status_t pmix_ptl_base_select(void);
/* framework globals */
struct pmix_ptl_base_t {
bool initialized;
bool selected;
pmix_list_t posted_recvs; // list of pmix_ptl_posted_recv_t
pmix_list_t unexpected_msgs;
pmix_listener_t listener;
struct sockaddr_storage *connection;
uint32_t current_tag;
size_t max_msg_size;
char *session_tmpdir;
char *system_tmpdir;
char *report_uri;
char *uri;
char *urifile;
char *sysctrlr_filename;
char *scheduler_filename;
char *system_filename;
char *session_filename;
char *nspace_filename;
char *pid_filename;
char *rendezvous_filename;
bool created_rendezvous_file;
bool created_session_tmpdir;
bool created_system_tmpdir;
bool created_sysctrlr_filename;
bool created_scheduler_filename;
bool created_system_filename;
bool created_session_filename;
bool created_nspace_filename;
bool created_pid_filename;
bool created_urifile;
bool remote_connections;
bool system_tool;
bool session_tool;
bool tool_support;
char *if_include;
char *if_exclude;
int ipv4_port;
bool disable_ipv4_family;
int ipv6_port;
bool disable_ipv6_family;
int max_retries;
int wait_to_connect;
int handshake_wait_time;
int handshake_max_retries;
};
typedef struct pmix_ptl_base_t pmix_ptl_base_t;
PMIX_EXPORT extern pmix_ptl_base_t pmix_ptl_base;
typedef struct {
pmix_list_item_t super;
int sd;
char *nspace;
pmix_rank_t rank;
char *uri;
char *version;
} pmix_connection_t;
PMIX_CLASS_DECLARATION(pmix_connection_t);
/* API stubs */
PMIX_EXPORT pmix_status_t pmix_ptl_base_set_notification_cbfunc(pmix_ptl_cbfunc_t cbfunc);
PMIX_EXPORT pmix_status_t pmix_ptl_base_connect_to_peer(struct pmix_peer_t *peer,
pmix_info_t info[], size_t ninfo,
char **suri);
PMIX_EXPORT pmix_status_t pmix_ptl_base_parse_uri_file(char *filename,
bool optional,
pmix_list_t *connections);
PMIX_EXPORT pmix_status_t pmix_ptl_base_setup_connection(char *uri,
struct sockaddr_storage *connection,
size_t *len);
PMIX_EXPORT void pmix_ptl_base_post_recv(int fd, short args, void *cbdata);
PMIX_EXPORT void pmix_ptl_base_cancel_recv(int sd, short args, void *cbdata);
PMIX_EXPORT pmix_status_t pmix_ptl_base_start_listening(pmix_info_t info[], size_t ninfo);
PMIX_EXPORT void pmix_ptl_base_stop_listening(void);
PMIX_EXPORT pmix_status_t pmix_base_write_rndz_file(char *filename, char *uri, bool *created);
/* base support functions */
PMIX_EXPORT pmix_status_t pmix_ptl_base_check_server_uris(pmix_peer_t *peer, char **evar);
PMIX_EXPORT pmix_status_t pmix_ptl_base_check_directives(pmix_info_t *info, size_t ninfo);
PMIX_EXPORT pmix_status_t pmix_ptl_base_setup_fork(const pmix_proc_t *proc, char ***env);
PMIX_EXPORT void pmix_ptl_base_send_handler(int sd, short flags, void *cbdata);
PMIX_EXPORT void pmix_ptl_base_recv_handler(int sd, short flags, void *cbdata);
PMIX_EXPORT void pmix_ptl_base_process_msg(int fd, short flags, void *cbdata);
PMIX_EXPORT pmix_status_t pmix_ptl_base_set_nonblocking(int sd);
PMIX_EXPORT pmix_status_t pmix_ptl_base_set_blocking(int sd);
PMIX_EXPORT pmix_status_t pmix_ptl_base_send_blocking(int sd, char *ptr, size_t size);
PMIX_EXPORT pmix_status_t pmix_ptl_base_recv_blocking(int sd, char *data, size_t size);
PMIX_EXPORT pmix_status_t pmix_ptl_base_connect(struct sockaddr_storage *addr, pmix_socklen_t len,
int *fd);
PMIX_EXPORT void pmix_ptl_base_connection_handler(int sd, short args, void *cbdata);
PMIX_EXPORT pmix_status_t pmix_ptl_base_setup_listener(pmix_info_t info[], size_t ninfo);
PMIX_EXPORT pmix_status_t pmix_ptl_base_send_connect_ack(int sd);
PMIX_EXPORT pmix_status_t pmix_ptl_base_recv_connect_ack(int sd);
PMIX_EXPORT void pmix_ptl_base_lost_connection(pmix_peer_t *peer, pmix_status_t err);
PMIX_EXPORT bool pmix_ptl_base_peer_is_earlier(pmix_peer_t *peer, uint8_t major, uint8_t minor,
uint8_t release);
PMIX_EXPORT void pmix_ptl_base_query_servers(int sd, short args, void *cbdata);
PMIX_EXPORT pmix_status_t pmix_ptl_base_parse_uri(const char *evar, char **nspace,
pmix_rank_t *rank, char **suri);
PMIX_EXPORT pmix_status_t pmix_ptl_base_df_search(char *dirname, char *prefix, pmix_info_t info[],
size_t ninfo, bool optional, pmix_list_t *connections);
PMIX_EXPORT pmix_rnd_flag_t pmix_ptl_base_set_flag(size_t *sz);
PMIX_EXPORT pmix_status_t pmix_ptl_base_make_connection(pmix_peer_t *peer, char *suri,
pmix_info_t *iptr, size_t niptr);
PMIX_EXPORT void pmix_ptl_base_complete_connection(pmix_peer_t *peer, char *nspace,
pmix_rank_t rank);
PMIX_EXPORT pmix_status_t pmix_ptl_base_set_timeout(pmix_peer_t *peer, struct timeval *save,
pmix_socklen_t *sz, bool *sockopt);
PMIX_EXPORT void pmix_ptl_base_setup_socket(pmix_peer_t *peer);
PMIX_EXPORT pmix_status_t pmix_ptl_base_client_handshake(pmix_peer_t *peer, pmix_status_t reply);
PMIX_EXPORT pmix_status_t pmix_ptl_base_tool_handshake(pmix_peer_t *peer, pmix_status_t rp);
PMIX_EXPORT char **pmix_ptl_base_split_and_resolve(const char *orig_str,
const char *name);
PMIX_EXPORT pmix_status_t pmix_ptl_base_set_peer(pmix_peer_t *peer, char *evar);
PMIX_EXPORT char *pmix_ptl_base_get_cmd_line(void);
END_C_DECLS
#endif

View File

@@ -0,0 +1,215 @@
/* -*- C -*-
*
* Copyright (c) 2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef PMIX_PTL_BASE_HANDSHAKE_H_
#define PMIX_PTL_BASE_HANDSHAKE_H_
#include "src/include/pmix_config.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
/* The following macros are for use in the PTL connection
* handler. For simplicity, they include variables that are
* defined in the functions where they are used - thus, these
* macros are NOT portable for use elsewhere
*
* A symmetric pair of macros are provided specifically to
* make it easier to read and compare the two ends of the
* handshake */
BEGIN_C_DECLS
/* define flag values that indicate the type of process attempting
* to connect to a server:
* 0 => simple client process
* 1 => legacy tool - may or may not have an identifier
* 2 => legacy launcher - may or may not have an identifier
* ------------------------------------------
* 3 => self-started tool process that needs an identifier
* 4 => self-started tool process that was given an identifier by caller
* 5 => tool that was started by a PMIx server - identifier specified by server
* 6 => self-started launcher that needs an identifier
* 7 => self-started launcher that was given an identifier by caller
* 8 => launcher that was started by a PMIx server - identifier specified by server
* 9 => singleton client - treated like a tool that has an identifier
* ------------------------------------------
* 10 => scheduler
*/
typedef uint8_t pmix_rnd_flag_t;
#define PMIX_SIMPLE_CLIENT 0
#define PMIX_LEGACY_TOOL 1
#define PMIX_LEGACY_LAUNCHER 2
#define PMIX_TOOL_NEEDS_ID 3
#define PMIX_TOOL_GIVEN_ID 4
#define PMIX_TOOL_CLIENT 5
#define PMIX_LAUNCHER_NEEDS_ID 6
#define PMIX_LAUNCHER_GIVEN_ID 7
#define PMIX_LAUNCHER_CLIENT 8
#define PMIX_SINGLETON_CLIENT 9
#define PMIX_SCHEDULER_WITH_ID 10
/* The following macros are used in the ptl_base_connection_hdlr.c
* file to parse the handshake message and extract its fields */
#define PMIX_PTL_GET_STRING(n) \
do { \
size_t _l; \
PMIX_STRNLEN(_l, mg, cnt); \
if (_l < cnt) { \
(n) = strdup(mg); \
mg += strlen((n)) + 1; \
cnt -= strlen((n)) + 1; \
} else { \
PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); \
goto error; \
} \
} while (0)
/* numerical value must be converted back to host
* order, so we use an intermediate storage place
* for that purpose */
#define PMIX_PTL_GET_U32_NOERROR(r, n) \
do { \
uint32_t _u; \
if (sizeof(uint32_t) <= cnt) { \
memcpy(&_u, mg, sizeof(uint32_t)); \
(n) = ntohl(_u); \
mg += sizeof(uint32_t); \
cnt -= sizeof(uint32_t); \
(r) = PMIX_SUCCESS; \
} else { \
(r) = PMIX_ERR_BAD_PARAM; \
} \
} while (0)
#define PMIX_PTL_GET_U32(n) \
do { \
uint32_t _u; \
if (sizeof(uint32_t) <= cnt) { \
memcpy(&_u, mg, sizeof(uint32_t)); \
(n) = ntohl(_u); \
mg += sizeof(uint32_t); \
cnt -= sizeof(uint32_t); \
} else { \
PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); \
goto error; \
} \
} while (0)
#define PMIX_PTL_GET_BLOB(b, l) \
do { \
if (0 < (l)) { \
(b) = (char *) malloc((l)); \
if (NULL == (b)) { \
PMIX_ERROR_LOG(PMIX_ERR_NOMEM); \
goto error; \
} \
memcpy((b), mg, (l)); \
mg += (l); \
cnt -= (l); \
} \
} while (0)
#define PMIX_PTL_GET_U8(n) \
do { \
if (sizeof(uint8_t) <= cnt) { \
memcpy(&(n), mg, sizeof(uint8_t)); \
mg += sizeof(uint8_t); \
cnt -= sizeof(uint8_t); \
} else { \
PMIX_ERROR_LOG(PMIX_ERR_BAD_PARAM); \
goto error; \
} \
} while (0)
#define PMIX_PTL_GET_PROCID(p) \
do { \
char *n; \
uint32_t _r; \
pmix_status_t _rc; \
PMIX_PTL_GET_STRING(n); \
PMIX_PTL_GET_U32_NOERROR(_rc, _r); \
if (PMIX_SUCCESS != _rc) { \
PMIX_ERROR_LOG(_rc); \
free(n); \
goto error; \
} \
PMIX_LOAD_PROCID(&(p), n, _r); \
free(n); \
} while (0)
/* The following macros are for use in the ptl_base_fns.c
* when constructing the handshake message. */
#define PMIX_PTL_PUT_STRING(n) \
do { \
memcpy(msg + csize, (n), strlen((n))); \
csize += strlen((n)) + 1; \
} while (0)
/* numerical value must be converted to network byte
* order, so we use an intermediate storage place
* for that purpose */
#define PMIX_PTL_PUT_U32(n) \
do { \
uint32_t _u; \
_u = htonl((uint32_t)(n)); \
memcpy(msg + csize, &_u, sizeof(uint32_t)); \
csize += sizeof(uint32_t); \
} while (0)
#define PMIX_PTL_PUT_BLOB(b, l) \
do { \
if (0 < (l)) { \
memcpy(msg + csize, (b), (l)); \
csize += (l); \
} \
} while (0)
#define PMIX_PTL_PUT_U8(n) \
do { \
memcpy(msg + csize, &(n), sizeof(uint8_t)); \
csize += sizeof(uint8_t); \
} while (0)
#define PMIX_PTL_PUT_PROCID(p) \
do { \
PMIX_PTL_PUT_STRING((p).nspace); \
PMIX_PTL_PUT_U32((p).rank); \
} while (0)
/* the following macros are for use in the ptl_base_fns.c
* when sending/recving values during the handshake */
#define PMIX_PTL_RECV_NSPACE(s, n) \
do { \
pmix_status_t r; \
r = pmix_ptl_base_recv_blocking((s), (char *) (n), PMIX_MAX_NSLEN + 1); \
(n)[PMIX_MAX_NSLEN] = '\0'; /* ensure NULL termination */ \
if (PMIX_SUCCESS != r) { \
return r; \
} \
} while (0)
#define PMIX_PTL_RECV_U32(s, n) \
do { \
pmix_status_t r; \
uint32_t _u; \
r = pmix_ptl_base_recv_blocking((s), (char *) &_u, sizeof(uint32_t)); \
if (PMIX_SUCCESS != r) { \
return r; \
} \
(n) = htonl(_u); \
} while (0)
END_C_DECLS
#endif

View File

@@ -0,0 +1,222 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Data packing subsystem.
*/
#ifndef PMIX_PTL_H_
#define PMIX_PTL_H_
#include "src/include/pmix_config.h"
#include "src/include/pmix_types.h"
#include "src/mca/base/pmix_mca_base_framework.h"
#include "src/mca/base/pmix_mca_base_var.h"
#include "src/mca/bfrops/bfrops_types.h"
#include "src/mca/mca.h"
#include "ptl_types.h"
BEGIN_C_DECLS
/* forward declaration */
struct pmix_peer_t;
/* The overall objective of this framework is to provide transport
* options by which a server can communicate with a client:
*
* (a) across different versions of the library - e.g., when the
* connection handshake changes.
*
* (b) using different transports as necessitated by different
* environments.
*
* This is a single-select framework - i.e., only one component
* is selected and "active" at a time. The intent is
* to have one component for each use-case, with the
* expectation that the community will do its best not to revise
* communications in manners that expand components to support (a).
* Thus, new variations should be rare, and only a few components
* will exist.
*/
/**** MODULE INTERFACE DEFINITION ****/
/* initialize the active plugin */
typedef pmix_status_t (*pmix_ptl_init_fn_t)(void);
/* finalize the active plugin */
typedef void (*pmix_ptl_finalize_fn_t)(void);
/* (ONE-WAY) register a persistent recv */
typedef pmix_status_t (*pmix_ptl_recv_fn_t)(struct pmix_peer_t *peer, pmix_ptl_cbfunc_t cbfunc,
pmix_ptl_tag_t tag);
/* Cancel a persistent recv */
typedef pmix_status_t (*pmix_ptl_cancel_fn_t)(struct pmix_peer_t *peer, pmix_ptl_tag_t tag);
/* connect to a peer - this is a blocking function
* to establish a connection to a peer*/
typedef pmix_status_t (*pmix_ptl_connect_to_peer_fn_t)(struct pmix_peer_t *peer,
pmix_info_t info[],
size_t ninfo,
char **suri);
/* query available servers on the local node */
typedef void (*pmix_ptl_query_servers_fn_t)(char *dirname, pmix_list_t *servers);
/* define an API for establishing a
* communication rendezvous point for local procs. The active component
* is given an opportunity to register a listener with the
* PTL base */
typedef pmix_status_t (*pmix_ptl_setup_listener_fn_t)(pmix_info_t info[], size_t ninfo);
/* define an API for obtaining any envars that are to
* be passed to client procs upon fork */
typedef pmix_status_t (*pmix_ptl_setup_fork_fn_t)(const pmix_proc_t *proc, char ***env);
/**
* Base structure for a PTL module
*/
struct pmix_ptl_module_t {
char *name;
pmix_ptl_init_fn_t init;
pmix_ptl_finalize_fn_t finalize;
pmix_ptl_recv_fn_t recv;
pmix_ptl_cancel_fn_t cancel;
pmix_ptl_connect_to_peer_fn_t connect_to_peer;
pmix_ptl_query_servers_fn_t query_servers;
pmix_ptl_setup_listener_fn_t setup_listener;
pmix_ptl_setup_fork_fn_t setup_fork;
};
typedef struct pmix_ptl_module_t pmix_ptl_module_t;
/***** MACROS FOR EXECUTING PTL FUNCTIONS *****/
/* (TWO-WAY) send a message to the peer, and get a response delivered
* to the specified callback function. The buffer will be free'd
* at the completion of the send, and the cbfunc will be called
* when the corresponding reply is received */
#define PMIX_PTL_SEND_RECV(r, p, b, c, d) \
do { \
pmix_ptl_sr_t *ms; \
pmix_peer_t *pr = (pmix_peer_t *) (p); \
if ((p)->finalized) { \
(r) = PMIX_ERR_UNREACH; \
} else { \
ms = PMIX_NEW(pmix_ptl_sr_t); \
PMIX_RETAIN(pr); \
ms->peer = pr; \
ms->bfr = (b); \
ms->cbfunc = (c); \
ms->cbdata = (d); \
PMIX_THREADSHIFT(ms, pmix_ptl_base_send_recv); \
(r) = PMIX_SUCCESS; \
} \
} while (0)
/* (ONE-WAY) send a message to the peer. The buffer will be free'd
* at the completion of the send */
#define PMIX_PTL_SEND_ONEWAY(r, p, b, t) \
do { \
pmix_ptl_queue_t *q; \
pmix_peer_t *pr = (pmix_peer_t *) (p); \
if ((p)->finalized) { \
(r) = PMIX_ERR_UNREACH; \
} else { \
q = PMIX_NEW(pmix_ptl_queue_t); \
PMIX_RETAIN(pr); \
q->peer = pr; \
q->buf = (b); \
q->tag = (t); \
PMIX_THREADSHIFT(q, pmix_ptl_base_send); \
(r) = PMIX_SUCCESS; \
} \
} while (0)
#define PMIX_PTL_RECV(r, c, t) \
do { \
pmix_ptl_posted_recv_t *req; \
req = PMIX_NEW(pmix_ptl_posted_recv_t); \
if (NULL == req) { \
(r) = PMIX_ERR_NOMEM; \
} else { \
req->tag = (t); \
req->cbfunc = (c); \
pmix_event_assign(&(req->ev), pmix_globals.evbase, -1, EV_WRITE, \
pmix_ptl_base_post_recv, req); \
pmix_event_active(&(req->ev), EV_WRITE, 1); \
(r) = PMIX_SUCCESS; \
} \
} while (0)
#define PMIX_PTL_CANCEL(r, t) \
do { \
pmix_ptl_posted_recv_t *req; \
req = PMIX_NEW(pmix_ptl_posted_recv_t); \
if (NULL == req) { \
(r) = PMIX_ERR_NOMEM; \
} else { \
req->tag = (t); \
pmix_event_assign(&(req->ev), pmix_globals.evbase, -1, EV_WRITE, \
pmix_ptl_base_cancel_recv, req); \
pmix_event_active(&(req->ev), EV_WRITE, 1); \
(r) = PMIX_SUCCESS; \
} \
} while (0)
/* expose functions used by the macros */
PMIX_EXPORT extern void pmix_ptl_base_send(int sd, short args, void *cbdata);
PMIX_EXPORT extern void pmix_ptl_base_send_recv(int sd, short args, void *cbdata);
PMIX_EXPORT extern void pmix_ptl_base_register_recv(int sd, short args, void *cbdata);
PMIX_EXPORT extern void pmix_ptl_base_cancel_recv(int sd, short args, void *cbdata);
/**** COMPONENT STRUCTURE DEFINITION ****/
/*
* the standard component data structure
*/
struct pmix_ptl_base_component_t {
pmix_mca_base_component_t base;
int priority;
char *uri;
};
typedef struct pmix_ptl_base_component_t pmix_ptl_base_component_t;
/* export the PTL module struct */
PMIX_EXPORT extern pmix_ptl_module_t pmix_ptl;
/*
* Macro for use in components that are of type ptl
*/
#define PMIX_PTL_BASE_VERSION_2_0_0 PMIX_MCA_BASE_VERSION_1_0_0("ptl", 2, 0, 0)
END_C_DECLS
#endif /* PMIX_PTL_H */

View File

@@ -0,0 +1,435 @@
/* -*- C -*-
*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved.
* Copyright (c) 2014-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Buffer management types.
*/
#ifndef PMIX_PTL_TYPES_H_
#define PMIX_PTL_TYPES_H_
#include "src/include/pmix_config.h"
#include "src/include/pmix_types.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#ifdef HAVE_NET_UIO_H
# include <net/uio.h>
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#include <event.h>
#include "src/class/pmix_list.h"
#include "src/include/pmix_stdatomic.h"
#include "src/mca/bfrops/bfrops_types.h"
#include "src/mca/ptl/base/ptl_base_handshake.h"
#include "src/util/pmix_output.h"
BEGIN_C_DECLS
// forward declaration
struct pmix_peer_t;
struct pmix_ptl_module_t;
/* define a process type */
typedef struct {
uint32_t type;
uint8_t major;
uint8_t minor;
uint8_t release;
uint8_t flag; // see pmix_ptl_base_set_flag for definition of values
} pmix_proc_type_t;
#define PMIX_MAJOR_WILDCARD 255
#define PMIX_MINOR_WILDCARD 255
#define PMIX_RELEASE_WILDCARD 255
/* use 255 as WILDCARD for the release triplet values */
#define PMIX_PROC_TYPE_STATIC_INIT \
{ \
.type = PMIX_PROC_UNDEF, \
.major = PMIX_MAJOR_WILDCARD, \
.minor = PMIX_MINOR_WILDCARD, \
.release = PMIX_RELEASE_WILDCARD, \
.flag = 0 \
}
/* Define process types - we use a bit-mask as procs can
* span multiple types */
#define PMIX_PROC_UNDEF 0x00000000
#define PMIX_PROC_CLIENT 0x00000001 // simple client process
#define PMIX_PROC_SERVER 0x00000002 // simple server process
#define PMIX_PROC_TOOL 0x00000004 // simple tool
#define PMIX_PROC_SINGLETON_ACT 0x00000008 // self-started client process
#define PMIX_PROC_SINGLETON (PMIX_PROC_CLIENT | PMIX_PROC_SINGLETON_ACT)
#define PMIX_PROC_LAUNCHER_ACT 0x10000000 // process acting as launcher
#define PMIX_PROC_LAUNCHER (PMIX_PROC_TOOL | PMIX_PROC_SERVER | PMIX_PROC_LAUNCHER_ACT)
#define PMIX_PROC_CLIENT_LAUNCHER (PMIX_PROC_LAUNCHER | PMIX_PROC_CLIENT)
#define PMIX_PROC_CLIENT_TOOL_ACT 0x20000000
#define PMIX_PROC_CLIENT_TOOL (PMIX_PROC_TOOL | PMIX_PROC_CLIENT | PMIX_PROC_CLIENT_TOOL_ACT)
#define PMIX_PROC_GATEWAY_ACT 0x40000000
#define PMIX_PROC_GATEWAY (PMIX_PROC_SERVER | PMIX_PROC_GATEWAY_ACT)
#define PMIX_PROC_SCHEDULER_ACT 0x80000000
#define PMIX_PROC_SCHEDULER (PMIX_PROC_SERVER | PMIX_PROC_SCHEDULER_ACT)
#define PMIX_PROC_SYS_CTRLR_ACT 0x01000000
#define PMIX_PROC_SYS_CTRLR (PMIX_PROC_SERVER | PMIX_PROC_SYS_CTRLR_ACT)
#define PMIX_SET_PEER_TYPE(a, b) (a)->proc_type.type |= (b)
#define PMIX_SET_PROC_TYPE(a, b) (a)->type |= (b)
/* define some convenience macros for testing proc type */
#define PMIX_PEER_IS_CLIENT(p) (PMIX_PROC_CLIENT & (p)->proc_type.type)
#define PMIX_PEER_IS_SINGLETON(p) (PMIX_PROC_SINGLETON_ACT & (p)->proc_type.type)
#define PMIX_PEER_IS_SERVER(p) (PMIX_PROC_SERVER & (p)->proc_type.type)
#define PMIX_PEER_IS_TOOL(p) (PMIX_PROC_TOOL & (p)->proc_type.type)
#define PMIX_PEER_IS_LAUNCHER(p) (PMIX_PROC_LAUNCHER_ACT & (p)->proc_type.type)
#define PMIX_PEER_IS_CLIENT_LAUNCHER(p) \
((PMIX_PROC_LAUNCHER_ACT & (p)->proc_type.type) && (PMIX_PROC_CLIENT & (p)->proc_type.type))
#define PMIX_PEER_IS_CLIENT_TOOL(p) \
((PMIX_PROC_CLIENT_TOOL_ACT & (p)->proc_type.type) && (PMIX_PROC_CLIENT & (p)->proc_type.type))
#define PMIX_PEER_IS_GATEWAY(p) (PMIX_PROC_GATEWAY_ACT & (p)->proc_type.type)
#define PMIX_PEER_IS_SCHEDULER(p) (PMIX_PROC_SCHEDULER_ACT & (p)->proc_type.type)
#define PMIX_PEER_IS_SYS_CTRLR(p) (PMIX_PROC_SYS_CTRLR_ACT & (p)->proc_type.type)
#define PMIX_PROC_IS_CLIENT(p) (PMIX_PROC_CLIENT & (p)->type)
#define PMIX_PROC_IS_SERVER(p) (PMIX_PROC_SERVER & (p)->type)
#define PMIX_PROC_IS_TOOL(p) (PMIX_PROC_TOOL & (p)->type)
#define PMIX_PROC_IS_LAUNCHER(p) (PMIX_PROC_LAUNCHER_ACT & (p)->type)
#define PMIX_PROC_IS_CLIENT_LAUNCHER(p) \
((PMIX_PROC_LAUNCHER_ACT & (p)->type) && (PMIX_PROC_CLIENT & (p)->type))
#define PMIX_PROC_IS_CLIENT_TOOL(p) \
((PMIX_PROC_CLIENT_TOOL_ACT & (p)->type) && (PMIX_PROC_CLIENT & (p)->type))
#define PMIX_PROC_IS_GATEWAY(p) (PMIX_PROC_GATEWAY_ACT & (p)->type)
#define PMIX_PROC_IS_SCHEDULER(p) (PMIX_PROC_SCHEDULER_ACT & (p)->type)
#define PMIX_PROC_IS_SYS_CTRLR(p) (PMIX_PROC_SYS_CTRLR_ACT & (p)->type)
/* provide macros for setting the major, minor, and release values
* just so people don't have to deal with the details of the struct */
#define PMIX_SET_PEER_VERSION(p, e, a, b) \
do { \
char *e2; \
unsigned long mj, mn, rl; \
if (NULL != e) { \
if ('v' == e[0]) { \
mj = strtoul(&e[1], &e2, 10); \
} else { \
mj = strtoul(e, &e2, 10); \
} \
++e2; \
mn = strtoul(e2, &e2, 10); \
++e2; \
rl = strtoul(e2, NULL, 10); \
PMIX_SET_PEER_MAJOR((p), mj); \
PMIX_SET_PEER_MINOR((p), mn); \
PMIX_SET_PEER_RELEASE((p), rl); \
} else { \
PMIX_SET_PEER_MAJOR((p), (a)); \
PMIX_SET_PEER_MINOR((p), (b)); \
} \
} while (0)
#define PMIX_SET_PEER_MAJOR(p, a) (p)->proc_type.major = (a)
#define PMIX_SET_PEER_MINOR(p, a) (p)->proc_type.minor = (a)
#define PMIX_SET_PEER_RELEASE(p, a) (p)->proc_type.release = (a)
#define PMIX_SET_PROC_MAJOR(p, a) (p)->major = (a)
#define PMIX_SET_PROC_MINOR(p, a) (p)->minor = (a)
#define PMIX_SET_PROC_RELEASE(p, a) (p)->release = (a)
/* define some convenience macros for testing version */
#define PMIX_PEER_MAJOR_VERSION(p) (p)->proc_type.major
#define PMIX_PEER_MINOR_VERSION(p) (p)->proc_type.minor
#define PMIX_PEER_REL_VERSION(p) (p)->proc_type.release
#define PMIX_PROC_MAJOR_VERSION(p) (p)->major
#define PMIX_PROC_MINOR_VERSION(p) (p)->minor
#define PMIX_PROC_REL_VERSION(p) (p)->release
#define PMIX_PEER_IS_V1(p) ((p)->proc_type.major == 1)
#define PMIX_PEER_IS_V20(p) ((p)->proc_type.major == 2 && (p)->proc_type.minor == 0)
#define PMIX_PEER_IS_V21(p) ((p)->proc_type.major == 2 && (p)->proc_type.minor == 1)
#define PMIX_PEER_IS_V3(p) ((p)->proc_type.major == 3)
#define PMIX_PEER_IS_V40(p) ((p)->proc_type.major == 4 && (p)->proc_type.minor == 0)
#define PMIX_PEER_IS_V41(p) ((p)->proc_type.major == 4 && (p)->proc_type.minor == 1)
#define PMIX_PEER_TRIPLET(p, a, b, c) \
((PMIX_PEER_MAJOR_VERSION(p) == PMIX_MAJOR_WILDCARD || (a) == PMIX_MAJOR_WILDCARD \
|| PMIX_PEER_MAJOR_VERSION(p) == (a)) \
&& (PMIX_PEER_MINOR_VERSION(p) == PMIX_MINOR_WILDCARD || (b) == PMIX_MINOR_WILDCARD \
|| PMIX_PEER_MINOR_VERSION(p) == (b)) \
&& (PMIX_PEER_REL_VERSION(p) == PMIX_RELEASE_WILDCARD || (c) == PMIX_RELEASE_WILDCARD \
|| PMIX_PEER_REL_VERSION(p) == (c)))
#define PMIX_PROC_TRIPLET(p, a, b, c) \
((PMIX_PROC_MAJOR_VERSION(p) == PMIX_MAJOR_WILDCARD || PMIX_PROC_MAJOR_VERSION(p) == (a)) \
&& (PMIX_PROC_MINOR_VERSION(p) == PMIX_MINOR_WILDCARD || PMIX_PROC_MINOR_VERSION(p) == (b)) \
&& (PMIX_PROC_REL_VERSION(p) == PMIX_RELEASE_WILDCARD || PMIX_PROC_REL_VERSION(p) == (c)))
#define PMIX_PEER_IS_EARLIER(p, a, b, c) pmix_ptl_base_peer_is_earlier(p, a, b, c)
/**** MESSAGING STRUCTURES ****/
typedef uint32_t pmix_ptl_tag_t;
/* define a range of "reserved" tags - these
* are tags that are used for persistent recvs
* within the system */
#define PMIX_PTL_TAG_NOTIFY 0
#define PMIX_PTL_TAG_HEARTBEAT 1
#define PMIX_PTL_TAG_IOF 2
/* define the start of dynamic tags that are
* assigned for send/recv operations */
#define PMIX_PTL_TAG_DYNAMIC 100
/* header for messages */
typedef struct {
int32_t pindex;
pmix_ptl_tag_t tag;
uint32_t nbytes;
#if SIZEOF_SIZE_T == 8
uint32_t padding;
#endif
} pmix_ptl_hdr_t;
/* define the messaging cbfunc */
typedef void (*pmix_ptl_cbfunc_t)(struct pmix_peer_t *peer, pmix_ptl_hdr_t *hdr, pmix_buffer_t *buf,
void *cbdata);
/* define a callback function for notifying that server connection
* has completed */
typedef void (*pmix_ptl_connect_cbfunc_t)(pmix_status_t status, void *cbdata);
/* define a callback function for processing pending connections */
typedef void (*pmix_ptl_pending_cbfunc_t)(int sd, short args, void *cbdata);
/* structure for sending a message */
typedef struct {
pmix_list_item_t super;
pmix_event_t ev;
pmix_ptl_hdr_t hdr;
pmix_buffer_t *data;
bool hdr_sent;
char *sdptr;
size_t sdbytes;
} pmix_ptl_send_t;
PMIX_CLASS_DECLARATION(pmix_ptl_send_t);
/* structure for recving a message */
typedef struct {
pmix_list_item_t super;
pmix_event_t ev;
struct pmix_peer_t *peer;
int sd;
pmix_ptl_hdr_t hdr;
char *data;
bool hdr_recvd;
char *rdptr;
size_t rdbytes;
} pmix_ptl_recv_t;
PMIX_CLASS_DECLARATION(pmix_ptl_recv_t);
/* structure for tracking posted recvs */
typedef struct {
pmix_list_item_t super;
pmix_event_t ev;
uint32_t tag;
pmix_ptl_cbfunc_t cbfunc;
void *cbdata;
} pmix_ptl_posted_recv_t;
PMIX_CLASS_DECLARATION(pmix_ptl_posted_recv_t);
/* struct for posting send/recv request */
typedef struct {
pmix_object_t super;
volatile bool active;
pmix_event_t ev;
struct pmix_peer_t *peer;
pmix_status_t status;
pmix_buffer_t *bfr;
pmix_ptl_cbfunc_t cbfunc;
void *cbdata;
} pmix_ptl_sr_t;
PMIX_CLASS_DECLARATION(pmix_ptl_sr_t);
typedef struct {
pmix_object_t super;
volatile bool active;
pmix_event_t ev;
struct pmix_peer_t *peer;
pmix_buffer_t *buf;
pmix_ptl_tag_t tag;
} pmix_ptl_queue_t;
PMIX_CLASS_DECLARATION(pmix_ptl_queue_t);
/* define listener protocol types */
typedef uint16_t pmix_listener_protocol_t;
#define PMIX_PROTOCOL_UNDEF 0
#define PMIX_PROTOCOL_V1 1 // legacy usock
#define PMIX_PROTOCOL_V2 2 // tcp
/* connection support */
typedef struct {
pmix_object_t super;
pmix_event_t ev;
pmix_listener_protocol_t protocol;
int sd;
bool need_id;
pmix_rnd_flag_t flag;
pmix_proc_t proc;
pmix_info_t *info;
size_t ninfo;
pmix_status_t status;
struct sockaddr_storage addr;
struct pmix_peer_t *peer;
char *version;
char *bfrops;
char *psec;
char *gds;
pmix_bfrop_buffer_type_t buffer_type;
char *cred;
size_t len;
uid_t uid;
gid_t gid;
pmix_proc_type_t proc_type;
} pmix_pending_connection_t;
PMIX_CLASS_DECLARATION(pmix_pending_connection_t);
/* listener objects */
typedef struct pmix_listener_t {
pmix_list_item_t super;
pmix_event_t ev;
pmix_atomic_bool_t active;
pmix_listener_protocol_t protocol;
int socket;
char *varname;
char *uri;
uint32_t owner;
bool owner_given;
uint32_t group;
bool group_given;
uint32_t mode;
pmix_ptl_pending_cbfunc_t cbfunc;
} pmix_listener_t;
PMIX_CLASS_DECLARATION(pmix_listener_t);
#define PMIX_LISTENER_STATIC_INIT \
{ \
.super = PMIX_LIST_ITEM_STATIC_INIT, \
.active = false, \
.protocol = PMIX_PROTOCOL_UNDEF, \
.socket = 0, \
.varname = NULL, \
.uri = NULL, \
.owner = 0, \
.owner_given = false, \
.group = 0, \
.mode = 0, \
.cbfunc = NULL \
}
/* provide a backdoor to the framework output for debugging */
PMIX_EXPORT extern int pmix_ptl_base_output;
#define PMIX_ACTIVATE_POST_MSG(ms) \
do { \
pmix_event_assign(&((ms)->ev), pmix_globals.evbase, -1, EV_WRITE, \
pmix_ptl_base_process_msg, (ms)); \
PMIX_POST_OBJECT(ms); \
pmix_event_active(&((ms)->ev), EV_WRITE, 1); \
} while (0)
#define PMIX_SND_CADDY(c, h, s) \
do { \
(c) = PMIX_NEW(pmix_server_caddy_t); \
(void) memcpy(&(c)->hdr, &(h), sizeof(pmix_ptl_hdr_t)); \
PMIX_RETAIN((s)); \
(c)->snd = (s); \
} while (0)
/* queue a message to be sent to one of our procs - must
* provide the following params:
* p - pmix_peer_t of target recipient
* t - tag to be sent to
* b - buffer to be sent
*/
#define PMIX_SERVER_QUEUE_REPLY(r, p, t, b) \
do { \
pmix_ptl_send_t *snd; \
uint32_t nbytes; \
pmix_output_verbose(5, pmix_ptl_base_output, \
"[%s:%d] queue callback called: reply to %s:%d on tag %d size %d", \
__FILE__, __LINE__, (p)->info->pname.nspace, (p)->info->pname.rank, \
(t), (int) (b)->bytes_used); \
if ((p)->finalized) { \
(r) = PMIX_ERR_UNREACH; \
} else { \
snd = PMIX_NEW(pmix_ptl_send_t); \
snd->hdr.pindex = htonl(pmix_globals.pindex); \
snd->hdr.tag = htonl(t); \
nbytes = (b)->bytes_used; \
snd->hdr.nbytes = htonl(nbytes); \
snd->data = (b); \
/* always start with the header */ \
snd->sdptr = (char *) &snd->hdr; \
snd->sdbytes = sizeof(pmix_ptl_hdr_t); \
/* if there is no message on-deck, put this one there */ \
if (NULL == (p)->send_msg) { \
(p)->send_msg = snd; \
} else { \
/* add it to the queue */ \
pmix_list_append(&(p)->send_queue, &snd->super); \
} \
/* ensure the send event is active */ \
if (!(p)->send_ev_active && 0 <= (p)->sd) { \
(p)->send_ev_active = true; \
PMIX_POST_OBJECT(snd); \
pmix_event_add(&(p)->send_event, 0); \
} \
(r) = PMIX_SUCCESS; \
} \
} while (0)
#define CLOSE_THE_SOCKET(s) \
do { \
if (0 <= (s)) { \
shutdown((s), 2); \
close((s)); \
(s) = -1; \
} \
} while (0)
END_C_DECLS
#endif /* PMIX_PTL_TYPES_H */