From f8a441957aa05d4b4311e3608fb614f60495f5ac Mon Sep 17 00:00:00 2001 From: KAWASHIMA Takahiro Date: Wed, 26 Dec 2018 14:43:01 +0900 Subject: [PATCH] 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 --- ompi/mpi/fortran/common_sym_whitelist.txt | 1 + ompi/mpi/fortran/use-mpi-f08/constants.c | 2 ++ ompi/mpiext/shortfloat/README.txt | 7 +++++++ .../{mpiext_shortfloat_c.h => mpiext_shortfloat_c.h.in} | 4 ++++ ompi/mpiext/shortfloat/configure.m4 | 9 +++++++++ ...t_shortfloat_mpifh.h => mpiext_shortfloat_mpifh.h.in} | 2 ++ ...loat_usempif08.h => mpiext_shortfloat_usempif08.h.in} | 4 ++++ 7 files changed, 29 insertions(+) rename ompi/mpiext/shortfloat/c/{mpiext_shortfloat_c.h => mpiext_shortfloat_c.h.in} (82%) rename ompi/mpiext/shortfloat/mpif-h/{mpiext_shortfloat_mpifh.h => mpiext_shortfloat_mpifh.h.in} (73%) rename ompi/mpiext/shortfloat/use-mpi-f08/{mpiext_shortfloat_usempif08.h => mpiext_shortfloat_usempif08.h.in} (80%) diff --git a/ompi/mpi/fortran/common_sym_whitelist.txt b/ompi/mpi/fortran/common_sym_whitelist.txt index 0fafe7f6f3..334b303447 100644 --- a/ompi/mpi/fortran/common_sym_whitelist.txt +++ b/ompi/mpi/fortran/common_sym_whitelist.txt @@ -14,6 +14,7 @@ ompi_f08_mpi_byte ompi_f08_mpi_c_bool ompi_f08_mpi_c_complex ompi_f08_mpi_c_double_complex +ompi_f08_mpi_c_float16 ompi_f08_mpi_c_float_complex ompi_f08_mpi_c_long_double_complex ompi_f08_mpi_c_short_float_complex diff --git a/ompi/mpi/fortran/use-mpi-f08/constants.c b/ompi/mpi/fortran/use-mpi-f08/constants.c index 791befd5b8..f741b16640 100644 --- a/ompi/mpi/fortran/use-mpi-f08/constants.c +++ b/ompi/mpi/fortran/use-mpi-f08/constants.c @@ -153,9 +153,11 @@ OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_comp * OMPI_MPI_* macros are not defined in ompi/include/mpif-values.pl * because they should not be included in mpif.h. So immediate values * defined in ompi/datatype/ompi_datatype_module.c are used here. + * ompi_f08_mpi_c_float16 is a synonym for ompi_f08_mpi_short_float. */ #if defined(HAVE_SHORT_FLOAT) || defined(HAVE_OPAL_SHORT_FLOAT_T) OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_short_float = {74}; OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_c_short_float_complex = {75}; OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_cxx_short_float_complex = {76}; +OMPI_DECLSPEC ompi_fortran_08_handle_t OMPI_F08_HANDLE_ALIGNED ompi_f08_mpi_c_float16 = {74}; #endif diff --git a/ompi/mpiext/shortfloat/README.txt b/ompi/mpiext/shortfloat/README.txt index 428126e23d..6e39fafaf0 100644 --- a/ompi/mpiext/shortfloat/README.txt +++ b/ompi/mpiext/shortfloat/README.txt @@ -13,6 +13,13 @@ Each MPI datatype corresponds to the C/C++ type 'short float', the C type 'short float _Complex', and the C++ type 'std::complex', respectively. +In addition, this extension provides a datatype MPIX_C_FLOAT16 for +the C type _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. + + https://github.com/pmodels/mpich/pull/3455 + This extension is enabled only if the C compiler supports 'short float' or '_Float16', or the '--enable-alt-short-float=TYPE' option is passed to the configure script. diff --git a/ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h b/ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h.in similarity index 82% rename from ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h rename to ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h.in index fe26b5c7ac..eb97ac4eeb 100644 --- a/ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h +++ b/ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h.in @@ -15,3 +15,7 @@ OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_cxx_sfltcplex; #define MPIX_SHORT_FLOAT OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_short_float) #define MPIX_C_SHORT_FLOAT_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_c_short_float_complex) #define MPIX_CXX_SHORT_FLOAT_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_cxx_sfltcplex) + +#if @OMPI_MPIX_SHORT_FLOAT_IS_C_FLOAT16@ +#define MPIX_C_FLOAT16 OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_short_float) +#endif diff --git a/ompi/mpiext/shortfloat/configure.m4 b/ompi/mpiext/shortfloat/configure.m4 index 728dc25e80..4067dbd83d 100644 --- a/ompi/mpiext/shortfloat/configure.m4 +++ b/ompi/mpiext/shortfloat/configure.m4 @@ -17,6 +17,9 @@ AC_DEFUN([OMPI_MPIEXT_shortfloat_CONFIG],[ ompi/mpiext/shortfloat/mpif-h/Makefile ompi/mpiext/shortfloat/use-mpi/Makefile ompi/mpiext/shortfloat/use-mpi-f08/Makefile + ompi/mpiext/shortfloat/c/mpiext_shortfloat_c.h + ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h + ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h ]) AS_IF([{ test "$ENABLE_shortfloat" = "1" || \ @@ -25,6 +28,12 @@ AC_DEFUN([OMPI_MPIEXT_shortfloat_CONFIG],[ test "$ac_cv_type_opal_short_float_t" = "yes"; }], [$1], [$2]) + + AS_IF([test "$opal_short_float_type" = "_Float16"], + [AC_SUBST([OMPI_MPIX_SHORT_FLOAT_IS_C_FLOAT16], 1) + AC_SUBST([OMPI_MPIX_C_FLOAT16_FORTRAN_COMMENT_OUT], [])], + [AC_SUBST([OMPI_MPIX_SHORT_FLOAT_IS_C_FLOAT16], 0), + AC_SUBST([OMPI_MPIX_C_FLOAT16_FORTRAN_COMMENT_OUT], [!])]) ]) # The mpi_f08_ext module should not include mpiext_shortfloat_mpifh.h diff --git a/ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h b/ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h.in similarity index 73% rename from ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h rename to ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h.in index 2c79b9a6c7..3bf3692e59 100644 --- a/ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h +++ b/ompi/mpiext/shortfloat/mpif-h/mpiext_shortfloat_mpifh.h.in @@ -11,7 +11,9 @@ integer MPIX_SHORT_FLOAT integer MPIX_C_SHORT_FLOAT_COMPLEX integer MPIX_CXX_SHORT_FLOAT_COMPLEX +@OMPI_MPIX_C_FLOAT16_FORTRAN_COMMENT_OUT@ integer MPIX_C_FLOAT16 parameter (MPIX_SHORT_FLOAT=74) parameter (MPIX_C_SHORT_FLOAT_COMPLEX=75) parameter (MPIX_CXX_SHORT_FLOAT_COMPLEX=76) +@OMPI_MPIX_C_FLOAT16_FORTRAN_COMMENT_OUT@ parameter (MPIX_C_FLOAT16=74) diff --git a/ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h b/ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h.in similarity index 80% rename from ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h rename to ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h.in index 3a1b1181b0..8384798c75 100644 --- a/ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h +++ b/ompi/mpiext/shortfloat/use-mpi-f08/mpiext_shortfloat_usempif08.h.in @@ -14,3 +14,7 @@ type(MPI_Datatype), bind(C, name="ompi_f08_mpi_short_float") OMPI_PROTECTED :: MPIX_SHORT_FLOAT type(MPI_Datatype), bind(C, name="ompi_f08_mpi_c_short_float_complex") OMPI_PROTECTED :: MPIX_C_SHORT_FLOAT_COMPLEX type(MPI_Datatype), bind(C, name="ompi_f08_mpi_cxx_short_float_complex") OMPI_PROTECTED :: MPIX_CXX_SHORT_FLOAT_COMPLEX + +#if @OMPI_MPIX_SHORT_FLOAT_IS_C_FLOAT16@ +type(MPI_Datatype), bind(C, name="ompi_f08_mpi_c_float16") OMPI_PROTECTED :: MPIX_C_FLOAT16 +#endif