1
1

Bring the name server files into the repository so proc_info can compile.

This commit was SVN r1506.
Этот коммит содержится в:
Ralph Castain 2004-06-29 21:17:10 +00:00
родитель c83ddc15d0
Коммит 066063fcef
5 изменённых файлов: 274 добавлений и 298 удалений

Просмотреть файл

@ -39,6 +39,9 @@
*
*/
#ifndef MCA_GPR_BASE_H_
#define MCA_GRP_BASE_H_
/*
* includes
*/
@ -47,14 +50,30 @@
#include "ompi_config.h"
#include "class/ompi_list.h"
#include "mca/mca.h"
#include "mca/gpr/gpr.h"
/*
* Global functions for MCA overall collective open and close
*/
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
int mca_gpr_base_open(void);
int mca_gpr_base_select(bool *allow_multi_user_threads,
bool *have_hidden_threads);
int mca_gpr_base_close(void);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
/*
* globals
* globals that might be needed
*/
extern mca_gpr_t ompi_registry;
extern mca_gpr_t ompi_registry; /* holds selected module's function pointers */
extern ompi_list_t mca_gpr_base_modules_available;
extern mca_gpr_base_module_t mca_gpr_base_selected_module;
/*
* structures
@ -79,303 +98,30 @@ typedef struct ompi_registry_value_t ompi_registry_value_t;
OBJ_CLASS_DECLARATION(ompi_registry_value_t);
#endif
/*
* external functions - here for purely documentation purposes
*/
/** @fn int ompi_registry.definesegment(char *segment)
*
* Define a new registry segment.
* The ompi_registry.definesegment() function allows the caller to create a new registry
* segment with the specified name. Each segment is given its own token-key dictionary and
* object storage list. There is no limit nor restrictions on the number of segments
* that can be created and who can create them, or for what they can be used. Attempts to
* define a segment with a name that already exists will return an error.
*
* @param segment A pointer to a character string containing the name of the segment
* to be created.
*
* @retval OMPI_SUCCESS Indicates that the operation was successfully completed.
* @retval OMPI_ERROR Indicates that the operation failed - most likely due to the
* prior existence of a segment with an identical name.
*/
/** @verbatim
int ompi_registry.definesegment(char *segment);
Define a new registry segment.
The ompi_registry.definesegment() function allows the caller to create a new registry
segment with the specified name. Each segment is given its own token-key dictionary and
object storage list. There is no limit nor restrictions on the number of segments
that can be created and who can create them, or for what they can be used. Attempts to
define a segment with a name that already exists will return an error.
Param segment A pointer to a character string containing the name of the segment
to be created.
Returns
OMPI_SUCCESS Indicates that the operation was successfully completed.
OMPI_ERROR Indicates that the operation failed - most likely due to the
prior existence of a segment with an identical name.
*/
/** @fn int ompi_registry.deletesegment(char *segment)
*
* Delete a registry segment.
* The ompi_registry.deletesegment() function removes a segment - and ALL of its stored
* objects - from the registry.
*
* @param segment A pointer to a character string containing the name of the segment
* to be created.
*
* @retval OMPI_SUCCESS Indicates that the operation was successfully completed.
* @retval OMPI_ERROR Indicates that the operation failed - most likely due to the
* non-existence of the segment.
*/
/** @fn int ompi_registry.put(ompi_registry_mode_t mode, char *segment, char **tokens, uint8_t *object, int size)
*
* Place an object on the registry.
* The ompi_registry.put() function places an object on the registry within the specified
* registry segment. At least one token describing the object must be provided - an unlimited
* number of additional tokens may also be provided. Note that placing an object on the
* registry where another object with all tokens identical already exists will cause the
* prior object to either: (a) be replaced with the new object, if the action bit-mask
* includes overwrite permission, or (b) generate an error, if the action bit-mask does
* not include overwrite permission.
*
* @param mode A bit-mask constructed from the defined mode values that controls
* the behaviour of the function.
*
* @param segment A pointer to a character string stating the registry segment to be used.
*
* @param tokens An array of one or more pointers to characters string containing a token
* that defines the object
* being stored.
*
* CAUTION: The array of tokens MUST end with a string of zero length ("\0")! Failure to correctly
* terminate the array will result
* in segmentation violations or bus errors, thus causing the program to catastrophically fail.
*
* @param object A pointer to pre-packed buffer to be stored on the registry. The registry will create
* a copy of the object. Since the registry has no knowledge of the object's internal structure,
* the object must be pre-packed by the caller to ensure accurate communication to other
* requestors on systems of different architecture.
*
* @param size Integer value of the size of the object being passed, in bytes.
*
* @retval OMPI_SUCCESS Indicates that the operation was successful.
* @retval OMPI_ERROR Indicates that the registry was unable to store the object - most
* likely due to specifying a non-existent segment or lack of available memory.
*/
/** @fn ompi_registry_value_t* ompi_registry.get(ompi_registry_mode_t mode, char *segment, char **tokens)
*
* Retrieve an object from the registry.
* The ompi_registry.get() function retrieves one or more packed buffers, each containing a copy of an
* object previously stored on
* the registry. The caller must provide the registry segment containing the object, and at
* least one token that describes it. An unlimited number of additional tokens describing the
* object may be provided. The function will return a linked list of all objects whose description
* contains the specified tokens, with the tokens used as defined by the specified mode.
*
* @param mode A bit-mask constructed from the defined registry mode flags that controls
* the behaviour of the function, as previously described.
*
* @param segment Pointer to a character string defining the segment of the registry.
*
* @param tokens Pointer to an array of pointers to character strings containing one or
* more tokens describing the object to be retrieved.
*
* CAUTION: The array must end with a string of zero length ("\0")! Failure to correctly
* terminate the array will result
* in segmentation violations or bus errors, thus causing the program to catastrophically fail.
*
* @retval object Pointer to a linked list of ompi_registry_value_t structures, each containing
* the name of the segment,
* a linked list of the tokens that describe the object,
* a pointer to a packed buffer containing a copy of the object retrieved from the registry,
* and the size of the object in bytes. The caller must unpack the buffer to access
* the information in the object.
* @retval NULL Indicates that no object meeting the provided specifications could not be found.
*/
/** @fn int ompi_registry.delete(ompi_registry_mode_t mode, char *segment, char **tokens)
*
* Delete an object from the registry.
* The ompi_registry.delete() function removes an object that was previously stored on the registry.
* The caller must provide the registry segment containing the object, and at
* least one token that describes it. An unlimited number of additional tokens describing the
* object may be provided.
*
* @param mode A bit-mask constructed from the defined registry mode flags that controls
* the behaviour of the function, as previously described.
*
* CAUTION: The function will delete ALL objects that match the search criteria.
*
* @param segment Pointer to a character string defining the segment of the registry.
* @param tokens Pointer to an array of pointers to character strings containing one or
* more tokens describing the object to be retrieved.
*
* CAUTION: The array must end with a string of zero length ("\0")! Failure to correctly
* terminate the array will result
* in segmentation violations or bus errors, thus causing the program to catastrophically fail.
*
* @retval OMPI_SUCCESS Indicates that the operation was successful.
* @retval OMPI_ERROR Indicates that the registry was unable to delete the object - most
* likely due to specifying a non-existent segment or object.
*/
/** @fn ompi_keytable_t* ompi_registry.index(char *segment)
*
* Obtain an index of the registry dictionary.
* The ompi_registry.index() function provides a list of the tokens within
* a specified dictionary. The caller provides the name of the segment being
* queried - this will return a linked list of all tokens within that segment's
* dictionary - or a NULL to return the list of tokens in the universe directory.
*
* @param segment Pointer to a character string defining the segment of the registry.
* @param NULL If segment parameter is NULL, then index of universe dictionary is returned.
*
* @retval keyvalues A pointer to a linked list of tokens.
* @retval NULL Indicates that the operation failed - most likely caused by specifying a non-existent segment.
*/
/** @fn int ompi_registry.subscribe(ompi_registry_mode_t mode, ompi_registry_action_t action, char *segment, char **tokens)
*
* Subscribe to a registry object.
* The ompi_registry.subscribe() function allows the caller to be notified when specific actions
* are taken on the specified object. Notification will be sent via the OOB communication channel.
*
* @param mode A bit-mask constructed from the defined registry mode flags that controls
* the behaviour of the function, as previously described.
* @param action A bit-mask value formed using the OMPI_REGISTRY_NOTIFY flags that indicates
* the action that shall trigger notification of the caller.
* @param segment Pointer to a character string defining the segment of the registry.
* @param tokens Pointer to an array of pointers to character strings containing one or
* more tokens describing the object to be retrieved.
*
* CAUTION: The array must end with a string of zero length ("\0")! Failure to correctly
* terminate the array will result
* in segmentation violations or bus errors, thus causing the program to catastrophically fail.
*
* @retval OMPI_SUCCESS Indicates that the operation was successful.
* @retval OMPI_ERROR Indicates that the operation failed - most likely caused by specifying
* an object that did not exist within the specified segment, or a non-existent segment.
*/
/** @fn int ompi_registry.unsubscribe(ompi_registry_mode_t mode, char *segment, char **tokens)
*
* Unsubscribe from a registry object.
* The ompi_registry.unsubscribe() function allows the caller to cancel a subscription to
* one or more objects on the registry.
*
* @param mode A bit-mask constructed from the defined registry mode flags that controls
* the behaviour of the function, as previously described.
* @param segment Pointer to a character string defining the segment of the registry.
* @param tokens Pointer to an array of pointers to character strings containing one or
* more tokens describing the object to be retrieved.
*
* CAUTION: The array must end with a string of zero length ("\0")! Failure to correctly
* terminate the array will result
* in segmentation violations or bus errors, thus causing the program to catastrophically fail.
*
* @retval OMPI_SUCCESS Indicates that the operation was successful. Note that this value will
* also be returned if the caller was not previously subscribed to the specified object since an
* unsubscribe request would have resulted in the same end condition.
* @retval OMPI_ERROR Indicates that the operation failed - most likely caused by specifying
* an object that did not exist within the specified segment, or a non-existent segment.
*/
/** @fn ompi_registry_buf_t *ompi_registry.getbuf(size_t size)
*
* Get a buffer for packing a multi-command request.
*
* The ompi_registry.getbuf() function creates a buffer for packing multiple commands
* into a single registry request. Packing multiple commands saves on messaging overhead,
* thus potentially providing faster response. Each command packed into the buffer will
* be processed in sequence, and the result of the command packed into a "response" buffer
* that will subsequently be returned. The results must then be unpacked by the caller
* in the reverse order of the original commands.
*
* Note: any command that returns an error condition will automatically terminate processing
* of the packed command sequence. In such cases, the returned "response" buffer will
* contain the results of all commands up to that point, with the error conditions
* from the last command being the first item in the buffer.
*
* @param size The size of the requested buffer in bytes. If a value of zero is provided,
* the function will allocate an unlimited buffer.
*
* @retval buffer A pointer to the requested buffer.
* @retval NULL Indicates that a buffer could not be obtained - most likely due to lack
* of sufficient available memory or a problem in the OOB subsystem.
*/
/** @fn int ompi_registry.packbuf(ompi_registry_buf_t *buf, void *ptr, size_t num_items, ompi_registry_bufdata_t datatype)
*
* Pack non-string data types into a buffer.
* Pack arbitrary bytes and previously packed buffers for recursive
* packing commands.
*
* @param buf A pointer to the buffer to which the packed info is to be added. A NULL value will
* cause the function to return OMPI_ERROR, but not fail.
*
* @param ptr A pointer (cast as void) to the data to be packed into the buffer.
*
* @param num_items The number of items in the data to be packed into the buffer. The items must all
* be of the same type.
*
* @param datatype One of the defined datatype flags indicating the type of the data to be packed
* into the buffer.
*
* @retval OMPI_SUCCESS Indicates that the operation was successful.
* @retval OMPI_ERROR Indicates that the operation failed.
*/
/** @fn int ompi_registry.pack_string(ompi_registry_buf_t *buf, char *string)
*
* Pack a string into a buffer.
* Due to their use as tokens in the registry, the packing of strings into the buffer is a fairly
* common operation. This function packs strings - and only strings - into the specified buffer.
*
* @param buf A pointer to the buffer to which the string is being added. A NULL value will cause
* the function to return OMPI_ERROR, but not fail.
* @param string A pointer to the string to be added to the buffer.
*
* @retval OMPI_SUCCESS Indicates that the operation was successful.
* @retval OMPI_ERROR Indicates that the operation failed.
*/
/** @fn int ompi_registry.unpack_string(ompi_registry_buf_t *buf, char *string, size_t maxlen)
*
* Unpack a string from buffer.
* Due to their use as tokens in the registry, the packing of strings into the buffer is a fairly
* common operation. This function unpacks strings - and only strings - from the specified buffer.
*
* @param buf A pointer to the buffer from which the string is to be extracted. A NULL value will cause
* the function to return OMPI_ERROR, but not fail.
* @param string A pointer to where the string is to be placed.
* @param maxlen The maximum length of the string that can be placed into the provided storage location.
* Strings longer than the maximum length will be truncated, but the function will still return
* "success".
*
* @retval OMPI_SUCCESS Indicates that the operation was successful.
* @retval OMPI_ERROR Indicates that the operation failed.
*/
/** @fn int ompi_registry.unpack_buf(ompi_registry_buf_t *buf, void *ptr, size_t num_items, ompi_registry_bufdata_t datatype)
*
* Unpack non-string data types from a buffer.
* Unpack arbitrary bytes and previously packed buffers for recursive
* packing commands.
*
* @param buf A pointer to the buffer from which the packed info is to be extracted. A NULL value will
* cause the function to return OMPI_ERROR, but not fail.
*
* @param ptr A pointer (cast as void) to the location where the packed data is to be placed.
*
* @param num_items The number of items in the data to be extracted from the buffer. The items must all
* be of the same type.
*
* @param datatype One of the defined datatype flags indicating the type of the data to be extracted
* from the buffer.
*
* @retval OMPI_SUCCESS Indicates that the operation was successful.
* @retval OMPI_ERROR Indicates that the operation failed.
*/
/** @fn int ompi_registry.sendbuf(ompi_process_name_t *target, ompi_registry_buf_t *buf, bool freebuf)
*
* Send a previously packed buffer to a target process.
* Once a buffer has been packed with commands, this function will send it to the target process.
*
* @param target The name of the process to which the buffer is to be sent.
* @param buf A pointer to the buffer to be sent. A NULL value will cause the function to return
* OMPI_ERROR, but not fail.
* @param freebuf A boolean value indicating if the buffer is to be released (true) or not (false)
* once the send has been completed.
*
* @retval OMPI_SUCCESS Indicates that the operation was successful.
* @retval OMPI_ERROR Indicates that the operation failed.
/** @endverbatim
*/

Просмотреть файл

@ -2,10 +2,12 @@
*
* $HEADER$
*/
/** @file **/
/** @file
* @page gpr_api
*/
/**
* \brief General Purpose Registry (GPR)
* \brief General Purpose Registry (GPR) API
*
* The Open MPI General Purpose Registry (GPR)
*/

26
src/mca/ns/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,26 @@
# -*- makefile -*-
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libns.la
# Source code files
headers = \
name_server.h
libns_la_SOURCES = \
$(headers) \
name_server.c
# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(includedir)/ompi/util
ompi_HEADERS = $(headers)
else
ompidir = $(includedir)
endif

130
src/mca/ns/ns.h Обычный файл
Просмотреть файл

@ -0,0 +1,130 @@
/*
* $HEADER$
*/
/** @file:
*
* The Open MPI Name Server
*
* The Open MPI Name Server provides unique name ranges for processes within the
* universe. Each universe will have one name server running within the seed daemon.
* This is done to prevent the inadvertent duplication of names.
*
*/
/*
* includes
*/
#include <sys/types.h>
#include <stdint.h>
#include "ompi_config.h"
/*
* typedefs
*/
typedef uint32_t ompi_process_id_t; /**< Set the allowed range for id's in each space */
struct ompi_process_name_t {
bool daemon; /**< Boolean indicating if process is a daemon (true) or application process (false) */
char *name; /**< String representation of the process name, expressed in %x.%x.%x format */
ompi_process_id_t cellid; /**< Cell number */
ompi_process_id_t jobid; /**< Job number */
ompi_process_id_t procid; /**< Process number */
};
typedef struct ompi_process_name_t ompi_process_name_t;
ompi_process_id_t ompi_ns_create_cellid(void);
ompi_process_id_t ompi_ns_create_jobid(void);
/**
* Obtain a single new process name.
* The ompi_process_name_new() function obtains a single new process name.
*
* @return name An ompi_process_name_t value of the name. A value of
* 0 indicates that the name server is out of names for that cell/jobid.
*/
ompi_process_name_t ompi_ns_create_proc_name(bool daemon, ompi_process_id_t cell, ompi_process_id_t jobid);
/**
* Obtain a range of process names.
* The ompi_process_name_get_range() function requests reservation of a range of
* names.
*
* @return name An ompi_process_name_t value of the name. A value of
* 0 indicates that the name server is out of names.
*/
ompi_process_name_t ompi_ns_reserve_name_range(bool daemon, ompi_process_id_t cell, ompi_process_id_t jobid, ompi_process_id_t range);
/**
* Releases a process name.
* The ompi_process_name_free() function will release a name for re-use. At this
* time, this function does nothing!! It will simply return OMPI_SUCCESS. This is
* here solely to reserve the function for further definition.
*
* @param name An ompi_process_name_t value of the name to be released.
* @return OMPI_SUCCESS At this time, this is always returned.
*/
int ompi_ns_free_name(ompi_process_name_t *name);
/**
* Release a range of process names.
* The ompi_process_name_free_range() function releases a range of names for re-use.
* At this time, this function does nothing!! This is here solely to reserve the
* function for further definition.
*
* @param name An ompi_process_name_t value indicating
* start of the range being freed.
* @param range An ompi_process_name_t value indicating how many names are being released.
*
* @return OMPI_SUCCESS Always returned at this time.
*/
int ompi_ns_free_name_range(ompi_process_name_t *name, ompi_process_id_t range);
/**
* Return the process name as a string.
*
* In a number of places within Open MPI (e.g., the General Purpose Registry), it
* is helpful/required that the process name be treated as a string. This function
* converts the name into a string by expressing the name in hex.
*
* @param name Pointer to the ompi_process_name_t structure whose name is desired.
*
* @return name_string Pointer to the name as a string expressed in hex format.
*
*/
char *ompi_get_procid_string(ompi_process_name_t *name);
ompi_process_id_t ompi_get_procid(ompi_process_name_t *name);
/**
* Return the process name fields as an array of strings.
*
* In a number of places within Open MPI (e.g., the General Purpose Registry), it
* is helpful/required that one or more of the process name's fields be treated
* as a string. This function
* converts the name fields into an array of strings by expressing them in hex.
*
* @param name Pointer to the ompi_process_name_t structure whose name is desired.
*
* @return name_strings Pointer to an array of strings, each representing one field
* in the name structure expressed in hex format. The array is terminated with a
* NULL pointer.
*
*/
char *ompi_get_jobid_string(ompi_process_name_t *name);
ompi_process_id_t ompi_get_jobid(ompi_process_name_t *name);
char *ompi_get_cellid_string(ompi_process_name_t *name);
ompi_process_id_t ompi_get_cellid(ompi_process_name_t *name);

72
src/mca/ns/replica/name_server.c Обычный файл
Просмотреть файл

@ -0,0 +1,72 @@
/*
* $HEADER$
*/
/** @file:
*
* The Open MPI Name Server
*
* The Open MPI Name Server provides unique name ranges for processes within the
* universe. Each universe will have one name server running within the seed daemon.
* This is done to prevent the inadvertent duplication of names.
*
*/
/*
* includes
*/
#include "ompi_config.h"
#include "include/constants.h"
#include "ns/name_server.h"
/*
* defines
*/
#define OMPI_SUCCESS 1
/**
* globals
*/
ompi_process_name_t ompi_name_service = 0;
ompi_process_name_t OMPI_NAME_SERVICE_MAX = 0xffffffffffffffff;
ompi_process_name_t ompi_process_name_new(void)
{
if (OMPI_NAME_SERVICE_MAX > ompi_name_service) {
ompi_name_service = ompi_name_service + 1;
return(ompi_name_service);
} else {
return(0);
}
}
ompi_process_name_t ompi_process_name_get_range (ompi_process_name_t range)
{
if ((OMPI_NAME_SERVICE_MAX-range) > ompi_name_service) {
ompi_name_service = ompi_name_service + range;
return(ompi_name_service);
} else {
return(0);
}
}
int ompi_process_name_free(ompi_process_name_t name)
{
return OMPI_SUCCESS;
}
int ompi_process_name_free_range(ompi_process_name_t name, ompi_process_name_t range)
{
return OMPI_SUCCESS;
}
char *ompi_convert_process_name_to_string(ompi_process_name_t name)
{
char * name_string;
uint32_t *name32;
name32 = (uint32_t*) &name;
sprintf(name_string, "%x%x", name32[0], name32[1]);
return(name_string);
}