Botan
3.9.0
Crypto and TLS for C&
src
lib
utils
prefetch.h
Go to the documentation of this file.
1
/*
2
* (C) 2023 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6
7
#ifndef BOTAN_PREFETCH_UTILS_H_
8
#define BOTAN_PREFETCH_UTILS_H_
9
10
#include <botan/types.h>
11
#include <concepts>
12
#include <type_traits>
13
14
namespace
Botan
{
15
16
/**
17
* Prefetch an array
18
*
19
* This function returns a uint64_t which is accumulated from values
20
* read from the array. This may help confuse the compiler sufficiently
21
* to not elide otherwise "useless" reads. The return value will always
22
* be zero.
23
*/
24
uint64_t
prefetch_array_raw
(
size_t
bytes,
const
void
* array)
noexcept
;
25
26
/**
27
* Prefetch several arrays
28
*
29
* This function returns a uint64_t which is accumulated from values
30
* read from the array. This may help confuse the compiler sufficiently
31
* to not elide otherwise "useless" reads. The return value will always
32
* be zero.
33
*/
34
template
<std::unsigned_integral T,
size_t
... Ns>
35
T
prefetch_arrays
(T (&... arr)[Ns])
noexcept
{
36
return
(
static_cast<
T
>
(
prefetch_array_raw
(
sizeof
(T) * Ns, arr)) & ...);
37
}
38
39
}
// namespace Botan
40
41
#endif
Botan
Definition
alg_id.cpp:13
Botan::prefetch_array_raw
uint64_t prefetch_array_raw(size_t bytes, const void *arrayv) noexcept
Definition
prefetch.cpp:14
Botan::prefetch_arrays
T prefetch_arrays(T(&... arr)[Ns]) noexcept
Definition
prefetch.h:35
Generated by
1.14.0