diff --git a/config/opal_check_alt_short_float.m4 b/config/opal_check_alt_short_float.m4 index 1df8b228b3..ac285eed9e 100644 --- a/config/opal_check_alt_short_float.m4 +++ b/config/opal_check_alt_short_float.m4 @@ -1,6 +1,7 @@ dnl -*- shell-script -*- dnl -dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. +dnl Copyright (c) 2018-2020 FUJITSU LIMITED. All rights reserved. +dnl Copyright (c) 2020 Cisco Systems, Inc. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -8,10 +9,10 @@ dnl dnl $HEADER$ dnl -# Check whether the user wants to use an alternate type of C 'short float'. +dnl Check whether the user wants to use an alternate type of C 'short float'. -# OPAL_CHECK_ALT_SHORT_FLOAT -# ------------------------------------------------------------ +dnl OPAL_CHECK_ALT_SHORT_FLOAT +dnl ------------------------------------------------------------ AC_DEFUN([OPAL_CHECK_ALT_SHORT_FLOAT], [ AC_CHECK_TYPES(_Float16) AC_MSG_CHECKING([if want alternate C type of short float]) @@ -35,7 +36,34 @@ AC_DEFUN([OPAL_CHECK_ALT_SHORT_FLOAT], [ fi if test "$opal_short_float_type" != ""; then AC_MSG_RESULT([yes ($opal_short_float_type)]) - AC_CHECK_TYPES($opal_short_float_type, [opal_enable_short_float=1], [opal_enable_short_float=0]) + AC_CHECK_TYPES($opal_short_float_type, [opal_alt_short_float_exists=1], [opal_alt_short_float_exists=0]) + + # Even if the alternate short float type exists, make sure + # that the compiler can actually compile/link when + # mathematical operations are performed on variables of that + # type. Case in point: clang 6.0.x and 7.0.x need an + # additional CLI flag added (--rtlib=compiler-rt) to enable + # software emulation of _Float16. Open MPI will *not* + # automagically add that flag -- we'll just emit a warning and + # point the user to a README where more information is + # available. + AC_MSG_CHECKING([if compiler supports arithmetic operations on $opal_short_float_type]) + AS_IF([test $opal_alt_short_float_exists -eq 1], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ +static $opal_short_float_type a = 2.5, b = 3.8; +a += b;]])], + [AC_MSG_RESULT([yes]) + opal_enable_short_float=1], + [AC_MSG_RESULT([no]) + AS_IF([test `basename $CC` = "clang"], + [AC_MSG_WARN([if you are using the Clang 6.0.x or 7.0.x compilers and want]) + AC_MSG_WARN([to enable software emulation of half-precision floating point]) + AC_MSG_WARN([in conjunction with the "shortfloat" Open MPI extension,]) + AC_MSG_WARN([see the ompi/mpiext/shortfloat/README.txt file for details.]) + ]) + opal_enable_short_float=0]) + ]) + if test "$opal_enable_short_float" = 1; then AC_DEFINE_UNQUOTED(opal_short_float_t, [[$opal_short_float_type]], [User-selected alternate C type of short float]) diff --git a/ompi/mpiext/shortfloat/README.txt b/ompi/mpiext/shortfloat/README.txt index 6e39fafaf0..3406fc5d1b 100644 --- a/ompi/mpiext/shortfloat/README.txt +++ b/ompi/mpiext/shortfloat/README.txt @@ -23,3 +23,13 @@ that of MPICH. 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. + +NOTE: The Clang 6.0.x and 7.0.x compilers support the "_Float16" type +(via software emulation), but require an additional linker flag to +function properly. If you wish to enable Clang 6.0.x or 7.0.x's +software emulation of _Float16, use the following CLI options to Open +MPI configure script: + + ./configure \ + LDFLAGS=--rtlib=compiler-rt \ + --with-wrapper-ldflags=--rtlib=compiler-rt ...