Skip to content

Commit f8a4419

Browse files
committed
mpiext/shortfloat: Add MPIX_C_FLOAT16 datatype
`MPIX_C_FLOAT16` is defined as a synonym for `MPIX_SHORT_FLOAT` if the C compiler supports `_Float16`, which is defined in ISO/IEC JTC 1/SC 22/WG 14 N1945 (ISO/IEC TS 18661-3:2015). This name and meaning are same as that of MPICH. This may be a transitional datatype until the MPI Forum decides a proper name for the type. Signed-off-by: KAWASHIMA Takahiro <t-kawashima@jp.fujitsu.com>
1 parent c44599e commit f8a4419

File tree

7 files changed

+29
-0
lines changed

7 files changed

+29
-0
lines changed

ompi/mpi/fortran/common_sym_whitelist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ompi_f08_mpi_byte
1414
ompi_f08_mpi_c_bool
1515
ompi_f08_mpi_c_complex
1616
ompi_f08_mpi_c_double_complex
17+
ompi_f08_mpi_c_float16
1718
ompi_f08_mpi_c_float_complex
1819
ompi_f08_mpi_c_long_double_complex
1920
ompi_f08_mpi_c_short_float_complex

ompi/mpi/fortran/use-mpi-f08/constants.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_comp
153153
* OMPI_MPI_* macros are not defined in ompi/include/mpif-values.pl
154154
* because they should not be included in mpif.h. So immediate values
155155
* defined in ompi/datatype/ompi_datatype_module.c are used here.
156+
* ompi_f08_mpi_c_float16 is a synonym for ompi_f08_mpi_short_float.
156157
*/
157158
#if defined(HAVE_SHORT_FLOAT) || defined(HAVE_OPAL_SHORT_FLOAT_T)
158159
OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_short_float = {74};
159160
OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_c_short_float_complex = {75};
160161
OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_cxx_short_float_complex = {76};
162+
OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_c_float16 = {74};
161163
#endif

ompi/mpiext/shortfloat/README.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ Each MPI datatype corresponds to the C/C++ type 'short float', the C type
1313
'short float _Complex', and the C++ type 'std::complex<short float>',
1414
respectively.
1515

16+
In addition, this extension provides a datatype MPIX_C_FLOAT16 for
17+
the C type _Float16, which is defined in ISO/IEC JTC 1/SC 22/WG 14
18+
N1945 (ISO/IEC TS 18661-3:2015). This name and meaning are same as
19+
that of MPICH.
20+
21+
https://github.com/pmodels/mpich/pull/3455
22+
1623
This extension is enabled only if the C compiler supports 'short float'
1724
or '_Float16', or the '--enable-alt-short-float=TYPE' option is passed
1825
to the configure script.

ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h renamed to ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_cxx_sfltcplex;
1515
#define MPIX_SHORT_FLOAT OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_short_float)
1616
#define MPIX_C_SHORT_FLOAT_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_c_short_float_complex)
1717
#define MPIX_CXX_SHORT_FLOAT_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_cxx_sfltcplex)
18+
19+
#if @OMPI_MPIX_SHORT_FLOAT_IS_C_FLOAT16@
20+
#define MPIX_C_FLOAT16 OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_short_float)
21+
#endif

ompi/mpiext/shortfloat/configure.m4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ AC_DEFUN([OMPI_MPIEXT_shortfloat_CONFIG],[
1717
ompi/mpiext/shortfloat/mpif-h/Makefile
1818
ompi/mpiext/shortfloat/use-mpi/Makefile
1919
ompi/mpiext/shortfloat/use-mpi-f08/Makefile
20+
ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h
21+
ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h
22+
ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h
2023
])
2124

2225
AS_IF([{ test "$ENABLE_shortfloat" = "1" || \
@@ -25,6 +28,12 @@ AC_DEFUN([OMPI_MPIEXT_shortfloat_CONFIG],[
2528
test "$ac_cv_type_opal_short_float_t" = "yes"; }],
2629
[$1],
2730
[$2])
31+
32+
AS_IF([test "$opal_short_float_type" = "_Float16"],
33+
[AC_SUBST([OMPI_MPIX_SHORT_FLOAT_IS_C_FLOAT16], 1)
34+
AC_SUBST([OMPI_MPIX_C_FLOAT16_FORTRAN_COMMENT_OUT], [])],
35+
[AC_SUBST([OMPI_MPIX_SHORT_FLOAT_IS_C_FLOAT16], 0),
36+
AC_SUBST([OMPI_MPIX_C_FLOAT16_FORTRAN_COMMENT_OUT], [!])])
2837
])
2938

3039
# The mpi_f08_ext module should not include mpiext_shortfloat_mpifh.h

ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h renamed to ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
integer MPIX_SHORT_FLOAT
1212
integer MPIX_C_SHORT_FLOAT_COMPLEX
1313
integer MPIX_CXX_SHORT_FLOAT_COMPLEX
14+
@OMPI_MPIX_C_FLOAT16_FORTRAN_COMMENT_OUT@ integer MPIX_C_FLOAT16
1415

1516
parameter (MPIX_SHORT_FLOAT=74)
1617
parameter (MPIX_C_SHORT_FLOAT_COMPLEX=75)
1718
parameter (MPIX_CXX_SHORT_FLOAT_COMPLEX=76)
19+
@OMPI_MPIX_C_FLOAT16_FORTRAN_COMMENT_OUT@ parameter (MPIX_C_FLOAT16=74)

ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h renamed to ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
type(MPI_Datatype), bind(C, name="ompi_f08_mpi_short_float") OMPI_PROTECTED :: MPIX_SHORT_FLOAT
1515
type(MPI_Datatype), bind(C, name="ompi_f08_mpi_c_short_float_complex") OMPI_PROTECTED :: MPIX_C_SHORT_FLOAT_COMPLEX
1616
type(MPI_Datatype), bind(C, name="ompi_f08_mpi_cxx_short_float_complex") OMPI_PROTECTED :: MPIX_CXX_SHORT_FLOAT_COMPLEX
17+
18+
#if @OMPI_MPIX_SHORT_FLOAT_IS_C_FLOAT16@
19+
type(MPI_Datatype), bind(C, name="ompi_f08_mpi_c_float16") OMPI_PROTECTED :: MPIX_C_FLOAT16
20+
#endif

0 commit comments

Comments
 (0)