1
1

Correctly handle the pack and unpack for contiguous types with gaps. Th

pack/unpack let the convertor in a consistent state, such that the next operation
will succeed.

This commit was SVN r13630.
Этот коммит содержится в:
George Bosilca 2007-02-13 09:28:05 +00:00
родитель 085826d94a
Коммит 5214e3751b
2 изменённых файлов: 26 добавлений и 18 удалений

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

@ -186,18 +186,16 @@ ompi_pack_homogeneous_contig_with_gaps_function( ompi_convertor_t* pConv,
size_t done;
packed_buffer = iov[iov_count].iov_base;
done = pConv->bConverted - i * pData->size; /* how much data left last time */
user_memory += done;
done = pConv->bConverted - i * pData->size; /* partial data from last pack */
if( done != 0 ) { /* still some data to copy from the last time */
done = pData->size - done;
OMPI_DDT_SAFEGUARD_POINTER( user_memory, done, pConv->pBaseBuf, pData, pConv->count );
MEMCPY_CSUM( packed_buffer, user_memory, done, pConv );
packed_buffer += done;
max_allowed -= done;
i++; /* just to compute the correct source pointer */
total_bytes_converted += done;
user_memory += (extent - pData->size + done);
}
user_memory = pConv->pBaseBuf + initial_displ + i * extent;
counter = (uint32_t)(max_allowed / pData->size);
if( counter > pConv->count ) counter = pConv->count;
for( i = 0; i < counter; i++ ) {
@ -206,16 +204,23 @@ ompi_pack_homogeneous_contig_with_gaps_function( ompi_convertor_t* pConv,
packed_buffer+= pData->size;
user_memory += extent;
}
max_allowed -= (counter * pData->size);
iov[iov_count].iov_len -= max_allowed;
total_bytes_converted += iov[iov_count].iov_len;
done = (counter * pData->size);
max_allowed -= done;
total_bytes_converted += done;
/* If there is anything pending ... */
if( 0 != max_allowed ) {
done = max_allowed;
OMPI_DDT_SAFEGUARD_POINTER( user_memory, done, pConv->pBaseBuf, pData, pConv->count );
MEMCPY_CSUM( packed_buffer, user_memory, done, pConv );
packed_buffer += done;
max_allowed = 0;
total_bytes_converted += done;
user_memory += done;
}
}
/* Now update the user_memory pointer. At the end of each parth we have to update
* the pStack[0].disp field. BEWARE here we remove the pStack[1].disp as
* it's supposed to be useless from now.
*/
user_memory = pConv->pBaseBuf + initial_displ + pStack[0].disp;
}
pStack[0].disp = (intptr_t)user_memory - (intptr_t)pConv->pBaseBuf - initial_displ;
pStack[1].disp = max_allowed;
*max_data = total_bytes_converted;
pConv->bConverted += total_bytes_converted;
*out_size = iov_count;

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

@ -189,7 +189,7 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv,
char *user_memory, *packed_buffer;
uint32_t iov_count, i;
size_t bConverted, remaining, length, initial_bytes_converted = pConv->bConverted;
dt_stack_t* stack = &(pConv->pStack[1]);
dt_stack_t* stack = pConv->pStack;
ptrdiff_t extent = pData->ub - pData->lb;
ptrdiff_t initial_displ = pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp;
@ -203,11 +203,10 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv,
bConverted = remaining; /* how much will get unpacked this time */
user_memory = pConv->pBaseBuf + initial_displ;
DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %lu\n",
user_memory, packed_buffer, (unsigned long)remaining ); );
if( (ptrdiff_t)pData->size == extent ) {
user_memory += pConv->bConverted;
DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %lu\n",
user_memory, packed_buffer, (unsigned long)remaining ); );
/* contiguous data or basic datatype with count */
OMPI_DDT_SAFEGUARD_POINTER( user_memory, remaining,
@ -216,7 +215,10 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv,
user_memory, packed_buffer, (unsigned long)remaining ); );
MEMCPY_CSUM( user_memory, packed_buffer, remaining, pConv );
} else {
user_memory += stack->disp;
user_memory += stack[0].disp + stack[1].disp;
DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %lu\n",
user_memory, packed_buffer, (unsigned long)remaining ); );
length = pConv->bConverted / pData->size; /* already done */
length = pConv->bConverted - length * pData->size; /* how much of the last data we convert */
@ -245,6 +247,8 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv,
user_memory += extent;
remaining -= pData->size;
}
stack[0].disp = (intptr_t)user_memory - (intptr_t)pConv->pBaseBuf - initial_displ;
stack[1].disp = remaining;
/* copy the last bits */
if( remaining != 0 ) {
OMPI_DDT_SAFEGUARD_POINTER( user_memory, remaining, pConv->pBaseBuf,
@ -254,7 +258,6 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv,
MEMCPY_CSUM( user_memory, packed_buffer, remaining, pConv );
user_memory += remaining;
}
stack->disp = user_memory - pConv->pBaseBuf; /* save the position */
}
pConv->bConverted += bConverted;
}