This source file includes following definitions.
- opal_datatype_contain_basic_datatypes
- opal_datatype_dump_data_flags
- opal_datatype_dump_data_desc
- opal_datatype_dump
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #include "opal_config.h"
26
27 #include <stdlib.h>
28 #include <stdio.h>
29
30 #include "opal/constants.h"
31 #include "opal/util/output.h"
32 #include "opal/datatype/opal_datatype.h"
33 #include "opal/datatype/opal_datatype_internal.h"
34
35
36
37
38
39 int opal_datatype_contain_basic_datatypes( const opal_datatype_t* pData, char* ptr, size_t length )
40 {
41 int i;
42 int32_t index = 0;
43 uint64_t mask = 1;
44
45 if( pData->flags & OPAL_DATATYPE_FLAG_USER_LB ) index += snprintf( ptr, length - index, "lb " );
46 if( pData->flags & OPAL_DATATYPE_FLAG_USER_UB ) index += snprintf( ptr + index, length - index, "ub " );
47 for( i = 0; i < OPAL_DATATYPE_MAX_PREDEFINED; i++ ) {
48 if( pData->bdt_used & mask ) {
49 if( NULL == pData->ptypes ) {
50 index += snprintf( ptr + index, length - index, "%s:* ", opal_datatype_basicDatatypes[i]->name );
51 } else {
52 index += snprintf( ptr + index, length - index, "%s:%" PRIsize_t " ", opal_datatype_basicDatatypes[i]->name,
53 pData->ptypes[i]);
54 }
55 }
56 mask <<= 1;
57 if( length <= (size_t)index ) break;
58 }
59 return index;
60 }
61
62 int opal_datatype_dump_data_flags( unsigned short usflags, char* ptr, size_t length )
63 {
64 int index = 0;
65 if( length < 22 ) return 0;
66 index = snprintf( ptr, 22, "-----------[---][---]" );
67 if( usflags & OPAL_DATATYPE_FLAG_COMMITTED ) ptr[1] = 'c';
68 if( usflags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) ptr[2] = 'C';
69 if( usflags & OPAL_DATATYPE_FLAG_OVERLAP ) ptr[3] = 'o';
70 if( usflags & OPAL_DATATYPE_FLAG_USER_LB ) ptr[4] = 'l';
71 if( usflags & OPAL_DATATYPE_FLAG_USER_UB ) ptr[5] = 'u';
72 if( usflags & OPAL_DATATYPE_FLAG_PREDEFINED ) ptr[6] = 'P';
73 if( !(usflags & OPAL_DATATYPE_FLAG_NO_GAPS) ) ptr[7] = 'G';
74 if( usflags & OPAL_DATATYPE_FLAG_DATA ) ptr[8] = 'D';
75 if( (usflags & OPAL_DATATYPE_FLAG_BASIC) == OPAL_DATATYPE_FLAG_BASIC ) ptr[9] = 'B';
76
77
78 return index;
79 }
80
81
82 int opal_datatype_dump_data_desc( dt_elem_desc_t* pDesc, int nbElems, char* ptr, size_t length )
83 {
84 int i;
85 int32_t index = 0;
86
87 for( i = 0; i < nbElems; i++ ) {
88 index += opal_datatype_dump_data_flags( pDesc->elem.common.flags, ptr + index, length );
89 if( length <= (size_t)index ) break;
90 index += snprintf( ptr + index, length - index, "%15s ", opal_datatype_basicDatatypes[pDesc->elem.common.type]->name );
91 if( length <= (size_t)index ) break;
92 if( OPAL_DATATYPE_LOOP == pDesc->elem.common.type )
93 index += snprintf( ptr + index, length - index, "%u times the next %u elements extent %td\n",
94 pDesc->loop.loops, pDesc->loop.items,
95 pDesc->loop.extent );
96 else if( OPAL_DATATYPE_END_LOOP == pDesc->elem.common.type )
97 index += snprintf( ptr + index, length - index, "prev %u elements first elem displacement %td size of data %" PRIsize_t "\n",
98 pDesc->end_loop.items, pDesc->end_loop.first_elem_disp,
99 pDesc->end_loop.size );
100 else
101 index += snprintf( ptr + index, length - index, "count %" PRIsize_t " disp 0x%tx (%td) blen %u extent %td (size %zd)\n",
102 pDesc->elem.count, pDesc->elem.disp, pDesc->elem.disp, pDesc->elem.blocklen,
103 pDesc->elem.extent, (pDesc->elem.count * pDesc->elem.blocklen * opal_datatype_basicDatatypes[pDesc->elem.common.type]->size) );
104 pDesc++;
105
106 if( length <= (size_t)index ) break;
107 }
108 return index;
109 }
110
111
112 void opal_datatype_dump( const opal_datatype_t* pData )
113 {
114 size_t length;
115 int index = 0;
116 char* buffer;
117
118 length = pData->opt_desc.used + pData->desc.used;
119 length = length * 100 + 500;
120 buffer = (char*)malloc( length );
121 index += snprintf( buffer, length - index, "Datatype %p[%s] size %" PRIsize_t " align %u id %u length %" PRIsize_t " used %" PRIsize_t "\n"
122 "true_lb %td true_ub %td (true_extent %td) lb %td ub %td (extent %td)\n"
123 "nbElems %" PRIsize_t " loops %u flags %X (",
124 (void*)pData, pData->name, pData->size, pData->align, (uint32_t)pData->id, pData->desc.length, pData->desc.used,
125 pData->true_lb, pData->true_ub, pData->true_ub - pData->true_lb,
126 pData->lb, pData->ub, pData->ub - pData->lb,
127 pData->nbElems, pData->loops, (int)pData->flags );
128
129 if( pData->flags == OPAL_DATATYPE_FLAG_PREDEFINED )
130 index += snprintf( buffer + index, length - index, "predefined " );
131 else {
132 if( pData->flags & OPAL_DATATYPE_FLAG_COMMITTED ) index += snprintf( buffer + index, length - index, "committed " );
133 if( pData->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS) index += snprintf( buffer + index, length - index, "contiguous " );
134 }
135 index += snprintf( buffer + index, length - index, ")" );
136 index += opal_datatype_dump_data_flags( pData->flags, buffer + index, length - index );
137 {
138 index += snprintf( buffer + index, length - index, "\n contain " );
139 index += opal_datatype_contain_basic_datatypes( pData, buffer + index, length - index );
140 index += snprintf( buffer + index, length - index, "\n" );
141 }
142 if( (pData->opt_desc.desc != pData->desc.desc) && (NULL != pData->opt_desc.desc) ) {
143
144
145
146 index += opal_datatype_dump_data_desc( pData->desc.desc, pData->desc.used + 1, buffer + index, length - index );
147 index += snprintf( buffer + index, length - index, "Optimized description \n" );
148 index += opal_datatype_dump_data_desc( pData->opt_desc.desc, pData->opt_desc.used + 1, buffer + index, length - index );
149 } else {
150 index += opal_datatype_dump_data_desc( pData->desc.desc, pData->desc.used, buffer + index, length - index );
151 index += snprintf( buffer + index, length - index, "No optimized description\n" );
152 }
153 buffer[index] = '\0';
154 opal_output( 0, "%s\n", buffer );
155
156 free(buffer);
157 }