On 6/8/20 5:53 AM, LIU Zhiwei wrote:
Hi Richard,
I am doing bfloat16 support on QEMU.
Once I tried to reuse float32 interface, but I couldn't properly process
rounding in some insns like fadd.
What's your opinion about it? Should I expand the fpu/softfloat?
Yes, we need to expand fpu/softfloat.
You'll want something like
static const FloatFmt bfloat16_params = {
FLOAT_PARAMS(8, 7)
};
(This would be the Arm and x86 definition, anyway; hopefully risc-v is the
same.)
And then add all of the other interface functions that you need to use that
parameter.
FWIW, it appears that Arm only requires:
float32_to_bfloat16
bfloat16_mul
bfloat16_add
and I could even get away with only float32_to_bfloat16, since technically
Arm's BFAdd and BFMul psuedo-code are implemented in terms of single-precision
arithmetic, followed by a round-to-odd into BFloat16.