DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
To: <dev@dpdk.org>
Cc: "Mattias Rönnblom" <hofors@lysator.liu.se>,
	"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: [RFC 0/1] replace inline assembly prefetch with cc builtins
Date: Sun, 23 Feb 2025 13:52:14 +0100	[thread overview]
Message-ID: <20250223125215.358925-1-mattias.ronnblom@ericsson.com> (raw)

This is an unorthodox RFC in that I think it probably shouldn't be
accepted.

I thought I'd try replacing the x86 inline assembly for DPDK software
prefetch with GCC __builtin_prefetch().

Being essentially a black box for the compiler, inline assembly
hinders certain optimizations. The hope was beyond DPDK source code
simplification there would also be a performance upside.

I evaluate this change in an eventdev-based application with a
multi-stage pipeline, which heavily relies on software prefetching to
mitigate the cost of core-to-core transitions. After I replaced the
lib/eal/x86/include/rte_prefetch.h inline assembly with calls to GCC
built-ins, the reference application saw a ~50 cc/stage slowdown on
GCC 13.3.0 and GCC 14.2.0.

So unfortunately GCC uses its newfound freedom to make the code
slower. I'm guessing it reorders the prefetches to happen at a
too-late time.

On clang 17.0.6 and clang 18.1.3, the application-level performance
remains the same after the change.

I've tested only a single application, so it would be of great value
of we could get some more experience (preferably from real-world
apps).

rte_prefetch*_write() is using GCC built-ins, so I tried moving that
to inline assembly. Initially a saw a 10 cc/stage gain from this move
(on GCC), but after reorganizing the prefetch logic, that gain was
gone. I have a patch for that change as well, if anyone is
interested. (It's a little more complicated that you might think,
since you need to detect if prefetchw is available in the target ISA.)

Mattias Rönnblom (1):
  eal/x86: replace inline assembly prefetch with cc builtins

 lib/eal/x86/include/rte_prefetch.h | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

-- 
2.43.0


             reply	other threads:[~2025-02-23 13:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-23 12:52 Mattias Rönnblom [this message]
2025-02-23 12:52 ` [RFC 1/1] eal/x86: " Mattias Rönnblom

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=20250223125215.358925-1-mattias.ronnblom@ericsson.com \
    --to=mattias.ronnblom@ericsson.com \
    --cc=dev@dpdk.org \
    --cc=hofors@lysator.liu.se \
    /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).