|
From: | LIU Zhiwei |
Subject: | Re: fpu/softfloat: a question on BFloat 16 support on QEMU |
Date: | Tue, 9 Jun 2020 19:16:00 +0800 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
On 2020/6/9 17:42, Alex Bennée wrote:
LIU Zhiwei <zhiwei_liu@c-sky.com> writes:On 2020/6/8 23:50, Alex Bennée wrote:LIU Zhiwei <zhiwei_liu@c-sky.com> writes: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 do you mean by re-use the float32 interface?Once I think bfloat16 can been converted to float32 by deposit32(0, 16, 16, bf16) Then do a bfloat16 op by float32 op.No I don't think you want to be munging things like that - best to decompose it into FloatParts and let the common code deal with the actual calculation. We've learnt the hard way that having lots of slightly different functions each dealing with edge cases and rounding ends up in mistakes creeping in. The common code path is well tested and a lot easier to understand.
Get it. Thanks. If I am ready, I will upstream the bfloat16 code. Best Regards, Zhiwei
At last, get the bfloat16 result by right shift the float32 result 16 bits.Again the common round and packing code should be agnostic to the underlying precision.Isn't bfloat16 going to be pretty much the same as float16 but with some slightly different float parameters for the different encoding?Agree.Like the float16 code it won't have to deal with any of the hardfloat wrappers so it should look pretty similar.Good idea. I will list the float16 interfaces, and try to emulate the bfloat16 one by one. I list float16 interfaces in softfloat.c alone. It counts 67 interfaces.What's your opinion about it? Should I expand the fpu/softfloat?bfloat16 is certainly going to become more common that we should have common softfloat code to handle it. It would be nice is TestFloat could exercise it as well.Thanks. I will try to use make check-softfloat to test bfloat16 interfaces. Best Regards, ZhiweiBest Regards, Zhiwei
[Prev in Thread] | Current Thread | [Next in Thread] |