LIU Zhiwei <zhiwei_...@c-sky.com> writes:
> On 2020/6/8 23:50, Alex Bennée wrote: >> LIU Zhiwei <zhiwei_...@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. > > 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, > Zhiwei >>> Best Regards, >>> Zhiwei >> -- Alex Bennée