[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

Don Provan dprovan at bivio.net
Tue May 12 00:29:04 CEST 2015


I probably shouldn't stick my nose into this, but I can't help myself.

An experienced programmer will tend to ignore the documentation for
a routine named "blahblah_memcmp" and just assume it functions like
memcmp. Whether or not there's currently a use case in DPDK is
completely irrelevant because as soon as there *is* a use case, some
poor DPDK developer will try to use rte_memcmp for that and may or
may not have a test case that reveals their mistake.

The term "compare" suggests checking for larger or smaller.
If you want to check for equality, use "equal" or "eq" in the name
and return true if they're equal. But personally, I'd compare unless
there was a good reason not to. Indeed, I would just implement
full memcmp functionality and be done with it, even if that meant
using my fancy new assembly code for the cases I handle and then
calling memcmp itself for the cases I didn't.

If a routine that appears to take an arbitrary size doesn't, the name
should in some manner reflect what sizes it takes. Better would be
for a routine that only handles specific sizes to be split into versions
that only take fixed sizes, but I don't know enough about your use
cases to say whether that makes sense here.

-don provan
dprovan at bivio.net

-----Original Message-----
From: Ravi Kerur [mailto:rkerur at gmail.com] 
Sent: Monday, May 11, 2015 1:47 PM
To: Ananyev, Konstantin
Cc: dev at dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

...
Following memcmp semantics is not hard but there are no use-cases for it in DPDK currently. Keeping it specific to DPDK usage simplifies code as well.
I can change the name to "rte_compare" and add comments to the function.
Will it work?
...



More information about the dev mailing list