2004-11-04 07:03:32 +03:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-04 07:03:32 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2004-12-07 18:38:01 +03:00
|
|
|
#include <errno.h>
|
2004-11-04 07:03:32 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "util/output.h"
|
|
|
|
#include "util/if.h"
|
|
|
|
#include "mca/pml/pml.h"
|
|
|
|
#include "mca/ptl/ptl.h"
|
|
|
|
#include "mca/pml/base/pml_base_sendreq.h"
|
|
|
|
#include "mca/pml/base/pml_base_recvreq.h"
|
|
|
|
#include "mca/ptl/base/ptl_base_header.h"
|
|
|
|
#include "mca/ptl/base/ptl_base_sendfrag.h"
|
|
|
|
#include "mca/ptl/base/ptl_base_recvfrag.h"
|
|
|
|
#include "mca/common/sm/common_sm_mmap.h"
|
|
|
|
#include "ptl_sm.h"
|
|
|
|
#include "util/sys_info.h"
|
|
|
|
#include "mca/ptl/sm/src/ptl_sm_peer.h"
|
|
|
|
#include "mca/common/sm/common_sm_mmap.h"
|
|
|
|
#include "util/proc_info.h"
|
|
|
|
#include "util/printf.h"
|
|
|
|
#include "mca/ptl/sm/src/ptl_sm_sendreq.h"
|
|
|
|
#include "class/ompi_fifo.h"
|
|
|
|
#include "class/ompi_free_list.h"
|
2005-07-04 02:45:48 +04:00
|
|
|
#include "opal/threads/mutex.h"
|
2005-06-23 22:46:57 +04:00
|
|
|
#include "datatype/datatype.h"
|
2004-11-04 07:03:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're "recompiling" (see the Makefile.am for an explanation),
|
|
|
|
* change the function names.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef SM_COMMON_BASE_ADDR
|
|
|
|
#define mca_ptl_sm_matched mca_ptl_sm_matched_same_base_addr
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A posted receive has been matched:
|
|
|
|
* - deliver data to user buffers
|
|
|
|
* - update receive request data
|
|
|
|
* - ack
|
|
|
|
*
|
|
|
|
* fragment lists are NOT manipulated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_ptl_sm_matched(
|
|
|
|
mca_ptl_base_module_t* ptl,
|
|
|
|
mca_ptl_base_recv_frag_t* frag)
|
|
|
|
{
|
2005-05-09 23:37:10 +04:00
|
|
|
mca_ptl_base_recv_request_t* recv_desc;
|
2004-11-04 07:03:32 +03:00
|
|
|
mca_ptl_sm_frag_t *sm_frag_desc;
|
|
|
|
struct iovec iov;
|
|
|
|
ompi_convertor_t frag_convertor;
|
|
|
|
int free_after,my_local_smp_rank,peer_local_smp_rank, return_status;
|
2005-06-25 01:12:38 +04:00
|
|
|
unsigned int iov_count;
|
|
|
|
size_t max_data;
|
2004-11-04 07:03:32 +03:00
|
|
|
ompi_fifo_t *send_fifo;
|
|
|
|
|
|
|
|
/* copy data from shared memory buffer to user buffer */
|
|
|
|
/* get pointer to the matched receive descriptor */
|
|
|
|
recv_desc = frag->frag_request;
|
|
|
|
sm_frag_desc = (mca_ptl_sm_frag_t *)frag;
|
|
|
|
|
|
|
|
my_local_smp_rank=mca_ptl_sm_component.my_smp_rank;
|
|
|
|
peer_local_smp_rank=sm_frag_desc->queue_index;
|
|
|
|
|
|
|
|
/* copy, only if there is data to copy */
|
2005-06-23 22:46:57 +04:00
|
|
|
max_data=0;
|
2004-11-04 07:03:32 +03:00
|
|
|
if( 0 < sm_frag_desc->super.frag_base.frag_size ) {
|
2005-06-23 22:46:57 +04:00
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/*
|
|
|
|
* Initialize convertor and use it to unpack data
|
2005-06-23 22:46:57 +04:00
|
|
|
*/
|
2005-06-09 00:47:48 +04:00
|
|
|
ompi_convertor_clone_with_position( &(recv_desc->req_recv.req_convertor), &frag_convertor,
|
|
|
|
1, &(sm_frag_desc->send_offset) );
|
2005-06-23 22:46:57 +04:00
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* convert address from sender's address space to my virtual
|
|
|
|
* address space */
|
|
|
|
#ifdef SM_COMMON_BASE_ADDR
|
|
|
|
iov.iov_base = (void *)( (char *)sm_frag_desc->buff);
|
|
|
|
#else
|
|
|
|
iov.iov_base = (void *)( (char *)sm_frag_desc->buff+
|
|
|
|
mca_ptl_sm_component.sm_offset[peer_local_smp_rank]);
|
|
|
|
#endif
|
|
|
|
iov.iov_len = sm_frag_desc->super.frag_base.frag_size;
|
|
|
|
iov_count = 1;
|
|
|
|
max_data = iov.iov_len;
|
2004-12-06 18:58:57 +03:00
|
|
|
ompi_convertor_unpack( &frag_convertor, &iov, &iov_count, &max_data, &free_after );
|
2004-11-04 07:03:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* update receive request information */
|
|
|
|
frag->frag_base.frag_owner->ptl_recv_progress(
|
|
|
|
ptl,
|
|
|
|
recv_desc,
|
|
|
|
sm_frag_desc->super.frag_base.frag_size,
|
|
|
|
max_data);
|
|
|
|
|
|
|
|
/* ack - ack recycles shared memory fragment resources, so
|
|
|
|
* don't agragate */
|
|
|
|
|
|
|
|
send_fifo=&(mca_ptl_sm_component.fifo
|
|
|
|
[my_local_smp_rank][peer_local_smp_rank]);
|
2005-04-19 01:13:30 +04:00
|
|
|
|
|
|
|
/* lock as multiple processes can attempt to init the head */
|
2005-07-04 02:45:48 +04:00
|
|
|
if(opal_using_threads())
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_lock(&send_fifo->head_lock);
|
2005-04-19 01:13:30 +04:00
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* check to see if fifo is allocated */
|
2005-04-19 01:13:30 +04:00
|
|
|
if(OMPI_CB_FREE == send_fifo->head) {
|
2004-11-04 07:03:32 +03:00
|
|
|
/* no queues have been allocated - allocate now */
|
|
|
|
return_status=ompi_fifo_init_same_base_addr(
|
|
|
|
mca_ptl_sm_component.size_of_cb_queue,
|
|
|
|
mca_ptl_sm_component.cb_lazy_free_freq,
|
|
|
|
/* at this stage we are not doing anything with memory
|
|
|
|
* locality */
|
|
|
|
0,0,0,
|
|
|
|
send_fifo, mca_ptl_sm_component.sm_mpool);
|
|
|
|
if( return_status != OMPI_SUCCESS ) {
|
2005-07-04 02:45:48 +04:00
|
|
|
if(opal_using_threads())
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_unlock(&send_fifo->head_lock);
|
2004-11-04 07:03:32 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* change address to be relative to offset from base of shared
|
2004-12-06 18:58:57 +03:00
|
|
|
* memory segment
|
|
|
|
*/
|
2004-11-04 07:03:32 +03:00
|
|
|
|
|
|
|
/* set the fragment type to be an ack */
|
|
|
|
sm_frag_desc->super.frag_base.frag_header.hdr_common.hdr_type=
|
|
|
|
MCA_PTL_HDR_TYPE_ACK;
|
|
|
|
return_status=ompi_fifo_write_to_head_same_base_addr(sm_frag_desc,
|
|
|
|
send_fifo, mca_ptl_sm_component.sm_mpool);
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
if(opal_using_threads())
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_unlock(&send_fifo->head_lock);
|
2005-04-19 01:13:30 +04:00
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* if can't ack, put on list for later delivery */
|
|
|
|
if( 0 > return_status ) {
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&(mca_ptl_sm_component.sm_pending_ack_lock));
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&(mca_ptl_sm_component.sm_pending_ack),
|
|
|
|
(opal_list_item_t *)sm_frag_desc);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&(mca_ptl_sm_component.sm_pending_ack_lock));
|
2004-12-07 18:38:01 +03:00
|
|
|
} else {
|
|
|
|
MCA_PTL_SM_SIGNAL_PEER(mca_ptl_sm_component.sm_peers[peer_local_smp_rank]);
|
2004-11-04 07:03:32 +03:00
|
|
|
}
|
|
|
|
|
2004-12-07 18:38:01 +03:00
|
|
|
|
2004-11-04 07:03:32 +03:00
|
|
|
/* return */
|
|
|
|
return;
|
|
|
|
}
|