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.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* 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$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
#include "ompi/mca/bml/bml.h"
|
|
|
|
#include "ompi/mca/btl/btl.h"
|
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
2005-05-24 02:06:50 +04:00
|
|
|
#include "pml_ob1_comm.h"
|
|
|
|
#include "pml_ob1_recvreq.h"
|
|
|
|
#include "pml_ob1_recvfrag.h"
|
|
|
|
#include "pml_ob1_sendreq.h"
|
2005-08-17 22:23:38 +04:00
|
|
|
#include "pml_ob1_rdmafrag.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/bml/base/base.h"
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2006-03-16 01:53:41 +03:00
|
|
|
#include "ompi/datatype/dt_arch.h"
|
2006-02-26 03:45:54 +03:00
|
|
|
|
2005-06-10 00:16:33 +04:00
|
|
|
static mca_pml_ob1_recv_frag_t* mca_pml_ob1_recv_request_match_specific_proc(
|
2005-05-24 02:06:50 +04:00
|
|
|
mca_pml_ob1_recv_request_t* request, mca_pml_ob1_comm_proc_t* proc);
|
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
void mca_pml_ob1_recv_request_process_pending(void)
|
|
|
|
{
|
|
|
|
mca_pml_ob1_recv_request_t* recvreq;
|
2006-11-08 20:02:46 +03:00
|
|
|
int i, s = (int)opal_list_get_size(&mca_pml_ob1.recv_pending);
|
2006-07-20 18:44:35 +04:00
|
|
|
|
|
|
|
for(i = 0; i < s; i++) {
|
|
|
|
OPAL_THREAD_LOCK(&mca_pml_ob1.lock);
|
|
|
|
recvreq = (mca_pml_ob1_recv_request_t*)
|
|
|
|
opal_list_remove_first(&mca_pml_ob1.recv_pending);
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_ob1.lock);
|
|
|
|
if(NULL == recvreq)
|
|
|
|
break;
|
|
|
|
recvreq->req_pending = false;
|
|
|
|
if(mca_pml_ob1_recv_request_schedule_exclusive(recvreq) ==
|
|
|
|
OMPI_ERR_OUT_OF_RESOURCE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2006-03-24 07:21:30 +03:00
|
|
|
static int mca_pml_ob1_recv_request_free(struct ompi_request_t** request)
|
2005-05-24 02:06:50 +04:00
|
|
|
{
|
2005-09-15 22:47:59 +04:00
|
|
|
mca_pml_ob1_recv_request_t* recvreq = *(mca_pml_ob1_recv_request_t**)request;
|
2006-03-16 01:53:41 +03:00
|
|
|
|
|
|
|
assert( false == recvreq->req_recv.req_base.req_free_called );
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
|
|
|
recvreq->req_recv.req_base.req_free_called = true;
|
2006-03-31 21:09:09 +04:00
|
|
|
|
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_NOTIFY,
|
|
|
|
&(recvreq->req_recv.req_base), PERUSE_RECV );
|
|
|
|
|
2006-09-29 03:54:38 +04:00
|
|
|
if( true == recvreq->req_recv.req_base.req_pml_complete ) {
|
|
|
|
MCA_PML_OB1_RECV_REQUEST_RETURN( recvreq );
|
|
|
|
}
|
|
|
|
|
2006-03-16 01:53:41 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2006-02-14 12:09:05 +03:00
|
|
|
*request = MPI_REQUEST_NULL;
|
2005-05-24 02:06:50 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mca_pml_ob1_recv_request_cancel(struct ompi_request_t* ompi_request, int complete)
|
|
|
|
{
|
|
|
|
mca_pml_ob1_recv_request_t* request = (mca_pml_ob1_recv_request_t*)ompi_request;
|
|
|
|
mca_pml_ob1_comm_t* comm = request->req_recv.req_base.req_comm->c_pml_comm;
|
|
|
|
|
|
|
|
if( true == ompi_request->req_complete ) { /* way to late to cancel this one */
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The rest should be protected behind the match logic lock */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&comm->matching_lock);
|
2005-05-24 02:06:50 +04:00
|
|
|
if( OMPI_ANY_TAG == ompi_request->req_status.MPI_TAG ) { /* the match has not been already done */
|
|
|
|
if( request->req_recv.req_base.req_peer == OMPI_ANY_SOURCE ) {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item( &comm->wild_receives, (opal_list_item_t*)request );
|
2005-05-24 02:06:50 +04:00
|
|
|
} else {
|
|
|
|
mca_pml_ob1_comm_proc_t* proc = comm->procs + request->req_recv.req_base.req_peer;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(&proc->specific_receives, (opal_list_item_t*)request);
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
2006-03-31 21:09:09 +04:00
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_REMOVE_FROM_POSTED_Q,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
2006-09-19 22:04:09 +04:00
|
|
|
/**
|
|
|
|
* As now the PML is done with this request we have to force the lmp_complete
|
|
|
|
* to true. Otherwise, the request will never be freed.
|
|
|
|
*/
|
|
|
|
request->req_recv.req_base.req_pml_complete = true;
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&comm->matching_lock);
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
2005-05-24 02:06:50 +04:00
|
|
|
ompi_request->req_status._cancelled = true;
|
2006-01-26 02:17:17 +03:00
|
|
|
/* This macro will set the req_complete to true so the MPI Test/Wait* functions
|
|
|
|
* on this request will be able to complete. As the status is marked as
|
|
|
|
* cancelled the cancel state will be detected.
|
2005-05-24 02:06:50 +04:00
|
|
|
*/
|
2006-03-31 21:09:09 +04:00
|
|
|
MCA_PML_OB1_RECV_REQUEST_MPI_COMPLETE(request);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
2005-05-24 02:06:50 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mca_pml_ob1_recv_request_construct(mca_pml_ob1_recv_request_t* request)
|
|
|
|
{
|
|
|
|
request->req_recv.req_base.req_type = MCA_PML_REQUEST_RECV;
|
|
|
|
request->req_recv.req_base.req_ompi.req_free = mca_pml_ob1_recv_request_free;
|
|
|
|
request->req_recv.req_base.req_ompi.req_cancel = mca_pml_ob1_recv_request_cancel;
|
2006-03-16 01:53:41 +03:00
|
|
|
request->req_rdma_cnt = 0;
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
|
|
|
mca_pml_ob1_recv_request_t,
|
|
|
|
mca_pml_base_recv_request_t,
|
|
|
|
mca_pml_ob1_recv_request_construct,
|
2006-09-29 03:57:49 +04:00
|
|
|
NULL);
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2005-06-01 18:34:22 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Release resources.
|
|
|
|
*/
|
|
|
|
|
2006-12-02 01:26:14 +03:00
|
|
|
static void mca_pml_ob1_recv_ctl_completion( mca_btl_base_module_t* btl,
|
|
|
|
struct mca_btl_base_endpoint_t* ep,
|
|
|
|
struct mca_btl_base_descriptor_t* des,
|
|
|
|
int status )
|
2005-06-01 18:34:22 +04:00
|
|
|
{
|
2005-08-12 06:41:14 +04:00
|
|
|
mca_bml_base_btl_t* bml_btl = (mca_bml_base_btl_t*)des->des_context;
|
|
|
|
MCA_BML_BASE_BTL_DES_RETURN(bml_btl, des);
|
2006-07-20 18:44:35 +04:00
|
|
|
|
|
|
|
MCA_PML_OB1_PROGRESS_PENDING(bml_btl);
|
2005-06-01 18:34:22 +04:00
|
|
|
}
|
|
|
|
|
2005-08-17 22:23:38 +04:00
|
|
|
/*
|
|
|
|
* Put operation has completed remotely - update request status
|
|
|
|
*/
|
|
|
|
|
2006-12-02 01:26:14 +03:00
|
|
|
static void mca_pml_ob1_put_completion( mca_btl_base_module_t* btl,
|
|
|
|
struct mca_btl_base_endpoint_t* ep,
|
|
|
|
struct mca_btl_base_descriptor_t* des,
|
|
|
|
int status )
|
2005-08-17 22:23:38 +04:00
|
|
|
{
|
|
|
|
mca_bml_base_btl_t* bml_btl = (mca_bml_base_btl_t*)des->des_context;
|
|
|
|
mca_pml_ob1_recv_request_t* recvreq = (mca_pml_ob1_recv_request_t*)des->des_cbdata;
|
2006-02-08 10:20:48 +03:00
|
|
|
size_t bytes_received = 0;
|
2005-08-24 03:05:01 +04:00
|
|
|
|
2006-02-08 09:03:54 +03:00
|
|
|
MCA_PML_OB1_COMPUTE_SEGMENT_LENGTH( des->des_dst, des->des_dst_cnt,
|
|
|
|
0, bytes_received );
|
2005-08-18 21:06:35 +04:00
|
|
|
OPAL_THREAD_ADD_SIZE_T(&recvreq->req_pipeline_depth,-1);
|
|
|
|
mca_bml_base_free(bml_btl, des);
|
2005-08-24 03:05:01 +04:00
|
|
|
|
|
|
|
/* check completion status */
|
2006-02-08 09:03:54 +03:00
|
|
|
if( OPAL_THREAD_ADD_SIZE_T(&recvreq->req_bytes_received, bytes_received)
|
|
|
|
>= recvreq->req_recv.req_bytes_packed ) {
|
2006-03-16 01:53:41 +03:00
|
|
|
MCA_PML_OB1_RECV_REQUEST_PML_COMPLETE( recvreq );
|
2005-08-24 03:05:01 +04:00
|
|
|
} else if (recvreq->req_rdma_offset < recvreq->req_recv.req_bytes_packed) {
|
2006-01-22 00:02:35 +03:00
|
|
|
/* schedule additional rdma operations */
|
2005-08-24 03:05:01 +04:00
|
|
|
mca_pml_ob1_recv_request_schedule(recvreq);
|
|
|
|
}
|
2006-07-20 18:44:35 +04:00
|
|
|
MCA_PML_OB1_PROGRESS_PENDING(bml_btl);
|
2005-08-17 22:23:38 +04:00
|
|
|
}
|
2005-06-01 18:34:22 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
int mca_pml_ob1_recv_request_ack_send_btl(
|
|
|
|
ompi_proc_t* proc, mca_bml_base_btl_t* bml_btl,
|
2006-12-04 23:11:42 +03:00
|
|
|
uint64_t hdr_src_req, void *hdr_dst_req, uint64_t hdr_rdma_offset)
|
2006-07-20 18:44:35 +04:00
|
|
|
{
|
|
|
|
mca_btl_base_descriptor_t* des;
|
|
|
|
mca_pml_ob1_ack_hdr_t* ack;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* allocate descriptor */
|
|
|
|
MCA_PML_OB1_DES_ALLOC(bml_btl, des, sizeof(mca_pml_ob1_ack_hdr_t));
|
|
|
|
if(NULL == des) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill out header */
|
2007-01-05 01:07:37 +03:00
|
|
|
ack = (mca_pml_ob1_ack_hdr_t*)des->des_src->seg_addr.pval;
|
2006-07-20 18:44:35 +04:00
|
|
|
ack->hdr_common.hdr_type = MCA_PML_OB1_HDR_TYPE_ACK;
|
|
|
|
ack->hdr_common.hdr_flags = 0;
|
2007-01-05 01:07:37 +03:00
|
|
|
ack->hdr_src_req.lval = hdr_src_req;
|
|
|
|
ack->hdr_dst_req.pval = hdr_dst_req;
|
2006-07-20 18:44:35 +04:00
|
|
|
ack->hdr_rdma_offset = hdr_rdma_offset;
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
ack->hdr_common.hdr_flags |= MCA_PML_OB1_HDR_FLAGS_NBO;
|
|
|
|
#else
|
|
|
|
/* if we are little endian and the remote side is big endian,
|
|
|
|
we're responsible for making sure the data is in network byte
|
|
|
|
order */
|
|
|
|
if (proc->proc_arch & OMPI_ARCH_ISBIGENDIAN) {
|
|
|
|
ack->hdr_common.hdr_flags |= MCA_PML_OB1_HDR_FLAGS_NBO;
|
|
|
|
MCA_PML_OB1_ACK_HDR_HTON(*ack);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* initialize descriptor */
|
|
|
|
des->des_flags |= MCA_BTL_DES_FLAGS_PRIORITY;
|
|
|
|
des->des_cbfunc = mca_pml_ob1_recv_ctl_completion;
|
|
|
|
|
|
|
|
rc = mca_bml_base_send(bml_btl, des, MCA_BTL_TAG_PML);
|
|
|
|
if(rc != OMPI_SUCCESS) {
|
|
|
|
mca_bml_base_free(bml_btl, des);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mca_pml_ob1_recv_request_ack(
|
2005-06-01 18:34:22 +04:00
|
|
|
mca_pml_ob1_recv_request_t* recvreq,
|
2005-09-22 03:23:47 +04:00
|
|
|
mca_pml_ob1_rendezvous_hdr_t* hdr,
|
|
|
|
size_t bytes_received)
|
2005-06-01 18:34:22 +04:00
|
|
|
{
|
2006-02-05 09:13:07 +03:00
|
|
|
ompi_proc_t* proc = (ompi_proc_t*)recvreq->req_recv.req_base.req_proc;
|
2005-08-15 02:10:08 +04:00
|
|
|
mca_bml_base_endpoint_t* bml_endpoint = NULL;
|
2005-06-01 18:34:22 +04:00
|
|
|
|
2006-07-04 05:20:20 +04:00
|
|
|
bml_endpoint = (mca_bml_base_endpoint_t*) proc->proc_bml;
|
2006-07-20 18:44:35 +04:00
|
|
|
|
2007-01-03 15:37:11 +03:00
|
|
|
/* by default copy */
|
|
|
|
recvreq->req_rdma_offset = hdr->hdr_msg_length;
|
2005-09-22 03:23:47 +04:00
|
|
|
if(hdr->hdr_msg_length > bytes_received) {
|
2005-07-16 00:58:11 +04:00
|
|
|
|
2006-01-26 02:17:17 +03:00
|
|
|
|
2005-09-13 02:28:23 +04:00
|
|
|
/*
|
|
|
|
* lookup request buffer to determine if memory is already
|
|
|
|
* registered.
|
|
|
|
*/
|
|
|
|
|
2005-11-11 18:33:25 +03:00
|
|
|
if(ompi_convertor_need_buffers(&recvreq->req_recv.req_convertor) == 0 &&
|
|
|
|
hdr->hdr_match.hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_CONTIG) {
|
2007-03-31 02:02:45 +04:00
|
|
|
unsigned char *base;
|
|
|
|
ompi_convertor_get_current_pointer( &recvreq->req_recv.req_convertor, (void**)&(base) );
|
2007-03-30 06:06:08 +04:00
|
|
|
|
2007-03-31 02:02:45 +04:00
|
|
|
recvreq->req_rdma_cnt = mca_pml_ob1_rdma_btls( bml_endpoint,
|
|
|
|
base,
|
|
|
|
recvreq->req_recv.req_bytes_packed,
|
|
|
|
recvreq->req_rdma );
|
2005-09-13 02:28:23 +04:00
|
|
|
|
|
|
|
/* memory is already registered on both sides */
|
|
|
|
if (hdr->hdr_match.hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_PIN &&
|
|
|
|
recvreq->req_rdma_cnt != 0) {
|
|
|
|
|
2006-09-07 14:42:35 +04:00
|
|
|
recvreq->req_rdma_offset = bytes_received;
|
2006-02-09 18:49:51 +03:00
|
|
|
/* are rdma devices available for long rdma protocol */
|
2006-12-17 15:26:41 +03:00
|
|
|
} else if (bml_endpoint->btl_rdma_offset < hdr->hdr_msg_length &&
|
2006-02-09 18:49:51 +03:00
|
|
|
mca_bml_base_btl_array_get_size(&bml_endpoint->btl_rdma)) {
|
|
|
|
|
2005-07-16 00:58:11 +04:00
|
|
|
/* use convertor to figure out the rdma offset for this request */
|
2005-08-12 06:41:14 +04:00
|
|
|
recvreq->req_rdma_offset = bml_endpoint->btl_rdma_offset;
|
2006-09-07 14:42:35 +04:00
|
|
|
if(recvreq->req_rdma_offset < bytes_received) {
|
|
|
|
recvreq->req_rdma_offset = bytes_received;
|
2005-07-28 23:35:47 +04:00
|
|
|
}
|
2006-06-26 23:00:07 +04:00
|
|
|
ompi_convertor_set_position( &recvreq->req_recv.req_convertor,
|
|
|
|
&recvreq->req_rdma_offset );
|
2006-02-09 18:49:51 +03:00
|
|
|
}
|
2005-06-22 00:58:24 +04:00
|
|
|
}
|
2006-12-17 15:26:41 +03:00
|
|
|
/* start rdma at current fragment offset - no need to ack */
|
|
|
|
if(recvreq->req_rdma_offset == bytes_received)
|
|
|
|
return OMPI_SUCCESS;
|
2005-06-23 23:24:44 +04:00
|
|
|
}
|
Fix hang in receiving into MPI_alloced area.
This code hangs with openib BTL:
int size = 4000000;
sbuf = malloc(size);
MPI_Alloc_mem(size, MPI_INFO_NULL, &rbuf);
if (rank == 0)
{
MPI_Recv(rbuf, size, MPI_CHAR, 1, 1, MPI_COMM_WORLD, &stat);
}else{
MPI_Send(sbuf, size, MPI_CHAR, 0, 1, MPI_COMM_WORLD);
}
This commit was SVN r11613.
2006-09-11 16:18:59 +04:00
|
|
|
/* let know to shedule function there is no need to put ACK flag */
|
|
|
|
recvreq->req_ack_sent = true;
|
2007-01-05 01:07:37 +03:00
|
|
|
return mca_pml_ob1_recv_request_ack_send(proc, hdr->hdr_src_req.lval,
|
2006-07-20 18:44:35 +04:00
|
|
|
recvreq, recvreq->req_rdma_offset);
|
2005-06-01 18:34:22 +04:00
|
|
|
}
|
|
|
|
|
2005-08-17 22:23:38 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return resources used by the RDMA
|
|
|
|
*/
|
2006-03-16 01:53:41 +03:00
|
|
|
|
2005-08-17 22:23:38 +04:00
|
|
|
static void mca_pml_ob1_rget_completion(
|
|
|
|
mca_btl_base_module_t* btl,
|
|
|
|
struct mca_btl_base_endpoint_t* ep,
|
|
|
|
struct mca_btl_base_descriptor_t* des,
|
|
|
|
int status)
|
|
|
|
{
|
|
|
|
mca_bml_base_btl_t* bml_btl = (mca_bml_base_btl_t*)des->des_context;
|
|
|
|
mca_pml_ob1_rdma_frag_t* frag = (mca_pml_ob1_rdma_frag_t*)des->des_cbdata;
|
2006-08-24 20:38:08 +04:00
|
|
|
mca_pml_ob1_recv_request_t* recvreq = (mca_pml_ob1_recv_request_t*)frag->rdma_req;
|
2005-08-17 22:23:38 +04:00
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
/* check completion status */
|
|
|
|
if(OMPI_SUCCESS != status) {
|
|
|
|
/* TSW - FIX */
|
|
|
|
ORTE_ERROR_LOG(status);
|
2005-08-17 22:23:38 +04:00
|
|
|
orte_errmgr.abort();
|
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
mca_pml_ob1_send_fin(recvreq->req_recv.req_base.req_proc,
|
2007-01-05 01:07:37 +03:00
|
|
|
frag->rdma_hdr.hdr_rget.hdr_des.pval, bml_btl);
|
2006-02-26 03:45:54 +03:00
|
|
|
|
2006-03-16 01:53:41 +03:00
|
|
|
/* is receive request complete */
|
|
|
|
if( OPAL_THREAD_ADD_SIZE_T(&recvreq->req_bytes_received, frag->rdma_length)
|
|
|
|
== recvreq->req_recv.req_bytes_packed ) {
|
|
|
|
MCA_PML_OB1_RECV_REQUEST_PML_COMPLETE( recvreq );
|
|
|
|
}
|
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
MCA_PML_OB1_RDMA_FRAG_RETURN(frag);
|
|
|
|
|
|
|
|
/* return rdma descriptor - do this after queuing the fin message - as
|
|
|
|
* release rdma resources (unpin memory) can take some time.
|
|
|
|
*/
|
|
|
|
mca_bml_base_free(bml_btl, des);
|
|
|
|
|
|
|
|
MCA_PML_OB1_PROGRESS_PENDING(bml_btl);
|
2005-08-17 22:23:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
2006-07-20 18:44:35 +04:00
|
|
|
int mca_pml_ob1_recv_request_get_frag(
|
|
|
|
mca_pml_ob1_rdma_frag_t* frag)
|
2005-08-17 22:23:38 +04:00
|
|
|
{
|
2006-08-24 20:38:08 +04:00
|
|
|
mca_pml_ob1_recv_request_t* recvreq = (mca_pml_ob1_recv_request_t*)frag->rdma_req;
|
2006-07-20 18:44:35 +04:00
|
|
|
mca_bml_base_endpoint_t* bml_endpoint = frag->rdma_ep;
|
2005-08-17 22:23:38 +04:00
|
|
|
mca_bml_base_btl_t* bml_btl;
|
|
|
|
mca_btl_base_descriptor_t* descriptor;
|
2006-07-20 18:44:35 +04:00
|
|
|
size_t save_size = frag->rdma_length;
|
2005-08-17 22:23:38 +04:00
|
|
|
int rc;
|
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
bml_btl = mca_bml_base_btl_array_find(&bml_endpoint->btl_rdma,
|
|
|
|
frag->rdma_btl);
|
2005-08-17 22:23:38 +04:00
|
|
|
if(NULL == bml_btl) {
|
|
|
|
opal_output(0, "[%s:%d] invalid bml for rdma get", __FILE__, __LINE__);
|
|
|
|
orte_errmgr.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* prepare descriptor */
|
|
|
|
mca_bml_base_prepare_dst(
|
|
|
|
bml_btl,
|
2006-12-17 15:26:41 +03:00
|
|
|
NULL,
|
2005-08-17 22:23:38 +04:00
|
|
|
&recvreq->req_recv.req_convertor,
|
|
|
|
0,
|
2006-07-20 18:44:35 +04:00
|
|
|
&frag->rdma_length,
|
2005-08-17 22:23:38 +04:00
|
|
|
&descriptor);
|
|
|
|
if(NULL == descriptor) {
|
2006-07-20 18:44:35 +04:00
|
|
|
frag->rdma_length = save_size;
|
|
|
|
OPAL_THREAD_LOCK(&mca_pml_ob1.lock);
|
|
|
|
opal_list_append(&mca_pml_ob1.rdma_pending, (opal_list_item_t*)frag);
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_ob1.lock);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2005-08-17 22:23:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
descriptor->des_src = frag->rdma_segs;
|
2006-07-20 18:44:35 +04:00
|
|
|
descriptor->des_src_cnt = frag->rdma_hdr.hdr_rdma.hdr_seg_cnt;
|
2005-08-17 22:23:38 +04:00
|
|
|
descriptor->des_cbfunc = mca_pml_ob1_rget_completion;
|
2006-07-20 18:44:35 +04:00
|
|
|
descriptor->des_cbdata = frag;
|
2005-08-17 22:23:38 +04:00
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
PERUSE_TRACE_COMM_OMPI_EVENT(PERUSE_COMM_REQ_XFER_CONTINUE,
|
|
|
|
&(recvreq->req_recv.req_base),
|
|
|
|
frag->rdma_length, PERUSE_RECV);
|
2006-06-26 23:00:07 +04:00
|
|
|
|
2005-08-17 22:23:38 +04:00
|
|
|
/* queue up get request */
|
2006-07-20 18:44:35 +04:00
|
|
|
if(OMPI_SUCCESS != (rc = mca_bml_base_get(bml_btl,descriptor))) {
|
|
|
|
if(OMPI_ERR_OUT_OF_RESOURCE == rc) {
|
|
|
|
mca_bml_base_free(bml_btl, descriptor);
|
|
|
|
OPAL_THREAD_LOCK(&mca_pml_ob1.lock);
|
|
|
|
opal_list_append(&mca_pml_ob1.rdma_pending,
|
|
|
|
(opal_list_item_t*)frag);
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_ob1.lock);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
} else {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
orte_errmgr.abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mca_pml_ob1_recv_request_rget(
|
|
|
|
mca_pml_ob1_recv_request_t* recvreq,
|
|
|
|
mca_btl_base_module_t* btl,
|
|
|
|
mca_pml_ob1_rget_hdr_t* hdr)
|
|
|
|
{
|
|
|
|
mca_bml_base_endpoint_t* bml_endpoint = NULL;
|
|
|
|
mca_pml_ob1_rdma_frag_t* frag;
|
|
|
|
size_t i, size = 0;
|
|
|
|
int rc;
|
2007-04-12 02:03:06 +04:00
|
|
|
|
|
|
|
/* if receive buffer is not contiguous we can't just RDMA read into it, so
|
|
|
|
* fall back to copy in/out protocol. It is a pity because buffer on the
|
|
|
|
* sender side is already registered. We need to ne smarter here, perhaps
|
|
|
|
* do couple of RDMA reads */
|
|
|
|
if(ompi_convertor_need_buffers(&recvreq->req_recv.req_convertor) == true) {
|
|
|
|
mca_pml_ob1_recv_request_ack(recvreq, &hdr->hdr_rndv, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
MCA_PML_OB1_RDMA_FRAG_ALLOC(frag,rc);
|
|
|
|
if(NULL == frag) {
|
|
|
|
/* GLB - FIX */
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
orte_errmgr.abort();
|
2005-08-17 22:23:38 +04:00
|
|
|
}
|
2006-07-20 18:44:35 +04:00
|
|
|
|
|
|
|
/* lookup bml datastructures */
|
|
|
|
bml_endpoint = (mca_bml_base_endpoint_t*)recvreq->req_recv.req_base.req_proc->proc_bml;
|
|
|
|
|
|
|
|
/* allocate/initialize a fragment */
|
|
|
|
for(i = 0; i < hdr->hdr_seg_cnt; i++) {
|
|
|
|
size += hdr->hdr_segs[i].seg_len;
|
|
|
|
frag->rdma_segs[i] = hdr->hdr_segs[i];
|
|
|
|
}
|
|
|
|
frag->rdma_hdr.hdr_rget = *hdr;
|
|
|
|
frag->rdma_req = recvreq;
|
|
|
|
frag->rdma_ep = bml_endpoint;
|
|
|
|
frag->rdma_btl = btl;
|
|
|
|
frag->rdma_length = size;
|
|
|
|
frag->rdma_state = MCA_PML_OB1_RDMA_GET;
|
|
|
|
|
|
|
|
mca_pml_ob1_recv_request_get_frag(frag);
|
2005-08-17 22:23:38 +04:00
|
|
|
}
|
|
|
|
|
2005-06-01 18:34:22 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/*
|
|
|
|
* Update the recv request status to reflect the number of bytes
|
|
|
|
* received and actually delivered to the application.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_pml_ob1_recv_request_progress(
|
2005-06-01 18:34:22 +04:00
|
|
|
mca_pml_ob1_recv_request_t* recvreq,
|
2005-08-17 22:23:38 +04:00
|
|
|
mca_btl_base_module_t* btl,
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_base_segment_t* segments,
|
2005-05-24 02:06:50 +04:00
|
|
|
size_t num_segments)
|
|
|
|
{
|
2005-06-08 23:10:15 +04:00
|
|
|
size_t bytes_received = 0;
|
|
|
|
size_t bytes_delivered = 0;
|
2005-06-09 00:37:19 +04:00
|
|
|
size_t data_offset = 0;
|
2007-01-05 01:07:37 +03:00
|
|
|
mca_pml_ob1_hdr_t* hdr = (mca_pml_ob1_hdr_t*)segments->seg_addr.pval;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2006-02-08 09:03:54 +03:00
|
|
|
MCA_PML_OB1_COMPUTE_SEGMENT_LENGTH( segments, num_segments,
|
|
|
|
0, bytes_received );
|
2005-05-24 02:06:50 +04:00
|
|
|
switch(hdr->hdr_common.hdr_type) {
|
2005-05-24 02:22:20 +04:00
|
|
|
case MCA_PML_OB1_HDR_TYPE_MATCH:
|
2005-06-01 18:34:22 +04:00
|
|
|
|
2005-08-17 22:23:38 +04:00
|
|
|
bytes_received -= sizeof(mca_pml_ob1_match_hdr_t);
|
|
|
|
recvreq->req_recv.req_bytes_packed = bytes_received;
|
|
|
|
MCA_PML_OB1_RECV_REQUEST_MATCHED(recvreq,&hdr->hdr_match);
|
2005-06-01 18:34:22 +04:00
|
|
|
MCA_PML_OB1_RECV_REQUEST_UNPACK(
|
|
|
|
recvreq,
|
|
|
|
segments,
|
|
|
|
num_segments,
|
|
|
|
sizeof(mca_pml_ob1_match_hdr_t),
|
2005-06-09 00:37:19 +04:00
|
|
|
data_offset,
|
2005-06-01 18:34:22 +04:00
|
|
|
bytes_received,
|
|
|
|
bytes_delivered);
|
2005-05-24 02:06:50 +04:00
|
|
|
break;
|
2005-06-01 18:34:22 +04:00
|
|
|
|
2005-05-24 02:22:20 +04:00
|
|
|
case MCA_PML_OB1_HDR_TYPE_RNDV:
|
2005-06-01 18:34:22 +04:00
|
|
|
|
2005-08-17 22:23:38 +04:00
|
|
|
bytes_received -= sizeof(mca_pml_ob1_rendezvous_hdr_t);
|
|
|
|
recvreq->req_recv.req_bytes_packed = hdr->hdr_rndv.hdr_msg_length;
|
2005-06-09 07:11:51 +04:00
|
|
|
recvreq->req_send = hdr->hdr_rndv.hdr_src_req;
|
2005-08-17 22:23:38 +04:00
|
|
|
MCA_PML_OB1_RECV_REQUEST_MATCHED(recvreq,&hdr->hdr_match);
|
2005-09-22 03:23:47 +04:00
|
|
|
mca_pml_ob1_recv_request_ack(recvreq, &hdr->hdr_rndv, bytes_received);
|
2007-04-12 02:03:06 +04:00
|
|
|
if(recvreq->req_recv.req_base.req_pml_complete) {
|
|
|
|
/* We must check that completion hasn't already occured */
|
|
|
|
/* for the self BTL we may choose the RDMA PUT protocol */
|
|
|
|
/* on the send side, in this case we send no eager data */
|
|
|
|
/* if, on the receiver side the data is not contiguous we */
|
|
|
|
/* may choose to use the copy in/out protocol */
|
|
|
|
/* if this occurs, the entire request can be completed in a */
|
|
|
|
/* single call to mca_pml_ob1_recv_request_ack */
|
|
|
|
/* as soon as the last fragment of the copy in/out protocol */
|
|
|
|
/* gets local completion. This doesn't occur in the general */
|
|
|
|
/* case of the copy in/out protocol because when both sender */
|
|
|
|
/* and receiver agree on the copy in/out protoocol we eagerly */
|
|
|
|
/* send data, we don't update the request with this eagerly sent */
|
|
|
|
/* data until the end of this function, so completion could not have */
|
|
|
|
/* yet occurred. */
|
|
|
|
return;
|
|
|
|
}
|
2006-06-20 18:16:52 +04:00
|
|
|
/**
|
|
|
|
* The PUT protocol do not attach any data to the original request.
|
|
|
|
* Therefore, we might want to avoid unpacking if there is nothing to
|
|
|
|
* unpack.
|
|
|
|
*/
|
|
|
|
if( 0 < bytes_received ) {
|
|
|
|
MCA_PML_OB1_RECV_REQUEST_UNPACK(
|
|
|
|
recvreq,
|
|
|
|
segments,
|
|
|
|
num_segments,
|
|
|
|
sizeof(mca_pml_ob1_rendezvous_hdr_t),
|
|
|
|
data_offset,
|
|
|
|
bytes_received,
|
|
|
|
bytes_delivered);
|
|
|
|
}
|
2005-06-01 18:34:22 +04:00
|
|
|
break;
|
|
|
|
|
2005-08-17 22:23:38 +04:00
|
|
|
case MCA_PML_OB1_HDR_TYPE_RGET:
|
|
|
|
|
|
|
|
recvreq->req_recv.req_bytes_packed = hdr->hdr_rndv.hdr_msg_length;
|
|
|
|
MCA_PML_OB1_RECV_REQUEST_MATCHED(recvreq,&hdr->hdr_match);
|
|
|
|
mca_pml_ob1_recv_request_rget(recvreq, btl, &hdr->hdr_rget);
|
|
|
|
return;
|
|
|
|
|
2005-06-01 18:34:22 +04:00
|
|
|
case MCA_PML_OB1_HDR_TYPE_FRAG:
|
|
|
|
|
2005-08-17 22:23:38 +04:00
|
|
|
bytes_received -= sizeof(mca_pml_ob1_frag_hdr_t);
|
2005-06-10 00:16:33 +04:00
|
|
|
data_offset = hdr->hdr_frag.hdr_frag_offset;
|
2005-06-01 18:34:22 +04:00
|
|
|
MCA_PML_OB1_RECV_REQUEST_UNPACK(
|
|
|
|
recvreq,
|
|
|
|
segments,
|
|
|
|
num_segments,
|
2005-06-07 02:08:02 +04:00
|
|
|
sizeof(mca_pml_ob1_frag_hdr_t),
|
2005-06-10 00:16:33 +04:00
|
|
|
data_offset,
|
2005-06-01 18:34:22 +04:00
|
|
|
bytes_received,
|
|
|
|
bytes_delivered);
|
2005-05-24 02:06:50 +04:00
|
|
|
break;
|
2005-06-01 18:34:22 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-06-01 18:34:22 +04:00
|
|
|
/* check completion status */
|
2006-02-08 09:03:54 +03:00
|
|
|
if( OPAL_THREAD_ADD_SIZE_T(&recvreq->req_bytes_received, bytes_received)
|
|
|
|
>= recvreq->req_recv.req_bytes_packed ) {
|
2006-03-16 01:53:41 +03:00
|
|
|
MCA_PML_OB1_RECV_REQUEST_PML_COMPLETE( recvreq );
|
2005-06-10 00:16:33 +04:00
|
|
|
} else if (recvreq->req_rdma_offset < recvreq->req_recv.req_bytes_packed) {
|
2006-01-22 00:02:35 +03:00
|
|
|
/* schedule additional rdma operations */
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_request_schedule(recvreq);
|
|
|
|
}
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-13 20:45:41 +04:00
|
|
|
/**
|
|
|
|
* Handle completion of a probe request
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_pml_ob1_recv_request_matched_probe(
|
|
|
|
mca_pml_ob1_recv_request_t* recvreq,
|
|
|
|
mca_btl_base_module_t* btl,
|
|
|
|
mca_btl_base_segment_t* segments,
|
|
|
|
size_t num_segments)
|
|
|
|
{
|
|
|
|
size_t bytes_packed = 0;
|
2007-01-05 01:07:37 +03:00
|
|
|
mca_pml_ob1_hdr_t* hdr = (mca_pml_ob1_hdr_t*)segments->seg_addr.pval;
|
2005-09-13 20:45:41 +04:00
|
|
|
|
|
|
|
switch(hdr->hdr_common.hdr_type) {
|
|
|
|
case MCA_PML_OB1_HDR_TYPE_MATCH:
|
|
|
|
|
2006-02-08 09:03:54 +03:00
|
|
|
MCA_PML_OB1_COMPUTE_SEGMENT_LENGTH( segments, num_segments,
|
|
|
|
sizeof(mca_pml_ob1_match_hdr_t),
|
|
|
|
bytes_packed );
|
2005-09-13 20:45:41 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_PML_OB1_HDR_TYPE_RNDV:
|
|
|
|
case MCA_PML_OB1_HDR_TYPE_RGET:
|
|
|
|
|
|
|
|
bytes_packed = hdr->hdr_rndv.hdr_msg_length;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-11-30 20:57:59 +03:00
|
|
|
/* set completion status */
|
2005-09-13 20:45:41 +04:00
|
|
|
recvreq->req_recv.req_base.req_ompi.req_status.MPI_TAG = hdr->hdr_match.hdr_tag;
|
|
|
|
recvreq->req_recv.req_base.req_ompi.req_status.MPI_SOURCE = hdr->hdr_match.hdr_src;
|
2006-03-16 01:53:41 +03:00
|
|
|
recvreq->req_bytes_received = bytes_packed;
|
|
|
|
recvreq->req_bytes_delivered = bytes_packed;
|
|
|
|
MCA_PML_OB1_RECV_REQUEST_PML_COMPLETE( recvreq );
|
2005-09-13 20:45:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-09 07:11:51 +04:00
|
|
|
/*
|
|
|
|
* Schedule RDMA protocol.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-12-02 01:26:14 +03:00
|
|
|
int mca_pml_ob1_recv_request_schedule_exclusive( mca_pml_ob1_recv_request_t* recvreq )
|
2005-06-09 07:11:51 +04:00
|
|
|
{
|
2006-07-20 18:44:35 +04:00
|
|
|
ompi_proc_t* proc = recvreq->req_recv.req_base.req_proc;
|
2006-12-02 01:26:14 +03:00
|
|
|
mca_bml_base_endpoint_t* bml_endpoint = (mca_bml_base_endpoint_t*) proc->proc_bml;
|
2006-07-20 18:44:35 +04:00
|
|
|
mca_bml_base_btl_t* bml_btl;
|
|
|
|
int num_btl_avail =
|
|
|
|
mca_bml_base_btl_array_get_size(&bml_endpoint->btl_rdma);
|
|
|
|
int num_tries = num_btl_avail;
|
|
|
|
|
|
|
|
if(recvreq->req_rdma_cnt)
|
|
|
|
num_tries = recvreq->req_rdma_cnt;
|
|
|
|
|
|
|
|
do {
|
|
|
|
size_t bytes_remaining = recvreq->req_recv.req_bytes_packed -
|
|
|
|
recvreq->req_rdma_offset;
|
|
|
|
size_t prev_bytes_remaining = 0;
|
|
|
|
int num_fail = 0;
|
|
|
|
|
2006-12-02 01:26:14 +03:00
|
|
|
while( bytes_remaining > 0 &&
|
|
|
|
recvreq->req_pipeline_depth < mca_pml_ob1.recv_pipeline_depth ) {
|
2006-07-20 18:44:35 +04:00
|
|
|
size_t hdr_size;
|
2007-01-07 04:48:57 +03:00
|
|
|
size_t size, i;
|
2006-07-20 18:44:35 +04:00
|
|
|
mca_pml_ob1_rdma_hdr_t* hdr;
|
|
|
|
mca_btl_base_descriptor_t* dst;
|
|
|
|
mca_btl_base_descriptor_t* ctl;
|
|
|
|
mca_mpool_base_registration_t * reg = NULL;
|
|
|
|
int rc;
|
|
|
|
|
2006-10-17 08:38:38 +04:00
|
|
|
if(prev_bytes_remaining == bytes_remaining) {
|
|
|
|
if( ++num_fail == num_tries ) {
|
|
|
|
OPAL_THREAD_LOCK(&mca_pml_ob1.lock);
|
|
|
|
if(false == recvreq->req_pending) {
|
|
|
|
opal_list_append(&mca_pml_ob1.recv_pending,
|
|
|
|
(opal_list_item_t*)recvreq);
|
|
|
|
recvreq->req_pending = true;
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_pml_ob1.lock);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2005-07-01 21:00:59 +04:00
|
|
|
}
|
2006-10-17 08:38:38 +04:00
|
|
|
} else {
|
|
|
|
num_fail = 0;
|
|
|
|
prev_bytes_remaining = bytes_remaining;
|
2006-07-20 18:44:35 +04:00
|
|
|
}
|
2006-10-17 08:38:38 +04:00
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
ompi_convertor_set_position(&recvreq->req_recv.req_convertor,
|
2006-10-17 08:38:38 +04:00
|
|
|
&recvreq->req_rdma_offset);
|
2006-07-20 18:44:35 +04:00
|
|
|
|
|
|
|
if(recvreq->req_rdma_cnt) {
|
|
|
|
/*
|
|
|
|
* Select the next btl out of the list w/ preregistered
|
|
|
|
* memory.
|
|
|
|
*/
|
|
|
|
bml_btl = recvreq->req_rdma[recvreq->req_rdma_idx].bml_btl;
|
|
|
|
num_btl_avail = recvreq->req_rdma_cnt - recvreq->req_rdma_idx;
|
|
|
|
reg = recvreq->req_rdma[recvreq->req_rdma_idx].btl_reg;
|
|
|
|
|
|
|
|
if(++recvreq->req_rdma_idx >= recvreq->req_rdma_cnt)
|
|
|
|
recvreq->req_rdma_idx = 0;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Otherwise, schedule round-robin across the
|
|
|
|
* available RDMA nics dynamically registering/deregister
|
|
|
|
* as required.
|
|
|
|
*/
|
|
|
|
bml_btl =
|
|
|
|
mca_bml_base_btl_array_get_next(&bml_endpoint->btl_rdma);
|
|
|
|
}
|
2005-07-01 21:00:59 +04:00
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
/*
|
|
|
|
* If more than one NIC is available - try to use both for
|
|
|
|
* anything larger than the eager limit
|
|
|
|
*/
|
2006-12-02 01:26:14 +03:00
|
|
|
if( num_btl_avail == 1 ||
|
|
|
|
bytes_remaining < bml_btl->btl_eager_limit ) {
|
2006-07-20 18:44:35 +04:00
|
|
|
size = bytes_remaining;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* otherwise attempt to give the BTL a percentage of
|
|
|
|
* the message based on a weighting factor. for
|
|
|
|
* simplicity calculate this as a percentage of the
|
|
|
|
* overall message length (regardless of amount
|
|
|
|
* previously assigned)
|
|
|
|
*/
|
|
|
|
size = (size_t)(bml_btl->btl_weight * bytes_remaining);
|
|
|
|
}
|
2006-11-06 15:00:17 +03:00
|
|
|
/* makes sure that we don't exceed BTL max rdma size
|
|
|
|
* if memory is not pinned already */
|
2006-12-03 11:29:55 +03:00
|
|
|
if(0 == recvreq->req_rdma_cnt &&
|
|
|
|
bml_btl->btl_max_rdma_size != 0 &&
|
|
|
|
size > bml_btl->btl_max_rdma_size) {
|
2006-07-20 18:44:35 +04:00
|
|
|
size = bml_btl->btl_max_rdma_size;
|
|
|
|
}
|
2005-06-09 07:11:51 +04:00
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
/* prepare a descriptor for RDMA */
|
|
|
|
mca_bml_base_prepare_dst(bml_btl, reg,
|
|
|
|
&recvreq->req_recv.req_convertor, 0, &size, &dst);
|
|
|
|
if(dst == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->des_cbfunc = mca_pml_ob1_put_completion;
|
|
|
|
dst->des_cbdata = recvreq;
|
|
|
|
|
|
|
|
/* prepare a descriptor for rdma control message */
|
|
|
|
hdr_size = sizeof(mca_pml_ob1_rdma_hdr_t);
|
|
|
|
if(dst->des_dst_cnt > 1) {
|
|
|
|
hdr_size += (sizeof(mca_btl_base_segment_t) *
|
|
|
|
(dst->des_dst_cnt-1));
|
|
|
|
}
|
|
|
|
|
|
|
|
MCA_PML_OB1_DES_ALLOC(bml_btl, ctl, hdr_size);
|
|
|
|
if(ctl == NULL) {
|
|
|
|
mca_bml_base_free(bml_btl,dst);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ctl->des_flags |= MCA_BTL_DES_FLAGS_PRIORITY;
|
|
|
|
ctl->des_cbfunc = mca_pml_ob1_recv_ctl_completion;
|
|
|
|
|
|
|
|
/* fill in rdma header */
|
2007-01-05 01:07:37 +03:00
|
|
|
hdr = (mca_pml_ob1_rdma_hdr_t*)ctl->des_src->seg_addr.pval;
|
2006-07-20 18:44:35 +04:00
|
|
|
hdr->hdr_common.hdr_type = MCA_PML_OB1_HDR_TYPE_PUT;
|
Fix hang in receiving into MPI_alloced area.
This code hangs with openib BTL:
int size = 4000000;
sbuf = malloc(size);
MPI_Alloc_mem(size, MPI_INFO_NULL, &rbuf);
if (rank == 0)
{
MPI_Recv(rbuf, size, MPI_CHAR, 1, 1, MPI_COMM_WORLD, &stat);
}else{
MPI_Send(sbuf, size, MPI_CHAR, 0, 1, MPI_COMM_WORLD);
}
This commit was SVN r11613.
2006-09-11 16:18:59 +04:00
|
|
|
hdr->hdr_common.hdr_flags =
|
|
|
|
(!recvreq->req_ack_sent) ? MCA_PML_OB1_HDR_TYPE_ACK : 0;
|
2006-07-20 18:44:35 +04:00
|
|
|
hdr->hdr_req = recvreq->req_send;
|
2007-01-05 01:07:37 +03:00
|
|
|
hdr->hdr_des.pval = dst;
|
2006-07-20 18:44:35 +04:00
|
|
|
hdr->hdr_rdma_offset = recvreq->req_rdma_offset;
|
|
|
|
hdr->hdr_seg_cnt = dst->des_dst_cnt;
|
2007-01-07 04:48:57 +03:00
|
|
|
|
|
|
|
for( i = 0; i < dst->des_dst_cnt; i++ ) {
|
|
|
|
hdr->hdr_segs[i].seg_addr.lval = ompi_ptr_ptol(dst->des_dst[i].seg_addr.pval);
|
|
|
|
hdr->hdr_segs[i].seg_len = dst->des_dst[i].seg_len;
|
|
|
|
hdr->hdr_segs[i].seg_key.key64 = dst->des_dst[i].seg_key.key64;
|
|
|
|
}
|
|
|
|
|
Fix hang in receiving into MPI_alloced area.
This code hangs with openib BTL:
int size = 4000000;
sbuf = malloc(size);
MPI_Alloc_mem(size, MPI_INFO_NULL, &rbuf);
if (rank == 0)
{
MPI_Recv(rbuf, size, MPI_CHAR, 1, 1, MPI_COMM_WORLD, &stat);
}else{
MPI_Send(sbuf, size, MPI_CHAR, 0, 1, MPI_COMM_WORLD);
}
This commit was SVN r11613.
2006-09-11 16:18:59 +04:00
|
|
|
if(!recvreq->req_ack_sent)
|
|
|
|
recvreq->req_ack_sent = true;
|
2006-02-28 22:54:46 +03:00
|
|
|
#if OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
2006-02-26 03:45:54 +03:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
2006-07-20 18:44:35 +04:00
|
|
|
hdr->hdr_common.hdr_flags |= MCA_PML_OB1_HDR_FLAGS_NBO;
|
2006-02-28 22:54:46 +03:00
|
|
|
#else
|
2006-07-20 18:44:35 +04:00
|
|
|
/* if we are little endian and the remote side is big endian,
|
|
|
|
we're responsible for making sure the data is in network byte
|
|
|
|
order */
|
|
|
|
/* 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 == (recvreq->req_recv.req_base.req_proc->proc_arch &
|
|
|
|
OMPI_ARCH_ISBIGENDIAN));
|
2006-02-28 22:54:46 +03:00
|
|
|
#endif
|
2006-02-26 03:45:54 +03:00
|
|
|
#endif
|
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
PERUSE_TRACE_COMM_OMPI_EVENT( PERUSE_COMM_REQ_XFER_CONTINUE,
|
|
|
|
&(recvreq->req_recv.req_base), size,
|
|
|
|
PERUSE_RECV);
|
|
|
|
|
|
|
|
/* send rdma request to peer */
|
|
|
|
rc = mca_bml_base_send(bml_btl, ctl, MCA_BTL_TAG_PML);
|
|
|
|
if(rc == OMPI_SUCCESS) {
|
2005-06-09 07:11:51 +04:00
|
|
|
/* update request state */
|
|
|
|
recvreq->req_rdma_offset += size;
|
2005-08-02 21:36:01 +04:00
|
|
|
OPAL_THREAD_ADD_SIZE_T(&recvreq->req_pipeline_depth,1);
|
2006-07-20 18:44:35 +04:00
|
|
|
bytes_remaining -= size;
|
|
|
|
} else {
|
|
|
|
mca_bml_base_free(bml_btl,ctl);
|
|
|
|
mca_bml_base_free(bml_btl,dst);
|
|
|
|
continue;
|
|
|
|
}
|
2005-06-09 07:11:51 +04:00
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
/* run progress as the prepare (pinning) can take some time */
|
2006-08-20 19:54:04 +04:00
|
|
|
mca_bml.bml_progress();
|
2006-07-20 18:44:35 +04:00
|
|
|
}
|
|
|
|
} while(OPAL_THREAD_ADD32(&recvreq->req_lock,-1) > 0);
|
2005-06-15 19:25:19 +04:00
|
|
|
|
2006-07-20 18:44:35 +04:00
|
|
|
return OMPI_SUCCESS;
|
2005-06-09 07:11:51 +04:00
|
|
|
}
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/*
|
|
|
|
* This routine is used to match a posted receive when the source process
|
|
|
|
* is specified.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_pml_ob1_recv_request_match_specific(mca_pml_ob1_recv_request_t* request)
|
|
|
|
{
|
|
|
|
mca_pml_ob1_comm_t* comm = request->req_recv.req_base.req_comm->c_pml_comm;
|
|
|
|
mca_pml_ob1_comm_proc_t* proc = comm->procs + request->req_recv.req_base.req_peer;
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_frag_t* frag;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/* check for a specific match */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&comm->matching_lock);
|
2006-03-31 21:09:09 +04:00
|
|
|
/**
|
|
|
|
* The laps of time between the ACTIVATE event and the SEARCH_UNEX one include
|
|
|
|
* the cost of the request lock.
|
|
|
|
*/
|
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_SEARCH_UNEX_Q_BEGIN,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/* assign sequence number */
|
|
|
|
request->req_recv.req_base.req_sequence = comm->recv_sequence++;
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
if (opal_list_get_size(&proc->unexpected_frags) > 0 &&
|
2005-05-24 02:06:50 +04:00
|
|
|
(frag = mca_pml_ob1_recv_request_match_specific_proc(request, proc)) != NULL) {
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&comm->matching_lock);
|
2006-03-31 21:09:09 +04:00
|
|
|
|
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_SEARCH_UNEX_Q_END,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
if( !((MCA_PML_REQUEST_IPROBE == request->req_recv.req_base.req_type) ||
|
|
|
|
(MCA_PML_REQUEST_PROBE == request->req_recv.req_base.req_type)) ) {
|
2005-09-13 20:45:41 +04:00
|
|
|
mca_pml_ob1_recv_request_progress(request,frag->btl,frag->segments,frag->num_segments);
|
2005-06-10 00:16:33 +04:00
|
|
|
MCA_PML_OB1_RECV_FRAG_RETURN(frag);
|
2005-09-13 20:45:41 +04:00
|
|
|
} else {
|
|
|
|
mca_pml_ob1_recv_request_matched_probe(request,frag->btl,frag->segments,frag->num_segments);
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
return; /* match found */
|
|
|
|
}
|
|
|
|
|
2006-03-31 21:09:09 +04:00
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_SEARCH_UNEX_Q_END,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/* We didn't find any matches. Record this irecv so we can match
|
|
|
|
* it when the message comes in.
|
2006-10-17 08:38:38 +04:00
|
|
|
*/
|
2005-05-24 02:06:50 +04:00
|
|
|
if(request->req_recv.req_base.req_type != MCA_PML_REQUEST_IPROBE) {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&proc->specific_receives, (opal_list_item_t*)request);
|
2006-03-31 21:09:09 +04:00
|
|
|
if(request->req_recv.req_base.req_type != MCA_PML_REQUEST_PROBE) {
|
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_INSERT_IN_POSTED_Q,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
|
|
|
}
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&comm->matching_lock);
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this routine is used to try and match a wild posted receive - where
|
|
|
|
* wild is determined by the value assigned to the source process
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_pml_ob1_recv_request_match_wild(mca_pml_ob1_recv_request_t* request)
|
|
|
|
{
|
|
|
|
mca_pml_ob1_comm_t* comm = request->req_recv.req_base.req_comm->c_pml_comm;
|
|
|
|
mca_pml_ob1_comm_proc_t* proc = comm->procs;
|
|
|
|
size_t proc_count = comm->num_procs;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop over all the outstanding messages to find one that matches.
|
|
|
|
* There is an outer loop over lists of messages from each
|
|
|
|
* process, then an inner loop over the messages from the
|
|
|
|
* process.
|
|
|
|
*/
|
2005-08-02 21:36:01 +04:00
|
|
|
OPAL_THREAD_LOCK(&comm->matching_lock);
|
2006-03-31 21:09:09 +04:00
|
|
|
/**
|
|
|
|
* The laps of time between the ACTIVATE event and the SEARCH_UNEX one include
|
|
|
|
* the cost of the request lock.
|
|
|
|
*/
|
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_SEARCH_UNEX_Q_BEGIN,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/* assign sequence number */
|
|
|
|
request->req_recv.req_base.req_sequence = comm->recv_sequence++;
|
|
|
|
|
|
|
|
for (i = 0; i < proc_count; i++) {
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_frag_t* frag;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/* continue if no frags to match */
|
2005-07-03 20:22:16 +04:00
|
|
|
if (opal_list_get_size(&proc->unexpected_frags) == 0) {
|
2005-05-24 02:06:50 +04:00
|
|
|
proc++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* loop over messages from the current proc */
|
|
|
|
if ((frag = mca_pml_ob1_recv_request_match_specific_proc(request, proc)) != NULL) {
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&comm->matching_lock);
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2006-03-31 21:09:09 +04:00
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_SEARCH_UNEX_Q_END,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
if( !((MCA_PML_REQUEST_IPROBE == request->req_recv.req_base.req_type) ||
|
|
|
|
(MCA_PML_REQUEST_PROBE == request->req_recv.req_base.req_type)) ) {
|
2005-09-13 20:45:41 +04:00
|
|
|
mca_pml_ob1_recv_request_progress(request,frag->btl,frag->segments,frag->num_segments);
|
2005-06-10 00:16:33 +04:00
|
|
|
MCA_PML_OB1_RECV_FRAG_RETURN(frag);
|
2005-09-13 20:45:41 +04:00
|
|
|
} else {
|
|
|
|
mca_pml_ob1_recv_request_matched_probe(request,frag->btl,frag->segments,frag->num_segments);
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
return; /* match found */
|
|
|
|
}
|
|
|
|
proc++;
|
|
|
|
}
|
|
|
|
|
2006-03-31 21:09:09 +04:00
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_SEARCH_UNEX_Q_END,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/* We didn't find any matches. Record this irecv so we can match to
|
|
|
|
* it when the message comes in.
|
|
|
|
*/
|
|
|
|
|
2006-03-31 21:09:09 +04:00
|
|
|
if(request->req_recv.req_base.req_type != MCA_PML_REQUEST_IPROBE) {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&comm->wild_receives, (opal_list_item_t*)request);
|
2006-03-31 21:09:09 +04:00
|
|
|
/**
|
|
|
|
* We don't want to generate this kind of event for MPI_Probe. Hopefully,
|
|
|
|
* the compiler will optimize out the empty if loop in the case where PERUSE
|
|
|
|
* support is not required by the user.
|
|
|
|
*/
|
|
|
|
if(request->req_recv.req_base.req_type != MCA_PML_REQUEST_PROBE) {
|
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_INSERT_IN_POSTED_Q,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
|
|
|
}
|
|
|
|
}
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&comm->matching_lock);
|
2005-05-24 02:06:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this routine tries to match a posted receive. If a match is found,
|
2005-11-14 02:01:41 +03:00
|
|
|
* it places the request in the appropriate matched receive list. This
|
|
|
|
* function has to be called with the communicator matching lock held.
|
2005-05-24 02:06:50 +04:00
|
|
|
*/
|
|
|
|
|
2005-06-10 00:16:33 +04:00
|
|
|
static mca_pml_ob1_recv_frag_t* mca_pml_ob1_recv_request_match_specific_proc(
|
2005-05-24 02:06:50 +04:00
|
|
|
mca_pml_ob1_recv_request_t* request,
|
|
|
|
mca_pml_ob1_comm_proc_t* proc)
|
|
|
|
{
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t* unexpected_frags = &proc->unexpected_frags;
|
2005-06-10 00:16:33 +04:00
|
|
|
mca_pml_ob1_recv_frag_t* frag;
|
2005-05-24 02:06:50 +04:00
|
|
|
mca_pml_ob1_match_hdr_t* hdr;
|
|
|
|
int tag = request->req_recv.req_base.req_tag;
|
|
|
|
|
|
|
|
if( OMPI_ANY_TAG == tag ) {
|
2005-07-03 20:22:16 +04:00
|
|
|
for (frag = (mca_pml_ob1_recv_frag_t*)opal_list_get_first(unexpected_frags);
|
|
|
|
frag != (mca_pml_ob1_recv_frag_t*)opal_list_get_end(unexpected_frags);
|
|
|
|
frag = (mca_pml_ob1_recv_frag_t*)opal_list_get_next(frag)) {
|
2005-05-24 02:06:50 +04:00
|
|
|
hdr = &(frag->hdr.hdr_match);
|
|
|
|
|
|
|
|
/* check first frag - we assume that process matching has been done already */
|
|
|
|
if( hdr->hdr_tag >= 0 ) {
|
|
|
|
goto find_fragment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2005-07-03 20:22:16 +04:00
|
|
|
for (frag = (mca_pml_ob1_recv_frag_t*)opal_list_get_first(unexpected_frags);
|
|
|
|
frag != (mca_pml_ob1_recv_frag_t*)opal_list_get_end(unexpected_frags);
|
|
|
|
frag = (mca_pml_ob1_recv_frag_t*)opal_list_get_next(frag)) {
|
2005-05-24 02:06:50 +04:00
|
|
|
hdr = &(frag->hdr.hdr_match);
|
|
|
|
|
|
|
|
/* check first frag - we assume that process matching has been done already */
|
|
|
|
if ( tag == hdr->hdr_tag ) {
|
|
|
|
/* we assume that the tag is correct from MPI point of view (ie. >= 0 ) */
|
|
|
|
goto find_fragment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
find_fragment:
|
2006-09-21 02:14:46 +04:00
|
|
|
request->req_recv.req_base.req_proc = proc->ompi_proc;
|
2005-05-24 02:06:50 +04:00
|
|
|
if( !((MCA_PML_REQUEST_IPROBE == request->req_recv.req_base.req_type) ||
|
|
|
|
(MCA_PML_REQUEST_PROBE == request->req_recv.req_base.req_type)) ) {
|
2006-03-31 21:09:09 +04:00
|
|
|
PERUSE_TRACE_MSG_EVENT( PERUSE_COMM_MSG_REMOVE_FROM_UNEX_Q,
|
|
|
|
request->req_recv.req_base.req_comm,
|
|
|
|
hdr->hdr_src, hdr->hdr_tag, PERUSE_RECV );
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(unexpected_frags, (opal_list_item_t*)frag);
|
2005-05-24 02:06:50 +04:00
|
|
|
frag->request = request;
|
|
|
|
}
|
2006-03-31 21:09:09 +04:00
|
|
|
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_MATCH_UNEX,
|
|
|
|
&(request->req_recv.req_base), PERUSE_RECV );
|
2005-05-24 02:06:50 +04:00
|
|
|
return frag;
|
|
|
|
}
|
|
|
|
|