Commit 28c72172 authored by Su Huang's avatar Su Huang Committed by Michael Blocksome
Browse files

PAMID:fix memory leak and BGQ problems


Signed-off-by: default avatarMichael Blocksome <blocksom@us.ibm.com>
parent 4b07ac8a
......@@ -193,6 +193,13 @@ MPID_Accumulate(void *origin_addr,
}
req->offset = target_disp * win->mpid.info[target_rank].disp_unit;
#ifdef __BGQ__
/* PAMI limitation as it doesnt permit VA of 0 to be passed into
* memregion create, so we must pass base_va of heap computed from
* an SPI call instead. So the target offset must be adjusted */
if (req->win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC)
req->offset -= (size_t)req->win->mpid.info[target_rank].base_addr;
#endif
if (origin_datatype == MPI_DOUBLE_INT)
{
......
......@@ -95,6 +95,13 @@ int MPID_Compare_and_swap(const void *origin_addr, const void *compare_addr,
req->type = MPIDI_WIN_REQUEST_COMPARE_AND_SWAP;
req->offset = target_disp * win->mpid.info[target_rank].disp_unit;
#ifdef __BGQ__
/* PAMI limitation as it doesnt permit VA of 0 to be passed into
* memregion create, so we must pass base_va of heap computed from
* an SPI call instead. So the target offset must be adjusted */
if (req->win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC)
req->offset -= (size_t)req->win->mpid.info[target_rank].base_addr;
#endif
MPIDI_Win_datatype_basic(1, datatype, &req->origin.dt);
......@@ -119,6 +126,10 @@ int MPID_Compare_and_swap(const void *origin_addr, const void *compare_addr,
base = win->mpid.info[target_rank].base_addr;
disp_unit = win->disp_unit;
}
else if (win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC) {
base = NULL;
disp_unit = win->disp_unit;
}
else {
base = win->base;
disp_unit = win->disp_unit;
......@@ -178,10 +189,13 @@ int MPID_Compare_and_swap(const void *origin_addr, const void *compare_addr,
MPI_Op null_op=0;
pami_data_function pami_op;
#ifndef __BGQ__
if(MPIDI_Datatype_is_pami_rmw_supported(basic_type, &pami_type, null_op, &pami_op) ) {
req->pami_datatype = pami_type;
PAMI_Context_post(MPIDI_Context[0], &req->post_request, MPIDI_Compare_and_swap_using_pami_rmw, req);
} else {
} else
#endif
{
PAMI_Context_post(MPIDI_Context[0], &req->post_request, MPIDI_Atomic, req);
}
}
......
......@@ -52,11 +52,34 @@ MPID_Win_create_dynamic( MPID_Info * info,
rc=MPIDI_Win_init(0,1,win_ptr, info, comm_ptr, MPI_WIN_FLAVOR_DYNAMIC, MPI_WIN_UNIFIED);
win = *win_ptr;
win->base = MPI_BOTTOM;
rank = comm_ptr->rank;
win->base = MPI_BOTTOM;
winfo = &win->mpid.info[rank];
winfo->win = win;
#ifdef __BGQ__
void *base = NULL;
size_t length = 0;
Kernel_MemoryRegion_t memregion;
void *tmpbuf = malloc(sizeof(int));
Kernel_CreateMemoryRegion(&memregion, tmpbuf, sizeof(int));
//Reset base to base VA of local heap
base = memregion.BaseVa;
length = memregion.Bytes;
free(tmpbuf);
if (length != 0)
{
size_t length_out = 0;
pami_result_t rc;
rc = PAMI_Memregion_create(MPIDI_Context[0], base, length, &length_out, &winfo->memregion);
MPID_assert(rc == PAMI_SUCCESS);
MPID_assert(length == length_out);
}
win->base = base;
winfo->base_addr = base;
#endif
rc= MPIDI_Win_allgather(0,win_ptr);
if (rc != MPI_SUCCESS)
return rc;
......
......@@ -229,7 +229,9 @@ int MPID_Fetch_and_op(const void *origin_addr, void *result_addr,
MPID_assert(basic_type != MPI_DATATYPE_NULL);
if(MPIDI_Datatype_is_pami_rmw_supported(basic_type, &pami_type, op, &pami_op) ) {
#ifndef __BGQ__
good_for_rmw = 1;
#endif
} else {
if((op == MPI_NO_OP) && (origin_addr == NULL) && (win->create_flavor != MPI_WIN_FLAVOR_SHARED) ) {
/* essentially a MPI_Get to result buffer */
......@@ -244,6 +246,13 @@ int MPID_Fetch_and_op(const void *origin_addr, void *result_addr,
req->type = MPIDI_WIN_REQUEST_FETCH_AND_OP;
req->offset = target_disp * win->mpid.info[target_rank].disp_unit;
#ifdef __BGQ__
/* PAMI limitation as it doesnt permit VA of 0 to be passed into
* memregion create, so we must pass base_va of heap computed from
* an SPI call instead. So the target offset must be adjusted */
if (req->win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC)
req->offset -= (size_t)req->win->mpid.info[target_rank].base_addr;
#endif
if (datatype == MPI_DOUBLE_INT)
{
......@@ -300,6 +309,10 @@ int MPID_Fetch_and_op(const void *origin_addr, void *result_addr,
disp_unit = win->disp_unit;
}
else if (win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC) {
base = NULL;
disp_unit = win->disp_unit;
}
else {
base = win->base;
disp_unit = win->disp_unit;
......
......@@ -236,6 +236,13 @@ MPID_Get(void *origin_addr,
}
req->offset = target_disp * win->mpid.info[target_rank].disp_unit;
#ifdef __BGQ__
/* PAMI limitation as it doesnt permit VA of 0 to be passed into
* memregion create, so we must pass base_va of heap computed from
* an SPI call instead. So the target offset must be adjusted */
if (req->win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC)
req->offset -= (size_t)req->win->mpid.info[target_rank].base_addr;
#endif
MPIDI_Win_datatype_basic(origin_count,
origin_datatype,
......
......@@ -23,10 +23,12 @@
static void
MPIDI_Win_GetAccSendAckDoneCB(pami_context_t context,
void * _buf,
void * _info,
pami_result_t result)
{
MPIU_Free (_buf);
MPIDI_Win_GetAccMsgInfo *msginfo = (MPIDI_Win_GetAccMsgInfo *) _info;
MPIU_Free(msginfo->tptr);
MPIU_Free(msginfo);
}
static void
......@@ -69,19 +71,18 @@ MPIDI_Win_GetAccumSendAck(pami_context_t context,
.dest = msginfo->src_endpoint,
},
.events = {
.cookie = buffer,
.cookie = msginfo,
.local_fn = MPIDI_Win_GetAccSendAckDoneCB, //cleanup buffer
},
};
msginfo->tptr = buffer;
params.send.data.iov_len = msginfo->size;
params.send.data.iov_base = buffer;
rc = PAMI_Send(context, &params);
MPID_assert(rc == PAMI_SUCCESS);
//free msginfo
//MPIU_Free(msginfo);
}
void
......@@ -148,6 +149,9 @@ MPIDI_Win_GetAccDoneCB(pami_context_t context,
if (req->accum_headers)
MPIU_Free(req->accum_headers);
MPIDI_Win_datatype_unmap(&req->target.dt);
MPIDI_Win_datatype_unmap(&req->result.dt);
if( req->type != MPIDI_WIN_REQUEST_RGET_ACCUMULATE )
MPIU_Free(req);
}
......@@ -166,10 +170,10 @@ MPIDI_Win_GetAccAckDoneCB(pami_context_t context,
MPIR_Localcopy(req->result.addr,
req->result.count,
req->result.datatype,
msginfo->result_addr,
msginfo->tptr,
msginfo->size,
MPI_CHAR);
MPIU_Free(msginfo->result_addr);
MPIU_Free(msginfo->tptr);
}
MPIU_Free(msginfo);
......@@ -194,10 +198,10 @@ MPIDI_WinGetAccumAckCB(pami_context_t context,
*msginfo = *(const MPIDI_Win_GetAccMsgInfo *)_msginfo;
MPIDI_Win_request *req = (MPIDI_Win_request *) msginfo->request;
msginfo->result_addr = NULL;
msginfo->tptr = NULL;
recv->addr = req->result.addr;
if (req->result_num_contig > 1)
recv->addr = msginfo->result_addr = MPIU_Malloc(msginfo->size);
recv->addr = msginfo->tptr = MPIU_Malloc(msginfo->size);
recv->type = PAMI_TYPE_BYTE;
recv->offset = 0;
......@@ -213,7 +217,6 @@ MPIDI_Get_accumulate(pami_context_t context,
{
MPIDI_Win_request *req = (MPIDI_Win_request*)_req;
pami_result_t rc;
void *map;
pami_send_t params = {
.send = {
......@@ -248,15 +251,8 @@ MPIDI_Get_accumulate(pami_context_t context,
params.send.data.iov_base = req->buffer + req->state.local_offset;
if (req->target.dt.num_contig - req->state.index == 1) {
map=NULL;
if (req->target.dt.map != &req->target.dt.__map) {
map=(void *) req->target.dt.map;
}
rc = PAMI_Send(context, &params);
MPID_assert(rc == PAMI_SUCCESS);
if (map)
MPIU_Free(map);
return PAMI_SUCCESS;
} else {
rc = PAMI_Send(context, &params);
......@@ -265,9 +261,6 @@ MPIDI_Get_accumulate(pami_context_t context,
++req->state.index;
}
}
MPIDI_Win_datatype_unmap(&req->target.dt);
return PAMI_SUCCESS;
}
......
......@@ -249,6 +249,13 @@ MPID_Put(void *origin_addr,
}
req->offset = target_disp * win->mpid.info[target_rank].disp_unit;
#ifdef __BGQ__
/* PAMI limitation as it doesnt permit VA of 0 to be passed into
* memregion create, so we must pass base_va of heap computed from
* an SPI call instead. So the target offset must be adjusted */
if (req->win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC)
req->offset -= (size_t)req->win->mpid.info[target_rank].base_addr;
#endif
MPIDI_Win_datatype_basic(origin_count,
origin_datatype,
......
......@@ -201,7 +201,7 @@ typedef struct
int num_contig;
int size;
void * request;
void * result_addr;
void * tptr;
pami_endpoint_t src_endpoint;
} MPIDI_Win_GetAccMsgInfo;
......
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