Commit f9b5a0a9 authored by Matthieu Dorier's avatar Matthieu Dorier

client-side read function now gets the size read

parent 5f5cc293
......@@ -282,6 +282,7 @@ int bake_get_data(
* @param [in] region_offset offset into the target region to read from
* @param [in] buf local memory buffer read into
* @param [in] buf_size size of local memory buffer to read into
* @param [out] bytes_read number of bytes effectively read into the buffer
* @returns 0 on success, -1 on failure
*/
int bake_read(
......@@ -289,7 +290,8 @@ int bake_read(
bake_region_id_t rid,
uint64_t region_offset,
void *buf,
uint64_t buf_size);
uint64_t buf_size,
uint64_t* bytes_read);
/**
* Reads data from a previously persisted BAKE region like bake_read(),
......@@ -302,6 +304,7 @@ int bake_read(
* @param [in] remote_offset offset in the remote bulk handle to read to
* @param [in] remote_addr address string of the remote target to read to
* @param [in] size size to read to remote bulk handle
* @param [out] bytes_read number of bytes effectively read
* @returns 0 on success, -1 on failure
*/
int bake_proxy_read(
......@@ -311,7 +314,8 @@ int bake_proxy_read(
hg_bulk_t remote_bulk,
uint64_t remote_offset,
const char* remote_addr,
uint64_t size);
uint64_t size,
uint64_t* bytes_read);
/**
* Shuts down a remote BAKE service (given an address).
......
......@@ -743,7 +743,8 @@ static int bake_eager_read(
bake_region_id_t rid,
uint64_t region_offset,
void *buf,
uint64_t buf_size)
uint64_t buf_size,
uint64_t* bytes_read)
{
hg_return_t hret;
hg_handle_t handle;
......@@ -778,6 +779,7 @@ static int bake_eager_read(
ret = out.ret;
if(ret == 0)
memcpy(buf, out.buffer, out.size);
*bytes_read = out.size;
margo_free_output(handle, &out);
margo_destroy(handle);
......@@ -789,7 +791,8 @@ int bake_read(
bake_region_id_t rid,
uint64_t region_offset,
void *buf,
uint64_t buf_size)
uint64_t buf_size,
uint64_t* bytes_read)
{
hg_return_t hret;
hg_handle_t handle;
......@@ -798,7 +801,7 @@ int bake_read(
int ret;
if(buf_size <= provider->eager_limit)
return(bake_eager_read(provider, rid, region_offset, buf, buf_size));
return(bake_eager_read(provider, rid, region_offset, buf, buf_size, bytes_read));
in.rid = rid;
in.region_offset = region_offset;
......@@ -837,6 +840,7 @@ int bake_read(
}
ret = out.ret;
*bytes_read = out.size;
margo_free_output(handle, &out);
margo_bulk_free(in.bulk_handle);
......@@ -851,7 +855,8 @@ int bake_proxy_read(
hg_bulk_t remote_bulk,
uint64_t remote_offset,
const char* remote_addr,
uint64_t size)
uint64_t size,
uint64_t* bytes_read)
{
hg_return_t hret;
hg_handle_t handle;
......@@ -863,7 +868,7 @@ int bake_proxy_read(
in.region_offset = region_offset;
in.bulk_handle = remote_bulk;
in.bulk_offset = remote_offset;
in.bulk_size = size;
in.bulk_size = size;
in.remote_addr_str = (char*)remote_addr;
hret = margo_create(provider->client->mid, provider->addr,
......@@ -887,6 +892,7 @@ int bake_proxy_read(
}
ret = out.ret;
*bytes_read = out.size;
margo_free_output(handle, &out);
margo_destroy(handle);
......
......@@ -157,12 +157,14 @@ int main(int argc, char **argv)
}
/* transfer data */
uint64_t bytes_read;
ret = bake_read(
bph,
rid,
0,
local_region,
check_size);
check_size,
&bytes_read);
if(ret != 0)
{
munmap(local_region, check_size);
......
......@@ -192,12 +192,14 @@ static void bench_routine_read(bake_provider_handle_t bph, int iterations, doubl
{
tm1 = Wtime();
/* transfer data (reads) */
uint64_t bytes_read;
ret = bake_read(
bph,
rid,
region_offset,
buffer,
size);
size,
&bytes_read);
tm2 = Wtime();
assert(ret == 0);
region_offset += size;
......
......@@ -99,6 +99,7 @@ MERCURY_GEN_PROC(bake_read_in_t,
((uint64_t)(bulk_size))\
((hg_string_t)(remote_addr_str)))
MERCURY_GEN_PROC(bake_read_out_t,
((hg_size_t)(size))\
((int32_t)(ret)))
DECLARE_MARGO_RPC_HANDLER(bake_read_ult)
......
......@@ -877,6 +877,7 @@ static void bake_read_ult(hg_handle_t handle)
}
out.ret = 0;
out.size = in.bulk_size; // TODO change that to the actual size read
if(in.remote_addr_str)
margo_addr_free(mid, src_addr);
......
......@@ -132,7 +132,8 @@ int main(int argc, char *argv[])
/* reset the buffer and read it back via BAKE */
memset(buf, 0, ALLOC_BUF_SIZE);
ret = bake_read(bph, the_rid, 0, buf, buf_size);
uint64_t bytes_read;
ret = bake_read(bph, the_rid, 0, buf, buf_size, &bytes_read);
if(ret != 0)
{
fprintf(stderr, "Error: bake_read()\n");
......
......@@ -132,7 +132,8 @@ int main(int argc, char *argv[])
/* reset the buffer and read it back via BAKE */
memset(buf, 0, ALLOC_BUF_SIZE);
ret = bake_read(bph, the_rid, 0, buf, buf_size);
uint64_t bytes_read;
ret = bake_read(bph, the_rid, 0, buf, buf_size, &bytes_read);
if(ret != 0)
{
fprintf(stderr, "Error: bake_read()\n");
......
......@@ -285,8 +285,9 @@ static void proxy_read_ult(hg_handle_t handle)
assert(hret == HG_SUCCESS);
/* perform proxy write on behalf of client */
uint64_t bytes_read;
ret = bake_proxy_read(g_proxy_svr_ctx->svr_bph, g_proxy_svr_ctx->the_rid,
0, in.bulk_handle, in.bulk_offset, in.bulk_addr, in.bulk_size);
0, in.bulk_handle, in.bulk_offset, in.bulk_addr, in.bulk_size, &bytes_read);
assert(ret == 0);
/* set return value */
......
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