Commit c9eda878 authored by Rob Latham's avatar Rob Latham
Browse files

allow 'separate-group' tests to shutdown cleanly

thanks to recent addition of margo_push_prefinalize_callback, the group
creating process can now exit cleanly.
parent e04acc55
......@@ -5,6 +5,7 @@
int main(int argc, char **argv)
{
int ret;
hg_addr_t remote_addr = HG_ADDR_NULL;
ssg_group_id_t gid;
margo_instance_id mid;
......@@ -25,8 +26,15 @@ int main(int argc, char **argv)
ssg_group_dump(gid);
fprintf(stderr, " dumped...\n");
remote_addr = ssg_get_group_member_addr(gid, ssg_get_group_member_id_from_rank(gid, 0));
assert(remote_addr != HG_ADDR_NULL);
ret = margo_shutdown_remote_instance(mid, remote_addr);
assert (ret == HG_SUCCESS);
ssg_group_unobserve(gid);
ssg_finalize();
margo_finalize(mid);
MPI_Finalize();
}
......@@ -4,12 +4,19 @@
#define GROUP_NAME "test-group"
#define ASSERT(__cond, __msg, ...) { if(!(__cond)) { fprintf(stderr, "[%s:%d] " __msg, __FILE__, __LINE__, __VA_ARGS__); exit(-1); } }
static void finalized_ssg_group_cb(void* data)
{
ssg_group_id_t gid = *((ssg_group_id_t*)data);
ssg_group_destroy(gid);
}
typedef struct {
ssg_group_id_t g_id;
margo_instance_id mid;
} finalize_args_t;
void ssg_finalize_callback(void* arg) {
fprintf(stderr, "Entering ssg_finalize_callback\n");
finalize_args_t* a = (finalize_args_t*)arg;
ssg_group_destroy(a->g_id);
fprintf(stderr, "Successfully destroyed ssg group\n");
ssg_finalize();
fprintf(stderr, "Successfully finalized ssg\n");
}
int main(int argc, char **argv)
{
......@@ -35,17 +42,24 @@ int main(int argc, char **argv)
fprintf(stderr, "ssg_group_create_mpi failed\n");
exit(-1);
}
margo_push_finalize_callback(mid, &finalized_ssg_group_cb, (void*)&gid);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)
ssg_group_id_store(argv[2], gid, 1);
fprintf(stderr, " just hanging out...\n");
finalize_args_t args = {
.g_id = gid,
.mid = mid
};
margo_push_prefinalize_callback(mid, ssg_finalize_callback, (void*)&args);
fprintf(stderr, " just hanging out waiting for shutdown\n");
margo_wait_for_finalize(mid);
fprintf(stderr, " .. done waiting: now cleaning up\n");
ssg_group_destroy(gid);
margo_finalize(mid);
fprintf(stderr, "bye\n");
MPI_Finalize();
}
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