aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vppinfra/cache.h24
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