Modified the mpool and allocator to allow user defined data to be passed in and out of the mpool allocate functions, this is necessary if we use the mpool to allocate IB registered memory as need to pass in the hca handle and pass out the memory region handle.
This commit was SVN r5895.
Этот коммит содержится в:
родитель
c80f54052e
Коммит
f16f9703a5
@ -150,7 +150,7 @@ static inline int ompi_cb_fifo_init(int size_of_fifo, int lazy_free_freq,
|
||||
|
||||
/* allocate fifo array */
|
||||
len_to_allocate = sizeof(void *) * fifo->size;
|
||||
fifo->queue=memory_allocator->mpool_alloc(len_to_allocate,CACHE_LINE_SIZE);
|
||||
fifo->queue=memory_allocator->mpool_alloc(memory_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == fifo->queue) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -162,11 +162,11 @@ static inline int ompi_cb_fifo_init(int size_of_fifo, int lazy_free_freq,
|
||||
|
||||
/* change address be relative to the base of the memory segment */
|
||||
fifo->queue=(volatile void **)( (char *)(fifo->queue) -
|
||||
(size_t)(memory_allocator->mpool_base()));
|
||||
(size_t)(memory_allocator->mpool_base(memory_allocator)));
|
||||
|
||||
/* allocate head control structure */
|
||||
len_to_allocate = sizeof(ompi_cb_fifo_ctl_t);
|
||||
fifo->head=memory_allocator->mpool_alloc(len_to_allocate,CACHE_LINE_SIZE);
|
||||
fifo->head=memory_allocator->mpool_alloc(memory_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == fifo->head) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -178,7 +178,7 @@ static inline int ompi_cb_fifo_init(int size_of_fifo, int lazy_free_freq,
|
||||
|
||||
/* allocate tail control structure */
|
||||
len_to_allocate = sizeof(ompi_cb_fifo_ctl_t);
|
||||
fifo->tail=memory_allocator->mpool_alloc(len_to_allocate,CACHE_LINE_SIZE);
|
||||
fifo->tail=memory_allocator->mpool_alloc(memory_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == fifo->tail) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -195,9 +195,9 @@ static inline int ompi_cb_fifo_init(int size_of_fifo, int lazy_free_freq,
|
||||
|
||||
/* change addresses be relative to the base of the memory segment */
|
||||
fifo->head=(ompi_cb_fifo_ctl_t *)( (char *)(fifo->head) -
|
||||
(size_t)(memory_allocator->mpool_base()));
|
||||
(size_t)(memory_allocator->mpool_base(memory_allocator)));
|
||||
fifo->tail=(ompi_cb_fifo_ctl_t *)( (char *)(fifo->tail) -
|
||||
(size_t)(memory_allocator->mpool_base()));
|
||||
(size_t)(memory_allocator->mpool_base(memory_allocator)));
|
||||
|
||||
/* return */
|
||||
return errorCode;
|
||||
@ -226,23 +226,23 @@ static inline int ompi_cb_fifo_free( ompi_cb_fifo_t *fifo,
|
||||
|
||||
/* free fifo array */
|
||||
if( OMPI_CB_NULL != fifo->queue ){
|
||||
ptr=(char *)(fifo->queue)+(size_t)(memory_allocator->mpool_base());
|
||||
memory_allocator->mpool_free(ptr);
|
||||
ptr=(char *)(fifo->queue)+(size_t)(memory_allocator->mpool_base(memory_allocator));
|
||||
memory_allocator->mpool_free(memory_allocator, ptr);
|
||||
fifo->queue=OMPI_CB_NULL;
|
||||
}
|
||||
|
||||
/* free head control structure */
|
||||
if( OMPI_CB_NULL != fifo->head) {
|
||||
ptr=(char *)(fifo->head)+(size_t)(memory_allocator->mpool_base());
|
||||
memory_allocator->mpool_free(ptr);
|
||||
ptr=(char *)(fifo->head)+(size_t)(memory_allocator->mpool_base(memory_allocator));
|
||||
memory_allocator->mpool_free(memory_allocator, ptr);
|
||||
fifo->head=OMPI_CB_NULL;
|
||||
|
||||
}
|
||||
|
||||
/* free tail control structure */
|
||||
if( OMPI_CB_NULL != fifo->tail) {
|
||||
ptr=(char *)(fifo->tail)+(size_t)(memory_allocator->mpool_base());
|
||||
memory_allocator->mpool_free(ptr);
|
||||
ptr=(char *)(fifo->tail)+(size_t)(memory_allocator->mpool_base(memory_allocator));
|
||||
memory_allocator->mpool_free(memory_allocator, ptr);
|
||||
fifo->tail=OMPI_CB_NULL;
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ static inline int ompi_cb_fifo_init_same_base_addr(int size_of_fifo,
|
||||
|
||||
/* allocate fifo array */
|
||||
len_to_allocate = sizeof(void *) * fifo->size;
|
||||
fifo->queue=memory_allocator->mpool_alloc(len_to_allocate,CACHE_LINE_SIZE);
|
||||
fifo->queue=memory_allocator->mpool_alloc(memory_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == fifo->queue) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -495,7 +495,7 @@ static inline int ompi_cb_fifo_init_same_base_addr(int size_of_fifo,
|
||||
|
||||
/* allocate head control structure */
|
||||
len_to_allocate = sizeof(ompi_cb_fifo_ctl_t);
|
||||
fifo->head=memory_allocator->mpool_alloc(len_to_allocate,CACHE_LINE_SIZE);
|
||||
fifo->head=memory_allocator->mpool_alloc(memory_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == fifo->head) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -507,7 +507,7 @@ static inline int ompi_cb_fifo_init_same_base_addr(int size_of_fifo,
|
||||
|
||||
/* allocate tail control structure */
|
||||
len_to_allocate = sizeof(ompi_cb_fifo_ctl_t);
|
||||
fifo->tail=memory_allocator->mpool_alloc(len_to_allocate,CACHE_LINE_SIZE);
|
||||
fifo->tail=memory_allocator->mpool_alloc(memory_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == fifo->tail) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -550,14 +550,14 @@ static inline int ompi_cb_fifo_free_same_base_addr( ompi_cb_fifo_t *fifo,
|
||||
/* free fifo array */
|
||||
if( OMPI_CB_NULL != fifo->head ){
|
||||
ptr=(char *)(fifo->queue);
|
||||
memory_allocator->mpool_free(ptr);
|
||||
memory_allocator->mpool_free(memory_allocator, ptr);
|
||||
fifo->queue=OMPI_CB_NULL;
|
||||
}
|
||||
|
||||
/* free head control structure */
|
||||
if( OMPI_CB_NULL != fifo->head) {
|
||||
ptr=(char *)(fifo->head);
|
||||
memory_allocator->mpool_free(ptr);
|
||||
memory_allocator->mpool_free(memory_allocator, ptr);
|
||||
fifo->head=OMPI_CB_NULL;
|
||||
|
||||
}
|
||||
@ -565,7 +565,7 @@ static inline int ompi_cb_fifo_free_same_base_addr( ompi_cb_fifo_t *fifo,
|
||||
/* free tail control structure */
|
||||
if( OMPI_CB_NULL != fifo->tail) {
|
||||
ptr=(char *)(fifo->tail);
|
||||
memory_allocator->mpool_free(ptr);
|
||||
memory_allocator->mpool_free(memory_allocator, ptr);
|
||||
fifo->tail=OMPI_CB_NULL;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ static inline int ompi_fifo_init(int size_of_cb_fifo, int lazy_free_freq,
|
||||
|
||||
/* allocate head ompi_cb_fifo_t structure */
|
||||
len_to_allocate=sizeof(ompi_cb_fifo_wrapper_t);
|
||||
fifo->head=memory_allocator->mpool_alloc(len_to_allocate,CACHE_LINE_SIZE);
|
||||
fifo->head=memory_allocator->mpool_alloc(memory_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == fifo->head) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -182,7 +182,7 @@ static inline int ompi_fifo_free( ompi_fifo_t *fifo,
|
||||
ff_tmp=(ompi_cb_fifo_wrapper_t *)ff->next_fifo_wrapper;
|
||||
|
||||
/* free the element */
|
||||
memory_allocator->mpool_free(ff);
|
||||
memory_allocator->mpool_free(memory_allocator, ff);
|
||||
|
||||
ff=ff_tmp;
|
||||
|
||||
@ -253,7 +253,7 @@ static inline int ompi_fifo_write_to_head(void *data, ompi_fifo_t
|
||||
/* allocate head ompi_cb_fifo_t structure */
|
||||
len_to_allocate=sizeof(ompi_cb_fifo_wrapper_t);
|
||||
next_ff=fifo_allocator->mpool_alloc
|
||||
(len_to_allocate,CACHE_LINE_SIZE);
|
||||
(fifo_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == next_ff) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -337,7 +337,7 @@ static inline cb_slot_t ompi_fifo_get_slot(ompi_fifo_t *fifo,
|
||||
/* allocate head ompi_cb_fifo_t structure */
|
||||
len_to_allocate=sizeof(ompi_cb_fifo_wrapper_t);
|
||||
next_ff=fifo_allocator->mpool_alloc
|
||||
(len_to_allocate,CACHE_LINE_SIZE);
|
||||
(fifo_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == next_ff) {
|
||||
return_params.index=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
return return_params;
|
||||
@ -446,7 +446,7 @@ static inline int ompi_fifo_init_same_base_addr(int size_of_cb_fifo,
|
||||
|
||||
/* allocate head ompi_cb_fifo_t structure */
|
||||
len_to_allocate=sizeof(ompi_cb_fifo_wrapper_t);
|
||||
fifo->head=memory_allocator->mpool_alloc(len_to_allocate,CACHE_LINE_SIZE);
|
||||
fifo->head=memory_allocator->mpool_alloc(memory_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == fifo->head) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -533,7 +533,7 @@ static inline int ompi_fifo_write_to_head_same_base_addr(void *data,
|
||||
/* allocate head ompi_cb_fifo_t structure */
|
||||
len_to_allocate=sizeof(ompi_cb_fifo_wrapper_t);
|
||||
next_ff=fifo_allocator->mpool_alloc
|
||||
(len_to_allocate,CACHE_LINE_SIZE);
|
||||
(fifo_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == next_ff) {
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -612,7 +612,7 @@ static inline cb_slot_t ompi_fifo_get_slot_same_base_addr(ompi_fifo_t *fifo,
|
||||
/* allocate head ompi_cb_fifo_t structure */
|
||||
len_to_allocate=sizeof(ompi_cb_fifo_wrapper_t);
|
||||
next_ff=fifo_allocator->mpool_alloc
|
||||
(len_to_allocate,CACHE_LINE_SIZE);
|
||||
(fifo_allocator, len_to_allocate,CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == next_ff) {
|
||||
return_params.index=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
return return_params;
|
||||
|
@ -80,7 +80,7 @@ int ompi_free_list_grow(ompi_free_list_t* flist, size_t num_elements)
|
||||
return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
|
||||
|
||||
if (NULL != flist->fl_mpool)
|
||||
ptr = (unsigned char*)flist->fl_mpool->mpool_alloc((num_elements * flist->fl_elem_size) + CACHE_LINE_SIZE, 0);
|
||||
ptr = (unsigned char*)flist->fl_mpool->mpool_alloc(flist->fl_mpool, (num_elements * flist->fl_elem_size) + CACHE_LINE_SIZE, 0, NULL);
|
||||
else
|
||||
ptr = (unsigned char *)malloc((num_elements * flist->fl_elem_size) + CACHE_LINE_SIZE);
|
||||
if(NULL == ptr)
|
||||
|
@ -30,12 +30,12 @@ struct mca_allocator_base_module_t;
|
||||
/**
|
||||
* The allocate function typedef for the functrion to be provided by the component.
|
||||
*/
|
||||
typedef void* (*mca_allocator_base_module_alloc_fn_t)(struct mca_allocator_base_module_t*, size_t size, size_t align);
|
||||
typedef void* (*mca_allocator_base_module_alloc_fn_t)(struct mca_allocator_base_module_t*, size_t size, size_t align, void* user_out);
|
||||
|
||||
/**
|
||||
* The realloc function typedef
|
||||
*/
|
||||
typedef void* (*mca_allocator_base_module_realloc_fn_t)(struct mca_allocator_base_module_t*, void*, size_t);
|
||||
typedef void* (*mca_allocator_base_module_realloc_fn_t)(struct mca_allocator_base_module_t*, void*, size_t, void* user_out);
|
||||
|
||||
/**
|
||||
* Free function typedef
|
||||
@ -72,8 +72,9 @@ struct mca_allocator_base_module_t {
|
||||
/**< Free memory */
|
||||
mca_allocator_base_module_compact_fn_t alc_compact;
|
||||
/**< Return memory */
|
||||
mca_allocator_base_module_finalize_fn_t alc_finalize;
|
||||
mca_allocator_base_module_finalize_fn_t alc_finalize;
|
||||
/**< Finalize and free everything */
|
||||
void* user_in;
|
||||
};
|
||||
/**
|
||||
* Convenience typedef.
|
||||
@ -86,7 +87,7 @@ typedef struct mca_allocator_base_module_t mca_allocator_base_module_t;
|
||||
* provided by the module to the allocator framework.
|
||||
*/
|
||||
|
||||
typedef void* (*mca_allocator_base_component_segment_alloc_fn_t)(size_t* size);
|
||||
typedef void* (*mca_allocator_base_component_segment_alloc_fn_t)(size_t* size, void* user_in, void* user_out);
|
||||
|
||||
/**
|
||||
* A function to free memory from the control of the allocator framework
|
||||
@ -103,7 +104,8 @@ typedef struct mca_allocator_base_module_t*
|
||||
(*mca_allocator_base_component_init_fn_t)(
|
||||
bool enable_mpi_threads,
|
||||
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free,
|
||||
void* user_in
|
||||
);
|
||||
|
||||
/**
|
||||
@ -142,3 +144,22 @@ OMPI_DECLSPEC extern int mca_allocator_base_output;
|
||||
#endif
|
||||
#endif /* MCA_ALLOCATOR_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -76,7 +76,8 @@ int mca_allocator_basic_component_close(void)
|
||||
mca_allocator_base_module_t* mca_allocator_basic_component_init(
|
||||
bool enable_mpi_threads,
|
||||
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free)
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free,
|
||||
void* user_in)
|
||||
{
|
||||
mca_allocator_basic_module_t *module = (mca_allocator_basic_module_t *)
|
||||
malloc(sizeof(mca_allocator_basic_module_t));
|
||||
@ -89,6 +90,7 @@ mca_allocator_base_module_t* mca_allocator_basic_component_init(
|
||||
module->super.alc_free = mca_allocator_basic_free;
|
||||
module->super.alc_compact = mca_allocator_basic_compact;
|
||||
module->super.alc_finalize = mca_allocator_basic_finalize;
|
||||
module->super.user_in = user_in;
|
||||
module->seg_alloc = segment_alloc;
|
||||
module->seg_free = segment_free;
|
||||
OBJ_CONSTRUCT(&module->seg_list, ompi_list_t);
|
||||
@ -158,7 +160,8 @@ static void mca_allocator_basic_combine_next(
|
||||
void *mca_allocator_basic_alloc(
|
||||
mca_allocator_base_module_t * base,
|
||||
size_t size,
|
||||
size_t align)
|
||||
size_t align,
|
||||
void* user_out)
|
||||
{
|
||||
mca_allocator_basic_module_t* module = (mca_allocator_basic_module_t*)base;
|
||||
mca_allocator_basic_segment_t* seg;
|
||||
@ -194,7 +197,7 @@ void *mca_allocator_basic_alloc(
|
||||
|
||||
/* request additional block */
|
||||
allocated_size = (unsigned char)size;
|
||||
if(NULL == (addr = (unsigned char *)module->seg_alloc(&allocated_size))) {
|
||||
if(NULL == (addr = (unsigned char *)module->seg_alloc(&allocated_size, module->super.user_in, user_out))) {
|
||||
OMPI_THREAD_UNLOCK(&module->seg_lock);
|
||||
return NULL;
|
||||
}
|
||||
@ -237,13 +240,14 @@ void *mca_allocator_basic_alloc(
|
||||
void * mca_allocator_basic_realloc(
|
||||
mca_allocator_base_module_t * base,
|
||||
void * ptr,
|
||||
size_t size)
|
||||
size_t size,
|
||||
void* user_out)
|
||||
{
|
||||
unsigned char* addr = ((unsigned char*)ptr) - sizeof(size_t);
|
||||
size_t alloc_size = *(size_t*)addr;
|
||||
if(size <= alloc_size)
|
||||
return ptr;
|
||||
addr = (unsigned char *)mca_allocator_basic_alloc(base,size,0);
|
||||
addr = (unsigned char *)mca_allocator_basic_alloc(base,size,0, user_out);
|
||||
if(addr == NULL)
|
||||
return addr;
|
||||
memcpy(addr,ptr,alloc_size);
|
||||
|
@ -73,7 +73,8 @@ int mca_allocator_basic_component_close(void);
|
||||
mca_allocator_base_module_t* mca_allocator_basic_component_init(
|
||||
bool enable_mpi_threads,
|
||||
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free,
|
||||
void* user_in
|
||||
);
|
||||
|
||||
/**
|
||||
@ -90,7 +91,8 @@ mca_allocator_base_module_t* mca_allocator_basic_component_init(
|
||||
void * mca_allocator_basic_alloc(
|
||||
mca_allocator_base_module_t * mem,
|
||||
size_t size,
|
||||
size_t align);
|
||||
size_t align,
|
||||
void* user_out);
|
||||
|
||||
/**
|
||||
* Attempts to resize the passed region of memory into a larger or a smaller
|
||||
@ -109,7 +111,8 @@ mca_allocator_base_module_t* mca_allocator_basic_component_init(
|
||||
void * mca_allocator_basic_realloc(
|
||||
mca_allocator_base_module_t * mem,
|
||||
void * ptr,
|
||||
size_t size);
|
||||
size_t size,
|
||||
void* user_out);
|
||||
|
||||
/**
|
||||
* Frees the passed region of memory
|
||||
@ -158,3 +161,10 @@ OMPI_COMP_EXPORT extern mca_allocator_base_component_t mca_allocator_basic_compo
|
||||
#endif
|
||||
|
||||
#endif /* ALLOCATOR_BUCKET_ALLOC_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -23,14 +23,16 @@
|
||||
struct mca_allocator_base_module_t* mca_allocator_bucket_module_init(
|
||||
bool enable_mpi_threads,
|
||||
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free);
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free,
|
||||
void* user
|
||||
);
|
||||
|
||||
int mca_allocator_bucket_module_open(void);
|
||||
|
||||
int mca_allocator_bucket_module_close(void);
|
||||
|
||||
void * mca_allocator_bucket_alloc_wrapper(struct mca_allocator_base_module_t* allocator,
|
||||
size_t size, size_t align);
|
||||
size_t size, size_t align, void* user_out);
|
||||
static int mca_allocator_num_buckets;
|
||||
|
||||
|
||||
@ -45,7 +47,8 @@ int mca_allocator_bucket_finalize(struct mca_allocator_base_module_t* allocator)
|
||||
struct mca_allocator_base_module_t* mca_allocator_bucket_module_init(
|
||||
bool enable_mpi_threads,
|
||||
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free)
|
||||
mca_allocator_base_component_segment_free_fn_t segment_free,
|
||||
void* user_in)
|
||||
{
|
||||
size_t alloc_size = sizeof(mca_allocator_bucket_t);
|
||||
mca_allocator_bucket_t * retval;
|
||||
@ -64,7 +67,7 @@ struct mca_allocator_base_module_t* mca_allocator_bucket_module_init(
|
||||
allocator->super.alc_free = mca_allocator_bucket_free;
|
||||
allocator->super.alc_compact = mca_allocator_bucket_cleanup;
|
||||
allocator->super.alc_finalize = mca_allocator_bucket_finalize;
|
||||
|
||||
allocator->super.user_in = user_in;
|
||||
return((mca_allocator_base_module_t *) allocator);
|
||||
}
|
||||
|
||||
@ -80,12 +83,12 @@ int mca_allocator_bucket_module_close(void) {
|
||||
}
|
||||
|
||||
void * mca_allocator_bucket_alloc_wrapper(struct mca_allocator_base_module_t* allocator,
|
||||
size_t size, size_t align)
|
||||
size_t size, size_t align, void* user_out)
|
||||
{
|
||||
if(0 == align){
|
||||
return(mca_allocator_bucket_alloc(allocator, size));
|
||||
return(mca_allocator_bucket_alloc(allocator, size, user_out));
|
||||
}
|
||||
return(mca_allocator_bucket_alloc_align(allocator, size, align));
|
||||
return(mca_allocator_bucket_alloc_align(allocator, size, align, user_out));
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +68,7 @@ mca_allocator_bucket_t * mca_allocator_bucket_init(mca_allocator_base_module_t *
|
||||
*
|
||||
*/
|
||||
void * mca_allocator_bucket_alloc(mca_allocator_base_module_t * mem,
|
||||
size_t size)
|
||||
size_t size, void* user_out)
|
||||
{
|
||||
mca_allocator_bucket_t * mem_options = (mca_allocator_bucket_t *) mem;
|
||||
/* initialize for the later bit shifts */
|
||||
@ -107,7 +107,7 @@ void * mca_allocator_bucket_alloc(mca_allocator_base_module_t * mem,
|
||||
allocated_size += sizeof(mca_allocator_bucket_segment_head_t);
|
||||
/* attempt to get the memory */
|
||||
segment_header = (mca_allocator_bucket_segment_head_t *)
|
||||
mem_options->get_mem_fn(&allocated_size);
|
||||
mem_options->get_mem_fn(&allocated_size, mem_options->super.user_in, user_out);
|
||||
if(NULL == segment_header) {
|
||||
/* release the lock */
|
||||
OMPI_THREAD_UNLOCK(&(mem_options->buckets[bucket_num].lock));
|
||||
@ -148,7 +148,7 @@ void * mca_allocator_bucket_alloc(mca_allocator_base_module_t * mem,
|
||||
* allocates an aligned region of memory
|
||||
*/
|
||||
void * mca_allocator_bucket_alloc_align(mca_allocator_base_module_t * mem,
|
||||
size_t size, size_t alignment)
|
||||
size_t size, size_t alignment, void* user_out)
|
||||
{
|
||||
mca_allocator_bucket_t * mem_options = (mca_allocator_bucket_t *) mem;
|
||||
int bucket_num = 1;
|
||||
@ -168,7 +168,7 @@ void * mca_allocator_bucket_alloc_align(mca_allocator_base_module_t * mem,
|
||||
bucket_size = size;
|
||||
allocated_size = aligned_max_size;
|
||||
/* get some memory */
|
||||
ptr = mem_options->get_mem_fn(&allocated_size);
|
||||
ptr = mem_options->get_mem_fn(&allocated_size, mem_options->super.user_in, user_out);
|
||||
if(NULL == ptr) {
|
||||
return(NULL);
|
||||
}
|
||||
@ -228,7 +228,7 @@ void * mca_allocator_bucket_alloc_align(mca_allocator_base_module_t * mem,
|
||||
* function to reallocate the segment of memory
|
||||
*/
|
||||
void * mca_allocator_bucket_realloc(mca_allocator_base_module_t * mem,
|
||||
void * ptr, size_t size)
|
||||
void * ptr, size_t size, void* user_out)
|
||||
{
|
||||
mca_allocator_bucket_t * mem_options = (mca_allocator_bucket_t *) mem;
|
||||
/* initialize for later bit shifts */
|
||||
@ -249,7 +249,7 @@ void * mca_allocator_bucket_realloc(mca_allocator_base_module_t * mem,
|
||||
return(ptr);
|
||||
}
|
||||
/* we need a new space in memory, so let's get it */
|
||||
ret_ptr = mca_allocator_bucket_alloc((mca_allocator_base_module_t *) mem_options, size);
|
||||
ret_ptr = mca_allocator_bucket_alloc((mca_allocator_base_module_t *) mem_options, size, user_out);
|
||||
if(NULL == ret_ptr) {
|
||||
return(NULL);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ typedef struct mca_allocator_bucket_t mca_allocator_bucket_t;
|
||||
* @retval Pointer to the area of memory if the allocation was successful
|
||||
* @retval NULL if the allocation was unsuccessful
|
||||
*/
|
||||
void * mca_allocator_bucket_alloc(mca_allocator_base_module_t * mem, size_t size);
|
||||
void * mca_allocator_bucket_alloc(mca_allocator_base_module_t * mem, size_t size, void* user_out);
|
||||
|
||||
/**
|
||||
* Accepts a request for memory in a specific region defined by the
|
||||
@ -140,7 +140,7 @@ typedef struct mca_allocator_bucket_t mca_allocator_bucket_t;
|
||||
*
|
||||
*/
|
||||
void * mca_allocator_bucket_alloc_align(mca_allocator_base_module_t * mem,
|
||||
size_t size, size_t alignment);
|
||||
size_t size, size_t alignment, void* user_out);
|
||||
|
||||
/**
|
||||
* Attempts to resize the passed region of memory into a larger or a smaller
|
||||
@ -157,7 +157,7 @@ typedef struct mca_allocator_bucket_t mca_allocator_bucket_t;
|
||||
*
|
||||
*/
|
||||
void * mca_allocator_bucket_realloc(mca_allocator_base_module_t * mem,
|
||||
void * ptr, size_t size);
|
||||
void * ptr, size_t size, void* user_out);
|
||||
|
||||
/**
|
||||
* Frees the passed region of memory
|
||||
|
@ -331,8 +331,8 @@ int mca_bmi_sm_add_procs_same_base_addr(
|
||||
* this can be used by other procs */
|
||||
mca_bmi_sm_component.sm_ctl_header->fifo=
|
||||
mca_bmi_sm_component.sm_mpool->mpool_alloc
|
||||
(n_to_allocate*sizeof(ompi_fifo_t *),
|
||||
CACHE_LINE_SIZE);
|
||||
(mca_bmi_sm_component.sm_mpool, n_to_allocate*sizeof(ompi_fifo_t *),
|
||||
CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == mca_bmi_sm_component.sm_ctl_header->fifo ) {
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
goto CLEANUP;
|
||||
@ -347,7 +347,7 @@ int mca_bmi_sm_add_procs_same_base_addr(
|
||||
mca_bmi_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_segment = ( volatile char **)
|
||||
mca_bmi_sm_component.sm_mpool->mpool_alloc
|
||||
(n_to_allocate*sizeof(char *), CACHE_LINE_SIZE);
|
||||
(mca_bmi_sm_component.sm_mpool, n_to_allocate*sizeof(char *), CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == mca_bmi_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_segment ) {
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
@ -365,7 +365,7 @@ int mca_bmi_sm_add_procs_same_base_addr(
|
||||
mca_bmi_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_flags = ( int *)
|
||||
mca_bmi_sm_component.sm_mpool->mpool_alloc
|
||||
(n_to_allocate*sizeof(int), CACHE_LINE_SIZE);
|
||||
(mca_bmi_sm_component.sm_mpool, n_to_allocate*sizeof(int), CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == mca_bmi_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_flags ) {
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
@ -430,7 +430,7 @@ int mca_bmi_sm_add_procs_same_base_addr(
|
||||
*/
|
||||
my_fifos=( ompi_fifo_t *)
|
||||
mca_bmi_sm_component.sm_mpool->mpool_alloc
|
||||
(n_to_allocate*sizeof(ompi_fifo_t), CACHE_LINE_SIZE);
|
||||
(mca_bmi_sm_component.sm_mpool, n_to_allocate*sizeof(ompi_fifo_t), CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == my_fifos ) {
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
goto CLEANUP;
|
||||
|
@ -212,7 +212,7 @@ mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
|
||||
*
|
||||
* @retval addr virtual address
|
||||
*/
|
||||
void* mca_common_sm_mmap_alloc(size_t* size)
|
||||
void* mca_common_sm_mmap_alloc(size_t* size, void* user_in, void* user_out)
|
||||
{
|
||||
mca_common_sm_mmap_t* map = mca_common_sm_mmap;
|
||||
mca_common_sm_file_header_t* seg = map->map_seg;
|
||||
|
@ -88,7 +88,7 @@ OBJ_CLASS_DECLARATION(mca_common_sm_mmap_t);
|
||||
|
||||
mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
|
||||
size_t size_ctl_structure, size_t data_seg_alignment);
|
||||
void* mca_common_sm_mmap_alloc(size_t* size);
|
||||
void* mca_common_sm_mmap_alloc(size_t* size, void* user_in, void* user_out);
|
||||
void mca_common_sm_mmap_free(void* addr);
|
||||
|
||||
/*
|
||||
|
@ -70,8 +70,7 @@ mca_mpool_base_module_t* mca_mpool_base_module_init(const char* name)
|
||||
ompi_output_verbose(10, mca_mpool_base_output,
|
||||
"select: no init function; ignoring module");
|
||||
} else {
|
||||
module = component->mpool_init(mca_mpool_enable_progress_threads,
|
||||
mca_mpool_enable_mpi_threads);
|
||||
module = component->mpool_init(NULL);
|
||||
|
||||
/* If the module didn't initialize, unload it */
|
||||
|
||||
|
@ -54,11 +54,15 @@ mca_mpool_base_module_t* mca_mpool_base_module_lookup(const char* name)
|
||||
mca_mpool_base_selected_module_t *sm = (mca_mpool_base_selected_module_t *) item;
|
||||
if(strcmp(sm->mpool_component->mpool_version.mca_component_name,
|
||||
name) == 0) {
|
||||
return sm->mpool_module;
|
||||
return sm->mpool_module;
|
||||
}
|
||||
}
|
||||
|
||||
/* if not create it */
|
||||
return mca_mpool_base_module_init(name);;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -28,42 +28,42 @@ struct mca_mpool_t;
|
||||
* component initialize
|
||||
*/
|
||||
typedef struct mca_mpool_base_module_t* (*mca_mpool_base_component_init_fn_t)
|
||||
(bool enable_progress_threads, bool enable_mpi_threads);
|
||||
(void* user_in);
|
||||
|
||||
/**
|
||||
* if appropriate - returns base address of memory pool
|
||||
*/
|
||||
typedef void* (*mca_mpool_base_module_address_fn_t)(void);
|
||||
typedef void* (*mca_mpool_base_module_address_fn_t)(struct mca_mpool_base_module_t* mpool);
|
||||
|
||||
/**
|
||||
* allocate function typedef
|
||||
*/
|
||||
typedef void* (*mca_mpool_base_module_alloc_fn_t)(size_t size, size_t align);
|
||||
typedef void* (*mca_mpool_base_module_alloc_fn_t)(struct mca_mpool_base_module_t* mpool, size_t size, size_t align, void* user_out);
|
||||
|
||||
/**
|
||||
* allocate function typedef
|
||||
*/
|
||||
typedef void* (*mca_mpool_base_module_alloc_and_register_fn_t)(size_t size, size_t align, void* user);
|
||||
typedef void* (*mca_mpool_base_module_alloc_and_register_fn_t)(struct mca_mpool_base_module_t* mpool,size_t size, size_t align, void* user_out);
|
||||
|
||||
/**
|
||||
* realloc function typedef
|
||||
*/
|
||||
typedef void* (*mca_mpool_base_module_realloc_fn_t)(void* addr, size_t size);
|
||||
typedef void* (*mca_mpool_base_module_realloc_fn_t)(struct mca_mpool_base_module_t* mpool, void* addr, size_t size, void* user_out);
|
||||
|
||||
/**
|
||||
* free function typedef
|
||||
*/
|
||||
typedef void (*mca_mpool_base_module_free_fn_t)(void *);
|
||||
typedef void (*mca_mpool_base_module_free_fn_t)(struct mca_mpool_base_module_t* mpool, void *);
|
||||
|
||||
/**
|
||||
* register memory
|
||||
*/
|
||||
typedef int (*mca_mpool_base_module_register_fn_t)(void * addr, size_t size, void* user);
|
||||
typedef int (*mca_mpool_base_module_register_fn_t)(struct mca_mpool_base_module_t* mpool, void * addr, size_t size, void** user_out);
|
||||
|
||||
/**
|
||||
* deregister memory
|
||||
*/
|
||||
typedef int (*mca_mpool_base_module_deregister_fn_t)(void * addr, size_t size);
|
||||
typedef int (*mca_mpool_base_module_deregister_fn_t)(struct mca_mpool_base_module_t* mpool, void * addr, size_t size);
|
||||
|
||||
/**
|
||||
* finalize
|
||||
|
@ -29,36 +29,50 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
struct mca_mpool_sm_component_t {
|
||||
mca_mpool_base_component_t super;
|
||||
mca_allocator_base_module_t* sm_allocator;
|
||||
char* sm_allocator_name;
|
||||
size_t sm_size;
|
||||
struct mca_mpool_sm_mmap_t *sm_mmap;
|
||||
mca_mpool_base_component_t super;
|
||||
/* mca_allocator_base_module_t* sm_allocator; */
|
||||
char* sm_allocator_name;
|
||||
size_t sm_size;
|
||||
/* struct mca_mpool_sm_mmap_t *sm_mmap; */
|
||||
};
|
||||
typedef struct mca_mpool_sm_component_t mca_mpool_sm_component_t;
|
||||
|
||||
OMPI_COMP_EXPORT extern mca_mpool_sm_component_t mca_mpool_sm_component;
|
||||
OMPI_COMP_EXPORT extern mca_mpool_base_module_t mca_mpool_sm_module;
|
||||
/* OMPI_COMP_EXPORT extern mca_mpool_base_module_t mca_mpool_sm_module; */
|
||||
|
||||
|
||||
|
||||
struct mca_mpool_sm_module_t {
|
||||
mca_mpool_base_module_t super;
|
||||
mca_allocator_base_module_t * sm_allocator;
|
||||
struct mca_mpool_sm_mmap_t *sm_mmap;
|
||||
}; typedef struct mca_mpool_sm_module_t mca_mpool_sm_module_t;
|
||||
|
||||
/*
|
||||
* Initializes the mpool module.
|
||||
*/
|
||||
void mca_mpool_sm_module_init(mca_mpool_sm_module_t* mpool);
|
||||
|
||||
|
||||
/*
|
||||
* Returns base address of shared memory mapping.
|
||||
*/
|
||||
void* mca_mpool_sm_base(void);
|
||||
void* mca_mpool_sm_base(mca_mpool_base_module_t*);
|
||||
|
||||
/**
|
||||
* Allocate block of shared memory.
|
||||
*/
|
||||
void* mca_mpool_sm_alloc(size_t size, size_t align);
|
||||
void* mca_mpool_sm_alloc( mca_mpool_base_module_t* mpool, size_t size, size_t align, void* user_out);
|
||||
|
||||
/**
|
||||
* realloc function typedef
|
||||
*/
|
||||
void* mca_mpool_sm_realloc(void* addr, size_t size);
|
||||
void* mca_mpool_sm_realloc(mca_mpool_base_module_t* mpool, void* addr, size_t size, void* user_out);
|
||||
|
||||
/**
|
||||
* free function typedef
|
||||
*/
|
||||
void mca_mpool_sm_free(void *);
|
||||
void mca_mpool_sm_free(mca_mpool_base_module_t* mpool, void *);
|
||||
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
@ -66,3 +80,18 @@ void mca_mpool_sm_free(void *);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -28,9 +28,7 @@
|
||||
* Local functions
|
||||
*/
|
||||
static int mca_mpool_sm_open(void);
|
||||
static mca_mpool_base_module_t* mca_mpool_sm_init(bool enable_progress_threads,
|
||||
bool enable_mpi_threads);
|
||||
|
||||
static mca_mpool_base_module_t* mca_mpool_sm_init(void* user);
|
||||
|
||||
mca_mpool_sm_component_t mca_mpool_sm_component = {
|
||||
{
|
||||
@ -97,13 +95,11 @@ static int mca_mpool_sm_open(void)
|
||||
}
|
||||
|
||||
|
||||
static mca_mpool_base_module_t*
|
||||
mca_mpool_sm_init(bool enable_progress_threads,
|
||||
bool enable_mpi_threads)
|
||||
static mca_mpool_base_module_t* mca_mpool_sm_init(void * user_in)
|
||||
{
|
||||
char *file_name;
|
||||
int len;
|
||||
|
||||
mca_mpool_sm_module_t* mpool_module;
|
||||
mca_allocator_base_component_t* allocator_component = mca_allocator_component_lookup(
|
||||
mca_mpool_sm_component.sm_allocator_name);
|
||||
|
||||
@ -122,6 +118,10 @@ mca_mpool_sm_init(bool enable_progress_threads,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mpool_module = (mca_mpool_sm_module_t*)malloc(sizeof(mca_mpool_sm_module_t));
|
||||
mca_mpool_sm_module_init(mpool_module);
|
||||
|
||||
/* create initial shared memory mapping */
|
||||
len=asprintf(&file_name,"%s/shared_mem_pool.%s",
|
||||
orte_process_info.job_session_dir,
|
||||
@ -145,14 +145,24 @@ mca_mpool_sm_init(bool enable_progress_threads,
|
||||
/* setup function pointers */
|
||||
|
||||
|
||||
/* setup allocator */
|
||||
mca_mpool_sm_component.sm_allocator =
|
||||
allocator_component->allocator_init(enable_mpi_threads,
|
||||
mca_common_sm_mmap_alloc, NULL);
|
||||
if(NULL == mca_mpool_sm_component.sm_allocator) {
|
||||
ompi_output(0, "mca_mpool_sm_init: unable to initialize allocator");
|
||||
/* setup allocator TODO fix up */
|
||||
mpool_module->sm_allocator =
|
||||
allocator_component->allocator_init(true,
|
||||
mca_common_sm_mmap_alloc, NULL, NULL);
|
||||
if(NULL == mpool_module->sm_allocator) {
|
||||
ompi_output(0, "mca_mpool_sm_init: unable to initialize allocator");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &mca_mpool_sm_module;
|
||||
|
||||
return &mpool_module->super;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,21 +21,36 @@
|
||||
#include "mca/common/sm/common_sm_mmap.h"
|
||||
|
||||
|
||||
mca_mpool_base_module_t mca_mpool_sm_module = {
|
||||
&mca_mpool_sm_component.super,
|
||||
mca_mpool_sm_base,
|
||||
mca_mpool_sm_alloc,
|
||||
mca_mpool_sm_realloc,
|
||||
mca_mpool_sm_free,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
/*
|
||||
* Initializes the mpool module.
|
||||
*/
|
||||
void mca_mpool_sm_module_init(mca_mpool_sm_module_t* mpool)
|
||||
{
|
||||
mpool->super.mpool_component = &mca_mpool_sm_component.super;
|
||||
mpool->super.mpool_base = mca_mpool_sm_base;
|
||||
mpool->super.mpool_alloc = mca_mpool_sm_alloc;
|
||||
mpool->super.mpool_realloc = mca_mpool_sm_realloc;
|
||||
mpool->super.mpool_free = mca_mpool_sm_free;
|
||||
mpool->super.mpool_register = NULL;
|
||||
mpool->super.mpool_deregister = NULL;
|
||||
mpool->super.mpool_finalize = NULL;
|
||||
|
||||
}
|
||||
/* mca_mpool_base_module_t mca_mpool_sm_module = { */
|
||||
/* &mca_mpool_sm_component.super, */
|
||||
/* mca_mpool_sm_base, */
|
||||
/* mca_mpool_sm_alloc, */
|
||||
/* mca_mpool_sm_realloc, */
|
||||
/* mca_mpool_sm_free, */
|
||||
/* NULL, */
|
||||
/* NULL */
|
||||
/* }; */
|
||||
|
||||
|
||||
/*
|
||||
* base address of shared memory mapping
|
||||
*/
|
||||
void* mca_mpool_sm_base(void)
|
||||
void* mca_mpool_sm_base(mca_mpool_base_module_t* mpool)
|
||||
{
|
||||
return (mca_common_sm_mmap != NULL) ? mca_common_sm_mmap->map_addr : NULL;
|
||||
}
|
||||
@ -43,23 +58,26 @@ void* mca_mpool_sm_base(void)
|
||||
/**
|
||||
* allocate function
|
||||
*/
|
||||
void* mca_mpool_sm_alloc(size_t size, size_t align)
|
||||
void* mca_mpool_sm_alloc(mca_mpool_base_module_t* mpool, size_t size, size_t align, void* user_out)
|
||||
{
|
||||
return mca_mpool_sm_component.sm_allocator->alc_alloc(mca_mpool_sm_component.sm_allocator, size, align);
|
||||
mca_mpool_sm_module_t* mpool_sm = (mca_mpool_sm_module_t*)mpool;
|
||||
return mpool_sm->sm_allocator->alc_alloc(mpool_sm->sm_allocator, size, align, user_out);
|
||||
}
|
||||
|
||||
/**
|
||||
* realloc function
|
||||
*/
|
||||
void* mca_mpool_sm_realloc(void* addr, size_t size)
|
||||
void* mca_mpool_sm_realloc(mca_mpool_base_module_t* mpool, void* addr, size_t size, void* user_out)
|
||||
{
|
||||
return mca_mpool_sm_component.sm_allocator->alc_realloc(mca_mpool_sm_component.sm_allocator, addr, size);
|
||||
mca_mpool_sm_module_t* mpool_sm = (mca_mpool_sm_module_t*)mpool;
|
||||
return mpool_sm->sm_allocator->alc_realloc(mpool_sm->sm_allocator, addr, size, user_out);
|
||||
}
|
||||
|
||||
/**
|
||||
* free function
|
||||
*/
|
||||
void mca_mpool_sm_free(void * addr)
|
||||
void mca_mpool_sm_free(mca_mpool_base_module_t* mpool, void * addr)
|
||||
{
|
||||
mca_mpool_sm_component.sm_allocator->alc_free(mca_mpool_sm_component.sm_allocator, addr);
|
||||
mca_mpool_sm_module_t* mpool_sm = (mca_mpool_sm_module_t*)mpool;
|
||||
mpool_sm->sm_allocator->alc_free(mpool_sm->sm_allocator, addr);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ int mca_pml_base_bsend_attach(void* addr, int size)
|
||||
}
|
||||
|
||||
/* try to create an instance of the allocator - to determine thread safety level */
|
||||
mca_pml_bsend_allocator = mca_pml_bsend_allocator_component->allocator_init(thread_safe, mca_pml_bsend_alloc_segment, NULL);
|
||||
mca_pml_bsend_allocator = mca_pml_bsend_allocator_component->allocator_init(thread_safe, mca_pml_bsend_alloc_segment, NULL, NULL);
|
||||
if(NULL == mca_pml_bsend_allocator) {
|
||||
OMPI_THREAD_UNLOCK(&mca_pml_bsend_mutex);
|
||||
return OMPI_ERR_BUFFER;
|
||||
@ -204,7 +204,7 @@ int mca_pml_base_bsend_request_start(ompi_request_t* request)
|
||||
|
||||
/* allocate a buffer to hold packed message */
|
||||
sendreq->req_addr = mca_pml_bsend_allocator->alc_alloc(
|
||||
mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0);
|
||||
mca_pml_bsend_allocator, sendreq->req_bytes_packed, 0, NULL);
|
||||
if(NULL == sendreq->req_addr) {
|
||||
/* release resources when request is freed */
|
||||
sendreq->req_base.req_pml_complete = true;
|
||||
|
@ -236,7 +236,7 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
goto CLEANUP;
|
||||
}
|
||||
mca_ptl_sm_component.sm_mpool_base =
|
||||
mca_ptl_sm_component.sm_mpool->mpool_base();
|
||||
mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool);
|
||||
}
|
||||
|
||||
/* make sure that my_smp_rank has been defined */
|
||||
@ -327,8 +327,8 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
* for any access to these queues to ensure data consistancy when
|
||||
* the array is grown */
|
||||
|
||||
if(0 == mca_ptl_sm_component.my_smp_rank ) {
|
||||
/* allocate ompi_fifo_t strucutes for each fifo of the queue
|
||||
if(0 == mca_ptl_sm_component.my_smp_rank ) { /* show TIM */
|
||||
/* allocate ompi_fifo_t strucutes for each fifo of the queue
|
||||
* pairs - one per pair of local processes */
|
||||
/* check to make sure number of local procs is within the
|
||||
* specified limits */
|
||||
@ -343,8 +343,8 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
* this can be used by other procs */
|
||||
mca_ptl_sm_component.sm_ctl_header->fifo=
|
||||
mca_ptl_sm_component.sm_mpool->mpool_alloc
|
||||
(n_to_allocate*sizeof(ompi_fifo_t *),
|
||||
CACHE_LINE_SIZE);
|
||||
(mca_ptl_sm_component.sm_mpool, n_to_allocate*sizeof(ompi_fifo_t *),
|
||||
CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == mca_ptl_sm_component.sm_ctl_header->fifo ) {
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
goto CLEANUP;
|
||||
@ -359,7 +359,7 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
mca_ptl_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_segment = ( volatile char **)
|
||||
mca_ptl_sm_component.sm_mpool->mpool_alloc
|
||||
(n_to_allocate*sizeof(char *), CACHE_LINE_SIZE);
|
||||
(mca_ptl_sm_component.sm_mpool, n_to_allocate*sizeof(char *), CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == mca_ptl_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_segment ) {
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
@ -377,7 +377,7 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
mca_ptl_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_flags = ( int *)
|
||||
mca_ptl_sm_component.sm_mpool->mpool_alloc
|
||||
(n_to_allocate*sizeof(int), CACHE_LINE_SIZE);
|
||||
(mca_ptl_sm_component.sm_mpool, n_to_allocate*sizeof(int), CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == mca_ptl_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_flags ) {
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
@ -393,16 +393,16 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
mca_ptl_sm_component.sm_ctl_header->fifo=
|
||||
(volatile ompi_fifo_t **)
|
||||
( (char *)(mca_ptl_sm_component.sm_ctl_header->fifo)-
|
||||
(char *)(mca_ptl_sm_component.sm_mpool->mpool_base()) );
|
||||
(char *)(mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool)) );
|
||||
|
||||
mca_ptl_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_segment=( volatile char **)
|
||||
( (char *)(mca_ptl_sm_component.sm_ctl_header->
|
||||
segment_header.base_shared_mem_segment) -
|
||||
(char *)(mca_ptl_sm_component.sm_mpool->mpool_base()) );
|
||||
(char *)(mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool)) );
|
||||
|
||||
/* allow other procs to use this shared memory map */
|
||||
mca_ptl_sm_component.mmap_file->map_seg->seg_inited=true;
|
||||
mca_ptl_sm_component.mmap_file->map_seg->seg_inited=true;
|
||||
|
||||
/* memory barrier to ensure this flag is set before other
|
||||
* flags are set */
|
||||
@ -423,9 +423,9 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
tmp_ptr=(volatile char **)
|
||||
( (char *)(mca_ptl_sm_component.sm_ctl_header->segment_header.
|
||||
base_shared_mem_segment) +
|
||||
(long )(mca_ptl_sm_component.sm_mpool->mpool_base()) );
|
||||
(long )(mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool)) );
|
||||
tmp_ptr[mca_ptl_sm_component.my_smp_rank]=
|
||||
mca_ptl_sm_component.sm_mpool->mpool_base();
|
||||
mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool);
|
||||
/* memory barrier to ensure this flag is set before other
|
||||
* flags are set */
|
||||
ompi_atomic_mb();
|
||||
@ -442,7 +442,7 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
*/
|
||||
my_fifos=( ompi_fifo_t *)
|
||||
mca_ptl_sm_component.sm_mpool->mpool_alloc
|
||||
(n_to_allocate*sizeof(ompi_fifo_t), CACHE_LINE_SIZE);
|
||||
(mca_ptl_sm_component.sm_mpool, n_to_allocate*sizeof(ompi_fifo_t), CACHE_LINE_SIZE, NULL);
|
||||
if ( NULL == my_fifos ) {
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
goto CLEANUP;
|
||||
@ -456,7 +456,7 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
}
|
||||
fifo_tmp=(ompi_fifo_t * volatile *)
|
||||
( (char *)(mca_ptl_sm_component.sm_ctl_header->fifo) +
|
||||
(long)(mca_ptl_sm_component.sm_mpool->mpool_base()) );
|
||||
(long)(mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool)) );
|
||||
/* RLG : need memory barrier */
|
||||
fifo_tmp[mca_ptl_sm_component.my_smp_rank]=my_fifos;
|
||||
|
||||
@ -474,7 +474,7 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
/* cache the pointers to the rest of the fifo arrays */
|
||||
fifo_tmp=(ompi_fifo_t * volatile *)
|
||||
( (char *)(mca_ptl_sm_component.sm_ctl_header->fifo) +
|
||||
(long)(mca_ptl_sm_component.sm_mpool->mpool_base()) );
|
||||
(long)(mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool)) );
|
||||
for( j=mca_ptl_sm_component.num_smp_procs ; j <
|
||||
mca_ptl_sm_component.num_smp_procs+n_local_procs ; j++ ) {
|
||||
|
||||
@ -485,7 +485,7 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
tmp_ptr=(volatile char **)
|
||||
( (char *)mca_ptl_sm_component.sm_ctl_header->
|
||||
segment_header.base_shared_mem_segment +
|
||||
(long)mca_ptl_sm_component.sm_mpool->mpool_base());
|
||||
(long)mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool));
|
||||
diff= tmp_ptr[mca_ptl_sm_component.my_smp_rank]-tmp_ptr[j];
|
||||
mca_ptl_sm_component.fifo[j]=
|
||||
( ompi_fifo_t *)( (char *)fifo_tmp[j]+diff);
|
||||
@ -564,7 +564,7 @@ int mca_ptl_sm_add_procs_same_base_addr(
|
||||
tmp_ptr=(volatile char **)
|
||||
( (char *)mca_ptl_sm_component.sm_ctl_header->
|
||||
segment_header.base_shared_mem_segment +
|
||||
(long)mca_ptl_sm_component.sm_mpool->mpool_base());
|
||||
(long)mca_ptl_sm_component.sm_mpool->mpool_base(mca_ptl_sm_component.sm_mpool));
|
||||
same_sm_base=(tmp_ptr[peer->peer_smp_rank] ==
|
||||
tmp_ptr[mca_ptl_sm_component.my_smp_rank]);
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user