From nobody Sat Sep 21 05:37:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1684440571; cv=none; d=zohomail.com; s=zohoarc; b=MART1/yGOLZNRYIOb8TfuWJKmiYoMaLYM+mdqLab5aNJMCG8xn7YM1uC93UJgKUma7z0P27meT2BkDGO3fTAK9qQd7s6HqhT6oAMPiHvyp9kUpUdorLTeKzZhQqBjY4UleE4XglcGdWW9nduLJLkPcXDprwgW+tme9Wk/RRY3n0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684440571; h=Content-Type: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=6OVuJ69Dn7grqUFcrPYeh58DDKgs1zWH4cIbLOEbN7E=; b=STdd1w4nhaUVMLTXuwiJ9HfC1RMDTKrxzXvqFy4D/3KoRfmdXO7LOcl+fAQaXmsVNFys0l3apIV4YqahEWarDElYSOxcBOUaee3sbbX78hE6JZnL2E4eGtpZY8E/64hmCxjk2agiqeZkP5FCy98O/kPl39T6OGqWl95W/fYOUF0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684440571478583.1753846562156; Thu, 18 May 2023 13:09:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzjrr-0000SD-2x; Thu, 18 May 2023 16:04:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzjrO-0008VR-5H for qemu-devel@nongnu.org; Thu, 18 May 2023 16:04:27 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzjrH-000568-4F for qemu-devel@nongnu.org; Thu, 18 May 2023 16:04:25 -0400 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34IIVvJh030810; Thu, 18 May 2023 20:04:16 GMT Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qn8d2jewn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 20:04:15 +0000 Received: from pps.filterd (NALASPPMTA02.qualcomm.com [127.0.0.1]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 34IK4EDq003753; Thu, 18 May 2023 20:04:14 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 3qnstj08ep-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 20:04:14 +0000 Received: from NALASPPMTA02.qualcomm.com (NALASPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 34IK4EHh003742; Thu, 18 May 2023 20:04:14 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 34IK4E4o003729 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 May 2023 20:04:14 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 5E6736C7; Thu, 18 May 2023 13:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=qcppdkim1; bh=6OVuJ69Dn7grqUFcrPYeh58DDKgs1zWH4cIbLOEbN7E=; b=ZdrjyQJPDkNTCelAsUT0NiMhzT0ieuawe94r02JzHUlJJ5eOpUTns2/6YNuYySVYJTgI bHORz0cesDTvhXa1qib2hm3dEUHohPETih1/voUNLaOyxTdQQ9b7KgGKmTOvvqlPROQf Net0usL5YgqvY1NiGUObZ1IFaj0K6l4r+DCeV7KsrBZodRVWmLb59hhqnOJm3iF0Ckqh Sl2E4/3dl4z6Sq8CTEPMoCYTKbHrtex+9R8vWpOypofXcRyEr7MUSmnJAk/AGW8VYit3 4XXy7XJ16qyHxS8n3c9QVxz4/AOSiht7poOSDrzdqGixkLEKrKVs2SoBWdpqHX20Y5FG YA== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL v2 07/44] Hexagon (tests/tcg/hexagon) Add v69 HVX tests Date: Thu, 18 May 2023 13:03:34 -0700 Message-Id: <20230518200411.271148-8-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518200411.271148-1-tsimpson@quicinc.com> References: <20230518200411.271148-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: m0OV-RBjPK9u5yLGqRJwwgL0dYi9JN_L X-Proofpoint-GUID: m0OV-RBjPK9u5yLGqRJwwgL0dYi9JN_L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_15,2023-05-17_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305180165 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=205.220.180.131; envelope-from=tsimpson@qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1684440573349100005 The following instructions are tested V6_vasrvuhubrndsat V6_vasrvuhubsat V6_vasrvwuhrndsat V6_vasrvwuhsat V6_vassign_tmp V6_vcombine_tmp V6_vmpyuhvs Signed-off-by: Taylor Simpson Reviewed-by: Anton Johansson Message-Id: <20230427224057.3766963-8-tsimpson@quicinc.com> --- tests/tcg/hexagon/v69_hvx.c | 318 ++++++++++++++++++++++++++++++ tests/tcg/hexagon/Makefile.target | 3 + 2 files changed, 321 insertions(+) create mode 100644 tests/tcg/hexagon/v69_hvx.c diff --git a/tests/tcg/hexagon/v69_hvx.c b/tests/tcg/hexagon/v69_hvx.c new file mode 100644 index 0000000000..a0d567d142 --- /dev/null +++ b/tests/tcg/hexagon/v69_hvx.c @@ -0,0 +1,318 @@ +/* + * Copyright(c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include +#include +#include +#include +#include + +int err; + +#include "hvx_misc.h" + +#define fVROUND(VAL, SHAMT) \ + ((VAL) + (((SHAMT) > 0) ? (1LL << ((SHAMT) - 1)) : 0)) + +#define fVSATUB(VAL) \ + ((((VAL) & 0xffLL) =3D=3D (VAL)) ? \ + (VAL) : \ + ((((int32_t)(VAL)) < 0) ? 0 : 0xff)) + +#define fVSATUH(VAL) \ + ((((VAL) & 0xffffLL) =3D=3D (VAL)) ? \ + (VAL) : \ + ((((int32_t)(VAL)) < 0) ? 0 : 0xffff)) + +static void test_vasrvuhubrndsat(void) +{ + void *p0 =3D buffer0; + void *p1 =3D buffer1; + void *pout =3D output; + + memset(expect, 0xaa, sizeof(expect)); + memset(output, 0xbb, sizeof(output)); + + for (int i =3D 0; i < BUFSIZE / 2; i++) { + asm("v4 =3D vmem(%0 + #0)\n\t" + "v5 =3D vmem(%0 + #1)\n\t" + "v6 =3D vmem(%1 + #0)\n\t" + "v5.ub =3D vasr(v5:4.uh, v6.ub):rnd:sat\n\t" + "vmem(%2) =3D v5\n\t" + : : "r"(p0), "r"(p1), "r"(pout) + : "v4", "v5", "v6", "memory"); + p0 +=3D sizeof(MMVector) * 2; + p1 +=3D sizeof(MMVector); + pout +=3D sizeof(MMVector); + + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 2; j++) { + int shamt; + uint8_t byte0; + uint8_t byte1; + + shamt =3D buffer1[i].ub[2 * j + 0] & 0x7; + byte0 =3D fVSATUB(fVROUND(buffer0[2 * i + 0].uh[j], shamt) >> = shamt); + shamt =3D buffer1[i].ub[2 * j + 1] & 0x7; + byte1 =3D fVSATUB(fVROUND(buffer0[2 * i + 1].uh[j], shamt) >> = shamt); + expect[i].uh[j] =3D (byte1 << 8) | (byte0 & 0xff); + } + } + + check_output_h(__LINE__, BUFSIZE / 2); +} + +static void test_vasrvuhubsat(void) +{ + void *p0 =3D buffer0; + void *p1 =3D buffer1; + void *pout =3D output; + + memset(expect, 0xaa, sizeof(expect)); + memset(output, 0xbb, sizeof(output)); + + for (int i =3D 0; i < BUFSIZE / 2; i++) { + asm("v4 =3D vmem(%0 + #0)\n\t" + "v5 =3D vmem(%0 + #1)\n\t" + "v6 =3D vmem(%1 + #0)\n\t" + "v5.ub =3D vasr(v5:4.uh, v6.ub):sat\n\t" + "vmem(%2) =3D v5\n\t" + : : "r"(p0), "r"(p1), "r"(pout) + : "v4", "v5", "v6", "memory"); + p0 +=3D sizeof(MMVector) * 2; + p1 +=3D sizeof(MMVector); + pout +=3D sizeof(MMVector); + + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 2; j++) { + int shamt; + uint8_t byte0; + uint8_t byte1; + + shamt =3D buffer1[i].ub[2 * j + 0] & 0x7; + byte0 =3D fVSATUB(buffer0[2 * i + 0].uh[j] >> shamt); + shamt =3D buffer1[i].ub[2 * j + 1] & 0x7; + byte1 =3D fVSATUB(buffer0[2 * i + 1].uh[j] >> shamt); + expect[i].uh[j] =3D (byte1 << 8) | (byte0 & 0xff); + } + } + + check_output_h(__LINE__, BUFSIZE / 2); +} + +static void test_vasrvwuhrndsat(void) +{ + void *p0 =3D buffer0; + void *p1 =3D buffer1; + void *pout =3D output; + + memset(expect, 0xaa, sizeof(expect)); + memset(output, 0xbb, sizeof(output)); + + for (int i =3D 0; i < BUFSIZE / 2; i++) { + asm("v4 =3D vmem(%0 + #0)\n\t" + "v5 =3D vmem(%0 + #1)\n\t" + "v6 =3D vmem(%1 + #0)\n\t" + "v5.uh =3D vasr(v5:4.w, v6.uh):rnd:sat\n\t" + "vmem(%2) =3D v5\n\t" + : : "r"(p0), "r"(p1), "r"(pout) + : "v4", "v5", "v6", "memory"); + p0 +=3D sizeof(MMVector) * 2; + p1 +=3D sizeof(MMVector); + pout +=3D sizeof(MMVector); + + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 4; j++) { + int shamt; + uint16_t half0; + uint16_t half1; + + shamt =3D buffer1[i].uh[2 * j + 0] & 0xf; + half0 =3D fVSATUH(fVROUND(buffer0[2 * i + 0].w[j], shamt) >> s= hamt); + shamt =3D buffer1[i].uh[2 * j + 1] & 0xf; + half1 =3D fVSATUH(fVROUND(buffer0[2 * i + 1].w[j], shamt) >> s= hamt); + expect[i].w[j] =3D (half1 << 16) | (half0 & 0xffff); + } + } + + check_output_w(__LINE__, BUFSIZE / 2); +} + +static void test_vasrvwuhsat(void) +{ + void *p0 =3D buffer0; + void *p1 =3D buffer1; + void *pout =3D output; + + memset(expect, 0xaa, sizeof(expect)); + memset(output, 0xbb, sizeof(output)); + + for (int i =3D 0; i < BUFSIZE / 2; i++) { + asm("v4 =3D vmem(%0 + #0)\n\t" + "v5 =3D vmem(%0 + #1)\n\t" + "v6 =3D vmem(%1 + #0)\n\t" + "v5.uh =3D vasr(v5:4.w, v6.uh):sat\n\t" + "vmem(%2) =3D v5\n\t" + : : "r"(p0), "r"(p1), "r"(pout) + : "v4", "v5", "v6", "memory"); + p0 +=3D sizeof(MMVector) * 2; + p1 +=3D sizeof(MMVector); + pout +=3D sizeof(MMVector); + + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 4; j++) { + int shamt; + uint16_t half0; + uint16_t half1; + + shamt =3D buffer1[i].uh[2 * j + 0] & 0xf; + half0 =3D fVSATUH(buffer0[2 * i + 0].w[j] >> shamt); + shamt =3D buffer1[i].uh[2 * j + 1] & 0xf; + half1 =3D fVSATUH(buffer0[2 * i + 1].w[j] >> shamt); + expect[i].w[j] =3D (half1 << 16) | (half0 & 0xffff); + } + } + + check_output_w(__LINE__, BUFSIZE / 2); +} + +static void test_vassign_tmp(void) +{ + void *p0 =3D buffer0; + void *pout =3D output; + + memset(expect, 0xaa, sizeof(expect)); + memset(output, 0xbb, sizeof(output)); + + for (int i =3D 0; i < BUFSIZE; i++) { + /* + * Assign into v12 as .tmp, then use it in the next packet + * Should get the new value within the same packet and + * the old value in the next packet + */ + asm("v3 =3D vmem(%0 + #0)\n\t" + "r1 =3D #1\n\t" + "v12 =3D vsplat(r1)\n\t" + "r1 =3D #2\n\t" + "v13 =3D vsplat(r1)\n\t" + "{\n\t" + " v12.tmp =3D v13\n\t" + " v4.w =3D vadd(v12.w, v3.w)\n\t" + "}\n\t" + "v4.w =3D vadd(v4.w, v12.w)\n\t" + "vmem(%1 + #0) =3D v4\n\t" + : : "r"(p0), "r"(pout) + : "r1", "v3", "v4", "v12", "v13", "memory"); + p0 +=3D sizeof(MMVector); + pout +=3D sizeof(MMVector); + + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 4; j++) { + expect[i].w[j] =3D buffer0[i].w[j] + 3; + } + } + + check_output_w(__LINE__, BUFSIZE); +} + +static void test_vcombine_tmp(void) +{ + void *p0 =3D buffer0; + void *p1 =3D buffer1; + void *pout =3D output; + + memset(expect, 0xaa, sizeof(expect)); + memset(output, 0xbb, sizeof(output)); + + for (int i =3D 0; i < BUFSIZE; i++) { + /* + * Combine into v13:12 as .tmp, then use it in the next packet + * Should get the new value within the same packet and + * the old value in the next packet + */ + asm("v3 =3D vmem(%0 + #0)\n\t" + "r1 =3D #1\n\t" + "v12 =3D vsplat(r1)\n\t" + "r1 =3D #2\n\t" + "v13 =3D vsplat(r1)\n\t" + "r1 =3D #3\n\t" + "v14 =3D vsplat(r1)\n\t" + "r1 =3D #4\n\t" + "v15 =3D vsplat(r1)\n\t" + "{\n\t" + " v13:12.tmp =3D vcombine(v15, v14)\n\t" + " v4.w =3D vadd(v12.w, v3.w)\n\t" + " v16 =3D v13\n\t" + "}\n\t" + "v4.w =3D vadd(v4.w, v12.w)\n\t" + "v4.w =3D vadd(v4.w, v13.w)\n\t" + "v4.w =3D vadd(v4.w, v16.w)\n\t" + "vmem(%2 + #0) =3D v4\n\t" + : : "r"(p0), "r"(p1), "r"(pout) + : "r1", "v3", "v4", "v12", "v13", "v14", "v15", "v16", "memory= "); + p0 +=3D sizeof(MMVector); + p1 +=3D sizeof(MMVector); + pout +=3D sizeof(MMVector); + + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 4; j++) { + expect[i].w[j] =3D buffer0[i].w[j] + 10; + } + } + + check_output_w(__LINE__, BUFSIZE); +} + +static void test_vmpyuhvs(void) +{ + void *p0 =3D buffer0; + void *p1 =3D buffer1; + void *pout =3D output; + + memset(expect, 0xaa, sizeof(expect)); + memset(output, 0xbb, sizeof(output)); + + for (int i =3D 0; i < BUFSIZE; i++) { + asm("v4 =3D vmem(%0 + #0)\n\t" + "v5 =3D vmem(%1 + #0)\n\t" + "v4.uh =3D vmpy(V4.uh, v5.uh):>>16\n\t" + "vmem(%2) =3D v4\n\t" + : : "r"(p0), "r"(p1), "r"(pout) + : "v4", "v5", "memory"); + p0 +=3D sizeof(MMVector); + p1 +=3D sizeof(MMVector); + pout +=3D sizeof(MMVector); + + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 2; j++) { + expect[i].uh[j] =3D (buffer0[i].uh[j] * buffer1[i].uh[j]) >> 1= 6; + } + } + + check_output_h(__LINE__, BUFSIZE); +} + +int main() +{ + init_buffers(); + + test_vasrvuhubrndsat(); + test_vasrvuhubsat(); + test_vasrvwuhrndsat(); + test_vasrvwuhsat(); + + test_vassign_tmp(); + test_vcombine_tmp(); + + test_vmpyuhvs(); + + puts(err ? "FAIL" : "PASS"); + return err ? 1 : 0; +} diff --git a/tests/tcg/hexagon/Makefile.target b/tests/tcg/hexagon/Makefile= .target index 2ee930cf1f..558c056148 100644 --- a/tests/tcg/hexagon/Makefile.target +++ b/tests/tcg/hexagon/Makefile.target @@ -78,6 +78,7 @@ HEX_TESTS +=3D test_vspliceb =20 HEX_TESTS +=3D v68_scalar HEX_TESTS +=3D v68_hvx +HEX_TESTS +=3D v69_hvx =20 TESTS +=3D $(HEX_TESTS) =20 @@ -95,6 +96,8 @@ hvx_misc: CFLAGS +=3D -mhvx hvx_histogram: CFLAGS +=3D -mhvx -Wno-gnu-folding-constant v68_hvx: v68_hvx.c hvx_misc.h v6mpy_ref.c.inc v68_hvx: CFLAGS +=3D -mhvx -Wno-unused-function +v69_hvx: v69_hvx.c hvx_misc.h +v69_hvx: CFLAGS +=3D -mhvx -Wno-unused-function =20 hvx_histogram: hvx_histogram.c hvx_histogram_row.S $(CC) $(CFLAGS) $(CROSS_CC_GUEST_CFLAGS) $^ -o $@ $(LDFLAGS) --=20 2.25.1