check_alt_short_float: ensure compiler supports math
Even if the compiler supports an "alternate" short float type (e.g., _Float16), check to make sure that the compiler will correctly link applications that perform mathematical operations on that type. Carefully choose the mathematical test in the configure check to ensure the mathematical operation is not removed by compiler optimization (when setting CFLAGS=-O1 or higher). Out of the box, clang 6.0.x and 7.0.x will fail to link applications that try to perform addition (and other mathematical operations) on _Float16 variables (an additional CLI flag is required to enable software emulation of _Float16). If we detect a situation where the type is supported by a sample program fails to link and the basename of $CC is "clang", emit a warning and point the user to a relevant README. Signed-off-by: Jeff Squyres <jsquyres@cisco.com> Signed-off-by: KAWASHIMA Takahiro <t-kawashima@fujitsu.com>
Этот коммит содержится в:
родитель
9af19ab205
Коммит
47df60717c
@ -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
|
||||
@ -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])
|
||||
|
@ -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 ...
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user