From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Bruce Richardson" <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>, "Zhihong Wang" <wangzhihong.wzh@bytedance.com>
Subject: x86 rte_memcpy_aligned possible optimization
Date: Mon, 27 Mar 2023 13:45:17 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D8780D@smartserver.smartshare.dk> (raw)
Hi Bruce,
I think one of the loops in rte_memcpy_aligned() takes one too many rounds in the case where the catch-up could replace the last round.
Consider e.g. n = 128:
The 64 bytes block copy will take two rounds, and the catch-up will copy the last 64 bytes once again.
I think that the 64 bytes block copy could take only one round and let the catch-up copy the last 64 bytes.
I'm not sure if my suggested method is generally faster than the current method, so I'm passing the ball.
PS: It looks like something similar can be done for the other block copy loops in this file. I haven't dug into the details.
static __rte_always_inline void *
rte_memcpy_aligned(void *dst, const void *src, size_t n)
{
void *ret = dst;
/* Copy size < 16 bytes */
if (n < 16) {
return rte_mov15_or_less(dst, src, n);
}
/* Copy 16 <= size <= 32 bytes */
if (n <= 32) {
rte_mov16((uint8_t *)dst, (const uint8_t *)src);
rte_mov16((uint8_t *)dst - 16 + n,
(const uint8_t *)src - 16 + n);
return ret;
}
/* Copy 32 < size <= 64 bytes */
if (n <= 64) {
rte_mov32((uint8_t *)dst, (const uint8_t *)src);
rte_mov32((uint8_t *)dst - 32 + n,
(const uint8_t *)src - 32 + n);
return ret;
}
/* Copy 64 bytes blocks */
- for (; n >= 64; n -= 64) {
+ for (; n > 64; n -= 64) {
rte_mov64((uint8_t *)dst, (const uint8_t *)src);
dst = (uint8_t *)dst + 64;
src = (const uint8_t *)src + 64;
}
/* Copy whatever left */
rte_mov64((uint8_t *)dst - 64 + n,
(const uint8_t *)src - 64 + n);
return ret;
}
Med venlig hilsen / Kind regards,
-Morten Brørup
reply other threads:[~2023-03-27 11:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=98CBD80474FA8B44BF855DF32C47DC35D8780D@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=wangzhihong.wzh@bytedance.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).