1
1
This commit was SVN r25413.
Этот коммит содержится в:
Nathan Hjelm 2011-11-02 15:07:57 +00:00
родитель f00753881e
Коммит 211e2dbdf3
12 изменённых файлов: 407 добавлений и 407 удалений

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2011 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -33,41 +33,41 @@
#include "btl_vader_fbox.h"
static int vader_del_procs (struct mca_btl_base_module_t *btl,
size_t nprocs, struct ompi_proc_t **procs,
struct mca_btl_base_endpoint_t **peers);
size_t nprocs, struct ompi_proc_t **procs,
struct mca_btl_base_endpoint_t **peers);
static int vader_register_error_cb (struct mca_btl_base_module_t* btl,
mca_btl_base_module_error_cb_fn_t cbfunc);
mca_btl_base_module_error_cb_fn_t cbfunc);
static int vader_finalize (struct mca_btl_base_module_t* btl);
static int vader_free (struct mca_btl_base_module_t* btl, mca_btl_base_descriptor_t* des);
static struct mca_btl_base_descriptor_t *vader_prepare_src (
struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
mca_mpool_base_registration_t *registration,
struct opal_convertor_t *convertor,
uint8_t order,
size_t reserve,
size_t *size,
uint32_t flags
);
struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
mca_mpool_base_registration_t *registration,
struct opal_convertor_t *convertor,
uint8_t order,
size_t reserve,
size_t *size,
uint32_t flags
);
static struct mca_btl_base_descriptor_t *vader_prepare_dst (
struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_mpool_base_registration_t *registration,
struct opal_convertor_t *convertor,
uint8_t order,
size_t reserve,
size_t *size,
uint32_t flags);
struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_mpool_base_registration_t *registration,
struct opal_convertor_t *convertor,
uint8_t order,
size_t reserve,
size_t *size,
uint32_t flags);
static int vader_add_procs(struct mca_btl_base_module_t* btl,
size_t nprocs, struct ompi_proc_t **procs,
struct mca_btl_base_endpoint_t** peers,
struct opal_bitmap_t* reachability);
size_t nprocs, struct ompi_proc_t **procs,
struct mca_btl_base_endpoint_t** peers,
struct opal_bitmap_t* reachability);
static int vader_ft_event (int state);
@ -93,7 +93,7 @@ mca_btl_vader_t mca_btl_vader = {
vader_prepare_src,
vader_prepare_dst,
mca_btl_vader_send,
mca_btl_vader_sendi,
mca_btl_vader_sendi,
mca_btl_vader_put,
mca_btl_vader_get,
mca_btl_base_dump,
@ -131,9 +131,9 @@ static void vader_init_maffinity (int *my_mem_node)
/* find core we are running on */
for (i = 0; i < num_core; ++i) {
if (OPAL_PAFFINITY_CPU_ISSET(i, cpus)) {
break;
}
if (OPAL_PAFFINITY_CPU_ISSET(i, cpus)) {
break;
}
}
if (OMPI_SUCCESS != opal_paffinity_base_get_map_to_socket_core(i, &socket, &i)) {
@ -146,17 +146,17 @@ static void vader_init_maffinity (int *my_mem_node)
slot_node = opal_carto_base_find_node(topo, myslot);
if (NULL == slot_node) {
goto out;
goto out;
}
opal_carto_base_get_nodes_distance(topo, slot_node, "Memory", &dists);
if (opal_value_array_get_size(&dists) > 1) {
dist = (opal_carto_node_distance_t *) opal_value_array_get_item(&dists, 0);
opal_maffinity_base_node_name_to_id(dist->node->node_name, my_mem_node);
dist = (opal_carto_node_distance_t *) opal_value_array_get_item(&dists, 0);
opal_maffinity_base_node_name_to_id(dist->node->node_name, my_mem_node);
}
out:
if (myslot) {
free(myslot);
free(myslot);
}
OBJ_DESTRUCT(&dists);
@ -181,7 +181,7 @@ static inline int vader_init_mpool (mca_btl_vader_t *vader_btl, int n)
* in the allocator.
*/
res.size = sizeof (vader_fifo_t) + 4 * opal_cache_line_size +
(2 * n + component->vader_free_list_inc) * (component->eager_limit + 2 * opal_cache_line_size);
(2 * n + component->vader_free_list_inc) * (component->eager_limit + 2 * opal_cache_line_size);
/* before we multiply by n, make sure the result won't overflow */
/* Stick that little pad in, particularly since we'll eventually
@ -190,21 +190,21 @@ static inline int vader_init_mpool (mca_btl_vader_t *vader_btl, int n)
* added.
*/
if ( ((double) res.size) * n > LONG_MAX - 4096 )
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
res.size *= n;
/* now, create it */
component->vader_mpool =
mca_mpool_base_module_create(component->vader_mpool_name,
vader_btl, &res);
mca_mpool_base_module_create(component->vader_mpool_name,
vader_btl, &res);
/* Sanity check to ensure that we found it */
if(NULL == component->vader_mpool) {
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
}
component->vader_mpool_base =
component->vader_mpool->mpool_base (component->vader_mpool);
component->vader_mpool->mpool_base (component->vader_mpool);
return OMPI_SUCCESS;
}
@ -222,14 +222,14 @@ static int vader_btl_first_time_init(mca_btl_vader_t *vader_btl, int n)
/* make the entire memory space of this process accessible */
my_segid = xpmem_make (0, 0xffffffffffffffffll, XPMEM_PERMIT_MODE,
(void *)0666);
(void *)0666);
if (-1 == my_segid) {
return OMPI_ERROR;
return OMPI_ERROR;
}
rc = vader_init_mpool (vader_btl, n);
if (OMPI_SUCCESS != rc) {
return rc;
return rc;
}
/* create a list of peers */
@ -251,7 +251,7 @@ static int vader_btl_first_time_init(mca_btl_vader_t *vader_btl, int n)
segment (only the shared control structure) */
size = sizeof (mca_common_sm_seg_header_t) +
n * (sizeof (vader_fifo_t *) + sizeof (char *)
+ sizeof (xpmem_segid_t)) + opal_cache_line_size;
+ sizeof (xpmem_segid_t)) + opal_cache_line_size;
procs = ompi_proc_world(&num_procs);
if (!(mca_btl_vader_component.vader_seg =
mca_common_sm_init(procs, num_procs, size, vader_ctl_file,
@ -287,40 +287,40 @@ static int vader_btl_first_time_init(mca_btl_vader_t *vader_btl, int n)
return OMPI_ERR_OUT_OF_RESOURCE;
component->shm_fifo[component->my_smp_rank] =
component->fifo[component->my_smp_rank] = my_fifos;
component->fifo[component->my_smp_rank] = my_fifos;
component->apids = (xpmem_apid_t *) calloc (n, sizeof (xpmem_apid_t));
if (NULL == component->apids)
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
component->xpmem_rcaches =
(struct mca_rcache_base_module_t **) calloc (n, sizeof (struct mca_rcache_base_module_t *));
(struct mca_rcache_base_module_t **) calloc (n, sizeof (struct mca_rcache_base_module_t *));
if (NULL == component->xpmem_rcaches)
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
component->vader_fboxes_in = (char **) calloc (n, sizeof (char *));
if (NULL == component->vader_fboxes_in)
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
component->vader_fboxes_out = (char **) calloc (n, sizeof (char *));
if (NULL == component->vader_fboxes_out)
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
component->vader_next_fbox_in = (unsigned char *) calloc (64, 1);
if (NULL == component->vader_next_fbox_in)
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
component->vader_next_fbox_out = (unsigned char *) calloc (64, 1);
if (NULL == component->vader_next_fbox_out)
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
/* initialize fragment descriptor free lists */
/* initialize free list for send fragments */
i = ompi_free_list_init_new(&component->vader_frags_eager,
sizeof (mca_btl_vader_frag_t),
sizeof (mca_btl_vader_frag_t),
opal_cache_line_size, OBJ_CLASS(mca_btl_vader_frag_t),
sizeof (mca_btl_vader_hdr_t) + component->eager_limit,
opal_cache_line_size,
sizeof (mca_btl_vader_hdr_t) + component->eager_limit,
opal_cache_line_size,
component->vader_free_list_num,
component->vader_free_list_max,
component->vader_free_list_inc,
@ -330,16 +330,16 @@ static int vader_btl_first_time_init(mca_btl_vader_t *vader_btl, int n)
/* initialize free list for put/get fragments */
i = ompi_free_list_init_new(&component->vader_frags_user,
sizeof(mca_btl_vader_frag_t),
opal_cache_line_size, OBJ_CLASS(mca_btl_vader_frag_t),
sizeof(mca_btl_vader_hdr_t) + mca_btl_vader_max_inline_send,
opal_cache_line_size,
component->vader_free_list_num,
component->vader_free_list_max,
component->vader_free_list_inc,
component->vader_mpool);
sizeof(mca_btl_vader_frag_t),
opal_cache_line_size, OBJ_CLASS(mca_btl_vader_frag_t),
sizeof(mca_btl_vader_hdr_t) + mca_btl_vader_max_inline_send,
opal_cache_line_size,
component->vader_free_list_num,
component->vader_free_list_max,
component->vader_free_list_inc,
component->vader_mpool);
if (OMPI_SUCCESS != i)
return i;
return i;
/* set flag indicating btl has been inited */
vader_btl->btl_inited = true;
@ -353,7 +353,7 @@ mca_btl_base_endpoint_t *create_vader_endpoint (int local_proc, struct ompi_proc
struct mca_btl_base_endpoint_t *ep = (struct mca_btl_base_endpoint_t *)
calloc(1, sizeof (struct mca_btl_base_endpoint_t));
if(NULL != ep) {
ep->peer_smp_rank = local_proc + mca_btl_vader_component.num_smp_procs;
ep->peer_smp_rank = local_proc + mca_btl_vader_component.num_smp_procs;
}
return ep;
@ -374,9 +374,9 @@ mca_btl_base_endpoint_t *create_vader_endpoint (int local_proc, struct ompi_proc
*/
static int vader_add_procs (struct mca_btl_base_module_t* btl,
size_t nprocs, struct ompi_proc_t **procs,
struct mca_btl_base_endpoint_t **peers,
opal_bitmap_t *reachability)
size_t nprocs, struct ompi_proc_t **procs,
struct mca_btl_base_endpoint_t **peers,
opal_bitmap_t *reachability)
{
mca_btl_vader_component_t *component = &mca_btl_vader_component;
mca_btl_vader_t *vader_btl = (mca_btl_vader_t *) btl;
@ -408,7 +408,7 @@ static int vader_add_procs (struct mca_btl_base_module_t* btl,
/* check to see if this is me */
if (my_proc == procs[proc]) {
my_smp_rank = component->my_smp_rank = n_local_procs++;
continue;
continue;
}
/* we have someone to talk to */
@ -424,7 +424,7 @@ static int vader_add_procs (struct mca_btl_base_module_t* btl,
rc = opal_bitmap_set_bit (reachability, proc);
if(OMPI_SUCCESS != rc) {
goto CLEANUP;
}
}
}
/* jump out if there's not someone we can talk to */
@ -442,7 +442,7 @@ static int vader_add_procs (struct mca_btl_base_module_t* btl,
rc = vader_btl_first_time_init(vader_btl, n_local_procs);
if(rc != OMPI_SUCCESS) {
goto CLEANUP;
}
}
}
/* set local proc's smp rank in the peers structure for
@ -462,7 +462,7 @@ static int vader_add_procs (struct mca_btl_base_module_t* btl,
*/
rc = vader_fifo_init (component->fifo[my_smp_rank]);
if (OMPI_SUCCESS != rc) {
goto CLEANUP;
goto CLEANUP;
}
opal_atomic_wmb();
@ -479,7 +479,7 @@ static int vader_add_procs (struct mca_btl_base_module_t* btl,
/* coordinate with other processes */
for (i = 0 ; i < n_local_procs ; ++i) {
int peer_smp_rank = i + component->num_smp_procs;
int peer_smp_rank = i + component->num_smp_procs;
/* spin until this element is allocated */
/* doesn't really wait for that process... FIFO might be allocated, but not initialized */
@ -488,31 +488,31 @@ static int vader_add_procs (struct mca_btl_base_module_t* btl,
opal_atomic_rmb();
}
if (my_smp_rank != peer_smp_rank) {
void *rem_ptr = (void *) component->shm_fifo[peer_smp_rank];
if (my_smp_rank != peer_smp_rank) {
void *rem_ptr = (void *) component->shm_fifo[peer_smp_rank];
component->apids[peer_smp_rank] =
xpmem_get (component->shm_seg_ids[peer_smp_rank],
XPMEM_RDWR, XPMEM_PERMIT_MODE, (void *) 0666);
component->xpmem_rcaches[peer_smp_rank] = mca_rcache_base_module_create("vma");
component->apids[peer_smp_rank] =
xpmem_get (component->shm_seg_ids[peer_smp_rank],
XPMEM_RDWR, XPMEM_PERMIT_MODE, (void *) 0666);
component->xpmem_rcaches[peer_smp_rank] = mca_rcache_base_module_create("vma");
/* get a persistent pointer to the peer's fifo */
component->fifo[peer_smp_rank] =
vader_reg_to_ptr (vader_get_registation (peer_smp_rank, rem_ptr,
(n_local_procs + 1) * getpagesize (),
MCA_MPOOL_FLAGS_PERSIST), rem_ptr);
/* get a persistent pointer to the peer's fifo */
component->fifo[peer_smp_rank] =
vader_reg_to_ptr (vader_get_registation (peer_smp_rank, rem_ptr,
(n_local_procs + 1) * getpagesize (),
MCA_MPOOL_FLAGS_PERSIST), rem_ptr);
/* fast boxes are allocated at the same time as the fifos */
component->vader_fboxes_in[peer_smp_rank] = (char *) component->fifo[my_smp_rank] +
(peer_smp_rank + 1) * getpagesize ();
component->vader_fboxes_out[peer_smp_rank] = (char *) component->fifo[peer_smp_rank] +
(my_smp_rank + 1) * getpagesize ();
/* fast boxes are allocated at the same time as the fifos */
component->vader_fboxes_in[peer_smp_rank] = (char *) component->fifo[my_smp_rank] +
(peer_smp_rank + 1) * getpagesize ();
component->vader_fboxes_out[peer_smp_rank] = (char *) component->fifo[peer_smp_rank] +
(my_smp_rank + 1) * getpagesize ();
component->vader_next_fbox_in[peer_smp_rank] = 0;
component->vader_next_fbox_out[peer_smp_rank] = 0;
component->vader_next_fbox_in[peer_smp_rank] = 0;
component->vader_next_fbox_out[peer_smp_rank] = 0;
memset (component->vader_fboxes_in[peer_smp_rank], MCA_BTL_VADER_FBOX_FREE, getpagesize());
}
memset (component->vader_fboxes_in[peer_smp_rank], MCA_BTL_VADER_FBOX_FREE, getpagesize());
}
}
/* update the local smp process count */
@ -520,7 +520,7 @@ static int vader_add_procs (struct mca_btl_base_module_t* btl,
/* make sure we have enough eager fragmnents for each process */
rc = ompi_free_list_resize(&component->vader_frags_eager,
component->num_smp_procs * 2);
component->num_smp_procs * 2);
CLEANUP:
@ -538,8 +538,8 @@ static int vader_add_procs (struct mca_btl_base_module_t* btl,
*/
static int vader_del_procs(struct mca_btl_base_module_t *btl,
size_t nprocs, struct ompi_proc_t **procs,
struct mca_btl_base_endpoint_t **peers)
size_t nprocs, struct ompi_proc_t **procs,
struct mca_btl_base_endpoint_t **peers)
{
return OMPI_SUCCESS;
}
@ -572,7 +572,7 @@ static int vader_finalize(struct mca_btl_base_module_t *btl)
* @return Status indicating if cleanup was successful
*/
static int vader_register_error_cb(struct mca_btl_base_module_t* btl,
mca_btl_base_module_error_cb_fn_t cbfunc)
mca_btl_base_module_error_cb_fn_t cbfunc)
{
((mca_btl_vader_t *)btl)->error_cb = cbfunc;
return OMPI_SUCCESS;
@ -585,28 +585,28 @@ static int vader_register_error_cb(struct mca_btl_base_module_t* btl,
* @param size (IN) Request segment size.
*/
mca_btl_base_descriptor_t *mca_btl_vader_alloc(struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
uint8_t order, size_t size, uint32_t flags)
struct mca_btl_base_endpoint_t *endpoint,
uint8_t order, size_t size, uint32_t flags)
{
mca_btl_vader_frag_t *frag = NULL;
int rc;
if (size <= mca_btl_vader_max_inline_send) {
MCA_BTL_VADER_FRAG_ALLOC_USER(frag, rc);
MCA_BTL_VADER_FRAG_ALLOC_USER(frag, rc);
} else if (size <= mca_btl_vader_component.eager_limit) {
MCA_BTL_VADER_FRAG_ALLOC_EAGER(frag, rc);
}
if (OPAL_LIKELY(frag != NULL)) {
frag->segment.seg_len = size;
frag->endpoint = endpoint;
frag->endpoint = endpoint;
frag->base.des_flags = flags;
frag->base.order = order;
frag->base.des_src = &frag->segment;
frag->base.des_src_cnt = 1;
frag->base.des_dst = &frag->segment;
frag->base.des_src_cnt = 1;
frag->base.order = order;
frag->base.des_src = &frag->segment;
frag->base.des_src_cnt = 1;
frag->base.des_dst = &frag->segment;
frag->base.des_src_cnt = 1;
}
return (mca_btl_base_descriptor_t *) frag;
@ -626,11 +626,11 @@ static int vader_free (struct mca_btl_base_module_t *btl, mca_btl_base_descripto
}
struct mca_btl_base_descriptor_t *vader_prepare_dst(struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_mpool_base_registration_t *registration,
struct opal_convertor_t *convertor,
uint8_t order, size_t reserve, size_t *size,
uint32_t flags)
struct mca_btl_base_endpoint_t *endpoint,
struct mca_mpool_base_registration_t *registration,
struct opal_convertor_t *convertor,
uint8_t order, size_t reserve, size_t *size,
uint32_t flags)
{
mca_btl_vader_frag_t *frag;
void *data_ptr;
@ -662,11 +662,11 @@ struct mca_btl_base_descriptor_t *vader_prepare_dst(struct mca_btl_base_module_t
* @param btl (IN) BTL module
*/
static struct mca_btl_base_descriptor_t *vader_prepare_src (struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
mca_mpool_base_registration_t *registration,
struct opal_convertor_t *convertor,
uint8_t order, size_t reserve, size_t *size,
uint32_t flags)
struct mca_btl_base_endpoint_t *endpoint,
mca_mpool_base_registration_t *registration,
struct opal_convertor_t *convertor,
uint8_t order, size_t reserve, size_t *size,
uint32_t flags)
{
struct iovec iov, *lcl_mem;
mca_btl_vader_frag_t *frag;
@ -677,69 +677,69 @@ static struct mca_btl_base_descriptor_t *vader_prepare_src (struct mca_btl_base_
opal_convertor_get_current_pointer (convertor, &data_ptr);
if (OPAL_LIKELY(reserve)) {
/* in place send fragment */
if (OPAL_UNLIKELY(opal_convertor_need_buffers(convertor))) {
/* non-contiguous data requires the convertor */
MCA_BTL_VADER_FRAG_ALLOC_EAGER(frag,rc);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
/* in place send fragment */
if (OPAL_UNLIKELY(opal_convertor_need_buffers(convertor))) {
/* non-contiguous data requires the convertor */
MCA_BTL_VADER_FRAG_ALLOC_EAGER(frag,rc);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
iov.iov_len = mca_btl_vader_component.eager_limit - reserve;
iov.iov_base =
(IOVBASE_TYPE *)(((uintptr_t)(frag->segment.seg_addr.pval)) +
reserve);
iov.iov_len = mca_btl_vader_component.eager_limit - reserve;
iov.iov_base =
(IOVBASE_TYPE *)(((uintptr_t)(frag->segment.seg_addr.pval)) +
reserve);
rc = opal_convertor_pack (convertor, &iov, &iov_count, size);
if (OPAL_UNLIKELY(rc < 0)) {
MCA_BTL_VADER_FRAG_RETURN(frag);
return NULL;
}
rc = opal_convertor_pack (convertor, &iov, &iov_count, size);
if (OPAL_UNLIKELY(rc < 0)) {
MCA_BTL_VADER_FRAG_RETURN(frag);
return NULL;
}
frag->segment.seg_len = reserve + *size;
} else {
MCA_BTL_VADER_FRAG_ALLOC_USER(frag, rc);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
frag->segment.seg_len = reserve + *size;
} else {
MCA_BTL_VADER_FRAG_ALLOC_USER(frag, rc);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
if ((*size + reserve) > mca_btl_vader_max_inline_send) {
/* single copy send */
/* pack the iovec after the reserved memory */
lcl_mem = (struct iovec *) ((uintptr_t)frag->segment.seg_addr.pval + reserve);
if ((*size + reserve) > mca_btl_vader_max_inline_send) {
/* single copy send */
/* pack the iovec after the reserved memory */
lcl_mem = (struct iovec *) ((uintptr_t)frag->segment.seg_addr.pval + reserve);
frag->hdr->flags = MCA_BTL_VADER_FLAG_SINGLE_COPY;
frag->hdr->flags = MCA_BTL_VADER_FLAG_SINGLE_COPY;
lcl_mem->iov_base = data_ptr;
lcl_mem->iov_len = *size;
lcl_mem->iov_base = data_ptr;
lcl_mem->iov_len = *size;
frag->segment.seg_len = reserve;
} else {
/* inline send */
frag->segment.seg_len = reserve;
} else {
/* inline send */
/* try to reserve a fast box for this transfer */
fbox_ptr = mca_btl_vader_reserve_fbox (endpoint->peer_smp_rank, reserve + *size);
/* try to reserve a fast box for this transfer */
fbox_ptr = mca_btl_vader_reserve_fbox (endpoint->peer_smp_rank, reserve + *size);
if (fbox_ptr) {
frag->hdr->flags |= MCA_BTL_VADER_FLAG_FBOX;
frag->segment.seg_addr.pval = fbox_ptr;
}
if (fbox_ptr) {
frag->hdr->flags |= MCA_BTL_VADER_FLAG_FBOX;
frag->segment.seg_addr.pval = fbox_ptr;
}
/* NTH: the covertor adds some latency so we bypass it here */
vader_memmove ((void *)((uintptr_t)frag->segment.seg_addr.pval + reserve),
data_ptr, *size);
frag->segment.seg_len = reserve + *size;
}
}
/* NTH: the covertor adds some latency so we bypass it here */
vader_memmove ((void *)((uintptr_t)frag->segment.seg_addr.pval + reserve),
data_ptr, *size);
frag->segment.seg_len = reserve + *size;
}
}
} else {
/* put/get fragment */
MCA_BTL_VADER_FRAG_ALLOC_USER(frag, rc);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
/* put/get fragment */
MCA_BTL_VADER_FRAG_ALLOC_USER(frag, rc);
if (OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
frag->segment.seg_key.ptr = (uintptr_t) data_ptr;
frag->segment.seg_len = reserve + *size;
frag->segment.seg_key.ptr = (uintptr_t) data_ptr;
frag->segment.seg_len = reserve + *size;
}
frag->base.des_src = &frag->segment;

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -91,19 +91,19 @@ struct mca_btl_vader_component_t {
int vader_free_list_num; /**< initial size of free lists */
int vader_free_list_max; /**< maximum size of free lists */
int vader_free_list_inc; /**< number of elements to alloc
* when growing free lists */
* when growing free lists */
char *vader_mpool_name; /**< name of shared memory pool module */
mca_mpool_base_module_t *vader_mpool; /**< mpool on local node */
void *vader_mpool_base; /**< base address of shared memory pool */
size_t eager_limit; /**< send fragment size */
mca_common_sm_module_t *vader_seg; /**< description of shared memory segment */
volatile struct vader_fifo_t **shm_fifo;/**< pointer to fifo 2D array in
* shared memory */
* shared memory */
char **shm_bases; /**< pointer to base pointers in
* shared memory */
* shared memory */
xpmem_segid_t *shm_seg_ids; /* xpmem segment ids */
struct vader_fifo_t **fifo; /**< cached copy of the pointer to
* the 2D fifo array. */
* the 2D fifo array. */
struct mca_rcache_base_module_t **xpmem_rcaches;
xpmem_apid_t *apids; /* xpmem apids */
int32_t num_smp_procs; /**< current number of smp procs on this host */
@ -161,7 +161,7 @@ static inline uintptr_t get_mask (uintptr_t x)
/* look up the remote pointer in the peer rcache and attach if
* necessary */
static inline mca_mpool_base_registration_t *vader_get_registation (int peer_smp_rank, void *rem_ptr,
size_t size, int flags)
size_t size, int flags)
{
struct mca_rcache_base_module_t *rcache = mca_btl_vader_component.xpmem_rcaches[peer_smp_rank];
mca_mpool_base_registration_t *regs[10], *reg = NULL;
@ -170,75 +170,75 @@ static inline mca_mpool_base_registration_t *vader_get_registation (int peer_smp
int rc, i;
if (OPAL_UNLIKELY(peer_smp_rank == mca_btl_vader_component.my_smp_rank)) {
return rem_ptr;
return rem_ptr;
}
mask = get_mask (mca_btl_vader_segment_multiple);
base = (uintptr_t) down_align_addr(rem_ptr, mca_mpool_base_page_size_log);
bound = (uintptr_t) up_align_addr((void *)((uintptr_t) rem_ptr + size - 1),
mca_mpool_base_page_size_log) + 1;
mca_mpool_base_page_size_log) + 1;
/* several segments may match the base pointer */
rc = rcache->rcache_find_all (rcache, (void *) base, bound - base, regs, 10);
for (i = 0 ; i < rc ; ++i) {
if (bound <= (uintptr_t)regs[i]->bound && base >= (uintptr_t)regs[i]->base) {
opal_atomic_add (&regs[i]->ref_count, 1);
return regs[i];
}
if (bound <= (uintptr_t)regs[i]->bound && base >= (uintptr_t)regs[i]->base) {
opal_atomic_add (&regs[i]->ref_count, 1);
return regs[i];
}
if (regs[i]->flags & MCA_MPOOL_FLAGS_PERSIST) {
continue;
}
if (regs[i]->flags & MCA_MPOOL_FLAGS_PERSIST) {
continue;
}
/* remove this pointer from the rcache and decrement its reference count
(so it is detached later) */
rc = rcache->rcache_delete (rcache, regs[i]);
if (OPAL_UNLIKELY(0 != rc)) {
/* someone beat us to it? */
break;
}
/* remove this pointer from the rcache and decrement its reference count
(so it is detached later) */
rc = rcache->rcache_delete (rcache, regs[i]);
if (OPAL_UNLIKELY(0 != rc)) {
/* someone beat us to it? */
break;
}
/* start the new segment from the lower of the two bases */
base = (uintptr_t) regs[i]->base < base ? (uintptr_t) regs[i]->base : base;
/* start the new segment from the lower of the two bases */
base = (uintptr_t) regs[i]->base < base ? (uintptr_t) regs[i]->base : base;
opal_atomic_add (&regs[i]->ref_count, -1);
opal_atomic_add (&regs[i]->ref_count, -1);
if (OPAL_LIKELY(0 == regs[i]->ref_count)) {
/* this pointer is not in use */
(void) xpmem_detach (regs[i]->alloc_base);
OBJ_RELEASE(regs[i]);
}
if (OPAL_LIKELY(0 == regs[i]->ref_count)) {
/* this pointer is not in use */
(void) xpmem_detach (regs[i]->alloc_base);
OBJ_RELEASE(regs[i]);
}
break;
break;
}
if ((ptrdiff_t) (bound - base) & mask) {
bound = base + ((bound - base) & ~mask) + mca_btl_vader_segment_multiple;
bound = base + ((bound - base) & ~mask) + mca_btl_vader_segment_multiple;
}
if (OPAL_UNLIKELY(bound > VADER_MAX_ADDRESS)) {
bound = VADER_MAX_ADDRESS;
bound = VADER_MAX_ADDRESS;
}
reg = OBJ_NEW(mca_mpool_base_registration_t);
if (OPAL_UNLIKELY(NULL != reg)) {
/* stick around for awhile */
reg->ref_count = 2;
reg->base = (unsigned char *) base;
reg->bound = (unsigned char *) bound;
reg->flags = flags;
xpmem_addr.apid = mca_btl_vader_component.apids[peer_smp_rank];
xpmem_addr.offset = base;
/* stick around for awhile */
reg->ref_count = 2;
reg->base = (unsigned char *) base;
reg->bound = (unsigned char *) bound;
reg->flags = flags;
xpmem_addr.apid = mca_btl_vader_component.apids[peer_smp_rank];
xpmem_addr.offset = base;
reg->alloc_base = xpmem_attach (xpmem_addr, bound - base, NULL);
if (OPAL_UNLIKELY((void *)-1 == reg->alloc_base)) {
OBJ_RELEASE(reg);
reg = NULL;
} else {
rcache->rcache_insert (rcache, reg, 0);
}
reg->alloc_base = xpmem_attach (xpmem_addr, bound - base, NULL);
if (OPAL_UNLIKELY((void *)-1 == reg->alloc_base)) {
OBJ_RELEASE(reg);
reg = NULL;
} else {
rcache->rcache_insert (rcache, reg, 0);
}
}
return reg;
@ -250,16 +250,16 @@ static inline void vader_return_registration (mca_mpool_base_registration_t *reg
opal_atomic_add (&reg->ref_count, -1);
if (OPAL_UNLIKELY(0 == reg->ref_count && !(reg->flags & MCA_MPOOL_FLAGS_PERSIST))) {
rcache->rcache_delete (rcache, reg);
(void)xpmem_detach (reg->alloc_base);
OBJ_RELEASE (reg);
rcache->rcache_delete (rcache, reg);
(void)xpmem_detach (reg->alloc_base);
OBJ_RELEASE (reg);
}
}
static inline void *vader_reg_to_ptr (mca_mpool_base_registration_t *reg, void *rem_ptr)
{
return (void *) ((uintptr_t) reg->alloc_base +
(ptrdiff_t)((uintptr_t) rem_ptr - (uintptr_t) reg->base));
(ptrdiff_t)((uintptr_t) rem_ptr - (uintptr_t) reg->base));
}
/* memcpy is faster at larger sizes but is undefined if the
@ -267,9 +267,9 @@ static inline void *vader_reg_to_ptr (mca_mpool_base_registration_t *reg, void *
static inline void vader_memmove (void *dst, void *src, size_t size)
{
if (size >= mca_btl_vader_memcpy_limit) {
memcpy (dst, src, size);
memcpy (dst, src, size);
} else {
memmove (dst, src, size);
memmove (dst, src, size);
}
}
@ -280,9 +280,9 @@ static inline void vader_memmove (void *dst, void *src, size_t size)
* @param peer (IN) BTL peer addressing
*/
int mca_btl_vader_send(struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *descriptor,
mca_btl_base_tag_t tag);
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *descriptor,
mca_btl_base_tag_t tag);
/**
* Initiate an inline send to the peer.
@ -291,12 +291,12 @@ int mca_btl_vader_send(struct mca_btl_base_module_t *btl,
* @param peer (IN) BTL peer addressing
*/
int mca_btl_vader_sendi (struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct opal_convertor_t *convertor,
void *header, size_t header_size,
size_t payload_size, uint8_t order,
uint32_t flags, mca_btl_base_tag_t tag,
mca_btl_base_descriptor_t **descriptor);
struct mca_btl_base_endpoint_t *endpoint,
struct opal_convertor_t *convertor,
void *header, size_t header_size,
size_t payload_size, uint8_t order,
uint32_t flags, mca_btl_base_tag_t tag,
mca_btl_base_descriptor_t **descriptor);
/**
* Initiate an synchronous put.
@ -306,8 +306,8 @@ int mca_btl_vader_sendi (struct mca_btl_base_module_t *btl,
* @param descriptor (IN) Description of the data to be transferred
*/
int mca_btl_vader_put (struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *des);
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *des);
/**
* Initiate an synchronous get.
@ -317,8 +317,8 @@ int mca_btl_vader_put (struct mca_btl_base_module_t *btl,
* @param descriptor (IN) Description of the data to be transferred
*/
int mca_btl_vader_get (struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *des);
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *des);
/**
* Allocate a segment.
@ -327,8 +327,8 @@ int mca_btl_vader_get (struct mca_btl_base_module_t *btl,
* @param size (IN) Request segment size.
*/
mca_btl_base_descriptor_t* mca_btl_vader_alloc (struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
uint8_t order, size_t size, uint32_t flags);
struct mca_btl_base_endpoint_t* endpoint,
uint8_t order, size_t size, uint32_t flags);
END_C_DECLS

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2011 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -42,8 +42,8 @@ static int mca_btl_vader_component_open(void);
static int mca_btl_vader_component_close(void);
static int mca_btl_vader_component_register(void);
static mca_btl_base_module_t** mca_btl_vader_component_init(int *num_btls,
bool enable_progress_threads,
bool enable_mpi_threads);
bool enable_progress_threads,
bool enable_mpi_threads);
/* limit where we should switch from bcopy to memcpy */
int mca_btl_vader_memcpy_limit = 524288;
@ -57,7 +57,7 @@ int mca_btl_vader_max_inline_send = 256;
mca_btl_vader_component_t mca_btl_vader_component = {
{
/* First, the mca_base_component_t struct containing meta information
about the component itself */
about the component itself */
{
MCA_BTL_BASE_VERSION_2_0_0,
@ -86,21 +86,21 @@ mca_btl_vader_component_t mca_btl_vader_component = {
*/
static inline char *mca_btl_vader_param_register_string(const char *param_name,
const char *default_value)
const char *default_value)
{
char *param_value;
int id = mca_base_param_register_string("btl", "vader",
param_name, NULL,
default_value);
param_name, NULL,
default_value);
mca_base_param_lookup_string(id, &param_value);
return param_value;
}
static inline int mca_btl_vader_param_register_int(const char *param_name,
int value)
int value)
{
int id = mca_base_param_register_int("btl", "vader", param_name,
NULL, value);
NULL, value);
mca_base_param_lookup_int(id, &value);
return value;
}
@ -127,11 +127,11 @@ static int mca_btl_vader_component_register (void)
mca_btl_vader_component.vader_mpool_name =
mca_btl_vader_param_register_string("mpool", "sm");
mca_btl_vader_memcpy_limit =
mca_btl_vader_param_register_int("memcpy_limit", mca_btl_vader_memcpy_limit);
mca_btl_vader_param_register_int("memcpy_limit", mca_btl_vader_memcpy_limit);
mca_btl_vader_segment_multiple =
msb(mca_btl_vader_param_register_int("segment_multiple", mca_btl_vader_segment_multiple));
msb(mca_btl_vader_param_register_int("segment_multiple", mca_btl_vader_segment_multiple));
mca_btl_vader_max_inline_send =
mca_btl_vader_param_register_int("max_inline_send", mca_btl_vader_max_inline_send);
mca_btl_vader_param_register_int("max_inline_send", mca_btl_vader_max_inline_send);
mca_btl_vader.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_HIGH;
mca_btl_vader.super.btl_eager_limit = 64 * 1024;
@ -141,7 +141,7 @@ static int mca_btl_vader_component_register (void)
mca_btl_vader.super.btl_rdma_pipeline_frag_size = mca_btl_vader.super.btl_eager_limit;
mca_btl_vader.super.btl_min_rdma_pipeline_size = mca_btl_vader.super.btl_eager_limit;
mca_btl_vader.super.btl_flags = MCA_BTL_FLAGS_GET | MCA_BTL_FLAGS_PUT |
MCA_BTL_FLAGS_SEND_INPLACE;
MCA_BTL_FLAGS_SEND_INPLACE;
mca_btl_vader.super.btl_bandwidth = 40000; /* Mbs */
mca_btl_vader.super.btl_latency = 1; /* Microsecs */
@ -199,7 +199,7 @@ static int mca_btl_vader_component_close(void)
* to it are gone - no error checking, since we want all procs
* to call this, so that in an abnormal termination scenario,
* this file will still get cleaned up */
/* XXX LANL TODO -- remove unlink once the shmem segment uses xpmem */
/* XXX LANL TODO -- remove unlink once the shmem segment uses xpmem */
unlink(mca_btl_vader_component.vader_seg->shmem_ds.seg_name);
OBJ_RELEASE(mca_btl_vader_component.vader_seg);
}
@ -220,8 +220,8 @@ static int mca_btl_vader_component_close(void)
* VADER component initialization
*/
static mca_btl_base_module_t **mca_btl_vader_component_init (int *num_btls,
bool enable_progress_threads,
bool enable_mpi_threads)
bool enable_progress_threads,
bool enable_mpi_threads)
{
mca_btl_vader_component_t *component = &mca_btl_vader_component;
mca_btl_base_module_t **btls = NULL;
@ -266,24 +266,24 @@ static inline void mca_btl_vader_progress_sends (void)
mca_btl_vader_frag_t *frag;
for (item = opal_list_get_first (list) ; item != opal_list_get_end (list) ; ) {
frag = (mca_btl_vader_frag_t *) item;
next = opal_list_get_next (item);
frag = (mca_btl_vader_frag_t *) item;
next = opal_list_get_next (item);
if (OPAL_LIKELY(frag->hdr->complete)) {
opal_list_remove_item (&mca_btl_vader_component.active_sends, item);
if (OPAL_LIKELY(frag->hdr->complete)) {
opal_list_remove_item (&mca_btl_vader_component.active_sends, item);
if (OPAL_UNLIKELY(MCA_BTL_DES_SEND_ALWAYS_CALLBACK & frag->base.des_flags)) {
/* completion callback */
frag->base.des_cbfunc(&mca_btl_vader.super, frag->endpoint,
&frag->base, OMPI_SUCCESS);
}
if (OPAL_UNLIKELY(MCA_BTL_DES_SEND_ALWAYS_CALLBACK & frag->base.des_flags)) {
/* completion callback */
frag->base.des_cbfunc(&mca_btl_vader.super, frag->endpoint,
&frag->base, OMPI_SUCCESS);
}
if (OPAL_LIKELY(frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP)) {
MCA_BTL_VADER_FRAG_RETURN(frag);
}
}
if (OPAL_LIKELY(frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP)) {
MCA_BTL_VADER_FRAG_RETURN(frag);
}
}
item = next;
item = next;
}
}
@ -308,7 +308,7 @@ static int mca_btl_vader_component_progress (void)
/* poll the fifo once */
hdr = (mca_btl_vader_hdr_t *) vader_fifo_read (fifo);
if (VADER_FIFO_FREE == hdr) {
return 0;
return 0;
}
/* change the address from address relative to the shared
@ -322,21 +322,21 @@ static int mca_btl_vader_component_progress (void)
segments[0].seg_len = hdr->len;
if (OPAL_UNLIKELY(hdr->flags & MCA_BTL_VADER_FLAG_SINGLE_COPY)) {
struct iovec *rem_mem = (struct iovec *) ((uintptr_t)segments[0].seg_addr.pval + hdr->len);
struct iovec *rem_mem = (struct iovec *) ((uintptr_t)segments[0].seg_addr.pval + hdr->len);
xpmem_reg = vader_get_registation (hdr->my_smp_rank, rem_mem->iov_base,
rem_mem->iov_len, 0);
xpmem_reg = vader_get_registation (hdr->my_smp_rank, rem_mem->iov_base,
rem_mem->iov_len, 0);
segments[1].seg_addr.pval = vader_reg_to_ptr (xpmem_reg, rem_mem->iov_base);
segments[1].seg_len = rem_mem->iov_len;
segments[1].seg_addr.pval = vader_reg_to_ptr (xpmem_reg, rem_mem->iov_base);
segments[1].seg_len = rem_mem->iov_len;
/* recv upcall */
frag.base.des_dst_cnt = 2;
reg->cbfunc(&mca_btl_vader.super, hdr->tag, &(frag.base), reg->cbdata);
vader_return_registration (xpmem_reg, hdr->my_smp_rank);
/* recv upcall */
frag.base.des_dst_cnt = 2;
reg->cbfunc(&mca_btl_vader.super, hdr->tag, &(frag.base), reg->cbdata);
vader_return_registration (xpmem_reg, hdr->my_smp_rank);
} else {
frag.base.des_dst_cnt = 1;
reg->cbfunc(&mca_btl_vader.super, hdr->tag, &(frag.base), reg->cbdata);
frag.base.des_dst_cnt = 1;
reg->cbfunc(&mca_btl_vader.super, hdr->tag, &(frag.base), reg->cbdata);
}
/* return the fragment */

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2011 Los Alamos National Security, LLC.
* All rights reserved.
@ -23,10 +23,10 @@
enum {MCA_BTL_VADER_FBOX_FREE = 0xfe, MCA_BTL_VADER_FBOX_RESERVED = 0xff};
#define MCA_BTL_VADER_FBOX_OUT_PTR(peer_smp_rank, fbox) \
#define MCA_BTL_VADER_FBOX_OUT_PTR(peer_smp_rank, fbox) \
(mca_btl_vader_component.vader_fboxes_out[peer_smp_rank] + FBOX_SIZE * (fbox))
#define MCA_BTL_VADER_FBOX_IN_PTR(peer_smp_rank, fbox) \
#define MCA_BTL_VADER_FBOX_IN_PTR(peer_smp_rank, fbox) \
(mca_btl_vader_component.vader_fboxes_in[peer_smp_rank] + FBOX_SIZE * (fbox))
static inline unsigned char *mca_btl_vader_reserve_fbox (int peer_smp_rank, size_t size)
@ -37,12 +37,12 @@ static inline unsigned char *mca_btl_vader_reserve_fbox (int peer_smp_rank, size
/* todo -- need thread locks here for the multi-threaded case */
if (size > MAX_MSG || fbox[0] != MCA_BTL_VADER_FBOX_FREE) {
/* fall back on fifo */
return NULL;
/* fall back on fifo */
return NULL;
}
mca_btl_vader_component.vader_next_fbox_out[peer_smp_rank] =
next_fbox == LAST_FBOX ? 0 : next_fbox + 1;
next_fbox == LAST_FBOX ? 0 : next_fbox + 1;
/* mark this fast box as in use */
fbox[0] = MCA_BTL_VADER_FBOX_RESERVED;
@ -61,20 +61,20 @@ static inline void mca_btl_vader_fbox_send (unsigned char *fbox, unsigned char t
}
static inline int mca_btl_vader_fbox_sendi (struct mca_btl_base_endpoint_t *endpoint, char tag,
void *header, size_t header_size,
void *payload, size_t payload_size)
void *header, size_t header_size,
void *payload, size_t payload_size)
{
unsigned char *fbox;
fbox = mca_btl_vader_reserve_fbox(endpoint->peer_smp_rank, header_size + payload_size);
if (NULL == fbox) {
return 0;
return 0;
}
memcpy (fbox, header, header_size);
if (OPAL_UNLIKELY(payload)) {
/* inline sends are typically just pml headers (due to MCA_BTL_FLAGS_SEND_INPLACE) */
memcpy (fbox + header_size, payload, payload_size);
/* inline sends are typically just pml headers (due to MCA_BTL_FLAGS_SEND_INPLACE) */
memcpy (fbox + header_size, payload, payload_size);
}
/* mark the fbox as sent */
@ -93,35 +93,35 @@ static inline void mca_btl_vader_check_fboxes (void)
int i;
for (i = 0 ; i < mca_btl_vader_component.num_smp_procs ; ++i) {
int next_fbox = mca_btl_vader_component.vader_next_fbox_in[i];
unsigned char *fbox = MCA_BTL_VADER_FBOX_IN_PTR(i, next_fbox);
int next_fbox = mca_btl_vader_component.vader_next_fbox_in[i];
unsigned char *fbox = MCA_BTL_VADER_FBOX_IN_PTR(i, next_fbox);
if (my_smp_rank == i) {
continue;
}
if (my_smp_rank == i) {
continue;
}
/* process all fast-box messages */
while (0xfe != ((size = fbox[0]) & 0xfe)) {
opal_atomic_rmb ();
/* process all fast-box messages */
while (0xfe != ((size = fbox[0]) & 0xfe)) {
opal_atomic_rmb ();
tag = fbox[1];
tag = fbox[1];
reg = mca_btl_base_active_message_trigger + tag;
reg = mca_btl_base_active_message_trigger + tag;
frag.segment.seg_addr.pval = fbox + 2;
frag.segment.seg_len = size;
frag.segment.seg_addr.pval = fbox + 2;
frag.segment.seg_len = size;
frag.base.des_dst = &frag.segment;
frag.base.des_dst_cnt = 1;
reg->cbfunc(&mca_btl_vader.super, tag, &(frag.base), reg->cbdata);
frag.base.des_dst = &frag.segment;
frag.base.des_dst_cnt = 1;
reg->cbfunc(&mca_btl_vader.super, tag, &(frag.base), reg->cbdata);
fbox[0] = MCA_BTL_VADER_FBOX_FREE;
fbox[0] = MCA_BTL_VADER_FBOX_FREE;
next_fbox = next_fbox == LAST_FBOX ? 0 : next_fbox + 1;
fbox = MCA_BTL_VADER_FBOX_IN_PTR(i, next_fbox);
}
next_fbox = next_fbox == LAST_FBOX ? 0 : next_fbox + 1;
fbox = MCA_BTL_VADER_FBOX_IN_PTR(i, next_fbox);
}
mca_btl_vader_component.vader_next_fbox_in[i] = next_fbox;
mca_btl_vader_component.vader_next_fbox_in[i] = next_fbox;
}
}

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -76,10 +76,10 @@ static inline void vader_fifo_write (void *value, vader_fifo_t *fifo)
opal_atomic_wmb ();
if (OPAL_LIKELY(VADER_FIFO_FREE != prev)) {
hdr = (mca_btl_vader_hdr_t *) RELATIVE2VIRTUAL(prev);
hdr->next = value;
hdr = (mca_btl_vader_hdr_t *) RELATIVE2VIRTUAL(prev);
hdr->next = value;
} else {
fifo->fifo_head = value;
fifo->fifo_head = value;
}
opal_atomic_wmb ();
@ -94,22 +94,22 @@ static inline void *vader_fifo_read (vader_fifo_t *fifo)
value = (void *) opal_atomic_swap_ptr (&fifo->fifo_head, (intptr_t) VADER_FIFO_FREE);
if (VADER_FIFO_FREE == value) {
/* fifo is empty or we lost the race with another thread */
return value;
/* fifo is empty or we lost the race with another thread */
return value;
}
hdr = (mca_btl_vader_hdr_t *) RELATIVE2VIRTUAL(value);
if (OPAL_UNLIKELY(VADER_FIFO_FREE == hdr->next)) {
if (!opal_atomic_cmpset_ptr (&fifo->fifo_tail, value, VADER_FIFO_FREE)) {
while (VADER_FIFO_FREE == hdr->next) {
opal_atomic_rmb ();
}
if (!opal_atomic_cmpset_ptr (&fifo->fifo_tail, value, VADER_FIFO_FREE)) {
while (VADER_FIFO_FREE == hdr->next) {
opal_atomic_rmb ();
}
fifo->fifo_head = hdr->next;
}
fifo->fifo_head = hdr->next;
}
} else {
fifo->fifo_head = hdr->next;
fifo->fifo_head = hdr->next;
}
opal_atomic_wmb ();
@ -154,10 +154,10 @@ static inline int vader_fifo_write (void *value, vader_fifo_t *fifo)
fifo->fifo_tail = value;
if (OPAL_LIKELY(VADER_FIFO_FREE != prev)) {
hdr = (mca_btl_vader_hdr_t *) RELATIVE2VIRTUAL(prev);
hdr->next = value;
hdr = (mca_btl_vader_hdr_t *) RELATIVE2VIRTUAL(prev);
hdr->next = value;
} else {
fifo->fifo_head = value;
fifo->fifo_head = value;
}
opal_atomic_unlock(&(fifo->tail_lock));
@ -174,12 +174,12 @@ static inline void *vader_fifo_read (vader_fifo_t *fifo)
/* aquire thread lock */
if (opal_using_threads ()) {
opal_atomic_lock (&fifo->head_lock);
opal_atomic_lock (&fifo->head_lock);
}
opal_atomic_rmb();
if (VADER_FIFO_FREE == fifo->fifo_head) {
return VADER_FIFO_FREE;
return VADER_FIFO_FREE;
}
value = (void *) fifo->fifo_head;
@ -187,20 +187,20 @@ static inline void *vader_fifo_read (vader_fifo_t *fifo)
fifo->fifo_head = hdr->next;
if (OPAL_UNLIKELY(VADER_FIFO_FREE == fifo->fifo_head)) {
opal_atomic_rmb();
opal_atomic_lock(&(fifo->tail_lock));
opal_atomic_rmb();
opal_atomic_lock(&(fifo->tail_lock));
if (OPAL_LIKELY(fifo->fifo_tail == value)) {
fifo->fifo_tail = VADER_FIFO_FREE;
} else {
fifo->fifo_head = hdr->next;
}
opal_atomic_unlock(&(fifo->tail_lock));
if (OPAL_LIKELY(fifo->fifo_tail == value)) {
fifo->fifo_tail = VADER_FIFO_FREE;
} else {
fifo->fifo_head = hdr->next;
}
opal_atomic_unlock(&(fifo->tail_lock));
}
/* release thread lock */
if (opal_using_threads ()) {
opal_atomic_unlock (&fifo->head_lock);
opal_atomic_unlock (&fifo->head_lock);
}
return value;

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -34,4 +34,4 @@ static inline void mca_btl_vader_frag_constructor (mca_btl_vader_frag_t *frag)
}
OBJ_CLASS_INSTANCE(mca_btl_vader_frag_t, mca_btl_base_descriptor_t,
mca_btl_vader_frag_constructor, NULL);
mca_btl_vader_frag_constructor, NULL);

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -57,30 +57,30 @@ typedef struct mca_btl_vader_frag_t mca_btl_vader_frag_t;
OBJ_CLASS_DECLARATION(mca_btl_vader_frag_t);
#define MCA_BTL_VADER_FRAG_ALLOC_EAGER(frag, rc) \
do { \
ompi_free_list_item_t *item; \
OMPI_FREE_LIST_GET(&mca_btl_vader_component.vader_frags_eager, item, rc); \
frag = (mca_btl_vader_frag_t *) item; \
frag->hdr->complete = false; \
frag->hdr->flags = MCA_BTL_VADER_FLAG_INLINE; \
frag->segment.seg_addr.pval = (char *)(frag->hdr + 1); \
frag->my_list = &mca_btl_vader_component.vader_frags_eager; \
#define MCA_BTL_VADER_FRAG_ALLOC_EAGER(frag, rc) \
do { \
ompi_free_list_item_t *item; \
OMPI_FREE_LIST_GET(&mca_btl_vader_component.vader_frags_eager, item, rc); \
frag = (mca_btl_vader_frag_t *) item; \
frag->hdr->complete = false; \
frag->hdr->flags = MCA_BTL_VADER_FLAG_INLINE; \
frag->segment.seg_addr.pval = (char *)(frag->hdr + 1); \
frag->my_list = &mca_btl_vader_component.vader_frags_eager; \
} while (0)
#define MCA_BTL_VADER_FRAG_ALLOC_USER(frag, rc) \
do { \
ompi_free_list_item_t *item; \
OMPI_FREE_LIST_GET(&mca_btl_vader_component.vader_frags_user, item, rc); \
frag = (mca_btl_vader_frag_t *) item; \
frag->hdr->complete = false; \
frag->hdr->flags = MCA_BTL_VADER_FLAG_INLINE; \
frag->segment.seg_addr.pval = (char *)(frag->hdr + 1); \
frag->my_list = &mca_btl_vader_component.vader_frags_user; \
#define MCA_BTL_VADER_FRAG_ALLOC_USER(frag, rc) \
do { \
ompi_free_list_item_t *item; \
OMPI_FREE_LIST_GET(&mca_btl_vader_component.vader_frags_user, item, rc); \
frag = (mca_btl_vader_frag_t *) item; \
frag->hdr->complete = false; \
frag->hdr->flags = MCA_BTL_VADER_FLAG_INLINE; \
frag->segment.seg_addr.pval = (char *)(frag->hdr + 1); \
frag->my_list = &mca_btl_vader_component.vader_frags_user; \
} while (0)
#define MCA_BTL_VADER_FRAG_RETURN(frag) \
OMPI_FREE_LIST_RETURN((frag)->my_list, (ompi_free_list_item_t *)(frag))
#define MCA_BTL_VADER_FRAG_RETURN(frag) \
OMPI_FREE_LIST_RETURN((frag)->my_list, (ompi_free_list_item_t *)(frag))
#endif /* MCA_BTL_VADER_SEND_FRAG_H */

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2010-2011 Los Alamos National Security, LLC.
* All rights reserved.
@ -23,8 +23,8 @@
* @param descriptor (IN) Description of the data to be transferred
*/
int mca_btl_vader_get (struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *des)
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *des)
{
mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) des;
mca_btl_base_segment_t *src = des->des_src;
@ -34,10 +34,10 @@ int mca_btl_vader_get (struct mca_btl_base_module_t *btl,
void *rem_ptr;
reg = vader_get_registation (endpoint->peer_smp_rank,
(void *) src->seg_key.ptr,
src->seg_len, 0);
(void *) src->seg_key.ptr,
src->seg_len, 0);
if (OPAL_UNLIKELY(NULL == reg)) {
return OMPI_ERROR;
return OMPI_ERROR;
}
rem_ptr = vader_reg_to_ptr (reg, (void *) src->seg_key.ptr);

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2010-2011 Los Alamos National Security, LLC.
* All rights reserved.
@ -23,8 +23,8 @@
* @param descriptor (IN) Description of the data to be transferred
*/
int mca_btl_vader_put (struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *des)
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *des)
{
mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) des;
mca_btl_base_segment_t *src = des->des_src;
@ -34,10 +34,10 @@ int mca_btl_vader_put (struct mca_btl_base_module_t *btl,
void *rem_ptr;
reg = vader_get_registation (endpoint->peer_smp_rank,
(void *) dst->seg_key.ptr,
dst->seg_len, 0);
(void *) dst->seg_key.ptr,
dst->seg_len, 0);
if (OPAL_UNLIKELY(NULL == reg)) {
return OMPI_ERROR;
return OMPI_ERROR;
}
rem_ptr = vader_reg_to_ptr (reg, (void *) dst->seg_key.ptr);
@ -49,7 +49,7 @@ int mca_btl_vader_put (struct mca_btl_base_module_t *btl,
/* always call the callback function (if it exists) */
if (OPAL_LIKELY(NULL != frag->base.des_cbfunc)) {
frag->base.des_cbfunc(&mca_btl_vader.super, frag->endpoint,
&frag->base, OMPI_SUCCESS);
&frag->base, OMPI_SUCCESS);
}
if (frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP) {

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2011 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -35,20 +35,20 @@
* @param peer (IN) BTL peer addressing
*/
int mca_btl_vader_send (struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *descriptor,
mca_btl_base_tag_t tag)
struct mca_btl_base_endpoint_t *endpoint,
struct mca_btl_base_descriptor_t *descriptor,
mca_btl_base_tag_t tag)
{
mca_btl_vader_frag_t *frag = (mca_btl_vader_frag_t *) descriptor;
if (frag->hdr->flags & MCA_BTL_VADER_FLAG_FBOX) {
mca_btl_vader_fbox_send (frag->segment.seg_addr.pval, tag, frag->segment.seg_len);
mca_btl_vader_fbox_send (frag->segment.seg_addr.pval, tag, frag->segment.seg_len);
if (OPAL_LIKELY(frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP)) {
MCA_BTL_VADER_FRAG_RETURN(frag);
}
if (OPAL_LIKELY(frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP)) {
MCA_BTL_VADER_FRAG_RETURN(frag);
}
return 1;
return 1;
}
/* available header space */
@ -60,11 +60,11 @@ int mca_btl_vader_send (struct mca_btl_base_module_t *btl,
/* post the relative address of the descriptor into the peer's fifo */
vader_fifo_write ((void *) VIRTUAL2RELATIVE(frag->hdr),
mca_btl_vader_component.fifo[endpoint->peer_smp_rank]);
mca_btl_vader_component.fifo[endpoint->peer_smp_rank]);
if (frag->hdr->flags & MCA_BTL_VADER_FLAG_SINGLE_COPY) {
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
return 0;
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
return 0;
}
/* data is gone */

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2011 The Trustees of Indiana University and Indiana
* University Research and Technology
@ -36,12 +36,12 @@
* @param peer (IN) BTL peer addressing
*/
int mca_btl_vader_sendi (struct mca_btl_base_module_t *btl,
struct mca_btl_base_endpoint_t *endpoint,
struct opal_convertor_t *convertor,
void *header, size_t header_size,
size_t payload_size, uint8_t order,
uint32_t flags, mca_btl_base_tag_t tag,
mca_btl_base_descriptor_t **descriptor)
struct mca_btl_base_endpoint_t *endpoint,
struct opal_convertor_t *convertor,
void *header, size_t header_size,
size_t payload_size, uint8_t order,
uint32_t flags, mca_btl_base_tag_t tag,
mca_btl_base_descriptor_t **descriptor)
{
size_t length = (header_size + payload_size);
mca_btl_vader_frag_t *frag;
@ -57,20 +57,20 @@ int mca_btl_vader_sendi (struct mca_btl_base_module_t *btl,
*descriptor = NULL;
if (OPAL_LIKELY(!(payload_size && opal_convertor_need_buffers (convertor)))) {
if (payload_size) {
opal_convertor_get_current_pointer (convertor, &data_ptr);
}
if (payload_size) {
opal_convertor_get_current_pointer (convertor, &data_ptr);
}
if (mca_btl_vader_fbox_sendi (endpoint, tag, header, header_size, data_ptr, payload_size)) {
return OMPI_SUCCESS;
}
if (mca_btl_vader_fbox_sendi (endpoint, tag, header, header_size, data_ptr, payload_size)) {
return OMPI_SUCCESS;
}
}
/* allocate a fragment, giving up if we can't get one */
frag = (mca_btl_vader_frag_t *) mca_btl_vader_alloc (btl, endpoint, order, length,
flags | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);
flags | MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);
if (OPAL_UNLIKELY(NULL == frag)) {
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_ERR_OUT_OF_RESOURCE;
}
/* fill in fragment fields */
@ -87,24 +87,24 @@ int mca_btl_vader_sendi (struct mca_btl_base_module_t *btl,
/* we can't use single-copy semantics here since as caller will consider the send
complete if we return success */
if (OPAL_UNLIKELY(payload_size && opal_convertor_need_buffers (convertor))) {
/* pack the data into the supplied buffer */
iov.iov_base = (IOVBASE_TYPE *)((uintptr_t)frag->segment.seg_addr.pval + header_size);
iov.iov_len = max_data = payload_size;
/* pack the data into the supplied buffer */
iov.iov_base = (IOVBASE_TYPE *)((uintptr_t)frag->segment.seg_addr.pval + header_size);
iov.iov_len = max_data = payload_size;
(void) opal_convertor_pack (convertor, &iov, &iov_count, &max_data);
(void) opal_convertor_pack (convertor, &iov, &iov_count, &max_data);
assert (max_data == payload_size);
assert (max_data == payload_size);
} else if (payload_size) {
/* bypassing the convertor may speed things up a little */
opal_convertor_get_current_pointer (convertor, &data_ptr);
memcpy ((void *)((uintptr_t)frag->segment.seg_addr.pval + header_size), data_ptr, payload_size);
/* bypassing the convertor may speed things up a little */
opal_convertor_get_current_pointer (convertor, &data_ptr);
memcpy ((void *)((uintptr_t)frag->segment.seg_addr.pval + header_size), data_ptr, payload_size);
}
opal_list_append (&mca_btl_vader_component.active_sends, (opal_list_item_t *) frag);
/* write the fragment pointer to peer's the FIFO */
vader_fifo_write ((void *) VIRTUAL2RELATIVE(frag->hdr),
mca_btl_vader_component.fifo[endpoint->peer_smp_rank]);
mca_btl_vader_component.fifo[endpoint->peer_smp_rank]);
/* the progress function will return the fragment */