Botan  2.6.0
Crypto and TLS for C++11
prefetch.h
Go to the documentation of this file.
1 /*
2 * Prefetching Operations
3 * (C) 2009 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_PREFETCH_H_
9 #define BOTAN_PREFETCH_H_
10 
11 #include <botan/cpuid.h>
12 
13 namespace Botan {
14 
15 template<typename T>
16 inline void prefetch_readonly(const T* addr, size_t length)
17  {
18 #if defined(__GNUG__)
19  const size_t Ts_per_cache_line = CPUID::cache_line_size() / sizeof(T);
20 
21  for(size_t i = 0; i <= length; i += Ts_per_cache_line)
22  __builtin_prefetch(addr + i, 0);
23 #endif
24  }
25 
26 template<typename T>
27 inline void prefetch_readwrite(const T* addr, size_t length)
28  {
29 #if defined(__GNUG__)
30  const size_t Ts_per_cache_line = CPUID::cache_line_size() / sizeof(T);
31 
32  for(size_t i = 0; i <= length; i += Ts_per_cache_line)
33  __builtin_prefetch(addr + i, 1);
34 #endif
35  }
36 
37 }
38 
39 #endif
void prefetch_readonly(const T *addr, size_t length)
Definition: prefetch.h:16
static size_t cache_line_size()
Definition: cpuid.h:66
Definition: alg_id.cpp:13
void prefetch_readwrite(const T *addr, size_t length)
Definition: prefetch.h:27
fe T
Definition: ge.cpp:37