Commit 122d70cf authored by Philip Carns's avatar Philip Carns

iterate through transfers

parent f295222a
...@@ -45,6 +45,8 @@ struct bench_worker_arg ...@@ -45,6 +45,8 @@ struct bench_worker_arg
{ {
bake_provider_handle_t bph; bake_provider_handle_t bph;
bake_target_id_t bti; bake_target_id_t bti;
ABT_mutex *cur_off_mutex;
unsigned long *cur_off;
}; };
/* defealt to 512 MiB total xfer unless specified otherwise */ /* defealt to 512 MiB total xfer unless specified otherwise */
...@@ -358,12 +360,16 @@ static int run_benchmark(struct options *opts, bake_provider_handle_t bph, ...@@ -358,12 +360,16 @@ static int run_benchmark(struct options *opts, bake_provider_handle_t bph,
int i; int i;
ABT_thread *tid_array; ABT_thread *tid_array;
struct bench_worker_arg *arg_array; struct bench_worker_arg *arg_array;
ABT_mutex cur_off_mutex;
unsigned long cur_off = 0;
tid_array = malloc(g_opts.concurrency * sizeof(*tid_array)); tid_array = malloc(g_opts.concurrency * sizeof(*tid_array));
assert(tid_array); assert(tid_array);
arg_array = malloc(g_opts.concurrency * sizeof(*arg_array)); arg_array = malloc(g_opts.concurrency * sizeof(*arg_array));
assert(arg_array); assert(arg_array);
ABT_mutex_create(&cur_off_mutex);
ret = ABT_xstream_self(&xstream); ret = ABT_xstream_self(&xstream);
assert(ret == 0); assert(ret == 0);
...@@ -374,6 +380,8 @@ static int run_benchmark(struct options *opts, bake_provider_handle_t bph, ...@@ -374,6 +380,8 @@ static int run_benchmark(struct options *opts, bake_provider_handle_t bph,
{ {
arg_array[i].bph = bph; arg_array[i].bph = bph;
arg_array[i].bti = bti; arg_array[i].bti = bti;
arg_array[i].cur_off_mutex = &cur_off_mutex;
arg_array[i].cur_off = &cur_off;
ret = ABT_thread_create(pool, bench_worker, ret = ABT_thread_create(pool, bench_worker,
&arg_array[i], ABT_THREAD_ATTR_NULL, &tid_array[i]); &arg_array[i], ABT_THREAD_ATTR_NULL, &tid_array[i]);
assert(ret == 0); assert(ret == 0);
...@@ -386,6 +394,7 @@ static int run_benchmark(struct options *opts, bake_provider_handle_t bph, ...@@ -386,6 +394,7 @@ static int run_benchmark(struct options *opts, bake_provider_handle_t bph,
} }
free(tid_array); free(tid_array);
ABT_mutex_free(&cur_off_mutex);
return(0); return(0);
} }
...@@ -395,14 +404,22 @@ static void bench_worker(void *_arg) ...@@ -395,14 +404,22 @@ static void bench_worker(void *_arg)
struct bench_worker_arg* arg = _arg; struct bench_worker_arg* arg = _arg;
bake_region_id_t rid; bake_region_id_t rid;
int ret; int ret;
char* this_buffer;
/* TODO: iterate through g_buffer to end and stop, transfering xfer_size ABT_mutex_spinlock(*arg->cur_off_mutex);
* at a time, coordinating with other workers on offset. Stop benchmark while(*arg->cur_off < g_opts.total_mem_size)
* when the end is reached and do not reuse memory buffers. {
*/ this_buffer = (char*)((unsigned long)g_buffer + *arg->cur_off);
ret = bake_create_write_persist(arg->bph, arg->bti, g_buffer, (*arg->cur_off) += g_opts.xfer_size;
g_opts.xfer_size, &rid); ABT_mutex_unlock(*arg->cur_off_mutex);
assert(ret == 0);
ret = bake_create_write_persist(arg->bph, arg->bti, this_buffer,
g_opts.xfer_size, &rid);
assert(ret == 0);
ABT_mutex_spinlock(*arg->cur_off_mutex);
}
ABT_mutex_unlock(*arg->cur_off_mutex);
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