Skip to content

Commit 3e317d7

Browse files
committed
[from mpich] darray (romio) needs a resize in the block()/cyclic() subtype creation
Merging a romio commit that was accepted by mpich: > darray (romio) needs a resize in the block()/cyclic() subtype creation > > When Type_create_darray() uses the block()/cyclic() function to > construct a subtype for whatever dimension it's processing, it > needs to resize the resulting type before it goes into the type > construction as the input for processing the next dimension. > > The same problem is in the main path's type creation, and in romio's > mirroring of it. > > Gist for a testcase: > https://gist.github.com/markalle/940de93d64fd779e304ee124855b8e6a > > The darray_bug_romio.c testcase creates a darray using > * 4 ranks in a 2x2 grid > * looking at the type made for rank 0 > * inner dimension: 4 ints distributed block over 2 ranks with 2 items each > * outer dimension: 6 of the above distributed cyclic over 2 ranks with 2 items each > > The type created by processing the first dimension should look like this > [ x x . . ] > > And then distributing those for the second dimension becomes > > [ x x x x ] > [ . . . . ] > [ . . . . ] > [ . . . . ] > [ x x x x ] > [ . . . . ] > > Going to the MPI standard to justify why the first layout is right, > it's where the definiton of the cyclic() function has a ub_marker > of gsize*ex, eg 4 ints for that first type. Signed-off-by: Mark Allen <[email protected]>
1 parent 4de4fd3 commit 3e317d7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ompi/mca/io/romio321/romio/adio/common/ad_darray.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ static int MPIOI_Type_block(int *array_of_gsizes, int dim, int ndims, int nprocs
199199
/* in terms of no. of elements of type oldtype in this dimension */
200200
if (mysize == 0) *st_offset = 0;
201201

202+
MPI_Aint ex;
203+
MPI_Type_extent(type_old, &ex);
204+
MPI_Datatype type_tmp;
205+
MPI_Type_create_resized(*type_new, 0, array_of_gsizes[dim] * ex, &type_tmp);
206+
MPI_Type_free(type_new);
207+
*type_new = type_tmp;
208+
202209
return MPI_SUCCESS;
203210
}
204211

@@ -287,5 +294,12 @@ static int MPIOI_Type_cyclic(int *array_of_gsizes, int dim, int ndims, int nproc
287294

288295
if (local_size == 0) *st_offset = 0;
289296

297+
MPI_Aint ex;
298+
MPI_Type_extent(type_old, &ex);
299+
MPI_Datatype type_tmp2;
300+
MPI_Type_create_resized(*type_new, 0, array_of_gsizes[dim] * ex, &type_tmp2);
301+
MPI_Type_free(type_new);
302+
*type_new = type_tmp2;
303+
290304
return MPI_SUCCESS;
291305
}

0 commit comments

Comments
 (0)