|
11 | 11 | * Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
|
12 | 12 | * Copyright (c) 2010-2018 Cisco Systems, Inc. All rights reserved
|
13 | 13 | * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
|
| 14 | + * Copyright (c) 2025 Triad National Security, LLC. All rights |
| 15 | + * reserved. |
14 | 16 | * $COPYRIGHT$
|
15 | 17 | *
|
16 | 18 | * Additional copyrights may follow
|
|
27 | 29 | #include "opal/util/printf.h"
|
28 | 30 | #include "opal/util/string_copy.h"
|
29 | 31 | #include "ompi/datatype/ompi_datatype.h"
|
| 32 | +#include "ompi/datatype/ompi_datatype_internal.h" |
30 | 33 | #include "ompi/attribute/attribute.h"
|
31 | 34 |
|
32 | 35 | static void __ompi_datatype_allocate( ompi_datatype_t* datatype )
|
@@ -121,3 +124,54 @@ ompi_datatype_duplicate( const ompi_datatype_t* oldType, ompi_datatype_t** newTy
|
121 | 124 | return OMPI_SUCCESS;
|
122 | 125 | }
|
123 | 126 |
|
| 127 | +/* |
| 128 | + * Note this is not a complete implementation for the MPI_Type_get_value_index function described in |
| 129 | + * MPI 4.1 and newer as it doesn't support possible unnamed datatypes returned for other value_type/index_type |
| 130 | + * pairs. |
| 131 | + */ |
| 132 | +int |
| 133 | +ompi_datatype_get_value_index(const ompi_datatype_t *value_type, const ompi_datatype_t *index_type, ompi_datatype_t **pair_type) |
| 134 | +{ |
| 135 | + /* C predefined data types */ |
| 136 | + if (index_type->id == OMPI_DATATYPE_MPI_INT) { |
| 137 | + if (value_type->id == OMPI_DATATYPE_MPI_FLOAT) { |
| 138 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_float_int; |
| 139 | + } else if (value_type->id == OMPI_DATATYPE_MPI_DOUBLE) { |
| 140 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_double_int; |
| 141 | + } else if (value_type->id == OMPI_DATATYPE_MPI_LONG) { |
| 142 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_long_int; |
| 143 | + } else if (value_type->id == OMPI_DATATYPE_MPI_SHORT) { |
| 144 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_short_int; |
| 145 | + } else if (value_type->id == OMPI_DATATYPE_MPI_INT) { |
| 146 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_2int; |
| 147 | + } else if (value_type->id == OMPI_DATATYPE_MPI_LONG_DOUBLE) { |
| 148 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_longdbl_int; |
| 149 | + } else { |
| 150 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_datatype_null; |
| 151 | + } |
| 152 | + /* Fortran predefined data types */ |
| 153 | + } else if ((index_type->id == OMPI_DATATYPE_MPI_INTEGER) && |
| 154 | + (value_type->id == OMPI_DATATYPE_MPI_INTEGER)) { |
| 155 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_2integer; |
| 156 | + } else if ((index_type->id == OMPI_DATATYPE_MPI_FLOAT) && |
| 157 | + (value_type->id == OMPI_DATATYPE_MPI_FLOAT)) { |
| 158 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_2real; |
| 159 | + } else if ((index_type->id == OMPI_DATATYPE_MPI_DOUBLE) && |
| 160 | + (value_type->id == OMPI_DATATYPE_MPI_DOUBLE)) { |
| 161 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_2dblprec; |
| 162 | +#if OMPI_HAVE_FORTRAN_COMPLEX |
| 163 | + } else if ((index_type->id == OMPI_DATATYPE_MPI_COMPLEX) && |
| 164 | + (value_type->id == OMPI_DATATYPE_MPI_COMPLEX)) { |
| 165 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_2cplex; |
| 166 | +#endif |
| 167 | +#if OMPI_HAVE_FORTRAN_DOUBLE_COMPLEX |
| 168 | + } else if ((index_type->id == OMPI_DATATYPE_MPI_DOUBLE_COMPLEX) && |
| 169 | + (value_type->id == OMPI_DATATYPE_MPI_DOUBLE_COMPLEX)) { |
| 170 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_2dblcplex; |
| 171 | +#endif |
| 172 | + } else { |
| 173 | + *pair_type = (ompi_datatype_t *)&ompi_mpi_datatype_null; |
| 174 | + } |
| 175 | + |
| 176 | + return OMPI_SUCCESS; |
| 177 | +} |
0 commit comments