The user provided memory allocation function take one more argument a void*. This can be
set by the caller via the ompi_convertor_personalize call. This commit was SVN r6021.
Этот коммит содержится в:
родитель
1c57ae20b0
Коммит
f11ec2560a
@ -49,11 +49,12 @@ inline int ompi_convertor_cleanup( ompi_convertor_t* convertor )
|
||||
|
||||
static void ompi_convertor_construct( ompi_convertor_t* convertor )
|
||||
{
|
||||
convertor->pDesc = NULL;
|
||||
convertor->pStack = convertor->static_stack;
|
||||
convertor->stack_size = DT_STATIC_STACK_SIZE;
|
||||
convertor->fAdvance = NULL;
|
||||
convertor->memAlloc_fn = NULL;
|
||||
convertor->pDesc = NULL;
|
||||
convertor->pStack = convertor->static_stack;
|
||||
convertor->stack_size = DT_STATIC_STACK_SIZE;
|
||||
convertor->fAdvance = NULL;
|
||||
convertor->memAlloc_fn = NULL;
|
||||
convertor->memAlloc_userdata = NULL;
|
||||
}
|
||||
|
||||
static void ompi_convertor_destruct( ompi_convertor_t* convertor )
|
||||
@ -212,10 +213,12 @@ inline int32_t ompi_convertor_set_position( ompi_convertor_t* convertor, size_t*
|
||||
|
||||
int32_t
|
||||
ompi_convertor_personalize( ompi_convertor_t* convertor, uint32_t flags,
|
||||
size_t* position, memalloc_fct_t allocfn )
|
||||
size_t* position, memalloc_fct_t allocfn, void* userdata )
|
||||
{
|
||||
convertor->flags |= flags;
|
||||
convertor->memAlloc_fn = allocfn;
|
||||
convertor->memAlloc_userdata = userdata;
|
||||
|
||||
return ompi_convertor_set_position( convertor, position );
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef int32_t (*convertor_advance_fct_t)( ompi_convertor_t* pConvertor,
|
||||
uint32_t* inputCount,
|
||||
size_t* max_data,
|
||||
int32_t* freeAfter );
|
||||
typedef void*(*memalloc_fct_t)( size_t* pLength );
|
||||
typedef void*(*memalloc_fct_t)( size_t* pLengthi, void* userdata );
|
||||
|
||||
typedef struct dt_stack {
|
||||
int16_t index; /**< index in the element description */
|
||||
@ -78,6 +78,7 @@ struct ompi_convertor_t {
|
||||
uint32_t stack_size; /**< size of the allocated stack */
|
||||
convertor_advance_fct_t fAdvance; /**< pointer to the pack/unpack functions */
|
||||
memalloc_fct_t memAlloc_fn; /**< pointer to the memory allocation function */
|
||||
void* memAlloc_userdata; /**< user data for the malloc function */
|
||||
conversion_fct_t* pFunctions; /**< the convertor functions pointer */
|
||||
/* All others fields get modified for every call to pack/unpack functions */
|
||||
uint32_t stack_pos; /**< the actual position on the stack */
|
||||
@ -133,7 +134,8 @@ ompi_convertor_set_position( ompi_convertor_t* convertor,
|
||||
OMPI_DECLSPEC int32_t
|
||||
ompi_convertor_personalize( ompi_convertor_t* pConv, uint32_t flags,
|
||||
size_t* starting_point,
|
||||
memalloc_fct_t allocfn );
|
||||
memalloc_fct_t allocfn,
|
||||
void* userdata );
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -84,7 +84,8 @@ int ompi_convertor_pack_general( ompi_convertor_t* pConvertor,
|
||||
if( (*max_data) < length )
|
||||
length = *max_data;
|
||||
iov[iov_count].iov_len = length;
|
||||
iov[iov_count].iov_base = pConvertor->memAlloc_fn( &(iov[iov_count].iov_len) );
|
||||
iov[iov_count].iov_base = pConvertor->memAlloc_fn( &(iov[iov_count].iov_len),
|
||||
pConvertor->memAlloc_userdata );
|
||||
*freeAfter = (*freeAfter) | ( 1 << iov_count);
|
||||
}
|
||||
pInput = iov[iov_count].iov_base;
|
||||
@ -415,7 +416,8 @@ int ompi_convertor_pack_no_conversion( ompi_convertor_t* pConv,
|
||||
/* point to the end of loop element */
|
||||
ddt_endloop_desc_t* end_loop = &(pElems[pos_desc + pElems[pos_desc].loop.items].end_loop);
|
||||
if( iov[iov_pos].iov_base == NULL ) {
|
||||
iov[iov_pos].iov_base = pConv->memAlloc_fn( &(iov[iov_pos].iov_len) );
|
||||
iov[iov_pos].iov_base = pConv->memAlloc_fn( &(iov[iov_pos].iov_len),
|
||||
pConv->memAlloc_userdata );
|
||||
space_on_iovec = iov[iov_pos].iov_len;
|
||||
destination = iov[iov_pos].iov_base;
|
||||
(*freeAfter) |= (1 << iov_pos);
|
||||
@ -499,7 +501,8 @@ int ompi_convertor_pack_no_conversion( ompi_convertor_t* pConv,
|
||||
break;
|
||||
}
|
||||
/* Let's allocate some. */
|
||||
iov[iov_pos].iov_base = pConv->memAlloc_fn( &(iov[iov_pos].iov_len) );
|
||||
iov[iov_pos].iov_base = pConv->memAlloc_fn( &(iov[iov_pos].iov_len),
|
||||
pConv->memAlloc_userdata );
|
||||
(*freeAfter) |= (1 << iov_pos);
|
||||
destination = iov[iov_pos].iov_base;
|
||||
space_on_iovec = iov[iov_pos].iov_len;
|
||||
@ -705,7 +708,8 @@ ompi_convertor_pack_no_conv_contig_with_gaps( ompi_convertor_t* pConv,
|
||||
uint32_t done, counter;
|
||||
|
||||
if( iov[iov_count].iov_base == NULL ) {
|
||||
iov[iov_count].iov_base = pConv->memAlloc_fn( &(iov[iov_count].iov_len) );
|
||||
iov[iov_count].iov_base = pConv->memAlloc_fn( &(iov[iov_count].iov_len),
|
||||
pConv->memAlloc_userdata );
|
||||
(*freeAfter) |= (1 << 0);
|
||||
if( max_allowed < iov[iov_count].iov_len )
|
||||
iov[iov_count].iov_len = max_allowed;
|
||||
@ -761,7 +765,8 @@ ompi_convertor_prepare_for_send( ompi_convertor_t* convertor,
|
||||
}
|
||||
|
||||
convertor->flags |= CONVERTOR_SEND | CONVERTOR_HOMOGENEOUS;
|
||||
convertor->memAlloc_fn = NULL;
|
||||
convertor->memAlloc_fn = NULL;
|
||||
convertor->memAlloc_userdata = NULL;
|
||||
/* Just to avoid complaint from the compiler */
|
||||
convertor->fAdvance = ompi_convertor_pack_general;
|
||||
convertor->fAdvance = ompi_convertor_pack_homogeneous_with_memcpy;
|
||||
|
@ -68,7 +68,7 @@ int32_t ompi_ddt_sndrcv( void *sbuf, int32_t scount, const ompi_datatype_t* sdty
|
||||
if (rdtype == MPI_PACKED) {
|
||||
send_convertor = OBJ_NEW(ompi_convertor_t);
|
||||
ompi_convertor_prepare_for_send( send_convertor, sdtype, scount, sbuf );
|
||||
ompi_convertor_personalize( send_convertor, 0, 0, NULL );
|
||||
ompi_convertor_personalize( send_convertor, 0, 0, NULL, NULL );
|
||||
|
||||
iov_count = 1;
|
||||
iov.iov_len = rcount;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user