Commit 73c74312 authored by Philip Carns's avatar Philip Carns
Browse files

benchmark option support

parent e34624a4
...@@ -16,6 +16,15 @@ ...@@ -16,6 +16,15 @@
#include <abt-io.h> #include <abt-io.h>
#include <abt-snoozer.h> #include <abt-snoozer.h>
struct worker_ult_arg
{
int opt_abt_io;
int opt_abt_snoozer;
int opt_unit_size;
int opt_num_units;
abt_io_instance_id aid;
};
static void worker_ult(void *_arg); static void worker_ult(void *_arg);
static double wtime(void); static double wtime(void);
...@@ -30,12 +39,27 @@ int main(int argc, char **argv) ...@@ -30,12 +39,27 @@ int main(int argc, char **argv)
ABT_pool io_pool; ABT_pool io_pool;
ABT_xstream *compute_xstreams; ABT_xstream *compute_xstreams;
ABT_pool compute_pool; ABT_pool compute_pool;
abt_io_instance_id aid;
int io_es_count = 4; int io_es_count = 4;
int compute_es_count = 16; int compute_es_count = 16;
int target_ops = 100; struct worker_ult_arg arg;
if(argc != 5)
{
fprintf(stderr, "Usage: abt-io-overlap <abt_io 0|1> <abt_snoozer 0|1> <unit_size> <num_units>\n");
return(-1);
}
ret = sscanf(argv[1], "%d", &arg.opt_abt_io);
assert(ret == 1);
ret = sscanf(argv[2], "%d", &arg.opt_abt_snoozer);
assert(ret == 1);
ret = sscanf(argv[3], "%d", &arg.opt_unit_size);
assert(ret == 1);
assert(arg.opt_unit_size % 4096 == 0);
ret = sscanf(argv[4], "%d", &arg.opt_num_units);
assert(ret == 1);
tid_array = malloc(target_ops * sizeof(*tid_array)); tid_array = malloc(arg.opt_num_units * sizeof(*tid_array));
assert(tid_array); assert(tid_array);
io_xstreams = malloc(io_es_count * sizeof(*io_xstreams)); io_xstreams = malloc(io_es_count * sizeof(*io_xstreams));
...@@ -48,57 +72,79 @@ int main(int argc, char **argv) ...@@ -48,57 +72,79 @@ int main(int argc, char **argv)
ret = ABT_init(argc, argv); ret = ABT_init(argc, argv);
assert(ret == 0); assert(ret == 0);
/* set primary ES to idle without polling */ if(arg.opt_abt_snoozer)
ret = ABT_snoozer_xstream_self_set(); {
assert(ret == 0); /* set primary ES to idle without polling */
ret = ABT_snoozer_xstream_self_set();
assert(ret == 0);
/* create dedicated pool drive IO */
ret = ABT_snoozer_xstream_create(io_es_count, &io_pool, io_xstreams);
assert(ret == 0);
/* create dedicated pool for computatcomputen */ /* create dedicated pool for computatcomputen */
ret = ABT_snoozer_xstream_create(compute_es_count, &compute_pool, compute_xstreams); ret = ABT_snoozer_xstream_create(compute_es_count, &compute_pool, compute_xstreams);
assert(ret == 0); assert(ret == 0);
}
else
{
assert(0);
}
/* initialize abt_io */ if(arg.opt_abt_io)
aid = abt_io_init(io_pool); {
assert(aid != NULL); if(arg.opt_abt_snoozer)
{
/* create dedicated pool drive IO */
ret = ABT_snoozer_xstream_create(io_es_count, &io_pool, io_xstreams);
assert(ret == 0);
}
else
{
assert(0);
}
/* initialize abt_io */
arg.aid = abt_io_init(io_pool);
assert(arg.aid != NULL);
}
start = wtime(); start = wtime();
for(i=0; i<target_ops; i++) for(i=0; i<arg.opt_num_units; i++)
{ {
/* create ULTs */ /* create ULTs */
ret = ABT_thread_create(compute_pool, worker_ult, NULL, ABT_THREAD_ATTR_NULL, &tid_array[i]); ret = ABT_thread_create(compute_pool, worker_ult, &arg, ABT_THREAD_ATTR_NULL, &tid_array[i]);
assert(ret == 0); assert(ret == 0);
} }
for(i=0; i<target_ops; i++) for(i=0; i<arg.opt_num_units; i++)
ABT_thread_join(tid_array[i]); ABT_thread_join(tid_array[i]);
end = wtime(); end = wtime();
for(i=0; i<target_ops; i++) for(i=0; i<arg.opt_num_units; i++)
ABT_thread_free(&tid_array[i]); ABT_thread_free(&tid_array[i]);
seconds = end-start; seconds = end-start;
abt_io_finalize(aid); /* wait on the compute ESs to complete */
/* wait on the ESs to complete */
for(i=0; i<io_es_count; i++)
{
ABT_xstream_join(io_xstreams[i]);
ABT_xstream_free(&io_xstreams[i]);
}
/* wait on the ESs to complete */
for(i=0; i<compute_es_count; i++) for(i=0; i<compute_es_count; i++)
{ {
ABT_xstream_join(compute_xstreams[i]); ABT_xstream_join(compute_xstreams[i]);
ABT_xstream_free(&compute_xstreams[i]); ABT_xstream_free(&compute_xstreams[i]);
} }
if(arg.opt_abt_io)
{
abt_io_finalize(arg.aid);
/* wait on IO ESs to complete */
for(i=0; i<io_es_count; i++)
{
ABT_xstream_join(io_xstreams[i]);
ABT_xstream_free(&io_xstreams[i]);
}
}
ABT_finalize(); ABT_finalize();
free(tid_array); free(tid_array);
...@@ -110,37 +156,43 @@ int main(int argc, char **argv) ...@@ -110,37 +156,43 @@ int main(int argc, char **argv)
static void worker_ult(void *_arg) static void worker_ult(void *_arg)
{ {
struct write_abt_arg* arg = _arg; struct worker_ult_arg* arg = _arg;
void *buffer; void *buffer;
size_t ret; size_t ret;
int size = 1024*1024*4;
char template[256]; char template[256];
int fd; int fd;
fprintf(stderr, "start\n"); fprintf(stderr, "start\n");
ret = posix_memalign(&buffer, 4096, size); ret = posix_memalign(&buffer, 4096, arg->opt_unit_size);
assert(ret == 0); assert(ret == 0);
memset(buffer, 0, size); memset(buffer, 0, arg->opt_unit_size);
ret = RAND_bytes(buffer, size); ret = RAND_bytes(buffer, arg->opt_unit_size);
assert(ret == 1); assert(ret == 1);
sprintf(template, "./XXXXXX"); sprintf(template, "./XXXXXX");
fd = mkostemp(template, O_DIRECT|O_SYNC); if(arg->opt_abt_io)
assert(fd >= 0); {
ret = pwrite(fd, buffer, size, 0);
assert(ret == size);
ret = unlink(template);
assert(ret == 0);
#if 0 #if 0
ret = abt_io_pwrite(arg->aid, arg->fd, buffer, arg->size, my_offset); ret = abt_io_pwrite(arg->aid, arg->fd, buffer, arg->size, my_offset);
assert(ret == arg->size); assert(ret == arg->size);
#endif #endif
assert(0);
}
else
{
fd = mkostemp(template, O_DIRECT|O_SYNC);
assert(fd >= 0);
ret = pwrite(fd, buffer, arg->opt_unit_size, 0);
assert(ret == arg->opt_unit_size);
ret = unlink(template);
assert(ret == 0);
}
free(buffer); free(buffer);
fprintf(stderr, "end\n"); fprintf(stderr, "end\n");
......
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