1
1

Rewrite the subarray strictly following the MPI standard. Set the lb and ub

as it should be. I hope I get it right this time ...

This commit was SVN r10293.
Этот коммит содержится в:
George Bosilca 2006-06-11 19:57:49 +00:00
родитель 95dd1b173a
Коммит 386a02d2ae

Просмотреть файл

@ -42,8 +42,8 @@ int MPI_Type_create_subarray(int ndims,
{
MPI_Datatype last_type;
int32_t i, step, end_loop;
int32_t block_length[2], start[2];
int32_t i, step, start_loop, end_loop;
MPI_Aint size, displ, extent;
if (MPI_PARAM_CHECK) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
@ -67,41 +67,50 @@ int MPI_Type_create_subarray(int ndims,
}
}
/* If the ndims is zero then return the NULL datatype */
if( ndims < 1 ) {
*newtype = &ompi_mpi_datatype_null;
if( ndims < 2 ) {
if( 0 == ndims ) {
*newtype = &ompi_mpi_datatype_null;
return MPI_SUCCESS;
}
ompi_ddt_create_contiguous( subsize_array[0], oldtype, newtype );
return MPI_SUCCESS;
}
if( MPI_ORDER_C == order ) {
i = ndims - 1;
start_loop = i = ndims - 1;
step = -1;
end_loop = -1;
} else {
i = 0;
start_loop = i = 0;
step = 1;
end_loop = ndims - 1;
}
ompi_ddt_type_extent( oldtype, &extent );
/* As we know that the ndims is at least 1 we can start by creating the first dimension data
* outside the loop, such that we dont have to create a duplicate of the oldtype just to be able
* to free it.
*/
block_length[0] = subsize_array[i];
block_length[1] = 0;
start[0] = start_array[i];
start[1] = size_array[i];
ompi_ddt_create_indexed( 2, block_length, start, oldtype, newtype );
last_type = *newtype;
for( i += step; i != end_loop; i += step ) {
block_length[0] = subsize_array[i];
block_length[1] = 0;
start[0] = start_array[i];
start[1] = size_array[i];
ompi_ddt_create_indexed( 2, block_length, start, last_type, newtype );
ompi_ddt_destroy( &last_type );
last_type = *newtype;
}
ompi_ddt_create_vector( subsize_array[i+step], subsize_array[i], size_array[i],
oldtype, newtype );
last_type = *newtype;
size = size_array[i] * size_array[i+step];
displ = start_array[i] + start_array[i+step] * size_array[i];
for( i += 2 * step; i != end_loop; i += step ) {
last_type = *newtype;
ompi_ddt_create_vector( subsize_array[i], 1, size_array[i],
last_type, newtype );
ompi_ddt_destroy( &last_type );
displ += size * start_array[i];
size *= size_array[i];
}
ompi_ddt_create_resized( last_type, displ * extent,
(size - start_array[start_loop]) * extent, newtype );
ompi_ddt_destroy( &last_type );
{
int* a_i[5];