CNDP  22.08.0
cne_prefetch.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2019-2022 Intel Corporation
3  */
4 
5 #ifndef _CNE_PREFETCH_H_
6 #define _CNE_PREFETCH_H_
7 
14 #include <cne_common.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
26 static inline void
27 cne_prefetch0(const volatile void *p)
28 {
29  asm volatile("prefetcht0 %[p]" : : [p] "m"(*(const volatile char *)p));
30 }
31 
38 static inline void
39 cne_prefetch1(const volatile void *p)
40 {
41  asm volatile("prefetcht1 %[p]" : : [p] "m"(*(const volatile char *)p));
42 }
43 
50 static inline void
51 cne_prefetch2(const volatile void *p)
52 {
53  asm volatile("prefetcht2 %[p]" : : [p] "m"(*(const volatile char *)p));
54 }
55 
63 static inline void
64 cne_prefetch_non_temporal(const volatile void *p)
65 {
66  asm volatile("prefetchnta %[p]" : : [p] "m"(*(const volatile char *)p));
67 }
68 
76 static inline void
77 cne_prefetch0_write(const void *p)
78 {
79  /* 1 indicates intention to write, 3 sets target cache level to L1. See
80  * GCC docs where these integer constants are described in more detail:
81  * https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
82  */
83  __builtin_prefetch(p, 1, 3);
84 }
85 
93 static inline void
94 cne_prefetch1_write(const void *p)
95 {
96  /* 1 indicates intention to write, 2 sets target cache level to L2. See
97  * GCC docs where these integer constants are described in more detail:
98  * https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
99  */
100  __builtin_prefetch(p, 1, 2);
101 }
102 
110 static inline void
111 cne_prefetch2_write(const void *p)
112 {
113  /* 1 indicates intention to write, 1 sets target cache level to L3. See
114  * GCC docs where these integer constants are described in more detail:
115  * https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
116  */
117  __builtin_prefetch(p, 1, 1);
118 }
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif /* _CNE_PREFETCH_H_ */
static void cne_prefetch2(const volatile void *p)
Definition: cne_prefetch.h:51
static void cne_prefetch1_write(const void *p)
Definition: cne_prefetch.h:94
static void cne_prefetch2_write(const void *p)
Definition: cne_prefetch.h:111
static void cne_prefetch_non_temporal(const volatile void *p)
Definition: cne_prefetch.h:64
static void cne_prefetch0(const volatile void *p)
Definition: cne_prefetch.h:27
static void cne_prefetch0_write(const void *p)
Definition: cne_prefetch.h:77
static void cne_prefetch1(const volatile void *p)
Definition: cne_prefetch.h:39