From patchwork Mon Dec 11 12:56:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 121394 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2756874qgn; Mon, 11 Dec 2017 05:00:08 -0800 (PST) X-Google-Smtp-Source: ACJfBosF1Si6lEelOvS1eQ/NNHimCm4fYkaVO3R5VLWOix6KB+CX+wPx8IJSSEHo0CB6crUWrk+O X-Received: by 10.37.210.132 with SMTP id j126mr202170ybg.52.1512997208152; Mon, 11 Dec 2017 05:00:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512997208; cv=none; d=google.com; s=arc-20160816; b=surh9C7fK6B77EGnUWv6Inyvb2Q/AKqXMX1vmXpF2RHEzGjUo7uQuMZJTfZuC8sAft Hy929z10HJ7pK9kzqYwPknboGaWgltNJXTHHtx9UASzyZig4+IekkJKqqxJhr6SHGD6c 4Eg2K5s0/GB7NU/bhRFmjgl/KiV3WgCLB0TO6miotzibW8JkusWub9tQ+GWODSKYePDf kD/FSaBe9/qqAMbw7EuMdIW39fIVEbRfeypMC4FaY4qQnuU93CutaGcEAdQ3abfC03Ai rVtDZVmKpnQ7s8XqlpUZz1JlGvarorcfSim0yPwmsAL+r2p6dRu6+eROICRSBaNkkhow Bc3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=FZoUzdEOGi8vCdd5t/iOojrsOe2HX8s5dXvc64u5IlU=; b=XitirU17aeKT0udjrvmZmtRlaAaposN/cbjEaCIfDW123cZjhrVxFPNUXQ5Uj2U+1M Jx7y1UhZdB2Edq9btddgkVRUZpojWE/p/Mi3gTOEXefpVVuGCUhcagLYb0q/YAO3L2RZ fwPjcAGvyT7vyCKYuH0GvNAT+u23xgxVUb0Iuv2cwwJBLxskPOZj06sJIeZYHkXgKPjl z2cLM1vkbt8iWg8e3LT/lJ8rRST4BuSJOmh6Vi5cQVzrbO8fidGlHxEWzmbQB0GReZ5r gCGGJcaDaR9Hne0JFYzXB5tHAD5HRdj2wbBK5PaMGK/yCwbzSANzlP3+tvFDdtnp99vK bwYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LUyf8wO7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h63si2969916ywh.427.2017.12.11.05.00.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Dec 2017 05:00:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LUyf8wO7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eONgl-0003aR-Hu for patch@linaro.org; Mon, 11 Dec 2017 08:00:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eONdv-0002JV-VR for qemu-devel@nongnu.org; Mon, 11 Dec 2017 07:57:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eONds-0007XW-Sn for qemu-devel@nongnu.org; Mon, 11 Dec 2017 07:57:12 -0500 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:37728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eONds-0007W3-Kz for qemu-devel@nongnu.org; Mon, 11 Dec 2017 07:57:08 -0500 Received: by mail-wm0-x22f.google.com with SMTP id f140so13911889wmd.2 for ; Mon, 11 Dec 2017 04:57:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FZoUzdEOGi8vCdd5t/iOojrsOe2HX8s5dXvc64u5IlU=; b=LUyf8wO7tWlPfHIf3H4Cnin5+09UkGMRN4M86dplZwR2fxmITdcvjBmfh//aiVGtmu tdBFYyO8maI7BKszkzVwNW9v4BCi+OkmLey4GRsUXI76ptgfbqFHQ5Aro1Lh6CTQb8Pz azaUDdehsPlAMGUQO4xnRkVcDtdTC1VC5CHK8= 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:mime-version :content-transfer-encoding; bh=FZoUzdEOGi8vCdd5t/iOojrsOe2HX8s5dXvc64u5IlU=; b=kY9UZRXGtxRH6IhdSaqNN4brio4rbK0akZMU6LsmGaz6STKpWdOeP3+2hCdqZpYCOK XCyx1Eo0eCoGQZ+uwidemUozz0Exf4dRmzScekT54Ra633L6l8kmWn58AE6pVzXHMoOk XAglShAvkcz2rBjisKMYGzxmG78AwmCh5yT9KPIa8FHtGI7dc/BmKLM+H6357QoZ9abD gc2I6BZM4uC+/UofATy07hgIavKXSeKfAfluITKA3jCiRfbm8v1b45zHVBsXJQWEKUhA iLWAhsogBj6ruHxL3n5JsDXK/dcTOtLH2B+7siPtkhNlO89i3I1ifb1foIJhYTA8Gsjz b+LQ== X-Gm-Message-State: AKGB3mKV4gU9s3WK/mssw7OAYBii0kNg03Ax3TYxOiHumiNCiwq4NmHI N0x7SWGbtBWJ8BvilapLvUAhDA== X-Received: by 10.28.131.73 with SMTP id f70mr744948wmd.153.1512997026958; Mon, 11 Dec 2017 04:57:06 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 19sm9435170wmv.41.2017.12.11.04.57.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 04:57:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 647CE3E03DD; Mon, 11 Dec 2017 12:57:05 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: richard.henderson@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, bharata@linux.vnet.ibm.com, andrew@andrewdutcher.com, aleksandar.markovic@imgtec.com Date: Mon, 11 Dec 2017 12:56:46 +0000 Message-Id: <20171211125705.16120-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22f Subject: [Qemu-devel] [PATCH v1 00/19] re-factor softfloat and add fp16 functions 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: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Hi, In my previous run at this I'd simply taken the existing float32 functions and attempted to copy and paste the code changing the relevant constants. Apart from the usual typos and missed bits there were sections where softfloat pulls tricks because it knows the exact bit positions of things. While I'm sure it's marginally faster it does make the code rather impenetrable to someone not familiar with how SoftFloat does things. One thing the last few months have taught me is the world is not awash with experts on the finer implementation details of floating point maths. After reviewing the last series Richard Henderson suggested a different approach which pushed most of the code into common shared functions. The majority of the work on the fractional bits is done in 64 bit resolution which leaves plenty of spare bits for rounding for everything from float16 to float64. This series is a result of that work and a coding sprint we did 2 weeks ago in Cambridge. We've not touched anything that needs higher precision which at the moment is float80 and 128 bit quad precision operations. They would need similar decomposed routines to operate on the higher precision fractional parts. I suspect we'd need to beef up our Int128 wrapper in the process so it can be done efficiently with 128 bit maths. This work is part of the larger chunk of adding half-precision ops to the ARM front-end. However I've split the series up to make for a less messy review. This tree can be found at: https://github.com/stsquad/qemu/tree/softfloat-refactor-and-fp16-v1 While I have been testing the half-precision stuff in the ARM specific tree this series is all common code. It has however been tested with ARM RISU which exercises the float32/64 code paths quite nicely. Any additional testing appreciated. Series Breakdown ---------------- The first five patches are simple helper functions that are mostly inline and there for the benefit of architecture helper functions. This includes the float16 constants in the final patch. The next two patches fixed a bug in NaN propagation which only showed up when doing ARM "Reduction" operations in float16. Although the minmax code is totally replaced later on I wanted to fix it in place first rather than add the fix when it was re-written. The next two patches start preparing the ground for the new decomposed functions and their public APIs. I've used macro expansion in a few places just to avoid the amount of repeated boiler-plate for these APIs. Most of the work is done in the static decompose_foo functions. As you can see in the diffstat there is an overall code reduction even though we have also added float16 support. For reference the previous attempt added 1258 lines of code to implement a subset of the float16 functions. I think the code is also a lot easier to follow and reason about. Alex Bennée (19): fpu/softfloat: implement float16_squash_input_denormal include/fpu/softfloat: implement float16_abs helper include/fpu/softfloat: implement float16_chs helper include/fpu/softfloat: implement float16_set_sign helper include/fpu/softfloat: add some float16 contants fpu/softfloat: propagate signalling NaNs in MINMAX fpu/softfloat: improve comments on ARM NaN propagation fpu/softfloat: move the extract functions to the top of the file fpu/softfloat: define decompose structures fpu/softfloat: re-factor add/sub fpu/softfloat: re-factor mul fpu/softfloat: re-factor div fpu/softfloat: re-factor muladd fpu/softfloat: re-factor round_to_int fpu/softfloat: re-factor float to int/uint fpu/softfloat: re-factor int/uint to float fpu/softfloat: re-factor scalbn fpu/softfloat: re-factor minmax fpu/softfloat: re-factor compare fpu/softfloat-macros.h | 44 + fpu/softfloat-specialize.h | 115 +- fpu/softfloat.c | 6668 ++++++++++++++++++++------------------------ include/fpu/softfloat.h | 89 +- 4 files changed, 3066 insertions(+), 3850 deletions(-) -- 2.15.1