@@ -48,37 +48,37 @@ static inline void _predefined_data( const dt_elem_desc_t* ELEM,
4848 unsigned char * DESTINATION ,
4949 size_t * SPACE )
5050{
51- size_t _copy_count = (COUNT );
52- size_t _copy_blength ;
5351 const ddt_elem_desc_t * _elem = & ((ELEM )-> elem );
5452 unsigned char * _source = (SOURCE ) + _elem -> disp ;
5553 unsigned char * _destination = (DESTINATION ) + _elem -> disp ;
54+ size_t total_count = _elem -> count * _elem -> blocklen ;
55+ size_t do_now , do_now_bytes ;
5656
57- _copy_blength = opal_datatype_basicDatatypes [_elem -> common .type ]-> size ;
57+ assert ( (COUNT ) == total_count );
58+ assert ( total_count <= ((* SPACE ) / opal_datatype_basicDatatypes [_elem -> common .type ]-> size ) );
5859
59- if ( _copy_blength == (size_t )_elem -> extent ) {
60- _copy_blength *= _copy_count ;
61- OPAL_DATATYPE_SAFEGUARD_POINTER ( _source , _copy_blength , (SOURCE_BASE ),
62- (DATATYPE ), (TOTAL_COUNT ) );
63- /* the extent and the size of the basic datatype are equals */
64- DO_DEBUG ( opal_output ( 0 , "copy 1. %s( %p, %p, %" PRIsize_t " ) => space %" PRIsize_t "\n" ,
65- STRINGIFY (MEM_OP_NAME ), (void * )_destination , (void * )_source , _copy_blength , * (SPACE ) ); );
66- MEM_OP ( _destination , _source , _copy_blength );
67- _source += _copy_blength ;
68- _destination += _copy_blength ;
69- } else {
70- for (size_t _i = 0 ; _i < _copy_count ; _i ++ ) {
71- OPAL_DATATYPE_SAFEGUARD_POINTER ( _source , _copy_blength , (SOURCE_BASE ),
72- (DATATYPE ), (TOTAL_COUNT ) );
73- DO_DEBUG ( opal_output ( 0 , "copy 2. %s( %p, %p, %lu ) => space %lu\n" ,
74- STRINGIFY (MEM_OP_NAME ), (void * )_destination , (void * )_source , (unsigned long )_copy_blength , (unsigned long )(* (SPACE ) - (_i * _copy_blength )) ); );
75- MEM_OP ( _destination , _source , _copy_blength );
76- _source += _elem -> extent ;
60+ /* We don't a prologue and epilogue here as we are __always__ working
61+ * with full copies of the data description.
62+ */
63+
64+ /**
65+ * Compute how many full blocklen we need to do and do them.
66+ */
67+ do_now = _elem -> count ;
68+ if ( 0 != do_now ) {
69+ do_now_bytes = _elem -> blocklen * opal_datatype_basicDatatypes [_elem -> common .type ]-> size ;
70+ for (size_t _i = 0 ; _i < do_now ; _i ++ ) {
71+ OPAL_DATATYPE_SAFEGUARD_POINTER ( _source , do_now_bytes , (SOURCE_BASE ),
72+ (DATATYPE ), (TOTAL_COUNT ) );
73+ DO_DEBUG ( opal_output ( 0 , "copy %s( %p, %p, %" PRIsize_t " ) => space %" PRIsize_t "\n" ,
74+ STRINGIFY (MEM_OP_NAME ), (void * )_destination , (void * )_source , do_now_bytes , * (SPACE ) ); );
75+ MEM_OP ( _destination , _source , do_now_bytes );
7776 _destination += _elem -> extent ;
77+ _source += _elem -> extent ;
78+ * (SPACE ) -= do_now_bytes ;
7879 }
79- _copy_blength *= _copy_count ;
80+ ( COUNT ) -= total_count ;
8081 }
81- * (SPACE ) -= _copy_blength ;
8282}
8383
8484static inline void _contiguous_loop ( const dt_elem_desc_t * ELEM ,
@@ -147,12 +147,10 @@ static inline int32_t _copy_content_same_ddt( const opal_datatype_t* datatype, i
147147 if ( (ptrdiff_t )datatype -> size == extent ) { /* all contiguous == no gaps around */
148148 size_t total_length = iov_len_local ;
149149 size_t memop_chunk = opal_datatype_memop_block_size ;
150+ OPAL_DATATYPE_SAFEGUARD_POINTER ( source , iov_len_local ,
151+ (unsigned char * )source_base , datatype , count );
150152 while ( total_length > 0 ) {
151153 if ( memop_chunk > total_length ) memop_chunk = total_length ;
152- OPAL_DATATYPE_SAFEGUARD_POINTER ( destination , memop_chunk ,
153- (unsigned char * )destination_base , datatype , count );
154- OPAL_DATATYPE_SAFEGUARD_POINTER ( source , memop_chunk ,
155- (unsigned char * )source_base , datatype , count );
156154 DO_DEBUG ( opal_output ( 0 , "copy c1. %s( %p, %p, %lu ) => space %lu\n" ,
157155 STRINGIFY (MEM_OP_NAME ), (void * )destination , (void * )source , (unsigned long )memop_chunk , (unsigned long )total_length ); );
158156 MEM_OP ( destination , source , memop_chunk );
@@ -184,17 +182,12 @@ static inline int32_t _copy_content_same_ddt( const opal_datatype_t* datatype, i
184182 pos_desc = 0 ;
185183 stack_pos = 0 ;
186184
187- if ( datatype -> opt_desc .desc != NULL ) {
188- description = datatype -> opt_desc .desc ;
189- } else {
185+ description = datatype -> opt_desc .desc ;
186+ if ( NULL == description ) {
190187 description = datatype -> desc .desc ;
191188 }
192189
193- if ( description [0 ].elem .common .type == OPAL_DATATYPE_LOOP )
194- count_desc = description [0 ].loop .loops ;
195- else
196- count_desc = description [0 ].elem .count ;
197- pElem = & (description [pos_desc ]);
190+ UPDATE_INTERNAL_COUNTERS ( description , 0 , pElem , count_desc );
198191
199192 while ( 1 ) {
200193 while ( OPAL_LIKELY (pElem -> elem .common .flags & OPAL_DATATYPE_FLAG_DATA ) ) {
0 commit comments