|
SkePU 0.7
|
A vector container class, implemented as a wrapper for std::vector. More...
#include <vector.h>
Classes | |
| class | iterator |
| An vector iterator class. More... | |
| class | proxy_elem |
| A proxy class representing one element of Vector. More... | |
Public Member Functions | |
| void | randomize (int min=0, int max=RAND_MAX) |
| Randomizes the vector. | |
| void | save (const std::string &filename) |
| Saves content of vector to a file. | |
| void | load (const std::string &filename, int numElements=0) |
| Loads the vector from a file. | |
| Vector () | |
| Vector (const Vector &vec) | |
| Vector (size_type num, const T &val=T()) | |
| template<typename input_iterator > | |
| Vector (input_iterator start, input_iterator end) | |
| ~Vector () | |
| proxy_elem | operator[] (const size_type index) const |
| T & | operator[] (const size_type index) |
| Vector< T > & | operator= (const Vector< T > &other) |
| bool | operator== (const Vector< T > &c1) |
| bool | operator!= (const Vector< T > &c1) |
| bool | operator< (const Vector< T > &c1) |
| bool | operator> (const Vector< T > &c1) |
| bool | operator<= (const Vector< T > &c1) |
| bool | operator>= (const Vector< T > &c1) |
| iterator | begin () |
| const_iterator | begin () const |
| iterator | end () |
| const_iterator | end () const |
| reverse_iterator | rbegin () |
| const_reverse_iterator | rbegin () const |
| reverse_iterator | rend () |
| const_reverse_iterator | rend () const |
| size_type | capacity () const |
| size_type | size () const |
| size_type | max_size () const |
| void | resize (size_type num, T val=T()) |
| bool | empty () const |
| void | reserve (size_type size) |
| proxy_elem | at (size_type loc) |
| const T & | at (size_type loc) const |
| proxy_elem | back () |
| const T & | back () const |
| proxy_elem | front () |
| const T & | front () const |
| void | assign (size_type num, const T &val) |
| template<typename input_iterator > | |
| void | assign (input_iterator start, input_iterator end) |
| void | clear () |
| void | pop_back () |
| void | push_back (const T &val) |
| void | swap (Vector< T > &from) |
| device_pointer_type_cl | updateDevice_CL (T *start, size_type numElements, Device_CL *device, bool copy) |
| Update device with vector content. | |
| void | flush_CL () |
| Flushes the vector. | |
| device_pointer_type_cu | updateDevice_CU (T *start, size_type numElements, int deviceID, bool copy) |
| Update device with vector content. | |
| void | flush_CU () |
| Flushes the vector. | |
| bool | isVectorOnDevice_CU (int deviceID) |
| void | flush () |
| T & | operator() (const size_type index) |
| void | updateHost () const |
| void | invalidateDevice () |
| void | updateHostAndInvalidateDevice () |
| template<typename T> | |
| Vector< T >::iterator | insert (typename Vector< T >::iterator loc, const T &val) |
| template<typename T> | |
| void | insert (typename Vector< T >::iterator loc, size_type num, const T &val) |
| template<typename input_iterator > | |
| void | insert (typename Vector< T >::iterator loc, input_iterator start, input_iterator end) |
Friends | |
| std::ostream & | operator<< (std::ostream &output, Vector< T > &vec) |
| Overloaded stream operator, for testing purposes. | |
A vector container class, implemented as a wrapper for std::vector.
A skepu::Vector is a container of vector/array type and is implemented as a wrapper for std::vector. Its interface and behaviour is largely compatible with std::vector but with some additions and variations. Instead of the regular element, it sometimes returns a proxy element so it can distinguish between reads and writes. It also keeps track of which parts of it are currently allocated and uploaded to the GPU. If a computation is done, changing the vector in the GPU memory, it is not directly transferred back to the host memory. Instead, the vector waits until an element is accessed before any copying is done.
It also implements support for allocating and de-allocating page-locked memory using cudaMallocHost and cudaFreeHost. This could help is running asynchronous operations especially when using multiple CUDA devices. It can be enabled by defining USE_PINNED_MEMORY flag in the skeleton program.
Please refer to C++ STL vector documentation for more information about CPU side implementation.
| skepu::Vector< T >::Vector | ( | ) |
Please refer to the documentation of std::vector.
| skepu::Vector< T >::Vector | ( | const Vector< T > & | c | ) |
Please refer to the documentation of std::vector.
Updates vector c before copying.
References skepu::Vector< T >::updateHost().

| skepu::Vector< T >::Vector | ( | size_type | num, |
| const T & | val = T() |
||
| ) | [explicit] |
Please refer to the documentation of std::vector.
| skepu::Vector< T >::Vector | ( | input_iterator | start, |
| input_iterator | end | ||
| ) |
Please refer to the documentation of std::vector.
| skepu::Vector< T >::~Vector | ( | ) |
Releases all allocations made on device.
| void skepu::Vector< T >::assign | ( | size_type | num, |
| const T & | val | ||
| ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::assign | ( | input_iterator | start, |
| input_iterator | end | ||
| ) |
Please refer to the documentation of std::vector.
| Vector< T >::proxy_elem skepu::Vector< T >::at | ( | size_type | loc | ) |
Please refer to the documentation of std::vector.
Returns a proxy_elem instead of an ordinary element. The proxy_elem usually behaves like an ordinary, but there might be exceptions.
| const T & skepu::Vector< T >::at | ( | size_type | loc | ) | const |
Please refer to the documentation of std::vector.
| Vector< T >::proxy_elem skepu::Vector< T >::back | ( | ) |
Please refer to the documentation of std::vector.
Returns a proxy_elem instead of an ordinary element. The proxy_elem usually behaves like an ordinary, but there might be exceptions.
| const T & skepu::Vector< T >::back | ( | ) | const |
Please refer to the documentation of std::vector.
| Vector< T >::const_iterator skepu::Vector< T >::begin | ( | ) | const |
Please refer to the documentation of std::vector.
| Vector< T >::iterator skepu::Vector< T >::begin | ( | ) |
Please refer to the documentation of std::vector.
| Vector< T >::size_type skepu::Vector< T >::capacity | ( | ) | const |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::clear | ( | ) |
Please refer to the documentation of std::vector.
| bool skepu::Vector< T >::empty | ( | ) | const |
Please refer to the documentation of std::vector.
| Vector< T >::const_iterator skepu::Vector< T >::end | ( | ) | const |
Please refer to the documentation of std::vector.
| Vector< T >::iterator skepu::Vector< T >::end | ( | ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::flush | ( | ) |
Flushes the vector, synchronizing it with the device then release all device allocations.
| void skepu::Vector< T >::flush_CL | ( | ) |
Flushes the vector.
First it updates the vector from all its device allocations, then it releases all allocations.
| void skepu::Vector< T >::flush_CU | ( | ) |
Flushes the vector.
First it updates the vector from all its device allocations, then it releases all allocations.
| const T & skepu::Vector< T >::front | ( | ) | const |
Please refer to the documentation of std::vector.
| Vector< T >::proxy_elem skepu::Vector< T >::front | ( | ) |
Please refer to the documentation of std::vector.
Returns a proxy_elem instead of an ordinary element. The proxy_elem usually behaves like an ordinary, but there might be exceptions.
| void skepu::Vector< T >::insert | ( | typename Vector< T >::iterator | loc, |
| input_iterator | start, | ||
| input_iterator | end | ||
| ) |
Please refer to the documentation of std::vector.
| Vector<T>::iterator skepu::Vector< T >::insert | ( | typename Vector< T >::iterator | loc, |
| const T & | val | ||
| ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::insert | ( | typename Vector< T >::iterator | loc, |
| size_type | num, | ||
| const T & | val | ||
| ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::invalidateDevice | ( | ) | [inline] |
Invalidates all device data that this vector has allocated.
| bool skepu::Vector< T >::isVectorOnDevice_CU | ( | int | deviceID | ) |
Can be used to query whether vector is already available on a device or not.
| void skepu::Vector< T >::load | ( | const std::string & | filename, |
| int | numElements = 0 |
||
| ) | [inline] |
Loads the vector from a file.
Reads a variable nuimber of elements from a file. In the file, all elemets should be in ASCII on one line with whitespace between each element. Mainly for testing purposes.
| filename | Name of file to save to. |
| numElements | The number of elements to load. Default value 0 means all values. |
References skepu::Vector< T >::clear(), and skepu::Vector< T >::push_back().

| Vector< T >::size_type skepu::Vector< T >::max_size | ( | ) | const |
Please refer to the documentation of std::vector.
| bool skepu::Vector< T >::operator!= | ( | const Vector< T > & | c1 | ) |
Please refer to the documentation of std::vector.
References skepu::Vector< T >::updateHost().

| T & skepu::Vector< T >::operator() | ( | const size_type | index | ) |
Behaves like operator[] but does not care about synchronizing with device. Can be used when accessing many elements quickly so that no synchronization overhead effects performance. Make sure to properly synch with device by calling updateHost etc before use.
| index | Index to a specific element of the vector. |
| bool skepu::Vector< T >::operator< | ( | const Vector< T > & | c1 | ) |
Please refer to the documentation of std::vector.
References skepu::Vector< T >::updateHost().

| bool skepu::Vector< T >::operator<= | ( | const Vector< T > & | c1 | ) |
Please refer to the documentation of std::vector.
References skepu::Vector< T >::updateHost().

| Vector< T > & skepu::Vector< T >::operator= | ( | const Vector< T > & | other | ) |
Please refer to the documentation of std::vector.
References skepu::Vector< T >::updateHost().

| bool skepu::Vector< T >::operator== | ( | const Vector< T > & | c1 | ) |
Please refer to the documentation of std::vector.
References skepu::Vector< T >::updateHost().

| bool skepu::Vector< T >::operator> | ( | const Vector< T > & | c1 | ) |
Please refer to the documentation of std::vector.
References skepu::Vector< T >::updateHost().

| bool skepu::Vector< T >::operator>= | ( | const Vector< T > & | c1 | ) |
Please refer to the documentation of std::vector.
References skepu::Vector< T >::updateHost().

| Vector< T >::proxy_elem skepu::Vector< T >::operator[] | ( | const size_type | index | ) | const |
Please refer to the documentation of std::vector.
Returns a proxy_elem instead of an ordinary element. The proxy_elem usually behaves like an ordinary, but there might be exceptions.
| T & skepu::Vector< T >::operator[] | ( | const size_type | index | ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::pop_back | ( | ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::push_back | ( | const T & | val | ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::randomize | ( | int | min = 0, |
| int | max = RAND_MAX |
||
| ) | [inline] |
Randomizes the vector.
Sets each element of the vector to a random number between min and max. The numbers are generated as integers but are cast to the type of the vector.
| min | The smallest number an element can become. |
| max | The largest number an element can become. |
References skepu::Vector< T >::invalidateDevice(), skepu::max(), and skepu::min().

| Vector< T >::const_reverse_iterator skepu::Vector< T >::rbegin | ( | ) | const |
Please refer to the documentation of std::vector.
| Vector< T >::reverse_iterator skepu::Vector< T >::rbegin | ( | ) |
Please refer to the documentation of std::vector.
| Vector< T >::const_reverse_iterator skepu::Vector< T >::rend | ( | ) | const |
Please refer to the documentation of std::vector.
| Vector< T >::reverse_iterator skepu::Vector< T >::rend | ( | ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::reserve | ( | size_type | size | ) |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::resize | ( | size_type | num, |
| T | val = T() |
||
| ) |
resize matrix,,, invalidates all copies before resizing.
Please refer to the documentation of std::vector.
References skepu::min().

| void skepu::Vector< T >::save | ( | const std::string & | filename | ) | [inline] |
Saves content of vector to a file.
Outputs the vector as text on one line with space between elements to the specified file. Mainly for testing purposes.
| filename | Name of file to save to. |
References skepu::Vector< T >::at(), and skepu::Vector< T >::size().

| Vector< T >::size_type skepu::Vector< T >::size | ( | ) | const |
Please refer to the documentation of std::vector.
| void skepu::Vector< T >::swap | ( | Vector< T > & | from | ) |
Please refer to the documentation of std::vector.
References skepu::Vector< T >::updateHostAndInvalidateDevice().

| Vector< T >::device_pointer_type_cl skepu::Vector< T >::updateDevice_CL | ( | T * | start, |
| size_type | numElements, | ||
| Device_CL * | device, | ||
| bool | copy | ||
| ) |
Update device with vector content.
Update device with a vector range. If vector does not have an allocation on the device for the current range, create a new allocation and if specified, also copy vector data to device. Saves newly allocated ranges to m_deviceMemPointers_CL so vector can keep track of where and what it has stored on devices.
| start | Pointer to first element in range to be updated with device. |
| numElements | Number of elemets in range. |
| device | Pointer to the device that should be synched with. |
| copy | Boolean value that tells whether to only allocate or also copy vector data to device. True copies, False only allocates. |
References skepu::DeviceMemPointer_CL< T >::copyHostToDevice(), and skepu::Device_CL::getDeviceID().

| Vector< T >::device_pointer_type_cu skepu::Vector< T >::updateDevice_CU | ( | T * | start, |
| size_type | numElements, | ||
| int | deviceID, | ||
| bool | copy | ||
| ) |
Update device with vector content.
Update device with a vector range. If vector does not have an allocation on the device for the current range, create a new allocation and if specified, also copy vector data to device. Saves newly allocated ranges to m_deviceMemPointers_CU so vector can keep track of where and what it has stored on devices.
| start | Pointer to first element in range to be updated with device. |
| numElements | Number of elemets in range. |
| deviceID | Integer specififying the device that should be synched with. |
| copy | Boolean value that tells whether to only allocate or also copy vector data to device. True copies, False only allocates. |
References skepu::DeviceMemPointer_CU< T >::copyHostToDevice(), and skepu::Environment< T >::getInstance().

| void skepu::Vector< T >::updateHost | ( | ) | const [inline] |
Updates the vector from its device allocations.
| void skepu::Vector< T >::updateHostAndInvalidateDevice | ( | ) | [inline] |
First updates the vector from its device allocations. Then invalidates the data allocated on devices.
| std::ostream& operator<< | ( | std::ostream & | output, |
| Vector< T > & | vec | ||
| ) | [friend] |
Overloaded stream operator, for testing purposes.
Outputs the vector on one line with space between elements to the chosen stream.
1.7.4