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