From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2084B45619; Fri, 12 Jul 2024 19:20:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C51E42F73; Fri, 12 Jul 2024 19:20:15 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id F2EE0402F2 for ; Fri, 12 Jul 2024 19:20:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720804812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=krWK8YSXH4Earl1lyjg4zdIpDgfMZ1XbpExK7HXzpHc=; b=JKQu5ldTr0WBK4zvfOkuD2Dj8xH7x/PyfViOGTMCcY0dWLDRAhPZ2MegOXCKSl3I33gYNd +X3F7TKxuM6zK4VMTlu9XrcF1P4cDKtdoPdlIUr1TbBgXIjMm4tcyXktPgmtoiZ7AW6y2w JcOL53SGFBzkHpUxtn3INhTwxDT6/v8= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-sJBUIy3tMNmKQnxpe3j1zQ-1; Fri, 12 Jul 2024 13:20:11 -0400 X-MC-Unique: sJBUIy3tMNmKQnxpe3j1zQ-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ee90290a7aso28647421fa.3 for ; Fri, 12 Jul 2024 10:20:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720804809; x=1721409609; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=krWK8YSXH4Earl1lyjg4zdIpDgfMZ1XbpExK7HXzpHc=; b=idF3bkLcq5zwTE+fvDdDU2qfY2sDmvlkwKlzBVEqA6QnXGn06fWscc0VM5gU8kJbtt kes6YAnM/6/VokxQTbErGKyMBw2xw2eVFUA5aC09ix6a2w9GhTKF/9WHavvbm3ovJ4zu DE2ENYrTAPCwqiefTY//SOEfOAq0fDvdb0UdY0lpvDGapQE5t4iW5/YjaLrQj3LEDDI+ kGQzJk0dG19lav2Mqs1VooFlq4DjPb6XeMGS4LItUA1AP++t6mr2QLjuSwTuhWQrK/ux rcFyIUqhlQBFpbt2XmY9lGY2pgGvpT1nTPyt+lleSl7OSEluS8EsFUMKbP5VTGggXfC2 U5xQ== X-Forwarded-Encrypted: i=1; AJvYcCVX8X6o8AGSmoLsNYP2Yhw9bSeHkLH6RixyyVMLKpQae8KFPGeWQvZiLZTGsW40zuzTkdDfx7ph/r1toyU= X-Gm-Message-State: AOJu0YzyoH/n0u/lMbO3KX2VwpJdk6AKp7tj8tuTnsp/Au86QJfaWmJQ BSE2x9zQH7ZctzR376Mk0yHVJbp89bp7xR2UTfMyWlgaSW9CJzEyXU5CMncVMCy3E31XJQ9jzk+ a8fBZEPcqXf+1oUQAKzERVe4jNWqxn26IYP90/W8lV9lHYy3tT7fVzPU5CH651PZnN27nhc5qKD u8xzMnb1fYFMMfPSo= X-Received: by 2002:a2e:9b0f:0:b0:2ee:8dce:2f92 with SMTP id 38308e7fff4ca-2eeb30ba7acmr98314021fa.1.1720804809730; Fri, 12 Jul 2024 10:20:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIJncf/7x/dZVN1euULqIjf7bnEH1oRD6BYJY8Q8nZ3hCP3qHalAWmSGtNtn32hQCRi+eLh0ksPY2Af2wkzeU= X-Received: by 2002:a2e:9b0f:0:b0:2ee:8dce:2f92 with SMTP id 38308e7fff4ca-2eeb30ba7acmr98313901fa.1.1720804809330; Fri, 12 Jul 2024 10:20:09 -0700 (PDT) MIME-Version: 1.0 References: <20240618174133.33457-1-daniel.gregory@bytedance.com> <20240712154645.80622-1-daniel.gregory@bytedance.com> In-Reply-To: <20240712154645.80622-1-daniel.gregory@bytedance.com> From: David Marchand Date: Fri, 12 Jul 2024 19:19:57 +0200 Message-ID: Subject: Re: [PATCH v2 0/9] riscv: implement accelerated crc using zbc To: Daniel Gregory Cc: Stanislaw Kardach , dev@dpdk.org, Punit Agrawal , Liang Ma , Pengcheng Wang , Chunsong Feng , Stephen Hemminger , Sachin Saxena X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, Jul 12, 2024 at 5:47=E2=80=AFPM Daniel Gregory wrote: > > The RISC-V Zbc extension adds instructions for carry-less multiplication > we can use to implement CRC in hardware. This patch set contains two new > implementations: > > - one in lib/hash/rte_crc_riscv64.h that uses a Barrett reduction to > implement the four rte_hash_crc_* functions > - one in lib/net/net_crc_zbc.c that uses repeated single-folds to reduce > the buffer until it is small enough for a Barrett reduction to > implement rte_crc16_ccitt_zbc_handler and rte_crc32_eth_zbc_handler > > My approach is largely based on the Intel's "Fast CRC Computation Using > PCLMULQDQ Instruction" white paper > https://www.researchgate.net/publication/263424619_Fast_CRC_computation > and a post about "Optimizing CRC32 for small payload sizes on x86" > https://mary.rs/lab/crc32/ > > Whether these new implementations are enabled is controlled by new > build-time and run-time detection of the RISC-V extensions present in > the compiler and on the target system. > > I have carried out some performance comparisons between the generic > table implementations and the new hardware implementations. Listed below > is the number of cycles it takes to compute the CRC hash for buffers of > various sizes (as reported by rte_get_timer_cycles()). These results > were collected on a Kendryte K230 and averaged over 20 samples: > > |Buffer | CRC32-ETH (lib/net) | CRC32C (lib/hash) | > |Size (MB) | Table | Hardware | Table | Hardware | > |----------|----------|----------|----------|----------| > | 1 | 155168 | 11610 | 73026 | 18385 | > | 2 | 311203 | 22998 | 145586 | 35886 | > | 3 | 466744 | 34370 | 218536 | 53939 | > | 4 | 621843 | 45536 | 291574 | 71944 | > | 5 | 777908 | 56989 | 364152 | 89706 | > | 6 | 932736 | 68023 | 437016 | 107726 | > | 7 | 1088756 | 79236 | 510197 | 125426 | > | 8 | 1243794 | 90467 | 583231 | 143614 | > > These results suggest a speed-up of lib/net by thirteen times, and of > lib/hash by four times. > > I have also run the hash_functions_autotest benchmark in dpdk_test, > which measures the performance of the lib/hash implementation on small > buffers, getting the following times: > > | Key Length | Time (ticks/op) | > | (bytes) | Table | Hardware | > |------------|----------|----------| > | 1 | 0.47 | 0.85 | > | 2 | 0.57 | 0.87 | > | 4 | 0.99 | 0.88 | > | 8 | 1.35 | 0.88 | > | 9 | 1.20 | 1.09 | > | 13 | 1.76 | 1.35 | > | 16 | 1.87 | 1.02 | > | 32 | 2.96 | 0.98 | > | 37 | 3.35 | 1.45 | > | 40 | 3.49 | 1.12 | > | 48 | 4.02 | 1.25 | > | 64 | 5.08 | 1.54 | Thanks for the submission. This series comes late for v24.07 and there was no review, it is deferred to v24.11. Cc: Sachin for info. --=20 David Marchand