Commit cab2fa11 authored by Philip Carns's avatar Philip Carns

optional operation without dedicated progress pool

- fixes #5
- suggested by John
- run example server as "./server single" intead of "./server" to
  demonstrate
parent 0e1703d2
...@@ -31,7 +31,27 @@ int main(int argc, char **argv) ...@@ -31,7 +31,27 @@ int main(int argc, char **argv)
na_context_t *na_context; na_context_t *na_context;
hg_context_t *hg_context; hg_context_t *hg_context;
hg_class_t *hg_class; hg_class_t *hg_class;
int single_pool_mode = 0;
if(argc > 2)
{
fprintf(stderr, "Usage: ./server <single>\n");
fprintf(stderr, " Note: the optional \"single\" argument makes the server use a single ABT pool for both HG progress and RPC handlers.\n");
return(-1);
}
if(argc == 2)
{
if(strcmp(argv[1], "single") == 0)
single_pool_mode = 1;
else
{
fprintf(stderr, "Usage: ./server <single>\n");
fprintf(stderr, " Note: the optional \"single\" argument makes the server use a single ABT pool for both HG progress and RPC handlers.\n");
return(-1);
}
}
/* boilerplate HG initialization steps */ /* boilerplate HG initialization steps */
/***************************************/ /***************************************/
network_class = NA_Initialize("tcp://localhost:1234", NA_TRUE); network_class = NA_Initialize("tcp://localhost:1234", NA_TRUE);
...@@ -96,12 +116,15 @@ int main(int argc, char **argv) ...@@ -96,12 +116,15 @@ int main(int argc, char **argv)
return(-1); return(-1);
} }
/* create a dedicated ES drive Mercury progress */ if(!single_pool_mode)
ret = ABT_snoozer_xstream_create(1, &progress_pool, &progress_xstream);
if(ret != 0)
{ {
fprintf(stderr, "Error: ABT_snoozer_xstream_create()\n"); /* create a dedicated ES drive Mercury progress */
return(-1); ret = ABT_snoozer_xstream_create(1, &progress_pool, &progress_xstream);
if(ret != 0)
{
fprintf(stderr, "Error: ABT_snoozer_xstream_create()\n");
return(-1);
}
} }
/* actually start margo */ /* actually start margo */
...@@ -110,7 +133,10 @@ int main(int argc, char **argv) ...@@ -110,7 +133,10 @@ int main(int argc, char **argv)
* communication. * communication.
*/ */
/***************************************/ /***************************************/
mid = margo_init(progress_pool, handler_pool, hg_context, hg_class); if(single_pool_mode)
mid = margo_init(handler_pool, handler_pool, hg_context, hg_class);
else
mid = margo_init(progress_pool, handler_pool, hg_context, hg_class);
/* register RPC */ /* register RPC */
MERCURY_REGISTER(hg_class, "my_rpc", my_rpc_in_t, my_rpc_out_t, MERCURY_REGISTER(hg_class, "my_rpc", my_rpc_in_t, my_rpc_out_t,
...@@ -129,8 +155,11 @@ int main(int argc, char **argv) ...@@ -129,8 +155,11 @@ int main(int argc, char **argv)
/* shut down everything */ /* shut down everything */
margo_finalize(mid); margo_finalize(mid);
ABT_xstream_join(progress_xstream); if(!single_pool_mode)
ABT_xstream_free(&progress_xstream); {
ABT_xstream_join(progress_xstream);
ABT_xstream_free(&progress_xstream);
}
ABT_finalize(); ABT_finalize();
......
...@@ -109,6 +109,7 @@ static void hg_progress_fn(void* foo) ...@@ -109,6 +109,7 @@ static void hg_progress_fn(void* foo)
int ret; int ret;
unsigned int actual_count; unsigned int actual_count;
struct margo_instance *mid = (struct margo_instance *)foo; struct margo_instance *mid = (struct margo_instance *)foo;
size_t size;
while(!mid->hg_progress_shutdown_flag) while(!mid->hg_progress_shutdown_flag)
{ {
...@@ -117,7 +118,18 @@ static void hg_progress_fn(void* foo) ...@@ -117,7 +118,18 @@ static void hg_progress_fn(void* foo)
} while((ret == HG_SUCCESS) && actual_count && !mid->hg_progress_shutdown_flag); } while((ret == HG_SUCCESS) && actual_count && !mid->hg_progress_shutdown_flag);
if(!mid->hg_progress_shutdown_flag) if(!mid->hg_progress_shutdown_flag)
HG_Progress(mid->hg_class, mid->hg_context, 100); {
ABT_pool_get_total_size(mid->progress_pool, &size);
if(size > 1)
{
HG_Progress(mid->hg_class, mid->hg_context, 0);
ABT_thread_yield();
}
else
{
HG_Progress(mid->hg_class, mid->hg_context, 100);
}
}
} }
return; return;
......
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