Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 43f3a7c

Browse files
bosilcajsquyres
authored andcommitted
Allow NULL arrays for empty datatypes.
When building an empty datatype (aka. size = 0) because the count of included datatypes is 0, be less strict on what the arguments are (allow NULL pointers). (cherry picked from commit open-mpi/ompi@6e6ed62)
1 parent b1232c4 commit 43f3a7c

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

ompi/datatype/ompi_datatype_create_subarray.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2015 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
@@ -51,7 +51,7 @@ int32_t ompi_datatype_create_subarray(int ndims,
5151
/* If the ndims is zero then return the NULL datatype */
5252
if( ndims < 2 ) {
5353
if( 0 == ndims ) {
54-
*newtype = &ompi_mpi_datatype_null.dt;
54+
ompi_datatype_duplicate(&ompi_mpi_datatype_null.dt, newtype);
5555
return MPI_SUCCESS;
5656
}
5757
ompi_datatype_create_contiguous( subsize_array[0], oldtype, &last_type );

ompi/mpi/c/type_create_darray.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2011 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -65,7 +65,8 @@ int MPI_Type_create_darray(int size,
6565
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
6666
} else if( ndims < 0 ) {
6767
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT, FUNC_NAME);
68-
} else if( (NULL == gsize_array) || (NULL == distrib_array) || (NULL == darg_array) || (NULL == psize_array)) {
68+
} else if( (ndims > 0) && ((NULL == gsize_array) || (NULL == distrib_array) ||
69+
(NULL == darg_array) || (NULL == psize_array))) {
6970
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
7071
} else if (NULL == newtype) {
7172
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME);

ompi/mpi/c/type_create_hindexed.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -57,8 +57,8 @@ int MPI_Type_create_hindexed(int count,
5757
if( count < 0 ) {
5858
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT,
5959
FUNC_NAME);
60-
} else if (NULL == array_of_blocklengths ||
61-
NULL == array_of_displacements) {
60+
} else if ((count > 0) && (NULL == array_of_blocklengths ||
61+
NULL == array_of_displacements)) {
6262
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
6363
FUNC_NAME);
6464
} else if (MPI_DATATYPE_NULL == oldtype || NULL == oldtype ||

ompi/mpi/c/type_create_subarray.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2011 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -59,7 +59,7 @@ int MPI_Type_create_subarray(int ndims,
5959
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
6060
if( ndims < 0 ) {
6161
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT, FUNC_NAME);
62-
} else if( (NULL == size_array) || (NULL == subsize_array) || (NULL == start_array) ) {
62+
} else if( (ndims > 0) && ((NULL == size_array) || (NULL == subsize_array) || (NULL == start_array)) ) {
6363
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
6464
} else if( (NULL == oldtype) || (MPI_DATATYPE_NULL == oldtype) || (NULL == newtype) ) {
6565
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TYPE, FUNC_NAME);

ompi/mpi/c/type_hindexed.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2005 The University of Tennessee and The University
5+
* Copyright (c) 2004-2016 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -57,8 +57,8 @@ int MPI_Type_hindexed(int count,
5757
} else if (count < 0) {
5858
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT,
5959
FUNC_NAME );
60-
} else if (NULL == array_of_blocklengths ||
61-
NULL == array_of_displacements) {
60+
} else if ((count > 0) && (NULL == array_of_blocklengths ||
61+
NULL == array_of_displacements) ) {
6262
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
6363
FUNC_NAME );
6464
}

ompi/mpi/c/type_indexed.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -60,8 +60,8 @@ int MPI_Type_indexed(int count,
6060
} else if( count < 0 ) {
6161
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COUNT,
6262
FUNC_NAME);
63-
} else if (NULL == array_of_blocklengths ||
64-
NULL == array_of_displacements) {
63+
} else if ((count > 0) && (NULL == array_of_blocklengths ||
64+
NULL == array_of_displacements)) {
6565
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
6666
FUNC_NAME);
6767
}

0 commit comments

Comments
 (0)