1
1
This commit was SVN r6121.
Этот коммит содержится в:
Galen Shipman 2005-06-21 19:38:50 +00:00
родитель 2759fd46c9
Коммит 5154d78981
14 изменённых файлов: 205 добавлений и 228 удалений

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

@ -35,6 +35,17 @@ struct mca_bmi_base_selected_module_t {
};
typedef struct mca_bmi_base_selected_module_t mca_bmi_base_selected_module_t;
/* holds the recv call back function to be called by the bmi on
* a receive.
*/
struct mca_bmi_base_recv_reg_t {
mca_bmi_base_module_recv_cb_fn_t cbfunc;
void* cbdata;
};
typedef struct mca_bmi_base_recv_reg_t mca_bmi_base_recv_reg_t;
OBJ_CLASS_DECLARATION(mca_bmi_base_selected_module_t);
/*

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

@ -349,15 +349,6 @@ typedef void (*mca_bmi_base_module_recv_cb_fn_t)(
);
/* holds the recv call back function to be called by the bmi on
* a receive.
*/
struct mca_bmi_base_registration_t {
mca_bmi_base_module_recv_cb_fn_t cbfunc;
void* cbdata;
};
typedef struct mca_bmi_base_registration_t mca_bmi_base_registration_t;
/**
* Register a callback function that is called on receipt

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

@ -217,6 +217,7 @@ int mca_bmi_ib_free(
mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_src(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* endpoint,
struct mca_bmi_base_registration_t* registration,
struct ompi_convertor_t* convertor,
size_t reserve,
size_t* size
@ -228,7 +229,8 @@ mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_src(
int32_t iov_count = 1;
size_t max_data = *size;
int32_t free_after;
int i, rc;
int rc;
ib_bmi = (mca_bmi_ib_module_t*) bmi;
@ -288,123 +290,88 @@ mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_src(
return &frag->base;
} else {
VAPI_mrw_t mr_in, mr_out;
VAPI_ret_t ret;
mca_common_vapi_memhandle_t mem_hndl;
mca_common_vapi_memhandle_t * mem_hndl_p;
mca_mpool_base_chunk_t * mpool_chunk;
VAPI_mrw_t mr_in, mr_out;
mca_mpool_base_chunk_t * mpool_chunk;
memset(&mr_in, 0, sizeof(VAPI_mrw_t));
memset(&mr_out, 0, sizeof(VAPI_mrw_t));
memset(&mem_hndl, 0, sizeof(mca_common_vapi_memhandle_t));
memset(&mr_in, 0, sizeof(VAPI_mrw_t));
memset(&mr_out, 0, sizeof(VAPI_mrw_t));
mpool_chunk = NULL;
mpool_chunk = NULL;
mem_hndl.hndl = VAPI_INVAL_HNDL;
mr_in.acl = VAPI_EN_LOCAL_WRITE | VAPI_EN_REMOTE_WRITE;
mr_in.l_key = 0;
mr_in.r_key = 0;
mr_in.pd_hndl = ib_bmi->ptag;
mr_in.type = VAPI_MR;
MCA_BMI_IB_FRAG_ALLOC_FRAG(bmi, frag, rc);
if(NULL == frag){
return NULL;
}
mr_in.acl = VAPI_EN_LOCAL_WRITE | VAPI_EN_REMOTE_WRITE;
mr_in.l_key = 0;
mr_in.r_key = 0;
mr_in.pd_hndl = ib_bmi->ptag;
mr_in.type = VAPI_MR;
MCA_BMI_IB_FRAG_ALLOC_FRAG(bmi, frag, rc);
if(NULL == frag){
return NULL;
}
iov.iov_len = max_data;
iov.iov_base = NULL;
ompi_convertor_pack(convertor, &iov, &iov_count, &max_data, &free_after);
/* first we will try to find this address in the memory tree (from MPI_Alloc_mem) */
frag->segment.seg_len = max_data;
frag->segment.seg_addr.pval = iov.iov_base;
if(NULL != registration) {
size_t reg_len;
reg_len = registration->bound - iov.iov_base + 1;
if(frag->segment.seg_len > reg_len) {
iov.iov_len = max_data;
iov.iov_base = NULL;
ompi_convertor_pack(convertor, &iov, &iov_count, &max_data, &free_after);
/* first we will try to find this address in the memory tree (from MPI_Alloc_mem) */
frag->segment.seg_len = max_data;
frag->segment.seg_addr.pval = iov.iov_base;
mpool_chunk = mca_mpool_base_find((void*) iov.iov_base);
if(NULL != mpool_chunk && frag->segment.seg_len > (mpool_chunk->key.top - mpool_chunk->key.bottom + 1)){
for(i = 0; i< MCA_MPOOL_BASE_MAX_REG; i++){
if(NULL != mpool_chunk->mpools[i].mpool && mpool_chunk->mpools[i].mpool == ib_bmi->ib_pool){
mem_hndl = *(mca_common_vapi_memhandle_t*) mpool_chunk->mpools[i].user;
frag->mem_hndl = mem_hndl.hndl;
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
break;
}
}
frag->ret = VAPI_deregister_mr(
ib_bmi->nic,
frag->mem_hndl
);
mca_mpool_base_remove((void*) iov.iov_base);
mpool_chunk = NULL;
}
if(NULL == mpool_chunk) {
mr_in.size = max_data;
mr_in.start = (VAPI_virt_addr_t) (MT_virt_addr_t) iov.iov_base;
ret = VAPI_register_mr(
ib_bmi->nic,
&mr_in,
&mem_hndl.hndl,
&mr_out
);
if(VAPI_OK != ret){
ompi_output(0, "error pinning vapi memory\n");
return NULL;
}
mem_hndl.l_key = mr_out.l_key;
mem_hndl.r_key = mr_out.r_key;
frag->mem_hndl = mem_hndl.hndl;
if(frag->base.des_flags && MCA_BMI_DES_FLAGS_LEAVE_PINNED) {
mem_hndl_p = (mca_common_vapi_memhandle_t*) malloc(sizeof(mca_common_vapi_memhandle_t));
memcpy(mem_hndl_p, &mem_hndl, sizeof(mca_common_vapi_memhandle_t));
rc = mca_mpool_base_insert(iov.iov_base, iov.iov_len, ib_bmi->ib_pool, (void*) mem_hndl_p);
if(rc != OMPI_SUCCESS)
return NULL;
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
}
} else {
for(i = 0; i< MCA_MPOOL_BASE_MAX_REG; i++){
if(NULL != mpool_chunk->mpools[i].mpool && mpool_chunk->mpools[i].mpool == ib_bmi->ib_pool){
mem_hndl = *(mca_common_vapi_memhandle_t*) mpool_chunk->mpools[i].user;
frag->mem_hndl = mem_hndl.hndl;
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
break;
}
}
}
frag->sg_entry.len = max_data;
frag->sg_entry.lkey = mem_hndl.l_key;
frag->sg_entry.addr = (VAPI_virt_addr_t) (MT_virt_addr_t) iov.iov_base;
frag->segment.seg_key.key32[0] = (uint32_t) mem_hndl.l_key;
frag->base.des_src = &frag->segment;
frag->base.des_src_cnt = 1;
frag->base.des_dst = NULL;
frag->base.des_dst_cnt = 0;
return &frag->base;
frag->ret = VAPI_deregister_mr(
ib_bmi->nic,
registration->hndl
);
mca_mpool_base_remove((void*) registration->base);
ib_bmi->ib_pool->mpool_register(ib_bmi->ib_pool,
registration->base,
registration->bound - registration->base + 1 + frag->segment.seg_len - reg_len,
&registration);
}
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
}
else {
ib_bmi->ib_pool->mpool_register(ib_bmi->ib_pool,
iov.iov_base,
max_data,
&registration);
if(frag->base.des_flags && MCA_BMI_DES_FLAGS_LEAVE_PINNED) {
rc = mca_mpool_base_insert(iov.iov_base,
iov.iov_len,
ib_bmi->ib_pool,
&ib_bmi->super,
registration);
if(rc != OMPI_SUCCESS)
return NULL;
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
}
}
frag->mem_hndl = registration->hndl;
frag->sg_entry.len = max_data;
frag->sg_entry.lkey = registration->l_key;
frag->sg_entry.addr = (VAPI_virt_addr_t) (MT_virt_addr_t) iov.iov_base;
frag->segment.seg_key.key32[0] = (uint32_t) registration->l_key;
frag->base.des_src = &frag->segment;
frag->base.des_src_cnt = 1;
frag->base.des_dst = NULL;
frag->base.des_dst_cnt = 0;
return &frag->base;
}
@ -420,6 +387,7 @@ mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_src(
mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_dst(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* endpoint,
struct mca_bmi_base_registration_t* registration,
struct ompi_convertor_t* convertor,
size_t reserve,
size_t* size)
@ -427,26 +395,10 @@ mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_dst(
mca_bmi_ib_module_t* ib_bmi;
mca_bmi_ib_frag_t* frag;
int i, rc;
size_t reg_len;
ib_bmi = (mca_bmi_ib_module_t*) bmi;
VAPI_mrw_t mr_in, mr_out;
VAPI_ret_t ret;
mca_common_vapi_memhandle_t mem_hndl;
mca_common_vapi_memhandle_t *mem_hndl_p;
mca_mpool_base_chunk_t* mpool_chunk;
memset(&mr_in, 0, sizeof(VAPI_mrw_t));
memset(&mr_out, 0, sizeof(VAPI_mrw_t));
memset(&mem_hndl, 0, sizeof(mca_common_vapi_memhandle_t));
mem_hndl.hndl = VAPI_INVAL_HNDL;
mr_in.acl = VAPI_EN_LOCAL_WRITE | VAPI_EN_REMOTE_WRITE;
mr_in.l_key = 0;
mr_in.r_key = 0;
mr_in.pd_hndl = ib_bmi->ptag;
mr_in.type = VAPI_MR;
MCA_BMI_IB_FRAG_ALLOC_FRAG(bmi, frag, rc);
if(NULL == frag){
@ -456,83 +408,56 @@ mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_dst(
frag->segment.seg_len = *size;
frag->segment.seg_addr.pval = convertor->pBaseBuf + convertor->bConverted;
mpool_chunk = mca_mpool_base_find((void*) frag->segment.seg_addr.pval);
if(NULL != mpool_chunk && frag->segment.seg_len > (mpool_chunk->key.top - mpool_chunk->key.bottom + 1)){
for(i = 0; i< MCA_MPOOL_BASE_MAX_REG; i++){
if(NULL != mpool_chunk->mpools[i].mpool && mpool_chunk->mpools[i].mpool == ib_bmi->ib_pool){
mem_hndl = *(mca_common_vapi_memhandle_t*) mpool_chunk->mpools[i].user;
frag->mem_hndl = mem_hndl.hndl;
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
break;
}
}
frag->ret = VAPI_deregister_mr(
ib_bmi->nic,
frag->mem_hndl
);
mca_mpool_base_remove((void*) frag->segment.seg_addr.pval);
mpool_chunk = NULL;
}
if(NULL == mpool_chunk){
mr_in.size = *size;
mr_in.start = (VAPI_virt_addr_t) (MT_virt_addr_t) frag->segment.seg_addr.pval;
ret = VAPI_register_mr(
ib_bmi->nic,
&mr_in,
&mem_hndl.hndl,
&mr_out
);
if(VAPI_OK != ret){
ompi_output(0, "error pinning vapi memory\n");
return NULL;
}
if(NULL!= registration){
if(frag->segment.seg_len > reg_len) {
mem_hndl.l_key = mr_out.l_key;
mem_hndl.r_key = mr_out.r_key;
frag->mem_hndl = mem_hndl.hndl;
frag->ret = VAPI_deregister_mr(
ib_bmi->nic,
registration->hndl
);
mca_mpool_base_remove((void*) registration->base);
ib_bmi->ib_pool->mpool_register(ib_bmi->ib_pool,
registration->base,
registration->bound - registration->base + 1 + frag->segment.seg_len - reg_len,
&registration);
}
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
} else {
ib_bmi->ib_pool->mpool_register(ib_bmi->ib_pool,
frag->segment.seg_addr.pval,
*size,
&registration);
if(frag->base.des_flags && MCA_BMI_DES_FLAGS_LEAVE_PINNED) {
mem_hndl_p = (mca_common_vapi_memhandle_t*) malloc(sizeof(mca_common_vapi_memhandle_t));
memcpy(mem_hndl_p, &mem_hndl, sizeof(mca_common_vapi_memhandle_t));
rc = mca_mpool_base_insert(frag->segment.seg_addr.pval, frag->segment.seg_len, ib_bmi->ib_pool, (void*) mem_hndl_p);
if(rc!=OMPI_SUCCESS)
rc = mca_mpool_base_insert(frag->segment.seg_addr.pval,
*size,
ib_bmi->ib_pool,
&ib_bmi->super,
(void*) registration);
if(rc != OMPI_SUCCESS)
return NULL;
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
}
}
}
else {
if(frag->segment.seg_len > (mpool_chunk->key.top - mpool_chunk->key.bottom + 1)){
ompi_output(0, "%s: segment len is larger than that previously pinned", __func__);
return NULL;
}
for(i = 0; i< MCA_MPOOL_BASE_MAX_REG; i++){
if(NULL != mpool_chunk->mpools[i].mpool && mpool_chunk->mpools[i].mpool == ib_bmi->ib_pool){
mem_hndl = *(mca_common_vapi_memhandle_t*) mpool_chunk->mpools[i].user;
frag->mem_hndl = mem_hndl.hndl;
frag->base.des_flags |= MCA_BMI_DES_FLAGS_PINNED;
break;
}
}
}
frag->mem_hndl = registration->hndl;
frag->sg_entry.len = *size;
frag->sg_entry.lkey = mem_hndl.l_key;
frag->sg_entry.lkey = registration->l_key;
frag->sg_entry.addr = (VAPI_virt_addr_t) (MT_virt_addr_t) frag->segment.seg_addr.pval;
frag->segment.seg_key.key32[0] = (uint32_t) mem_hndl.l_key;
frag->segment.seg_key.key32[0] = (uint32_t) registration->l_key;
frag->base.des_dst = &frag->segment;
frag->base.des_dst_cnt = 1;
frag->base.des_src = NULL;
frag->base.des_src_cnt = 0;
return &frag->base;
}

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

@ -34,8 +34,8 @@
#include "mca/mpool/mpool.h"
#include "bmi_ib_error.h"
/* InfiniBand VAPI includes */
#include "mca/bmi/bmi.h"
#include "mca/bmi/base/base.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
@ -99,7 +99,7 @@ struct mca_bmi_ib_component_t {
extern mca_bmi_ib_component_t mca_bmi_ib_component;
typedef mca_bmi_base_registration_t mca_bmi_ib_registration_t;
typedef mca_bmi_base_recv_reg_t mca_bmi_ib_recv_reg_t;
@ -109,7 +109,7 @@ typedef mca_bmi_base_registration_t mca_bmi_ib_registration_t;
struct mca_bmi_ib_module_t {
mca_bmi_base_module_t super; /**< base PTL interface */
bool bmi_inited;
mca_bmi_ib_registration_t ib_reg[256];
mca_bmi_ib_recv_reg_t ib_reg[256];
VAPI_hca_id_t hca_id; /**< ID of HCA */
IB_port_t port_id; /**< ID of the PORT */
VAPI_hca_port_t port; /**< IB port of this PTL */
@ -339,6 +339,7 @@ extern int mca_bmi_ib_free(
mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_src(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* peer,
struct mca_bmi_base_registration_t* registration,
struct ompi_convertor_t* convertor,
size_t reserve,
size_t* size
@ -354,6 +355,7 @@ mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_src(
extern mca_bmi_base_descriptor_t* mca_bmi_ib_prepare_dst(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* peer,
struct mca_bmi_base_registration_t* registration,
struct ompi_convertor_t* convertor,
size_t reserve,
size_t* size);

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

@ -242,7 +242,7 @@ mca_bmi_base_module_t** mca_bmi_ib_component_init(int *num_bmi_modules,
uint32_t num_hcas;
mca_bmi_base_module_t** bmis;
uint32_t i,j, length;
mca_common_vapi_hca_pd_t hca_pd;
mca_bmi_base_resources_t hca_pd;
ompi_list_t bmi_list;
mca_bmi_ib_module_t * ib_bmi;
mca_bmi_base_selected_module_t* ib_selected;
@ -374,7 +374,9 @@ mca_bmi_base_module_t** mca_bmi_ib_component_init(int *num_bmi_modules,
/* initialize the memory pool using the hca */
ib_bmi->ib_pool =
mca_mpool_base_module_create(mca_bmi_ib_component.ib_mpool_name, &hca_pd);
mca_mpool_base_module_create(mca_bmi_ib_component.ib_mpool_name,
&ib_bmi->super,
&hca_pd);
if(NULL == ib_bmi->ib_pool) {
ompi_output(0, "%s: error creating vapi memory pool! aborting ib bmi initialization", __func__);

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

@ -7,7 +7,7 @@
static void mca_bmi_ib_frag_common_constructor( mca_bmi_ib_frag_t* frag)
{
size_t mod;
mca_common_vapi_memhandle_t* mem_hndl = frag->base.super.user_data;
mca_bmi_base_registration_t* mem_hndl = frag->base.super.user_data;
frag->hdr = (mca_bmi_ib_header_t*) (frag+1); /* initialize the bmi header to point to start at end of frag */
#if 0
mod = (unsigned long) frag->hdr % MCA_BMI_IB_FRAG_ALIGN;

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

@ -29,6 +29,7 @@
#include "event/event.h"
#include "mca/pml/pml.h"
#include "mca/bmi/bmi.h"
#include "mca/bmi/base/base.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
@ -47,7 +48,7 @@ struct mca_bmi_self_component_t {
ompi_free_list_t self_frags_eager; /**< free list of self first */
ompi_free_list_t self_frags_send; /**< free list of self second */
ompi_free_list_t self_frags_rdma; /**< free list of self second */
mca_bmi_base_registration_t self_reg[256];
mca_bmi_base_recv_reg_t self_reg[256];
};
typedef struct mca_bmi_self_component_t mca_bmi_self_component_t;
extern mca_bmi_self_component_t mca_bmi_self_component;

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

@ -1,3 +1,4 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
@ -29,6 +30,8 @@
#include "event/event.h"
#include "mca/pml/pml.h"
#include "mca/bmi/bmi.h"
#include "mca/bmi/base/base.h"
#include "mca/mpool/mpool.h"
#include "mca/common/sm/common_sm_mmap.h"
@ -60,7 +63,7 @@ extern mca_bmi_sm_module_resource_t mca_bmi_sm_module_resource;
#define DONE (char)1
#endif
typedef mca_bmi_base_registration_t mca_bmi_sm_registration_t;
typedef mca_bmi_base_recv_reg_t mca_bmi_sm_recv_reg_t;
/**
@ -164,7 +167,7 @@ extern int mca_bmi_sm_component_progress(void);
struct mca_bmi_sm_t {
mca_bmi_base_module_t super; /**< base BMI interface */
bool bmi_inited; /**< flag indicating if bmi has been inited */
mca_bmi_sm_registration_t sm_reg[256];
mca_bmi_sm_recv_reg_t sm_reg[256];
};
typedef struct mca_bmi_sm_t mca_bmi_sm_t;

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

@ -382,7 +382,7 @@ int mca_bmi_sm_component_progress(void)
case MCA_BMI_SM_FRAG_SEND:
{
/* recv upcall */
mca_bmi_sm_registration_t* reg = mca_bmi_sm[0].sm_reg + frag->tag;
mca_bmi_sm_recv_reg_t* reg = mca_bmi_sm[0].sm_reg + frag->tag;
frag->base.des_dst = frag->base.des_src;
frag->base.des_dst_cnt = frag->base.des_src_cnt;
frag->base.des_src = NULL;
@ -468,7 +468,7 @@ int mca_bmi_sm_component_progress(void)
case MCA_BMI_SM_FRAG_SEND:
{
/* recv upcall */
mca_bmi_sm_registration_t* reg = mca_bmi_sm[0].sm_reg + frag->tag;
mca_bmi_sm_recv_reg_t* reg = mca_bmi_sm[0].sm_reg + frag->tag;
frag->base.des_dst = (mca_bmi_base_segment_t*)
((unsigned char*)frag->base.des_src + mca_bmi_sm_component.sm_offset[peer_smp_rank]);
frag->base.des_dst->seg_addr.pval =

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

@ -35,16 +35,19 @@ typedef struct mca_bmi_base_resources_t mca_bmi_base_resources_t;
struct mca_bmi_base_registration_t {
VAPI_mr_hndl_t hndl;
/* Memory region handle */
VAPI_lkey_t l_key;
/* Local key to registered memory, needed for
* posting send/recv requests */
VAPI_mr_hndl_t hndl;
/* Memory region handle */
VAPI_lkey_t l_key;
/* Local key to registered memory, needed for
* posting send/recv requests */
VAPI_rkey_t r_key;
/* Remote key to registered memory, need to send this
* to remote processes for incoming RDMA ops */
void * base;
void * bound;
VAPI_rkey_t r_key;
/* Remote key to registered memory, need to send this
* to remote processes for incoming RDMA ops */
};
typedef struct mca_bmi_base_registration_t mca_bmi_base_registration_t;

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

@ -25,6 +25,7 @@
#include "class/ompi_rb_tree.h"
#include "mca/mca.h"
#include "mca/mpool/mpool.h"
#include "threads/mutex.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
@ -106,6 +107,7 @@ OMPI_DECLSPEC extern ompi_list_t mca_mpool_base_components;
OMPI_DECLSPEC extern ompi_list_t mca_mpool_base_modules;
OMPI_DECLSPEC extern ompi_free_list_t mca_mpool_base_mem_list;
OMPI_DECLSPEC extern ompi_rb_tree_t mca_mpool_base_tree;
OMPI_DECLSPEC extern ompi_mutex_t tree_lock;
#if defined(c_plusplus) || defined(__cplusplus)
}

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

@ -23,9 +23,12 @@
#endif /* HAVE_STRING_H */
#include "mca/mpool/mpool.h"
#include "mca/mpool/base/base.h"
#include "threads/mutex.h"
ompi_rb_tree_t mca_mpool_base_tree;
ompi_free_list_t mca_mpool_base_mem_list;
static ompi_mutex_t tree_lock;
/**
* Function for the red black tree to compare 2 keys
@ -68,8 +71,12 @@ int mca_mpool_base_insert(void * addr, size_t size,
((mca_mpool_base_chunk_t *) item)->key.bottom = addr;
((mca_mpool_base_chunk_t *) item)->key.top = (void *)
((char *) addr + size - 1);
OMPI_THREAD_LOCK(tree_lock);
rc = ompi_rb_tree_insert(&mca_mpool_base_tree,
&((mca_mpool_base_chunk_t *)item)->key, item);
OMPI_THREAD_UNLOCK(tree_lock);
if(rc != OMPI_SUCCESS)
return rc;
((mca_mpool_base_chunk_t *) item)->mpools[0].mpool = mpool;
@ -88,16 +95,22 @@ int mca_mpool_base_insert(void * addr, size_t size,
*/
int mca_mpool_base_remove(void * base)
{
int rc;
mca_mpool_base_chunk_t * chunk = mca_mpool_base_find(base);
if(NULL == chunk){
return OMPI_ERR_BAD_PARAM;
}
if(OMPI_SUCCESS == ompi_rb_tree_delete(&mca_mpool_base_tree, &chunk->key))
OMPI_THREAD_LOCK(tree_lock);
rc = ompi_rb_tree_delete(&mca_mpool_base_tree, &chunk->key);
OMPI_THREAD_UNLOCK(tree_lock);
if(OMPI_SUCCESS == rc)
return OMPI_SUCCESS;
else
else
return OMPI_ERROR;
}
/**
@ -215,8 +228,12 @@ void * mca_mpool_base_alloc(size_t size, ompi_info_t * info)
((mca_mpool_base_chunk_t *) item)->key.bottom = mem;
((mca_mpool_base_chunk_t *) item)->key.top = (void *)
((char *) mem + size - 1);
OMPI_THREAD_LOCK(tree_lock);
ompi_rb_tree_insert(&mca_mpool_base_tree,
&((mca_mpool_base_chunk_t *)item)->key, item);
OMPI_THREAD_UNLOCK(tree_lock);
return mem;
}
}
@ -279,8 +296,12 @@ void * mca_mpool_base_alloc(size_t size, ompi_info_t * info)
{
((mca_mpool_base_chunk_t *) item)->mpools[num_modules].mpool = NULL;
}
OMPI_THREAD_LOCK(tree_lock);
ompi_rb_tree_insert(&mca_mpool_base_tree,
&((mca_mpool_base_chunk_t *)item)->key, item);
OMPI_THREAD_UNLOCK(tree_lock);
free(has_reg_function);
return mem;
}
@ -309,7 +330,12 @@ int mca_mpool_base_free(void * base)
{
free(chunk->key.bottom);
OMPI_FREE_LIST_RETURN(&mca_mpool_base_mem_list, (ompi_list_item_t*) chunk);
if(OMPI_SUCCESS == ompi_rb_tree_delete(&mca_mpool_base_tree, &chunk->key))
OMPI_THREAD_LOCK(tree_lock);
rc = ompi_rb_tree_delete(&mca_mpool_base_tree, &chunk->key);
OMPI_THREAD_UNLOCK(tree_lock);
if(OMPI_SUCCESS == rc)
return OMPI_SUCCESS;
else
return OMPI_ERROR;
@ -326,7 +352,12 @@ int mca_mpool_base_free(void * base)
}
chunk->mpools[i].mpool->mpool_free(chunk->mpools[i].mpool, chunk->key.bottom);
OMPI_FREE_LIST_RETURN(&mca_mpool_base_mem_list, (ompi_list_item_t *) chunk);
if(OMPI_SUCCESS == ompi_rb_tree_delete(&mca_mpool_base_tree, &chunk->key))
OMPI_THREAD_LOCK(tree_lock);
rc = ompi_rb_tree_delete(&mca_mpool_base_tree, &chunk->key);
OMPI_THREAD_UNLOCK(tree_lock);
if(OMPI_SUCCESS == rc)
return OMPI_SUCCESS;
else
return OMPI_ERROR;

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

@ -24,6 +24,7 @@
#include "mca/mpool/base/base.h"
#include "class/ompi_rb_tree.h"
#include "class/ompi_free_list.h"
#include "threads/mutex.h"
OBJ_CLASS_INSTANCE(mca_mpool_base_selected_module_t, ompi_list_item_t, NULL, NULL);
static bool mca_mpool_enable_progress_threads = true;
@ -47,6 +48,8 @@ int mca_mpool_base_init(bool enable_progress_threads, bool enable_mpi_threads)
ompi_free_list_init(&mca_mpool_base_mem_list, sizeof(mca_mpool_base_chunk_t),
OBJ_CLASS(mca_mpool_base_chunk_t), 0, -1 , 128, NULL);
OBJ_CONSTRUCT(&mca_mpool_base_tree, ompi_rb_tree_t);
OBJ_CONSTRUCT(&tree_lock, ompi_mutex_t);
return ompi_rb_tree_init(&mca_mpool_base_tree, mca_mpool_base_tree_node_compare);
}

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

@ -95,6 +95,9 @@ int mca_mpool_vapi_register(mca_mpool_base_module_t* mpool, void *addr, size_t s
mem_hndl->l_key = mr_out.l_key;
mem_hndl->r_key = mr_out.r_key;
mem_hndl->base = addr;
mem_hndl->bound = (void*) ((char*) addr + size - 1);
return OMPI_SUCCESS;
}