From patchwork Sat Nov 18 03:21:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: flow gg X-Patchwork-Id: 44708 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6a89:b0:181:818d:5e7f with SMTP id bi9csp319184pzb; Fri, 17 Nov 2023 19:21:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDjv58u1BnyagpM0VjWonvXo5VDj7DmVNeE/0DxpYKszJfP8EbFfsuT5J7H3vfNWcp8zOW X-Received: by 2002:a17:907:77d3:b0:9ad:c763:bc7a with SMTP id kz19-20020a17090777d300b009adc763bc7amr888757ejc.23.1700277687029; Fri, 17 Nov 2023 19:21:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700277687; cv=none; d=google.com; s=arc-20160816; b=DrPqOgAn0U92mfSE5EpCDtmbMytljfoM/Zt9VxlHli4PqpilH3td9xYneH1OazMOnW BWNr3EXngFHdB0kiW5MNZ+s+vPXGS8REITi+dWqvoohihLbvQf2bsMcrTntdOOlciwye vtUvO8m79BN5UfcV4GxTnJVzOdeAjEf0OIE58Kny5t1WqN0fX5tnId3uNXu9y3Q+qvly R0q0ir0tetbRVINvD8hd4/DOSKj2fiasELYrb1NVMs51BgoSCXJ+9mjJ4F0j1IOZX3St KZ9SKHIZDrKetzeNvHgPftU4obqefDmW5EcBL7BBROrceOewmAyN5lSk4euJLBahR73O 8GSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=4LGAweHKEIEq3g0gJnCn8hmVURmybu/vyrGwjKSEpFI=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=rRRPV/OsSZhvTmbYgwjR7GlQuiBDcHGzhwCCh8JnIplZXk849fzOGDM4Qy+k8S3okE JSFSu9g4SD5LlwL3sIZU8nTpJbggal1rbh1JotxCZX++mnI7ZiNlRGKeiJdwVw4SBRjr 2IApGFKGOj4yAF3q8FjwAgEard8Q0Rdq6TxKRuo5fssnnKCKB0wYugqtnqrOg4cSiFjp u4Obwp+jPMmj1UO/9FLtxHZIWv9eijTStgfop5Ny0YsYk6kRS+yqyShGiYE+LtKy9UPU pr8+u+Q7HdJcGVcp3GO3POjRRIiafscs8ro3DnDniv9qgk0a8Z7rBFhEYQOd9NqtPZZl BGIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Yub2k0cm; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a15-20020a170906274f00b009fad323ed77si190475ejd.544.2023.11.17.19.21.25; Fri, 17 Nov 2023 19:21:27 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=Yub2k0cm; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7772468CD16; Sat, 18 Nov 2023 05:21:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D2E768CC35 for ; Sat, 18 Nov 2023 05:21:15 +0200 (EET) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-66d190a8f87so883196d6.0 for ; Fri, 17 Nov 2023 19:21:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700277674; x=1700882474; darn=ffmpeg.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=vLuJ6137Y3UZ4SmM0DFyPK8IvPP5254aOTcum/ySPrI=; b=Yub2k0cmO7b3EEXaXydV6UUB2oETVL55+TuaSQFZ+2xVlFdfP3WWtv8sNyNy0dfcJS GpfsqyJIOmmSiaamkEMY5xPfrUFv4XEn/nU9EsZHMb6ONKDNNBKZIjjdVibNCEIEphy6 iBPqg1G/sDYqDfPPuq+o6ycWaj15xZHV8G3zGdvyk8LJaNLQ3A9rdTiWxikzZnUQWCm5 HS2rt9+j0gfHvUxg1oaHMYqx6yLvFsk6f0BX0qvObC9/rYSr3FnwhNVMMgtU7vkbT8F7 N9TLCxXoLbRfIq8CwIlxOCeaVAREolYt8xfxZxVvz4bSt2KjpdGneSqHlxqvT0TAEq8A 7DFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700277674; x=1700882474; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vLuJ6137Y3UZ4SmM0DFyPK8IvPP5254aOTcum/ySPrI=; b=d64w3Z3y7MIHcBe3gle1DnBgOWi7BqxJia3T2fc8e3RhmPAOEDAnT5u5i38HveoybV tAZ3Ow0kpPovw6Scv/atqWuFLnWt4R3SbGjDf5f7H1Q96EjkHO64M86XUos8nOUoOZy+ LXfoWq69cIjUPNqrqIrvwkHadLX1+TkwpoBqopwP12mNf6JHPeAjUme7OeuXWE+zfbOL BEbJdRXmDgrlfxwJ3NWA/xENvmXZfdc63BYpvjEVp4jIEN7WQyvaAmgFEmfUrLiToK4I XIEJi6oyZdF+8KG0OEDlepLnvOCTYucKhGMBz8sUGvi7qbKrTKnimAjOUEpUbBZhGa2K r/+g== X-Gm-Message-State: AOJu0YxbzmXOo4lO/qOMeGF1oMONlrj/CLG98q4jSrSHKOGhxj/U3DhY 2F97AZ5t/OCJwshJL4OGgNp1SVSduLsO1Hl21Jtwr62yf6U= X-Received: by 2002:a05:6214:19cb:b0:671:3493:61e8 with SMTP id j11-20020a05621419cb00b00671349361e8mr1446524qvc.26.1700277673695; Fri, 17 Nov 2023 19:21:13 -0800 (PST) MIME-Version: 1.0 From: flow gg Date: Sat, 18 Nov 2023 11:21:02 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH] checkasm: add test for dcmul_add X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BjLsAQnzNp8q From 2785ce57f68dbb2373c951b9432afa73796f7cc1 Mon Sep 17 00:00:00 2001 From: sunyuechi Date: Sat, 18 Nov 2023 10:58:17 +0800 Subject: [PATCH] checkasm: test for dcmul_add --- tests/checkasm/af_afir.c | 141 +++++++++++++++++++++++++++------------ 1 file changed, 98 insertions(+), 43 deletions(-) diff --git a/tests/checkasm/af_afir.c b/tests/checkasm/af_afir.c index 08c55dacfc..6cb59dbb6c 100644 --- a/tests/checkasm/af_afir.c +++ b/tests/checkasm/af_afir.c @@ -33,64 +33,119 @@ do { \ int i; \ double bmg[2], stddev = 10.0, mean = 0.0; \ \ - for (i = 0; i < LEN*2+8; i += 2) { \ + for (i = 0; i < BUF_SIZE; i += 2) { \ av_bmg_get(&checkasm_lfg, bmg); \ buf[i] = bmg[0] * stddev + mean; \ buf[i + 1] = bmg[1] * stddev + mean; \ } \ } while(0); -static void test_fcmul_add(const float *src0, const float *src1, const float *src2) +static void test_fcmul_add(AudioFIRDSPContext *fir) { - LOCAL_ALIGNED_32(float, cdst, [LEN*2+8]); - LOCAL_ALIGNED_32(float, odst, [LEN*2+8]); - int i; - - declare_func(void, float *sum, const float *t, const float *c, - ptrdiff_t len); - - memcpy(cdst, src0, (LEN*2+8) * sizeof(float)); - memcpy(odst, src0, (LEN*2+8) * sizeof(float)); - call_ref(cdst, src1, src2, LEN); - call_new(odst, src1, src2, LEN); - for (i = 0; i <= LEN*2; i++) { - int idx = i & ~1; - float cre = src2[idx]; - float cim = src2[idx + 1]; - float tre = src1[idx]; - float tim = src1[idx + 1]; - double t = fabs(src0[i]) + - fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) + - fabs(tre * cre) + fabs(tim * cim) + - fabs(tre * cim) + fabs(tim * cre) + - fabs(tre * cre - tim * cim) + - fabs(tre * cim + tim * cre) + - fabs(cdst[i]) + 1.0; - if (!float_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) { - fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", - i, cdst[i], odst[i], cdst[i] - odst[i]); - fail(); - break; +#define BUF_SIZE LEN*2+8 + LOCAL_ALIGNED_32(float, src0, [BUF_SIZE]); + LOCAL_ALIGNED_32(float, src1, [BUF_SIZE]); + LOCAL_ALIGNED_32(float, src2, [BUF_SIZE]); + + randomize_buffer(src0); + randomize_buffer(src1); + randomize_buffer(src2); + + if (check_func(fir->fcmul_add, "fcmul_add")) { + LOCAL_ALIGNED_32(float, cdst, [BUF_SIZE]); + LOCAL_ALIGNED_32(float, odst, [BUF_SIZE]); + int i; + + declare_func(void, float *sum, const float *t, const float *c, + ptrdiff_t len); + + memcpy(cdst, src0, (BUF_SIZE) * sizeof(float)); + memcpy(odst, src0, (BUF_SIZE) * sizeof(float)); + call_ref(cdst, src1, src2, LEN); + call_new(odst, src1, src2, LEN); + for (i = 0; i <= LEN*2; i++) { + int idx = i & ~1; + float cre = src2[idx]; + float cim = src2[idx + 1]; + float tre = src1[idx]; + float tim = src1[idx + 1]; + double t = fabs(src0[i]) + + fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) + + fabs(tre * cre) + fabs(tim * cim) + + fabs(tre * cim) + fabs(tim * cre) + + fabs(tre * cre - tim * cim) + + fabs(tre * cim + tim * cre) + + fabs(cdst[i]) + 1.0; + if (!float_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) { + fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", + i, cdst[i], odst[i], cdst[i] - odst[i]); + fail(); + break; + } } + memcpy(odst, src0, (BUF_SIZE) * sizeof(float)); + bench_new(odst, src1, src2, LEN); } - memcpy(odst, src0, (LEN*2+8) * sizeof(float)); - bench_new(odst, src1, src2, LEN); + + report("fcmul_add"); } -void checkasm_check_afir(void) +static void test_dcmul_add(AudioFIRDSPContext *fir) { - LOCAL_ALIGNED_32(float, src0, [LEN*2+8]); - LOCAL_ALIGNED_32(float, src1, [LEN*2+8]); - LOCAL_ALIGNED_32(float, src2, [LEN*2+8]); - AudioFIRDSPContext fir = { 0 }; - - ff_afir_init(&fir); +#define BUF_SIZE LEN*2+8 + LOCAL_ALIGNED_32(double, src0, [BUF_SIZE]); + LOCAL_ALIGNED_32(double, src1, [BUF_SIZE]); + LOCAL_ALIGNED_32(double, src2, [BUF_SIZE]); randomize_buffer(src0); randomize_buffer(src1); randomize_buffer(src2); - if (check_func(fir.fcmul_add, "fcmul_add")) - test_fcmul_add(src0, src1, src2); - report("fcmul_add"); + if (check_func(fir->dcmul_add, "dcmul_add")) { + LOCAL_ALIGNED_32(double, cdst, [BUF_SIZE]); + LOCAL_ALIGNED_32(double, odst, [BUF_SIZE]); + int i; + + declare_func(void, double *sum, const double *t, const double *c, + ptrdiff_t len); + + memcpy(cdst, src0, (BUF_SIZE) * sizeof(double)); + memcpy(odst, src0, (BUF_SIZE) * sizeof(double)); + call_ref(cdst, src1, src2, LEN); + call_new(odst, src1, src2, LEN); + for (i = 0; i <= LEN*2; i++) { + int idx = i & ~1; + double cre = src2[idx]; + double cim = src2[idx + 1]; + double tre = src1[idx]; + double tim = src1[idx + 1]; + double t = fabs(src0[i]) + + fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) + + fabs(tre * cre) + fabs(tim * cim) + + fabs(tre * cim) + fabs(tim * cre) + + fabs(tre * cre - tim * cim) + + fabs(tre * cim + tim * cre) + + fabs(cdst[i]) + 1.0; + if (!double_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) { + fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", + i, cdst[i], odst[i], cdst[i] - odst[i]); + fail(); + break; + } + } + memcpy(odst, src0, (BUF_SIZE) * sizeof(double)); + bench_new(odst, src1, src2, LEN); + } + + report("dcmul_add"); +} + + +void checkasm_check_afir(void) +{ + AudioFIRDSPContext fir = { 0 }; + + ff_afir_init(&fir); + test_fcmul_add(&fir); + test_dcmul_add(&fir); } -- 2.42.1