Commit 0b4ab705 authored by Shane Snyder's avatar Shane Snyder

add simple group config to group_create

parent 81b01cb8
......@@ -20,11 +20,13 @@ extern "C" {
#endif
/**
* Creates an SSG group from a given MPI communicator.
* Creates an SSG group from a given MPI communicator. A 'NULL' value for
* 'group_conf' will use SSG defaults for all configuration parameters.
*
* @param[in] mid Corresponding Margo instance identifier
* @param[in] group_name Name of the SSG group
* @param[in] comm MPI communicator containing group members
* @param[in] group_conf Configuration parameters for the group
* @param[in] update_cb Callback function executed on group membership changes
* @param[in] update_cb_dat User data pointer passed to membership update callback
* @returns SSG group identifier for created group on success, SSG_GROUP_ID_INVALID otherwise
......@@ -33,6 +35,7 @@ ssg_group_id_t ssg_group_create_mpi(
margo_instance_id mid,
const char * group_name,
MPI_Comm comm,
ssg_group_config_t *group_conf,
ssg_membership_update_cb update_cb,
void * update_cb_dat);
......
......@@ -20,11 +20,13 @@ extern "C" {
#endif
/**
* Creates an SSG group from a given PMIx proc handle.
* Creates an SSG group from a given PMIx proc handle. A 'NULL' value for
* 'group_conf' will use SSG defaults for all configuration parameters.
*
* @param[in] mid Corresponding Margo instance identifier
* @param[in] group_name Name of the SSG group
* @param[in] proc PMIx proc handle representing this group member
* @param[in] group_conf Configuration parameters for the group
* @param[in] update_cb Callback function executed on group membership changes
* @param[in] update_cb_dat User data pointer passed to membership update callback
* @returns SSG group identifier for created group on success, SSG_GROUP_ID_INVALID otherwise
......@@ -33,6 +35,7 @@ ssg_group_id_t ssg_group_create_pmix(
margo_instance_id mid,
const char * group_name,
pmix_proc_t proc,
ssg_group_config_t *group_conf,
ssg_membership_update_cb update_cb,
void * update_cb_dat);
......
......@@ -35,6 +35,21 @@ typedef uint64_t ssg_group_id_t;
typedef uint64_t ssg_member_id_t;
#define SSG_MEMBER_ID_INVALID 0
typedef struct ssg_group_config
{
int swim_period_length_ms; /* period length in miliseconds */
int swim_suspect_timeout_periods; /* suspicion timeout in periods */
int swim_subgroup_member_count; /* iping subgroup count */
} ssg_group_config_t;
/* initializer macro to ensure SSG ignores unset config params */
#define SSG_GROUP_CONFIG_INITIALIZER \
{\
.swim_period_length_ms = 0, \
.swim_suspect_timeout_periods = -1, \
.swim_subgroup_member_count = -1, \
}\
/* SSG group member update types */
typedef enum ssg_member_update_type
{
......@@ -77,12 +92,14 @@ int ssg_finalize(
*************************************/
/**
* Creates an SSG group from a given list of HG address strings.
* Creates an SSG group from a given list of HG address strings. A 'NULL' value for
* 'group_conf' will use SSG defaults for all configuration parameters.
*
* @param[in] mid Corresponding Margo instance identifier
* @param[in] group_name Name of the SSG group
* @param[in] group_addr_strs Array of HG address strings for each group member
* @param[in] group_size Number of group members
* @param[in] group_conf Configuration parameters for the group
* @param[in] update_cb Callback function executed on group membership changes
* @param[in] update_cb_dat User data pointer passed to membership update callback
* @returns SSG group identifier for created group on success, SSG_GROUP_ID_NULL otherwise
......@@ -96,17 +113,20 @@ ssg_group_id_t ssg_group_create(
const char * group_name,
const char * const group_addr_strs[],
int group_size,
ssg_group_config_t *group_conf,
ssg_membership_update_cb update_cb,
void * update_cb_dat);
/**
* Creates an SSG group from a given config file containing the HG address strings
* of all group members.
* of all group members. A 'NULL' value for 'group_conf' will use SSG defaults for
* all configuration parameters.
*
* @param[in] mid Corresponding Margo instance identifier
* @param[in] group_name Name of the SSG group
* @param[in] file_name Name of the config file containing the corresponding
* HG address strings for this group
* @param[in] group_conf Configuration parameters for the group
* @param[in] update_cb Callback function executed on group membership changes
* @param[in] update_cb_dat User data pointer passed to membership update callback
* @returns SSG group identifier for created group on success, SSG_GROUP_ID_NULL otherwise
......@@ -120,6 +140,7 @@ ssg_group_id_t ssg_group_create_config(
margo_instance_id mid,
const char * group_name,
const char * file_name,
ssg_group_config_t *group_conf,
ssg_membership_update_cb update_cb,
void * update_cb_dat);
......
......@@ -43,7 +43,8 @@ ssg_mid_state_t *ssg_retrieve_mid_state(
static ssg_group_id_t ssg_group_create_internal(
ssg_mid_state_t *mid_state, const char * group_name,
const char * const group_addr_strs[], int group_size,
ssg_membership_update_cb update_cb, void *update_cb_dat);
ssg_group_config_t *group_conf, ssg_membership_update_cb update_cb,
void *update_cb_dat);
static int ssg_group_view_create(
const char * const group_addr_strs[], int group_size,
const char * self_addr_str, ssg_mid_state_t *mid_state,
......@@ -193,6 +194,7 @@ ssg_group_id_t ssg_group_create(
const char * group_name,
const char * const group_addr_strs[],
int group_size,
ssg_group_config_t *group_conf,
ssg_membership_update_cb update_cb,
void * update_cb_dat)
{
......@@ -205,7 +207,7 @@ ssg_group_id_t ssg_group_create(
if(!mid_state) return g_id;
g_id = ssg_group_create_internal(mid_state, group_name, group_addr_strs,
group_size, update_cb, update_cb_dat);
group_size, group_conf, update_cb, update_cb_dat);
return g_id;
}
......@@ -214,6 +216,7 @@ ssg_group_id_t ssg_group_create_config(
margo_instance_id mid,
const char * group_name,
const char * file_name,
ssg_group_config_t *group_conf,
ssg_membership_update_cb update_cb,
void * update_cb_dat)
{
......@@ -295,7 +298,7 @@ ssg_group_id_t ssg_group_create_config(
/* invoke the generic group create routine using our list of addrs */
g_id = ssg_group_create_internal(mid_state, group_name, addr_strs, num_addrs,
update_cb, update_cb_dat);
group_conf, update_cb, update_cb_dat);
fini:
/* cleanup before returning */
......@@ -312,6 +315,7 @@ ssg_group_id_t ssg_group_create_mpi(
margo_instance_id mid,
const char * group_name,
MPI_Comm comm,
ssg_group_config_t *group_conf,
ssg_membership_update_cb update_cb,
void * update_cb_dat)
{
......@@ -360,7 +364,7 @@ ssg_group_id_t ssg_group_create_mpi(
/* invoke the generic group create routine using our list of addrs */
g_id = ssg_group_create_internal(mid_state, group_name, addr_strs, comm_size,
update_cb, update_cb_dat);
group_conf, update_cb, update_cb_dat);
fini:
/* cleanup before returning */
......@@ -378,6 +382,7 @@ ssg_group_id_t ssg_group_create_pmix(
margo_instance_id mid,
const char * group_name,
const pmix_proc_t proc,
ssg_group_config_t *group_conf,
ssg_membership_update_cb update_cb,
void * update_cb_dat)
{
......@@ -524,7 +529,7 @@ ssg_group_id_t ssg_group_create_pmix(
/* invoke the generic group create routine using our list of addrs */
g_id = ssg_group_create_internal(mid_state, group_name, addr_strs, nprocs,
update_cb, update_cb_dat);
group_conf, update_cb, update_cb_dat);
fini:
/* cleanup before returning */
......@@ -628,8 +633,9 @@ int ssg_group_join(
if(!addr_strs) goto fini;
addr_strs[group_size++] = mid_state->self_addr_str;
/* XXX how to config group? */
create_g_id = ssg_group_create_internal(mid_state, group_name, addr_strs, group_size,
update_cb, update_cb_dat);
NULL, update_cb, update_cb_dat);
if (create_g_id != SSG_GROUP_ID_INVALID)
{
......@@ -1568,7 +1574,8 @@ ssg_mid_state_t *ssg_retrieve_mid_state(
static ssg_group_id_t ssg_group_create_internal(
ssg_mid_state_t *mid_state, const char * group_name,
const char * const group_addr_strs[], int group_size,
ssg_membership_update_cb update_cb, void *update_cb_dat)
ssg_group_config_t *group_conf, ssg_membership_update_cb update_cb,
void *update_cb_dat)
{
ssg_group_descriptor_t *g_desc = NULL, *g_desc_check;
ssg_group_id_t g_id;
......@@ -1635,7 +1642,7 @@ static ssg_group_id_t ssg_group_create_internal(
}
/* initialize swim failure detector if everything succeeds */
sret = swim_init(g, g_desc->g_id, 1);
sret = swim_init(g, g_desc->g_id, group_conf, 1);
if (sret != SSG_SUCCESS)
{
HASH_DEL(ssg_rt->g_desc_table, g_desc);
......
......@@ -77,7 +77,8 @@ static void swim_register_ssg_member_update(
int swim_init(
ssg_group_t * group,
ssg_member_id_t g_id,
ssg_group_id_t group_id,
ssg_group_config_t *group_conf,
int active)
{
swim_context_t *swim_ctx;
......@@ -89,7 +90,7 @@ int swim_init(
swim_ctx = malloc(sizeof(*swim_ctx));
if (!swim_ctx) return(SSG_FAILURE);
memset(swim_ctx, 0, sizeof(*swim_ctx));
swim_ctx->g_id = g_id;
swim_ctx->g_id = group_id;
swim_ctx->self_inc_nr = 0;
swim_ctx->dping_target_id = SSG_MEMBER_ID_INVALID;
for (i = 0; i < SWIM_MAX_SUBGROUP_SIZE; i++)
......@@ -116,9 +117,18 @@ int swim_init(
}
/* set protocol parameters */
swim_ctx->prot_period_len = SWIM_DEF_PROTOCOL_PERIOD_LEN;
swim_ctx->prot_susp_timeout = SWIM_DEF_SUSPECT_TIMEOUT;
swim_ctx->prot_subgroup_sz = SWIM_DEF_SUBGROUP_SIZE;
if (group_conf && group_conf->swim_period_length_ms > 0)
swim_ctx->prot_period_len = group_conf->swim_period_length_ms;
else
swim_ctx->prot_period_len = SWIM_DEF_PROTOCOL_PERIOD_LEN;
if (group_conf && group_conf->swim_suspect_timeout_periods >= 0)
swim_ctx->prot_susp_timeout = group_conf->swim_suspect_timeout_periods;
else
swim_ctx->prot_susp_timeout = SWIM_DEF_SUSPECT_TIMEOUT;
if (group_conf && group_conf->swim_subgroup_member_count >= 0)
swim_ctx->prot_subgroup_sz = group_conf->swim_subgroup_member_count;
else
swim_ctx->prot_subgroup_sz = SWIM_DEF_SUBGROUP_SIZE;
group->swim_ctx = swim_ctx;
......
......@@ -61,13 +61,14 @@ void swim_deregister_ping_rpcs(
* Initialize SWIM protocol for the given SSG group and Margo instance.
*
* @param[in] group pointer to SSG group associated with this SWIM context
* @param[in] g_id SSG group identifier for group
* @param[in] group_id SSG group identifier for group
* @param[in] active boolean value indicating whether member should actively ping
* @returns SSG_SUCCESS on success, SSG_FAILURE otherwise
*/
int swim_init(
struct ssg_group * group,
ssg_member_id_t g_id,
ssg_group_id_t group_id,
ssg_group_config_t *group_conf,
int active);
/**
......
......@@ -132,6 +132,7 @@ int main(int argc, char *argv[])
margo_instance_id mid = MARGO_INSTANCE_NULL;
ssg_group_id_t g_id = SSG_GROUP_ID_INVALID;
ssg_member_id_t my_id;
ssg_group_config_t g_conf = SSG_GROUP_CONFIG_INITIALIZER;
int group_size;
int sret;
......@@ -171,14 +172,21 @@ int main(int argc, char *argv[])
sret = ssg_init();
DIE_IF(sret != SSG_SUCCESS, "ssg_init");
/* set non-default group config parameters */
g_conf.swim_period_length_ms = 1000; /* 1-second period length */
g_conf.swim_suspect_timeout_periods = 4; /* 4-period suspicion length */
g_conf.swim_subgroup_member_count = 3; /* 3-member subgroups for SWIM */
/* XXX do we want to use callback for testing anything about group??? */
#ifdef SSG_HAVE_MPI
if(strcmp(opts.group_mode, "mpi") == 0)
g_id = ssg_group_create_mpi(mid, opts.group_name, MPI_COMM_WORLD, NULL, NULL);
g_id = ssg_group_create_mpi(mid, opts.group_name, MPI_COMM_WORLD, &g_conf,
NULL, NULL);
#endif
#ifdef SSG_HAVE_PMIX
if(strcmp(opts.group_mode, "pmix") == 0)
g_id = ssg_group_create_pmix(mid, opts.group_name, proc, NULL, NULL);
g_id = ssg_group_create_pmix(mid, opts.group_name, proc, &g_conf,
NULL, NULL);
#endif
DIE_IF(g_id == SSG_GROUP_ID_INVALID, "ssg_group_create");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment