Commit 70385ee9 authored by Shane Snyder's avatar Shane Snyder
Browse files

more changes for sparse member ids in ssg

parent 0d329f87
......@@ -16,6 +16,7 @@
#include "ssg.h"
#include "uthash.h"
#include "utlist.h"
#ifdef __cplusplus
extern "C" {
......@@ -45,7 +46,6 @@ typedef struct ssg_member_state
ssg_member_id_t id;
char *addr_str;
hg_addr_t addr;
int is_member; /* XXX remove */
struct ssg_member_state *next;
UT_hash_handle hh;
} ssg_member_state_t;
......@@ -70,9 +70,9 @@ typedef struct ssg_group_view
typedef struct ssg_group
{
char *name;
ssg_group_descriptor_t *descriptor;
ssg_member_id_t self_id;
ssg_group_view_t view;
ssg_group_descriptor_t *descriptor;
void *fd_ctx; /* failure detector context (currently just SWIM) */
ssg_membership_update_cb update_cb;
void *update_cb_dat;
......@@ -105,10 +105,11 @@ enum ssg_group_descriptor_owner_status
#define ssg_hashlittle2 hashlittle2
extern void hashlittle2(const void *key, size_t length, uint32_t *pc, uint32_t *pb);
static inline ssg_hash64_str(const char * str)
static inline uint64_t ssg_hash64_str(const char * str)
{
uint32_t lower, upper;
uint64_t hash;
ssg_hashlittle2(__str, strlen(__str), &lower, &upper);
ssg_hashlittle2(str, strlen(str), &lower, &upper);
hash = lower + (((uint64_t)upper)<<32);
return hash;
}
......
......@@ -95,7 +95,7 @@ int ssg_group_attach_send(
/* allocate a buffer of the given size to try to store the group view in */
/* NOTE: We don't know if this buffer is big enough to store the complete
* view. If the buffers is not large enough, the group member we are
* view. If the buffer is not large enough, the group member we are
* attaching too will send a NACK indicating the necessary buffer size
*/
tmp_view_buf = malloc(tmp_view_buf_size);
......@@ -248,48 +248,37 @@ DEFINE_MARGO_RPC_HANDLER(ssg_group_attach_recv_ult)
static int ssg_group_view_serialize(
ssg_group_view_t *view, void **buf, hg_size_t *buf_size)
{
unsigned int i;
hg_size_t view_size = 0;
int tmp_size;
void *view_buf, *buf_p, *str_p;
ssg_member_state_t *member_state;
hg_size_t view_buf_size = 0;
void *view_buf;
void *buf_p, *str_p, *id_p;
*buf = NULL;
*buf_size = 0;
/* first determine view size */
for (i = 0; i < view->size; i++)
LL_FOREACH(view->member_list, member_state)
{
if (view->member_states[i].addr_str)
view_size += (strlen(view->member_states[i].addr_str) + 1);
else
view_size += 1;
view_buf_size += sizeof(ssg_member_id_t) + strlen(member_state->addr_str) + 1;
}
view_buf = malloc(view_size);
view_buf = malloc(view_buf_size);
if(!view_buf)
return SSG_FAILURE;
buf_p = view_buf;
for (i = 0; i < view->size; i++)
{
char null = '\0';
if (view->member_states[i].addr_str)
LL_FOREACH(view->member_list, member_state)
{
tmp_size = strlen(view->member_states[i].addr_str) + 1;
str_p = view->member_states[i].addr_str;
}
else
{
tmp_size = 1;
str_p = &null;
}
memcpy(buf_p, str_p, tmp_size);
buf_p += tmp_size;
str_p = member_state->addr_str;
id_p = &member_state->id;
memcpy(buf_p, id_p, sizeof(ssg_member_id_t));
buf_p += sizeof(ssg_member_id_t);
strcpy(buf_p, str_p);
buf_p += strlen(member_state->addr_str) + 1;
}
*buf = view_buf;
*buf_size = view_size;
*buf_size = view_buf_size;
return SSG_SUCCESS;
}
......
......@@ -31,7 +31,6 @@
#ifdef SSG_USE_SWIM_FD
#include "swim-fd/swim-fd.h"
#endif
#include "uthash.h"
/* arguments for group lookup ULTs */
struct ssg_group_lookup_ult_args
......@@ -591,8 +590,10 @@ hg_addr_t ssg_get_addr(
{
ssg_group_descriptor_t *group_descriptor = (ssg_group_descriptor_t *)group_id;
ssg_group_view_t *group_view = NULL;
ssg_member_state_t *member_state;
if (!ssg_inst || group_id == SSG_GROUP_ID_NULL)
if (!ssg_inst || group_id == SSG_GROUP_ID_NULL ||
member_id == SSG_MEMBER_ID_INVALID)
return HG_ADDR_NULL;
if (group_descriptor->owner_status == SSG_OWNER_IS_MEMBER)
......@@ -622,13 +623,12 @@ hg_addr_t ssg_get_addr(
if (group_view)
{
/* XXX for now we assume member ids are dense ranks and error out
* if they are not within allowable range for the group view size
*/
if (member_id >= group_view->size)
HASH_FIND(hh, group_view->member_map, &member_id, sizeof(ssg_member_id_t),
member_state);
if (member_state)
return member_state->addr;
else
return HG_ADDR_NULL;
return group_view->member_states[member_id].addr;
}
else
return HG_ADDR_NULL;
......@@ -865,7 +865,7 @@ void ssg_group_dump(
group_view = &g->view;
group_name = g->name;
strcpy(group_role, "member");
sprintf(group_self_id, "%"PRIu64, g->self_id);
sprintf(group_self_id, "%lu", g->self_id);
}
}
else if (group_descriptor->owner_status == SSG_OWNER_IS_ATTACHER)
......@@ -890,7 +890,7 @@ void ssg_group_dump(
if (group_view)
{
unsigned int i;
ssg_member_state_t *member_state, *tmp_ms;
printf("SSG membership information for group '%s':\n", group_name);
printf("\trole: '%s'\n", group_role);
......@@ -898,11 +898,10 @@ void ssg_group_dump(
printf("\tself_id: %s\n", group_self_id);
printf("\tsize: %d\n", group_view->size);
printf("\tview:\n");
for (i = 0; i < group_view->size; i++)
HASH_ITER(hh, group_view->member_map, member_state, tmp_ms)
{
if (group_view->member_states[i].is_member)
printf("\t\tid: %d\taddr: %s\n", i,
group_view->member_states[i].addr_str);
printf("\t\tid: %lu\taddr: %s\n", member_state->id,
member_state->addr_str);
}
}
else
......@@ -920,15 +919,23 @@ void ssg_apply_membership_update(
ssg_group_t *g,
ssg_membership_update_t update)
{
ssg_member_state_t *member_state;
if(!ssg_inst || !g) return;
if (update.type == SSG_MEMBER_REMOVE)
{
margo_addr_free(ssg_inst->mid, g->view.member_states[update.member].addr);
free(g->view.member_states[update.member].addr_str);
g->view.member_states[update.member].addr_str = NULL;
g->view.member_states[update.member].is_member = 0;
/* XXX: need to update size ... g->view.size--; */
HASH_FIND(hh, g->view.member_map, &update.member, sizeof(ssg_member_id_t),
member_state);
if (member_state)
{
LL_DELETE(g->view.member_list, member_state);
HASH_DELETE(hh, g->view.member_map, member_state);
margo_addr_free(ssg_inst->mid, member_state->addr);
free(member_state->addr_str);
free(member_state);
g->view.size--;
}
}
else
{
......@@ -1086,7 +1093,7 @@ static int ssg_group_view_create(
/* add self state to membership view */
LL_PREPEND(view->member_list, tmp_ms);
HASH_ADD(hh, view->member_map, id, sizeof(ssg_member_id_t),
HASH_ADD(hh, view->member_map, id, sizeof(ssg_member_id_t), tmp_ms);
/* don't look up our own address, we already know it */
continue;
......@@ -1120,7 +1127,7 @@ static int ssg_group_view_create(
if (aret != ABT_SUCCESS) goto fini;
else if (lookup_ult_args[i].out != HG_SUCCESS)
{
fprintf(stderr, "Error: SSG unable to lookup HG address for member %d"
fprintf(stderr, "Error: SSG unable to lookup HG address for member %lu"
"(err=%d)\n", lookup_ult_args[i].member_state->id,
lookup_ult_args[i].out);
goto fini;
......
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