|
3 | 3 | * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
|
4 | 4 | * University Research and Technology
|
5 | 5 | * Corporation. All rights reserved.
|
6 |
| - * Copyright (c) 2004-2017 The University of Tennessee and The University |
| 6 | + * Copyright (c) 2004-2019 The University of Tennessee and The University |
7 | 7 | * of Tennessee Research Foundation. All rights
|
8 | 8 | * reserved.
|
9 | 9 | * Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
|
@@ -71,97 +71,99 @@ opal_unpack_homogeneous_contig_function( opal_convertor_t* pConv,
|
71 | 71 | const opal_datatype_t *pData = pConv->pDesc;
|
72 | 72 | unsigned char *user_memory, *packed_buffer;
|
73 | 73 | uint32_t iov_count, i;
|
74 |
| - size_t bConverted, remaining, length, initial_bytes_converted = pConv->bConverted; |
| 74 | + size_t remaining, length, initial_bytes_converted = pConv->bConverted; |
75 | 75 | dt_stack_t* stack = pConv->pStack;
|
76 | 76 | ptrdiff_t extent = pData->ub - pData->lb;
|
77 |
| - ptrdiff_t initial_displ = pConv->use_desc->desc[pConv->use_desc->used].end_loop.first_elem_disp; |
78 | 77 |
|
79 | 78 | DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( pBaseBuf %p, iov_count %d )\n",
|
80 | 79 | (void*)pConv->pBaseBuf, *out_size ); );
|
81 | 80 | if( stack[1].type != opal_datatype_uint1.id ) {
|
82 | 81 | stack[1].count *= opal_datatype_basicDatatypes[stack[1].type]->size;
|
83 | 82 | stack[1].type = opal_datatype_uint1.id;
|
84 | 83 | }
|
| 84 | + |
85 | 85 | for( iov_count = 0; iov_count < (*out_size); iov_count++ ) {
|
86 | 86 | remaining = pConv->local_size - pConv->bConverted;
|
87 | 87 | if( 0 == remaining ) break; /* we're done this time */
|
88 | 88 | if( remaining > iov[iov_count].iov_len )
|
89 | 89 | remaining = iov[iov_count].iov_len;
|
90 | 90 | packed_buffer = (unsigned char*)iov[iov_count].iov_base;
|
91 |
| - bConverted = remaining; /* how much will get unpacked this time */ |
92 |
| - user_memory = pConv->pBaseBuf + initial_displ; |
| 91 | + pConv->bConverted += remaining; /* how much will get unpacked this time */ |
| 92 | + user_memory = pConv->pBaseBuf + pData->true_lb; |
93 | 93 |
|
94 | 94 | if( (ptrdiff_t)pData->size == extent ) {
|
95 | 95 | user_memory += pConv->bConverted;
|
96 |
| - DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %lu\n", |
97 |
| - (void*)user_memory, (void*)packed_buffer, (unsigned long)remaining ); ); |
| 96 | + DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %" PRIsize_t "\n", |
| 97 | + (void*)user_memory, (void*)packed_buffer, remaining ); ); |
98 | 98 |
|
99 | 99 | /* contiguous data or basic datatype with count */
|
100 | 100 | OPAL_DATATYPE_SAFEGUARD_POINTER( user_memory, remaining,
|
101 | 101 | pConv->pBaseBuf, pData, pConv->count );
|
102 |
| - DO_DEBUG( opal_output( 0, "1. unpack contig dest %p src %p length %lu\n", |
103 |
| - (void*)user_memory, (void*)packed_buffer, (unsigned long)remaining ); ); |
| 102 | + DO_DEBUG( opal_output( 0, "1. unpack contig dest %p src %p length %" PRIsize_t "\n", |
| 103 | + (void*)user_memory, (void*)packed_buffer, remaining ); ); |
104 | 104 | MEMCPY_CSUM( user_memory, packed_buffer, remaining, pConv );
|
105 | 105 | } else {
|
106 | 106 | user_memory += stack[0].disp + stack[1].disp;
|
107 | 107 |
|
108 |
| - DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %lu\n", |
109 |
| - (void*)user_memory, (void*)packed_buffer, (unsigned long)remaining ); ); |
| 108 | + DO_DEBUG( opal_output( 0, "unpack_homogeneous_contig( user_memory %p, packed_buffer %p length %" PRIsize_t "\n", |
| 109 | + (void*)user_memory, (void*)packed_buffer, remaining ); ); |
110 | 110 |
|
111 | 111 | length = (0 == pConv->stack_pos ? 0 : stack[1].count); /* left over from the last unpack */
|
112 | 112 | /* complete the last copy */
|
113 |
| - if( (0 != length) && (length <= remaining) ) { |
| 113 | + if( (pData->size != length) && (length <= remaining) ) { |
114 | 114 | OPAL_DATATYPE_SAFEGUARD_POINTER( user_memory, length, pConv->pBaseBuf,
|
115 | 115 | pData, pConv->count );
|
116 |
| - DO_DEBUG( opal_output( 0, "2. unpack dest %p src %p length %lu\n", |
117 |
| - (void*)user_memory, (void*)packed_buffer, (unsigned long)length ); ); |
| 116 | + DO_DEBUG( opal_output( 0, "2. unpack dest %p src %p length %" PRIsize_t "\n", |
| 117 | + (void*)user_memory, (void*)packed_buffer, length ); ); |
118 | 118 | MEMCPY_CSUM( user_memory, packed_buffer, length, pConv );
|
119 | 119 | packed_buffer += length;
|
120 |
| - user_memory += (extent - (pData->size - length)); |
121 | 120 | remaining -= length;
|
122 | 121 | stack[1].count -= length;
|
| 122 | + stack[1].disp += length; /* just in case, we overwrite this below */ |
123 | 123 | if( 0 == stack[1].count) { /* one completed element */
|
124 | 124 | stack[0].count--;
|
125 | 125 | stack[0].disp += extent;
|
126 |
| - if( 0 != stack[0].count ) { /* not yet done */ |
127 |
| - stack[1].count = pData->size; |
128 |
| - stack[1].disp = 0; |
129 |
| - } |
| 126 | + if( 0 == stack[0].count ) |
| 127 | + break; |
| 128 | + stack[1].count = pData->size; |
| 129 | + stack[1].disp = 0; |
130 | 130 | }
|
| 131 | + user_memory = pConv->pBaseBuf + pData->true_lb + stack[0].disp + stack[1].disp; |
131 | 132 | }
|
| 133 | + |
132 | 134 | for( i = 0; pData->size <= remaining; i++ ) {
|
133 | 135 | OPAL_DATATYPE_SAFEGUARD_POINTER( user_memory, pData->size, pConv->pBaseBuf,
|
134 | 136 | pData, pConv->count );
|
135 |
| - DO_DEBUG( opal_output( 0, "3. unpack dest %p src %p length %lu\n", |
136 |
| - (void*)user_memory, (void*)packed_buffer, (unsigned long)pData->size ); ); |
| 137 | + DO_DEBUG( opal_output( 0, "3. unpack dest %p src %p length %" PRIsize_t "\n", |
| 138 | + (void*)user_memory, (void*)packed_buffer, pData->size ); ); |
137 | 139 | MEMCPY_CSUM( user_memory, packed_buffer, pData->size, pConv );
|
138 | 140 | packed_buffer += pData->size;
|
139 | 141 | user_memory += extent;
|
140 | 142 | remaining -= pData->size;
|
141 | 143 | }
|
142 | 144 | stack[0].count -= i;
|
143 | 145 | stack[0].disp += (i * extent);
|
144 |
| - stack[1].disp += remaining; |
145 |
| - /* copy the last bits */ |
| 146 | + |
| 147 | + /* Copy the last bits */ |
146 | 148 | if( 0 != remaining ) {
|
147 | 149 | OPAL_DATATYPE_SAFEGUARD_POINTER( user_memory, remaining, pConv->pBaseBuf,
|
148 | 150 | pData, pConv->count );
|
149 |
| - DO_DEBUG( opal_output( 0, "4. unpack dest %p src %p length %lu\n", |
150 |
| - (void*)user_memory, (void*)packed_buffer, (unsigned long)remaining ); ); |
| 151 | + DO_DEBUG( opal_output( 0, "4. unpack dest %p src %p length %" PRIsize_t "\n", |
| 152 | + (void*)user_memory, (void*)packed_buffer, remaining ); ); |
151 | 153 | MEMCPY_CSUM( user_memory, packed_buffer, remaining, pConv );
|
152 |
| - user_memory += remaining; |
153 | 154 | stack[1].count -= remaining;
|
| 155 | + stack[1].disp += remaining; /* keep the += in case we are copying less that the datatype size */ |
| 156 | + if( 0 == stack[1].count ) { /* prepare for the next element */ |
| 157 | + stack[1].count = pData->size; |
| 158 | + stack[1].disp = 0; |
| 159 | + } |
154 | 160 | }
|
155 | 161 | }
|
156 |
| - pConv->bConverted += bConverted; |
157 | 162 | }
|
158 | 163 | *out_size = iov_count; /* we only reach this line after the for loop succesfully complete */
|
159 |
| - *max_data = (pConv->bConverted - initial_bytes_converted); |
160 |
| - if( pConv->bConverted == pConv->local_size ) { |
161 |
| - pConv->flags |= CONVERTOR_COMPLETED; |
162 |
| - return 1; |
163 |
| - } |
164 |
| - return 0; |
| 164 | + *max_data = pConv->bConverted - initial_bytes_converted; |
| 165 | + if( pConv->bConverted == pConv->local_size ) pConv->flags |= CONVERTOR_COMPLETED; |
| 166 | + return !!(pConv->flags & CONVERTOR_COMPLETED); /* done or not */ |
165 | 167 | }
|
166 | 168 |
|
167 | 169 | /**
|
|
0 commit comments