15 #ifndef OPAL_DATATYPE_PACK_H_HAS_BEEN_INCLUDED
16 #define OPAL_DATATYPE_PACK_H_HAS_BEEN_INCLUDED
18 #include "opal_config.h"
25 #if !defined(CHECKSUM) && OPAL_CUDA_SUPPORT
28 #define MEMCPY_CSUM( DST, SRC, BLENGTH, CONVERTOR ) \
29 CONVERTOR->cbmemcpy( (DST), (SRC), (BLENGTH) )
35 unsigned char** SOURCE,
36 unsigned char** DESTINATION,
39 uint32_t _copy_count = *(COUNT);
42 unsigned char* _source = (*SOURCE) + _elem->
disp;
44 _copy_blength = opal_datatype_basicDatatypes[_elem->
common.
type]->
size;
45 if( (_copy_count * _copy_blength) > *(SPACE) ) {
46 _copy_count = (uint32_t)(*(SPACE) / _copy_blength);
47 if( 0 == _copy_count )
return;
50 if( (OPAL_PTRDIFF_TYPE)_copy_blength == _elem->
extent ) {
51 _copy_blength *= _copy_count;
53 OPAL_DATATYPE_SAFEGUARD_POINTER( _source, _copy_blength, (CONVERTOR)->pBaseBuf,
54 (CONVERTOR)->pDesc, (CONVERTOR)->count );
55 DO_DEBUG(
opal_output( 0,
"pack 1. memcpy( %p, %p, %lu ) => space %lu\n",
56 *(DESTINATION), _source, (
unsigned long)_copy_blength, (
unsigned long)(*(SPACE)) ); );
57 MEMCPY_CSUM( *(DESTINATION), _source, _copy_blength, (CONVERTOR) );
58 _source += _copy_blength;
59 *(DESTINATION) += _copy_blength;
62 for( _i = 0; _i < _copy_count; _i++ ) {
63 OPAL_DATATYPE_SAFEGUARD_POINTER( _source, _copy_blength, (CONVERTOR)->pBaseBuf,
64 (CONVERTOR)->pDesc, (CONVERTOR)->count );
65 DO_DEBUG(
opal_output( 0,
"pack 2. memcpy( %p, %p, %lu ) => space %lu\n",
66 *(DESTINATION), _source, (
unsigned long)_copy_blength, (
unsigned long)(*(SPACE) - (_i * _copy_blength)) ); );
67 MEMCPY_CSUM( *(DESTINATION), _source, _copy_blength, (CONVERTOR) );
68 *(DESTINATION) += _copy_blength;
71 _copy_blength *= _copy_count;
73 *(SOURCE) = _source - _elem->
disp;
74 *(SPACE) -= _copy_blength;
75 *(COUNT) -= _copy_count;
81 unsigned char** SOURCE,
82 unsigned char** DESTINATION,
88 uint32_t _copy_loops = *(COUNT);
91 if( (_copy_loops * _end_loop->
size) > *(SPACE) )
92 _copy_loops = (uint32_t)(*(SPACE) / _end_loop->
size);
93 for( _i = 0; _i < _copy_loops; _i++ ) {
94 OPAL_DATATYPE_SAFEGUARD_POINTER( _source, _end_loop->
size, (CONVERTOR)->pBaseBuf,
95 (CONVERTOR)->pDesc, (CONVERTOR)->count );
96 DO_DEBUG(
opal_output( 0,
"pack 3. memcpy( %p, %p, %lu ) => space %lu\n",
97 *(DESTINATION), _source, (
unsigned long)_end_loop->
size, (
unsigned long)(*(SPACE) - _i * _end_loop->
size) ); );
98 MEMCPY_CSUM( *(DESTINATION), _source, _end_loop->
size, (CONVERTOR) );
99 *(DESTINATION) += _end_loop->
size;
103 *(SPACE) -= _copy_loops * _end_loop->
size;
104 *(COUNT) -= _copy_loops;
107 #define PACK_PREDEFINED_DATATYPE( CONVERTOR, \
113 pack_predefined_data( (CONVERTOR), (ELEM), &(COUNT), &(SOURCE), &(DESTINATION), &(SPACE) )
115 #define PACK_CONTIGUOUS_LOOP( CONVERTOR, ELEM, COUNT, SOURCE, DESTINATION, SPACE ) \
116 pack_contiguous_loop( (CONVERTOR), (ELEM), &(COUNT), &(SOURCE), &(DESTINATION), &(SPACE) )
OPAL_PTRDIFF_TYPE extent
extent of each block (in bytes)
Definition: opal_datatype_internal.h:161
Definition: opal_datatype_internal.h:175
OPAL_PTRDIFF_TYPE first_elem_disp
the displacement of the first block in the loop
Definition: opal_datatype_internal.h:180
Definition: opal_datatype_internal.h:184
Definition: opal_datatype_internal.h:166
uint32_t items
number of items in the loop
Definition: opal_datatype_internal.h:169
ddt_elem_id_description common
basic data description and flags
Definition: opal_datatype_internal.h:158
uint16_t type
the basic data type id
Definition: opal_datatype_internal.h:150
OPAL_DECLSPEC void opal_output(int output_id, const char *format,...) __opal_attribute_format__(__printf__
Main function to send output to a stream.
size_t size
real size of the data in the loop
Definition: opal_datatype_internal.h:179
size_t size
total size in bytes of the memory used by the data if the data is put on a contiguous buffer ...
Definition: opal_datatype.h:108
OPAL_PTRDIFF_TYPE extent
extent of the whole loop
Definition: opal_datatype_internal.h:171
Definition: opal_convertor.h:90
Definition: opal_datatype_internal.h:157
OPAL_PTRDIFF_TYPE disp
displacement of the first block
Definition: opal_datatype_internal.h:162