-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaligned_buf.hpp
More file actions
33 lines (25 loc) · 779 Bytes
/
aligned_buf.hpp
File metadata and controls
33 lines (25 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: GPL-2.0
// This class template implements an (over) aligned buffer.
// At the moment we align at 64 bytes, hoping that this is sufficient for
// getting optimal fftw plans and SIMD optimizations. Increasing this value
// is trivial.
#ifndef ALIGNED_BUF_HPP
#define ALIGNED_BUF_HPP
#include <cstddef> // For size_t
template <typename T>
class AlignedBuf {
T *buf;
public:
constexpr static size_t align = 64;
AlignedBuf(); // Undefined buffer
AlignedBuf(size_t n); // Buffer containing n elements
AlignedBuf(AlignedBuf &&); // Move buffer
AlignedBuf &operator=(AlignedBuf &&); // Move buffer
~AlignedBuf();
bool operator!() const;
operator bool() const;
T *get();
const T *get() const;
};
#include "aligned_buf_impl.hpp"
#endif