1
1

NOTE: These changes may break any code that uses the ompi_process_name_t type. Please recompile and check for the changes detailed below.

Major change to the name server system to introduce the OOB interface. Changed the ompi_process_name_t to no longer be an OBJ, but instead just a regular C structure. Include the packing-based oob interface.

This commit was SVN r2114.
Этот коммит содержится в:
Ralph Castain 2004-08-13 15:09:24 +00:00
родитель 573b4ea950
Коммит 4f7febc161
11 изменённых файлов: 229 добавлений и 79 удалений

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

@ -35,6 +35,8 @@ extern "C" {
mca_ns_base_jobid_t job, mca_ns_base_jobid_t job,
mca_ns_base_vpid_t vpid); mca_ns_base_vpid_t vpid);
ompi_process_name_t* ns_base_copy_process_name(ompi_process_name_t* name);
ompi_process_name_t* ns_base_convert_string_to_process_name(const char* name); ompi_process_name_t* ns_base_convert_string_to_process_name(const char* name);
char* ns_base_get_proc_name_string(const ompi_process_name_t* name); char* ns_base_get_proc_name_string(const ompi_process_name_t* name);
@ -74,7 +76,7 @@ extern "C" {
extern int mca_ns_base_output; extern int mca_ns_base_output;
extern mca_ns_base_module_t ompi_name_server; /* holds selected module's function pointers */ extern mca_ns_base_module_t ompi_name_server; /* holds selected module's function pointers */
extern ompi_process_name_t mca_ns_my_replica; extern ompi_process_name_t *mca_ns_my_replica; /* the name of the replica for this process */
extern bool mca_ns_base_selected; extern bool mca_ns_base_selected;
extern ompi_list_t mca_ns_base_components_available; extern ompi_list_t mca_ns_base_components_available;
extern mca_ns_base_component_t mca_ns_base_selected_component; extern mca_ns_base_component_t mca_ns_base_selected_component;

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

@ -34,7 +34,7 @@ ompi_process_name_t* ns_base_create_process_name(mca_ns_base_cellid_t cell,
return(NULL); return(NULL);
} }
newname = OBJ_NEW(ompi_process_name_t); newname = (ompi_process_name_t*)malloc(sizeof(ompi_process_name_t));
if (NULL == newname) { /* got an error */ if (NULL == newname) { /* got an error */
return(NULL); return(NULL);
} }
@ -45,6 +45,24 @@ ompi_process_name_t* ns_base_create_process_name(mca_ns_base_cellid_t cell,
return(newname); return(newname);
} }
ompi_process_name_t* ns_base_copy_process_name(ompi_process_name_t* name)
{
mca_ns_base_cellid_t cell;
mca_ns_base_jobid_t job;
mca_ns_base_vpid_t vpid;
ompi_process_name_t *newname;
if (NULL == name) {
return NULL;
}
cell = ns_base_get_cellid(name);
job = ns_base_get_jobid(name);
vpid = ns_base_get_vpid(name);
newname = ns_base_create_process_name(cell, job, vpid);
return newname;
}
char* ns_base_get_proc_name_string(const ompi_process_name_t* name) char* ns_base_get_proc_name_string(const ompi_process_name_t* name)
{ {
@ -254,3 +272,12 @@ int ns_base_compare(ompi_ns_cmp_bitmask_t fields,
return(0); return(0);
} }
int ns_base_free_name(ompi_process_name_t* name)
{
if (NULL != name) {
free(name);
}
return OMPI_SUCCESS;
}

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

@ -22,32 +22,12 @@
* globals * globals
*/ */
/* constructor - used to initialize state of name instance */
static void ompi_name_construct(ompi_process_name_t* name)
{
name->cellid = 0;
name->jobid = 0;
name->vpid = 0;
}
/* destructor - used to free any resources held by instance */
static void ompi_name_destructor(ompi_process_name_t* name)
{
}
OBJ_CLASS_INSTANCE(
ompi_process_name_t, /* type name */
ompi_object_t, /* parent "class" name */
ompi_name_construct, /* constructor */
ompi_name_destructor); /* destructor */
/* /*
* Global variables * Global variables
*/ */
int mca_ns_base_output = -1; int mca_ns_base_output = -1;
mca_ns_base_module_t ompi_name_server; mca_ns_base_module_t ompi_name_server;
ompi_process_name_t mca_ns_my_replica; ompi_process_name_t *mca_ns_my_replica;
bool mca_ns_base_selected = false; bool mca_ns_base_selected = false;
ompi_list_t mca_ns_base_components_available; ompi_list_t mca_ns_base_components_available;
mca_ns_base_component_t mca_ns_base_selected_component; mca_ns_base_component_t mca_ns_base_selected_component;

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

@ -7,6 +7,7 @@
#include "ompi_config.h" #include "ompi_config.h"
#include "mca/mca.h" #include "mca/mca.h"
#include "util/pack.h"
#include "mca/oob/base/base.h" #include "mca/oob/base/base.h"
#include "mca/ns/base/base.h" #include "mca/ns/base/base.h"
@ -20,45 +21,118 @@
mca_ns_base_cellid_t ns_base_create_cellid(void) mca_ns_base_cellid_t ns_base_create_cellid(void)
{ {
ompi_ns_msg_buffer_t cmd, *answer; ompi_buffer_t cmd;
struct iovec msg;
mca_ns_base_cellid_t cell; mca_ns_base_cellid_t cell;
ompi_buffer_t *answer;
mca_ns_cmd_flag_t command;
int recv_tag;
cmd.command = OMPI_NS_CREATE_CELLID; command = MCA_NS_CREATE_CELLID_CMD;
cmd.buflen = 0; recv_tag = MCA_OOB_TAG_NS;
cmd.buf = NULL;
msg.iov_base = (char*)&cmd; if (OMPI_SUCCESS != ompi_buffer_init(&cmd, 0)) { /* got a problem */
msg.iov_len = sizeof(cmd); return OMPI_ERROR;
}
if (0 > mca_oob_send(&mca_ns_my_replica, &msg, 1, MCA_OOB_TAG_ANY, 0)) { /* error on send */ if (OMPI_SUCCESS != ompi_pack(cmd, (void*)&command, 1, MCA_NS_OOB_PACK_CMD)) {
return 0; return OMPI_ERROR;
} }
if (0 > mca_oob_recv(&mca_ns_my_replica, &msg, 1, MCA_OOB_TAG_ANY, 0)) { /* error on recv */ if (0 > mca_oob_send_packed(mca_ns_my_replica, cmd, MCA_OOB_TAG_NS, 0)) {
return 0; return MCA_NS_BASE_CELLID_MAX;
} }
answer = (ompi_ns_msg_buffer_t*)msg.iov_base; if (0 > mca_oob_recv_packed(mca_ns_my_replica, answer, &recv_tag)) {
cell = (mca_ns_base_cellid_t)answer->buf; return MCA_NS_BASE_CELLID_MAX;
return cell; }
if (OMPI_SUCCESS != ompi_unpack(*answer, &cell, 1, MCA_NS_OOB_PACK_CELLID)) {
ompi_buffer_free(*answer);
return MCA_NS_BASE_CELLID_MAX;
} else {
ompi_buffer_free(*answer);
return cell;
}
} }
mca_ns_base_jobid_t ns_base_create_jobid(void) mca_ns_base_jobid_t ns_base_create_jobid(void)
{ {
/* JMS fill in here */ ompi_buffer_t cmd;
return 0; mca_ns_base_jobid_t job;
ompi_buffer_t *answer;
mca_ns_cmd_flag_t command;
int recv_tag;
command = MCA_NS_CREATE_JOBID_CMD;
recv_tag = MCA_OOB_TAG_NS;
if (OMPI_SUCCESS != ompi_buffer_init(&cmd, 0)) { /* got a problem */
return OMPI_ERROR;
}
if (OMPI_SUCCESS != ompi_pack(cmd, (void*)&command, 1, MCA_NS_OOB_PACK_CMD)) { /* got a problem */
return OMPI_ERROR;
}
if (0 > mca_oob_send_packed(mca_ns_my_replica, cmd, MCA_OOB_TAG_NS, 0)) {
return MCA_NS_BASE_JOBID_MAX;
}
if (0 > mca_oob_recv_packed(mca_ns_my_replica, answer, &recv_tag)) {
return MCA_NS_BASE_JOBID_MAX;
}
if (OMPI_SUCCESS != ompi_unpack(*answer, &job, 1, MCA_NS_OOB_PACK_JOBID)) {
ompi_buffer_free(*answer);
return MCA_NS_BASE_JOBID_MAX;
} else {
ompi_buffer_free(*answer);
return job;
}
} }
mca_ns_base_vpid_t ns_base_reserve_range(mca_ns_base_jobid_t job, mca_ns_base_vpid_t range) mca_ns_base_vpid_t ns_base_reserve_range(mca_ns_base_jobid_t job, mca_ns_base_vpid_t range)
{ {
/* JMS fill in here */ ompi_buffer_t cmd;
return 0; mca_ns_base_vpid_t starting_vpid;
} ompi_buffer_t *answer;
mca_ns_cmd_flag_t command;
int recv_tag;
command = MCA_NS_RESERVE_RANGE_CMD;
recv_tag = MCA_OOB_TAG_NS;
int ns_base_free_name(ompi_process_name_t* name) if (OMPI_SUCCESS != ompi_buffer_init(&cmd, 0)) { /* got a problem */
{ return OMPI_ERROR;
return OMPI_SUCCESS; }
if (OMPI_SUCCESS != ompi_pack(cmd, (void*)&command, 1, MCA_NS_OOB_PACK_CMD)) { /* got a problem */
return OMPI_ERROR;
}
if (OMPI_SUCCESS != ompi_pack(cmd, (void*)&job, 1, MCA_NS_OOB_PACK_JOBID)) { /* got a problem */
return OMPI_ERROR;
}
if (OMPI_SUCCESS != ompi_pack(cmd, (void*)&range, 1, MCA_NS_OOB_PACK_VPID)) { /* got a problem */
return OMPI_ERROR;
}
if (0 > mca_oob_send_packed(mca_ns_my_replica, cmd, MCA_OOB_TAG_NS, 0)) {
return MCA_NS_BASE_VPID_MAX;
}
if (0 > mca_oob_recv_packed(mca_ns_my_replica, answer, &recv_tag)) {
return MCA_NS_BASE_VPID_MAX;
}
if (OMPI_SUCCESS != ompi_unpack(*answer, &starting_vpid, 1, MCA_NS_OOB_PACK_VPID)) {
ompi_buffer_free(*answer);
return MCA_NS_BASE_VPID_MAX;
} else {
ompi_buffer_free(*answer);
return starting_vpid;
}
} }

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

@ -26,6 +26,7 @@
#include "class/ompi_list.h" #include "class/ompi_list.h"
#include "mca/mca.h" #include "mca/mca.h"
#include "util/pack.h"
/* /*
@ -43,14 +44,39 @@
#define MCA_NS_BASE_JOBID_MAX UINT32_MAX #define MCA_NS_BASE_JOBID_MAX UINT32_MAX
#define MCA_NS_BASE_VPID_MAX UINT32_MAX #define MCA_NS_BASE_VPID_MAX UINT32_MAX
/*
* define flag values for remote commands - only used internally
*/
#define MCA_NS_CREATE_CELLID_CMD 0x01
#define MCA_NS_CREATE_JOBID_CMD 0x02
#define MCA_NS_RESERVE_RANGE_CMD 0x04
#define MCA_NS_FREE_NAME_CMD 0x08
/* /*
* general typedefs & structures * general typedefs & structures
*/ */
/**< Set the allowed range for ids in each space */ /** Set the allowed range for ids in each space */
/* CAUTION - any changes here must also change corresponding
* OOB_PACK definitions below
*/
typedef uint32_t mca_ns_base_jobid_t; typedef uint32_t mca_ns_base_jobid_t;
typedef uint32_t mca_ns_base_cellid_t; typedef uint32_t mca_ns_base_cellid_t;
typedef uint32_t mca_ns_base_vpid_t; typedef uint32_t mca_ns_base_vpid_t;
typedef uint8_t ompi_ns_cmp_bitmask_t; /**< Bit mask for comparing process names */ typedef uint8_t ompi_ns_cmp_bitmask_t; /**< Bit mask for comparing process names */
typedef uint16_t mca_ns_cmd_flag_t;
/*
* packing type definitions
*/
/* CAUTION - any changes here must also change corresponding
* typedefs above
*/
#define MCA_NS_OOB_PACK_JOBID OMPI_INT32
#define MCA_NS_OOB_PACK_CELLID OMPI_INT32
#define MCA_NS_OOB_PACK_VPID OMPI_INT32
#define MCA_NS_OOB_PACK_CMD OMPI_INT16
struct ompi_process_name_t { struct ompi_process_name_t {
mca_ns_base_cellid_t cellid; /**< Cell number */ mca_ns_base_cellid_t cellid; /**< Cell number */
@ -59,8 +85,6 @@ struct ompi_process_name_t {
}; };
typedef struct ompi_process_name_t ompi_process_name_t; typedef struct ompi_process_name_t ompi_process_name_t;
/* declare the class */
OBJ_CLASS_DECLARATION(ompi_process_name_t);
/* /*
* define the command names/ids for use in OOB buffers. * define the command names/ids for use in OOB buffers.
@ -161,6 +185,18 @@ typedef mca_ns_base_jobid_t (*mca_ns_base_module_create_jobid_fn_t)(void);
*/ */
typedef ompi_process_name_t* (*mca_ns_base_module_create_proc_name_fn_t)(mca_ns_base_cellid_t cell, mca_ns_base_jobid_t job, mca_ns_base_vpid_t vpid); typedef ompi_process_name_t* (*mca_ns_base_module_create_proc_name_fn_t)(mca_ns_base_cellid_t cell, mca_ns_base_jobid_t job, mca_ns_base_vpid_t vpid);
/**
* Make a copy of a process name.
* Given a process name, this function creates a copy of it and returns a pointer
* to the duplicate structure.
*
* @param *name Pointer to an existing process name structure.
*
* @retval *newname Pointer to the duplicate structure, with all fields transferred.
* @retval NULL Indicates an error - most likely due to a NULL process name
* pointer being supplied as input.
*/
typedef ompi_process_name_t* (*mca_ns_base_module_copy_proc_name_fn_t)(ompi_process_name_t* name);
/** /**
* Convert a string representation to a process name. * Convert a string representation to a process name.
@ -403,6 +439,7 @@ struct mca_ns_base_module_1_0_0_t {
mca_ns_base_module_create_cellid_fn_t create_cellid; mca_ns_base_module_create_cellid_fn_t create_cellid;
mca_ns_base_module_create_jobid_fn_t create_jobid; mca_ns_base_module_create_jobid_fn_t create_jobid;
mca_ns_base_module_create_proc_name_fn_t create_process_name; mca_ns_base_module_create_proc_name_fn_t create_process_name;
mca_ns_base_module_copy_proc_name_fn_t copy_process_name;
mca_ns_base_module_convert_string_to_process_name_fn_t convert_string_to_process_name; mca_ns_base_module_convert_string_to_process_name_fn_t convert_string_to_process_name;
mca_ns_base_module_reserve_range_fn_t reserve_range; mca_ns_base_module_reserve_range_fn_t reserve_range;
mca_ns_base_module_free_name_fn_t free_name; mca_ns_base_module_free_name_fn_t free_name;

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

@ -30,7 +30,4 @@ int mca_ns_proxy_finalize(void);
* globals used within proxy component * globals used within proxy component
*/ */
extern ompi_process_name_t mca_ns_my_replica;
#endif #endif

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

@ -21,6 +21,7 @@
#include "util/proc_info.h" #include "util/proc_info.h"
#include "util/output.h" #include "util/output.h"
#include "mca/mca.h" #include "mca/mca.h"
#include "mca/base/mca_base_param.h"
#include "mca/ns/base/base.h" #include "mca/ns/base/base.h"
#include "ns_proxy.h" #include "ns_proxy.h"
@ -53,6 +54,7 @@ static mca_ns_base_module_t mca_ns_proxy = {
ns_base_create_cellid, ns_base_create_cellid,
ns_base_create_jobid, ns_base_create_jobid,
ns_base_create_process_name, ns_base_create_process_name,
ns_base_copy_process_name,
ns_base_convert_string_to_process_name, ns_base_convert_string_to_process_name,
ns_base_reserve_range, ns_base_reserve_range,
ns_base_free_name, ns_base_free_name,
@ -75,10 +77,10 @@ static bool initialized = false;
* globals needed within proxy component * globals needed within proxy component
*/ */
ompi_process_name_t *mca_ns_my_replica;
/* /*
* don't really need this function - could just put NULL in the above structure * Open the proxy component and obtain the name of my replica.
* Just holding the place in case we decide there is something we need to do
*/ */
int mca_ns_proxy_open(void) int mca_ns_proxy_open(void)
{ {
@ -95,34 +97,50 @@ int mca_ns_proxy_close(void)
mca_ns_base_module_t* mca_ns_proxy_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority) mca_ns_base_module_t* mca_ns_proxy_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority)
{ {
int index, error_code;
char *my_replica_string;
/* If we're NOT the seed, then we want to be selected, so do all /* If we're NOT the seed, then we want to be selected, so do all
the setup and return the module */ the setup and return the module */
ompi_output(mca_ns_base_output, "ns_proxy: entered init\n"); /* ompi_output(mca_ns_base_output, "ns_proxy: entered init\n"); */
if (!ompi_process_info.seed) { if (!ompi_process_info.seed) {
/* Return a module (choose an arbitrary, positive priority -- /* Return a module (choose an arbitrary, positive priority --
it's only relevant compared to other ns components). If it's only relevant compared to other ns components). If
we're not the seed, then we don't want to be selected, so we're not the seed, then we don't want to be selected, so
return NULL. */ return NULL. */
*priority = 10; *priority = 10;
/* We allow multi user threads but don't have any hidden threads */ /* We allow multi user threads but don't have any hidden threads */
*allow_multi_user_threads = true; *allow_multi_user_threads = true;
*have_hidden_threads = false; *have_hidden_threads = false;
/* define the replica for us to use - for now, use only the seed */ /* define the replica for us to use */
mca_ns_my_replica.cellid = 0; /* register the mca parameter containing my replica's contact info */
mca_ns_my_replica.jobid = 0; index = mca_base_param_register_string("NS", "PROXY", "REPLICA", NULL, NULL);
mca_ns_my_replica.vpid = 0;
/* Return the module */ error_code = mca_base_param_lookup_string(index, &my_replica_string);
if (OMPI_ERROR == error_code) { /* can't lookup mca parameter for some reason - can't operate */
return NULL;
}
initialized = true; mca_ns_my_replica = mca_ns_proxy.convert_string_to_process_name(my_replica_string);
return &mca_ns_proxy; if(NULL == mca_ns_my_replica) {
/* couldn't convert string to name - probably parameter not set - use seed as default */
mca_ns_my_replica = mca_ns_proxy.create_process_name(0,0,0);
if (NULL == mca_ns_my_replica) { /* couldn't create process name - can't operate */
return NULL;
}
}
/* Return the module */
initialized = true;
return &mca_ns_proxy;
} else { } else {
return NULL; return NULL;
} }
} }

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

@ -69,5 +69,9 @@ mca_ns_base_vpid_t ns_replica_reserve_range(mca_ns_base_jobid_t job, mca_ns_base
int ns_replica_free_name(ompi_process_name_t* name) int ns_replica_free_name(ompi_process_name_t* name)
{ {
if (NULL != name) {
free(name);
}
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

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

@ -54,6 +54,7 @@ static mca_ns_base_module_t mca_ns_replica = {
ns_replica_create_cellid, ns_replica_create_cellid,
ns_replica_create_jobid, ns_replica_create_jobid,
ns_base_create_process_name, ns_base_create_process_name,
ns_base_copy_process_name,
ns_base_convert_string_to_process_name, ns_base_convert_string_to_process_name,
ns_replica_reserve_range, ns_replica_reserve_range,
ns_replica_free_name, ns_replica_free_name,
@ -118,6 +119,7 @@ int mca_ns_replica_close(void)
mca_ns_base_module_t* mca_ns_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority) mca_ns_base_module_t* mca_ns_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority)
{ {
/* If we're the seed, then we want to be selected, so do all the /* If we're the seed, then we want to be selected, so do all the
setup and return the module */ setup and return the module */
@ -142,6 +144,10 @@ mca_ns_base_module_t* mca_ns_replica_init(bool *allow_multi_user_threads, bool *
OBJ_CONSTRUCT(&mca_ns_replica_name_tracker, ompi_list_t); OBJ_CONSTRUCT(&mca_ns_replica_name_tracker, ompi_list_t);
/* set my_replica to point to myself */
mca_ns_my_replica = mca_ns_replica.copy_process_name(&ompi_process_info.name);
/* Return the module */ /* Return the module */
initialized = true; initialized = true;

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

@ -39,9 +39,15 @@ extern ompi_process_name_t mca_oob_name_self;
* Other constants * Other constants
*/ */
/** /**
* Recieve from any tag. * Receive from any tag.
*/ */
#define MCA_OOB_TAG_ANY 0 #define MCA_OOB_TAG_ANY 0
/**
* Service tags
*/
#define MCA_OOB_TAG_NS 1
#define MCA_OOB_TAG_GPR 2
/* /*
* OOB API * OOB API

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

@ -10,6 +10,7 @@
#include "util/output.h" #include "util/output.h"
#include "mca/mca.h" #include "mca/mca.h"
#include "mca/base/base.h" #include "mca/base/base.h"
#include "mca/ns/base/base.h"
#include "mca/pcm/pcm.h" #include "mca/pcm/pcm.h"
#include "mca/oob/oob.h" #include "mca/oob/oob.h"
#include "mca/oob/base/base.h" #include "mca/oob/base/base.h"
@ -49,7 +50,6 @@ int mca_oob_base_init(bool *user_threads, bool *hidden_threads)
ompi_process_name_t *self; ompi_process_name_t *self;
/* setup local name */ /* setup local name */
OBJ_CONSTRUCT(&mca_oob_name_self, ompi_process_name_t);
self = mca_pcm.pcm_self(); self = mca_pcm.pcm_self();
if(NULL == self) { if(NULL == self) {
ompi_output(0, "mca_oob_base_init: could not get PCM self pointer"); ompi_output(0, "mca_oob_base_init: could not get PCM self pointer");
@ -58,13 +58,12 @@ int mca_oob_base_init(bool *user_threads, bool *hidden_threads)
mca_oob_name_self = *self; mca_oob_name_self = *self;
/* setup wildcard name */ /* setup wildcard name */
OBJ_CONSTRUCT(&mca_oob_name_any, ompi_process_name_t); mca_oob_name_any = *ompi_name_server.create_process_name(MCA_NS_BASE_CELLID_MAX,
mca_oob_name_any.cellid = -1; MCA_NS_BASE_JOBID_MAX,
mca_oob_name_any.jobid = -1; MCA_NS_BASE_VPID_MAX);
mca_oob_name_any.vpid = -1;
/* setup seed daemons name */ /* setup seed daemons name */
OBJ_CONSTRUCT(&mca_oob_name_seed, ompi_process_name_t); mca_oob_name_seed = *ompi_name_server.create_process_name(0,0,0);
/* Traverse the list of available modules; call their init functions. */ /* Traverse the list of available modules; call their init functions. */
for (item = ompi_list_get_first(&mca_oob_base_components); for (item = ompi_list_get_first(&mca_oob_base_components);