1
1

Do not forget to update the max_data before returning to the upper level.

This commit was SVN r7285.
Этот коммит содержится в:
George Bosilca 2005-09-09 23:37:44 +00:00
родитель 06d9c594ef
Коммит 35676f0c75

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

@ -26,7 +26,7 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#define DO_DEBUG(INST) /* no debug informations */ #define DO_DEBUG(INST) /* no debug info */
/* The pack/unpack functions need a cleanup. I have to create a proper interface to access /* The pack/unpack functions need a cleanup. I have to create a proper interface to access
* all basic functionalities, hence using them as basic blocks for all conversion functions. * all basic functionalities, hence using them as basic blocks for all conversion functions.
@ -140,6 +140,7 @@ int ompi_convertor_generic_simple_pack( ompi_convertor_t* pConvertor,
uint32_t count_desc; /* the number of items already done in the actual pos_desc */ uint32_t count_desc; /* the number of items already done in the actual pos_desc */
uint16_t type; /* type at current position */ uint16_t type; /* type at current position */
long disp_desc = 0; /* compute displacement for truncated data */ long disp_desc = 0; /* compute displacement for truncated data */
size_t total_packed = 0; /* total amount packed this time */
dt_elem_desc_t* description; dt_elem_desc_t* description;
dt_elem_desc_t* pElem; dt_elem_desc_t* pElem;
const ompi_datatype_t *pData = pConvertor->pDesc; const ompi_datatype_t *pData = pConvertor->pDesc;
@ -162,7 +163,7 @@ int ompi_convertor_generic_simple_pack( ompi_convertor_t* pConvertor,
source = source_base + disp_desc; source = source_base + disp_desc;
for( iov_count = 0; iov_count < (*out_size); iov_count++ ) { for( iov_count = 0; iov_count < (*out_size); iov_count++ ) {
if( pConvertor->bConverted == (pData->size * pConvertor->count) ) if( pConvertor->flags & CONVERTOR_COMPLETED )
break; /* do not pack over the boundaries even if there are more iovecs */ break; /* do not pack over the boundaries even if there are more iovecs */
if( iov[iov_count].iov_base == NULL ) { if( iov[iov_count].iov_base == NULL ) {
/* /*
@ -171,8 +172,8 @@ int ompi_convertor_generic_simple_pack( ompi_convertor_t* pConvertor,
uint32_t length = iov[iov_count].iov_len; uint32_t length = iov[iov_count].iov_len;
if( length <= 0 ) if( length <= 0 )
length = pConvertor->count * pData->size - pConvertor->bConverted; length = pConvertor->count * pData->size - pConvertor->bConverted;
if( (*max_data) < length ) if( ((*max_data) - total_packed) < length )
length = *max_data; length = (*max_data) - total_packed;
iov[iov_count].iov_len = length; 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 ); pConvertor->memAlloc_userdata );
@ -241,9 +242,11 @@ int ompi_convertor_generic_simple_pack( ompi_convertor_t* pConvertor,
} }
complete_loop: complete_loop:
iov[iov_count].iov_len -= iov_len_local; /* update the amount of valid data */ iov[iov_count].iov_len -= iov_len_local; /* update the amount of valid data */
total_packed += iov[iov_count].iov_len;
pConvertor->bConverted += iov[iov_count].iov_len; /* update the already converted bytes */ pConvertor->bConverted += iov[iov_count].iov_len; /* update the already converted bytes */
assert( iov_len_local >= 0 ); assert( iov_len_local >= 0 );
} }
*max_data = total_packed;
if( !(pConvertor->flags & CONVERTOR_COMPLETED) ) { if( !(pConvertor->flags & CONVERTOR_COMPLETED) ) {
/* I complete an element, next step I should go to the next one */ /* I complete an element, next step I should go to the next one */
PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_BYTE, count_desc, PUSH_STACK( pStack, pConvertor->stack_pos, pos_desc, DT_BYTE, count_desc,