Skip to content

Commit df1223f

Browse files
committed
mpi: add MPI_LOGICAL{1,2,4,8,16}
This has been passed and merged by MPI Forum. Assuming the next MPI standard will be ratified before next major mpich release, we are directly using the MPI_ prefix rather than MPIX_ prefix. Also add MPI_TYPECLASS_LOGICAL for MPI_Type_match_size API. reference: mpi-forum/mpi-issues#699 mpi-forum/mpi-standard#963
1 parent 1b5bffb commit df1223f

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,6 +3571,11 @@ AC_DEFINE_UNQUOTED([MPIR_OFFSET_INTERNAL],[MPIR_INT$len], [Internal type for MPI
35713571
len=`expr $MPI_SIZEOF_COUNT \* 8`
35723572
AC_DEFINE_UNQUOTED([MPIR_COUNT_INTERNAL], [MPIR_INT$len], [Internal type for MPI_COUNT_DATATYPE])
35733573
AC_DEFINE_UNQUOTED([MPIR_C_FLOAT16_INTERNAL], [MPIR_FLOAT16], [Internal type for MPIX_C_FLOAT16])
3574+
AC_DEFINE_UNQUOTED([MPIR_LOGICAL1_INTERNAL], [MPIR_FORTRAN_LOGICAL8], [Internal type for MPI_LOGICAL1])
3575+
AC_DEFINE_UNQUOTED([MPIR_LOGICAL2_INTERNAL], [MPIR_FORTRAN_LOGICAL16], [Internal type for MPI_LOGICAL2])
3576+
AC_DEFINE_UNQUOTED([MPIR_LOGICAL4_INTERNAL], [MPIR_FORTRAN_LOGICAL32], [Internal type for MPI_LOGICAL4])
3577+
AC_DEFINE_UNQUOTED([MPIR_LOGICAL8_INTERNAL], [MPIR_FORTRAN_LOGICAL64], [Internal type for MPI_LOGICAL8])
3578+
AC_DEFINE_UNQUOTED([MPIR_LOGICAL16_INTERNAL], [MPIR_FORTRAN_LOGICAL128],[Internal type for MPI_LOGICAL16])
35743579
AC_MSG_RESULT([done])
35753580

35763581
# ------------------------------------------------------------------------

maint/gen_abi.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ def gen_mpi_abi_internal_h(out):
6060
elif T == "MPI_Datatype":
6161
idx = int(val, 0) & G.datatype_mask
6262
G.abi_datatypes[idx] = name
63-
if re.match(r'MPI_LOGICAL\d+', name):
64-
G.abi_datatypes[idx] = "MPI_DATATYPE_NULL"
6563
elif T == "MPI_Op":
6664
idx = int(val, 0) & G.op_mask
6765
G.abi_ops[idx] = name

src/include/mpi.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ typedef int MPI_Datatype;
253253
#define MPI_COUNT ((MPI_Datatype)0x4c000845)
254254
/* other extension types */
255255
#define MPIX_C_FLOAT16 ((MPI_Datatype)0x4c000246)
256+
/* Fortran fixed-width logicals */
257+
#define MPI_LOGICAL1 ((MPI_Datatype)0x4c000147)
258+
#define MPI_LOGICAL2 ((MPI_Datatype)0x4c000248)
259+
#define MPI_LOGICAL4 ((MPI_Datatype)0x4c000449)
260+
#define MPI_LOGICAL8 ((MPI_Datatype)0x4c00084a)
261+
#define MPI_LOGICAL16 ((MPI_Datatype)0x4c00104b)
256262

257263
/* Communicators */
258264
typedef int MPI_Comm;
@@ -568,6 +574,7 @@ extern int * const MPI_WEIGHTS_EMPTY MPICH_API_PUBLIC;
568574
#define MPI_TYPECLASS_REAL 1
569575
#define MPI_TYPECLASS_INTEGER 2
570576
#define MPI_TYPECLASS_COMPLEX 3
577+
#define MPI_TYPECLASS_LOGICAL 4
571578

572579
#define MPI_LOCK_EXCLUSIVE 234
573580
#define MPI_LOCK_SHARED 235

src/include/mpir_objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const char *MPIR_Handle_get_kind_str(int kind);
217217
#define MPIR_GROUP_PREALLOC 8
218218
#endif
219219

220-
#define MPIR_DATATYPE_N_BUILTIN 71
220+
#define MPIR_DATATYPE_N_BUILTIN 76 /* 0x4c - must be in sync with mpi.h.in */
221221
#ifdef MPID_DATATYPE_PREALLOC
222222
#define MPIR_DATATYPE_PREALLOC MPID_DATATYPE_PREALLOC
223223
#else

src/mpi/datatype/datatype_impl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ int MPIR_Type_match_size_impl(int typeclass, int size, MPI_Datatype * datatype)
317317
static MPI_Datatype complex_types[] = {
318318
MPI_COMPLEX4, MPI_COMPLEX8, MPI_COMPLEX16, MPI_COMPLEX32,
319319
};
320+
static MPI_Datatype logical_types[] = {
321+
MPI_LOGICAL1, MPI_LOGICAL2, MPI_LOGICAL4, MPI_LOGICAL8, MPI_LOGICAL16,
322+
};
320323

321324
/* The following implementation follows the suggestion in the
322325
* MPI-2 standard.
@@ -353,6 +356,13 @@ int MPIR_Type_match_size_impl(int typeclass, int size, MPI_Datatype * datatype)
353356
matched_datatype = type_match_size(complex_types, n, size);
354357
#ifdef HAVE_ERROR_CHECKING
355358
tname = "MPI_TYPECLASS_COMPLEX";
359+
#endif
360+
break;
361+
case MPI_TYPECLASS_LOGICAL:
362+
n = sizeof(logical_types) / sizeof(MPI_Datatype);
363+
matched_datatype = type_match_size(logical_types, n, size);
364+
#ifdef HAVE_ERROR_CHECKING
365+
tname = "MPI_TYPECLASS_LOGICAL";
356366
#endif
357367
break;
358368
default:

src/mpi/datatype/typeutil.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ struct MPIR_Datatype_builtin_entry MPIR_Internal_types[] = {
9898
type_name_entry(OFFSET, MULTI), /* 0x44 */
9999
type_name_entry(COUNT, MULTI), /* 0x45 */
100100
type_name_x(C_FLOAT16, FLOATING_POINT), /* 0x46 */
101+
type_name_entry(LOGICAL1, LOGICAL), /* 0x47 */
102+
type_name_entry(LOGICAL2, LOGICAL), /* 0x48 */
103+
type_name_entry(LOGICAL4, LOGICAL), /* 0x49 */
104+
type_name_entry(LOGICAL8, LOGICAL), /* 0x4a */
105+
type_name_entry(LOGICAL16, LOGICAL), /* 0x4b */
101106
/* *INDENT-ON* */
102107
};
103108

0 commit comments

Comments
 (0)