Commit 12ab3811 authored by Darius Buntinas's avatar Darius Buntinas
Browse files

[svn-r10169] coded up send functions

parent e7e76596
......@@ -12,8 +12,11 @@
#define PTL_MAX_EAGER (64*1024) /* 64K */
#define PTL_LARGE_THRESHOLD (64*1024) /* 64K */
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;
#define MPID_NEM_PTL_MAX_OVERFLOW_DATA 32 /* that's way more than we need */
......@@ -24,18 +27,41 @@ typedef struct MPID_nem_ptl_pack_overflow
char buf[MPID_NEM_PTL_MAX_OVERFLOW_DATA];
} MPID_nem_ptl_pack_overflow_t;
#define MPID_NEM_PTL_NUM_CHUNK_BUFFERS 2
typedef struct {
struct MPID_nem_ptl_pack_overflow overflow;
struct MPID_nem_ptl_pack_overflow overflow[MPID_NEM_PTL_NUM_CHUNK_BUFFERS];
int noncontig;
int large;
ptl_handle_md_t md;
ptl_handle_me_t me;
void *chunk_buffer[MPID_NEM_PTL_NUM_CHUNK_BUFFERS];
} MPID_nem_ptl_req_area;
/* macro for ptl private in req */
#define REQ_PTL(req) ((MPID_nem_ptl_req_area *)((req)->ch.netmod_area.padding))
#define MPID_nem_ptl_init_sreq(sreq_) do { \
int i; \
for (i = 0; i < MPID_NEM_PTL_NUM_CHUNK_BUFFERS; ++i) { \
REQ_PTL(sreq)->overflow[i].len = 0; \
REQ_PTL(sreq_)->chunk_buffer[i] = NULL; \
} \
REQ_PTL(sreq_)->noncontig = FALSE; \
REQ_PTL(sreq_)->large = FALSE; \
REQ_PTL(sreq_)->md = PTL_INVALID_HANDLE; \
REQ_PTL(sreq_)->me = PTL_INVALID_HANDLE; \
} while (0)
#define MPID_nem_ptl_request_create_sreq(sreq_, errno_, on_fail_) do { \
MPIDI_Request_create_sreq(sreq_, errno_, on_fail_); \
MPID_nem_ptl_init_sreq(sreq_); \
} while (0)
typedef struct {
ptl_process_t id;
ptl_pt_index_t pt;
ptl_pt_index_t ptc;
int id_initialized; /* TRUE iff id and pt have been initialized */
MPIDI_msg_sz_t num_queued_sends; /* number of reqs for this vc in sendq */
} MPID_nem_ptl_vc_area;
......@@ -43,6 +69,41 @@ typedef struct {
/* macro for ptl private in VC */
#define VC_PTL(vc) ((MPID_nem_ptl_vc_area *)VC_CH((vc))->netmod_area.padding)
/* Header bit fields
bit field
---- -------------------
50 single/multiple
49 large/small
48 ssend
24-47 match-bits for large messages (24 bits)
0-23 source
Note: This means we support no more than 2^24 processes.
*/
#define NPTL_SOURCE_OFFSET 0
#define NPTL_MATCH_BITS_OFFSET 24
#define NPTL_SSEND ((ptl_hdr_data_t)1<<48)
#define NPTL_LARGE ((ptl_hdr_data_t)1<<49)
#define NPTL_MULTIPLE ((ptl_hdr_data_t)1<<50)
#define NPTL_SOURCE_MASK ((((ptl_hdr_data_t)1<<24)-1)<<NPTL_SOURCE_OFFSET)
#define NPTL_MATCH_BITS_MASK ((((ptl_hdr_data_t)1<<24)-1)<<NPTL_MATCH_BITS_OFFSET)
#define NPTL_HEADER(flags, match_bits, source) ((flags) | \
((ptl_hdr_data_t)(match_bits))<<NPTL_MATCH_BITS_OFFSET | \
((ptl_hdr_data_t)(source))<<NPTL_SOURCE_OFFSET)
#define NPTL_HEADER_SOURCE(hdr) ((hdr & NPTL_SOURCE_MASK)>>NPTL_SOURCE_OFFSET)
#define NPTL_HEADER_MATCH_BITS(hdr) ((hdr & NPTL_MATCH_BITS_MASK)>>NPTL_MATCH_BITS_OFFSET)
/* This is the maximum number of processes we support */
#define NPTL_MAX_PROCS (NPTL_SOURCE_MASK+1)
/* create a match value */
#define NPTL_TAG_SHIFT 32
#define NPTL_MATCH(tag, context_id) (((ptl_match_bits)(tag) << NPTL_TAG_SHIFT) | (ptl_match_bits)(context_id))
struct MPID_nem_ptl_sendbuf;
int MPID_nem_ptl_send_init(void);
......@@ -58,6 +119,23 @@ int MPID_nem_ptl_poll_init(void);
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);
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);
/* comm override functions */
int MPID_nem_ptl_recv_posted(struct MPIDI_VC *vc, struct MPID_Request *req);
/* isend is also used to implement send, rsend and irsend */
int MPID_nem_ptl_isend(struct MPIDI_VC *vc, const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
MPID_Comm *comm, int context_offset, struct MPID_Request **request);
/* issend is also used to implement ssend */
int MPID_nem_ptl_issend(struct MPIDI_VC *vc, const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
MPID_Comm *comm, int context_offset, struct MPID_Request **request);
int MPID_nem_ptl_cancel_send(struct MPIDI_VC *vc, struct MPID_Request *sreq);
int MPID_nem_ptl_cancel_recv(struct MPIDI_VC *vc, struct MPID_Request *rreq);
int MPID_nem_ptl_probe(struct MPIDI_VC *vc, int source, int tag, MPID_Comm *comm, int context_offset, MPI_Status *status);
int MPID_nem_ptl_iprobe(struct MPIDI_VC *vc, int source, int tag, MPID_Comm *comm, int context_offset, int *flag,
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);
#endif /* PTL_IMPL_H */
......@@ -11,9 +11,10 @@
#endif
#define EQ_COUNT 100
#define NID_KEY "NID"
#define PID_KEY "PID"
#define PTI_KEY "PTI"
#define NID_KEY "NID"
#define PID_KEY "PID"
#define PTI_KEY "PTI"
#define PTIC_KEY "PTIC"
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);
......@@ -23,6 +24,8 @@ 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,
......@@ -35,6 +38,30 @@ MPID_nem_netmod_funcs_t MPIDI_nem_portals4_funcs = {
NULL /* anysource iprobe */
};
static MPIDI_Comm_ops_t comm_ops = {
MPID_nem_ptl_recv_posted, /* recv_posted */
MPID_nem_ptl_isend, /* send */
MPID_nem_ptl_isend, /* rsend */
MPID_nem_ptl_issend, /* ssend */
MPID_nem_ptl_isend, /* isend */
MPID_nem_ptl_isend, /* irsend */
MPID_nem_ptl_issend, /* issend */
NULL, /* send_init */
NULL, /* bsend_init */
NULL, /* rsend_init */
NULL, /* ssend_init */
NULL, /* startall */
MPID_nem_ptl_cancel_send, /* cancel_send */
MPID_nem_ptl_cancel_recv, /* cancel_recv */
MPID_nem_ptl_probe, /* probe */
MPID_nem_ptl_iprobe, /* iprobe */
MPID_nem_ptl_improbe /* improbe */
};
#undef FUNCNAME
#define FUNCNAME ptl_init
......@@ -44,7 +71,6 @@ 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_process_t my_id;
MPIDI_STATE_DECL(MPID_STATE_PTL_INIT);
MPIDI_FUNC_ENTER(MPID_STATE_PTL_INIT);
......@@ -56,17 +82,23 @@ static int ptl_init(MPIDI_PG_t *pg_p, int pg_rank, char **bc_val_p, int *val_max
ret = PtlInit();
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlinit");
ret = PtlNIInit(PTL_IFACE_DEFAULT, PTL_NI_NO_MATCHING | PTL_NI_PHYSICAL,
ret = PtlNIInit(PTL_IFACE_DEFAULT, PTL_NI_MATCHING | PTL_NI_PHYSICAL,
PTL_PID_ANY, NULL, NULL, &MPIDI_nem_ptl_ni);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlniinit");
ret = PtlEQAlloc(MPIDI_nem_ptl_ni, EQ_COUNT, &MPIDI_nem_ptl_eq);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptleqalloc");
ret = PtlPTAlloc(MPIDI_nem_ptl_ni, 0, MPIDI_nem_ptl_eq, PTL_PT_ANY, &MPIDI_nem_ptl_pt);
/* 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,
PTL_PT_ANY, &MPIDI_nem_ptl_pt);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlptalloc");
ret = PtlGetId(MPIDI_nem_ptl_ni, &my_id);
/* 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,
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));
......@@ -134,21 +166,17 @@ 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;
ptl_process_t my_id;
int ret;
MPIDI_STATE_DECL(MPID_STATE_GET_BUSINESS_CARD);
MPIDI_FUNC_ENTER(MPID_STATE_GET_BUSINESS_CARD);
ret = PtlGetId(MPIDI_nem_ptl_ni, &my_id);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlgetid");
str_errno = MPIU_Str_add_binary_arg(bc_val_p, val_max_sz_p, NID_KEY, (char *)&my_id.phys.nid, sizeof(my_id.phys.nid));
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");
MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**buscard");
}
str_errno = MPIU_Str_add_binary_arg(bc_val_p, val_max_sz_p, PID_KEY, (char *)&my_id.phys.pid, sizeof(my_id.phys.pid));
str_errno = MPIU_Str_add_binary_arg(bc_val_p, val_max_sz_p, PID_KEY, (char *)&my_ptl_id.phys.pid, sizeof(my_ptl_id.phys.pid));
if (str_errno) {
MPIU_ERR_CHKANDJUMP(str_errno == MPIU_STR_NOMEM, mpi_errno, MPI_ERR_OTHER, "**buscard_len");
MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**buscard");
......@@ -158,6 +186,12 @@ static int get_business_card(int my_rank, char **bc_val_p, int *val_max_sz_p)
MPIU_ERR_CHKANDJUMP(str_errno == MPIU_STR_NOMEM, mpi_errno, MPI_ERR_OTHER, "**buscard_len");
MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**buscard");
}
str_errno = MPIU_Str_add_binary_arg(bc_val_p, val_max_sz_p, PTIC_KEY, (char *)&MPIDI_nem_ptl_control_pt,
sizeof(MPIDI_nem_ptl_control_pt));
if (str_errno) {
MPIU_ERR_CHKANDJUMP(str_errno == MPIU_STR_NOMEM, mpi_errno, MPI_ERR_OTHER, "**buscard_len");
MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**buscard");
}
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_GET_BUSINESS_CARD);
......@@ -200,10 +234,16 @@ 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;
if (MPIR_PARAM_COMM_OVERRIDES) /* allow feature to be disabled at runtime */
vc->comm_ops = &comm_ops;
vc_ch->next = NULL;
vc_ch->prev = NULL;
......@@ -232,7 +272,7 @@ static int vc_destroy(MPIDI_VC_t *vc)
#define FUNCNAME MPID_nem_ptl_get_id_from_bc
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_nem_ptl_get_id_from_bc(const char *business_card, ptl_process_t *id, ptl_pt_index_t *pt)
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)
{
int mpi_errno = MPI_SUCCESS;
int ret;
......@@ -250,6 +290,9 @@ int MPID_nem_ptl_get_id_from_bc(const char *business_card, ptl_process_t *id, pt
ret = MPIU_Str_get_binary_arg(business_card, PTI_KEY, (char *)pt, sizeof(pt), &len);
MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(*pt), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard");
ret = MPIU_Str_get_binary_arg(business_card, PTIC_KEY, (char *)ptc, sizeof(ptc), &len);
MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(*pt), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard");
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_GET_ID_FROM_BC);
return mpi_errno;
......
......@@ -33,7 +33,7 @@ int MPID_nem_ptl_poll_init(void)
recvbuf_le[i].uid = PTL_UID_ANY;
recvbuf_le[i].options = (PTL_LE_OP_PUT | PTL_LE_USE_ONCE |
PTL_LE_EVENT_UNLINK_DISABLE | PTL_LE_EVENT_LINK_DISABLE);
ret = PtlLEAppend(MPIDI_nem_ptl_ni, MPIDI_nem_ptl_pt, &recvbuf_le[i], PTL_PRIORITY_LIST, (void *)(uint64_t)i,
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");
}
......@@ -107,7 +107,7 @@ int MPID_nem_ptl_poll(int is_blocking_poll)
mpi_errno = MPID_nem_handle_pkt(vc, event.start, event.rlength);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
assert(event.start == recvbuf[(uint64_t)event.user_ptr]);
ret = PtlLEAppend(MPIDI_nem_ptl_ni, MPIDI_nem_ptl_pt, &recvbuf_le[(uint64_t)event.user_ptr],
ret = PtlLEAppend(MPIDI_nem_ptl_ni, MPIDI_nem_ptl_control_pt, &recvbuf_le[(uint64_t)event.user_ptr],
PTL_PRIORITY_LIST, event.user_ptr, &recvbuf_le_handle[(uint64_t)event.user_ptr]);
MPIU_ERR_CHKANDJUMP(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmeappend");
break;
......
......@@ -367,6 +367,17 @@ parameters:
will always be sent eagerly. If this parameter is set to -2,
then Nemesis will choose an appropriate value.
- category : nemesis
name : COMM_OVERRIDES
type : boolean
default : true
description : >-
If set to false, communication override functionality will be
disabled for netmods that provide the override feature. Some
netmods may not honor this flag.
# Note the netmod must implement this functionality by not
# setting the comm_ops table in any VC.
##############################################################
# debugging parameters
- category : debugger
......
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