|
HDK
|
A simple OpenCL-based array class. More...
#include <CE_Array.h>
Inheritance diagram for CE_Array< T >:Public Types | |
| typedef T | value_type |
| using | reduce_t = typename std::conditional< std::is_integral< T >::value, exint, fpreal64 >::type |
Public Types inherited from CE_BufferDevice< T > | |
| typedef T | value_type |
Public Member Functions | |
| exint | size () const |
| bool | isEmpty () const |
| void | init (exint size) |
| const cl::Buffer & | buffer () const |
| CE_Array () | |
| CE_Array (exint size) | |
| CE_Array (cl::Buffer &&buf, exint size=-1) | |
| CE_Array (const CE_Array< T > &a) | |
| CE_Array (CE_Array< T > &&a) noexcept | |
| Move constructor. Steals the buffer from the original. More... | |
| CE_Array (CE_BufferDevice< T > &&b) noexcept | |
| Move constructor. Steals the buffer from the original. More... | |
| CE_Array< T > & | operator= (CE_Array< T > &&other) |
| CE_Array< T > & | operator= (const CE_Array< T > &other)=delete |
| ~CE_Array () | |
| CE_BufferDevice base class will release buffer. More... | |
| CE_ArrayView< T > | view () |
| const CE_ArrayView< T > | view () const |
| template<typename V > | |
| void | initFromBuffer (const CE_BufferDevice< V > &src, int offset) |
| template<typename V > | |
| void | initAndConvertFrom (const CE_Array< V > &src, int src_tuplesize=1, int dst_tuplesize=1, T default_value=0) |
| template<typename V , typename I > | |
| void | initAndConvertFromIndices (const CE_Array< V > &src, const CE_Array< I > &indices, int src_tuplesize=1, int dst_tuplesize=1, T default_value=0) |
| template<typename V > | |
| void | convertFrom (const CE_Array< V > &src, int src_tuplesize=1, int dst_tuplesize=1, exint src_offset=0, exint dst_offset=0, exint nelements=-1, T default_value=0) |
| template<typename V , typename I > | |
| void | convertFromIndices (const CE_Array< V > &src, const CE_Array< I > &indices, int src_tuplesize=1, int dst_tuplesize=1, exint dst_offset=0, T default_value=0) |
| void | extractChannel (CE_Array< T > &dst, int tuplesize, int comp) const |
| Extract the channel from this into dst. More... | |
| void | insertChannel (const CE_Array< T > &src, int tuplesize, int comp) |
| Insert the channel from src into this. More... | |
| void | prefixSum (CE_Array< T > &dst, bool exclusive=true, CE_ScanOp op=CE_ScanOp::ADD) const |
| void | iota () |
| T | readValue (int idx) const |
| void | writeValue (int idx, const T &val, bool blocking=true) |
| void | sort (bool is_descending=false, int maxbits=0) |
| Sort the array. More... | |
| template<typename V > | |
| void | sortValues (CE_Array< V > &vals, bool is_descending=false, int maxbits=0) |
| Sort the array and the values. More... | |
| reduce_t | min (int tuplesize=1, int comp=0) const |
| reduce_t | minAbs (int tuplesize=1, int comp=0) const |
| reduce_t | minLength (int tuplesize=1) const |
| reduce_t | max (int tuplesize=1, int comp=0) const |
| reduce_t | maxAbs (int tuplesize=1, int comp=0) const |
| reduce_t | maxLength (int tuplesize=1) const |
| reduce_t | sum (int tuplesize=1, int comp=0) const |
| reduce_t | sumAbs (int tuplesize=1, int comp=0) const |
| reduce_t | sumSqr (int tuplesize=1, int comp=0) const |
| fpreal64 | average (int tuplesize=1, int comp=0) const |
| fpreal64 | rms (int tuplesize=1, int comp=0) const |
| reduce_t | dot (const CE_Array< T > &b) const |
| void | constant (T cval) |
| template<typename I > | |
| void | reorder (const CE_Array< I > &order) |
| cl::KernelFunctor | bind (cl::Kernel &k) const |
| cl::KernelFunctor | bind (const char *kernel_name) const |
Public Member Functions inherited from CE_BufferDevice< T > | |
| CE_BufferDevice () | |
| Empty buffer constructor. More... | |
| CE_BufferDevice (exint size) | |
| Allocated an uninitialized buffer of specified size (if > 0). More... | |
| CE_BufferDevice (cl::Buffer &&buf, exint size=-1) | |
| CE_BufferDevice (const CE_BufferDevice< T > &b)=delete | |
| No copy constructor. More... | |
| CE_BufferDevice (CE_BufferDevice< T > &&b) noexcept | |
| ~CE_BufferDevice () | |
| template<typename V > | |
| CE_ArrayView< V > | arrayView () |
| template<typename V > | |
| const CE_ArrayView< V > | arrayView () const |
| cl::Buffer | release () |
| void | reset (cl::Buffer &&buf, exint size=-1) |
| void | init (exint size) |
| void | initFromArray (const UT_Array< T > &src, exint len=-1, bool block=true) |
| Initialize from a UT_Array. If len >= 0, only len elements are copied. More... | |
| void | matchAndCopyToArray (UT_Array< T > &dst, exint len=-1, bool block=true) const |
| void | initFromData (const T *data, exint nelem, bool block=true) |
| Initialize from raw data block of T elements of length nelem. More... | |
| exint | size () const |
| Returns the buffer length. More... | |
| bool | isEmpty () const |
| Returns true iff there are no occupied elements in the buffer. More... | |
| const cl::Buffer & | buffer () const |
| void | copyFrom (const CE_BufferDevice< T > &b, exint len=-1) |
A simple OpenCL-based array class.
Definition at line 28 of file CE_Array.h.
| using CE_Array< T >::reduce_t = typename std::conditional<std::is_integral<T>::value, exint, fpreal64>::type |
Reduce to long for integral types and fpreal64 for floats, since the caller can always downcast after the fact if desired.
Definition at line 243 of file CE_Array.h.
| typedef T CE_Array< T >::value_type |
Definition at line 32 of file CE_Array.h.
Initialize to empty, and init must be called later with the desired size.
Definition at line 41 of file CE_Array.h.
Initialize to given size. Size can be zero in which case no allocation is done, and init must be called later with the desired size.
Definition at line 47 of file CE_Array.h.
|
inline |
Move construct from a raw cl::Buffer, which this object now owns. If size is not provided, calc from the buffer size and type. The input cl::Buffer is empty after this call.
Definition at line 53 of file CE_Array.h.
Copy constructor. It duplicates the data. It's marked explicit so that it's not accidentally passed by value.
Definition at line 58 of file CE_Array.h.
Move constructor. Steals the buffer from the original.
Definition at line 65 of file CE_Array.h.
|
inlinenoexcept |
Move constructor. Steals the buffer from the original.
Definition at line 69 of file CE_Array.h.
CE_BufferDevice base class will release buffer.
Definition at line 79 of file CE_Array.h.
|
inline |
Definition at line 264 of file CE_Array.h.
| cl::KernelFunctor CE_Array< T >::bind | ( | cl::Kernel & | k | ) | const |
| cl::KernelFunctor CE_Array< T >::bind | ( | const char * | kernel_name | ) | const |
|
inline |
Definition at line 37 of file CE_Array.h.
Definition at line 272 of file CE_Array.h.
|
inline |
Copy/convert data from an array of another type and/or tuple size. Does not allocate or reallocate this array's underlying cl::Buffer. Extra tuple components in the source array are discarded. Extra tuple components in the destination array are set to the default. It's up to the caller to ensure that the types can convert with sufficient precision. src_offset, dst_offset, and nelements each expect a number of tuples. If nelements >= 0, only the given number of tuples are copied.
Definition at line 167 of file CE_Array.h.
|
inline |
The same as convertFrom(), except this converts a selection of tuples listed in the index array. The indices should be in the range [0, src.size()/src_tuplesize - 1].
Definition at line 186 of file CE_Array.h.
Definition at line 269 of file CE_Array.h.
| void CE_Array< T >::extractChannel | ( | CE_Array< T > & | dst, |
| int | tuplesize, | ||
| int | comp | ||
| ) | const |
Extract the channel from this into dst.
Definition at line 36 of file CE_Array.h.
|
inline |
Initialize the array from an array of another type and/or tuple size. Extra tuple components in the source array are discarded. Extra tuple components in the destination array are set to the default. It's up to the caller to ensure that the types can convert with sufficient precision.
Definition at line 125 of file CE_Array.h.
|
inline |
The same as initAndConvertFrom(), except this converts a selection of tuples listed in the index array. The indices should be in the range [0, src.size()/src_tuplesize - 1].
Definition at line 142 of file CE_Array.h.
|
inline |
Initalize the array of elements of type T that are at the offset within type V in the buffer.
Definition at line 90 of file CE_Array.h.
| void CE_Array< T >::insertChannel | ( | const CE_Array< T > & | src, |
| int | tuplesize, | ||
| int | comp | ||
| ) |
Insert the channel from src into this.
Definition at line 214 of file CE_Array.h.
Definition at line 35 of file CE_Array.h.
Definition at line 251 of file CE_Array.h.
|
inline |
Definition at line 253 of file CE_Array.h.
Definition at line 255 of file CE_Array.h.
Definition at line 245 of file CE_Array.h.
|
inline |
Definition at line 247 of file CE_Array.h.
Definition at line 249 of file CE_Array.h.
Move assignment. Note that copy assignment is intentionally deleted.
Definition at line 74 of file CE_Array.h.
|
inline |
Sum entries of this into dst. exclusive true will have dst elements only include the values of this strictly prior to itself. oneifnonzero will count number of non-zero entries in this.
Definition at line 207 of file CE_Array.h.
Reads a single value from the array, blocking. May throw CE Exceptions
|
inline |
Definition at line 277 of file CE_Array.h.
Definition at line 266 of file CE_Array.h.
Definition at line 34 of file CE_Array.h.
|
inline |
Sort the array.
Definition at line 227 of file CE_Array.h.
|
inline |
Sort the array and the values.
Definition at line 234 of file CE_Array.h.
Definition at line 257 of file CE_Array.h.
|
inline |
Definition at line 259 of file CE_Array.h.
|
inline |
Definition at line 261 of file CE_Array.h.
|
inline |
Definition at line 82 of file CE_Array.h.
|
inline |
Definition at line 84 of file CE_Array.h.
| void CE_Array< T >::writeValue | ( | int | idx, |
| const T & | val, | ||
| bool | blocking = true |
||
| ) |
Writes a single value to the array. May throw CE Exceptions