Skip to content

Commit fcdcb59

Browse files
authored
Merge pull request #7826 from jsquyres/pr/clang-6-and-7-hate-float16
More carefully test "alternate" short float type in configure
2 parents 9af19ab + 2c17171 commit fcdcb59

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

config/opal_check_alt_short_float.m4

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
dnl -*- shell-script -*-
22
dnl
3-
dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
3+
dnl Copyright (c) 2018-2020 FUJITSU LIMITED. All rights reserved.
4+
dnl Copyright (c) 2020 Cisco Systems, Inc. All rights reserved.
45
dnl $COPYRIGHT$
56
dnl
67
dnl Additional copyrights may follow
78
dnl
89
dnl $HEADER$
910
dnl
1011

11-
# Check whether the user wants to use an alternate type of C 'short float'.
12+
dnl Check whether the user wants to use an alternate type of C 'short float'.
1213

13-
# OPAL_CHECK_ALT_SHORT_FLOAT
14-
# ------------------------------------------------------------
14+
dnl OPAL_CHECK_ALT_SHORT_FLOAT
15+
dnl ------------------------------------------------------------
1516
AC_DEFUN([OPAL_CHECK_ALT_SHORT_FLOAT], [
1617
AC_CHECK_TYPES(_Float16)
1718
AC_MSG_CHECKING([if want alternate C type of short float])
@@ -35,7 +36,34 @@ AC_DEFUN([OPAL_CHECK_ALT_SHORT_FLOAT], [
3536
fi
3637
if test "$opal_short_float_type" != ""; then
3738
AC_MSG_RESULT([yes ($opal_short_float_type)])
38-
AC_CHECK_TYPES($opal_short_float_type, [opal_enable_short_float=1], [opal_enable_short_float=0])
39+
AC_CHECK_TYPES($opal_short_float_type, [opal_alt_short_float_exists=1], [opal_alt_short_float_exists=0])
40+
41+
# Even if the alternate short float type exists, make sure
42+
# that the compiler can actually compile/link when
43+
# mathematical operations are performed on variables of that
44+
# type. Case in point: clang 6.0.x and 7.0.x need an
45+
# additional CLI flag added (--rtlib=compiler-rt) to enable
46+
# software emulation of _Float16. Open MPI will *not*
47+
# automagically add that flag -- we'll just emit a warning and
48+
# point the user to a README where more information is
49+
# available.
50+
AC_MSG_CHECKING([if compiler supports arithmetic operations on $opal_short_float_type])
51+
AS_IF([test $opal_alt_short_float_exists -eq 1],
52+
[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
53+
static $opal_short_float_type a = 2.5, b = 3.8;
54+
a += b;]])],
55+
[AC_MSG_RESULT([yes])
56+
opal_enable_short_float=1],
57+
[AC_MSG_RESULT([no])
58+
AS_IF([test `basename $CC` = "clang"],
59+
[AC_MSG_WARN([if you are using the Clang 6.0.x or 7.0.x compilers and want])
60+
AC_MSG_WARN([to enable software emulation of half-precision floating point])
61+
AC_MSG_WARN([in conjunction with the "shortfloat" Open MPI extension,])
62+
AC_MSG_WARN([see the ompi/mpiext/shortfloat/README.txt file for details.])
63+
])
64+
opal_enable_short_float=0])
65+
])
66+
3967
if test "$opal_enable_short_float" = 1; then
4068
AC_DEFINE_UNQUOTED(opal_short_float_t, [[$opal_short_float_type]],
4169
[User-selected alternate C type of short float])

ompi/mpiext/shortfloat/README.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@ that of MPICH.
2323
This extension is enabled only if the C compiler supports 'short float'
2424
or '_Float16', or the '--enable-alt-short-float=TYPE' option is passed
2525
to the configure script.
26+
27+
NOTE: The Clang 6.0.x and 7.0.x compilers support the "_Float16" type
28+
(via software emulation), but require an additional linker flag to
29+
function properly. If you wish to enable Clang 6.0.x or 7.0.x's
30+
software emulation of _Float16, use the following CLI options to Open
31+
MPI configure script:
32+
33+
./configure \
34+
LDFLAGS=--rtlib=compiler-rt \
35+
--with-wrapper-ldflags=--rtlib=compiler-rt ...

0 commit comments

Comments
 (0)