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

remove kv init/finalize routines

these small wrappers around margo init/finalize aren't helpful when
compositing with multiple services
parent db05fb0a
......@@ -312,38 +312,6 @@ hg_return_t kv_close(kv_context_t *context);
// benchmark routine
bench_result_t *kv_benchmark(kv_context_t *context, int32_t count);
static inline char *kv_protocol(const char *addr_str) {
int psize = 24;
char *protocol = (char*)malloc(psize);
memset(protocol, 0, psize);
/* we only need to the proto portion of the address to initialize */
for(int i=0; i<psize && addr_str[i] != '\0' && addr_str[i] != ':'; i++)
protocol[i] = addr_str[i];
return protocol;
}
// pass in address string and mode
// string can be just the protocol (e.g. "ofi+tcp")
// mode can be MARGO_CLIENT_MODE or MARGO_SERVER_MODE
static inline margo_instance_id kv_margo_init(const char *addr_str, int mode)
{
margo_instance_id mid;
assert(addr_str != NULL); // better pass something!
assert(mode == MARGO_CLIENT_MODE || mode == MARGO_SERVER_MODE);
mid = margo_init(addr_str, mode, 0, -1);
assert(mid != MARGO_INSTANCE_NULL);
margo_diag_start(mid); // initialize diagnostic support
return mid;
}
static inline void kv_margo_finalize(margo_instance_id mid)
{
margo_finalize(mid);
}
#if defined(__cplusplus)
}
#endif
......
......@@ -71,7 +71,8 @@ int main(int argc, char **argv)
size_t items = atoi(argv[1]);
char *server_addr_str = argv[2];
margo_instance_id mid = kv_margo_init(kv_protocol(server_addr_str), MARGO_CLIENT_MODE);
margo_instance_id mid = margo_init(server_addr_str,
MARGO_CLIENT_MODE, 0, -1);
context = kv_client_register(mid);
ret = kv_open(context, server_addr_str, "db/testdb");
......@@ -97,5 +98,5 @@ int main(int argc, char **argv)
ret = kv_client_deregister(context);
assert(ret == HG_SUCCESS);
kv_margo_finalize(mid);
margo_finalize(mid);
}
......@@ -10,7 +10,7 @@ int main(int argc, char **argv) {
assert(argc == 2);
char *server_addr_str = argv[1];
margo_instance_id mid = kv_margo_init(kv_protocol(server_addr_str), MARGO_CLIENT_MODE);
margo_instance_id mid = margo_init(argv[1], MARGO_CLIENT_MODE, 0, -1);
kv_context_t *context = kv_client_register(mid);
/* open */
......@@ -87,5 +87,5 @@ int main(int argc, char **argv) {
ret = kv_client_deregister(context);
assert(ret == HG_SUCCESS);
kv_margo_finalize(mid);
margo_finalize(mid);
}
......@@ -61,12 +61,10 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, MPI_UNDEFINED, rank, &clientComm);
// kv-server
char *proto = kv_protocol(addr_str);
kvgroup_context_t *context = kvgroup_server_register(kv_margo_init(proto, MARGO_SERVER_MODE),
kvgroup_context_t *context = kvgroup_server_register(margo_init(addr_str,
MARGO_SERVER_MODE, 0, -1),
ssg_name,
ssgComm);
free(proto); // only needed by kv_margo_init
hret = margo_addr_self(context->mid, &server_addr);
DIE_IF(hret != HG_SUCCESS, "margo_addr_self");
......@@ -111,10 +109,9 @@ int main(int argc, char *argv[])
// kv-client
char *proto = kvgroup_protocol(gid);
kvgroup_context_t *context = kvgroup_client_register(kv_margo_init(proto, MARGO_CLIENT_MODE),
kvgroup_context_t *context = kvgroup_client_register(margo_init(proto,
MARGO_CLIENT_MODE, 0, -1),
gid);
free(proto); // only needed by kv_margo_init
hret = margo_addr_self(context->mid, &client_addr);
DIE_IF(hret != HG_SUCCESS, "margo_addr_self");
......
......@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, MPI_UNDEFINED, rank, &clientComm);
// kv-server
margo_instance_id mid = kv_margo_init(kv_protocol(addr_str), MARGO_SERVER_MODE);
margo_instance_id mid = margo_init(addr_str, MARGO_SERVER_MODE, 0, -1);
kv_context_t *context = kv_server_register(mid);
hret = margo_addr_self(context->mid, &server_addr);
......@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
kv_server_deregister(context);
printf("rank %d: server deregistered\n", rank);
kv_margo_finalize(mid);
margo_finalize(mid);
}
else {
hg_size_t addr_str_sz = 128;
......@@ -88,7 +88,8 @@ int main(int argc, char *argv[])
printf("client (rank %d): server addr_str: %s\n", rank, server_addr_str);
// kv-client
margo_instance_id mid = kv_margo_init(kv_protocol(server_addr_str), MARGO_CLIENT_MODE);
margo_instance_id mid = margo_init(server_addr_str,
MARGO_CLIENT_MODE, 0, -1);
kv_context_t *context = kv_client_register(mid);
hret = margo_addr_self(context->mid, &client_addr);
......@@ -163,7 +164,7 @@ int main(int argc, char *argv[])
kv_client_deregister(context);
printf("rank %d: client deregistered\n", rank);
kv_margo_finalize(mid);
margo_finalize(mid);
}
MPI_Finalize();
......
......@@ -4,7 +4,6 @@
int main(int argc, char **argv) {
assert(argc == 2);
char *addr_str = argv[1];
margo_instance_id mid = margo_init(argv[1] == NULL ? "ofi+tcp://" : argv[1],
MARGO_SERVER_MODE, 0, -1);
......
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