From nobody Tue Feb 10 08:26:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528769290478360.7767159648407; Mon, 11 Jun 2018 19:08:10 -0700 (PDT) Received: from localhost ([::1]:52316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSYj2-0001WS-Kg for importer@patchew.org; Mon, 11 Jun 2018 22:08:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSYQm-000464-OO for qemu-devel@nongnu.org; Mon, 11 Jun 2018 21:49:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSYQi-0003Mm-GF for qemu-devel@nongnu.org; Mon, 11 Jun 2018 21:49:08 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:60827) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSYQi-0003Ls-9u for qemu-devel@nongnu.org; Mon, 11 Jun 2018 21:49:04 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E3C0921D77; Mon, 11 Jun 2018 21:49:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 11 Jun 2018 21:49:03 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 8B4EE1025D; Mon, 11 Jun 2018 21:49:03 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=Vfqc39+8Dvxfki rM4wL8QQDTSxAqwcvmeIBJexFl2YY=; b=2oh+bhFfGfShQIqSQ4Pv1wHejiPA6K 6wjDWIqkSiGlMsJW4eWsa8NUrOgCDuRlOvnzswkiN6O0aYWPxlaIrJTppbYidK9w KnFSw0Ac5SVfUwjDfVSmFKFxH8rliQ3Bj76mol61lKXbzRj8R59Xn4Pp57QUmwIm Cl4ogLcXqsgpU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=Vfqc39+8DvxfkirM4wL8QQDTSxAqwcvmeIBJexFl2YY=; b=mZjWRsL2 BZ5m3cT5PncLvEqgbnRtWn1RH2SQAWge4a1/+bRVn18vu0bc2X7kOwUdIB6P/r8a 2atNimnZxuJ/tS+YP5FOnBYaeRtBC+1eKvvL5BNzBiI4s2tCdllb828/rBWIjTDj FNpfii/4mnHG0nVvasJ3Hf8VWj6siEmyCx+T9eKnLPy+iSxkMl0UrBJQ7OL1hE1q tdA+N0dRDqGhQm06J/PHTKUeszd/i8KdJfxui4lvefuEXRZoHTwEdzgVM9cPwXq8 B+LfNbs0xVYuvO070dYn3Wslv7Nle1Ncxag2hBsfxGyqbLumh4dJ5zrCdjHC3col S0L5umJ7EKcquw== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Mon, 11 Jun 2018 21:48:59 -0400 Message-Id: <1528768140-17894-14-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528768140-17894-1-git-send-email-cota@braap.org> References: <1528768140-17894-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v4 13/14] hardfloat: support float32/64 square root X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Mark Cave-Ayland , Richard Henderson , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Performance results for fp-bench: 1. Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz - before: sqrt-single: 43.27 MFlops sqrt-double: 24.81 MFlops - after: sqrt-single: 297.94 MFlops sqrt-double: 210.46 MFlops 2. ARM Aarch64 A57 @ 2.4GHz - before: sqrt-single: 12.41 MFlops sqrt-double: 6.22 MFlops - after: sqrt-single: 55.58 MFlops sqrt-double: 40.63 MFlops 3. IBM POWER8E @ 2.1 GHz - before: sqrt-single: 17.01 MFlops sqrt-double: 9.61 MFlops - after: sqrt-single: 104.17 MFlops sqrt-double: 133.32 MFlops Here none of the machines got faster from enabling USE_FP. For instance, on x86_64 sqrt is 23% slower for single precision, with it enabled, and 17% slower for double precision. Signed-off-by: Emilio G. Cota --- fpu/softfloat.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 63cf60c..f89e872 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2812,14 +2812,16 @@ float16 __attribute__((flatten)) float16_sqrt(float= 16 a, float_status *status) return float16_round_pack_canonical(pr, status); } =20 -float32 __attribute__((flatten)) float32_sqrt(float32 a, float_status *sta= tus) +static float32 QEMU_SOFTFLOAT_ATTR +soft_float32_sqrt(float32 a, float_status *status) { FloatParts pa =3D float32_unpack_canonical(a, status); FloatParts pr =3D sqrt_float(pa, status, &float32_params); return float32_round_pack_canonical(pr, status); } =20 -float64 __attribute__((flatten)) float64_sqrt(float64 a, float_status *sta= tus) +static float64 QEMU_SOFTFLOAT_ATTR +soft_float64_sqrt(float64 a, float_status *status) { FloatParts pa =3D float64_unpack_canonical(a, status); FloatParts pr =3D sqrt_float(pa, status, &float64_params); @@ -2899,6 +2901,73 @@ float64 float64_silence_nan(float64 a, float_status = *status) return float64_pack_raw(p); } =20 +#define GEN_SQRT_SF(name, soft_t, host_t, host_sqrt_func) \ + static soft_t name(soft_t a, float_status *s) \ + { \ + if (QEMU_NO_HARDFLOAT) { \ + goto soft; \ + } \ + soft_t ## _input_flush1(&a, s); \ + if (likely(soft_t ## _is_zero_or_normal(a) && \ + !soft_t ## _is_neg(a) && \ + can_use_fpu(s))) { \ + host_t ha =3D soft_t ## _to_ ## host_t(a); \ + host_t hr =3D host_sqrt_func(ha); \ + \ + return host_t ## _to_ ## soft_t(hr); \ + } \ + soft: \ + return soft_ ## soft_t ## _sqrt(a, s); \ + } + +#define GEN_SQRT_FP(name, soft_t, host_t, host_sqrt_func) \ + static soft_t name(soft_t a, float_status *s) \ + { \ + host_t ha; \ + \ + if (QEMU_NO_HARDFLOAT) { \ + goto soft; \ + } \ + soft_t ## _input_flush1(&a, s); \ + ha =3D soft_t ## _to_ ## host_t(a); \ + if (likely((fpclassify(ha) =3D=3D FP_NORMAL || = \ + fpclassify(ha) =3D=3D FP_ZERO) && = \ + !signbit(ha) && \ + can_use_fpu(s))) { \ + host_t hr =3D host_sqrt_func(ha); \ + \ + return host_t ## _to_ ## soft_t(hr); \ + } \ + soft: \ + return soft_ ## soft_t ## _sqrt(a, s); \ + } + +GEN_SQRT_SF(f32_sqrt, float32, float, sqrtf) +GEN_SQRT_SF(f64_sqrt, float64, double, sqrt) +#undef GEN_SQRT_SF + +GEN_SQRT_FP(float_sqrt, float32, float, sqrtf) +GEN_SQRT_FP(double_sqrt, float64, double, sqrt) +#undef GEN_SQRT_FP + +float32 __attribute__((flatten)) float32_sqrt(float32 a, float_status *s) +{ + if (QEMU_HARDFLOAT_1F32_USE_FP) { + return float_sqrt(a, s); + } else { + return f32_sqrt(a, s); + } +} + +float64 __attribute__((flatten)) float64_sqrt(float64 a, float_status *s) +{ + if (QEMU_HARDFLOAT_1F64_USE_FP) { + return double_sqrt(a, s); + } else { + return f64_sqrt(a, s); + } +} + /*------------------------------------------------------------------------= ---- | Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 | and 7, and returns the properly rounded 32-bit integer corresponding to = the --=20 2.7.4