qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: LIU Zhiwei <zhiwei_liu@c-sky.com>
Cc: Richard Henderson <richard.henderson@linaro.org>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: fpu/softfloat: a question on BFloat 16 support on QEMU
Date: Tue, 09 Jun 2020 10:42:29 +0100	[thread overview]
Message-ID: <874krk60e2.fsf@linaro.org> (raw)
In-Reply-To: <53bee901-6917-1783-6507-3fef6955cc49@c-sky.com>


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.

>
> 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


  reply	other threads:[~2020-06-09  9:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08 12:53 fpu/softfloat: a question on BFloat 16 support on QEMU LIU Zhiwei
2020-06-08 15:50 ` Alex Bennée
2020-06-09  3:02   ` LIU Zhiwei
2020-06-09  9:42     ` Alex Bennée [this message]
2020-06-09 11:16       ` LIU Zhiwei
2020-06-17  7:09   ` LIU Zhiwei
2020-06-26 15:58     ` Richard Henderson
2020-06-08 19:34 ` Richard Henderson
2020-06-09  3:09   ` LIU Zhiwei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874krk60e2.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhiwei_liu@c-sky.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).