![]() |
fml
0.1-0
Fused Matrix Library
|
Vector class for data held on a single GPU. More...
#include <gpuvec.hh>
Public Member Functions | |
| gpuvec (std::shared_ptr< card > gpu) | |
| gpuvec (std::shared_ptr< card > gpu, len_t size) | |
| gpuvec (std::shared_ptr< card > gpu, T *data, len_t size, bool free_on_destruct=false) | |
| gpuvec (const gpuvec &x) | |
| void | resize (len_t size) |
| Resize the internal object storage. More... | |
| void | resize (std::shared_ptr< card > gpu, len_t size) |
| void | inherit (std::shared_ptr< card > gpu) |
| void | inherit (std::shared_ptr< card > gpu, T *data, len_t size, bool free_on_destruct=false) |
| gpuvec< T > | dupe () const |
| Duplicate the object in a deep copy. | |
| void | print (uint8_t ndigits=4, bool add_final_blank=true) const |
| Copy data from a CPU object to another. More... | |
| void | info () const |
| Print some brief information about the object. | |
| void | fill_zero () |
| Set all values to zero. | |
| void | fill_val (const T v) |
| Set all values to input value. More... | |
| void | fill_linspace () |
| Set values to linearly spaced numbers. More... | |
| void | fill_linspace (const T start, const T stop) |
| void | scale (const T s) |
| Multiply all values by the input value. More... | |
| void | pow (const T p) |
| Raise every value of the vector to the given power. More... | |
| void | rev () |
| Reverse the vector. | |
| T | sum () const |
| Sum the vector. | |
| T | max () const |
| Maximum value of the vector. | |
| T | min () const |
| Minimum value of the vector. | |
| T | get (const len_t i) const |
| Get the specified value. More... | |
| void | set (const len_t i, const T v) |
| Set the storage at the specified index with the provided value. More... | |
| bool | operator== (const gpuvec< T > &x) const |
| See if the two objects are the same. More... | |
| bool | operator!= (const gpuvec< T > &x) const |
See if the two objects are not the same. Uses same internal logic as the == method. More... | |
| gpuvec< T > & | operator= (const gpuvec< T > &x) |
| Operator that sets the LHS to a shallow copy of the input. Desctruction of the LHS object will not result in the internal array storage being freed. More... | |
| std::shared_ptr< card > | get_card () const |
| dim3 | get_blockdim () const |
| dim3 | get_griddim () const |
Public Member Functions inherited from fml::univec< T > | |
| len_t | size () const |
| Number of elements in the vector. | |
| T * | data_ptr () |
| Pointer to the internal array. | |
| T * | data_ptr () const |
Protected Attributes | |
| std::shared_ptr< card > | c |
Protected Attributes inherited from fml::univec< T > | |
| len_t | _size |
| T * | data |
| bool | free_data |
Additional Inherited Members | |
Protected Member Functions inherited from fml::univec< T > | |
| bool | should_free () const |
| void | check_index (const len_t i) const |
| void | printval (const T val, uint8_t ndigits) const |
| void | printval (const int val, uint8_t ndigits) const |
Vector class for data held on a single GPU.
| T | should be 'int', '__half', 'float' or 'double'. |
| void fml::gpuvec< T >::fill_linspace |
Set values to linearly spaced numbers.
| [in] | start,stop | Beginning/ending numbers. If not supplied, the vector will be filled with whole numbers from 1 to the total number of elements. |
| void fml::gpuvec< T >::fill_val | ( | const T | v | ) |
Set all values to input value.
| [in] | v | Value to set all data values to. |
| T fml::gpuvec< T >::get | ( | const len_t | i | ) | const |
Get the specified value.
| [in] | i | The index of the desired value, 0-indexed. |
Exceptions
If indices are out of bounds, the method will throw a runtime_error exception.
| bool fml::gpuvec< T >::operator!= | ( | const gpuvec< T > & | x | ) | const |
See if the two objects are not the same. Uses same internal logic as the == method.
| [in] | Comparison | object. |
| fml::gpuvec< T > & fml::gpuvec< T >::operator= | ( | const gpuvec< T > & | x | ) |
Operator that sets the LHS to a shallow copy of the input. Desctruction of the LHS object will not result in the internal array storage being freed.
| [in] | x | Setter value. |
| bool fml::gpuvec< T >::operator== | ( | const gpuvec< T > & | x | ) | const |
See if the two objects are the same.
| [in] | Comparison | object. |
false is necessarily returned. Next, if the pointer to the internal storage arrays match, then true is necessarily returned. Otherwise the objects are compared value by value. | void fml::gpuvec< T >::pow | ( | const T | p | ) |
Raise every value of the vector to the given power.
| [in] | p | Power. |
| void fml::gpuvec< REAL >::print | ( | uint8_t | ndigits = 4, |
| bool | add_final_blank = true |
||
| ) | const |
Copy data from a CPU object to another.
| [in] | ndigits | Number of decimal digits to print. |
| [in] | add_final_blank | Should a final blank line be printed? |
| void fml::gpuvec< T >::resize | ( | len_t | size | ) |
Resize the internal object storage.
| [in] | size | Length of the vector needed. |
Memory Allocations
Resizing triggers a re-allocation.
Exceptions
If the reallocation fails, a bad_alloc exception will be thrown. If the input values are invalid, a runtime_error exception will be thrown.
| void fml::gpuvec< T >::scale | ( | const T | s | ) |
Multiply all values by the input value.
| [in] | s | Scaling value. |
| void fml::gpuvec< T >::set | ( | const len_t | i, |
| const T | v | ||
| ) |
Set the storage at the specified index with the provided value.
| [in] | i | The index of the desired value, 0-indexed. |
| [in] | v | Setter value. |
Exceptions
If indices are out of bounds, the method will throw a runtime_error exception.