HDK
|
A simple OpenCL-based array class. More...
#include <CE_Array.h>
Public Types | |
typedef T | value_type |
using | reduce_t = typename std::conditional< std::is_integral< T >::value, exint, fpreal64 >::type |
![]() | |
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< 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... | |
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 > | |
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) |
void | prefixSum (CE_Array< T > &dst, bool exclusive=true, bool oneifnonzero=false) |
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) |
template<typename V > | |
void | sortValues (CE_Array< V > &vals, bool is_descending=false, int maxbits=0) |
reduce_t | min (int tuplesize=1, int comp=0) const |
reduce_t | minAbs (int tuplesize=1, int comp=0) const |
reduce_t | max (int tuplesize=1, int comp=0) const |
reduce_t | maxAbs (int tuplesize=1, int comp=0) 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) |
void | reorder (const CE_Array< uint32_t > &order) |
cl::KernelFunctor | bind (cl::Kernel &k) const |
cl::KernelFunctor | bind (const char *kernel_name) const |
![]() | |
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 () | |
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) |
Protected Types | |
using | scalar_arg_t = typename std::conditional_t< std::is_same_v< T, fpreal16 >, fpreal32, T > |
Protected Member Functions | |
cl::Kernel | loadKernel (const char *kernel_name, const char *opt=NULL) const |
reduce_t | doReduce (const char *reduce_flags, const CE_Array< T > *a, int tuplesize=1, int comp=0) const |
template<typename V > | |
V | reduceGroup (CE_Array< V > &out, uint groupsize, const char *reduce_flags) const |
template<typename V > | |
void | sortInternal (CE_Array< V > &vals, bool is_descending, int maxbits) |
scalar_arg_t | scalarKernelArg (T v) |
![]() | |
void | initInternal (exint size, bool doalloc=true) |
const cl::Buffer & | allocBuffer () const |
void | releaseBuffer () |
Static Protected Member Functions | |
template<typename V > | |
static void | appendElemType (UT_WorkBuffer &wb) |
Additional Inherited Members | |
![]() | |
cl::Buffer | myBuffer |
exint | mySize |
A simple OpenCL-based array class.
Definition at line 24 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 211 of file CE_Array.h.
|
protected |
Definition at line 270 of file CE_Array.h.
typedef T CE_Array< T >::value_type |
Definition at line 28 of file CE_Array.h.
Initialize to empty, and init must be called later with the desired size.
Definition at line 37 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 43 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 49 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 54 of file CE_Array.h.
Move constructor. Steals the buffer from the original.
Definition at line 61 of file CE_Array.h.
CE_BufferDevice base class will release buffer.
Definition at line 71 of file CE_Array.h.
|
staticprotected |
Definition at line 23 of file CE_ArraySortImpl.h.
|
inline |
Definition at line 221 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 33 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 133 of file CE_Array.h.
|
protected |
Definition at line 32 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 111 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 76 of file CE_Array.h.
Definition at line 31 of file CE_Array.h.
|
protected |
Move assignment. Note that copy assignment is intentionally deleted.
Definition at line 66 of file CE_Array.h.
void CE_Array< T >::prefixSum | ( | CE_Array< T > & | dst, |
bool | exclusive = true , |
||
bool | oneifnonzero = false |
||
) |
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.
Reads a single value from the array, blocking. May throw CE Exceptions
|
protected |
Definition at line 228 of file CE_Array.h.
|
inlineprotected |
Definition at line 272 of file CE_Array.h.
Definition at line 30 of file CE_Array.h.
|
inline |
Sort the array. Note the underlying buffer object could change for an odd number of internal sorting passes. maxbits limits the number of significant bits to consider if greater than zero.
Definition at line 191 of file CE_Array.h.
|
protected |
Definition at line 52 of file CE_ArraySortImpl.h.
|
inline |
Sort the array and the values. Note the underlying buffer objects could change for an odd number of internal sorting passes. maxbits limits the number of significant bits to consider if greater than zero.
Definition at line 202 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