Add 3 functions for Galen. The allow to import, export and reset the
pending bytes from the convertor. These bytes are used to handle partial conversions between peers. This commit was SVN r9531.
Этот коммит содержится в:
родитель
b9bdb2125e
Коммит
87269ba0aa
@ -60,7 +60,7 @@ static void ompi_convertor_construct( ompi_convertor_t* convertor )
|
||||
convertor->pStack = convertor->static_stack;
|
||||
convertor->stack_size = DT_STATIC_STACK_SIZE;
|
||||
convertor->remoteArch = 0;
|
||||
convertor->pending_length = 0;
|
||||
convertor->storage.length = 0;
|
||||
}
|
||||
|
||||
static void ompi_convertor_destruct( ompi_convertor_t* convertor )
|
||||
@ -261,7 +261,7 @@ int ompi_convertor_create_stack_at_begining( ompi_convertor_t* convertor,
|
||||
dt_elem_desc_t* pElems;
|
||||
|
||||
convertor->stack_pos = 1;
|
||||
convertor->pending_length = 0;
|
||||
convertor->storage.length = 0;
|
||||
convertor->bConverted = 0;
|
||||
/* Fill the first position on the stack. This one correspond to the
|
||||
* last fake DT_END_LOOP that we add to the data representation and
|
||||
@ -546,7 +546,7 @@ void ompi_convertor_dump( ompi_convertor_t* convertor )
|
||||
convertor->count, convertor->stack_pos, (unsigned long)convertor->bConverted );
|
||||
printf( "\tlocal_size %ld remote_size %ld flags %X stack_size %d pending_length %d\n",
|
||||
(unsigned long)convertor->local_size, (unsigned long)convertor->remote_size,
|
||||
convertor->flags, convertor->stack_size, convertor->pending_length );
|
||||
convertor->flags, convertor->stack_size, convertor->storage.length );
|
||||
ompi_ddt_dump( convertor->pDesc );
|
||||
printf( "Actual stack representation\n" );
|
||||
ompi_ddt_dump_stack( convertor->pStack, convertor->stack_pos,
|
||||
|
@ -78,6 +78,14 @@ typedef struct dt_stack {
|
||||
long disp; /**< actual displacement depending on the count field */
|
||||
} dt_stack_t;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
char data[16];
|
||||
uint32_t length;
|
||||
} ompi_convertor_storage_t;
|
||||
|
||||
#define DT_STATIC_STACK_SIZE 5
|
||||
|
||||
struct ompi_convertor_t {
|
||||
@ -103,8 +111,7 @@ struct ompi_convertor_t {
|
||||
uint32_t checksum; /**< checksum computed by pack/unpack operation */
|
||||
uint32_t csum_ui1; /**< partial checksum computed by pack/unpack operation */
|
||||
uint32_t csum_ui2; /**< partial checksum computed by pack/unpack operation */
|
||||
char pending[16]; /**< bytes pending from the last conversion */
|
||||
uint32_t pending_length; /**< # bytes pending ... */
|
||||
ompi_convertor_storage_t storage; /**< pending data from the last conversion */
|
||||
dt_stack_t static_stack[DT_STATIC_STACK_SIZE]; /**< local stack for small datatypes */
|
||||
};
|
||||
OBJ_CLASS_DECLARATION( ompi_convertor_t );
|
||||
@ -126,6 +133,47 @@ ompi_convertor_get_checksum( ompi_convertor_t* convertor )
|
||||
return convertor->checksum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the partially converted data to an outside entity.
|
||||
*/
|
||||
static inline int32_t ompi_convertor_export_storage( const ompi_convertor_t* convertor,
|
||||
ompi_convertor_storage_t* storage )
|
||||
{
|
||||
/* The storage has a meaning only for receive side. */
|
||||
assert( convertor->flags & CONVERTOR_RECV );
|
||||
storage->length = convertor->storage.length;
|
||||
assert( storage->length < 16 ); /* that's the maximum data length */
|
||||
if( 0 != convertor->storage.length ) {
|
||||
memcpy( storage->data, convertor->storage.data, storage->length );
|
||||
}
|
||||
return storage->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import partially unpacked data back in the convertor, in order to use it
|
||||
* on the next unpack operation.
|
||||
*/
|
||||
static inline int32_t ompi_convertor_import_storage( ompi_convertor_t* convertor,
|
||||
const ompi_convertor_storage_t* storage )
|
||||
{
|
||||
/* The storage has a meaning only for receive side. */
|
||||
assert( convertor->flags & CONVERTOR_RECV );
|
||||
convertor->storage.length = storage->length;
|
||||
assert( storage->length < 16 ); /* that's the maximum data length */
|
||||
if( 0 != storage->length ) {
|
||||
memcpy( convertor->storage.data, storage->data, storage->length );
|
||||
}
|
||||
return storage->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the pending data attached to the convertor by reseting the length.
|
||||
*/
|
||||
static inline void ompi_convertor_reset_storage( ompi_convertor_t* convertor )
|
||||
{
|
||||
convertor->storage.length = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
@ -459,18 +459,18 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor,
|
||||
|
||||
packed_buffer = iov[iov_count].iov_base;
|
||||
iov_len_local = iov[iov_count].iov_len;
|
||||
if( 0 != pConvertor->pending_length ) {
|
||||
if( 0 != pConvertor->storage.length ) {
|
||||
uint32_t element_length = ompi_ddt_basicDatatypes[pElem->elem.common.type]->size;
|
||||
uint32_t missing_length = element_length - pConvertor->pending_length;
|
||||
uint32_t missing_length = element_length - pConvertor->storage.length;
|
||||
|
||||
assert( pElem->elem.common.flags & DT_FLAG_DATA );
|
||||
#if defined(CHECKSUM)
|
||||
pConvertor->checksum -= OPAL_CSUM(pConvertor->pending, pConvertor->pending_length);
|
||||
pConvertor->checksum -= OPAL_CSUM(pConvertor->storage.data, pConvertor->storage.length);
|
||||
#endif
|
||||
memcpy(pConvertor->pending + pConvertor->pending_length, packed_buffer, missing_length);
|
||||
packed_buffer = pConvertor->pending;
|
||||
memcpy(pConvertor->storage.data + pConvertor->storage.length, packed_buffer, missing_length);
|
||||
packed_buffer = pConvertor->storage.data;
|
||||
DO_DEBUG( opal_output( 0, "unpack pending from the last unpack %d out of %d bytes\n",
|
||||
pConvertor->pending_length, ompi_ddt_basicDatatypes[pElem->elem.common.type]->size ); );
|
||||
pConvertor->storage.length, ompi_ddt_basicDatatypes[pElem->elem.common.type]->size ); );
|
||||
UNPACK_PREDEFINED_DATATYPE( pConvertor, pElem, count_desc,
|
||||
packed_buffer, user_memory_base, element_length );
|
||||
if( 0 == count_desc ) {
|
||||
@ -481,7 +481,7 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor,
|
||||
assert( 0 == element_length );
|
||||
packed_buffer = (char*)iov[iov_count].iov_base + missing_length;
|
||||
iov_len_local -= missing_length;
|
||||
pConvertor->pending_length = 0; /* nothing more inside */
|
||||
pConvertor->storage.length = 0; /* nothing more inside */
|
||||
}
|
||||
while( 1 ) {
|
||||
if( DT_END_LOOP == pElem->elem.common.type ) { /* end of the current loop */
|
||||
@ -556,9 +556,9 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor,
|
||||
*/
|
||||
assert (type < DT_MAX_PREDEFINED);
|
||||
assert( iov_len_local < ompi_ddt_basicDatatypes[type]->size );
|
||||
MEMCPY_CSUM( pConvertor->pending, packed_buffer, iov_len_local, pConvertor );
|
||||
MEMCPY_CSUM( pConvertor->storage.data, packed_buffer, iov_len_local, pConvertor );
|
||||
DO_DEBUG( opal_output( 0, "Saving %d bytes for the next call\n", iov_len_local ); );
|
||||
pConvertor->pending_length = iov_len_local;
|
||||
pConvertor->storage.length = iov_len_local;
|
||||
iov_len_local = 0;
|
||||
}
|
||||
iov[iov_count].iov_len -= iov_len_local; /* update the amount of valid data */
|
||||
|
@ -219,7 +219,7 @@ int ompi_convertor_generic_simple_position( ompi_convertor_t* pConvertor,
|
||||
complete_loop:
|
||||
(*position) -= iov_len_local;
|
||||
pConvertor->bConverted = *position; /* update the already converted bytes */
|
||||
if( (pConvertor->pending_length != iov_len_local) &&
|
||||
if( (pConvertor->storage.length != iov_len_local) &&
|
||||
(pConvertor->flags & CONVERTOR_RECV) ) {
|
||||
opal_output( 0, "Missing some data ?" );
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user