Commit cb2bf689 authored by Jonathan Jenkins's avatar Jonathan Jenkins
Browse files

add non-abt init method

parent 8aa2745a
......@@ -56,7 +56,6 @@ int main(int argc, char **argv)
int compute_es_count = -1;
struct worker_ult_arg *arg_array;
struct worker_ult_common common;
int *done;
if(argc != 10)
{
......@@ -125,7 +124,7 @@ int main(int argc, char **argv)
}
/* initialize abt_io */
common.aid = abt_io_init(io_pool);
common.aid = abt_io_init_pool(io_pool);
assert(common.aid != NULL);
}
......@@ -214,7 +213,6 @@ static void worker_ult(void *_arg)
size_t ret;
char template[256];
int fd;
int done = 0;
if(common->opt_compute)
{
......
......@@ -195,7 +195,7 @@ static void abt_bench(int buffer_per_thread, unsigned int concurrency, size_t si
assert(ret == 0);
/* initialize abt_io */
aid = abt_io_init(progress_pool);
aid = abt_io_init_pool(progress_pool);
assert(aid != NULL);
ABT_mutex_create(&mutex);
......@@ -319,7 +319,7 @@ static void abt_bench_nb(int buffer_per_thread, unsigned int concurrency, size_t
assert(ret == 0);
/* initialize abt_io */
aid = abt_io_init(progress_pool);
aid = abt_io_init_pool(progress_pool);
assert(aid != NULL);
/* set up buffers */
......
......@@ -23,12 +23,24 @@ typedef struct abt_io_instance* abt_io_instance_id;
struct abt_io_op;
typedef struct abt_io_op abt_io_op_t;
/**
* Initializes abt_io library, using the specified number of backing threads. A
* count of zero currently indicates that concurrent I/O progress is not made
* unless control is passed to blocking abt-io calls (or other blocking calls
* w.r.t. argobots).
* @param [in] progress_pool Argobots pool to drive I/O
* @returns abt_io instance id on success, NULL upon error
*/
abt_io_instance_id abt_io_init(int backing_thread_count);
/**
* Initializes abt_io library.
* Initializes abt_io library using the specified Argobots pool for operation
* dispatch.
* @param [in] progress_pool Argobots pool to drive I/O
* @returns abt_io instance id on success, NULL upon error
*/
abt_io_instance_id abt_io_init(ABT_pool progress_pool);
abt_io_instance_id abt_io_init_pool(ABT_pool progress_pool);
/**
* Shuts down abt_io library and its underlying resources
......
......@@ -23,8 +23,9 @@
struct abt_io_instance
{
/* provided by caller */
ABT_pool progress_pool;
ABT_xstream *progress_xstreams;
int num_xstreams;
};
struct abt_io_op
......@@ -34,23 +35,77 @@ struct abt_io_op
void (*free_fn)(void*);
};
abt_io_instance_id abt_io_init(ABT_pool progress_pool)
abt_io_instance_id abt_io_init(int backing_thread_count)
{
struct abt_io_instance *aid;
ABT_pool pool;
ABT_xstream self_xstream;
ABT_xstream *progress_xstreams = NULL;
int ret;
if (backing_thread_count < 0) return NULL;
aid = malloc(sizeof(*aid));
if (aid == NULL) return ABT_IO_INSTANCE_NULL;
if (backing_thread_count == 0) {
aid->num_xstreams = 0;
ret = ABT_xstream_self(&self_xstream);
if (ret != ABT_SUCCESS) { free(aid); return ABT_IO_INSTANCE_NULL; }
ret = ABT_xstream_get_main_pools(self_xstream, 1, &pool);
if (ret != ABT_SUCCESS) { free(aid); return ABT_IO_INSTANCE_NULL; }
}
else {
aid->num_xstreams = backing_thread_count;
progress_xstreams = malloc(
backing_thread_count * sizeof(*progress_xstreams));
if (progress_xstreams == NULL) {
free(aid);
return ABT_IO_INSTANCE_NULL;
}
ret = ABT_snoozer_xstream_create(backing_thread_count, &pool,
progress_xstreams);
if (ret != ABT_SUCCESS) {
free(aid);
free(progress_xstreams);
return ABT_IO_INSTANCE_NULL;
}
}
aid->progress_pool = pool;
aid->progress_xstreams = progress_xstreams;
return aid;
}
abt_io_instance_id abt_io_init_pool(ABT_pool progress_pool)
{
struct abt_io_instance *aid;
aid = malloc(sizeof(*aid));
if(!aid) return(ABT_IO_INSTANCE_NULL);
memset(aid, 0, sizeof(*aid));
aid->progress_pool = progress_pool;
aid->progress_xstreams = NULL;
aid->num_xstreams = 0;
return aid;
}
void abt_io_finalize(abt_io_instance_id aid)
{
int i;
if (aid->num_xstreams) {
for (i = 0; i < aid->num_xstreams; i++) {
ABT_xstream_join(aid->progress_xstreams[i]);
ABT_xstream_free(&aid->progress_xstreams[i]);
}
free(aid->progress_xstreams);
// pool gets implicitly freed
}
free(aid);
return;
}
struct abt_io_open_state
......
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