From: Gaurav Sharma <gauravs.2010@gmail.com>
To: QEMU-DEVEL <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Issues in conversion to half precision number.
Date: Mon, 11 Aug 2014 14:54:35 +0530 [thread overview]
Message-ID: <CABiB5K5o1z3yPS6kd5bfsOfNtCvO4y=T0DaTsfmq1UyAZGdxcg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]
Hi,
While trying conversion of single precision float value to half precision
value for ARM, it seems the code generates incorrect values in some of the
scenarios :
"inline uint32_t perform_round16(iss_info *iss, uint32_t sign, int16_t exp,
uint32_t frac, FPRounding rounding)"
[Case 1]
1. From ARM specs overflow_to_inf is true and result is an overflow
condition.
if N != 16 || fpcr.AHP == '0' then // Single, double or IEEE half precision
if biased_exp >= 2^E - 1 then
result = if overflow_to_inf then FPInfinity(sign) else
FPMaxNormal(sign);
FPProcessException(FPExc_Overflow, fpcr);
error = 1.0; // Ensure that an Inexact exception occurs
In qemu, we always return the value as :
>> return packFloat16(zSign, 0x1f, 0);
In case overflow_to_inf is false we need to return FPMaxNormal which is :
>> return float_num16(sign, 0x1e, 0x3ff);
[Case 2]
1. From ARM specs :
if round_up then
int_mant = int_mant + 1;
if int_mant == 2^F then // Rounded up from denormalized to normalized
biased_exp = 1;
if int_mant == 2^(F+1) then // Rounded up to next exponent
biased_exp = biased_exp + 1; int_mant = int_mant DIV 2;
result = sign : biased_exp<N-F-2:0> : int_mant<F-1:0>;
[QEMU]
if (exp < -10) {
return float_num16(sign, 0, 0);
}
The incremented round up value seems to be lost in this scenario.
Kindly, let me know in case more data points are required.
Thanks,
Gaurav
[-- Attachment #2: Type: text/html, Size: 1844 bytes --]
reply other threads:[~2014-08-11 9:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='CABiB5K5o1z3yPS6kd5bfsOfNtCvO4y=T0DaTsfmq1UyAZGdxcg@mail.gmail.com' \
--to=gauravs.2010@gmail.com \
--cc=qemu-devel@nongnu.org \
/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).