From nobody Tue Oct 7 04:27:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1593202273; cv=none; d=zohomail.com; s=zohoarc; b=EHUq017319CepH6aw/iXISib0+8CaSM4jRuBtE0/BIriBZdz66u2wMoXp4Y3Ihr2S4RUJc7KxfZGRgAbOjYq4J1vYkA4Cs8jL17mgDTXxkWg1wv4DZVhN9HqH93buYltUjsW7SvivgWKRKefTDLAveukko6d7M8ub6wBgKEXf3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593202273; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SW802rsBjyjH3nSM8zwvWR8Kt24bL/tDHyeHn/2Y6L4=; b=baFlOZo//mtaXP2V9E99S74l6FXgqp4Bv4EiJMxhu3JcOtgXgJHunjsEssOGCZP8UA5203l09HYGmkT8btu/BWbHh0E14E+pLsGTiow8LLR7Gl7WwTmg1IW0we0r1EGHB9OkvjvZ5LYllo0pct4VOUFBUN6A4/neMH4it0dMMvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593202273098795.398677184658; Fri, 26 Jun 2020 13:11:13 -0700 (PDT) Received: from localhost ([::1]:45724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jougp-0005gb-T8 for importer@patchew.org; Fri, 26 Jun 2020 16:11:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jouff-0004MH-P0 for qemu-devel@nongnu.org; Fri, 26 Jun 2020 16:09:59 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:46722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1joufe-000443-5Q for qemu-devel@nongnu.org; Fri, 26 Jun 2020 16:09:59 -0400 Received: by mail-pf1-x442.google.com with SMTP id b16so5060093pfi.13 for ; Fri, 26 Jun 2020 13:09:57 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id n8sm23879405pgi.18.2020.06.26.13.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 13:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SW802rsBjyjH3nSM8zwvWR8Kt24bL/tDHyeHn/2Y6L4=; b=N7qHoavy76cIFRRnP7H8p2TP83RVrVKT4yO7yN3Hg85MvuXYyNU91RAGg4g6RJMjUq 9UiS/9BG5IO2nfY4OA6Gq+5Gc9667D1p+DCxWjtCBD6Bc59Q5r+G1JU1SRjJiyZ95TW0 HWgIRYzhpCchKvuT/69134fepgDiQSsf8I7XkePCga8MJAMtSf/TWY5fknSG7hM1m71Q Q+4PaBB6ZiWSDCBZZCeBz2/L4Axzv2pixXMqkLxyVoXbiH6WE56ZM7Ihfru49fCrIhOa 1XWhH5enJkSd9NoW/AZuhQLg5TDJnNN2SvDK5k7tfsIip4+Dhd1z/wK0dGCFZQDJUzWE 7TfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SW802rsBjyjH3nSM8zwvWR8Kt24bL/tDHyeHn/2Y6L4=; b=Mk/2Q2Nm6oS5bQBwQAvxxJyg2LGXMBMkUHjaRbP29h9DiQs/wcaUTp9fFweI2r+k45 vMmyHHrulbif0LBpzLoznQmOJiCU/jJmhTGB+NzL6b6THTRxtxQIEEPNM1ee9uuXLYY3 Yrl9GQI5CKdh+tOlnQyQzA7ZswIfc3JZrcSjX3WuhzzAwKAWRNfrKDMhWFKE6arkivkR ZOHeozVJrmxm3jzevHwTHcEZyJ8MjubVOWhNp/rTSNvjza0U5VEtValXty69YjBOsoGn WxbLmW3Q3d/w0PHX8cmf07InbUbasbp7ZMeYr4IecMUEVyQ9N4D+yu7mMP5Fxa44Dz6f xGOA== X-Gm-Message-State: AOAM531cxfLkjzSxJvrlzK5lxOwICR3NO00J9m+7rLtKYwXn49eGG/Go +BOCDJSQqsFWjuQycDADzU4jlUTES0k= X-Google-Smtp-Source: ABdhPJxwx1bqsjUFmUaJMqD7eI0VJ6arOGJwYBAk3Vx3zJmmhqFdqSw4cvnrC+nc8BOiiBF94tMczw== X-Received: by 2002:aa7:9289:: with SMTP id j9mr4573050pfa.124.1593202196355; Fri, 26 Jun 2020 13:09:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] tests/qht-bench: Adjust threshold computation Date: Fri, 26 Jun 2020 13:09:50 -0700 Message-Id: <20200626200950.1015121-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200626200950.1015121-1-richard.henderson@linaro.org> References: <20200626200950.1015121-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qht-bench.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/qht-bench.c b/tests/qht-bench.c index ad885d89d0..362f03cb03 100644 --- a/tests/qht-bench.c +++ b/tests/qht-bench.c @@ -289,11 +289,25 @@ static void pr_params(void) =20 static void do_threshold(double rate, uint64_t *threshold) { + /* + * For 0 <=3D rate <=3D 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 =3D=3D 1.0) { *threshold =3D UINT64_MAX; } else { - *threshold =3D (rate * 0xffff000000000000ull) - + (rate * 0x0000ffffffffffffull); + *threshold =3D rate * 0x1p64; } } =20 --=20 2.25.1