diff options
author | Niyaz Murshed <niyaz.murshed@arm.com> | 2024-06-24 20:38:11 +0000 |
---|---|---|
committer | Fan Zhang <fanzhang.oss@gmail.com> | 2024-07-17 14:59:26 +0000 |
commit | 1d3faf0c578e27acb0bb39605365f9d6fbb7365b (patch) | |
tree | 43c405efdc832901da7a235dcfa596f0495ad540 /src | |
parent | 99213e0836aad04a1717e26e87d3830fe71e7f9f (diff) |
vppinfra: Add macro for targeted prefetching
In Arm platform, targeted prefetching[1] is supported. Adding this in infra
to use it in future optimisation.
[1] https://developer.arm.com/documentation/101458/2404/Optimize/Prefetching-with---builtin-prefetch
Type: improvement
Change-Id: Id3e2a274628289707840a6b2ba4b83c5e4add60b
Signed-off-by: Niyaz Murshed <niyaz.murshed@arm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vppinfra/cache.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vppinfra/cache.h b/src/vppinfra/cache.h index 4229a068486..13778a423fd 100644 --- a/src/vppinfra/cache.h +++ b/src/vppinfra/cache.h @@ -68,6 +68,17 @@ #define CLIB_PREFETCH_WRITE 1 #define CLIB_PREFETCH_STORE 1 /* alias for write */ +/* locality arguments to __builtin_prefetch. */ +#define CLIB_PREFETCH_TO_STREAM 0 // NTA +#define CLIB_PREFETCH_TO_L3 1 // T2 +#define CLIB_PREFETCH_TO_L2 2 // T1 +#define CLIB_PREFETCH_TO_L1 3 // T0 + +#define _CLIB_TARGETED_PREFETCH(n, size, type, loc) \ + if ((size) > (n) *CLIB_CACHE_PREFETCH_BYTES) \ + __builtin_prefetch (_addr + (n) *CLIB_CACHE_PREFETCH_BYTES, \ + CLIB_PREFETCH_##type, CLIB_PREFETCH_TO_##loc); + #define _CLIB_PREFETCH(n, size, type) \ if ((size) > (n) *CLIB_CACHE_PREFETCH_BYTES) \ __builtin_prefetch (_addr + (n) *CLIB_CACHE_PREFETCH_BYTES, \ @@ -86,6 +97,19 @@ } \ while (0) +#define CLIB_TARGETED_PREFETCH(addr, size, type, locality) \ + do \ + { \ + void *_addr = (addr); \ + \ + ASSERT ((size) <= 4 * CLIB_CACHE_PREFETCH_BYTES); \ + _CLIB_TARGETED_PREFETCH (0, size, type, locality); \ + _CLIB_TARGETED_PREFETCH (1, size, type, locality); \ + _CLIB_TARGETED_PREFETCH (2, size, type, locality); \ + _CLIB_TARGETED_PREFETCH (3, size, type, locality); \ + } \ + while (0) + #undef _ static_always_inline void |