|
ape
0.5.0
Audio Programming Environment
|
Go to the documentation of this file.
11 #ifndef __CPPAPE_NATIVE_VECTOR_BIT_WIDTH__
12 #define __CPPAPE_NATIVE_VECTOR_BIT_WIDTH__ 128
15 #define __CPPAPE_NATIVE_VECTOR_BYTES__ (__CPPAPE_NATIVE_VECTOR_BIT_WIDTH__ / CHAR_BIT)
21 using vector_register = T __attribute__((ext_vector_type(__CPPAPE_NATIVE_VECTOR_BYTES__ /
sizeof(T))));
42 return { a.real() * b.real() - a.imag() * b.imag(), a.real() * b.imag() + a.imag() * b.real() };
51 constexpr
auto mask = __CPPAPE_NATIVE_VECTOR_BYTES__ - 1;
53 assert((static_cast<std::uintptr_t>(input.
data()) & mask) == 0 &&
"Input array not sufficiently aligned");
54 assert(input.
size() *
sizeof(T) %
sizeof(
vector_register<T>) == 0 &&
"Whole number of machine vector registers does not fit in array");
65 constexpr
auto mask = __CPPAPE_NATIVE_VECTOR_BYTES__ - 1;
67 assert((reinterpret_cast<std::uintptr_t>(input.data()) & mask) == 0 &&
"Input array not sufficiently aligned");
68 assert(input.size() *
sizeof(T) %
sizeof(std::complex<
vector_register<T>>) == 0 &&
"Whole number of machine vector registers does not fit in array");
70 return {
reinterpret_cast<std::complex<vector_register<T>
>*>(input.data()), (
sizeof(std::complex<T>) * input.size()) /
sizeof(std::complex<
vector_register<T>>) };
Traits for vector_register
Definition: simd.h:27
uarray< T > as_uarray(std::vector< T > &vec)
Definition: misc.h:681
static constexpr std::size_t lanes
How many lanes (or "width") of the register there is
Definition: simd.h:36
An unowned array wrapper - a mutable "view" of something else, that cannot be resized....
Definition: misc.h:24
Definition: audiofile.h:7
uarray< vector_register< T > > as_vectors(uarray< T > input)
Reinterprets the input as a array of SIMD vectors
Definition: simd.h:49
T __attribute__((ext_vector_type(__CPPAPE_NATIVE_VECTOR_BYTES__/sizeof(T)))) vector_register
A machine sized SIMD register with as many lanes as possible for the given T
Definition: simd.h:21
std::size_t size() const noexcept
Returns the size of the array pointed to by this uarray
Definition: misc.h:113
T * data() noexcept
Retrieve a raw pointer to the array pointed to
Definition: misc.h:104
decltype(V()[0]) typedef value_type
The type of the element in the vector_register
Definition: simd.h:32