2005-05-24 02:06:50 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-05-24 02:06:50 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-04 02:45:48 +04:00
|
|
|
#include "opal/threads/mutex.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "ompi/communicator/communicator.h"
|
|
|
|
#include "ompi/mca/pml/pml.h"
|
2005-06-02 01:09:43 +04:00
|
|
|
#include "pml_ob1.h"
|
|
|
|
#include "pml_ob1_comm.h"
|
2005-05-24 02:06:50 +04:00
|
|
|
#include "pml_ob1_recvfrag.h"
|
|
|
|
#include "pml_ob1_recvreq.h"
|
2005-06-01 18:34:22 +04:00
|
|
|
#include "pml_ob1_sendreq.h"
|
2005-06-02 01:09:43 +04:00
|
|
|
#include "pml_ob1_hdr.h"
|
2006-02-26 03:45:54 +03:00
|
|
|
#include "ompi/datatype/dt_arch.h"
|
2005-06-02 01:09:43 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-06-07 18:12:47 +04:00
|
|
|
mca_pml_ob1_buffer_t,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t,
|
2005-06-07 18:12:47 +04:00
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_frag_t,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t,
|
2005-05-24 02:06:50 +04:00
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-02 01:09:43 +04:00
|
|
|
/**
|
2005-06-30 09:50:55 +04:00
|
|
|
* Callback from BTL on receive.
|
2005-06-02 01:09:43 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_pml_ob1_recv_frag_callback(
|
2005-08-12 06:41:14 +04:00
|
|
|
mca_btl_base_module_t* btl,
|
|
|
|
mca_btl_base_tag_t tag,
|
|
|
|
mca_btl_base_descriptor_t* des,
|
|
|
|
void* cbdata)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_base_segment_t* segments = des->des_dst;
|
2005-05-24 02:06:50 +04:00
|
|
|
mca_pml_ob1_hdr_t* hdr = (mca_pml_ob1_hdr_t*)segments->seg_addr.pval;
|
|
|
|
if(segments->seg_len < sizeof(mca_pml_ob1_common_hdr_t)) {
|
|
|
|
return;
|
|
|
|
}
|
2005-06-02 01:09:43 +04:00
|
|
|
|
2006-02-26 03:45:54 +03:00
|
|
|
/* hdr_type and hdr_flags are uint8_t, so no endian problems */
|
2005-05-24 02:06:50 +04:00
|
|
|
switch(hdr->hdr_common.hdr_type) {
|
2005-08-12 06:41:14 +04:00
|
|
|
case MCA_PML_OB1_HDR_TYPE_MATCH:
|
2006-02-26 03:45:54 +03:00
|
|
|
{
|
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (hdr->hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_NBO) {
|
|
|
|
MCA_PML_OB1_MATCH_HDR_NTOH(hdr->hdr_match);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mca_pml_ob1_recv_frag_match(btl, &hdr->hdr_match, segments,des->des_dst_cnt);
|
|
|
|
break;
|
|
|
|
}
|
2005-08-12 06:41:14 +04:00
|
|
|
case MCA_PML_OB1_HDR_TYPE_RNDV:
|
2006-02-26 03:45:54 +03:00
|
|
|
{
|
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (hdr->hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_NBO) {
|
|
|
|
MCA_PML_OB1_RNDV_HDR_NTOH(hdr->hdr_rndv);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mca_pml_ob1_recv_frag_match(btl, &hdr->hdr_match, segments,des->des_dst_cnt);
|
|
|
|
break;
|
|
|
|
}
|
2005-08-17 22:23:38 +04:00
|
|
|
case MCA_PML_OB1_HDR_TYPE_RGET:
|
2005-08-12 06:41:14 +04:00
|
|
|
{
|
2006-02-26 03:45:54 +03:00
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
2006-02-28 22:54:46 +03:00
|
|
|
/* RDMA is currently disabled by bml if arch doesn't
|
|
|
|
match, so this shouldn't be needed. here to make sure
|
|
|
|
we remember if we ever change the bml. */
|
|
|
|
assert(0 == (hdr->hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_NBO));
|
2006-02-26 03:45:54 +03:00
|
|
|
#endif
|
2005-08-12 06:41:14 +04:00
|
|
|
mca_pml_ob1_recv_frag_match(btl, &hdr->hdr_match, segments,des->des_dst_cnt);
|
2005-05-24 02:06:50 +04:00
|
|
|
break;
|
2005-08-12 06:41:14 +04:00
|
|
|
}
|
|
|
|
case MCA_PML_OB1_HDR_TYPE_ACK:
|
|
|
|
{
|
2006-02-26 03:45:54 +03:00
|
|
|
mca_pml_ob1_send_request_t* sendreq;
|
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (hdr->hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_NBO) {
|
|
|
|
MCA_PML_OB1_ACK_HDR_NTOH(hdr->hdr_ack);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
sendreq = (mca_pml_ob1_send_request_t*)
|
2005-06-02 01:09:43 +04:00
|
|
|
hdr->hdr_ack.hdr_src_req.pval;
|
|
|
|
sendreq->req_recv = hdr->hdr_ack.hdr_dst_req;
|
2005-06-09 00:37:19 +04:00
|
|
|
sendreq->req_rdma_offset = hdr->hdr_ack.hdr_rdma_offset;
|
2005-07-18 22:54:25 +04:00
|
|
|
MCA_PML_OB1_SEND_REQUEST_ADVANCE(sendreq);
|
2005-06-01 18:34:22 +04:00
|
|
|
break;
|
2005-08-12 06:41:14 +04:00
|
|
|
}
|
|
|
|
case MCA_PML_OB1_HDR_TYPE_FRAG:
|
|
|
|
{
|
2006-02-26 03:45:54 +03:00
|
|
|
mca_pml_ob1_recv_request_t* recvreq;
|
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (hdr->hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_NBO) {
|
|
|
|
MCA_PML_OB1_FRAG_HDR_NTOH(hdr->hdr_frag);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
recvreq = (mca_pml_ob1_recv_request_t*)
|
2005-06-02 01:09:43 +04:00
|
|
|
hdr->hdr_frag.hdr_dst_req.pval;
|
2005-08-17 22:23:38 +04:00
|
|
|
mca_pml_ob1_recv_request_progress(recvreq,btl,segments,des->des_dst_cnt);
|
2005-06-02 01:09:43 +04:00
|
|
|
break;
|
2005-08-12 06:41:14 +04:00
|
|
|
}
|
|
|
|
case MCA_PML_OB1_HDR_TYPE_PUT:
|
|
|
|
{
|
2006-02-26 03:45:54 +03:00
|
|
|
mca_pml_ob1_send_request_t* sendreq;
|
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
2006-02-28 22:54:46 +03:00
|
|
|
/* RDMA is currently disabled by bml if arch doesn't
|
|
|
|
match, so this shouldn't be needed. here to make sure
|
|
|
|
we remember if we ever change the bml. */
|
|
|
|
assert(0 == (hdr->hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_NBO));
|
2006-02-26 03:45:54 +03:00
|
|
|
#endif
|
|
|
|
sendreq = (mca_pml_ob1_send_request_t*)
|
2005-08-17 22:23:38 +04:00
|
|
|
hdr->hdr_rdma.hdr_req.pval;
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_pml_ob1_send_request_put(sendreq,btl,&hdr->hdr_rdma);
|
2005-06-09 07:11:51 +04:00
|
|
|
break;
|
2005-08-12 06:41:14 +04:00
|
|
|
}
|
|
|
|
case MCA_PML_OB1_HDR_TYPE_FIN:
|
|
|
|
{
|
2006-02-26 03:45:54 +03:00
|
|
|
mca_btl_base_descriptor_t* rdma;
|
|
|
|
#if !defined(WORDS_BIGENDIAN) && OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
if (hdr->hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_NBO) {
|
|
|
|
MCA_PML_OB1_FIN_HDR_NTOH(hdr->hdr_fin);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
rdma = (mca_btl_base_descriptor_t*)
|
2005-08-17 22:23:38 +04:00
|
|
|
hdr->hdr_fin.hdr_des.pval;
|
|
|
|
rdma->des_cbfunc(btl, NULL, rdma, OMPI_SUCCESS);
|
2005-06-09 07:11:51 +04:00
|
|
|
break;
|
2005-08-12 06:41:14 +04:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
}
|
2006-02-09 09:59:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try and match the incoming message fragment to a generic
|
|
|
|
* list of receives
|
|
|
|
*
|
|
|
|
* @param hdr Matching data from received fragment (IN)
|
|
|
|
*
|
|
|
|
* @param generic_receives Pointer to the receive list used for
|
|
|
|
* matching purposes. (IN)
|
|
|
|
*
|
|
|
|
* @return Matched receive
|
|
|
|
*
|
|
|
|
* This routine assumes that the appropriate matching locks are
|
|
|
|
* set by the upper level routine.
|
|
|
|
*/
|
2006-02-10 21:55:43 +03:00
|
|
|
#define MCA_PML_OB1_MATCH_GENERIC_RECEIVES(hdr,generic_receives,proc,return_match) \
|
2006-02-09 09:59:54 +03:00
|
|
|
do { \
|
|
|
|
/* local variables */ \
|
|
|
|
mca_pml_ob1_recv_request_t *generic_recv; \
|
|
|
|
int recv_tag, frag_tag = hdr->hdr_tag; \
|
|
|
|
\
|
|
|
|
/* Loop over the receives. */ \
|
|
|
|
for( generic_recv = (mca_pml_ob1_recv_request_t *) \
|
|
|
|
opal_list_get_first(generic_receives); \
|
|
|
|
generic_recv != (mca_pml_ob1_recv_request_t *) \
|
|
|
|
opal_list_get_end(generic_receives); \
|
|
|
|
generic_recv = (mca_pml_ob1_recv_request_t *) \
|
|
|
|
((opal_list_item_t *)generic_recv)->opal_list_next) { \
|
|
|
|
/* Check for a match */ \
|
|
|
|
recv_tag = generic_recv->req_recv.req_base.req_tag; \
|
|
|
|
if ( (frag_tag == recv_tag) || \
|
|
|
|
( (recv_tag == OMPI_ANY_TAG) && (0 <= frag_tag) ) ) { \
|
|
|
|
\
|
2006-02-10 21:55:43 +03:00
|
|
|
generic_recv->req_recv.req_base.req_proc = proc->proc_ompi; \
|
2006-02-09 09:59:54 +03:00
|
|
|
/* Match made */ \
|
|
|
|
return_match = generic_recv; \
|
|
|
|
\
|
|
|
|
/* remove descriptor from posted specific ireceive list */ \
|
|
|
|
opal_list_remove_item(generic_receives, \
|
|
|
|
(opal_list_item_t *)generic_recv); \
|
|
|
|
\
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while(0)
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Try and match the incoming message fragment to the list of
|
|
|
|
* "wild" receives
|
|
|
|
*
|
|
|
|
* @param hdr Matching data from recived fragment (IN)
|
|
|
|
*
|
|
|
|
* @param pml_comm Pointer to the communicator structure used for
|
|
|
|
* matching purposes. (IN)
|
|
|
|
*
|
|
|
|
* @return Matched receive
|
|
|
|
*
|
|
|
|
* This routine assumes that the appropriate matching locks are
|
|
|
|
* set by the upper level routine.
|
|
|
|
*/
|
|
|
|
|
2005-12-01 20:17:06 +03:00
|
|
|
#define MCA_PML_OB1_CHECK_WILD_RECEIVES_FOR_MATCH(hdr,comm,proc,return_match) \
|
2005-06-02 01:09:43 +04:00
|
|
|
do { \
|
|
|
|
/* local parameters */ \
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t* wild_receives = &comm->wild_receives; \
|
2006-02-10 21:55:43 +03:00
|
|
|
MCA_PML_OB1_MATCH_GENERIC_RECEIVES(hdr,wild_receives,proc,return_match); \
|
2005-06-02 01:09:43 +04:00
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try and match the incoming message fragment to the list of
|
|
|
|
* "specific" receives
|
|
|
|
*
|
|
|
|
* @param hdr Matching data from recived fragment (IN)
|
|
|
|
*
|
|
|
|
* @param comm Pointer to the communicator structure used for
|
|
|
|
* matching purposes. (IN)
|
|
|
|
*
|
|
|
|
* @return Matched receive
|
|
|
|
*
|
|
|
|
* This routine assumes that the appropriate matching locks are
|
|
|
|
* set by the upper level routine.
|
|
|
|
*/
|
2005-12-01 20:17:06 +03:00
|
|
|
#define MCA_PML_OB1_CHECK_SPECIFIC_RECEIVES_FOR_MATCH(hdr,comm,proc,return_match) \
|
2005-06-02 01:09:43 +04:00
|
|
|
do { \
|
|
|
|
/* local variables */ \
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t* specific_receives = &proc->specific_receives; \
|
2006-02-10 21:55:43 +03:00
|
|
|
MCA_PML_OB1_MATCH_GENERIC_RECEIVES(hdr,specific_receives,proc,return_match); \
|
2005-06-02 01:09:43 +04:00
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try and match the incoming message fragment to the list of
|
|
|
|
* "wild" receives and "specific" receives. Used when both types
|
|
|
|
* of receives have been posted, i.e. when we need to coordinate
|
|
|
|
* between multiple lists to make sure ordered delivery occurs.
|
|
|
|
*
|
|
|
|
* @param hdr Matching data from recived fragment (IN)
|
|
|
|
*
|
|
|
|
* @param comm Pointer to the communicator structure used for
|
|
|
|
* matching purposes. (IN)
|
|
|
|
*
|
|
|
|
* @return Matched receive
|
|
|
|
*
|
|
|
|
* This routine assumes that the appropriate matching locks are
|
|
|
|
* set by the upper level routine.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MCA_PML_OB1_CHECK_SPECIFIC_AND_WILD_RECEIVES_FOR_MATCH( \
|
2005-12-01 20:17:06 +03:00
|
|
|
hdr,comm,proc,return_match) \
|
2005-06-02 01:09:43 +04:00
|
|
|
do { \
|
|
|
|
/* local variables */ \
|
|
|
|
mca_pml_ob1_recv_request_t *specific_recv, *wild_recv; \
|
2006-02-23 03:39:01 +03:00
|
|
|
mca_pml_sequence_t wild_recv_seq, specific_recv_seq; \
|
2005-06-02 01:09:43 +04:00
|
|
|
int frag_tag, wild_recv_tag, specific_recv_tag; \
|
|
|
|
\
|
|
|
|
/* initialization */ \
|
|
|
|
frag_tag=hdr->hdr_tag; \
|
|
|
|
\
|
|
|
|
/* \
|
|
|
|
* We know that when this is called, both specific and wild irecvs \
|
|
|
|
* have been posted. \
|
|
|
|
*/ \
|
|
|
|
specific_recv = (mca_pml_ob1_recv_request_t *) \
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_first(&(proc)->specific_receives); \
|
2005-06-02 01:09:43 +04:00
|
|
|
wild_recv = (mca_pml_ob1_recv_request_t *) \
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_first(&comm->wild_receives); \
|
2005-06-02 01:09:43 +04:00
|
|
|
\
|
|
|
|
specific_recv_seq = specific_recv->req_recv.req_base.req_sequence; \
|
|
|
|
wild_recv_seq = wild_recv->req_recv.req_base.req_sequence; \
|
|
|
|
\
|
|
|
|
while (true) { \
|
|
|
|
if (wild_recv_seq < specific_recv_seq) { \
|
|
|
|
/* \
|
|
|
|
* wild recv is earlier than the specific one. \
|
|
|
|
*/ \
|
|
|
|
/* \
|
|
|
|
* try and match \
|
|
|
|
*/ \
|
|
|
|
wild_recv_tag = wild_recv->req_recv.req_base.req_tag; \
|
|
|
|
if ( (frag_tag == wild_recv_tag) || \
|
|
|
|
( (wild_recv_tag == OMPI_ANY_TAG) && (0 <= frag_tag) ) ) { \
|
|
|
|
/* \
|
|
|
|
* Match made \
|
|
|
|
*/ \
|
|
|
|
return_match=wild_recv; \
|
|
|
|
\
|
|
|
|
/* remove this recv from the wild receive queue */ \
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(&comm->wild_receives, \
|
|
|
|
(opal_list_item_t *)wild_recv); \
|
2005-06-02 01:09:43 +04:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
/* \
|
|
|
|
* No match, go to the next. \
|
|
|
|
*/ \
|
|
|
|
wild_recv=(mca_pml_ob1_recv_request_t *) \
|
2005-07-03 20:22:16 +04:00
|
|
|
((opal_list_item_t *)wild_recv)->opal_list_next; \
|
2005-06-02 01:09:43 +04:00
|
|
|
\
|
|
|
|
/* \
|
|
|
|
* If that was the last wild one, just look at the \
|
|
|
|
* rest of the specific ones. \
|
|
|
|
*/ \
|
|
|
|
if (wild_recv == (mca_pml_ob1_recv_request_t *) \
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_end(&comm->wild_receives) ) \
|
2005-06-02 01:09:43 +04:00
|
|
|
{ \
|
2005-12-01 20:17:06 +03:00
|
|
|
MCA_PML_OB1_CHECK_SPECIFIC_RECEIVES_FOR_MATCH(hdr, comm, proc, return_match); \
|
2005-06-02 01:09:43 +04:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
/* \
|
|
|
|
* Get the sequence number for this recv, and go \
|
|
|
|
* back to the top of the loop. \
|
|
|
|
*/ \
|
|
|
|
wild_recv_seq = wild_recv->req_recv.req_base.req_sequence; \
|
|
|
|
\
|
|
|
|
} else { \
|
|
|
|
/* \
|
|
|
|
* specific recv is earlier than the wild one. \
|
|
|
|
*/ \
|
|
|
|
specific_recv_tag=specific_recv->req_recv.req_base.req_tag; \
|
|
|
|
if ( (frag_tag == specific_recv_tag) || \
|
|
|
|
( (specific_recv_tag == OMPI_ANY_TAG) && (0<=frag_tag)) ) \
|
|
|
|
{ \
|
|
|
|
/* \
|
|
|
|
* Match made \
|
|
|
|
*/ \
|
|
|
|
return_match = specific_recv; \
|
|
|
|
/* remove descriptor from specific receive list */ \
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(&(proc)->specific_receives, \
|
|
|
|
(opal_list_item_t *)specific_recv); \
|
2005-06-02 01:09:43 +04:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
/* \
|
|
|
|
* No match, go on to the next specific irecv. \
|
|
|
|
*/ \
|
|
|
|
specific_recv = (mca_pml_ob1_recv_request_t *) \
|
2005-07-03 20:22:16 +04:00
|
|
|
((opal_list_item_t *)specific_recv)->opal_list_next; \
|
2005-06-02 01:09:43 +04:00
|
|
|
\
|
|
|
|
/* \
|
|
|
|
* If that was the last specific irecv, process the \
|
|
|
|
* rest of the wild ones. \
|
|
|
|
*/ \
|
|
|
|
if (specific_recv == (mca_pml_ob1_recv_request_t *) \
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_end(&(proc)->specific_receives)) \
|
2005-06-02 01:09:43 +04:00
|
|
|
{ \
|
2005-12-01 20:17:06 +03:00
|
|
|
MCA_PML_OB1_CHECK_WILD_RECEIVES_FOR_MATCH(hdr, comm, proc, return_match); \
|
2005-06-02 01:09:43 +04:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
/* \
|
|
|
|
* Get the sequence number for this recv, and go \
|
|
|
|
* back to the top of the loop. \
|
|
|
|
*/ \
|
|
|
|
specific_recv_seq = specific_recv->req_recv.req_base.req_sequence; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Specialized matching routines for internal use only.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool mca_pml_ob1_check_cantmatch_for_match(
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t *additional_matches,
|
2005-06-02 01:09:43 +04:00
|
|
|
mca_pml_ob1_comm_t* comm,
|
|
|
|
mca_pml_ob1_comm_proc_t *proc);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RCS/CTS receive side matching
|
|
|
|
*
|
|
|
|
* @param hdr list of parameters needed for matching
|
2005-06-07 18:12:47 +04:00
|
|
|
* This list is also embeded in frag,
|
2005-06-02 01:09:43 +04:00
|
|
|
* but this allows to save a memory copy when
|
|
|
|
* a match is made in this routine. (IN)
|
2005-06-07 18:12:47 +04:00
|
|
|
* @param frag pointer to receive fragment which we want
|
2005-06-02 01:09:43 +04:00
|
|
|
* to match (IN/OUT). If a match is not made,
|
2005-06-07 18:12:47 +04:00
|
|
|
* hdr is copied to frag.
|
|
|
|
* @param match_made parameter indicating if we matched frag/
|
2005-06-02 01:09:43 +04:00
|
|
|
* hdr (OUT)
|
2005-06-07 18:12:47 +04:00
|
|
|
* @param additional_matches if a match is made with frag, we
|
2005-06-02 01:09:43 +04:00
|
|
|
* may be able to match fragments that previously
|
|
|
|
* have arrived out-of-order. If this is the
|
|
|
|
* case, the associated fragment descriptors are
|
|
|
|
* put on this list for further processing. (OUT)
|
|
|
|
*
|
|
|
|
* @return OMPI error code
|
|
|
|
*
|
|
|
|
* This routine is used to try and match a newly arrived message fragment
|
|
|
|
* to pre-posted receives. The following assumptions are made
|
|
|
|
* - fragments are received out of order
|
|
|
|
* - for long messages, e.g. more than one fragment, a RTS/CTS algorithm
|
|
|
|
* is used.
|
|
|
|
* - 2nd and greater fragments include a receive descriptor pointer
|
|
|
|
* - fragments may be dropped
|
|
|
|
* - fragments may be corrupt
|
|
|
|
* - this routine may be called simultaneously by more than one thread
|
|
|
|
*/
|
|
|
|
int mca_pml_ob1_recv_frag_match(
|
2005-08-12 06:41:14 +04:00
|
|
|
mca_btl_base_module_t *btl,
|
|
|
|
mca_pml_ob1_match_hdr_t *hdr,
|
|
|
|
mca_btl_base_segment_t* segments,
|
|
|
|
size_t num_segments)
|
2005-06-02 01:09:43 +04:00
|
|
|
{
|
|
|
|
/* local variables */
|
|
|
|
uint16_t next_msg_seq_expected, frag_msg_seq;
|
|
|
|
ompi_communicator_t *comm_ptr;
|
|
|
|
mca_pml_ob1_recv_request_t *match = NULL;
|
|
|
|
mca_pml_ob1_comm_t *comm;
|
|
|
|
mca_pml_ob1_comm_proc_t *proc;
|
|
|
|
bool additional_match=false;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t additional_matches;
|
2005-06-02 01:09:43 +04:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* communicator pointer */
|
2005-08-17 22:23:38 +04:00
|
|
|
comm_ptr=ompi_comm_lookup(hdr->hdr_ctx);
|
2005-06-02 01:09:43 +04:00
|
|
|
comm=(mca_pml_ob1_comm_t *)comm_ptr->c_pml_comm;
|
|
|
|
|
|
|
|
/* source sequence number */
|
2005-08-17 22:23:38 +04:00
|
|
|
frag_msg_seq = hdr->hdr_seq;
|
2005-06-02 01:09:43 +04:00
|
|
|
proc = comm->procs + hdr->hdr_src;
|
|
|
|
|
|
|
|
/* get next expected message sequence number - if threaded
|
|
|
|
* run, lock to make sure that if another thread is processing
|
|
|
|
* a frag from the same message a match is made only once.
|
|
|
|
* Also, this prevents other posted receives (for a pair of
|
|
|
|
* end points) from being processed, and potentially "loosing"
|
|
|
|
* the fragment.
|
|
|
|
*/
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&comm->matching_lock);
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
/* get sequence number of next message that can be processed */
|
|
|
|
next_msg_seq_expected = (uint16_t)proc->expected_sequence;
|
|
|
|
if (frag_msg_seq == next_msg_seq_expected) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the sequence number we were expecting,
|
|
|
|
* so we can try matching it to already posted
|
|
|
|
* receives.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* We're now expecting the next sequence number. */
|
|
|
|
(proc->expected_sequence)++;
|
2005-12-01 20:06:40 +03:00
|
|
|
rematch:
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* figure out what sort of matching logic to use, if need to
|
|
|
|
* look only at "specific" receives, or "wild" receives,
|
|
|
|
* or if we need to traverse both sets at the same time.
|
|
|
|
*/
|
2005-07-03 20:22:16 +04:00
|
|
|
if (opal_list_get_size(&proc->specific_receives) == 0 ){
|
2005-06-02 01:09:43 +04:00
|
|
|
/*
|
|
|
|
* There are only wild irecvs, so specialize the algorithm.
|
|
|
|
*/
|
2005-12-01 20:17:06 +03:00
|
|
|
MCA_PML_OB1_CHECK_WILD_RECEIVES_FOR_MATCH(hdr, comm, proc, match);
|
2005-06-02 01:09:43 +04:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
} else if (opal_list_get_size(&comm->wild_receives) == 0 ) {
|
2005-06-02 01:09:43 +04:00
|
|
|
/*
|
|
|
|
* There are only specific irecvs, so specialize the algorithm.
|
|
|
|
*/
|
2005-12-01 20:17:06 +03:00
|
|
|
MCA_PML_OB1_CHECK_SPECIFIC_RECEIVES_FOR_MATCH(hdr, comm, proc, match);
|
2005-06-02 01:09:43 +04:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* There are some of each.
|
|
|
|
*/
|
2005-12-01 20:17:06 +03:00
|
|
|
MCA_PML_OB1_CHECK_SPECIFIC_AND_WILD_RECEIVES_FOR_MATCH(hdr, comm, proc, match);
|
2005-06-02 01:09:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if match found, process data */
|
|
|
|
if (match) {
|
2005-08-12 06:41:14 +04:00
|
|
|
|
2005-06-02 01:09:43 +04:00
|
|
|
/*
|
|
|
|
* update delivered sequence number information, if needed.
|
|
|
|
*/
|
2005-08-12 06:41:14 +04:00
|
|
|
if( (match->req_recv.req_base.req_type == MCA_PML_REQUEST_PROBE) ) {
|
2005-09-13 20:45:41 +04:00
|
|
|
|
|
|
|
/* complete the probe */
|
|
|
|
mca_pml_ob1_recv_request_matched_probe(match,btl,segments,num_segments);
|
|
|
|
|
2005-12-01 20:17:06 +03:00
|
|
|
/* attempt to match actual request */
|
2005-12-01 20:06:40 +03:00
|
|
|
match = NULL;
|
|
|
|
goto rematch;
|
2005-06-02 01:09:43 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* if no match found, place on unexpected queue */
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_frag_t* frag;
|
|
|
|
MCA_PML_OB1_RECV_FRAG_ALLOC(frag, rc);
|
2005-06-02 01:09:43 +04:00
|
|
|
if(OMPI_SUCCESS != rc) {
|
2005-08-02 21:36:01 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&comm->matching_lock);
|
2005-06-02 01:09:43 +04:00
|
|
|
return rc;
|
|
|
|
}
|
2005-08-17 22:23:38 +04:00
|
|
|
MCA_PML_OB1_RECV_FRAG_INIT(frag,hdr,segments,num_segments,btl);
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append( &proc->unexpected_frags, (opal_list_item_t *)frag );
|
2005-06-02 01:09:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that new message has arrived, check to see if
|
|
|
|
* any fragments on the c_c_frags_cant_match list
|
|
|
|
* may now be used to form new matchs
|
|
|
|
*/
|
2005-07-03 20:22:16 +04:00
|
|
|
if (0 < opal_list_get_size(&proc->frags_cant_match)) {
|
2005-06-02 01:09:43 +04:00
|
|
|
additional_match = mca_pml_ob1_check_cantmatch_for_match(&additional_matches,comm,proc);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This message comes after the next expected, so it
|
|
|
|
* is ahead of sequence. Save it for later.
|
|
|
|
*/
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_frag_t* frag;
|
|
|
|
MCA_PML_OB1_RECV_FRAG_ALLOC(frag, rc);
|
2005-06-02 01:09:43 +04:00
|
|
|
if(OMPI_SUCCESS != rc) {
|
2005-08-02 21:36:01 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&comm->matching_lock);
|
2005-06-02 01:09:43 +04:00
|
|
|
return rc;
|
|
|
|
}
|
2005-08-17 22:23:38 +04:00
|
|
|
MCA_PML_OB1_RECV_FRAG_INIT(frag,hdr,segments,num_segments,btl);
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&proc->frags_cant_match, (opal_list_item_t *)frag);
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
}
|
2005-12-11 02:25:29 +03:00
|
|
|
/* release matching lock before processing fragment */
|
2005-08-02 21:36:01 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&comm->matching_lock);
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
if(match != NULL) {
|
2005-08-17 22:23:38 +04:00
|
|
|
mca_pml_ob1_recv_request_progress(match,btl,segments,num_segments);
|
2005-06-17 22:25:44 +04:00
|
|
|
}
|
2005-06-02 01:09:43 +04:00
|
|
|
if(additional_match) {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t* item;
|
|
|
|
while(NULL != (item = opal_list_remove_first(&additional_matches))) {
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_frag_t* frag = (mca_pml_ob1_recv_frag_t*)item;
|
2005-08-17 22:23:38 +04:00
|
|
|
mca_pml_ob1_recv_request_progress(frag->request,frag->btl,frag->segments,frag->num_segments);
|
2005-06-10 00:16:33 +04:00
|
|
|
MCA_PML_OB1_RECV_FRAG_RETURN(frag);
|
2005-06-02 01:09:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scan the list of frags that came in ahead of time to see if any
|
|
|
|
* can be processed at this time. If they can, try and match the
|
|
|
|
* frags.
|
|
|
|
*
|
|
|
|
* @param additional_matches List to hold new matches with fragments
|
|
|
|
* from the c_frags_cant_match list. (IN/OUT)
|
|
|
|
*
|
|
|
|
* @param pml_comm Pointer to the communicator structure used for
|
|
|
|
* matching purposes. (IN)
|
|
|
|
*
|
|
|
|
* This routine assumes that the appropriate matching locks are
|
|
|
|
* set by the upper level routine.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool mca_pml_ob1_check_cantmatch_for_match(
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t *additional_matches,
|
2005-06-02 01:09:43 +04:00
|
|
|
mca_pml_ob1_comm_t* comm,
|
|
|
|
mca_pml_ob1_comm_proc_t *proc)
|
|
|
|
{
|
|
|
|
/* local parameters */
|
|
|
|
int match_found;
|
|
|
|
uint16_t next_msg_seq_expected, frag_seq;
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_frag_t *frag;
|
2005-06-02 01:09:43 +04:00
|
|
|
bool match_made = false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop over all the out of sequence messages. No ordering is assumed
|
|
|
|
* in the c_frags_cant_match list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
match_found = 1;
|
2005-07-03 20:22:16 +04:00
|
|
|
while ((0 < opal_list_get_size(&proc->frags_cant_match)) && match_found) {
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
/* initialize match flag for this search */
|
|
|
|
match_found = 0;
|
|
|
|
|
|
|
|
/* get sequence number of next message that can be processed */
|
|
|
|
next_msg_seq_expected = proc->expected_sequence;
|
|
|
|
|
|
|
|
/* search the list for a fragment from the send with sequence
|
|
|
|
* number next_msg_seq_expected
|
|
|
|
*/
|
2005-06-10 00:16:33 +04:00
|
|
|
for(frag = (mca_pml_ob1_recv_frag_t *)
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_first(&proc->frags_cant_match);
|
2005-06-10 00:16:33 +04:00
|
|
|
frag != (mca_pml_ob1_recv_frag_t *)
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_end(&proc->frags_cant_match);
|
2005-06-10 00:16:33 +04:00
|
|
|
frag = (mca_pml_ob1_recv_frag_t *)
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_next(frag))
|
2005-06-02 01:09:43 +04:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If the message has the next expected seq from that proc...
|
|
|
|
*/
|
2005-08-17 22:23:38 +04:00
|
|
|
frag_seq=frag->hdr.hdr_match.hdr_seq;
|
2005-06-02 01:09:43 +04:00
|
|
|
if (frag_seq == next_msg_seq_expected) {
|
2005-06-07 18:12:47 +04:00
|
|
|
mca_pml_ob1_match_hdr_t* hdr = &frag->hdr.hdr_match;
|
2005-11-30 20:57:59 +03:00
|
|
|
mca_pml_ob1_recv_request_t *match = NULL;
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
/* We're now expecting the next sequence number. */
|
|
|
|
(proc->expected_sequence)++;
|
|
|
|
|
|
|
|
/* signal that match was made */
|
|
|
|
match_found = 1;
|
|
|
|
|
|
|
|
/*
|
2005-06-07 18:12:47 +04:00
|
|
|
* remove frag from list
|
2005-06-02 01:09:43 +04:00
|
|
|
*/
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(&proc->frags_cant_match,
|
|
|
|
(opal_list_item_t *)frag);
|
2005-06-02 01:09:43 +04:00
|
|
|
|
2005-12-01 20:32:27 +03:00
|
|
|
rematch:
|
2005-06-02 01:09:43 +04:00
|
|
|
/*
|
|
|
|
* figure out what sort of matching logic to use, if need to
|
|
|
|
* look only at "specific" receives, or "wild" receives,
|
|
|
|
* or if we need to traverse both sets at the same time.
|
|
|
|
*/
|
|
|
|
proc = comm->procs + hdr->hdr_src;
|
2005-07-03 20:22:16 +04:00
|
|
|
if (opal_list_get_size(&proc->specific_receives) == 0 ) {
|
2005-06-02 01:09:43 +04:00
|
|
|
/*
|
|
|
|
* There are only wild irecvs, so specialize the algorithm.
|
|
|
|
*/
|
2005-12-01 20:17:06 +03:00
|
|
|
MCA_PML_OB1_CHECK_WILD_RECEIVES_FOR_MATCH(hdr, comm, proc, match);
|
2005-07-03 20:22:16 +04:00
|
|
|
} else if (opal_list_get_size(&comm->wild_receives) == 0 ) {
|
2005-06-02 01:09:43 +04:00
|
|
|
/*
|
|
|
|
* There are only specific irecvs, so specialize the algorithm.
|
|
|
|
*/
|
2005-12-01 20:17:06 +03:00
|
|
|
MCA_PML_OB1_CHECK_SPECIFIC_RECEIVES_FOR_MATCH(hdr, comm, proc, match);
|
2005-06-02 01:09:43 +04:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* There are some of each.
|
|
|
|
*/
|
2005-12-01 20:17:06 +03:00
|
|
|
MCA_PML_OB1_CHECK_SPECIFIC_AND_WILD_RECEIVES_FOR_MATCH(hdr, comm, proc, match);
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if match found, process data */
|
|
|
|
if (match) {
|
|
|
|
|
2005-11-30 20:57:59 +03:00
|
|
|
/*
|
|
|
|
* If this was a probe need to queue fragment on unexpected list
|
2005-06-02 01:09:43 +04:00
|
|
|
*/
|
2005-11-30 20:57:59 +03:00
|
|
|
if( (match->req_recv.req_base.req_type == MCA_PML_REQUEST_PROBE) ) {
|
|
|
|
|
|
|
|
/* complete the probe */
|
|
|
|
mca_pml_ob1_recv_request_matched_probe(match,frag->btl,frag->segments,frag->num_segments);
|
|
|
|
|
2005-12-01 20:32:27 +03:00
|
|
|
/* retry the match */
|
|
|
|
match = NULL;
|
|
|
|
goto rematch;
|
2005-11-30 20:57:59 +03:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* associate the receive descriptor with the fragment
|
|
|
|
* descriptor */
|
|
|
|
frag->request=match;
|
|
|
|
|
|
|
|
/* add this fragment descriptor to the list of
|
|
|
|
* descriptors to be processed later
|
|
|
|
*/
|
|
|
|
if(match_made == false) {
|
|
|
|
match_made = true;
|
|
|
|
OBJ_CONSTRUCT(additional_matches, opal_list_t);
|
|
|
|
}
|
|
|
|
opal_list_append(additional_matches, (opal_list_item_t *)frag);
|
2005-06-02 01:09:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* if no match found, place on unexpected queue */
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append( &proc->unexpected_frags, (opal_list_item_t *)frag);
|
2005-06-02 01:09:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* c_frags_cant_match is not an ordered list, so exit loop
|
|
|
|
* and re-start search for next sequence number */
|
|
|
|
break;
|
|
|
|
|
|
|
|
} /* end if (frag_seq == next_msg_seq_expected) */
|
|
|
|
|
2005-06-07 18:12:47 +04:00
|
|
|
} /* end for (frag) loop */
|
2005-06-02 01:09:43 +04:00
|
|
|
|
|
|
|
} /* end while loop */
|
|
|
|
|
|
|
|
return match_made;
|
|
|
|
}
|
2005-05-24 02:06:50 +04:00
|
|
|
|