Commit ebf4f8ea authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

adapted ssg-rpc.c to the new Margo API

parent 93f22fa8
......@@ -85,15 +85,12 @@ int ssg_group_attach_send(
*group_size = 0;
*view_buf = NULL;
hgcl = margo_get_class(ssg_inst->mid);
if (!hgcl) goto fini;
/* lookup the address of the given group member */
hret = margo_addr_lookup(ssg_inst->mid, group_descriptor->addr_str,
&member_addr);
if (hret != HG_SUCCESS) goto fini;
hret = HG_Create(margo_get_context(ssg_inst->mid), member_addr,
hret = margo_create(ssg_inst->mid, member_addr,
ssg_group_attach_rpc_id, &handle);
if (hret != HG_SUCCESS) goto fini;
......@@ -105,7 +102,7 @@ int ssg_group_attach_send(
tmp_view_buf = malloc(tmp_view_buf_size);
if (!tmp_view_buf) goto fini;
hret = HG_Bulk_create(hgcl, 1, &tmp_view_buf, &tmp_view_buf_size,
hret = margo_bulk_create(ssg_inst->mid, 1, &tmp_view_buf, &tmp_view_buf_size,
HG_BULK_WRITE_ONLY, &bulk_handle);
if (hret != HG_SUCCESS) goto fini;
......@@ -115,7 +112,7 @@ int ssg_group_attach_send(
hret = margo_forward(ssg_inst->mid, handle, &attach_req);
if (hret != HG_SUCCESS) goto fini;
hret = HG_Get_output(handle, &attach_resp);
hret = margo_get_output(handle, &attach_resp);
if (hret != HG_SUCCESS) goto fini;
/* if our initial buffer is too small, reallocate to the exact size & reattach */
......@@ -124,14 +121,14 @@ int ssg_group_attach_send(
b = realloc(tmp_view_buf, attach_resp.view_buf_size);
if(!b)
{
HG_Free_output(handle, &attach_resp);
margo_free_output(handle, &attach_resp);
goto fini;
}
tmp_view_buf = b;
tmp_view_buf_size = attach_resp.view_buf_size;
/* free old bulk handle and recreate it */
HG_Bulk_free(bulk_handle);
margo_bulk_free(bulk_handle);
hret = HG_Bulk_create(hgcl, 1, &tmp_view_buf, &tmp_view_buf_size,
HG_BULK_WRITE_ONLY, &bulk_handle);
if (hret != HG_SUCCESS) goto fini;
......@@ -140,7 +137,7 @@ int ssg_group_attach_send(
hret = margo_forward(ssg_inst->mid, handle, &attach_req);
if (hret != HG_SUCCESS) goto fini;
HG_Free_output(handle, &attach_resp);
margo_free_output(handle, &attach_resp);
hret = HG_Get_output(handle, &attach_resp);
if (hret != HG_SUCCESS) goto fini;
}
......@@ -151,7 +148,7 @@ int ssg_group_attach_send(
b = realloc(tmp_view_buf, attach_resp.view_buf_size);
if(!b)
{
HG_Free_output(handle, &attach_resp);
margo_free_output(handle, &attach_resp);
goto fini;
}
tmp_view_buf = b;
......@@ -162,13 +159,13 @@ int ssg_group_attach_send(
*group_size = (int)attach_resp.group_size;
*view_buf = tmp_view_buf;
HG_Free_output(handle, &attach_resp);
margo_free_output(handle, &attach_resp);
tmp_view_buf = NULL;
sret = SSG_SUCCESS;
fini:
if (hgcl && member_addr != HG_ADDR_NULL) HG_Addr_free(hgcl, member_addr);
if (handle != HG_HANDLE_NULL) HG_Destroy(handle);
if (bulk_handle != HG_BULK_NULL) HG_Bulk_free(bulk_handle);
if (member_addr != HG_ADDR_NULL) margo_addr_free(ssg_inst->mid, member_addr);
if (handle != HG_HANDLE_NULL) margo_destroy(ssg_inst->mid, handle);
if (bulk_handle != HG_BULK_NULL) margo_bulk_free(bulk_handle);
free(tmp_view_buf);
return sret;
......@@ -177,8 +174,7 @@ fini:
static void ssg_group_attach_recv_ult(
hg_handle_t handle)
{
hg_class_t *hgcl = NULL;
const struct hg_info *hgi = NULL;
const struct hg_info *hgi = NULL;
ssg_group_t *g = NULL;
ssg_group_attach_request_t attach_req;
ssg_group_attach_response_t attach_resp;
......@@ -191,39 +187,37 @@ static void ssg_group_attach_recv_ult(
if (!ssg_inst) goto fini;
hgcl = margo_get_class(ssg_inst->mid);
if (!hgcl) goto fini;
hgi = HG_Get_info(handle);
hgi = margo_get_info(handle);
if (!hgi) goto fini;
hret = HG_Get_input(handle, &attach_req);
hret = margo_get_input(handle, &attach_req);
if (hret != HG_SUCCESS) goto fini;
view_size_requested = HG_Bulk_get_size(attach_req.bulk_handle);
view_size_requested = margo_bulk_get_size(attach_req.bulk_handle);
/* look for the given group in my local table of groups */
HASH_FIND(hh, ssg_inst->group_table, &attach_req.group_descriptor.name_hash,
sizeof(uint64_t), g);
if (!g)
{
HG_Free_input(handle, &attach_req);
margo_free_input(handle, &attach_req);
goto fini;
}
sret = ssg_group_view_serialize(&g->view, &view_buf, &view_buf_size);
if (sret != SSG_SUCCESS)
{
HG_Free_input(handle, &attach_req);
margo_free_input(handle, &attach_req);
goto fini;
}
if (view_size_requested >= view_buf_size)
{
/* if attacher's buf is large enough, transfer the view */
hret = HG_Bulk_create(hgcl, 1, &view_buf, &view_buf_size, HG_BULK_READ_ONLY,
hret = margo_bulk_create(ssg_inst->mid, 1, &view_buf, &view_buf_size, HG_BULK_READ_ONLY,
&bulk_handle);
if (hret != HG_SUCCESS)
{
HG_Free_input(handle, &attach_req);
margo_free_input(handle, &attach_req);
goto fini;
}
......@@ -231,7 +225,7 @@ static void ssg_group_attach_recv_ult(
attach_req.bulk_handle, 0, bulk_handle, 0, view_buf_size);
if (hret != HG_SUCCESS)
{
HG_Free_input(handle, &attach_req);
margo_free_input(handle, &attach_req);
goto fini;
}
}
......@@ -242,11 +236,11 @@ static void ssg_group_attach_recv_ult(
attach_resp.view_buf_size = view_buf_size;
margo_respond(ssg_inst->mid, handle, &attach_resp);
HG_Free_input(handle, &attach_req);
margo_free_input(handle, &attach_req);
fini:
free(view_buf); /* TODO: cache this */
if (handle != HG_HANDLE_NULL) HG_Destroy(handle);
if (bulk_handle != HG_BULK_NULL) HG_Bulk_free(bulk_handle);
if (handle != HG_HANDLE_NULL) margo_destroy(ssg_inst->mid, handle);
if (bulk_handle != HG_BULK_NULL) margo_bulk_free(bulk_handle);
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