1
1

use the same multi-md workaround the rest of the Portals code is using.

This commit was SVN r28761.
Этот коммит содержится в:
Brian Barrett 2013-07-11 21:00:11 +00:00
родитель b5281778b0
Коммит 2f19fc52de
4 изменённых файлов: 115 добавлений и 139 удалений

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

@ -423,14 +423,24 @@ mca_btl_portals4_finalize(struct mca_btl_base_module_t *btl)
PtlMEUnlink(mca_btl_portals4_module.long_overflow_me_h);
PtlMDRelease(mca_btl_portals4_module.zero_md_h);
if (0 != mca_btl_portals4_module.fixed_md_h) {
int i, fixed_md_nb;
#if OMPI_PORTALS4_MAX_MD_SIZE < OMPI_PORTALS4_MAX_VA_SIZE
if (NULL != mca_btl_portals4_module.send_md_hs) {
int i;
int num_mds = mca_btl_portals4_module_get_num_mds();
if (MEMORY_MAX_SIZE > mca_btl_portals4_module.fixed_md_distance) fixed_md_nb = MEMORY_MAX_SIZE/mca_btl_portals4_module.fixed_md_distance;
else fixed_md_nb = 1;
for (i=0; i< fixed_md_nb; i++) PtlMDRelease(mca_btl_portals4_module.fixed_md_h[i]);
free(mca_btl_portals4_module.fixed_md_h);
for (i = 0 ; i < num_mds ; ++i) {
if (!PtlHandleIsEqual(mca_btl_portals4_module.send_md_hs[i], PTL_INVALID_HANDLE)) {
PtlMDRelease(mca_btl_portals4_module.send_md_hs[i]);
}
}
free(mca_btl_portals4_module.send_md_hs);
}
#else
if (!PtlHandleIsEqual(mca_btl_portals4_module.send_md_h, PTL_INVALID_HANDLE)) {
PtlMDRelease(mca_btl_portals4_module.send_md_h);
}
#endif
PtlPTFree(mca_btl_portals4_module.portals_ni_h, mca_btl_portals4_module.recv_idx);

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

@ -103,9 +103,12 @@ struct mca_btl_portals4_module_t {
/** MD handle for sending ACKS */
ptl_handle_md_t zero_md_h;
/** Fixed MD handles covering all of memory for sending normal messages */
ptl_handle_md_t *fixed_md_h;
uint64_t fixed_md_distance;
/** Send MD handle(s). Use ompi_mtl_portals4_get_md() to get the right md */
#if OMPI_PORTALS4_MAX_MD_SIZE < OMPI_PORTALS4_MAX_VA_SIZE
ptl_handle_md_t *send_md_hs;
#else
ptl_handle_md_t send_md_h;
#endif
/** long message receive overflow ME. Persistent ME, first in
overflow list on the recv_idx portal table. */
@ -159,6 +162,36 @@ extern mca_btl_portals4_module_t mca_btl_portals4_module;
hdr_data |= (length & 0xFFFFFFFFFFFFULL); \
}
/*
* See note in ompi/mtl/portals4/mtl_portals4.h for how we deal with
* platforms that don't allow us to crate an MD that covers all of
* memory.
*/
static inline void
ompi_btl_portals4_get_md(const void *ptr, ptl_handle_md_t *md_h, void **base_ptr)
{
#if OMPI_PORTALS4_MAX_MD_SIZE < OMPI_PORTALS4_MAX_VA_SIZE
int mask = (1ULL << (OMPI_PORTALS4_MAX_VA_SIZE - OMPI_PORTALS4_MAX_MD_SIZE + 1)) - 1;
int which = (((uintptr_t) ptr) >> (OMPI_PORTALS4_MAX_MD_SIZE - 1)) & mask;
*md_h = ompi_btl_portals4.send_md_hs[which];
*base_ptr = (void*) (which * (1ULL << (OMPI_PORTALS4_MAX_MD_SIZE - 1)));
#else
*md_h = mca_btl_portals4_module.send_md_h;
*base_ptr = 0;
#endif
}
static inline int
ompi_btl_portals4_get_num_mds(void)
{
#if OMPI_PORTALS4_MAX_MD_SIZE < OMPI_PORTALS4_MAX_VA_SIZE
return (1 << (OMPI_PORTALS4_MAX_VA_SIZE - OMPI_PORTALS4_MAX_MD_SIZE + 1));
#else
return 1;
#endif
}
int mca_btl_portals4_component_progress(void);
/* BTL interface functions */

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

@ -194,9 +194,6 @@ mca_btl_portals4_component_register(void)
static int
mca_btl_portals4_component_open(void)
{
unsigned int i;
uint64_t fixed_md_nb;
mca_btl_portals4_component.portals_verbosity = opal_output_get_verbosity(ompi_btl_base_framework.framework_output);
OPAL_OUTPUT_VERBOSE((1, ompi_btl_base_framework.framework_output, "mca_btl_portals4_component_open\n"));
@ -223,10 +220,11 @@ mca_btl_portals4_component_open(void)
mca_btl_portals4_module.recv_eq_h = PTL_EQ_NONE;
if (48 < ompi_btl_portals4_md_size_bit_width) ompi_btl_portals4_md_size_bit_width = 48;
mca_btl_portals4_module.fixed_md_distance = (unsigned long int) 1<<ompi_btl_portals4_md_size_bit_width;
opal_output_verbose(1, ompi_btl_base_framework.framework_output,
"fixed_md_distance=%16.16lx\n", mca_btl_portals4_module.fixed_md_distance);
#if OMPI_PORTALS4_MAX_MD_SIZE < OMPI_PORTALS4_MAX_VA_SIZE
mca_btl_portals4_module.send_md_hs = NULL;
#else
mca_btl_portals4_module.send_md_h = PTL_INVALID_HANDLE;
#endif
OBJ_CONSTRUCT(&(mca_btl_portals4_module.portals_frag_eager), ompi_free_list_t);
OBJ_CONSTRUCT(&(mca_btl_portals4_module.portals_frag_max), ompi_free_list_t);
@ -273,16 +271,6 @@ mca_btl_portals4_component_open(void)
mca_btl_portals4_module.portals_ni_h = PTL_INVALID_HANDLE;
mca_btl_portals4_module.zero_md_h = PTL_INVALID_HANDLE;
if (MEMORY_MAX_SIZE > mca_btl_portals4_module.fixed_md_distance)
fixed_md_nb = MEMORY_MAX_SIZE/mca_btl_portals4_module.fixed_md_distance;
else fixed_md_nb = 1;
if (fixed_md_nb > 32) mca_btl_portals4_module.fixed_md_distance = 0;
else {
/* Allocate the md_h table */
mca_btl_portals4_module.fixed_md_h = malloc(fixed_md_nb * sizeof(ptl_handle_md_t));
for (i=0; i<fixed_md_nb; i++) mca_btl_portals4_module.fixed_md_h[i] = PTL_INVALID_HANDLE;
}
mca_btl_portals4_module.long_overflow_me_h = PTL_INVALID_HANDLE;
mca_btl_portals4_module.portals_outstanding_ops = 0;
mca_btl_portals4_module.recv_idx = (ptl_pt_index_t) ~0UL;
@ -425,35 +413,42 @@ static mca_btl_base_module_t** mca_btl_portals4_component_init(int *num_btls,
}
OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output, "PtlMDBind (zero-length md) OK\n"));
/* bind fixed md across all of memory */
if (mca_btl_portals4_module.fixed_md_distance) {
unsigned int i;
uint64_t fixed_md_nb, fixed_md_distance;
fixed_md_distance = mca_btl_portals4_module.fixed_md_distance;
if (MEMORY_MAX_SIZE > fixed_md_distance) fixed_md_nb = MEMORY_MAX_SIZE/fixed_md_distance;
else fixed_md_nb = 1;
opal_output_verbose(1, ompi_btl_base_framework.framework_output, "Fixed MDs :\n");
/* Bind the fixed MDs */
for (i=0; i<fixed_md_nb; i++) {
uint64_t offset = i * fixed_md_distance;
/* if the most significant bit of the address space is set, set the extended address bits */
if (offset & (MEMORY_MAX_SIZE >> 1)) offset += EXTENDED_ADDR;
/* Bind MD/MDs across all memory. We prefer (for obvious reasons)
to have a single MD across all of memory */
#if OMPI_PORTALS4_MAX_MD_SIZE < OMPI_PORTALS4_MAX_VA_SIZE
{
int i;
int num_mds = ompi_btl_portals4_get_num_mds();
ptl_size_t size = 1ULL << OMPI_PORTALS4_MAX_MD_SIZE;
ptl_size_t offset_unit = (1ULL << OMPI_PORTALS4_MAX_MD_SIZE) / 2;
mca_btl_portals4_module.send_md_hs = malloc(sizeof(ptl_handle_md_t) * num_mds);
if (NULL == mca_btl_portals4_module.send_md_hs) {
opal_output_verbose(1, ompi_btl_base_framework.framework_output,
" %2d: [ %16lx - %16lx ]\n", i, offset, offset + fixed_md_distance - 2);
"%s:%d: Error allocating MD array",
__FILE__, __LINE__);
ret = OMPI_ERR_TEMP_OUT_OF_RESOURCE;
goto error;
}
md.start = (char *) offset;
md.length = fixed_md_distance - 1;
md.options = 0;
md.eq_handle = mca_btl_portals4_module.recv_eq_h;
for (i = 0 ; i < num_mds ; ++i) {
mca_btl_portals4_module.send_md_hs[i] = PTL_INVALID_HANDLE;
}
for (i = 0 ; i < num_mds ; ++i) {
md.start = (char*) (offset_unit * i);
md.length = (i - 1 == num_mds) ? size / 2 : size;
md.options = 0;
md.eq_handle = mca_btl_portals4_module.send_eq_h;
md.ct_handle = PTL_CT_NONE;
opal_output_verbose(50, ompi_btl_base_framework.framework_output,
"Binding md from %p of length %lx",
md.start, md.length);
ret = PtlMDBind(mca_btl_portals4_module.portals_ni_h,
&md,
&mca_btl_portals4_module.fixed_md_h[i]);
&mca_btl_portals4_module.send_md_hs[i]);
if (PTL_OK != ret) {
opal_output_verbose(1, ompi_btl_base_framework.framework_output,
"%s:%d: PtlMDBind failed: %d\n",
@ -461,9 +456,24 @@ static mca_btl_base_module_t** mca_btl_portals4_component_init(int *num_btls,
goto error;
}
}
OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output, "PtlMDBind (all memory) OK\n"));
}
else opal_output_verbose(1, ompi_btl_base_framework.framework_output, "No fixed MD\n");
#else
md.start = 0;
md.length = PTL_SIZE_MAX;
md.options = 0;
md.eq_handle = mca_btl_portals4_module.recv_eq_h;
md.ct_handle = PTL_CT_NONE;
ret = PtlMDBind(mca_btl_portals4_module.portals_ni_h,
&md,
&mca_btl_portals4_module.send_md_h);
if (PTL_OK != ret) {
opal_output_verbose(1, ompi_btl_base_framework.framework_output,
"%s:%d: PtlMDBind failed: %d\n",
__FILE__, __LINE__, ret);
goto error;
}
#endif
/* Handle long overflows */
me.start = NULL;
@ -505,18 +515,6 @@ static mca_btl_base_module_t** mca_btl_portals4_component_init(int *num_btls,
opal_output_verbose(1, ompi_btl_base_framework.framework_output, "Error in mca_btl_portals4_component_init\n");
free(btls);
if (mca_btl_portals4_module.fixed_md_distance) {
int i;
int fixed_md_nb;
if (MEMORY_MAX_SIZE > mca_btl_portals4_module.fixed_md_distance) fixed_md_nb = MEMORY_MAX_SIZE/mca_btl_portals4_module.fixed_md_distance;
else fixed_md_nb = 1;
for (i=0; i<fixed_md_nb; i++) {
if (!PtlHandleIsEqual(mca_btl_portals4_module.fixed_md_h[i], PTL_INVALID_HANDLE)) {
PtlMDRelease(mca_btl_portals4_module.fixed_md_h[i]);
}
}
}
/* Free also other portals4 resources */
return NULL;
}

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

@ -12,6 +12,7 @@
* Copyright (c) 2008 UT-Battelle, LLC. All rights reserved.
* Copyright (c) 2012 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2013 Sandia National Laboratories. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -25,12 +26,6 @@
#include "btl_portals4.h"
static int mca_btl_portals4_try_to_use_fixed_md(void *start,
int length,
ptl_handle_md_t *md_h,
int64_t *offset,
mca_btl_portals4_frag_t *frag);
int mca_btl_portals4_send(struct mca_btl_base_module_t* btl_base,
struct mca_btl_base_endpoint_t* endpoint,
struct mca_btl_base_descriptor_t* descriptor,
@ -38,15 +33,15 @@ int mca_btl_portals4_send(struct mca_btl_base_module_t* btl_base,
{
mca_btl_portals4_frag_t *frag = (mca_btl_portals4_frag_t*) descriptor;
ptl_match_bits_t match_bits, msglen_type;
ptl_size_t put_length, put_local_offset;
ptl_size_t put_length;
int64_t offset;
ptl_handle_md_t md_h;
void *base;
int ret;
frag->endpoint = endpoint;
frag->hdr.tag = tag;
put_local_offset = (ptl_size_t) frag->segments[0].base.seg_addr.pval;
put_length = frag->segments[0].base.seg_len;
if (put_length > mca_btl_portals4_module.super.btl_eager_limit)
msglen_type = BTL_PORTALS4_LONG_MSG;
@ -54,25 +49,25 @@ int mca_btl_portals4_send(struct mca_btl_base_module_t* btl_base,
BTL_PORTALS4_SET_SEND_BITS(match_bits, 0, 0, tag, msglen_type);
ompi_btl_portals4_get_md(frag->segments[0].base.seg_addr.pval, &md_h, &base);
offset = (ptl_size_t) ((char*) frag->segments[0].base.seg_addr.pval - (char*) base);
/* reserve space in the event queue for rdma operations immediately */
while (OPAL_THREAD_ADD32(&mca_btl_portals4_module.portals_outstanding_ops, 1) >
mca_btl_portals4_module.portals_max_outstanding_ops) {
OPAL_THREAD_ADD32(&mca_btl_portals4_module.portals_outstanding_ops, -1);
OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output, "Call to mca_btl_portals4_component_progress (4)\n"));
OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output,
"Call to mca_btl_portals4_component_progress (4)\n"));
mca_btl_portals4_component_progress();
}
OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output, "mca_btl_portals4_send: Incrementing portals_outstanding_ops=%d\n",
OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output,
"mca_btl_portals4_send: Incrementing portals_outstanding_ops=%d\n",
mca_btl_portals4_module.portals_outstanding_ops));
ret = mca_btl_portals4_try_to_use_fixed_md((void*)put_local_offset, put_length, &md_h, &offset, frag);
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
return ret;
}
OPAL_OUTPUT_VERBOSE((50, ompi_btl_base_framework.framework_output,
"PtlPut frag=%p pid=%x tag=%x addr=%p len=%ld match_bits=%lx\n",
"PtlPut frag=%p pid=%x tag=%x len=%ld match_bits=%lx\n",
(void*)frag, endpoint->ptl_proc.phys.pid, tag,
(void *)put_local_offset, put_length, (uint64_t)match_bits));
put_length, (uint64_t)match_bits));
ret = PtlPut(md_h,
(ptl_size_t) offset,
put_length, /* fragment length */
@ -107,63 +102,3 @@ int mca_btl_portals4_sendi(struct mca_btl_base_module_t* btl_base,
abort();
return OMPI_SUCCESS;
}
static int
mca_btl_portals4_try_to_use_fixed_md(void *start,
int length,
ptl_handle_md_t *md_h,
int64_t *offset,
mca_btl_portals4_frag_t *frag)
{
int ret;
ptl_md_t md;
int64_t addr;
addr = ((int64_t)start & ~EXTENDED_ADDR);
/* If fixed_md_distance is defined for MD and if the memory buffer is strictly contained in one of them, then use one */
if ((0 != mca_btl_portals4_module.fixed_md_distance) &&
(((addr % mca_btl_portals4_module.fixed_md_distance) + length) < mca_btl_portals4_module.fixed_md_distance)) {
if (0 == length) OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output,
" Memory : [ %16lx - (len = 0) ] is in fixed MD number: %d\n",
(unsigned long) start, (int) (addr / mca_btl_portals4_module.fixed_md_distance)));
else OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output,
" Memory : [ %16lx - %16lx ] is in fixed MD number: %d\n",
(unsigned long) start, (long int)start + length - 1, (int)(addr / mca_btl_portals4_module.fixed_md_distance)));
/* Use the fixed MD */
*md_h = mca_btl_portals4_module.fixed_md_h[addr / mca_btl_portals4_module.fixed_md_distance];
*offset = (addr % mca_btl_portals4_module.fixed_md_distance);
frag->md_h = PTL_INVALID_HANDLE;
}
else {
if (0 == mca_btl_portals4_module.fixed_md_distance)
OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output,
"\nWARNING: Memory cannot be connected to a fixed MD\n"));
else OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output,
"\nWARNING: Memory outside the scope of the fixed MD %d\n",
(int)(addr / mca_btl_portals4_module.fixed_md_distance)));
/* Bind the MD (and unbind it where necessary) */
md.start = start;
md.length = length;
md.options = 0;
md.eq_handle = mca_btl_portals4_module.recv_eq_h;
md.ct_handle = PTL_CT_NONE;
ret = PtlMDBind(mca_btl_portals4_module.portals_ni_h,
&md,
&frag->md_h);
if (OPAL_UNLIKELY(PTL_OK != ret)) {
opal_output_verbose(1, ompi_btl_base_framework.framework_output,
"%s:%d: PtlMDBind failed: %d\n",
__FILE__, __LINE__, ret);
return mca_btl_portals4_get_error(ret);
}
*md_h = frag->md_h;
*offset = 0;
}
OPAL_OUTPUT_VERBOSE((90, ompi_btl_base_framework.framework_output, "try_to_use_fixed_md: frag=%p start=%p len=%lx offset=%lx\n",
(void*)frag, (void *)start, (unsigned long)length, (unsigned long)*offset));
return OMPI_SUCCESS;
}