From patchwork Fri Oct 13 16:24:08 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: 115786 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp920725qgn; Fri, 13 Oct 2017 09:28:21 -0700 (PDT) X-Received: by 10.55.187.133 with SMTP id l127mr2574031qkf.94.1507912101320; Fri, 13 Oct 2017 09:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507912101; cv=none; d=google.com; s=arc-20160816; b=mwZ/AOS+EmASDt4CEDcp0TND/PMLGc3Pjuxda41/46GfhIwjxnZ7LcoF4EMBDdlvoL KdWrCmGQPn1vpFnLY0igGk8sC5u58zcYcwhC/CdP7dMaZB18rNlAvlQWPwTddhw0Xr9j TndZ7Barm+/m3UCCIx5S9u+cY4ZUfxDm0rBoPXQHzu48LleH0DOH1w3HiuKQWBWlPXtc AbcDhctdPnPCGPYDmrt+/ywV2yz6ImTC+ZVK+ewlJxoDSboT+4Frbv7bkVoxFbxvXQn1 B4gl0K3PmndXVWB3xTlsjZQCT+3VUy7OB4K2ynw64v7Tu7GnUuuh4Kx8WYDFeXo9aUO5 hMxQ== 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=WuwKSypULS7JyPghRwpMgIbG+FSYR2ENHT15lbOStU4=; b=N4I77janjTcY5C6OjQZwfEB1BXGTSAioK9u+a5wunf0Ty5HDU5ZZKexKMLAZ2TUv4G 4eVXqSn5Ups+yerBeZyVAIzXBFcuIfAk+POThXJy7kVr6cTo3GHT5TSJJ63ifuFcc6Jl JjeLiscUXBJV+vK1Ees1dkDZh7XwSLF1rUe1jSf1UVEjOitmN/idXWBpNE7AEP1Yny6f G7LkWrEl05rLewUG1Xu34MIXAXHSZlljfZUMnntzabkEzzU9YhJ1HtjebIN0d8vvlwOH DPQy4kL+tpDzXPA/boiXhFkx7pZmmbjuBBMa/7fLlq1HmU+NAiTOOUy9eJplsuJxjkuj ruoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bl27u2vf; 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 l33si1118046qtb.162.2017.10.13.09.28.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Oct 2017 09:28:21 -0700 (PDT) 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=Bl27u2vf; 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]:51035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32os-00054j-Jc for patch@linaro.org; Fri, 13 Oct 2017 12:28:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32lS-0002Pe-MH for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e32lN-0006SL-Ji for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:46 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:52246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e32lN-0006Rn-AG for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:41 -0400 Received: by mail-wr0-x22e.google.com with SMTP id k62so1426220wrc.9 for ; Fri, 13 Oct 2017 09:24:41 -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:mime-version :content-transfer-encoding; bh=WuwKSypULS7JyPghRwpMgIbG+FSYR2ENHT15lbOStU4=; b=Bl27u2vfsA1+y8/7CyJZqgujex4U3YXKKl0WB7tHBdjGeFTojb0aWXfElI6eLhtaEs fy1nZrp0CvLhNX9L0t0AWVIoLUc7qhrGji7Wby+gnhNSw7/h6+hPSvMyLrYN6Ar+eEzM 4u9u8azVsLMYdkARuDLp2wln43w+ZHJ6wtU2Y= 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=WuwKSypULS7JyPghRwpMgIbG+FSYR2ENHT15lbOStU4=; b=k5xmgK8WgHyic+/CTpfEPXIP07riprU5SbjwW3ZIAXrCP2QYP0FFlFX6RQnHZrYEct 3b4WkF7/n8PvwNda+KxNHPPnt5ygL+qO/yCdLmNmFCMrNAh8Pm3dgQa6TIAQ8GGhLzyW RIredwQs7Q6irMT0JoFWxTAzqd7ZXs1nLsa8btxHHqa1JNFPAu2c+qAWFwM7G7orRuqn HDfn34cyQsWpytvBcJ6QomUCq1FlGoK4UebhSNDwq27kOe7ImIC4w7v2ApBnkYsqxfQT og4lEhWJvrXgX6INkX8NUNUfn++VwiAHM6gh0HksiB/S8Pnoa2WceGcLnx+cEltyiIWb ch7A== X-Gm-Message-State: AMCzsaXkTJjDM6CSC1KLMIktU0XYdyt2c7u/8IxSSVZgHZ7vpvPKNB3B Id4XWIuSTfsuykE4GB3LUDsWqw== X-Google-Smtp-Source: AOwi7QB7eBliPJ+ktx3a84LCYJazDdRh0pnOGtDhk1icwA9vQyfdUyf/ta5srHeNo2UTfWu6kFlxFg== X-Received: by 10.223.150.53 with SMTP id b50mr1794799wra.30.1507911880087; Fri, 13 Oct 2017 09:24:40 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m28sm1206874wmi.20.2017.10.13.09.24.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 09:24:38 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 68DE63E05FB; Fri, 13 Oct 2017 17:24:38 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: richard.henderson@linaro.org Date: Fri, 13 Oct 2017 17:24:08 +0100 Message-Id: <20171013162438.32458-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.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:c0c::22e Subject: [Qemu-devel] [RFC PATCH 00/30] v8.2 half-precision support (work-in-progress) 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@linaro.org, qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Hi, This is the current state of ARM v8.2 half precision operations. There are two halves to this effort, expanding our copy of softfloat to include the requisite operations and then plumbing in the appropriate helpers and tcg generation code into the ARM front end. I'm posting this today as I wanted to get feedback before too many assumptions where baked into what is already a large patch series which will likely be giant by the time it is finished. SoftFloat ========= Previously I had pondered if switching to the newer SoftFloat3 would be a worthwhile. While the upstream project is certainly open to accepting patches it would be a slow process given the changes we've made over the years. As a result I've decided to stick with expanding our current code. Most of the helpers have been done fairly mechanically by copying the float32 equivalent, filing off the 32's, replacing with 16's and adjusting the constants appropriately (min/max exp, NaNs etc). I've done this in conjunction with reading the SoftFloat3 code as a sanity check although in places the design is a little different. Some bits of the softfloat code were a bit magical to me so I've added additional comments and re-written the flow to be a bit more obvious. Currently there a whole bunch of checkpatch things to fix, now we "own" this copy of softfloat I'm intending for the new code to follow our own internal coding standards. The tests/test-softfloat is slightly hacked up. I do want to build one for each configured target as softfloat varies depending on the target parameters but I couldn't quite get it to work with: @@ -156,10 +158,11 @@ check-unit-y += tests/ptimer-test$(EXESUF) gcov-files-ptimer-test-y = hw/core/ptimer.c check-unit-y += tests/test-qapi-util$(EXESUF) gcov-files-test-qapi-util-y = qapi/qapi-util.c -check-unit-y += tests/test-softfloat$(EXESUF) -gcov-files-test-softfloat-y = fpu/softfloat.c -check-unit-y += tests/test-softfloat-aarch64$(EXESUF) -gcov-files-test-softfloat-aarch64-y = fpu/softfloat.c + +# We built a softfloat test for each variant of softfloat we have +$(foreach TARGET,$(TARGETS),\ + $(eval check-unit-y += tests/test-softfloat-$(TARGET)$(EXESUF)) \ + $(eval gcov-files-test-softfloat-$(TARGET)-y = fpu/softfloat.c)) check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh @@ -608,8 +611,9 @@ tests/test-qht-par$(EXESUF): tests/test-qht-par.o tests/qht-bench$(EXESUF) $(tes tests/qht-bench$(EXESUF): tests/qht-bench.o $(test-util-obj-y) tests/test-bufferiszero$(EXESUF): tests/test-bufferiszero.o $(test-util-obj-y) tests/atomic_add-bench$(EXESUF): tests/atomic_add-bench.o $(test-util-obj-y) -tests/test-softfloat$(EXESUF): tests/test-softfloat.o $(BUILD_DIR)/aarch64-softmmu/fpu/softfloat.o -tests/test-softfloat-aarch64$(EXESUF): tests/test-softfloat.o $(BUILD_DIR)/aarch64-softmmu/fpu/softfloat.o +# There is a softfloat test target for each system type/softfloat build +$(foreach TARGET,$(TARGETS),\ + $(eval tests/test-softfloat-$(TARGET)$(EXESUF): tests/test-softfloat.o $(BUILD_DIR)/$(TARGET)-softmmu/fpu/softfloat.o)) I think it would be nice to add some softfloat unit tests so any pointers welcome. ARM Vector Code =============== The code follows the existing decompose into chunks and call helpers methodology. I was originally going to base this directly on top of Richard's TCGvec support but realised this would introduce a dependency that might complicate further development. I have ended up copy and pasting a bunch of the loop code, see lines like: for (pass = 0; pass < (is_q ? 8 : 4); pass++) { ... .. stuff per element .. ... } I wonder if more of that could be factored away into a common iterator which could be more easily converted when the vector code is ready. For now following the existing conventions hopefully makes it easier to review. Alex Bennée (30): linux-user/main: support dfilter arm: introduce ARM_V8_FP16 feature bit include/exec/helper-head.h: support f16 in helper calls target/arm/cpu.h: update comment for half-precision values softfloat: implement propagateFloat16NaN fpu/softfloat: implement float16_squash_input_denormal fpu/softfloat: implement float16_abs helper softfloat: add half-precision expansions for MINMAX fns softfloat: propagate signalling NaNs in MINMAX softfloat: improve comments on ARM NaN propagation target/arm: implement half-precision F(MIN|MAX)(V|NMV) target/arm/translate-a64.c: handle_3same_64 comment fix target/arm/translate-a64.c: AdvSIMD scalar 3 Same FP16 initial decode softfloat: 16 bit helpers for shr, clz and rounding and packing softfloat: half-precision add/sub/mul/div support target/arm/translate-a64.c: add FP16 FADD/FMUL/FDIV to AdvSIMD 3 Same (!sub) target/arm/translate-a64.c: add FP16 FMULX target/arm/translate-a64.c: add AdvSIMD scalar two-reg misc skeleton Fix mask for AdvancedSIMD 2 reg misc softfloat: half-precision compare functions target/arm/translate-a64: add FP16 2-reg misc compare (zero) target/arm/translate-a64.c: add FP16 FAGCT to AdvSIMD 3 Same softfloat: add float16_rem and float16_muladd (!CHECK) disas_simd_indexed: support half-precision operations softfloat: float16_round_to_int tests/test-softfloat: add a simple test framework target/arm/translate-a64.c: add FP16 FRINTP to 2 reg misc softfloat: float16_to_int16 conversion tests/test-softfloat: add f16_to_int16 conversion test target/arm/translate-a64.c: add FP16 FCVTPS to 2 reg misc fpu/softfloat-macros.h | 39 ++ fpu/softfloat-specialize.h | 105 ++++- fpu/softfloat.c | 1121 +++++++++++++++++++++++++++++++++++++++++++- include/exec/helper-head.h | 3 + include/fpu/softfloat.h | 37 ++ linux-user/main.c | 7 + target/arm/cpu.h | 2 + target/arm/cpu64.c | 1 + target/arm/helper-a64.c | 122 +++++ target/arm/helper-a64.h | 17 + target/arm/translate-a64.c | 420 ++++++++++++++--- tests/Makefile.include | 8 +- tests/test-softfloat.c | 84 ++++ 13 files changed, 1883 insertions(+), 83 deletions(-) create mode 100644 tests/test-softfloat.c -- 2.14.1