template<typename V>
class Vc::Common::Memory< V, 0u, 0u, true >
A helper class that is very similar to Memory<V, Size> but with dynamically allocated memory and thus dynamic size.
Example:
size_t size = 11;
Vc::Memory<int_v> array(size);
for (size_t i = 0; i < array.entriesCount(); ++i) {
array[i] = i;
}
for (size_t i = 0; i < array.vectorsCount(); ++i) {
}
This code allocates a small array with 11 scalar entries and implements two equivalent loops that initialize the memory. The scalar loop writes each individual int. The vectorized loop writes int_v::Size values to memory per iteration. 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. (Note: the scalar loop can be auto-vectorized, except for the last three assignments.)
- Note
- The internal data pointer is not declared with the
restrict
keyword. Therefore modifying memory of V::EntryType will require the compiler to assume aliasing. If you want to use the restrict
keyword you need to use a standard pointer to memory and do the vector address calculation and loads and stores manually.
- Parameters
-
V | The vector type you want to operate on. (e.g. float_v or uint_v) |
- See also
- Memory<V, Size>
Definition at line 457 of file memory.h.
|
| Memory (size_t size) |
| Allocate enough memory to access size values of type V::EntryType . More...
|
|
template<typename Parent , typename RM > |
| Memory (const MemoryBase< V, Parent, 1, RM > &rhs) |
| Copy the memory into a new memory area. More...
|
|
| Memory (const Memory &rhs) |
| Overload of the above function. More...
|
|
| ~Memory () |
| Frees the memory which was allocated in the constructor.
|
|
void | swap (Memory &rhs) |
| Swap the contents and size information of two Memory objects. More...
|
|
size_t | entriesCount () const |
|
size_t | vectorsCount () const |
|
template<typename Parent , typename RM > |
Memory & | operator= (const MemoryBase< V, Parent, 1, RM > &rhs) |
| Overwrite all entries with the values stored in rhs . More...
|
|
Memory & | operator= (const EntryType *rhs) |
| Overwrite all entries with the values stored in the memory at rhs . More...
|
|
MemoryVectorIterator< V, Flags > | begin (Flags flags=Flags()) |
| Return a (vectorized) iterator to the start of this memory object.
|
|
MemoryVectorIterator< const V, Flags > | begin (Flags flags=Flags()) const |
| const overload of the above
|
|
MemoryVectorIterator< V, Flags > | end (Flags flags=Flags()) |
| Return a (vectorized) iterator to the end of this memory object.
|
|
MemoryVectorIterator< const V, Flags > | end (Flags flags=Flags()) const |
| const overload of the above
|
|
std::enable_if<!std::is_convertible< Flags, int >::value, MemoryVector< V, Flags > >::type & | vector (size_t i, Flags=Flags()) |
|
std::enable_if<!std::is_convertible< Flags, int >::value, MemoryVector< const V, Flags > >::type & | vector (size_t i, Flags=Flags()) const |
| Const overload of the above function. More...
|
|
std::enable_if< std::is_convertible< ShiftT, int >::value, MemoryVector< V, decltype(std::declval< Flags >)|Unaligned)> >::type & | vector (size_t i, ShiftT shift, Flags=Flags()) |
|
std::enable_if< std::is_convertible< ShiftT, int >::value, MemoryVector< const V, decltype(std::declval< Flags >)|Unaligned)> >::type & | vector (size_t i, ShiftT shift, Flags=Flags()) const |
| Const overload of the above function.
|
|
MemoryVector< V, Flags > & | vectorAt (size_t i, Flags flags=Flags()) |
|
MemoryVector< const V, Flags > & | vectorAt (size_t i, Flags flags=Flags()) const |
| Const overload of the above function. More...
|
|
MemoryVector< V, Flags > & | firstVector (Flags=Flags()) |
|
MemoryVector< const V, Flags > & | firstVector (Flags=Flags()) const |
| Const overload of the above function.
|
|
MemoryVector< V, Flags > & | lastVector (Flags=Flags()) |
|
MemoryVector< const V, Flags > & | lastVector (Flags=Flags()) const |
| Const overload of the above function.
|
|
void | setZero () |
| Zero the whole memory area.
|
|
Memory< V, 0u, 0u, true > & | operator+= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to add up two arrays.
|
|
Memory< V, 0u, 0u, true > & | operator+= (EntryType rhs) |
| (Inefficient) shorthand to add a value to an array.
|
|
Memory< V, 0u, 0u, true > & | operator-= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to subtract two arrays.
|
|
Memory< V, 0u, 0u, true > & | operator-= (EntryType rhs) |
| (Inefficient) shorthand to subtract a value from an array.
|
|
Memory< V, 0u, 0u, true > & | operator*= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to multiply two arrays.
|
|
Memory< V, 0u, 0u, true > & | operator*= (EntryType rhs) |
| (Inefficient) shorthand to multiply a value to an array.
|
|
Memory< V, 0u, 0u, true > & | operator/= (const MemoryBase< V, P2, Dimension, RM > &rhs) |
| (Inefficient) shorthand to divide two arrays.
|
|
Memory< V, 0u, 0u, true > & | operator/= (EntryType rhs) |
| (Inefficient) shorthand to divide an array with a value.
|
|
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.
|
|