Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: [OMPI devel] mca_btl_tcp_alloc
From: Alex Margolin (alex.margolin_at_[hidden])
Date: 2012-04-04 09:22:52


Hi,

As I'm working out the bugs in my component I used TCP as reference and
came across the following:
In mca_btl_tcp_alloc (openmpi-trunk/ompi/mca/btl/tcp/btl_tcp.c:188) the
first segment is initialized to point to "frag + 1".
I don't get it... how/when is this location allocated? Isn't it just
after the mca_btl_tcp_frag_t structure ends?

Thanks,
Alex

mca_btl_base_descriptor_t* mca_btl_tcp_alloc(
     struct mca_btl_base_module_t* btl,
     struct mca_btl_base_endpoint_t* endpoint,
     uint8_t order,
     size_t size,
     uint32_t flags)
{
     mca_btl_tcp_frag_t* frag = NULL;
     int rc;

     if(size <= btl->btl_eager_limit) {
         MCA_BTL_TCP_FRAG_ALLOC_EAGER(frag, rc);
     } else if (size <= btl->btl_max_send_size) {
         MCA_BTL_TCP_FRAG_ALLOC_MAX(frag, rc);
     }
     if( OPAL_UNLIKELY(NULL == frag) ) {
         return NULL;
     }

     frag->segments[0].seg_len = size;
     frag->segments[0].seg_addr.pval = frag+1;

     frag->base.des_src = frag->segments;
     frag->base.des_src_cnt = 1;
     frag->base.des_dst = NULL;
     frag->base.des_dst_cnt = 0;
     frag->base.des_flags = flags;
     frag->base.order = MCA_BTL_NO_ORDER;
     frag->btl = (mca_btl_tcp_module_t*)btl;
     return (mca_btl_base_descriptor_t*)frag;
}