7#include "os_detect.hpp"
9#if TT_PROCESSOR == TT_CPU_X64
22template<
typename T,
size_t N>
26 using value_type =
typename container_type::value_type;
27 using size_type =
typename container_type::size_type;
28 using difference_type =
typename container_type::difference_type;
29 using reference =
typename container_type::reference;
30 using const_reference =
typename container_type::const_reference;
31 using pointer =
typename container_type::pointer;
32 using const_pointer =
typename container_type::const_pointer;
33 using iterator =
typename container_type::iterator;
34 using const_iterator =
typename container_type::const_iterator;
44 [[nodiscard]]
explicit aligned_array(__m128
const &rhs)
noexcept requires(N == 4 && std::is_same_v<T, float> && has_sse)
46 _mm_store_ps(v.
data(), rhs);
49 [[nodiscard]]
explicit aligned_array(__m128d
const &rhs)
noexcept requires(N == 2 && std::is_same_v<T, double> && has_sse)
51 _mm_store_pd(v.
data(), rhs);
54 [[nodiscard]]
explicit aligned_array(__m128i
const &rhs)
noexcept
55 requires(std::is_integral_v<T> &&std::is_signed_v<T> &&
sizeof(T) * N == 16 && has_sse)
57 _mm_store_si128(
reinterpret_cast<__m128i *
>(v.
data()), rhs);
60 [[nodiscard]]
explicit aligned_array(__m256
const &rhs)
noexcept requires(N == 8 && std::is_same_v<T, float> && has_sse)
62 _mm256_store_ps(v.
data(), rhs);
65 [[nodiscard]]
explicit aligned_array(__m256d
const &rhs)
noexcept requires(N == 4 && std::is_same_v<T, double> && has_sse)
67 _mm256_store_pd(v.
data(), rhs);
70 [[nodiscard]]
explicit aligned_array(__m256i
const &rhs)
noexcept
71 requires(std::is_integral_v<T> &&std::is_signed_v<T> &&
sizeof(T) * N == 32 && has_sse)
73 _mm256_store_si256(
reinterpret_cast<__m256i *
>(v.
data()), rhs);
76 [[nodiscard]]
explicit operator __m128()
const noexcept requires(N == 4 && std::is_same_v<T, float> && has_sse)
78 return _mm_load_ps(v.
data());
81 [[nodiscard]]
explicit operator __m128d()
const noexcept requires(N == 2 && std::is_same_v<T, double> && has_sse)
83 return _mm_load_pd(v.
data());
86 [[nodiscard]]
explicit operator __m128i()
const noexcept
87 requires(std::is_integral_v<T> &&std::is_signed_v<T> &&
sizeof(T) * N == 16 && has_sse)
89 return _mm_load_si128(
reinterpret_cast<__m128i*
>(data()));
92 [[nodiscard]]
explicit operator __m256()
const noexcept requires(N == 8 && std::is_same_v<T, float> && has_sse)
94 return _mm256_load_ps(data());
97 [[nodiscard]]
explicit operator __m256d()
const noexcept requires(N == 4 && std::is_same_v<T, double> && has_sse)
99 return _mm256_load_pd(data());
102 [[nodiscard]]
explicit operator __m256i()
const noexcept
103 requires(std::is_integral_v<T> &&std::is_signed_v<T> &&
sizeof(T) * N == 32 && has_sse)
105 return _mm256_load_si256(
reinterpret_cast<__m256i *
>(data()));
121 [[nodiscard]]
constexpr const_reference
at(
size_t pos)
const
129 [[nodiscard]]
constexpr reference operator[](
size_t pos)
noexcept
134 [[nodiscard]]
constexpr const_reference operator[](
size_t pos)
const noexcept
139 [[nodiscard]]
constexpr reference front() noexcept
144 [[nodiscard]]
constexpr const_reference front() const noexcept
149 [[nodiscard]]
constexpr reference back() noexcept
154 [[nodiscard]]
constexpr const_reference back() const noexcept
159 [[nodiscard]]
constexpr pointer data() noexcept
164 [[nodiscard]]
constexpr const_pointer data() const noexcept
169 [[nodiscard]]
constexpr iterator begin() noexcept
174 [[nodiscard]]
constexpr const_iterator begin() const noexcept
179 [[nodiscard]]
constexpr const_iterator cbegin() const noexcept
184 [[nodiscard]]
constexpr iterator end() noexcept
189 [[nodiscard]]
constexpr const_iterator end() const noexcept
194 [[nodiscard]]
constexpr const_iterator cend() const noexcept
199 [[nodiscard]]
constexpr bool empty() const noexcept
204 [[nodiscard]]
constexpr size_type size() const noexcept
209 [[nodiscard]]
constexpr size_type max_size() const noexcept
214 constexpr void fill(T
const &value)
noexcept
216 for (
size_t i = 0; i != N; ++i) {
221 constexpr void swap(aligned_array &other)
noexcept
223 for (
size_t i = 0; i != N; ++i) {
230 for (
size_t i = 0; i != N; ++i) {
235 template<std::
size_t I>
236 [[nodiscard]]
friend constexpr T &get(aligned_array &rhs)
noexcept
238 static_assert(I < N,
"Index out of bounds");
239 return get<I>(rhs.v);
242 template<std::
size_t I>
243 [[nodiscard]]
friend constexpr T get(aligned_array &&rhs)
noexcept
245 static_assert(I < N,
"Index out of bounds");
246 return get<I>(rhs.v);
249 template<std::
size_t I>
250 [[nodiscard]]
friend constexpr T
const &get(aligned_array
const &rhs)
noexcept
252 static_assert(I < N,
"Index out of bounds");
253 return get<I>(rhs.v);
256 [[nodiscard]]
constexpr friend bool operator==(aligned_array
const &lhs, aligned_array
const &rhs)
noexcept
258 for (
size_t i = 0; i != N; ++i) {
270template<
class T,
class... U>
271aligned_array(T, U...) -> aligned_array<T, 1 +
sizeof...(U)>;
273using i8x1_raw = aligned_array<int8_t, 1>;
274using i8x2_raw = aligned_array<int8_t, 2>;
275using i8x4_raw = aligned_array<int8_t, 4>;
276using i8x8_raw = aligned_array<int8_t, 8>;
277using i8x16_raw = aligned_array<int8_t, 16>;
278using i8x32_raw = aligned_array<int8_t, 32>;
279using i8x64_raw = aligned_array<int8_t, 64>;
281using u8x1_raw = aligned_array<uint8_t, 1>;
282using u8x2_raw = aligned_array<uint8_t, 2>;
283using u8x4_raw = aligned_array<uint8_t, 4>;
284using u8x8_raw = aligned_array<uint8_t, 8>;
285using u8x16_raw = aligned_array<uint8_t, 16>;
286using u8x32_raw = aligned_array<uint8_t, 32>;
287using u8x64_raw = aligned_array<uint8_t, 64>;
289using i16x1_raw = aligned_array<int16_t, 1>;
290using i16x2_raw = aligned_array<int16_t, 2>;
291using i16x4_raw = aligned_array<int16_t, 4>;
292using i16x8_raw = aligned_array<int16_t, 8>;
293using i16x16_raw = aligned_array<int16_t, 16>;
294using i16x32_raw = aligned_array<int16_t, 32>;
296using u16x1_raw = aligned_array<uint16_t, 1>;
297using u16x2_raw = aligned_array<uint16_t, 2>;
298using u16x4_raw = aligned_array<uint16_t, 4>;
299using u16x8_raw = aligned_array<uint16_t, 8>;
300using u16x16_raw = aligned_array<uint16_t, 16>;
301using u16x32_raw = aligned_array<uint16_t, 32>;
303using i32x1_raw = aligned_array<int32_t, 1>;
304using i32x2_raw = aligned_array<int32_t, 2>;
305using i32x4_raw = aligned_array<int32_t, 4>;
306using i32x8_raw = aligned_array<int32_t, 8>;
307using i32x16_raw = aligned_array<int32_t, 16>;
309using u32x1_raw = aligned_array<uint32_t, 1>;
310using u32x2_raw = aligned_array<uint32_t, 2>;
311using u32x4_raw = aligned_array<uint32_t, 4>;
312using u32x8_raw = aligned_array<uint32_t, 8>;
313using u32x16_raw = aligned_array<uint32_t, 16>;
315using f32x1_raw = aligned_array<float, 1>;
316using f32x2_raw = aligned_array<float, 2>;
317using f32x4_raw = aligned_array<float, 4>;
318using f32x8_raw = aligned_array<float, 8>;
319using f32x16_raw = aligned_array<float, 16>;
321using i64x1_raw = aligned_array<int64_t, 1>;
322using i64x2_raw = aligned_array<int64_t, 2>;
323using i64x4_raw = aligned_array<int64_t, 4>;
324using i64x8_raw = aligned_array<int64_t, 8>;
326using u64x1_raw = aligned_array<uint64_t, 1>;
327using u64x2_raw = aligned_array<uint64_t, 2>;
328using u64x4_raw = aligned_array<uint64_t, 4>;
329using u64x8_raw = aligned_array<uint64_t, 8>;
331using f64x1_raw = aligned_array<double, 1>;
332using f64x2_raw = aligned_array<double, 2>;
333using f64x4_raw = aligned_array<double, 4>;
334using f64x8_raw = aligned_array<double, 8>;
341template<
class T, std::
size_t N>
345template<std::
size_t I,
class T, std::
size_t N>
346struct tuple_element<I, tt::aligned_array<T, N>> {
Definition aligned_array.hpp:23
constexpr reference at(size_t pos)
Select item at pos.
Definition aligned_array.hpp:113
Definition concepts.hpp:18
Definition concepts.hpp:21