From 9bcec8fc3e346f0ae24388d1a812df0035d3f909 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Sat, 7 May 2016 12:44:25 -0700 Subject: [PATCH] client-side code for bulk write --- src/bake-bulk.c | 67 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/src/bake-bulk.c b/src/bake-bulk.c index 3822962..9b446e2 100644 --- a/src/bake-bulk.c +++ b/src/bake-bulk.c @@ -19,10 +19,15 @@ struct bake_instance hg_context_t *hg_context; }; -struct bake_instance g_binst; /* TODO: replace later, hard coded global instance */ -static hg_id_t g_bake_bulk_shutdown_id; /* TODO: probably not global in the long run either */ -static hg_id_t g_bake_bulk_create_id; /* TODO: probably not global in the long run either */ -static hg_id_t g_bake_bulk_write_id; /* TODO: probably not global in the long run either */ +/* TODO: replace later, hard coded global instance */ +struct bake_instance g_binst; + +/* TODO: probably not global in the long run either */ +static hg_id_t g_bake_bulk_shutdown_id; +/* TODO: probably not global in the long run either */ +static hg_id_t g_bake_bulk_create_id; +/* TODO: probably not global in the long run either */ +static hg_id_t g_bake_bulk_write_id; int bake_probe_instance( const char *mercury_dest, @@ -137,8 +142,54 @@ int bake_bulk_write( void const *buf, uint64_t buf_size) { + hg_return_t hret; + hg_handle_t handle; + bake_bulk_write_in_t in; + bake_bulk_write_out_t out; + int ret; + + in.bti = bti; + in.rid = rid; + in.region_offset = region_offset; - return(-1); + hret = HG_Bulk_create(g_binst.hg_class, 1, (void**)(&buf), &buf_size, + HG_BULK_READ_ONLY, &in.bulk_handle); + if(hret != HG_SUCCESS) + { + return(-1); + } + + /* create handle */ + hret = HG_Create(g_binst.hg_context, g_binst.dest, + g_bake_bulk_write_id, &handle); + if(hret != HG_SUCCESS) + { + HG_Bulk_free(in.bulk_handle); + return(-1); + } + + hret = margo_forward(g_binst.mid, handle, &in); + if(hret != HG_SUCCESS) + { + HG_Destroy(handle); + HG_Bulk_free(in.bulk_handle); + return(-1); + } + + hret = HG_Get_output(handle, &out); + if(hret != HG_SUCCESS) + { + HG_Destroy(handle); + HG_Bulk_free(in.bulk_handle); + return(-1); + } + + ret = out.ret; + + HG_Free_output(handle, &out); + HG_Destroy(handle); + HG_Bulk_free(in.bulk_handle); + return(ret); } int bake_bulk_create( @@ -152,6 +203,9 @@ int bake_bulk_create( bake_bulk_create_out_t out; int ret; + in.bti = bti; + in.region_size = region_size; + /* create handle */ hret = HG_Create(g_binst.hg_context, g_binst.dest, g_bake_bulk_create_id, &handle); @@ -160,9 +214,6 @@ int bake_bulk_create( return(-1); } - in.bti = bti; - in.region_size = region_size; - hret = margo_forward(g_binst.mid, handle, &in); if(hret != HG_SUCCESS) { -- 2.26.2