17 #ifndef AGX_PREFETCH_H
18 #define AGX_PREFETCH_H
20 #include <agx/config/AGX_USE_PREFETCHING.h>
21 #include <agx/config/AGX_USE_SSE.h>
23 #include <agx/config.h>
27 #if AGX_USE_PREFETCHING() && ( defined(_MSC_VER) || AGX_USE_SSE() )
29 #include <xmmintrin.h>
31 #if defined(__clang__) || defined(__INTEL_COMPILER)
53 template<
int h
int,
typename T >
57 _mm_prefetch( (
const char*) ptr, (_mm_hint) hint );
59 _mm_prefetch( (
const char*) ptr, hint );
64 template<
int h
int,
typename T >
67 prefetch<hint>( ptr );
70 template<
int h
int,
typename T >
73 prefetch<hint>( ptr );
74 prefetch<hint>( ((
const char*)ptr) + 64 );
77 template<
int h
int,
typename T >
80 prefetch<hint>( ptr );
81 prefetch<hint>( ((
const char*)ptr) + 64 );
82 prefetch<hint>( ((
const char*)ptr) + 128 );
83 prefetch<hint>( ((
const char*)ptr) + 192 );
89 const size_t PREFETCH_SIZE = 64;
91 template <PrefetchType PrefetchT>
94 const size_t numBlocks = (numBytes + PREFETCH_SIZE-1) / PREFETCH_SIZE;
97 for (
size_t i = 0; i < numBlocks; ++i)
99 const void *ptr = (
const char *)buffer + i * PREFETCH_SIZE;
100 prefetch<PrefetchT>(ptr);
104 template <
typename T>
107 const size_t numBytes = numElements *
sizeof(T);
108 prefetchBytes<agx::NTA>(buffer, numBytes);
111 template <
typename T>
114 const size_t numBytes = numElements *
sizeof(T);
115 prefetchBytes<agx::L3>(buffer, numBytes);
134 template<
int h
int,
typename T >
137 template<
int h
int,
typename T >
140 template<
int h
int,
typename T >
143 template<
int h
int,
typename T >
147 template <
int PrefetchT>
151 template <
typename T>
155 template <
typename T>
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
void prefetch_64(const T *)
void prefetchBytes(const void *, size_t)
void prefetchL3(const T *, size_t)
void prefetch_128(const T *)
void prefetch_256(const T *)
void prefetchNTA(const T *, size_t)