|
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-2014 The University of Tennessee and The University |
| 6 | + * Copyright (c) 2004-2015 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,
|
@@ -247,32 +247,28 @@ int32_t ompi_datatype_create_darray(int size,
|
247 | 247 | }
|
248 | 248 |
|
249 | 249 |
|
250 |
| - /* set displacement and UB correctly. Please read the comment in subarray */ |
| 250 | + /** |
| 251 | + * We need to shift the content (useful data) of the datatype, so |
| 252 | + * we need to force the displacement to be moved. Therefore, we |
| 253 | + * cannot use resize as it will only set the soft lb and ub |
| 254 | + * markers without moving the data. Instead, we have to create a |
| 255 | + * new data, and insert the last_Type with the correct |
| 256 | + * displacement. |
| 257 | + */ |
251 | 258 | {
|
252 |
| - ptrdiff_t displs[3], tmp_size; |
253 |
| - ompi_datatype_t *types[3]; |
254 |
| - int blength[3] = { 1, 1, 1}; |
| 259 | + ptrdiff_t displs[2], tmp_size = 1; |
255 | 260 |
|
256 |
| - displs[1] = st_offsets[start_loop]; |
257 |
| - tmp_size = 1; |
258 |
| - for (i = start_loop + step ; i != end_loop ; i += step) { |
| 261 | + displs[0] = st_offsets[start_loop]; |
| 262 | + displs[1] = orig_extent; |
| 263 | + for (i = start_loop + step; i != end_loop; i += step) { |
259 | 264 | tmp_size *= gsize_array[i - step];
|
260 |
| - displs[1] += tmp_size * st_offsets[i]; |
| 265 | + displs[0] += tmp_size * st_offsets[i]; |
| 266 | + displs[1] *= gsize_array[i]; |
261 | 267 | }
|
| 268 | + displs[0] *= orig_extent; |
262 | 269 |
|
263 |
| - displs[0] = 0; |
264 |
| - displs[1] *= orig_extent; |
265 |
| - displs[2] = orig_extent; |
266 |
| - for (i = 0 ; i < ndims ; i++) { |
267 |
| - displs[2] *= gsize_array[i]; |
268 |
| - } |
269 |
| - if(oldtype->super.flags & (OPAL_DATATYPE_FLAG_USER_LB | OPAL_DATATYPE_FLAG_USER_UB) ) { |
270 |
| - types[0] = MPI_LB; types[1] = lastType; types[2] = MPI_UB; |
271 |
| - |
272 |
| - rc = ompi_datatype_create_struct(3, blength, displs, types, newtype); |
273 |
| - } else { |
274 |
| - ompi_datatype_create_resized(lastType, displs[1], displs[2], newtype); |
275 |
| - } |
| 270 | + *newtype = ompi_datatype_create(lastType->super.desc.used); |
| 271 | + ompi_datatype_add(*newtype, lastType, 1, displs[0], displs[1]); |
276 | 272 | ompi_datatype_destroy(&lastType);
|
277 | 273 | /* need to destroy the old type even in error condition, so
|
278 | 274 | don't check return code from above until after cleanup. */
|
|
0 commit comments