Commit c5dbf0b9 authored by Darius Buntinas's avatar Darius Buntinas
Browse files

[svn-r10324] more portals coding

parent 9e3669e2
......@@ -7,9 +7,12 @@
if BUILD_NEMESIS_NETMOD_PORTALS4
lib_lib@MPILIBNAME@_la_SOURCES += \
src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_init.c \
src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_poll.c \
lib_lib@MPILIBNAME@_la_SOURCES += \
src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_init.c \
src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_pack_byte.c \
src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_poll.c \
src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_probe.c \
src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_recv.c \
src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_send.c
noinst_HEADERS += \
......
**ptlinit:PtlInit() failed
**ptlinit %s:PtlInit() failed (%s)
**ptlniinit:PtlNIInit() failed
**ptlniinit %s:PtlNIInit() failed (%s)
**ptlgetid:PtlGetId() failed
**ptlgetid %s:PtlGetId() failed (%s)
**ptleqalloc:PtlEQAlloc() failed
**ptleqalloc %s:PtlEQAlloc() failed (%s)
**ptlptalloc:PtlPTAlloc() failed
**ptlptalloc %s:PtlPTAlloc() failed (%s)
**ptlptfree:PtlPTFree() failed
**ptlptfree %s:PtlPTFree() failed (%s)
**ptlnifini:PtlNIFini() failed
**ptlnifini %s:PtlNIFini() failed (%s)
**ptleqget:PtlEQGet() failed
**ptleqget %s:PtlEQGet() failed (%s)
**ptlleappend:PtlLEAppend() failed
**ptlleappend %s:PtlLEAppend() failed (%s)
**ptlleunlink:PtlLEUnlink() failed
**ptlleunlink %s:PtlLEUnlink() failed (%s)
**ptlmeappend:PtlMEAppend() failed
**ptlmeappend %s:PtlMEAppend() failed (%s)
**ptlmeunlink:PtlMEUnlink() failed
**ptlmeunlink %s:PtlMEUnlink() failed (%s)
**ptlmesearch:PtlMESearch() failed
**ptlmdbind:PtlMDBind()failed
**ptlmesearch %s:PtlMESearch() failed (%s)
**ptlmdbind:PtlMDBind() failed
**ptlmdbind %s:PtlMDBind() failed (%s)
**ptlmdrelease:PtlMDRelease() failed
**ptlmdrelease %s:PtlMDRelease() failed (%s)
**ptlput:PtlPut() failed
**ptlput %s:PtlPut() failed (%s)
**ptlget:PtlGet() failed
**ptlget %s:PtlGet() failed (%s)
**eqdropped:Event queue overflowed
**badbusinesscard:Invalid business card
......@@ -51,7 +51,7 @@ typedef struct {
#define MPID_nem_ptl_init_req(req_) do { \
int i; \
for (i = 0; i < MPID_NEM_PTL_NUM_CHUNK_BUFFERS; ++i) { \
REQ_PTL(req)->overflow[i].len = 0; \
REQ_PTL(req_)->overflow[i].len = 0; \
REQ_PTL(req_)->chunk_buffer[i] = NULL; \
} \
REQ_PTL(req_)->noncontig = FALSE; \
......@@ -61,9 +61,24 @@ typedef struct {
REQ_PTL(req_)->event_handler = NULL; \
} while (0)
#define MPID_nem_ptl_request_create_req(sreq_, errno_, on_fail_) do { \
MPIDI_Request_create_sreq(sreq_, errno_, on_fail_); \
MPID_nem_ptl_init_req(req_); \
#define MPID_nem_ptl_request_create_sreq(sreq_, errno_, comm_) do { \
(sreq_) = MPIU_Handle_obj_alloc(&MPID_Request_mem); \
MPIU_ERR_CHKANDJUMP1((sreq_) == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem", "**nomem %s", "request"); \
MPIU_Object_set_ref((sreq_), 2); \
(sreq_)->kind = MPID_REQUEST_SEND; \
MPIR_Comm_add_ref(comm_); \
(sreq_)->comm = comm_; \
(sreq_)->greq_fns = NULL; \
MPID_cc_set(&(sreq_)->cc, 1); \
(sreq_)->cc_ptr = &(sreq_)->cc; \
(sreq_)->status.MPI_ERROR = MPI_SUCCESS; \
(sreq_)->status.cancelled = FALSE; \
(sreq_)->dev.cancel_pending = FALSE; \
(sreq_)->dev.state = 0; \
(sreq_)->dev.datatype_ptr = NULL; \
(sreq_)->dev.segment_ptr = NULL; \
\
MPID_nem_ptl_init_req(sreq_); \
} while (0)
typedef struct {
......@@ -95,14 +110,14 @@ typedef struct {
#define NPTL_MULTIPLE ((ptl_hdr_data_t)1<<63)
#define NPTL_LENGTH_MASK ((((ptl_hdr_data_t)1<<32)-1)<<NPTL_LENGTH_OFFSET)
#define NPTL_SEQNUM_MASK ((((ptl_hdr_data_t)1<<29)-1)<<NPTL_SEQNUM_OFFSET)
#define NPTL_SEQNUM_MASK ((((ptl_hdr_data_t)1<<29)-1)<<NPTL_SEQNUM_OFFSET)
#define NPTL_HEADER(flags, large_seqnum, length) ((flags) | \
((ptl_hdr_data_t)(seqnum))<<NPTL_SEQNUM_OFFSET | \
((ptl_hdr_data_t)(length))<<NPTL_LENGTH_OFFSET)
#define NPTL_HEADER(flags_, large_seqnum_, length_) ((flags_) | \
((ptl_hdr_data_t)(large_seqnum_))<<NPTL_SEQNUM_OFFSET | \
((ptl_hdr_data_t)(length_))<<NPTL_LENGTH_OFFSET)
#define NPTL_HEADER_GET_SEQNUM(hdr) ((hdr & NPTL_SEQNUM_MASK)>>NPTL_SEQNUM_OFFSET)
#define NPTL_HEADER_GET_LENGTH(hdr) ((hdr & NPTL_LENGTH_MASK)>>NPTL_LENGTH_OFFSET)
#define NPTL_HEADER_GET_SEQNUM(hdr_) (((hdr_) & NPTL_SEQNUM_MASK)>>NPTL_SEQNUM_OFFSET)
#define NPTL_HEADER_GET_LENGTH(hdr_) (((hdr_) & NPTL_LENGTH_MASK)>>NPTL_LENGTH_OFFSET)
/* The comm_world rank of the sender is stored in the match_bits, but they are
ignored when matching.
......@@ -115,20 +130,20 @@ typedef struct {
#define NPTL_MATCH_TAG_OFFSET 32
#define NPTL_MATCH_CTX_OFFSET 16
#define NPTL_MATCH_RANK_MASK (((ptl_match_bits)(1) << 16) - 1)
#define NPTL_MATCH_TAG_MASK ((((ptl_match_bits)(1) << 16) - 1) << NPTL_MATCH_TAG_OFFSET)
#define NPTL_MATCH(tag, ctx) (((ptl_match_bits)(tag) << NPTL_MATCH_TAG_OFFSET) | \
((ptl_match_bits)(ctx) << NPTL_MATCH_CTX_OFFSET) | \
((ptl_match_bits)MPIDI_Process.my_pg_rank))
#define NPTL_MATCH_RANK_MASK (((ptl_match_bits_t)(1) << 16) - 1)
#define NPTL_MATCH_TAG_MASK ((((ptl_match_bits_t)(1) << 16) - 1) << NPTL_MATCH_TAG_OFFSET)
#define NPTL_MATCH(tag_, ctx_) (((ptl_match_bits_t)(tag_) << NPTL_MATCH_TAG_OFFSET) | \
((ptl_match_bits_t)(ctx_) << NPTL_MATCH_CTX_OFFSET) | \
((ptl_match_bits_t)(MPIDI_Process.my_pg_rank)))
#define NPTL_MATCH_IGNORE NPTL_MATCH_RANK_MASK
#define NPTL_MATCH_IGNORE_ANY_TAG (NPTL_MATCH_IGNORE | NPTL_MATCH_TAG_MASK)
#define NPTL_MATCH_GET_RANK(match_bits) ((match_bits) & NPTL_MATCH_RANK_MASK)
#define NPTL_MATCH_GET_TAG(match_bits) ((match_bits) >> NPTL_MATCH_TAG_OFFSET)
#define NPTL_MATCH_GET_RANK(match_bits_) ((match_bits_) & NPTL_MATCH_RANK_MASK)
#define NPTL_MATCH_GET_TAG(match_bits_) ((match_bits_) >> NPTL_MATCH_TAG_OFFSET)
int MPID_nem_ptl_send_init(void);
int MPID_nem_ptl_send_finalize(void);
int MPID_nem_ptl_ev_send_handler(ptl_event_t *e);
int MPID_nem_ptl_ev_send_handler(const ptl_event_t *e);
int MPID_nem_ptl_sendq_complete_with_error(MPIDI_VC_t *vc, int req_errno);
int MPID_nem_ptl_SendNoncontig(MPIDI_VC_t *vc, MPID_Request *sreq, void *hdr, MPIDI_msg_sz_t hdr_sz);
int MPID_nem_ptl_iStartContigMsg(MPIDI_VC_t *vc, void *hdr, MPIDI_msg_sz_t hdr_sz, void *data, MPIDI_msg_sz_t data_sz,
......@@ -140,6 +155,11 @@ int MPID_nem_ptl_poll_finalize(void);
int MPID_nem_ptl_poll(int is_blocking_poll);
int MPID_nem_ptl_vc_terminated(MPIDI_VC_t *vc);
int MPID_nem_ptl_get_id_from_bc(const char *business_card, ptl_process_t *id, ptl_pt_index_t *pt, ptl_pt_index_t *ptc);
void MPI_nem_ptl_pack_byte(MPID_Segment *segment, MPI_Aint first, MPI_Aint last, void *buf,
MPID_nem_ptl_pack_overflow_t *overflow);
int MPID_nem_ptl_unpack_byte(MPID_Segment *segment, MPI_Aint first, MPI_Aint last, void *buf,
MPID_nem_ptl_pack_overflow_t *overflow);
const char *MPID_nem_ptl_strerror(int ret);
/* comm override functions */
int MPID_nem_ptl_recv_posted(struct MPIDI_VC *vc, struct MPID_Request *req);
......@@ -156,6 +176,10 @@ int MPID_nem_ptl_iprobe(struct MPIDI_VC *vc, int source, int tag, MPID_Comm *co
MPI_Status *status);
int MPID_nem_ptl_improbe(struct MPIDI_VC *vc, int source, int tag, MPID_Comm *comm, int context_offset, int *flag,
MPID_Request **message, MPI_Status *status);
int MPID_nem_ptl_anysource_iprobe(int tag, MPID_Comm * comm, int context_offset, int *flag, MPI_Status * status);
int MPID_nem_ptl_anysource_improbe(int tag, MPID_Comm * comm, int context_offset, int *flag, MPID_Request **message,
MPI_Status * status);
void MPID_nem_ptl_anysource_posted(MPID_Request *rreq);
int MPID_nem_ptl_anysource_matched(MPID_Request *rreq);
#endif /* PTL_IMPL_H */
......@@ -16,6 +16,13 @@
#define PTI_KEY "PTI"
#define PTIC_KEY "PTIC"
ptl_handle_ni_t MPIDI_nem_ptl_ni;
ptl_pt_index_t MPIDI_nem_ptl_pt;
ptl_pt_index_t MPIDI_nem_ptl_control_pt; /* portal for MPICH control messages */
ptl_handle_eq_t MPIDI_nem_ptl_eq;
ptl_handle_md_t MPIDI_nem_ptl_global_md;
extern ptl_handle_md_t MPIDI_nem_ptl_global_md;
static int ptl_init(MPIDI_PG_t *pg_p, int pg_rank, char **bc_val_p, int *val_max_sz_p);
static int ptl_finalize(void);
static int get_business_card(int my_rank, char **bc_val_p, int *val_max_sz_p);
......@@ -24,8 +31,6 @@ static int vc_init(MPIDI_VC_t *vc);
static int vc_destroy(MPIDI_VC_t *vc);
static int vc_terminate(MPIDI_VC_t *vc);
static ptl_process_t my_ptl_id;
MPID_nem_netmod_funcs_t MPIDI_nem_portals4_funcs = {
ptl_init,
ptl_finalize,
......@@ -72,6 +77,7 @@ static int ptl_init(MPIDI_PG_t *pg_p, int pg_rank, char **bc_val_p, int *val_max
{
int mpi_errno = MPI_SUCCESS;
int ret;
ptl_md_t md;
MPIDI_STATE_DECL(MPID_STATE_PTL_INIT);
MPIDI_FUNC_ENTER(MPID_STATE_PTL_INIT);
......@@ -79,6 +85,16 @@ static int ptl_init(MPIDI_PG_t *pg_p, int pg_rank, char **bc_val_p, int *val_max
/* first make sure that our private fields in the vc fit into the area provided */
MPIU_Assert(sizeof(MPID_nem_ptl_vc_area) <= MPID_NEM_VC_NETMOD_AREA_LEN);
/* Make sure our IOV is the same as portals4's IOV */
MPIU_Assert(sizeof(ptl_iovec_t) == sizeof(MPID_IOV));
MPIU_Assert(((void*)&(((ptl_iovec_t*)0)->iov_base)) == ((void*)&(((MPID_IOV*)0)->MPID_IOV_BUF)));
MPIU_Assert(((void*)&(((ptl_iovec_t*)0)->iov_len)) == ((void*)&(((MPID_IOV*)0)->MPID_IOV_LEN)));
MPIU_Assert(sizeof(((ptl_iovec_t*)0)->iov_len) == sizeof(((MPID_IOV*)0)->MPID_IOV_LEN));
mpi_errno = MPIDI_CH3I_Register_anysource_notification(MPID_nem_ptl_anysource_posted, MPID_nem_ptl_anysource_matched);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* init portals */
ret = PtlInit();
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlinit");
......@@ -91,26 +107,28 @@ static int ptl_init(MPIDI_PG_t *pg_p, int pg_rank, char **bc_val_p, int *val_max
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptleqalloc");
/* allocate portal for matching messages */
ret = PtlPTAlloc(MPIDI_nem_ptl_ni, PTL_PT_ONLY_USE_ONCE | PTL_PT_ONLY_TRUNCATE | PTL_PT_FLOW_CONTROL, MPIDI_nem_ptl_eq,
ret = PtlPTAlloc(MPIDI_nem_ptl_ni, PTL_PT_ONLY_USE_ONCE | PTL_PT_ONLY_TRUNCATE | PTL_PT_FLOWCTRL, MPIDI_nem_ptl_eq,
PTL_PT_ANY, &MPIDI_nem_ptl_pt);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlptalloc");
/* allocate portal for MPICH control messages */
ret = PtlPTAlloc(MPIDI_nem_ptl_ni, PTL_PT_ONLY_USE_ONCE | PTL_PT_ONLY_TRUNCATE | PTL_PT_FLOW_CONTROL, MPIDI_nem_ptl_eq,
ret = PtlPTAlloc(MPIDI_nem_ptl_ni, PTL_PT_ONLY_TRUNCATE | PTL_PT_FLOWCTRL, MPIDI_nem_ptl_eq,
PTL_PT_ANY, &MPIDI_nem_ptl_control_pt);
ret = PtlGetId(MPIDI_nem_ptl_ni, &my_ptl_id);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlgetid");
MPIU_DBG_MSG_FMT(CH3_CHANNEL, VERBOSE, (MPIU_DBG_FDEST, "Allocated NI and PT id=(%#x,%#x) pt=%#x",
my_id.phys.nid, my_id.phys.pid, MPIDI_nem_ptl_pt));
/* create an MD that covers all of memory */
md.start = 0;
md.length = (ptl_size_t)-1;
md.options = 0x0;
md.eq_handle = MPIDI_nem_ptl_eq;
md.ct_handle = PTL_CT_NONE;
ret = PtlMDBind(MPIDI_nem_ptl_ni, &md, &MPIDI_nem_ptl_global_md);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmdbind");
/* create business card */
mpi_errno = get_business_card(pg_rank, bc_val_p, val_max_sz_p);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIDI_CH3I_Register_anysource_notification(MPID_nem_ptl_anysource_posted, MPID_nem_ptl_anysource_matched);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* init other modules */
mpi_errno = MPID_nem_ptl_poll_init();
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
......@@ -171,10 +189,16 @@ static int get_business_card(int my_rank, char **bc_val_p, int *val_max_sz_p)
int mpi_errno = MPI_SUCCESS;
int str_errno = MPIU_STR_SUCCESS;
int ret;
ptl_process_t my_ptl_id;
MPIDI_STATE_DECL(MPID_STATE_GET_BUSINESS_CARD);
MPIDI_FUNC_ENTER(MPID_STATE_GET_BUSINESS_CARD);
ret = PtlGetId(MPIDI_nem_ptl_ni, &my_ptl_id);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlgetid");
MPIU_DBG_MSG_FMT(CH3_CHANNEL, VERBOSE, (MPIU_DBG_FDEST, "Allocated NI and PT id=(%#x,%#x) pt=%#x",
my_ptl_id.phys.nid, my_ptl_id.phys.pid, MPIDI_nem_ptl_pt));
str_errno = MPIU_Str_add_binary_arg(bc_val_p, val_max_sz_p, NID_KEY, (char *)&my_ptl_id.phys.nid, sizeof(my_ptl_id.phys.nid));
if (str_errno) {
MPIU_ERR_CHKANDJUMP(str_errno == MPIU_STR_NOMEM, mpi_errno, MPI_ERR_OTHER, "**buscard_len");
......@@ -238,9 +262,6 @@ static int vc_init(MPIDI_VC_t *vc)
MPIDI_FUNC_ENTER(MPID_STATE_VC_INIT);
/* */
MPIU_Assert(vc->lpid < NPTL_MAX_PROCS);
vc->sendNoncontig_fn = MPID_nem_ptl_SendNoncontig;
vc_ch->iStartContigMsg = MPID_nem_ptl_iStartContigMsg;
vc_ch->iSendContig = MPID_nem_ptl_iSendContig;
......@@ -366,3 +387,27 @@ int MPID_nem_ptl_vc_terminated(MPIDI_VC_t *vc)
goto fn_exit;
}
#define CASE_STR(x) case x: return ##x
const char *MPID_nem_ptl_strerror(int ret)
{
switch (ret) {
CASE_STR(PTL_OK);
CASE_STR(PTL_ARG_INVALID);
CASE_STR(PTL_CT_NONE_REACHED);
CASE_STR(PTL_EQ_DROPPED);
CASE_STR(PTL_EQ_EMPTY);
CASE_STR(PTL_FAIL);
CASE_STR(PTL_IN_USE);
CASE_STR(PTL_INTERRUPTED);
CASE_STR(PTL_IGNORED);
CASE_STR(PTL_LIST_TOO_LONG);
CASE_STR(PTL_NO_INIT);
CASE_STR(PTL_NO_SPACE);
CASE_STR(PTL_PID_IN_USE);
CASE_STR(PTL_PT_FULL);
CASE_STR(PTL_PT_EQ_NEEDED);
CASE_STR(PTL_PT_IN_USE);
default: return "UNKNOWN";
}
}
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* (C) 2012 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "ptl_impl.h"
#undef FUNCNAME
#define FUNCNAME MPI_nem_ptl_pack_byte
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
void MPI_nem_ptl_pack_byte(MPID_Segment *segment, MPI_Aint first, MPI_Aint last, void *buf,
MPID_nem_ptl_pack_overflow_t *overflow)
{
MPI_Aint my_last;
MPI_Aint bytes;
char *end;
MPIDI_STATE_DECL(MPID_STATE_MPI_NEM_PTL_PACK_BYTE);
MPIDI_FUNC_ENTER(MPID_STATE_MPI_NEM_PTL_PACK_BYTE);
/* first copy out of overflow buffer */
if (overflow->len) {
if (overflow->len <= last-first) {
MPIU_Memcpy(buf, &overflow->buf[overflow->offset], overflow->len);
first += overflow->len;
buf = (char *)buf + overflow->len;
overflow->len = 0;
if (last == first)
goto fn_exit;
} else {
MPIU_Memcpy(buf, &overflow->buf[overflow->offset], last-first);
overflow->offset += overflow->len - (last-first);
overflow->len -= last-first;
goto fn_exit;
}
}
/* unpack as much as we can into buf */
my_last = last;
MPID_Segment_pack(segment, first, &my_last, buf);
if (my_last == last)
/* buf is completely filled */
goto fn_exit;
/* remember where the unfilled section starts and how large it is */
end = &((char *)buf)[my_last-first];
bytes = last - my_last;
/* unpack some into the overflow */
first = my_last;
my_last += sizeof(overflow->buf);
MPID_Segment_pack(segment, first, &my_last, overflow->buf);
MPIU_Assert(my_last - first);
/* fill in the rest of buf */
MPIU_Memcpy(end, overflow->buf, bytes);
/* save the beginning of the offset buffer and its length */
overflow->offset = bytes;
overflow->len = my_last-first - bytes;
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPI_NEM_PTL_PACK_BYTE);
return;
}
/* MPID_nem_ptl_unpack_byte -- this function unpacks a contig buffer handling
the case where there are bytes left in the buffer that are less than a basic
datatype. Those bytes are copied into an overflow buffer so that the next
time unpack_byte is called they can be "prepended" to that buffer before
doing a segment_unpack. Note, that means that after calling unpack_byte,
the last few bytes may not have been copied into the target buffer. */
#undef FUNCNAME
#define FUNCNAME MPID_nem_ptl_unpack_byte
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_nem_ptl_unpack_byte(MPID_Segment *segment, MPI_Aint first, MPI_Aint last, void *buf,
MPID_nem_ptl_pack_overflow_t *overflow)
{
int mpi_errno = MPI_SUCCESS;
MPI_Aint my_last;
MPI_Aint bytes;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_UNPACK_BYTE);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_UNPACK_BYTE);
if (overflow->len) {
/* if there is data in the overflow buffer, then we already know that
it's too small to unpack with this datatype, so we return an error */
MPIU_ERR_CHKANDJUMP(overflow->len >= last-first, mpi_errno, MPI_ERR_OTHER, "**dtypemismatch");
/* bytes is the number of additional bytes to copy into the overflow buffer */
bytes = sizeof(overflow->buf) - overflow->len;
if (bytes > last-first)
bytes = last-first;
MPIU_Memcpy(overflow->buf + overflow->len, buf, bytes);
/* Now there are (overflow->len + bytes) bytes in the overflow buffer.
We try to unpack as many as we can */
my_last = first + overflow->len + bytes;
MPID_Segment_unpack(segment, first, &my_last, buf);
/* we update the buf pointer to the */
buf = ((char *)buf) + my_last-first - overflow->len;
first = my_last;
overflow->len = 0;
}
if (first == last)
goto fn_exit;
my_last = last;
MPID_Segment_unpack(segment, first, &my_last, buf);
if (my_last == last)
/* buf has been completely unpacked */
goto fn_exit;
bytes = last - my_last;
/* copy remaining bytes int overflow buffer */
MPIU_Memcpy(overflow->buf, &((char *)buf)[my_last-first], bytes);
overflow->offset = 0;
overflow->len = bytes;
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_UNPACK_BYTE);
return mpi_errno;
fn_fail:
goto fn_exit;
}
......@@ -9,10 +9,18 @@
#define NUMBUFS 20
#define BUFLEN (sizeof(MPIDI_CH3_Pkt_t) + PTL_MAX_EAGER)
#define OVERFLOW_LENGTH (1024*1024)
#define NUM_OVERFLOW_ME 5
static char recvbuf[BUFLEN][NUMBUFS];
static ptl_le_t recvbuf_le[NUMBUFS];
static ptl_handle_le_t recvbuf_le_handle[NUMBUFS];
static ptl_handle_me_t overflow_me_handle[NUM_OVERFLOW_ME];
static void *overflow_buf[NUM_OVERFLOW_ME];
static int append_overflow(int i);
#undef FUNCNAME
#define FUNCNAME MPID_nem_ptl_poll_init
#undef FCNAME
......@@ -22,10 +30,15 @@ int MPID_nem_ptl_poll_init(void)
int mpi_errno = MPI_SUCCESS;
int i;
int ret;
ptl_process_t id_any;
MPIU_CHKPMEM_DECL(NUM_OVERFLOW_ME);
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_POLL_INIT);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_POLL_INIT);
id_any.phys.pid = PTL_PID_ANY;
id_any.phys.nid = PTL_NID_ANY;
for (i = 0; i < NUMBUFS; ++i) {
recvbuf_le[i].start = recvbuf[i];
recvbuf_le[i].length = BUFLEN;
......@@ -35,15 +48,24 @@ int MPID_nem_ptl_poll_init(void)
PTL_LE_EVENT_UNLINK_DISABLE | PTL_LE_EVENT_LINK_DISABLE);
ret = PtlLEAppend(MPIDI_nem_ptl_ni, MPIDI_nem_ptl_control_pt, &recvbuf_le[i], PTL_PRIORITY_LIST, (void *)(uint64_t)i,
&recvbuf_le_handle[i]);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmeappend");
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlleappend");
}
/* create overflow buffers */
for (i = 0; i < NUM_OVERFLOW_ME; ++i) {
MPIU_CHKPMEM_MALLOC(overflow_buf[i], void *, OVERFLOW_LENGTH, mpi_errno, "overflow buffer");
mpi_errno = append_overflow(i);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
fn_exit:
MPIU_CHKPMEM_COMMIT();
fn_exit2:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_POLL_INIT);
return mpi_errno;
fn_fail:
goto fn_exit;
MPIU_CHKPMEM_REAP();
goto fn_exit2;
}
......@@ -61,9 +83,15 @@ int MPID_nem_ptl_poll_finalize(void)
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_POLL_FINALIZE);
for (i = 0; i < NUM_OVERFLOW_ME; ++i)
if (overflow_me_handle[i] != PTL_INVALID_HANDLE) {
ret = PtlMEUnlink(overflow_me_handle[i]);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmeunlink");
}
for (i = 0; i < NUMBUFS; ++i) {
ret = PtlLEUnlink(recvbuf_le_handle[i]);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmeunlink");
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlleunlink");
}
fn_exit:
......@@ -73,6 +101,48 @@ int MPID_nem_ptl_poll_finalize(void)
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME append_overflow
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
static int append_overflow(int i)
{
int mpi_errno = MPI_SUCCESS;
int ret;
ptl_me_t me;
ptl_process_t id_any;
MPIDI_STATE_DECL(MPID_STATE_APPEND_OVERFLOW);
MPIDI_FUNC_ENTER(MPID_STATE_APPEND_OVERFLOW);
MPIU_Assert(i >= 0 && i < NUM_OVERFLOW_ME);
id_any.phys.pid = PTL_PID_ANY;
id_any.phys.nid = PTL_NID_ANY;
me.start = overflow_buf[i];
me.length = OVERFLOW_LENGTH;
me.ct_handle = PTL_CT_NONE;
me.uid = PTL_UID_ANY;
me.options = ( PTL_ME_OP_PUT | PTL_ME_MANAGE_LOCAL | PTL_ME_NO_TRUNCATE | PTL_ME_MAY_ALIGN |
PTL_ME_IS_ACCESSIBLE | PTL_ME_EVENT_LINK_DISABLE | PTL_ME_EVENT_UNLINK_DISABLE );
me.match_id = id_any;
me.match_bits = 0;
me.ignore_bits = ~((ptl_match_bits_t)0);
me.min_free = PTL_MAX_EAGER;
ret = PtlMEAppend(MPIDI_nem_ptl_ni, MPIDI_nem_ptl_pt, &me, PTL_OVERFLOW_LIST, (void *)(size_t)i,
&overflow_me_handle[i]);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmeappend");
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_APPEND_OVERFLOW);
return mpi_errno;
fn_fail:
goto fn_exit;
}
#undef FUNCNAME
#define FUNCNAME MPID_nem_ptl_poll
#undef FCNAME
......@@ -82,7 +152,6 @@ int MPID_nem_ptl_poll(int is_blocking_poll)
int mpi_errno = MPI_SUCCESS;
ptl_event_t event;
int ret;
MPIDI_VC_t *vc;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_POLL);
/* MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_POLL); */
......@@ -91,21 +160,33 @@ int MPID_nem_ptl_poll(int is_blocking_poll)
ret = PtlEQGet(MPIDI_nem_ptl_eq, &event);
if (ret == PTL_EQ_EMPTY)
break;
MPIU_ERR_CHKANDJUMP(ret == PTL_EQ_DROPPED, mpi_errno, MPI_ERR_OTHER, "**eqdropped");
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptleqget");
switch (event.type) {
MPID_Request * const req = e->user_ptr;
case PTL_EVENT_PUT:
case PTL_EVENT_PUT_OVERFLOW:
case PTL_EVENT_GET:
case PTL_EVENT_ACK:
case PTL_EVENT_REPLY:
case PTL_EVENT_SEARCH:
mpi_errno = REQ_PTL(sreq)->event_handler(e);
case PTL_EVENT_SEARCH: {
MPID_Request * const req = event.user_ptr;
mpi_errno = REQ_PTL(req)->event_handler(&event);