ac_c_werror_flag=$cu_save_c_werror_flag
# Test compiler support for half precision floating point types (for od)
-AC_CHECK_TYPES([_Float16, __bf16])
+AC_MSG_CHECKING([IEEE 16 bit floating point])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([[
+ int
+ main (void)
+ {
+ _Float16 hf;
+ float f = hf; /* Ensure compiler can promote to float. */
+ }
+ ]])
+ ],[
+ ieee_16_bit_supported=yes
+ ],[
+ ieee_16_bit_supported=no
+ ])
+AC_MSG_RESULT([$ieee_16_bit_supported])
+if test $ieee_16_bit_supported = yes; then
+ AC_DEFINE([FLOAT16_SUPPORTED], [1], [IEEE 16 bit float supported])
+fi
+
+AC_MSG_CHECKING([Brain 16 bit floating point])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([[
+ int
+ main (void)
+ {
+ __bf16 hf;
+ float f = hf; /* Ensure compiler can promote to float. */
+ }
+ ]])
+ ],[
+ brain_16_bit_supported=yes
+ ],[
+ brain_16_bit_supported=no
+ ])
+AC_MSG_RESULT([$brain_16_bit_supported])
+if test $brain_16_bit_supported = yes; then
+ AC_DEFINE([BF16_SUPPORTED], [1], [Brain 16 bit float supported])
+fi
ac_save_CFLAGS=$CFLAGS
CFLAGS="-mavx -mpclmul $CFLAGS"
typedef unsigned long int unsigned_long_long_int;
#endif
-#if HAVE__FLOAT16
+#if FLOAT16_SUPPORTED
/* Available since clang 6 (2018), and gcc 7 (2017). */
typedef _Float16 float16;
#else
-# define HAVE__FLOAT16 0
+# define FLOAT16_SUPPORTED 0
/* This is just a place-holder to avoid a few '#if' directives.
In this case, the type isn't actually used. */
typedef float float16;
#endif
-#if HAVE___BF16
+#if BF16_SUPPORTED
/* Available since clang 11 (2020), and gcc 13 (2023). */
typedef __bf16 bfloat16;
#else
-# define HAVE___BF16 0
+# define BF16_SUPPORTED 0
/* This is just a place-holder to avoid a few '#if' directives.
In this case, the type isn't actually used. */
typedef float bfloat16;
sizeof (int),
sizeof (long int),
sizeof (unsigned_long_long_int),
-#if HAVE___BF16
+#if BF16_SUPPORTED
sizeof (bfloat16),
#else
sizeof (float16),
{
if (size > MAX_FP_TYPE_SIZE
|| fp_type_size[size] == NO_SIZE
- || (! HAVE__FLOAT16 && HAVE___BF16
+ || (! FLOAT16_SUPPORTED && BF16_SUPPORTED
&& size == sizeof (bfloat16))
)
{
}
size_spec = fp_type_size[size];
- if ((! HAVE__FLOAT16 && fmt == HFLOATING_POINT)
- || (! HAVE___BF16 && fmt == BFLOATING_POINT))
+ if ((! FLOAT16_SUPPORTED && fmt == HFLOATING_POINT)
+ || (! BF16_SUPPORTED && fmt == BFLOATING_POINT))
{
error (0, 0,
_("this system doesn't provide a %s floating point type"),
for (i = 0; i <= MAX_FP_TYPE_SIZE; i++)
fp_type_size[i] = NO_SIZE;
-#if HAVE__FLOAT16
+#if FLOAT16_SUPPORTED
fp_type_size[sizeof (float16)] = FLOAT_HALF;
-#elif HAVE___BF16
+#elif BF16_SUPPORTED
fp_type_size[sizeof (bfloat16)] = FLOAT_HALF;
#endif
fp_type_size[sizeof (float)] = FLOAT_SINGLE;
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ od
+print_ver_ od printf
export LC_ALL=C
#esac
# Check Half precision IEEE 16 bit float
-if grep '^#define HAVE__FLOAT16 1' "$CONFIG_HEADER" >/dev/null; then
+if grep '^#define FLOAT16_SUPPORTED 1' "$CONFIG_HEADER" >/dev/null; then
for fmt in '-tfH' '-tf2'; do
- od_out=$(printf '\x3C\x00\x3C\x00' | od --endian=big -An $fmt | tr -d ' ')
+ od_out=$(env printf '\x3C\x00\x3C\x00' | od --end=big -An $fmt | tr -d ' ')
test "$od_out" = '11' || fail=1
done
else
compare exp_err err || fail=1
fi
# Check Half precision Brain 16 bit float
-if grep '^#define HAVE___BF16 1' "$CONFIG_HEADER" >/dev/null; then
- od_out=$(printf '\x3F\x80\x3F\x80' | od --endian=big -An -tfB | tr -d ' ')
+if grep '^#define BF16_SUPPORTED 1' "$CONFIG_HEADER" >/dev/null; then
+ od_out=$(env printf '\x3F\x80\x3F\x80' | od --end=big -An -tfB | tr -d ' ')
test "$od_out" = '11' || fail=1
else
echo "od: this system doesn't provide a 'fB' floating point type" > exp_err