btl/vader: fix 32-bit support
cmr=v1.7.5:ticket=trac:4053 This commit was SVN r30626. The following Trac tickets were found above: Ticket 4053 --> https://svn.open-mpi.org/trac/ompi/ticket/4053
Этот коммит содержится в:
родитель
77869c3232
Коммит
a8867a9ca4
@ -158,23 +158,6 @@ OMPI_MODULE_DECLSPEC extern mca_btl_vader_t mca_btl_vader;
|
||||
/* local rank in the group */
|
||||
#define MCA_BTL_VADER_LOCAL_RANK ompi_process_info.my_local_rank
|
||||
|
||||
|
||||
/* This only works for finding the relative address for a pointer within my_segment */
|
||||
static inline intptr_t virtual2relative (char *addr)
|
||||
{
|
||||
return (intptr_t) (addr - mca_btl_vader_component.my_segment) | ((int64_t)MCA_BTL_VADER_LOCAL_RANK << 32);
|
||||
}
|
||||
|
||||
static inline intptr_t virtual2relativepeer (struct mca_btl_base_endpoint_t *endpoint, char *addr)
|
||||
{
|
||||
return (intptr_t) (addr - endpoint->segment_base) | ((int64_t)endpoint->peer_smp_rank << 32);
|
||||
}
|
||||
|
||||
static inline void *relative2virtual (intptr_t offset)
|
||||
{
|
||||
return (void *)((offset & 0xffffffffull) + mca_btl_vader_component.endpoints[offset >> 32].segment_base);
|
||||
}
|
||||
|
||||
/* memcpy is faster at larger sizes but is undefined if the
|
||||
pointers are aliased (TODO -- readd alias check) */
|
||||
static inline void vader_memmove (void *dst, void *src, size_t size)
|
||||
|
@ -118,14 +118,14 @@ static int mca_btl_vader_component_register (void)
|
||||
MCA_BASE_VAR_SCOPE_LOCAL,
|
||||
&mca_btl_vader_component.log_attach_align);
|
||||
|
||||
#if OMPI_BTL_VADER_HAVE_XPMEM
|
||||
#if OMPI_BTL_VADER_HAVE_XPMEM && 64 == MCA_BTL_VADER_BITNESS
|
||||
mca_btl_vader_component.segment_size = 1 << 24;
|
||||
#else
|
||||
mca_btl_vader_component.segment_size = 1 << 22;
|
||||
#endif
|
||||
(void) mca_base_component_var_register(&mca_btl_vader_component.super.btl_version,
|
||||
"segment_size", "Maximum size of all shared "
|
||||
#if OMPI_BTL_VADER_HAVE_XPMEM
|
||||
#if OMPI_BTL_VADER_HAVE_XPMEM && 64 == MCA_BTL_VADER_BITNESS
|
||||
"memory buffers (default: 16M)",
|
||||
#else
|
||||
"memory buffers (default: 4M)",
|
||||
@ -273,6 +273,10 @@ static mca_btl_base_module_t **mca_btl_vader_component_init (int *num_btls,
|
||||
mca_btl_vader_component.segment_size = (2 << 20);
|
||||
}
|
||||
|
||||
if (mca_btl_vader_component.segment_size > (1 << MCA_BTL_VADER_OFFSET_BITS)) {
|
||||
mca_btl_vader_component.segment_size = 2 << MCA_BTL_VADER_OFFSET_BITS;
|
||||
}
|
||||
|
||||
#if OMPI_BTL_VADER_HAVE_XPMEM
|
||||
/* create an xpmem segment for the entire memory space */
|
||||
component->my_seg_id = xpmem_make (0, 0xffffffffffffffffll, XPMEM_PERMIT_MODE,
|
||||
|
@ -30,15 +30,27 @@
|
||||
#include "btl_vader_endpoint.h"
|
||||
#include "btl_vader_frag.h"
|
||||
|
||||
#if OPAL_HAVE_ATOMIC_MATH_64
|
||||
#define vader_item_cmpset(x, y, z) opal_atomic_cmpset_64((volatile int64_t *)(x), (int64_t)(y), (int64_t)(z))
|
||||
#define vader_item_swap(x, y) opal_atomic_swap_64((volatile int64_t *)(x), (int64_t)(y))
|
||||
#if SIZEOF_VOID_P == 8
|
||||
#define vader_item_cmpset(x, y, z) opal_atomic_cmpset_64((volatile int64_t *)(x), (int64_t)(y), (int64_t)(z))
|
||||
#define vader_item_swap(x, y) opal_atomic_swap_64((volatile int64_t *)(x), (int64_t)(y))
|
||||
|
||||
#define MCA_BTL_VADER_OFFSET_MASK 0xffffffffll
|
||||
#define MCA_BTL_VADER_OFFSET_BITS 32
|
||||
#define MCA_BTL_VADER_BITNESS 64
|
||||
|
||||
typedef int64_t fifo_value_t;
|
||||
#else
|
||||
#define vader_item_cmpset(x, y, z) opal_atomic_cmpset_32((volatile int32_t *)(x), (int32_t)(y), (int32_t)(z))
|
||||
#define vader_item_swap(x, y) opal_atomic_swap_32((volatile int32_t *)(x), (int32_t)(y))
|
||||
#define vader_item_cmpset(x, y, z) opal_atomic_cmpset_32((volatile int32_t *)(x), (int32_t)(y), (int32_t)(z))
|
||||
#define vader_item_swap(x, y) opal_atomic_swap_32((volatile int32_t *)(x), (int32_t)(y))
|
||||
|
||||
#define MCA_BTL_VADER_OFFSET_MASK 0x00ffffffl
|
||||
#define MCA_BTL_VADER_OFFSET_BITS 24
|
||||
#define MCA_BTL_VADER_BITNESS 32
|
||||
|
||||
typedef int32_t fifo_value_t;
|
||||
#endif
|
||||
|
||||
#define VADER_FIFO_FREE ((intptr_t)-2)
|
||||
#define VADER_FIFO_FREE ((fifo_value_t)-2)
|
||||
|
||||
/*
|
||||
* Shared Memory FIFOs
|
||||
@ -56,17 +68,33 @@
|
||||
|
||||
/* lock free fifo */
|
||||
typedef struct vader_fifo_t {
|
||||
volatile intptr_t fifo_head;
|
||||
volatile intptr_t fifo_tail;
|
||||
volatile fifo_value_t fifo_head;
|
||||
volatile fifo_value_t fifo_tail;
|
||||
} vader_fifo_t;
|
||||
|
||||
/* large enough to ensure the fifo is on its own cache line */
|
||||
#define MCA_BTL_VADER_FIFO_SIZE 128
|
||||
|
||||
/* This only works for finding the relative address for a pointer within my_segment */
|
||||
static inline fifo_value_t virtual2relative (char *addr)
|
||||
{
|
||||
return (fifo_value_t) ((intptr_t) (addr - mca_btl_vader_component.my_segment)) | ((fifo_value_t)MCA_BTL_VADER_LOCAL_RANK << MCA_BTL_VADER_OFFSET_BITS);
|
||||
}
|
||||
|
||||
static inline fifo_value_t virtual2relativepeer (struct mca_btl_base_endpoint_t *endpoint, char *addr)
|
||||
{
|
||||
return (fifo_value_t) ((intptr_t) (addr - endpoint->segment_base)) | ((fifo_value_t)endpoint->peer_smp_rank << MCA_BTL_VADER_OFFSET_BITS);
|
||||
}
|
||||
|
||||
static inline void *relative2virtual (fifo_value_t offset)
|
||||
{
|
||||
return (void *)(intptr_t)((offset & MCA_BTL_VADER_OFFSET_MASK) + mca_btl_vader_component.endpoints[offset >> MCA_BTL_VADER_OFFSET_BITS].segment_base);
|
||||
}
|
||||
|
||||
static inline mca_btl_vader_hdr_t *vader_fifo_read (vader_fifo_t *fifo)
|
||||
{
|
||||
mca_btl_vader_hdr_t *hdr;
|
||||
intptr_t value;
|
||||
fifo_value_t value;
|
||||
|
||||
opal_atomic_rmb ();
|
||||
|
||||
@ -107,9 +135,9 @@ static inline int vader_fifo_init (vader_fifo_t *fifo)
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
static inline void vader_fifo_write (vader_fifo_t *fifo, intptr_t value)
|
||||
static inline void vader_fifo_write (vader_fifo_t *fifo, fifo_value_t value)
|
||||
{
|
||||
intptr_t prev;
|
||||
fifo_value_t prev;
|
||||
|
||||
opal_atomic_wmb ();
|
||||
prev = vader_item_swap (&fifo->fifo_tail, value);
|
||||
|
@ -184,7 +184,8 @@ static int init_vader_endpoint (struct mca_btl_base_endpoint_t *ep, struct ompi_
|
||||
(void) vader_get_registation (ep, modex->segment_base, mca_btl_vader_component.segment_size,
|
||||
MCA_MPOOL_FLAGS_PERSIST, (void **) &ep->segment_base);
|
||||
#else
|
||||
opal_shmem_ds_copy (&modex->seg_ds, &ep->seg_ds);
|
||||
msg_size -= offsetof (struct vader_modex_t, seg_ds);
|
||||
memcpy (&ep->seg_ds, &modex->seg_ds, msg_size);
|
||||
ep->segment_base = opal_shmem_segment_attach (&ep->seg_ds);
|
||||
if (NULL == ep->segment_base) {
|
||||
return rc;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user