Commit cab2fa11 authored by Philip Carns's avatar Philip Carns
Browse files

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,6 +31,26 @@ int main(int argc, char **argv) ...@@ -31,6 +31,26 @@ 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 */
/***************************************/ /***************************************/
...@@ -96,6 +116,8 @@ int main(int argc, char **argv) ...@@ -96,6 +116,8 @@ int main(int argc, char **argv)
return(-1); return(-1);
} }
if(!single_pool_mode)
{
/* create a dedicated ES drive Mercury progress */ /* create a dedicated ES drive Mercury progress */
ret = ABT_snoozer_xstream_create(1, &progress_pool, &progress_xstream); ret = ABT_snoozer_xstream_create(1, &progress_pool, &progress_xstream);
if(ret != 0) if(ret != 0)
...@@ -103,6 +125,7 @@ int main(int argc, char **argv) ...@@ -103,6 +125,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Error: ABT_snoozer_xstream_create()\n"); fprintf(stderr, "Error: ABT_snoozer_xstream_create()\n");
return(-1); return(-1);
} }
}
/* actually start margo */ /* actually start margo */
/* provide argobots pools for driving communication progress and /* provide argobots pools for driving communication progress and
...@@ -110,6 +133,9 @@ int main(int argc, char **argv) ...@@ -110,6 +133,9 @@ int main(int argc, char **argv)
* communication. * communication.
*/ */
/***************************************/ /***************************************/
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); mid = margo_init(progress_pool, handler_pool, hg_context, hg_class);
/* register RPC */ /* register RPC */
...@@ -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);
if(!single_pool_mode)
{
ABT_xstream_join(progress_xstream); ABT_xstream_join(progress_xstream);
ABT_xstream_free(&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,8 +118,19 @@ static void hg_progress_fn(void* foo) ...@@ -117,8 +118,19 @@ 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)
{
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); 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