fp-bench fixes
cover fp-bench fixes
Two small fixes for fp-bench. They fix the fact that we weren't generating normals, even though we intended to.
You can pull this series from:
https://github.com/cota/qemu/tree/fp-bench-fixes
Thanks,
Emilio
PATCH 1/2 fp-bench: fix update_random_ops
The second test in the branches is wrong; fix while converting to a switch statement, which is easier to get right.
--- tests/fp/fp-bench.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tests/fp/fp-bench.c +8 -3
@@ -143,15 +143,20 @@ static void update_random_ops(int n_ops, enum precision prec)for (i =0 ; i < n_ops; i++) {uint64_t r = random_ops[i]; -if (prec ==PREC_SINGLE ||PREC_FLOAT32 ) { +switch (prec) { +case PREC_SINGLE : +case PREC_FLOAT32 :do { r =xorshift64star (r); }while (!float32_is_normal (r)); - }else if (prec ==PREC_DOUBLE ||PREC_FLOAT64 ) { +break ; +case PREC_DOUBLE : +case PREC_FLOAT64 :do { r =xorshift64star (r); }while (!float64_is_normal (r)); - }else { +break ; +default :g_assert_not_reached (); } random_ops[i] = r;
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 1/2] fp-bench: fix update_random_ops
Quoted 7 lines · Emilio G. Cota
The second test in the branches is wrong; fix while converting to a switch statement, which is easier to get right.
Signed-off-by Emilio G. Cota <[email protected]>--- tests/fp/fp-bench.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
Whoops.
r~
Re: [Qemu-devel] [PATCH 1/2] fp-bench: fix update_random_ops
In reply to Emilio G. CotaQuoted 13 lines · Emilio G. Cota
The second test in the branches is wrong; fix while converting to a switch statement, which is easier to get right.
Signed-off-by Emilio G. Cota <[email protected]>--- tests/fp/fp-bench.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)tests/fp/fp-bench.c +0
-0
tests/fp/fp-bench.c static void update_random_ops(int n_ops, enum precision prec) · line 146
Quoted 4 lines
tests/fp/fp-bench.c +0
-1@@ -143,15 +143,20 @@ static void update_random_ops(int n_ops, enum precision prec)for (i =0 ; i < n_ops; i++) {uint64_t r = random_ops[i]; -if (prec ==PREC_SINGLE ||PREC_FLOAT32 ) {
:)
Quoted 20 lines
tests/fp/fp-bench.c +8
-2+switch (prec) { +case PREC_SINGLE : +case PREC_FLOAT32 :do { r =xorshift64star (r); }while (!float32_is_normal (r)); - }else if (prec ==PREC_DOUBLE ||PREC_FLOAT64 ) { +break ; +case PREC_DOUBLE : +case PREC_FLOAT64 :do { r =xorshift64star (r); }while (!float64_is_normal (r)); - }else { +break ; +default :g_assert_not_reached (); } random_ops[i] = r;
PATCH 2/2 fp-bench: remove wrong exponent raise in fill_random
In reply to Emilio G. CotaAt this point random_ops[] only contains normals, so there's no need to do anything to them. In fact, raising the exponent here can make the output !normal, which is precisely what the comment says we want to avoid.
--- tests/fp/fp-bench.c | 4 ---- 1 file changed, 4 deletions(-)
tests/fp/fp-bench.c +0 -4
@@ -176,8 +176,6 @@ static void fill_random(union fp *ops, int n_ops, enum precision prec,if (no_neg &&float32_is_neg (ops[i].f32)) { ops[i].f32 =float32_chs (ops[i].f32); } -/* raise the exponent to limit the frequency of denormal results */ - ops[i].f32 |=0x40000000 ;break ;case PREC_DOUBLE :case PREC_FLOAT64 :
@@ -185,8 +183,6 @@ static void fill_random(union fp *ops, int n_ops, enum precision prec,if (no_neg &&float64_is_neg (ops[i].f64)) { ops[i].f64 =float64_chs (ops[i].f64); } -/* raise the exponent to limit the frequency of denormal results */ - ops[i].f64 |=LIT64 (0x4000000000000000 );break ;default :g_assert_not_reached ();
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 2/2] fp-bench: remove wrong exponent raise in fill_random
Quoted 9 lines · Emilio G. Cota
At this point random_ops[] only contains normals, so there's no need to do anything to them. In fact, raising the exponent here can make the output !normal, which is precisely what the comment says we want to avoid.
Signed-off-by Emilio G. Cota <[email protected]>--- tests/fp/fp-bench.c | 4 ---- 1 file changed, 4 deletions(-)
r~
Alex Bennée
AppliedQuoted 9 lines · Emilio G. Cota
Two small fixes for fp-bench. They fix the fact that we weren't generating normals, even though we intended to.
You can pull this series from:
https://github.com/cota/qemu/tree/fp-bench-fixesThanks,
Emilio
Queued to fpu/next, thanks.
--
Alex Bennée