From: Stephen Hemminger <stephen@networkplumber.org>
To: P1erreCashon <2022302111412@whu.edu.cn>
Cc: Stanislaw Kardach <stanislaw.kardach@gmail.com>,
Bruce Richardson <bruce.richardson@intel.com>,
Yipeng Wang <yipeng1.wang@intel.com>,
Sameh Gobriel <sameh.gobriel@intel.com>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
dev@dpdk.org, gong-flying <gongxiaofei24@iscas.ac.cn>
Subject: Re: [PATCH] hash: add riscv vector support for 16-byte key comparison
Date: Thu, 26 Feb 2026 10:44:33 -0800 [thread overview]
Message-ID: <20260226104433.0c2dcbc2@phoenix.local> (raw)
In-Reply-To: <20260226064939.2362323-1-2022302111412@whu.edu.cn>
On Thu, 26 Feb 2026 14:49:38 +0800
P1erreCashon <2022302111412@whu.edu.cn> wrote:
> +/* Functions to compare multiple of 16 byte keys (up to 128 bytes) */
> +static inline int
> +rte_hash_k16_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused)
> +{
> + const uint8_t *p1 = (const uint8_t *)key1;
> + const uint8_t *p2 = (const uint8_t *)key2;
> + size_t offset = 0;
> +
> + while (offset < 16) {
> + size_t vl = __riscv_vsetvl_e8m1(16 - offset);
> +
> + vuint8m1_t v1 = __riscv_vle8_v_u8m1(p1 + offset, vl);
> + vuint8m1_t v2 = __riscv_vle8_v_u8m1(p2 + offset, vl);
> +
> + /* find != bytes */
> + vbool8_t neq = __riscv_vmsne_vv_u8m1_b8(v1, v2, vl);
> +
> + /* if any byte mismatches, return not equal */
> + if (__riscv_vfirst_m_b8(neq, vl) >= 0)
> + return 1;
> +
> + offset += vl;
> + }
> +
> + /* all bytes equal */
> + return 0;
> +}
> +
Compiling this with godbolt generates much bigger code than simple 64 bit version.
Is it really faster?
int
rte_hash_k16_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused)
{
const unaligned_uint64_t *k1 = key1;
const unaligned_uint64_t *k2 = key2;
return !!((k1[0] ^ k2[0]) | (k1[1] ^ k2[1]));
}
rte_hash_k16_cmp_eq:
ld a4,8(a0)
ld a5,0(a0)
ld a2,0(a1)
ld a3,8(a1)
xor a0,a5,a2
xor a4,a4,a3
or a0,a0,a4
snez a0,a0
ret
ricsv_hash_k16_cmp_eq:
li a4,0
li a6,16
li a7,15
.L5:
sub a5,a6,a4
vsetvli a5,a5,e8,m1,ta,ma
add a2,a0,a4
add a3,a1,a4
vle8.v v1,0(a2)
vle8.v v2,0(a3)
add a4,a4,a5
vmsne.vv v1,v1,v2
vfirst.m a5,v1
bge a5,zero,.L6
bleu a4,a7,.L5
li a0,0
ret
.L6:
li a0,1
ret
next prev parent reply other threads:[~2026-02-26 18:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 6:49 [PATCH] hash: add riscv vector support for 16-byte key comparison P1erreCashon
2026-02-26 18:31 ` Stephen Hemminger
2026-02-26 18:32 ` Stephen Hemminger
2026-02-26 18:44 ` Stephen Hemminger [this message]
2026-03-10 6:14 ` sunyuechi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260226104433.0c2dcbc2@phoenix.local \
--to=stephen@networkplumber.org \
--cc=2022302111412@whu.edu.cn \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=gongxiaofei24@iscas.ac.cn \
--cc=sameh.gobriel@intel.com \
--cc=stanislaw.kardach@gmail.com \
--cc=vladimir.medvedkin@intel.com \
--cc=yipeng1.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.