-----Original Message----- From: Boost
On Behalf Of Phil Endecott via Boost Sent: 14 October 2019 20:15 To: boost@lists.boost.org Cc: Phil Endecott Subject: [boost] [Math] float16 on ARM Hi,
There seems to be support for 16-bit floats on iOS, when using Apple's XCode clang. This seems to be a storage-only format with the only instruction set support being conversions to and from 32- and 64-bit floats. Quick test:
#if __ARM_FP & 2 #warning "Have 16-bit FP" #endif
void test() { __fp16 a = 1.234; static_assert(sizeof(a)==2); __fp16 b = 2.345; auto sum = a+b; static_assert(sizeof(sum)==4); }
There doesn't seem to be a std::numeric_limits specialisation.
I suspect that other platforms have something similar. It would be good to have a boost::float16_t typedef and a portable feature-test macro (and maybe a software fallback). As far as I can see, boost/math/cstdfloat/cstdfloat_types.hpp checks the sizes of float, double and long double, and checks for 128-bit floats provided by the compiler. Can this be extended to check for __fp16 ?
(P.S. it seems that gcc also has support, see https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html )
I:\boost\libs\math\include\boost\math\cstdfloat\cstdfloat_types.hpp has some mention for 16-bit floating-point double. Is this the only 16-bit floating-point format in use? The storage-only nature of the type is another complication. But in principle, yes, I support this (but am uncertain how to implement it in detail). Paul Paul A. Bristow Prizet Farmhouse Kendal, Cumbria LA8 8AB UK