1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2011-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2011 UT-Battelle, LLC. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#if !defined(MCA_BTL_UGNI_PREPARE_H)
# define MCA_BTL_UGNI_PREPARE_H
# include "opal_config.h"
# include "btl_ugni.h"
# include "btl_ugni_frag.h"
static inline struct mca_btl_base_descriptor_t *
mca_btl_ugni_prepare_src_send_nodata(struct mca_btl_base_module_t *btl,
mca_btl_base_endpoint_t *endpoint, uint8_t order,
size_t reserve, uint32_t flags)
{
mca_btl_ugni_base_frag_t *frag = NULL;
frag = mca_btl_ugni_frag_alloc_rdma(endpoint);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
BTL_VERBOSE(("preparing src for send fragment. size = %u", (unsigned int) reserve));
frag->hdr_size = reserve + sizeof(frag->hdr.send);
frag->segments[0].seg_addr.pval = frag->hdr.send_ex.pml_header;
frag->segments[0].seg_len = reserve;
frag->segments[1].seg_addr.pval = NULL;
frag->segments[1].seg_len = 0;
frag->base.des_segments = frag->segments;
frag->base.des_segment_count = 1;
frag->base.order = order;
frag->base.des_flags = flags;
return &frag->base;
}
static inline struct mca_btl_base_descriptor_t *mca_btl_ugni_prepare_src_send_inplace(
struct mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint,
struct opal_convertor_t *convertor, uint8_t order, size_t reserve, size_t *size, uint32_t flags)
{
bool use_eager_get = (*size + reserve) > mca_btl_ugni_component.smsg_max_data;
mca_btl_ugni_module_t *ugni_module = (mca_btl_ugni_module_t *) btl;
mca_btl_ugni_base_frag_t *frag = NULL;
mca_btl_ugni_reg_t *registration = NULL;
void *data_ptr;
int rc;
opal_convertor_get_current_pointer(convertor, &data_ptr);
frag = mca_btl_ugni_frag_alloc_rdma(endpoint);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
BTL_VERBOSE(("preparing src for send fragment. size = %u", (unsigned int) (*size + reserve)));
if (OPAL_UNLIKELY(true == use_eager_get)) {
rc = ugni_module->rcache
->rcache_register(ugni_module->rcache, data_ptr, *size, 0,
MCA_RCACHE_ACCESS_REMOTE_READ,
(mca_rcache_base_registration_t **) ®istration);
if (OPAL_UNLIKELY(OPAL_SUCCESS != rc)) {
mca_btl_ugni_frag_return(frag);
return NULL;
}
frag->flags = MCA_BTL_UGNI_FRAG_EAGER | MCA_BTL_UGNI_FRAG_IGNORE;
frag->registration = registration;
frag->hdr.eager.memory_handle = registration->handle;
;
frag->hdr_size = reserve + sizeof(frag->hdr.eager);
frag->segments[0].seg_addr.pval = frag->hdr.eager_ex.pml_header;
} else {
frag->hdr_size = reserve + sizeof(frag->hdr.send);
frag->segments[0].seg_addr.pval = frag->hdr.send_ex.pml_header;
}
frag->segments[0].seg_len = reserve;
frag->segments[1].seg_addr.pval = data_ptr;
frag->segments[1].seg_len = *size;
frag->base.des_segments = frag->segments;
frag->base.des_segment_count = 2;
frag->base.order = order;
frag->base.des_flags = flags;
return &frag->base;
}
static inline struct mca_btl_base_descriptor_t *mca_btl_ugni_prepare_src_send_buffered(
struct mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint,
struct opal_convertor_t *convertor, uint8_t order, size_t reserve, size_t *size, uint32_t flags)
{
bool use_eager_get = (*size + reserve) > mca_btl_ugni_component.smsg_max_data;
mca_btl_ugni_reg_t *registration = NULL;
mca_btl_ugni_base_frag_t *frag = NULL;
uint32_t iov_count = 1;
struct iovec iov;
int rc;
if (OPAL_UNLIKELY(true == use_eager_get)) {
frag = mca_btl_ugni_frag_alloc_eager_send(endpoint);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
frag->flags = MCA_BTL_UGNI_FRAG_EAGER | MCA_BTL_UGNI_FRAG_IGNORE;
registration = (mca_btl_ugni_reg_t *) frag->base.super.registration;
frag->hdr.eager.memory_handle = registration->handle;
frag->hdr_size = reserve + sizeof(frag->hdr.eager);
frag->segments[0].seg_addr.pval = frag->hdr.eager_ex.pml_header;
} else {
frag = mca_btl_ugni_frag_alloc_smsg(endpoint);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
frag->hdr_size = reserve + sizeof(frag->hdr.send);
frag->segments[0].seg_addr.pval = frag->hdr.send_ex.pml_header;
}
frag->flags |= MCA_BTL_UGNI_FRAG_BUFFERED;
iov.iov_len = *size;
iov.iov_base = (IOVBASE_TYPE *) frag->base.super.ptr;
rc = opal_convertor_pack(convertor, &iov, &iov_count, size);
if (OPAL_UNLIKELY(rc < 0)) {
mca_btl_ugni_frag_return(frag);
return NULL;
}
frag->segments[0].seg_len = reserve;
frag->segments[1].seg_addr.pval = frag->base.super.ptr;
frag->segments[1].seg_len = *size;
frag->base.des_segments = frag->segments;
frag->base.des_segment_count = 2;
frag->base.order = order;
frag->base.des_flags = flags;
return &frag->base;
}
static inline struct mca_btl_base_descriptor_t *
mca_btl_ugni_prepare_src_send(struct mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint,
struct opal_convertor_t *convertor, uint8_t order, size_t reserve,
size_t *size, uint32_t flags)
{
bool use_eager_get = (*size + reserve) > mca_btl_ugni_component.smsg_max_data;
bool send_in_place;
void *data_ptr;
if (!(*size)) {
return mca_btl_ugni_prepare_src_send_nodata(btl, endpoint, order, reserve, flags);
}
opal_convertor_get_current_pointer(convertor, &data_ptr);
send_in_place = (btl->btl_flags & MCA_BTL_FLAGS_SEND_INPLACE)
&& !(opal_convertor_need_buffers(convertor)
|| opal_convertor_on_device(convertor)
|| (use_eager_get && ((uintptr_t) data_ptr & 3)));
if (send_in_place) {
return mca_btl_ugni_prepare_src_send_inplace(btl, endpoint, convertor, order, reserve, size,
flags);
} else {
return mca_btl_ugni_prepare_src_send_buffered(btl, endpoint, convertor, order, reserve,
size, flags);
}
}
#endif
|