diff --git a/ompi/datatype/convertor.c b/ompi/datatype/convertor.c index 98d2df319d..9b2bc5c34f 100644 --- a/ompi/datatype/convertor.c +++ b/ompi/datatype/convertor.c @@ -374,7 +374,7 @@ int32_t ompi_convertor_set_position_nocheck( ompi_convertor_t* convertor, */ #define OMPI_CONVERTOR_PREPARE( convertor, datatype, count, pUserBuf ) \ { \ - convertor->pBaseBuf = (void*)pUserBuf; \ + convertor->pBaseBuf = (char*)pUserBuf + datatype->lb; \ convertor->count = count; \ \ /* Grab the datatype part of the flags */ \ diff --git a/ompi/datatype/datatype_internal.h b/ompi/datatype/datatype_internal.h index 3013e076e2..1662beb624 100644 --- a/ompi/datatype/datatype_internal.h +++ b/ompi/datatype/datatype_internal.h @@ -250,19 +250,19 @@ OMPI_DECLSPEC int ompi_ddt_safeguard_pointer_debug_breakpoint( const void* actua const ompi_datatype_t* pData, int count ); #define OMPI_DDT_SAFEGUARD_POINTER( ACTPTR, LENGTH, INITPTR, PDATA, COUNT ) \ -{ \ - char *__lower_bound = (char*)(INITPTR), *__upper_bound; \ - assert( ((LENGTH) != 0) && ((COUNT) != 0) ); \ - __lower_bound += (PDATA)->true_lb; \ - __upper_bound = (INITPTR) + ((PDATA)->ub - (PDATA)->lb) * ((COUNT) - 1) + (PDATA)->true_ub; \ - if( ((ACTPTR) < __lower_bound) || ((ACTPTR) >= __upper_bound) ) { \ - ompi_ddt_safeguard_pointer_debug_breakpoint( (ACTPTR), (LENGTH), (INITPTR), (PDATA), (COUNT) ); \ - opal_output( 0, "%s:%d\n\tPointer %p size %d is outside [%p,%p] for\n\tbase ptr %p count %d and data \n", \ - __FILE__, __LINE__, (ACTPTR), (LENGTH), __lower_bound, __upper_bound, \ - (INITPTR), (COUNT) ); \ - ompi_ddt_dump( (PDATA) ); \ - } \ -} + { \ + char *__lower_bound = (char*)(INITPTR), *__upper_bound; \ + assert( ((LENGTH) != 0) && ((COUNT) != 0) ); \ + __lower_bound += (PDATA)->true_lb - (PDATA)->lb; \ + __upper_bound = (INITPTR) + ((PDATA)->ub - (PDATA)->lb) * ((COUNT) - 1) + (PDATA)->true_ub - (PDATA)->lb; \ + if( ((ACTPTR) < __lower_bound) || ((ACTPTR) >= __upper_bound) ) { \ + ompi_ddt_safeguard_pointer_debug_breakpoint( (ACTPTR), (LENGTH), (INITPTR), (PDATA), (COUNT) ); \ + opal_output( 0, "%s:%d\n\tPointer %p size %d is outside [%p,%p] for\n\tbase ptr %p count %d and data \n", \ + __FILE__, __LINE__, (ACTPTR), (LENGTH), __lower_bound, __upper_bound, \ + (INITPTR), (COUNT) ); \ + ompi_ddt_dump( (PDATA) ); \ + } \ + } #else #define OMPI_DDT_SAFEGUARD_POINTER( ACTPTR, LENGTH, INITPTR, PDATA, COUNT ) diff --git a/ompi/datatype/datatype_pack.c b/ompi/datatype/datatype_pack.c index b003e6d2ac..ef5270ef5d 100644 --- a/ompi/datatype/datatype_pack.c +++ b/ompi/datatype/datatype_pack.c @@ -762,7 +762,7 @@ ompi_pack_homogeneous_contig_with_gaps_function( ompi_convertor_t* pConv, i++; /* just to compute the correct source pointer */ total_bytes_converted += done; } - user_memory = pConv->pBaseBuf + pData->true_lb + i * extent; + user_memory = pConv->pBaseBuf + i * extent; counter = max_allowed / pData->size; if( counter > pConv->count ) counter = pConv->count; for( i = 0; i < counter; i++ ) { @@ -827,10 +827,9 @@ ompi_generic_simple_pack_function( ompi_convertor_t* pConvertor, * main while loop we will set back the source_base to the correct value. This is * due to the fact that the convertor can stop in the middle of a data with a count */ - source_base = pConvertor->pBaseBuf; pStack = pConvertor->pStack + pConvertor->stack_pos; pos_desc = pStack->index; - source_base += pStack->disp; + source_base = pConvertor->pBaseBuf + pStack->disp; count_desc = pStack->count; pStack--; pConvertor->stack_pos--; diff --git a/ompi/datatype/datatype_unpack.c b/ompi/datatype/datatype_unpack.c index daec4c2b36..75c929d9c3 100644 --- a/ompi/datatype/datatype_unpack.c +++ b/ompi/datatype/datatype_unpack.c @@ -191,7 +191,7 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv, if( remaining > (uint32_t)iov[iov_count].iov_len ) remaining = iov[iov_count].iov_len; bConverted = remaining; /* how much will get unpacked this time */ - user_memory = pConv->pBaseBuf + pData->true_lb; + user_memory = pConv->pBaseBuf; /*opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %d\n", user_memory, packed_buffer, remaining );*/ @@ -240,7 +240,7 @@ ompi_unpack_homogeneous_contig_function( ompi_convertor_t* pConv, MEMCPY_CSUM( user_memory, packed_buffer, remaining, pConv ); user_memory += remaining; } - stack->disp = user_memory - pData->true_lb - pConv->pBaseBuf; /* save the position */ + stack->disp = user_memory - pConv->pBaseBuf; /* save the position */ } pConv->bConverted += bConverted; } @@ -332,12 +332,12 @@ ompi_generic_simple_unpack_function( ompi_convertor_t* pConvertor, */ pStack = pConvertor->pStack + pConvertor->stack_pos; pos_desc = pStack->index; - user_memory_base += pStack->disp; + user_memory_base = pConvertor->pBaseBuf + pStack->disp; count_desc = pStack->count; pStack--; pConvertor->stack_pos--; pElem = &(description[pos_desc]); - user_memory_base = pConvertor->pBaseBuf + pStack->disp; + user_memory_base += pStack->disp; DO_DEBUG( opal_output( 0, "unpack start pos_desc %d count_desc %d disp %ld\n" "stack_pos %d pos_desc %d count_desc %d disp %ld\n",