OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

opal_datatype_internal.h
1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
3 * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
4 * University Research and Technology
5 * Corporation. All rights reserved.
6 * Copyright (c) 2004-2012 The University of Tennessee and The University
7 * of Tennessee Research Foundation. All rights
8 * reserved.
9 * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
10 * University of Stuttgart. All rights reserved.
11 * Copyright (c) 2004-2006 The Regents of the University of California.
12 * All rights reserved.
13 * Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
14 * $COPYRIGHT$
15 *
16 * Additional copyrights may follow
17 *
18 * $HEADER$
19 */
20
21 #ifndef OPAL_DATATYPE_INTERNAL_H_HAS_BEEN_INCLUDED
22 #define OPAL_DATATYPE_INTERNAL_H_HAS_BEEN_INCLUDED
23
24 #include "opal_config.h"
25
26 #include <stddef.h>
27 #include <stdio.h>
28
29 #ifdef HAVE_STRING_H
30 #include <string.h>
31 #endif
32 #ifdef HAVE_STDINT_H
33 #include <stdint.h>
34 #endif
35
36 #if defined(VERBOSE)
37 #include "opal/util/output.h"
38
39 extern int opal_datatype_dfd;
40
41 # define DDT_DUMP_STACK( PSTACK, STACK_POS, PDESC, NAME ) \
42 opal_datatype_dump_stack( (PSTACK), (STACK_POS), (PDESC), (NAME) )
43 # if defined(ACCEPT_C99)
44 # define DUMP( ARGS... ) opal_output(opal_datatype_dfd, __VA_ARGS__)
45 # else
46 # if defined(__GNUC__) && !defined(__STDC__)
47 # define DUMP(ARGS...) opal_output( opal_datatype_dfd, ARGS)
48 # else
49 static inline void DUMP( char* fmt, ... )
50 {
51 va_list list;
52
53 va_start( list, fmt );
54 opal_output( opal_datatype_dfd, fmt, list );
55 va_end( list );
56 }
57 # define DUMP printf
58 # endif /* __GNUC__ && !__STDC__ */
59 # endif /* ACCEPT_C99 */
60 #else
61 # define DDT_DUMP_STACK( PSTACK, STACK_POS, PDESC, NAME )
62 # if defined(ACCEPT_C99)
63 # define DUMP(ARGS...)
64 # else
65 # if defined(__GNUC__) && !defined(__STDC__)
66 # define DUMP(ARGS...)
67 # else
68 /* If we do not compile with PGI, mark the parameter as unused */
69 # if !defined(__PGI)
70 # define __opal_attribute_unused_tmp__ __opal_attribute_unused__
71 # else
72 # define __opal_attribute_unused_tmp__
73 # endif
74 static inline void DUMP( char* fmt __opal_attribute_unused_tmp__, ... )
75 {
76 #if defined(__PGI)
77 /* Some compilers complain if we have "..." arguments and no
78 corresponding va_start() */
79 va_list arglist;
80 va_start(arglist, fmt);
81 va_end(arglist);
82 #endif
83 }
84 # undef __opal_attribute_unused_tmp__
85 # endif /* __GNUC__ && !__STDC__ */
86 # endif /* ACCEPT_C99 */
87 #endif /* VERBOSE */
88
89
90 /*
91 * There 3 types of predefined data types.
92 * - the basic one composed by just one basic datatype which are
93 * definitively contiguous
94 * - the derived ones where the same basic type is used multiple times.
95 * They should be most of the time contiguous.
96 * - and finally the derived one where multiple basic types are used.
97 * Depending on the architecture they can be contiguous or not.
98 *
99 * At the OPAL-level we do not care from which language the datatype came from
100 * (C, C++ or FORTRAN), we only focus on their internal representation in
101 * the host memory.
102 *
103 * NOTE: This (and in ompi_datatype_internal.h) is the id-order to obey
104 */
105 #define OPAL_DATATYPE_LOOP 0
106 #define OPAL_DATATYPE_END_LOOP 1
107 #define OPAL_DATATYPE_LB 2
108 #define OPAL_DATATYPE_UB 3
109 #define OPAL_DATATYPE_FIRST_TYPE 4 /* Number of first real type */
110 #define OPAL_DATATYPE_INT1 4
111 #define OPAL_DATATYPE_INT2 5
112 #define OPAL_DATATYPE_INT4 6
113 #define OPAL_DATATYPE_INT8 7
114 #define OPAL_DATATYPE_INT16 8
115 #define OPAL_DATATYPE_UINT1 9
116 #define OPAL_DATATYPE_UINT2 10
117 #define OPAL_DATATYPE_UINT4 11
118 #define OPAL_DATATYPE_UINT8 12
119 #define OPAL_DATATYPE_UINT16 13
120 #define OPAL_DATATYPE_FLOAT2 14
121 #define OPAL_DATATYPE_FLOAT4 15
122 #define OPAL_DATATYPE_FLOAT8 16
123 #define OPAL_DATATYPE_FLOAT12 17
124 #define OPAL_DATATYPE_FLOAT16 18
125 #define OPAL_DATATYPE_COMPLEX8 19
126 #define OPAL_DATATYPE_COMPLEX16 20
127 #define OPAL_DATATYPE_COMPLEX32 21
128 #define OPAL_DATATYPE_BOOL 22
129 #define OPAL_DATATYPE_WCHAR 23
130 #define OPAL_DATATYPE_UNAVAILABLE 24
131
132 #ifndef OPAL_DATATYPE_MAX_PREDEFINED
133 #define OPAL_DATATYPE_MAX_PREDEFINED 25
134 #endif
135
136 /*
137 * If the number of basic datatype should change update
138 * OPAL_DATATYPE_MAX_PREDEFINED in datatype.h
139 */
140 #if OPAL_DATATYPE_MAX_PREDEFINED <= OPAL_DATATYPE_UNAVAILABLE
141 #error OPAL_DATATYPE_MAX_PREDEFINED should be updated to the next value after the OPAL_DATATYPE_UNAVAILABLE define
142 #endif
143
144 #define DT_INCREASE_STACK 8
145
146 BEGIN_C_DECLS
147
148 struct ddt_elem_id_description {
149 uint16_t flags; /**< flags for the record */
150 uint16_t type; /**< the basic data type id */
151 };
152 typedef struct ddt_elem_id_description ddt_elem_id_description;
153
154 /* the basic element. A data description is composed
155 * by a set of basic elements.
156 */
157 struct ddt_elem_desc {
158 ddt_elem_id_description common; /**< basic data description and flags */
159 uint32_t count; /**< number of blocks */
160 uint32_t blocklen; /**< number of elements on each block */
161 OPAL_PTRDIFF_TYPE extent; /**< extent of each block (in bytes) */
162 OPAL_PTRDIFF_TYPE disp; /**< displacement of the first block */
163 };
164 typedef struct ddt_elem_desc ddt_elem_desc_t;
165
166 struct ddt_loop_desc {
167 ddt_elem_id_description common; /**< basic data description and flags */
168 uint32_t loops; /**< number of elements */
169 uint32_t items; /**< number of items in the loop */
170 size_t unused; /**< not used right now */
171 OPAL_PTRDIFF_TYPE extent; /**< extent of the whole loop */
172 };
173 typedef struct ddt_loop_desc ddt_loop_desc_t;
174
175 struct ddt_endloop_desc {
176 ddt_elem_id_description common; /**< basic data description and flags */
177 uint32_t items; /**< number of elements */
178 uint32_t unused; /**< not used right now */
179 size_t size; /**< real size of the data in the loop */
180 OPAL_PTRDIFF_TYPE first_elem_disp; /**< the displacement of the first block in the loop */
181 };
182 typedef struct ddt_endloop_desc ddt_endloop_desc_t;
183
184 union dt_elem_desc {
185 ddt_elem_desc_t elem;
186 ddt_loop_desc_t loop;
187 ddt_endloop_desc_t end_loop;
188 };
189
190 #define CREATE_LOOP_START( _place, _count, _items, _extent, _flags ) \
191 do { \
192 (_place)->loop.common.type = OPAL_DATATYPE_LOOP; \
193 (_place)->loop.common.flags = (_flags) & ~OPAL_DATATYPE_FLAG_DATA; \
194 (_place)->loop.loops = (_count); \
195 (_place)->loop.items = (_items); \
196 (_place)->loop.extent = (_extent); \
197 (_place)->loop.unused = -1; \
198 } while(0)
199
200 #define CREATE_LOOP_END( _place, _items, _first_item_disp, _size, _flags ) \
201 do { \
202 (_place)->end_loop.common.type = OPAL_DATATYPE_END_LOOP; \
203 (_place)->end_loop.common.flags = (_flags) & ~OPAL_DATATYPE_FLAG_DATA; \
204 (_place)->end_loop.items = (_items); \
205 (_place)->end_loop.first_elem_disp = (_first_item_disp); \
206 (_place)->end_loop.size = (_size); /* the size inside the loop */ \
207 (_place)->end_loop.unused = -1; \
208 } while(0)
209
210 #define CREATE_ELEM( _place, _type, _flags, _count, _disp, _extent ) \
211 do { \
212 (_place)->elem.common.flags = (_flags) | OPAL_DATATYPE_FLAG_DATA; \
213 (_place)->elem.common.type = (_type); \
214 (_place)->elem.count = (_count); \
215 (_place)->elem.disp = (_disp); \
216 (_place)->elem.extent = (_extent); \
217 (_place)->elem.blocklen = 1; \
218 } while(0)
219 /*
220 * This array holds the descriptions desc.desc[2] of the predefined basic datatypes.
221 */
222 OPAL_DECLSPEC extern union dt_elem_desc opal_datatype_predefined_elem_desc[2 * OPAL_DATATYPE_MAX_PREDEFINED];
223 struct opal_datatype_t;
224
225 /* Other fields starting after bdt_used (index of OPAL_DATATYPE_LOOP should be ONE) */
226 /*
227 * NOTE: The order of initialization *MUST* match the order of the OPAL_DATATYPE_-numbers.
228 * Unfortunateley, I don't get the preprocessor to replace
229 * OPAL_DATATYPE_INIT_BTYPES_ARRAY_ ## OPAL_DATATYPE ## NAME
230 * into
231 * OPAL_DATATYPE_INIT_BTYPES_ARRAY_[0-21], then order and naming would _not_ matter....
232 */
233 #define Z5 0, 0, 0, 0, 0
234 #define Z10 Z5, Z5
235 #define Z15 Z10, Z5
236 #define Z20 Z10, Z10
237 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_UNAVAILABLE { 0, }
238 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_LOOP { 1, }
239 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_END_LOOP { 0, 1, }
240 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_LB { 0, 0, 1, }
241 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_UB { 0, 0, 0, 1, }
242 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_INT1 { 0, 0, 0, 0, 1, }
243 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_INT2 { Z5, 1, } /*5*/
244 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_INT4 { Z5, 0, 1, }
245 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_INT8 { Z5, 0, 0, 1, }
246 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_INT16 { Z5, 0, 0, 0, 1, }
247 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_UINT1 { Z5, 0, 0, 0, 0, 1, }
248 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_UINT2 { Z10, 1, } /*10*/
249 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_UINT4 { Z10, 0, 1, }
250 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_UINT8 { Z10, 0, 0, 1, }
251 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_UINT16 { Z10, 0, 0, 0, 1, }
252 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_FLOAT2 { Z10, 0, 0, 0, 0, 1, }
253 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_FLOAT4 { Z15, 1, } /*15*/
254 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_FLOAT8 { Z15, 0, 1, }
255 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_FLOAT12 { Z15, 0, 0, 1, }
256 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_FLOAT16 { Z15, 0, 0, 0, 1, }
257 #if HAVE_FLOAT__COMPLEX
258 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_COMPLEX8 { Z15, 0, 0, 0, 0, 1 }
259 #else
260 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_COMPLEX8 { Z15, 2 } /* two floats */
261 #endif
262 #if HAVE_DOUBLE__COMPLEX
263 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_COMPLEX16 { Z15, 0, 0, 0, 0, 0, 1 }
264 #else
265 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_COMPLEX16 { Z15, 0, 2, }
266 #endif
267 #if HAVE_LONG_DOUBLE__COMPLEX
268 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_COMPLEX32 { Z15, 0, 0, 0, 0, 0, 0, 1 }
269 #else
270 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_COMPLEX32 { Z15, 0, 0, 0, 2, }
271 #endif
272 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_BOOL { Z20, 0, 1, } /*22*/
273 #define OPAL_DATATYPE_INIT_BTYPES_ARRAY_WCHAR { Z20, 0, 0, 1, }
274
275 #define OPAL_DATATYPE_INIT_NAME(NAME) "OPAL_" _OPAL_DATATYPE_INIT_NAME(NAME)
276 #define _OPAL_DATATYPE_INIT_NAME(NAME) #NAME
277
278 /*
279 * Macro to initialize the main description for basic types, setting the pointer
280 * into the array opal_datatype_predefined_type_desc, which is initialized at
281 * runtime in opal_datatype_init(). Each basic type has two desc-elements....
282 */
283 #define OPAL_DATATYPE_INIT_DESC_PREDEFINED(NAME) \
284 { \
285 1 /*length*/, 1/*used*/, \
286 &(opal_datatype_predefined_elem_desc[2 * OPAL_DATATYPE_ ## NAME]) /*desc*/ \
287 }
288 #define OPAL_DATATYPE_INIT_DESC_NULL {0 /*length*/, 0/*used*/, NULL /*desc*/}
289
290 #define OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( NAME, FLAGS ) \
291 { \
292 OPAL_OBJ_STATIC_INIT(opal_datatype_t), \
293 OPAL_DATATYPE_FLAG_UNAVAILABLE | OPAL_DATATYPE_FLAG_PREDEFINED | (FLAGS) /*flag*/, \
294 OPAL_DATATYPE_ ## NAME /*id*/, \
295 0 /*bdt_used*/, \
296 0 /*size*/, \
297 0 /*true_lb*/, 0 /*true_ub*/, 0 /*lb*/, 0 /*ub*/, \
298 0 /*align*/, \
299 1 /*nbElems*/, \
300 OPAL_DATATYPE_INIT_NAME(NAME), /*name*/ \
301 OPAL_DATATYPE_INIT_DESC_PREDEFINED(UNAVAILABLE), /*desc*/ \
302 OPAL_DATATYPE_INIT_DESC_PREDEFINED(UNAVAILABLE), /*opt_desc*/ \
303 OPAL_DATATYPE_INIT_BTYPES_ARRAY_UNAVAILABLE /*btypes*/ \
304 }
305
306 #define OPAL_DATATYPE_INITIALIZER_UNAVAILABLE( FLAGS ) \
307 OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( UNAVAILABLE, (FLAGS) )
308
309 #define OPAL_DATATYPE_INITIALIZER_EMPTY( FLAGS ) \
310 { \
311 OPAL_OBJ_STATIC_INIT(opal_datatype_t), \
312 OPAL_DATATYPE_FLAG_PREDEFINED | (FLAGS) /*flag*/, \
313 0 /*id*/, \
314 0 /*bdt_used*/, \
315 0 /*size*/, \
316 0 /*true_lb*/, 0 /*true_ub*/, 0 /*lb*/, 0 /*ub*/, \
317 0 /*align*/, \
318 1 /*nbElems*/, \
319 OPAL_DATATYPE_INIT_NAME(EMPTY), /*name*/ \
320 OPAL_DATATYPE_INIT_DESC_NULL, /*desc*/ \
321 OPAL_DATATYPE_INIT_DESC_NULL, /*opt_desc*/ \
322 OPAL_DATATYPE_INIT_BTYPES_ARRAY_UNAVAILABLE /*btypes*/ \
323 }
324
325 #define OPAL_DATATYPE_INIT_BASIC_TYPE( TYPE, NAME, FLAGS ) \
326 { \
327 OPAL_OBJ_STATIC_INIT(opal_datatype_t), \
328 OPAL_DATATYPE_FLAG_PREDEFINED | (FLAGS) /*flag*/, \
329 TYPE /*id*/, \
330 (((uint32_t)1)<<(TYPE)) /*bdt_used*/, \
331 0 /*size*/, \
332 0 /*true_lb*/, 0 /*true_ub*/, 0 /*lb*/, 0 /*ub*/, \
333 0 /*align*/, \
334 1 /*nbElems*/, \
335 OPAL_DATATYPE_INIT_NAME(NAME), /*name*/ \
336 OPAL_DATATYPE_INIT_DESC_NULL, /*desc*/ \
337 OPAL_DATATYPE_INIT_DESC_NULL, /*opt_desc*/ \
338 OPAL_DATATYPE_INIT_BTYPES_ARRAY_ ## NAME /*btypes*/ \
339 }
340
341 #define OPAL_DATATYPE_INIT_BASIC_DATATYPE( TYPE, ALIGN, NAME, FLAGS ) \
342 { \
343 OPAL_OBJ_STATIC_INIT(opal_datatype_t), \
344 OPAL_DATATYPE_FLAG_BASIC | (FLAGS) /*flag*/, \
345 OPAL_DATATYPE_ ## NAME /*id*/, \
346 (((uint32_t)1)<<(OPAL_DATATYPE_ ## NAME)) /*bdt_used*/, \
347 sizeof(TYPE) /*size*/, \
348 0 /*true_lb*/, sizeof(TYPE) /*true_ub*/, 0 /*lb*/, sizeof(TYPE) /*ub*/, \
349 (ALIGN) /*align*/, \
350 1 /*nbElems*/, \
351 OPAL_DATATYPE_INIT_NAME(NAME) /*name*/, \
352 OPAL_DATATYPE_INIT_DESC_PREDEFINED(NAME) /*desc*/, \
353 OPAL_DATATYPE_INIT_DESC_PREDEFINED(NAME) /*opt_desc*/, \
354 OPAL_DATATYPE_INIT_BTYPES_ARRAY_ ## NAME /*btypes*/ \
355 }
356
357 #define OPAL_DATATYPE_INITIALIZER_LOOP(FLAGS) OPAL_DATATYPE_INIT_BASIC_TYPE( OPAL_DATATYPE_LOOP, LOOP, FLAGS )
358 #define OPAL_DATATYPE_INITIALIZER_END_LOOP(FLAGS) OPAL_DATATYPE_INIT_BASIC_TYPE( OPAL_DATATYPE_END_LOOP, END_LOOP, FLAGS )
359 #define OPAL_DATATYPE_INITIALIZER_LB(FLAGS) OPAL_DATATYPE_INIT_BASIC_TYPE( OPAL_DATATYPE_LB, LB, FLAGS )
360 #define OPAL_DATATYPE_INITIALIZER_UB(FLAGS) OPAL_DATATYPE_INIT_BASIC_TYPE( OPAL_DATATYPE_UB, UB, FLAGS )
361 #define OPAL_DATATYPE_INITIALIZER_INT1(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( int8_t, OPAL_ALIGNMENT_INT8, INT1, FLAGS )
362 #define OPAL_DATATYPE_INITIALIZER_INT2(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( int16_t, OPAL_ALIGNMENT_INT16, INT2, FLAGS )
363 #define OPAL_DATATYPE_INITIALIZER_INT4(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( int32_t, OPAL_ALIGNMENT_INT32, INT4, FLAGS )
364 #define OPAL_DATATYPE_INITIALIZER_INT8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( int64_t, OPAL_ALIGNMENT_INT64, INT8, FLAGS )
365 #ifdef HAVE_INT128_T
366 #define OPAL_DATATYPE_INITIALIZER_INT16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( int128_t, OPAL_ALIGNMENT_INT128, INT16, FLAGS )
367 #else
368 #define OPAL_DATATYPE_INITIALIZER_INT16(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( INT16, FLAGS )
369 #endif
370 #define OPAL_DATATYPE_INITIALIZER_UINT1(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( uint8_t, OPAL_ALIGNMENT_INT8, UINT1, FLAGS )
371 #define OPAL_DATATYPE_INITIALIZER_UINT2(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( uint16_t, OPAL_ALIGNMENT_INT16, UINT2, FLAGS )
372 #define OPAL_DATATYPE_INITIALIZER_UINT4(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( uint32_t, OPAL_ALIGNMENT_INT32, UINT4, FLAGS )
373 #define OPAL_DATATYPE_INITIALIZER_UINT8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( uint64_t, OPAL_ALIGNMENT_INT64, UINT8, FLAGS )
374 #ifdef HAVE_UINT128_T
375 #define OPAL_DATATYPE_INITIALIZER_UINT16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( uint128_t, OPAL_ALIGNMENT_INT128, UINT16, FLAGS )
376 #else
377 #define OPAL_DATATYPE_INITIALIZER_UINT16(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( INT16, FLAGS )
378 #endif
379
380 #if SIZEOF_FLOAT == 2
381 #define OPAL_DATATYPE_INITIALIZER_FLOAT2(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( float, OPAL_ALIGNMENT_FLOAT, FLOAT2, FLAGS )
382 #elif SIZEOF_DOUBLE == 2
383 #define OPAL_DATATYPE_INITIALIZER_FLOAT2(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT2, FLAGS )
384 #elif SIZEOF_LONG_DOUBLE == 2
385 #define OPAL_DATATYPE_INITIALIZER_FLOAT2(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT2, FLAGS )
386 #else
387 #define OPAL_DATATYPE_INITIALIZER_FLOAT2(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT2, FLAGS )
388 #endif
389
390 #if SIZEOF_FLOAT == 4
391 #define OPAL_DATATYPE_INITIALIZER_FLOAT4(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( float, OPAL_ALIGNMENT_FLOAT, FLOAT4, FLAGS )
392 #elif SIZEOF_DOUBLE == 4
393 #define OPAL_DATATYPE_INITIALIZER_FLOAT4(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT4, FLAGS )
394 #elif SIZEOF_LONG_DOUBLE == 4
395 #define OPAL_DATATYPE_INITIALIZER_FLOAT4(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT4, FLAGS )
396 #else
397 #define OPAL_DATATYPE_INITIALIZER_FLOAT4(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT4, FLAGS )
398 #endif
399
400 #if SIZEOF_FLOAT == 8
401 #define OPAL_DATATYPE_INITIALIZER_FLOAT8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( float, OPAL_ALIGNMENT_FLOAT, FLOAT8, FLAGS )
402 #elif SIZEOF_DOUBLE == 8
403 #define OPAL_DATATYPE_INITIALIZER_FLOAT8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT8, FLAGS )
404 #elif SIZEOF_LONG_DOUBLE == 8
405 #define OPAL_DATATYPE_INITIALIZER_FLOAT8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT8, FLAGS )
406 #else
407 #define OPAL_DATATYPE_INITIALIZER_FLOAT8(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT8, FLAGS )
408 #endif
409
410 #if SIZEOF_FLOAT == 12
411 #define OPAL_DATATYPE_INITIALIZER_FLOAT12(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( float, OPAL_ALIGNMENT_FLOAT, FLOAT12, FLAGS )
412 #elif SIZEOF_DOUBLE == 12
413 #define OPAL_DATATYPE_INITIALIZER_FLOAT12(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT12, FLAGS )
414 #elif SIZEOF_LONG_DOUBLE == 12
415 #define OPAL_DATATYPE_INITIALIZER_FLOAT12(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT12, FLAGS )
416 #else
417 #define OPAL_DATATYPE_INITIALIZER_FLOAT12(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT12, FLAGS )
418 #endif
419
420 #if SIZEOF_FLOAT == 16
421 #define OPAL_DATATYPE_INITIALIZER_FLOAT16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( float, OPAL_ALIGNMENT_FLOAT, FLOAT16, FLAGS )
422 #elif SIZEOF_DOUBLE == 16
423 #define OPAL_DATATYPE_INITIALIZER_FLOAT16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double, OPAL_ALIGNMENT_DOUBLE, FLOAT16, FLAGS )
424 #elif SIZEOF_LONG_DOUBLE == 16
425 #define OPAL_DATATYPE_INITIALIZER_FLOAT16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double, OPAL_ALIGNMENT_LONG_DOUBLE, FLOAT16, FLAGS )
426 #else
427 #define OPAL_DATATYPE_INITIALIZER_FLOAT16(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( FLOAT16, FLAGS )
428 #endif
429
430 /*
431 * Until we figure out the whole logic behing the _Complex type, disable it. It only exists
432 * in C99 (i.e. __STDC_VERSION__ >= 199901L) but [evidently] not all compilers correctly
433 * export the __STDC_VERSION__.
434 * http://predef.sourceforge.net/prestd.html for more info.
435 */
436
437 #define OPAL_USE_FLOAT__COMPLEX (0 && HAVE_FLOAT__COMPLEX)
438 #define OPAL_USE_DOUBLE__COMPLEX (0 && HAVE_DOUBLE__COMPLEX)
439 #define OPAL_USE_LONG_DOUBLE__COMPLEX (0 && HAVE_LONG_DOUBLE__COMPLEX)
440
441 #if OPAL_USE_FLOAT__COMPLEX && (SIZEOF_FLOAT__COMPLEX == 8)
442 #define OPAL_DATATYPE_INITIALIZER_COMPLEX8(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( float _Complex, OPAL_ALIGNMENT_FLOAT_COMPLEX, COMPLEX8, (FLAGS) )
443 #else
444
445 #if SIZEOF_FLOAT == 4
446 typedef struct {
447 float r;
448 float i;
449 } opal_complex_float_t;
450
451 #define OPAL_DATATYPE_INITIALIZER_COMPLEX8( FLAGS ) \
452 { \
453 OPAL_OBJ_STATIC_INIT(opal_datatype_t), \
454 OPAL_DATATYPE_FLAG_BASIC | (FLAGS) /*flag*/, \
455 OPAL_DATATYPE_COMPLEX8 /*id*/, \
456 (((uint32_t)1)<<(OPAL_DATATYPE_ ## FLOAT4)) /*bdt_used*/, \
457 sizeof(opal_complex_float_t) /*size*/, \
458 0 /*true_lb*/, sizeof(opal_complex_float_t) /*true_ub*/, 0 /*lb*/, sizeof(opal_complex_float_t) /*ub*/, \
459 OPAL_ALIGNMENT_FLOAT /*align*/, \
460 2 /*nbElems*/, \
461 OPAL_DATATYPE_INIT_NAME(COMPLEX8) /*name*/, \
462 OPAL_DATATYPE_INIT_DESC_PREDEFINED(COMPLEX8) /*desc*/, \
463 OPAL_DATATYPE_INIT_DESC_PREDEFINED(COMPLEX8) /*opt_desc*/, \
464 {Z15, 2, } /*btypes*/ \
465 }
466 #else
467 #define OPAL_DATATYPE_INITIALIZER_COMPLEX8(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( COMPLEX8, FLAGS )
468 #endif
469
470 #endif /* HAVE_FLOAT__COMPLEX */
471
472 #if OPAL_USE_DOUBLE__COMPLEX && (SIZEOF_DOUBLE__COMPLEX == 16)
473 #define OPAL_DATATYPE_INITIALIZER_COMPLEX16(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( double _Complex, OPAL_ALIGNMENT_DOUBLE_COMPLEX, COMPLEX16, (FLAGS) )
474 #else
475
476 #if SIZEOF_DOUBLE == 8
477 typedef struct {
478 double r;
479 double i;
480 } opal_complex_double_t;
481
482 #define OPAL_DATATYPE_INITIALIZER_COMPLEX16( FLAGS ) \
483 { \
484 OPAL_OBJ_STATIC_INIT(opal_datatype_t), \
485 OPAL_DATATYPE_FLAG_BASIC | (FLAGS) /*flag*/, \
486 OPAL_DATATYPE_COMPLEX16 /*id*/, \
487 (((uint32_t)1)<<(OPAL_DATATYPE_ ## FLOAT8)) /*bdt_used*/, \
488 sizeof(opal_complex_double_t) /*size*/, \
489 0 /*true_lb*/, sizeof(opal_complex_double_t) /*true_ub*/, 0 /*lb*/, sizeof(opal_complex_double_t) /*ub*/, \
490 OPAL_ALIGNMENT_DOUBLE /*align*/, \
491 2 /*nbElems*/, \
492 OPAL_DATATYPE_INIT_NAME(COMPLEX16) /*name*/, \
493 OPAL_DATATYPE_INIT_DESC_PREDEFINED(COMPLEX16) /*desc*/, \
494 OPAL_DATATYPE_INIT_DESC_PREDEFINED(COMPLEX16) /*opt_desc*/, \
495 {Z15, 2, } /*btypes*/ \
496 }
497 #else
498 #define OPAL_DATATYPE_INITIALIZER_COMPLEX16(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( COMPLEX16, FLAGS )
499 #endif
500
501 #endif /* HAVE_DOUBLE__COMPLEX */
502
503 #if OPAL_USE_LONG_DOUBLE__COMPLEX && (SIZEOF_LONG_DOUBLE__COMPLEX == 32)
504 #define OPAL_DATATYPE_INITIALIZER_COMPLEX32(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( long double _Complex, OPAL_ALIGNMENT_LONG_DOUBLE_COMPLEX, COMPLEX32, (FLAGS) )
505 #else
506
507 #if HAVE_LONG_DOUBLE && (SIZEOF_LONG_DOUBLE == 16)
508 typedef struct {
509 long double r;
510 long double i;
511 } opal_complex_long_double_t;
512
513 #define OPAL_DATATYPE_INITIALIZER_COMPLEX32( FLAGS ) \
514 { \
515 OPAL_OBJ_STATIC_INIT(opal_datatype_t), \
516 OPAL_DATATYPE_FLAG_BASIC | (FLAGS) /*flag*/, \
517 OPAL_DATATYPE_COMPLEX32 /*id*/, \
518 (((uint32_t)1)<<(OPAL_DATATYPE_ ## FLOAT16)) /*bdt_used*/, \
519 sizeof(opal_complex_long_double_t) /*size*/, \
520 0 /*true_lb*/, sizeof(opal_complex_long_double_t) /*true_ub*/, 0 /*lb*/, sizeof(opal_complex_long_double_t) /*ub*/, \
521 OPAL_ALIGNMENT_LONG_DOUBLE /*align*/, \
522 2 /*nbElems*/, \
523 OPAL_DATATYPE_INIT_NAME(COMPLEX32) /*name*/, \
524 OPAL_DATATYPE_INIT_DESC_PREDEFINED(COMPLEX32) /*desc*/, \
525 OPAL_DATATYPE_INIT_DESC_PREDEFINED(COMPLEX32) /*opt_desc*/, \
526 {Z15, 2, } /*btypes*/ \
527 }
528 #else
529 #define OPAL_DATATYPE_INITIALIZER_COMPLEX32(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( COMPLEX32, FLAGS )
530 #endif
531
532 #endif /* HAVE_LONG_DOUBLE__COMPLEX */
533
534 #define OPAL_DATATYPE_INITIALIZER_BOOL(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( _Bool, OPAL_ALIGNMENT_BOOL, BOOL, FLAGS )
535
536 #if OPAL_ALIGNMENT_WCHAR != 0
537 #define OPAL_DATATYPE_INITIALIZER_WCHAR(FLAGS) OPAL_DATATYPE_INIT_BASIC_DATATYPE( wchar_t, OPAL_ALIGNMENT_WCHAR, WCHAR, FLAGS )
538 #else
539 #define OPAL_DATATYPE_INITIALIZER_WCHAR(FLAGS) OPAL_DATATYPE_INITIALIZER_UNAVAILABLE_NAMED( WCHAR, FLAGS )
540 #endif
541
542
543 #define BASIC_DDT_FROM_ELEM( ELEM ) (opal_datatype_basicDatatypes[(ELEM).elem.common.type])
544
545 #define SAVE_STACK( PSTACK, INDEX, TYPE, COUNT, DISP) \
546 do { \
547 (PSTACK)->index = (INDEX); \
548 (PSTACK)->type = (TYPE); \
549 (PSTACK)->count = (COUNT); \
550 (PSTACK)->disp = (DISP); \
551 } while(0)
552
553 #define PUSH_STACK( PSTACK, STACK_POS, INDEX, TYPE, COUNT, DISP) \
554 do { \
555 dt_stack_t* pTempStack = (PSTACK) + 1; \
556 SAVE_STACK( pTempStack, (INDEX), (TYPE), (COUNT), (DISP) ); \
557 (STACK_POS)++; \
558 (PSTACK) = pTempStack; \
559 } while(0)
560
561 #if OPAL_ENABLE_DEBUG
562 #define OPAL_DATATYPE_SAFEGUARD_POINTER( ACTPTR, LENGTH, INITPTR, PDATA, COUNT ) \
563 { \
564 unsigned char *__lower_bound = (INITPTR), *__upper_bound; \
565 assert( ((LENGTH) != 0) && ((COUNT) != 0) ); \
566 __lower_bound += (PDATA)->true_lb; \
567 __upper_bound = (INITPTR) + (PDATA)->true_ub + \
568 ((PDATA)->ub - (PDATA)->lb) * ((COUNT) - 1); \
569 if( ((ACTPTR) < __lower_bound) || ((ACTPTR) >= __upper_bound) ) { \
570 opal_datatype_safeguard_pointer_debug_breakpoint( (ACTPTR), (LENGTH), (INITPTR), (PDATA), (COUNT) ); \
571 opal_output( 0, "%s:%d\n\tPointer %p size %lu is outside [%p,%p] for\n\tbase ptr %p count %lu and data \n", \
572 __FILE__, __LINE__, (ACTPTR), (unsigned long)(LENGTH), __lower_bound, __upper_bound, \
573 (INITPTR), (unsigned long)(COUNT) ); \
574 opal_datatype_dump( (PDATA) ); \
575 } \
576 }
577
578 #else
579 #define OPAL_DATATYPE_SAFEGUARD_POINTER( ACTPTR, LENGTH, INITPTR, PDATA, COUNT )
580 #endif /* OPAL_ENABLE_DEBUG */
581
582 static inline int GET_FIRST_NON_LOOP( const union dt_elem_desc* _pElem )
583 {
584 int element_index = 0;
585
586 /* We dont have to check for the end as we always put an END_LOOP
587 * at the end of all datatype descriptions.
588 */
589 while( _pElem->elem.common.type == OPAL_DATATYPE_LOOP ) {
590 ++_pElem; element_index++;
591 }
592 return element_index;
593 }
594
595 #define UPDATE_INTERNAL_COUNTERS( DESCRIPTION, POSITION, ELEMENT, COUNTER ) \
596 do { \
597 (ELEMENT) = &((DESCRIPTION)[(POSITION)]); \
598 (COUNTER) = (ELEMENT)->elem.count; \
599 } while (0)
600
601 OPAL_DECLSPEC int opal_datatype_contain_basic_datatypes( const struct opal_datatype_t* pData, char* ptr, size_t length );
602 OPAL_DECLSPEC int opal_datatype_dump_data_flags( unsigned short usflags, char* ptr, size_t length );
603 OPAL_DECLSPEC int opal_datatype_dump_data_desc( union dt_elem_desc* pDesc, int nbElems, char* ptr, size_t length );
604
605 END_C_DECLS
606 #endif /* OPAL_DATATYPE_INTERNAL_H_HAS_BEEN_INCLUDED */
ddt_elem_desc::extent
OPAL_PTRDIFF_TYPE extent
extent of each block (in bytes)
Definition: opal_datatype_internal.h:161
output.h
OPAL output stream facility.
ddt_endloop_desc
Definition: opal_datatype_internal.h:175
ddt_endloop_desc::first_elem_disp
OPAL_PTRDIFF_TYPE first_elem_disp
the displacement of the first block in the loop
Definition: opal_datatype_internal.h:180
ddt_loop_desc::loops
uint32_t loops
number of elements
Definition: opal_datatype_internal.h:168
dt_elem_desc
Definition: opal_datatype_internal.h:184
ddt_loop_desc
Definition: opal_datatype_internal.h:166
ddt_loop_desc::unused
size_t unused
not used right now
Definition: opal_datatype_internal.h:170
ddt_loop_desc::items
uint32_t items
number of items in the loop
Definition: opal_datatype_internal.h:169
ddt_elem_id_description
Definition: opal_datatype_internal.h:148
ddt_elem_desc::common
ddt_elem_id_description common
basic data description and flags
Definition: opal_datatype_internal.h:158
ddt_elem_id_description::type
uint16_t type
the basic data type id
Definition: opal_datatype_internal.h:150
ddt_elem_desc::count
uint32_t count
number of blocks
Definition: opal_datatype_internal.h:159
opal_output
OPAL_DECLSPEC void opal_output(int output_id, const char *format,...) __opal_attribute_format__(__printf__
Main function to send output to a stream.
ddt_endloop_desc::size
size_t size
real size of the data in the loop
Definition: opal_datatype_internal.h:179
ddt_elem_desc::blocklen
uint32_t blocklen
number of elements on each block
Definition: opal_datatype_internal.h:160
ddt_loop_desc::extent
OPAL_PTRDIFF_TYPE extent
extent of the whole loop
Definition: opal_datatype_internal.h:171
opal_datatype_t
Definition: opal_datatype.h:103
ddt_endloop_desc::items
uint32_t items
number of elements
Definition: opal_datatype_internal.h:177
ddt_loop_desc::common
ddt_elem_id_description common
basic data description and flags
Definition: opal_datatype_internal.h:167
ddt_elem_id_description::flags
uint16_t flags
flags for the record
Definition: opal_datatype_internal.h:149
ddt_endloop_desc::common
ddt_elem_id_description common
basic data description and flags
Definition: opal_datatype_internal.h:176
ddt_elem_desc
Definition: opal_datatype_internal.h:157
ddt_endloop_desc::unused
uint32_t unused
not used right now
Definition: opal_datatype_internal.h:178
ddt_elem_desc::disp
OPAL_PTRDIFF_TYPE disp
displacement of the first block
Definition: opal_datatype_internal.h:162