Skip to content

Commit aeb2c02

Browse files
committed
Type_create_darray with mix of BLOCK/CYCLIC
Example (using MPI_ORDER_C so the below has 6 rows of 4 ints to parcel out) size = 4; rank = 0; ndims=2; gsizes[0] = 6; gsizes[1] = 4; distribs[0] = MPI_DISTRIBUTE_CYCLIC; distribs[1] = MPI_DISTRIBUTE_BLOCK; dargs[0] = 2; dargs[1] = 2; psizes[0] = 2; psizes[1] = 2; MPI_Type_create_darray(size, rank, ndims, gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &mydt); Expectation for the layout: inner dimension (1) is 4 items (ints) distributed block over 2 ranks with 2 items each eg for rank 0: [ x x . . ] outer dimension (0) is: 6 items (the above [ x x . .]) cyclic over 2 ranks with 2 items each eg for rank 0: [ x x . . ] : offset=0 bytes=8 [ x x . . ] : ofset=16 bytes=8 [ . . . . ] [ . . . . ] [ x x . . ] : offset=64 bytes=8 [ x x . . ] : offset=80 bytes=8 Or more specifically a stream of ints 0,1,2,3,4,5,6,7 sent into that type should be [ 0 1 . . ] [ 2 3 . . ] [ . . . . ] [ . . . . ] [ 4 5 . . ] [ 6 7 . . ] The data was laying out though as [ 0 1 2 3 ] [ . . . . ] [ . . . . ] [ . . . . ] [ 4 5 6 7 ] [ . . . . ] because the recursive construction inside the block() function (which creates the smaller row datatype [ x x . . ]) wasn't setting the extent of that type. Signed-off-by: Mark Allen <[email protected]>
1 parent f038fe6 commit aeb2c02

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ompi/datatype/ompi_datatype_create_darray.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
1616
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
1717
* reserved.
18+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -35,7 +36,7 @@ block(const int *gsize_array, int dim, int ndims, int nprocs,
3536
ptrdiff_t *st_offset)
3637
{
3738
int blksize, global_size, mysize, i, j, rc, start_loop, step;
38-
ptrdiff_t stride;
39+
ptrdiff_t stride, disps[2];
3940

4041
global_size = gsize_array[dim];
4142

@@ -71,6 +72,20 @@ block(const int *gsize_array, int dim, int ndims, int nprocs,
7172
/* in terms of no. of elements of type oldtype in this dimension */
7273
if (mysize == 0) *st_offset = 0;
7374

75+
/* need to set the UB for block-cyclic to work */
76+
disps[0] = 0; disps[1] = orig_extent;
77+
if (order == MPI_ORDER_FORTRAN) {
78+
for(i=0; i<=dim; i++) {
79+
disps[1] *= gsize_array[i];
80+
}
81+
} else {
82+
for(i=ndims-1; i>=dim; i--) {
83+
disps[1] *= gsize_array[i];
84+
}
85+
}
86+
rc = opal_datatype_resize( &(*type_new)->super, disps[0], disps[1] );
87+
if (OMPI_SUCCESS != rc) return rc;
88+
7489
return OMPI_SUCCESS;
7590
}
7691

0 commit comments

Comments
 (0)