[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 41/41] tests/qht-bench: Adjust threshold computation
From: |
Alex Bennée |
Subject: |
[PULL 41/41] tests/qht-bench: Adjust threshold computation |
Date: |
Tue, 7 Jul 2020 08:08:58 +0100 |
From: Richard Henderson <richard.henderson@linaro.org>
In 06c4cc3660b3, we split the multiplication in two parts to avoid
a clang warning. But because double still rounds to 53 bits, this
does not provide additional precision beyond multiplication by
nextafter(0x1p64, 0), the largest representable value smaller
than 2**64.
However, since we have eliminated 1.0, mutiplying by 2**64 produces
a better distribution of input values to the output values.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200626200950.1015121-3-richard.henderson@linaro.org>
diff --git a/tests/qht-bench.c b/tests/qht-bench.c
index ad885d89d054..362f03cb0370 100644
--- a/tests/qht-bench.c
+++ b/tests/qht-bench.c
@@ -289,11 +289,25 @@ static void pr_params(void)
static void do_threshold(double rate, uint64_t *threshold)
{
+ /*
+ * For 0 <= rate <= 1, scale to fit in a uint64_t.
+ *
+ * Scale by 2**64, with a special case for 1.0.
+ * The remainder of the possible values are scattered between 0
+ * and 0xfffffffffffff800 (nextafter(0x1p64, 0)).
+ *
+ * Note that we cannot simply scale by UINT64_MAX, because that
+ * value is not representable as an IEEE double value.
+ *
+ * If we scale by the next largest value, nextafter(0x1p64, 0),
+ * then the remainder of the possible values are scattered between
+ * 0 and 0xfffffffffffff000. Which leaves us with a gap between
+ * the final two inputs that is twice as large as any other.
+ */
if (rate == 1.0) {
*threshold = UINT64_MAX;
} else {
- *threshold = (rate * 0xffff000000000000ull)
- + (rate * 0x0000ffffffffffffull);
+ *threshold = rate * 0x1p64;
}
}
--
2.20.1
- Re: [PULL 10/41] python/qemu: Add ConsoleSocket for optional use in QEMUMachine, (continued)
[PULL 12/41] tests/vm: switch from optsparse to argparse, Alex Bennée, 2020/07/07
[PULL 14/41] tests/docker: check for an parameters not empty string, Alex Bennée, 2020/07/07
[PULL 15/41] tests/docker: change tag naming scheme of our images, Alex Bennée, 2020/07/07
[PULL 11/41] tests/vm: Add workaround to consume console, Alex Bennée, 2020/07/07
[PULL 13/41] tests/vm: allow us to take advantage of MTTCG, Alex Bennée, 2020/07/07
[PULL 29/41] tests/tcg: add more default compilers to configure.sh, Alex Bennée, 2020/07/07
[PULL 41/41] tests/qht-bench: Adjust threshold computation,
Alex Bennée <=
[PULL 28/41] gitlab: add acceptance testing to system builds, Alex Bennée, 2020/07/07
[PULL 31/41] linux-user/elfload: use MAP_FIXED_NOREPLACE in pgb_reserved_va, Alex Bennée, 2020/07/07
[PULL 20/41] gitlab: convert jobs to use custom built containers, Alex Bennée, 2020/07/07
[PULL 39/41] travis.yml: Test also the other targets on s390x, Alex Bennée, 2020/07/07
[PULL 18/41] gitlab: introduce explicit "container" and "build" stages, Alex Bennée, 2020/07/07
[PULL 16/41] .gitignore: un-ignore .gitlab-ci.d, Alex Bennée, 2020/07/07
[PULL 17/41] gitlab-ci: Fix the change rules after moving the YML files, Alex Bennée, 2020/07/07
[PULL 27/41] tests/acceptance: skip LinuxInitrd 2gib with v4.16 on GitLab, Alex Bennée, 2020/07/07
[PULL 36/41] containers.yml: build with docker.py tooling, Alex Bennée, 2020/07/07
[PULL 25/41] tests/acceptance: fix dtb path for machine_rx_gdbsim, Alex Bennée, 2020/07/07