29#include <seastar/core/align.hh>
30#include <seastar/core/cacheline.hh>
31#include <seastar/util/modules.hh>
36SEASTAR_MODULE_EXPORT_BEGIN
38template <
size_t N,
int RW,
int LOC>
41template<
int RW,
int LOC>
46template <
size_t N,
int RW,
int LOC>
49 __builtin_prefetch(
reinterpret_cast<void*
>(ptr), RW, LOC);
50 std::atomic_signal_fence(std::memory_order_seq_cst);
51 prefetcher<N-cache_line_size, RW, LOC>(ptr + cache_line_size);
61template<
typename T,
int LOC = 3>
62void prefetch(T* ptr) {
66template<
typename Iterator,
int LOC = 3>
67void prefetch(Iterator begin, Iterator end) {
68 std::for_each(begin, end, [] (
auto v) { prefetch<decltype(*v), LOC>(v); });
71template<
size_t C,
typename T,
int LOC = 3>
72void prefetch_n(T** pptr) {
73 std::invoke([&] <
size_t... x> (std::index_sequence<x...>) {
74 (..., prefetch<T, LOC>(*(pptr + x)));
75 }, std::make_index_sequence<C>{});
78template<
size_t L,
int LOC = 3>
79void prefetch(
void* ptr) {
80 prefetcher<L*cache_line_size, 0, LOC>(
reinterpret_cast<uintptr_t
>(ptr));
83template<
size_t L,
typename Iterator,
int LOC = 3>
84void prefetch_n(Iterator begin, Iterator end) {
85 std::for_each(begin, end, [] (
auto v) { prefetch<L, LOC>(v); });
88template<
size_t L,
size_t C,
typename T,
int LOC = 3>
89void prefetch_n(T** pptr) {
90 std::invoke([&] <
size_t... x> (std::index_sequence<x...>) {
91 (..., prefetch<L, LOC>(*(pptr + x)));
92 }, std::make_index_sequence<C>{});
95template<
typename T,
int LOC = 3>
96void prefetchw(T* ptr) {
97 prefetcher<align_up(sizeof(T), cache_line_size), 1, LOC>(
reinterpret_cast<uintptr_t
>(ptr));
100template<
typename Iterator,
int LOC = 3>
101void prefetchw_n(Iterator begin, Iterator end) {
102 std::for_each(begin, end, [] (
auto v) { prefetchw<decltype(*v), LOC>(v); });
105template<
size_t C,
typename T,
int LOC = 3>
106void prefetchw_n(T** pptr) {
107 std::invoke([&] <
size_t... x> (std::index_sequence<x...>) {
108 (..., prefetchw<T, LOC>(*(pptr + x)));
109 }, std::make_index_sequence<C>{});
112template<
size_t L,
int LOC = 3>
113void prefetchw(
void* ptr) {
114 prefetcher<L*cache_line_size, 1, LOC>(
reinterpret_cast<uintptr_t
>(ptr));
117template<
size_t L,
typename Iterator,
int LOC = 3>
118void prefetchw_n(Iterator begin, Iterator end) {
119 std::for_each(begin, end, [] (
auto v) { prefetchw<L, LOC>(v); });
122template<
size_t L,
size_t C,
typename T,
int LOC = 3>
123void prefetchw_n(T** pptr) {
124 std::invoke([&] <
size_t... x> (std::index_sequence<x...>) {
125 (..., prefetchw<L, LOC>(*(pptr + x)));
126 }, std::make_index_sequence<C>{});
128SEASTAR_MODULE_EXPORT_END
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: prefetch.hh:47