21 #ifndef OPAL_CONVERTOR_H_HAS_BEEN_INCLUDED
22 #define OPAL_CONVERTOR_H_HAS_BEEN_INCLUDED
24 #include "opal_config.h"
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
41 #include "opal/constants.h"
42 #include "opal/datatype/opal_datatype.h"
50 #define CONVERTOR_DATATYPE_MASK 0x0000FFFF
51 #define CONVERTOR_SEND_CONVERSION 0x00010000
52 #define CONVERTOR_RECV 0x00020000
53 #define CONVERTOR_SEND 0x00040000
54 #define CONVERTOR_HOMOGENEOUS 0x00080000
55 #define CONVERTOR_NO_OP 0x00100000
56 #define CONVERTOR_WITH_CHECKSUM 0x00200000
57 #define CONVERTOR_CUDA 0x00400000
58 #define CONVERTOR_TYPE_MASK 0x00FF0000
59 #define CONVERTOR_STATE_START 0x01000000
60 #define CONVERTOR_STATE_COMPLETE 0x02000000
61 #define CONVERTOR_STATE_ALLOC 0x04000000
62 #define CONVERTOR_COMPLETED 0x08000000
71 typedef void*(*memalloc_fct_t)(
size_t* pLength,
void* userdata );
72 typedef void*(*memcpy_fct_t)(
void* dest,
const void* src,
size_t n );
88 #define DT_STATIC_STACK_SIZE 5
117 #if OPAL_CUDA_SUPPORT
118 memcpy_fct_t cbmemcpy;
129 static inline uint32_t opal_convertor_get_checksum(
opal_convertor_t* convertor )
139 uint32_t* out_size,
size_t* max_data );
145 uint32_t* out_size,
size_t* max_data );
150 OPAL_DECLSPEC
opal_convertor_t* opal_convertor_create( int32_t remote_arch, int32_t mode );
162 if( OPAL_UNLIKELY(convertor->
stack_size > DT_STATIC_STACK_SIZE) ) {
163 free( convertor->
pStack );
167 #if OPAL_CUDA_SUPPORT
168 convertor->cbmemcpy = &memcpy;
170 convertor->
pDesc = NULL;
172 convertor->
flags = OPAL_DATATYPE_FLAG_NO_GAPS | CONVERTOR_COMPLETED;
186 static inline int32_t opal_convertor_need_buffers(
const opal_convertor_t* pConvertor )
188 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
189 if (OPAL_UNLIKELY(0 == (pConvertor->
flags & CONVERTOR_HOMOGENEOUS)))
return 1;
191 #if OPAL_CUDA_SUPPORT
192 if( pConvertor->
flags & CONVERTOR_CUDA )
return 1;
194 if( pConvertor->
flags & OPAL_DATATYPE_FLAG_NO_GAPS )
return 0;
195 if( (pConvertor->
count == 1) && (pConvertor->
flags & OPAL_DATATYPE_FLAG_CONTIGUOUS) )
return 0;
203 static inline void opal_convertor_get_packed_size(
const opal_convertor_t* pConv,
213 static inline void opal_convertor_get_unpacked_size(
const opal_convertor_t* pConv,
225 static inline void opal_convertor_get_current_pointer(
const opal_convertor_t* pConv,
229 *position = (
void*)base;
235 OPAL_DECLSPEC int32_t opal_convertor_prepare_for_send(
opal_convertor_t* convertor,
238 const void* pUserBuf);
240 static inline int32_t opal_convertor_copy_and_prepare_for_send(
const opal_convertor_t* pSrcConv,
243 const void* pUserBuf,
251 return opal_convertor_prepare_for_send( convertor, datatype, count, pUserBuf );
257 OPAL_DECLSPEC int32_t opal_convertor_prepare_for_recv(
opal_convertor_t* convertor,
260 const void* pUserBuf );
261 static inline int32_t opal_convertor_copy_and_prepare_for_recv(
const opal_convertor_t* pSrcConv,
264 const void* pUserBuf,
272 return opal_convertor_prepare_for_recv( convertor, datatype, count, pUserBuf );
278 OPAL_DECLSPEC int32_t
287 OPAL_DECLSPEC int32_t
290 static inline int32_t
298 if( OPAL_UNLIKELY(convertor->
local_size <= *position) ) {
299 convertor->
flags |= CONVERTOR_COMPLETED;
308 if( OPAL_LIKELY((*position) == convertor->
bConverted) )
return OPAL_SUCCESS;
311 convertor->
flags &= ~CONVERTOR_COMPLETED;
313 if( !(convertor->
flags & CONVERTOR_WITH_CHECKSUM) &&
314 (convertor->
flags & OPAL_DATATYPE_FLAG_NO_GAPS) &&
315 (convertor->
flags & (CONVERTOR_SEND | CONVERTOR_HOMOGENEOUS)) ) {
321 return opal_convertor_set_position_nocheck( convertor, position );
327 static inline int32_t
332 convertor->
flags |= flags;
334 if( OPAL_UNLIKELY(NULL == position) )
336 return opal_convertor_set_position( convertor, position );
345 int32_t copy_stack );
353 (void)opal_convertor_clone( source, destination, copy_stack );
354 return opal_convertor_set_position( destination, position );
364 opal_datatype_dump_stack(
const dt_stack_t* pStack,
uint32_t remoteArch
the remote architecture
Definition: opal_convertor.h:92
int16_t type
the type used for the last pack/unpack (original or OPAL_DATATYPE_UINT1)
Definition: opal_convertor.h:79
uint32_t stack_size
size of the allocated stack
Definition: opal_convertor.h:99
Definition: opal_datatype_internal.h:184
size_t count
number of times we still have to do it
Definition: opal_convertor.h:80
opal_object_t super
basic superclass
Definition: opal_convertor.h:91
Definition: opal_datatype.h:92
size_t remote_size
overall length data on remote machine, compared to bConverted
Definition: opal_convertor.h:95
convertor_advance_fct_t fAdvance
pointer to the pack/unpack functions
Definition: opal_convertor.h:103
dt_stack_t static_stack[DT_STATIC_STACK_SIZE]
local stack for small datatypes
Definition: opal_convertor.h:114
unsigned char * pBaseBuf
initial buffer as supplied by the user
Definition: opal_convertor.h:101
uint32_t checksum
checksum computed by pack/unpack operation
Definition: opal_convertor.h:110
uint32_t partial_length
amount of data left over from the last unpack
Definition: opal_convertor.h:108
const opal_datatype_t * pDesc
the datatype description associated with the convertor
Definition: opal_convertor.h:96
uint32_t csum_ui1
partial checksum computed by pack/unpack operation
Definition: opal_convertor.h:111
Definition: opal_convertor.h:77
Definition: opal_convertor_internal.h:31
dt_stack_t * pStack
the local stack for the actual conversion
Definition: opal_convertor.h:102
Definition: opal_datatype.h:103
Definition: ompi_uio.h:29
uint32_t stack_pos
the actual position on the stack
Definition: opal_convertor.h:107
size_t csum_ui2
partial checksum computed by pack/unpack operation
Definition: opal_convertor.h:112
Base object.
Definition: opal_object.h:182
Definition: opal_convertor.h:90
size_t bConverted
of bytes already converted
Definition: opal_convertor.h:109
const dt_type_desc_t * use_desc
the version used by the convertor (normal or optimized)
Definition: opal_convertor.h:97
size_t local_size
overall length data on local machine, compared to bConverted
Definition: opal_convertor.h:94
Compiler-specific prefetch functions.
opal_datatype_count_t count
the total number of full datatype elements
Definition: opal_convertor.h:98
uint32_t flags
the properties of this convertor
Definition: opal_convertor.h:93
struct opal_convertor_master_t * master
the master convertor
Definition: opal_convertor.h:104
OPAL_PTRDIFF_TYPE true_lb
the true lb of the data without user defined lb and ub
Definition: opal_datatype.h:110
int32_t index
index in the element description
Definition: opal_convertor.h:78
OPAL_PTRDIFF_TYPE disp
actual displacement depending on the count field
Definition: opal_convertor.h:81
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236