- added routine to ompi_pointer_array to remove array contents
- corrected memory hook callback to catch all allocations (need to optimize this) - don't attempt to consolidate allocations This commit was SVN r7600.
Этот коммит содержится в:
родитель
c7fe54ba44
Коммит
c05ef28f6e
@ -145,6 +145,25 @@ static inline int ompi_pointer_array_get_size(ompi_pointer_array_t *array)
|
||||
OMPI_DECLSPEC bool ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table,
|
||||
int index,
|
||||
void *value);
|
||||
|
||||
/**
|
||||
* Empty the array.
|
||||
*
|
||||
* @param array Pointer to array (IN)
|
||||
*
|
||||
*/
|
||||
static inline void ompi_pointer_array_remove_all(ompi_pointer_array_t *array)
|
||||
{
|
||||
int i;
|
||||
OPAL_THREAD_LOCK(&array->lock);
|
||||
array->lowest_free = 0;
|
||||
array->number_free = array->size;
|
||||
for(i=0; i<array->size; i++) {
|
||||
array->addr[i] = NULL;
|
||||
}
|
||||
OPAL_THREAD_UNLOCK(&array->lock);
|
||||
}
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -242,7 +242,7 @@ int mca_mpool_base_free(void * base)
|
||||
&cnt
|
||||
);
|
||||
if(OMPI_SUCCESS != rc) {
|
||||
goto cleanup;
|
||||
continue;
|
||||
}
|
||||
for(i = 0; i < cnt; i++) {
|
||||
mca_mpool_base_registration_t* reg = (mca_mpool_base_registration_t*)
|
||||
@ -253,6 +253,7 @@ int mca_mpool_base_free(void * base)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
ompi_pointer_array_remove_all(®s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
*/
|
||||
#include "mpool_base_mem_cb.h"
|
||||
#include "base.h"
|
||||
#include "orte/util/proc_info.h"
|
||||
#include "mca/ns/ns_types.h"
|
||||
|
||||
|
||||
extern uint32_t mca_mpool_base_page_size;
|
||||
@ -33,6 +35,7 @@ void mca_mpool_base_mem_cb(void* base, size_t size, void* cbdata)
|
||||
mca_mpool_base_registration_t* reg;
|
||||
mca_mpool_base_selected_module_t* current;
|
||||
int rc;
|
||||
int dereg = 0;
|
||||
opal_list_item_t* item;
|
||||
void* base_addr;
|
||||
void* bound_addr;
|
||||
@ -66,8 +69,8 @@ void mca_mpool_base_mem_cb(void* base, size_t size, void* cbdata)
|
||||
for(i = 0; i < cnt; i++) {
|
||||
|
||||
reg = (mca_mpool_base_registration_t*)ompi_pointer_array_get_item(®s, i);
|
||||
if(base_addr < (void*) ((unsigned long) reg->bound - mca_mpool_base_page_size + 1)) {
|
||||
base_addr = (reg->bound - mca_mpool_base_page_size + 1);
|
||||
if(base_addr < (void*) ((unsigned long) reg->bound - mca_mpool_base_page_size)) {
|
||||
base_addr = reg->bound - mca_mpool_base_page_size;
|
||||
}
|
||||
if(reg->flags & MCA_MPOOL_FLAGS_CACHE) {
|
||||
assert(reg->ref_count <= 3);
|
||||
@ -76,13 +79,26 @@ void mca_mpool_base_mem_cb(void* base, size_t size, void* cbdata)
|
||||
} else {
|
||||
assert(reg->ref_count <= 1);
|
||||
}
|
||||
#if 0
|
||||
fprintf(stderr, "[%lu,%lu,%lu] mca_mpool_base_mem_cb: base %p bound %p len %lu refcnt %d\n",
|
||||
ORTE_NAME_ARGS(orte_process_info.my_name), reg->base, reg->bound,
|
||||
reg->bound-reg->base+1, reg->ref_count);
|
||||
#endif
|
||||
current->mpool_module->mpool_deregister(current->mpool_module, reg);
|
||||
dereg++;
|
||||
}
|
||||
ompi_pointer_array_remove_all(®s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
OBJ_DESTRUCT(®s);
|
||||
#if 0
|
||||
if(dereg != 0) {
|
||||
fprintf(stderr, "[%lu,%lu,%lu] mca_mpool_base_mem_cb: addr %p size %lu base %p bound %p\n",
|
||||
ORTE_NAME_ARGS(orte_process_info.my_name), base, size,
|
||||
down_align_addr( base, mca_mpool_base_page_size_log), bound_addr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,7 +93,6 @@ int mca_mpool_base_open(void)
|
||||
/* get the page size for this architecture*/
|
||||
mca_mpool_base_page_size = sysconf(_SC_PAGESIZE);
|
||||
mca_mpool_base_page_size_log = my_log2(mca_mpool_base_page_size);
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,11 @@
|
||||
#include "ompi_config.h"
|
||||
#include <sched.h>
|
||||
#include "ompi/include/constants.h"
|
||||
#include "orte/util/proc_info.h"
|
||||
#include "mca/pml/pml.h"
|
||||
#include "mca/btl/btl.h"
|
||||
#include "mca/bml/bml.h"
|
||||
#include "mca/ns/ns_types.h"
|
||||
#include "mca/mpool/mpool.h"
|
||||
#include "pml_ob1.h"
|
||||
#include "pml_ob1_rdma.h"
|
||||
@ -39,8 +41,8 @@ size_t mca_pml_ob1_rdma_btls(
|
||||
mca_pml_ob1_rdma_btl_t* rdma_btls)
|
||||
{
|
||||
size_t num_btls = mca_bml_base_btl_array_get_size(&bml_endpoint->btl_rdma);
|
||||
size_t num_btls_used = 0;
|
||||
ompi_pointer_array_t regs;
|
||||
size_t num_btls_used = 0;
|
||||
size_t n;
|
||||
|
||||
/* shortcut when there are no rdma capable btls */
|
||||
@ -68,6 +70,7 @@ size_t mca_pml_ob1_rdma_btls(
|
||||
}
|
||||
|
||||
/* look through existing registrations */
|
||||
ompi_pointer_array_remove_all(®s);
|
||||
btl_mpool->mpool_find(btl_mpool,
|
||||
base,
|
||||
size,
|
||||
@ -91,14 +94,7 @@ size_t mca_pml_ob1_rdma_btls(
|
||||
|
||||
/* otherwise if leave_pinned re-register */
|
||||
} else if( mca_pml_ob1.leave_pinned ) {
|
||||
mca_mpool_base_registration_t reg_temp;
|
||||
unsigned char* new_base = reg->base < base ? reg->base : base;
|
||||
unsigned char* new_bound = reg->bound > (base + size - 1) ? reg->bound : (base + size - 1);
|
||||
size_t new_len = new_bound - new_base + 1;
|
||||
|
||||
/* printf("re-reg 2: base %p size %d new_base %p new_len %d\n", base, size, new_base, new_len); */
|
||||
assert(new_len >= size);
|
||||
reg_temp = *reg;
|
||||
|
||||
btl_mpool->mpool_deregister(btl_mpool, reg);
|
||||
btl_mpool->mpool_register(btl_mpool,
|
||||
base,
|
||||
@ -158,16 +154,13 @@ size_t mca_pml_ob1_rdma_btls(
|
||||
|
||||
/* a registration exists but is not large enough */
|
||||
} else {
|
||||
unsigned char* new_base = largest->base;
|
||||
size_t new_len = (base - largest->base) + size;
|
||||
|
||||
/* simplify cleanup - bump reference count as we decrement again below */
|
||||
btl_mpool->mpool_retain(btl_mpool,largest);
|
||||
btl_mpool->mpool_deregister(btl_mpool, largest);
|
||||
assert(new_len >= size);
|
||||
btl_mpool->mpool_register(btl_mpool,
|
||||
new_base,
|
||||
new_len,
|
||||
base,
|
||||
size,
|
||||
MCA_MPOOL_FLAGS_CACHE,
|
||||
&fit);
|
||||
assert(fit->ref_count == 3);
|
||||
@ -188,7 +181,6 @@ size_t mca_pml_ob1_rdma_btls(
|
||||
num_btls_used++;
|
||||
}
|
||||
}
|
||||
OBJ_DESTRUCT(®s);
|
||||
return num_btls_used;
|
||||
}
|
||||
|
||||
@ -224,7 +216,35 @@ mca_mpool_base_registration_t* mca_pml_ob1_rdma_registration(
|
||||
size,
|
||||
®s,
|
||||
®_cnt);
|
||||
|
||||
assert(reg_cnt <= 1);
|
||||
/* shortcut for one entry - the typical case */
|
||||
if(reg_cnt == 1) {
|
||||
mca_mpool_base_registration_t* reg = ompi_pointer_array_get_item(®s, 0);
|
||||
size_t reg_len = reg->bound - base + 1;
|
||||
|
||||
/* is the existing registration the required size */
|
||||
if(reg->base <= base && reg_len >= size) {
|
||||
return reg;
|
||||
|
||||
/* otherwise if leave_pinned re-register */
|
||||
} else if ( mca_pml_ob1.leave_pinned ) {
|
||||
|
||||
btl_mpool->mpool_deregister(btl_mpool, reg);
|
||||
btl_mpool->mpool_register(btl_mpool,
|
||||
base,
|
||||
size,
|
||||
MCA_MPOOL_FLAGS_CACHE,
|
||||
®);
|
||||
return reg;
|
||||
|
||||
/* existing registration cannot be used */
|
||||
} else {
|
||||
btl_mpool->mpool_release(btl_mpool, reg);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for(r = 0; r < reg_cnt; r++) {
|
||||
mca_mpool_base_registration_t* reg = ompi_pointer_array_get_item(®s, r);
|
||||
size_t reg_len = reg->bound - base + 1;
|
||||
@ -259,14 +279,9 @@ mca_mpool_base_registration_t* mca_pml_ob1_rdma_registration(
|
||||
assert(fit->ref_count >= 3);
|
||||
/* a registration exists but is not large enough */
|
||||
} else {
|
||||
unsigned char* new_base = largest->base < base ? largest->base: base;
|
||||
unsigned char* new_bound = largest->bound > (base + size - 1) ? largest->bound : (base + size - 1);
|
||||
size_t new_len = new_bound - new_base + 1;
|
||||
|
||||
/* printf("re-reg 2: base %p size %d new_base %p new_len %d\n", base, size, new_base, new_len); */
|
||||
|
||||
btl_mpool->mpool_retain(btl_mpool, largest);
|
||||
btl_mpool->mpool_deregister(btl_mpool, largest);
|
||||
assert(new_len >= size);
|
||||
btl_mpool->mpool_register(btl_mpool,
|
||||
base,
|
||||
size,
|
||||
|
@ -403,10 +403,11 @@ static void mca_pml_ob1_recv_request_rget(
|
||||
bml_btl,
|
||||
recvreq->req_recv.req_base.req_addr,
|
||||
recvreq->req_recv.req_bytes_packed);
|
||||
|
||||
recvreq->req_rdma[0].bml_btl = bml_btl;
|
||||
recvreq->req_rdma[0].btl_reg = reg;
|
||||
recvreq->req_rdma_cnt = 1;
|
||||
if(NULL != reg) {
|
||||
recvreq->req_rdma[0].bml_btl = bml_btl;
|
||||
recvreq->req_rdma[0].btl_reg = reg;
|
||||
recvreq->req_rdma_cnt = 1;
|
||||
}
|
||||
|
||||
/* prepare descriptor */
|
||||
mca_bml_base_prepare_dst(
|
||||
|
@ -73,9 +73,6 @@ int mca_rcache_rb_find (
|
||||
}
|
||||
|
||||
|
||||
OBJ_DESTRUCT(regs);
|
||||
OBJ_CONSTRUCT(regs, ompi_pointer_array_t);
|
||||
|
||||
pos = ompi_pointer_array_add(regs, (void*) tree_item->reg);
|
||||
if(0 != pos) {
|
||||
opal_output(0, "error inserting registration in 1st position");
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user