Commit e5519b23 authored by Shane Snyder's avatar Shane Snyder

cleanup/reorganize more ssg_init code

* init routines take a margo_instace_id rather than HG inputs
* rank resolution happens at init time, so no need for standalone
  ssg_resolve_rank() function
* ssg_lookup is now no longer public and done automatically as
  part of init as well
parent edb4c76c
......@@ -41,31 +41,15 @@ typedef struct ssg *ssg_t;
// is_member - nonzero if caller is expected to be in the group, zero otherwise
// - ssg_lookup fails if caller is unable to identify with one of the
// config entries
ssg_t ssg_init_config(hg_class_t *hgcl, const char * fname, int is_member);
ssg_t ssg_init_config(margo_instance_id mid, const char * fname, int is_member);
#ifdef HAVE_MPI
// mpi based (no config file) - all participants (defined by the input
// communicator) do a global address exchange
// in this case, the caller has already initialized HG with its address
ssg_t ssg_init_mpi(hg_class_t *hgcl, MPI_Comm comm);
ssg_t ssg_init_mpi(margo_instance_id mid, MPI_Comm comm);
// in the config-file initialization, rank determination is deferred until
// lookup. In the case where the rank is needed but you don't want to
// necessarily look up everyone, this call will resolve the rank. In the MPI
// bootstrap mode, or if the rank has already been resolved, this operation
// is a no-op
// the ssg_lookup functions implicitly call this
// this function works by using string comparison of HG_Addr_to_string against
// the entries in the config file
hg_return_t ssg_resolve_rank(ssg_t s, hg_class_t *hgcl);
// once the ssg has been initialized, wireup (a collection of HG_Addr_lookups)
// note that this is a simple blocking implementation - no margo/etc here
hg_return_t ssg_lookup(ssg_t s, hg_context_t *hgctx);
/// finalization
// teardown all connections associated with the given ssg
......@@ -87,6 +71,7 @@ const char * ssg_get_addr_str(const ssg_t s, int rank);
/// mercury support
#if 0
// group serialization mechanism
hg_return_t hg_proc_ssg_t(hg_proc_t proc, ssg_t *s);
......@@ -101,19 +86,12 @@ int ssg_dump(const ssg_t s, const char *fname);
// race condition - call this before kicking off the progress loop with margo
void ssg_register_barrier(ssg_t s, hg_class_t *hgcl);
// set/get the margo instance id used in margo communication calls
void ssg_set_margo_id(ssg_t s, margo_instance_id mid);
margo_instance_id ssg_get_margo_id(ssg_t s);
// a "margo-aware" version of hg_lookup - still looks up everyone in one go.
// requires ssg_set_margo_id to have been called.
hg_return_t ssg_lookup_margo(ssg_t s);
// perform a naive N-1 barrier using margo.
// requires ssg_set_margo_id to have been called.
// NOTE: rank must be set on all ranks prior to calling this. I.e. should init
// the rank prior to starting up margo
hg_return_t ssg_barrier_margo(ssg_t s);
#ifdef __cplusplus
......@@ -18,14 +18,13 @@
struct ssg
hg_class_t *hgcl;
margo_instance_id mid;
int rank;
int num_addrs;
char **addr_strs;
hg_addr_t *addrs;
void *backing_buf;
int num_addrs;
int buf_size;
int rank;
margo_instance_id mid;
hg_id_t barrier_rpc_id;
int barrier_id;
int barrier_count;
This diff is collapsed.
......@@ -64,9 +64,6 @@ int main(int argc, char *argv[])
// process state
int rank, size; // not mpi
// return codes
hg_return_t hret;
ABT_init(argc, argv);
#ifdef HAVE_MPI
......@@ -83,18 +80,9 @@ int main(int argc, char *argv[])
argc -= 2; argv += 2;
#if 1
if (!argc) { usage(); return 1; }
addr_str = argv[0];
argc--; argv++;
int mpi_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
if(mpi_rank == 0)
addr_str = "bmi+tcp://3344";
addr_str = "bmi+tcp://3345";
// init HG
hgcl = HG_Init(addr_str, HG_TRUE);
......@@ -112,7 +100,7 @@ int main(int argc, char *argv[])
argc--; argv++;
if (strcmp(mode, "mpi") == 0) {
#ifdef HAVE_MPI
s = ssg_init_mpi(hgcl, MPI_COMM_WORLD);
s = ssg_init_mpi(mid, MPI_COMM_WORLD);
fprintf(stderr, "Error: MPI support not built in\n");
return 1;
......@@ -123,7 +111,7 @@ int main(int argc, char *argv[])
if (!argc) { usage(); return 1; }
conf = argv[0];
argc--; argv++;
s = ssg_init_config(hgcl, conf, 1);
s = ssg_init_config(mid, conf, 1);
else {
fprintf(stderr, "Error: bad mode passed in %s\n", mode);
......@@ -132,15 +120,9 @@ int main(int argc, char *argv[])
DIE_IF(s == SSG_NULL, "ssg_init (mode %s)", mode);
ssg_set_margo_id(s, mid);
rank = ssg_get_rank(s);
size = ssg_get_count(s);
// resolve group addresses
hret = ssg_lookup_margo(s);
DIE_IF(hret != HG_SUCCESS, "ssg_lookup");
DEBUG("%d of %d: ssg_lookup complete\n", rank, size);
if (sleep_time >= 0) margo_thread_sleep(mid, sleep_time * 1000.0);
DEBUG("%d of %d: sleep over\n", rank, size);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment