template<typename V, size_t Size, bool InitPadding>
class Vc::Common::Memory< V, Size, 0u, InitPadding >
A helper class to simplify usage of correctly aligned and padded memory, allowing both vector and scalar access.
Example:
for (
size_t i = 0; i <
array.entriesCount(); ++i) {
}
for (
size_t i = 0; i <
array.entriesCount(); ++i) {
}
for (
size_t i = 0; i <
array.vectorsCount(); ++i) {
}
A helper class for fixed-size two-dimensional arrays.
Vector< int > int_v
vector of signed integers
This is std::array with additional subscript operators supporting gather and scatter operations.
This code allocates a small array and implements three equivalent loops (that do nothing useful). The loops show how scalar and vector read/write access is best implemented.
Since the size of 11 is not a multiple of int_v::Size (unless you use the scalar Vc implementation) the last write access of the vector loop would normally be out of bounds. But the Memory class automatically pads the memory such that the whole array can be accessed with correctly aligned memory addresses.
- Parameters
-
V | The vector type you want to operate on. (e.g. float_v or uint_v) |
Size | The number of entries of the scalar base type the memory should hold. This is thus the same number as you would use for a normal C array (e.g. float mem[11] becomes Memory<float_v, 11> mem). |
- See also
- Memory<V, 0u>
Definition at line 199 of file memory.h.
|
Memory & | operator= (const MemoryBase< V, Parent, 2, RM > &rhs) |
| Copies the data from a different object.
|
Memory & | operator= (const V &v) |
| Initialize all data with the given vector.
|
std::enable_if<!std::is_convertible< Flags, int >::value, vector_reference< Flags > >::type | vector (size_t i, Flags=Flags()) |
std::enable_if<!std::is_convertible< Flags, int >::value, const_vector_reference< Flags > >::type | vector (size_t i, Flags=Flags()) const |
| Const overload of the above function.
|
std::enable_if< std::is_convertible< ShiftT, int >::value, vector_reference< decltype(std::declval< Flags >()|Unaligned)> >::type | vector (size_t i, ShiftT shift, Flags=Flags()) |
std::enable_if< std::is_convertible< ShiftT, int >::value, const_vector_reference< decltype(std::declval< Flags >()|Unaligned)> >::type | vector (size_t i, ShiftT shift, Flags=Flags()) const |
| Const overload of the above function.
|
size_t | entriesCount () const |
size_t | vectorsCount () const |
MemoryVectorIterator< V, Flags > | begin (Flags flags=Flags()) |
| Return a (vectorized) iterator to the start of this memory object.
|
MemoryVectorIterator< V, Flags > | end (Flags flags=Flags()) |
| Return a (vectorized) iterator to the end of this memory object.
|
vector_reference< Flags > | vectorAt (size_t i, Flags flags=Flags()) |
vector_reference< Flags > | firstVector (Flags f=Flags()) |
vector_reference< Flags > | lastVector (Flags f=Flags()) |
void | setZero () |
| Zero the whole memory area.
|
Memory< V, Size1, Size2, InitPadding > & | operator+= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to add up two arrays.
|
Memory< V, Size1, Size2, InitPadding > & | operator-= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to subtract two arrays.
|
Memory< V, Size1, Size2, InitPadding > & | operator*= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to multiply two arrays.
|
Memory< V, Size1, Size2, InitPadding > & | operator/= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to divide two arrays.
|
bool | operator== (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare equality of two arrays.
|
bool | operator!= (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
bool | operator< (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
bool | operator<= (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
bool | operator> (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
bool | operator>= (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
size_t | entriesCount () const |
size_t | vectorsCount () const |
MemoryVectorIterator< V, Flags > | begin (Flags flags=Flags()) |
| Return a (vectorized) iterator to the start of this memory object.
|
MemoryVectorIterator< V, Flags > | end (Flags flags=Flags()) |
| Return a (vectorized) iterator to the end of this memory object.
|
vector_reference< Flags > | vectorAt (size_t i, Flags flags=Flags()) |
vector_reference< Flags > | firstVector (Flags f=Flags()) |
vector_reference< Flags > | lastVector (Flags f=Flags()) |
void | setZero () |
| Zero the whole memory area.
|
Memory< V, Size1, Size2, InitPadding > & | operator+= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to add up two arrays.
|
Memory< V, Size1, Size2, InitPadding > & | operator-= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to subtract two arrays.
|
Memory< V, Size1, Size2, InitPadding > & | operator*= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to multiply two arrays.
|
Memory< V, Size1, Size2, InitPadding > & | operator/= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to divide two arrays.
|
bool | operator== (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare equality of two arrays.
|
bool | operator!= (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
bool | operator< (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
bool | operator<= (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
bool | operator> (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
bool | operator>= (const MemoryBase< V, P2, Dimension, RM > &rhs) const |
| (Inefficient) shorthand compare two arrays.
|
MemoryVectorIterator< const V, Flags > | begin (Flags flags=Flags()) const |
| const overload of the above
|
MemoryVectorIterator< const V, Flags > | end (Flags flags=Flags()) const |
| const overload of the above
|
const_vector_reference< Flags > | vectorAt (size_t i, Flags flags=Flags()) const |
| Const overload of the above function.
|
const_vector_reference< Flags > | firstVector (Flags f=Flags()) const |
| Const overload of the above function.
|
const_vector_reference< Flags > | lastVector (Flags f=Flags()) const |
| Const overload of the above function.
|
Memory< V, Size, 0u, InitPadding > & | operator+= (EntryType rhs) |
| (Inefficient) shorthand to add a value to an array.
|
Memory< V, Size, 0u, InitPadding > & | operator-= (EntryType rhs) |
| (Inefficient) shorthand to subtract a value from an array.
|
Memory< V, Size, 0u, InitPadding > & | operator*= (EntryType rhs) |
| (Inefficient) shorthand to multiply a value to an array.
|
Memory< V, Size, 0u, InitPadding > & | operator/= (EntryType rhs) |
| (Inefficient) shorthand to divide an array with a value.
|