Skip to content

Commit

Permalink
datatype: Add support for MPI_TYPECLASS_LOGICAL
Browse files Browse the repository at this point in the history
  • Loading branch information
dalcinl committed Mar 21, 2024
1 parent 64e5f5f commit 7b93c9d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/man-openmpi/man3/MPI_Type_match_size.3.rst
Expand Up @@ -65,9 +65,9 @@ The function returns an MPI datatype matching a local variable of type
(*typeclass*, *size*). The returned type is a reference (handle) to a
predefined named datatype, not a duplicate. This type cannot be freed.

The value of *typeclass* may be set to one of MPI_TYPECLASS_REAL,
MPI_TYPECLASS_INTEGER, or MPI_TYPECLASS_COMPLEX, corresponding to the
desired datatype.
The value of *typeclass* may be set to one of MPI_TYPECLASS_LOGICAL,
MPI_TYPECLASS_INTEGER, MPI_TYPECLASS_REAL, or MPI_TYPECLASS_COMPLEX,
corresponding to the desired datatype.

MPI_type_match_size can be used to obtain a size-specific type that
matches a Fortran numeric intrinsic type: first call :ref:`MPI_Sizeof` to
Expand Down
1 change: 1 addition & 0 deletions ompi/datatype/ompi_datatype.h
Expand Up @@ -49,6 +49,7 @@ BEGIN_C_DECLS
#define OMPI_DATATYPE_FLAG_ANALYZED 0x0400
#define OMPI_DATATYPE_FLAG_MONOTONIC 0x0800
/* Keep trace of the type of the predefined datatypes */
#define OMPI_DATATYPE_FLAG_DATA_BOOL 0x0000 /* TODO: what to do here? */
#define OMPI_DATATYPE_FLAG_DATA_INT 0x1000
#define OMPI_DATATYPE_FLAG_DATA_FLOAT 0x2000
#define OMPI_DATATYPE_FLAG_DATA_COMPLEX 0x3000
Expand Down
12 changes: 6 additions & 6 deletions ompi/datatype/ompi_datatype_module.c
Expand Up @@ -179,7 +179,7 @@ ompi_predefined_datatype_t ompi_mpi_complex32 = OMPI_DATATYPE_INIT_UNAVAILA
/*
* Fortran datatypes
*/
ompi_predefined_datatype_t ompi_mpi_logical = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL, OMPI_SIZEOF_FORTRAN_LOGICAL, OMPI_ALIGNMENT_FORTRAN_LOGICAL, 0 );
ompi_predefined_datatype_t ompi_mpi_logical = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL, OMPI_SIZEOF_FORTRAN_LOGICAL, OMPI_ALIGNMENT_FORTRAN_LOGICAL, OMPI_DATATYPE_FLAG_DATA_BOOL );
ompi_predefined_datatype_t ompi_mpi_character = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, CHARACTER, 1, OPAL_ALIGNMENT_CHAR, 0 );
ompi_predefined_datatype_t ompi_mpi_integer = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, INTEGER, OMPI_SIZEOF_FORTRAN_INTEGER, OMPI_ALIGNMENT_FORTRAN_INTEGER, OMPI_DATATYPE_FLAG_DATA_INT );
ompi_predefined_datatype_t ompi_mpi_real = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (FLOAT, REAL, OMPI_SIZEOF_FORTRAN_REAL, OMPI_ALIGNMENT_FORTRAN_REAL, OMPI_DATATYPE_FLAG_DATA_FLOAT );
Expand All @@ -204,27 +204,27 @@ ompi_predefined_datatype_t ompi_mpi_2dblcplex = OMPI_DATATYPE_INIT_DEFER (2

/* For each of these we figure out, whether it is available -- otherwise it's set to unavailable */
#if OMPI_HAVE_FORTRAN_LOGICAL1
ompi_predefined_datatype_t ompi_mpi_logical1 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL1, OMPI_SIZEOF_FORTRAN_LOGICAL1, OMPI_ALIGNMENT_FORTRAN_LOGICAL1, 0);
ompi_predefined_datatype_t ompi_mpi_logical1 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL1, OMPI_SIZEOF_FORTRAN_LOGICAL1, OMPI_ALIGNMENT_FORTRAN_LOGICAL1, OMPI_DATATYPE_FLAG_DATA_BOOL);
#else
ompi_predefined_datatype_t ompi_mpi_logical1 = OMPI_DATATYPE_INIT_UNAVAILABLE (LOGICAL1, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
#endif
#if OMPI_HAVE_FORTRAN_LOGICAL2
ompi_predefined_datatype_t ompi_mpi_logical2 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL2, OMPI_SIZEOF_FORTRAN_LOGICAL2, OMPI_ALIGNMENT_FORTRAN_LOGICAL2, 0);
ompi_predefined_datatype_t ompi_mpi_logical2 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL2, OMPI_SIZEOF_FORTRAN_LOGICAL2, OMPI_ALIGNMENT_FORTRAN_LOGICAL2, OMPI_DATATYPE_FLAG_DATA_BOOL);
#else
ompi_predefined_datatype_t ompi_mpi_logical2 = OMPI_DATATYPE_INIT_UNAVAILABLE (LOGICAL2, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
#endif
#if OMPI_HAVE_FORTRAN_LOGICAL4
ompi_predefined_datatype_t ompi_mpi_logical4 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL4, OMPI_SIZEOF_FORTRAN_LOGICAL4, OMPI_ALIGNMENT_FORTRAN_LOGICAL4, 0);
ompi_predefined_datatype_t ompi_mpi_logical4 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL4, OMPI_SIZEOF_FORTRAN_LOGICAL4, OMPI_ALIGNMENT_FORTRAN_LOGICAL4, OMPI_DATATYPE_FLAG_DATA_BOOL);
#else
ompi_predefined_datatype_t ompi_mpi_logical4 = OMPI_DATATYPE_INIT_UNAVAILABLE (LOGICAL4, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
#endif
#if OMPI_HAVE_FORTRAN_LOGICAL8
ompi_predefined_datatype_t ompi_mpi_logical8 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL8, OMPI_SIZEOF_FORTRAN_LOGICAL8, OMPI_ALIGNMENT_FORTRAN_LOGICAL8, 0);
ompi_predefined_datatype_t ompi_mpi_logical8 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL8, OMPI_SIZEOF_FORTRAN_LOGICAL8, OMPI_ALIGNMENT_FORTRAN_LOGICAL8, OMPI_DATATYPE_FLAG_DATA_BOOL);
#else
ompi_predefined_datatype_t ompi_mpi_logical8 = OMPI_DATATYPE_INIT_UNAVAILABLE (LOGICAL8, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
#endif
#if OMPI_HAVE_FORTRAN_LOGICAL16
ompi_predefined_datatype_t ompi_mpi_logical16 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL16, OMPI_SIZEOF_FORTRAN_LOGICAL16, OMPI_ALIGNMENT_FORTRAN_LOGICAL16, 0);
ompi_predefined_datatype_t ompi_mpi_logical16 = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE_FORTRAN (INT, LOGICAL16, OMPI_SIZEOF_FORTRAN_LOGICAL16, OMPI_ALIGNMENT_FORTRAN_LOGICAL16, OMPI_DATATYPE_FLAG_DATA_BOOL);
#else
ompi_predefined_datatype_t ompi_mpi_logical16 = OMPI_DATATYPE_INIT_UNAVAILABLE (LOGICAL16, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
#endif
Expand Down
1 change: 1 addition & 0 deletions ompi/include/mpi.h.in
Expand Up @@ -1381,6 +1381,7 @@ OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub;
#define MPI_TYPECLASS_INTEGER 1
#define MPI_TYPECLASS_REAL 2
#define MPI_TYPECLASS_COMPLEX 3
#define MPI_TYPECLASS_LOGICAL 4

/* Aint helper macros (MPI-3.1) */
#define MPI_Aint_add(base, disp) ((MPI_Aint) ((char *) (base) + (disp)))
Expand Down
1 change: 1 addition & 0 deletions ompi/include/mpif-values.pl
Expand Up @@ -287,6 +287,7 @@ sub read_value_from_file {
$constants->{MPI_TYPECLASS_INTEGER} = 1;
$constants->{MPI_TYPECLASS_REAL} = 2;
$constants->{MPI_TYPECLASS_COMPLEX} = 3;
$constants->{MPI_TYPECLASS_LOGICAL} = 4;
$constants->{MPI_MODE_NOCHECK} = 1;
$constants->{MPI_MODE_NOPRECEDE} = 2;
$constants->{MPI_MODE_NOPUT} = 4;
Expand Down
3 changes: 3 additions & 0 deletions ompi/mpi/c/type_match_size.c
Expand Up @@ -54,6 +54,9 @@ int MPI_Type_match_size(int typeclass, int size, MPI_Datatype *type)
case MPI_TYPECLASS_COMPLEX:
*type = (MPI_Datatype)ompi_datatype_match_size( size, OMPI_DATATYPE_FLAG_DATA_COMPLEX, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
break;
case MPI_TYPECLASS_LOGICAL:
*type = (MPI_Datatype)ompi_datatype_match_size( size, OMPI_DATATYPE_FLAG_DATA_BOOL, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
break;
default:
*type = &ompi_mpi_datatype_null.dt;
}
Expand Down
3 changes: 3 additions & 0 deletions ompi/mpi/fortran/mpif-h/type_match_size_f.c
Expand Up @@ -97,6 +97,9 @@ void ompi_type_match_size_f(MPI_Fint *typeclass, MPI_Fint *size, MPI_Fint *type,
case MPI_TYPECLASS_COMPLEX:
c_type = (MPI_Datatype)ompi_datatype_match_size( c_size, OMPI_DATATYPE_FLAG_DATA_COMPLEX, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
break;
case MPI_TYPECLASS_LOGICAL:
c_type = (MPI_Datatype)ompi_datatype_match_size( c_size, OMPI_DATATYPE_FLAG_DATA_BOOL, OMPI_DATATYPE_FLAG_DATA_FORTRAN );
break;
default:
c_type = &ompi_mpi_datatype_null.dt;
}
Expand Down

0 comments on commit 7b93c9d

Please sign in to comment.