Viskores  1.0
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag > Struct Template Reference

Struct containing device adapter algorithms. More...

#include <DeviceAdapterAlgorithm.h>

Public Member Functions

static T class BinaryFunctor static void ScanExclusiveByKey (const viskores::cont::ArrayHandle< T, KIn > &keys, const viskores::cont::ArrayHandle< U, VIn > &values, viskores::cont::ArrayHandle< U, VOut > &output, const U &initialValue, BinaryFunctor binaryFunctor)
 

Static Public Member Functions

template<typename IndicesStorage >
static viskores::Id BitFieldToUnorderedSet (const viskores::cont::BitField &bits, viskores::cont::ArrayHandle< Id, IndicesStorage > &indices)
 Create a unique, unsorted list of indices denoting which bits are set in a bitfield. More...
 
template<typename T , typename U , class CIn , class COut >
static void Copy (const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< U, COut > &output)
 Copy the contents of one ArrayHandle to another. More...
 
template<typename T , typename U , class CIn , class CStencil , class COut >
static void CopyIf (const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< U, CStencil > &stencil, viskores::cont::ArrayHandle< T, COut > &output)
 Conditionally copy elements in the input array to the output array. More...
 
template<typename T , typename U , class CIn , class CStencil , class COut , class UnaryPredicate >
static void CopyIf (const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< U, CStencil > &stencil, viskores::cont::ArrayHandle< T, COut > &output, UnaryPredicate unary_predicate)
 Conditionally copy elements in the input array to the output array. More...
 
template<typename T , typename U , class CIn , class COut >
static bool CopySubRange (const viskores::cont::ArrayHandle< T, CIn > &input, viskores::Id inputStartIndex, viskores::Id numberOfElementsToCopy, viskores::cont::ArrayHandle< U, COut > &output, viskores::Id outputIndex=0)
 Copy the contents of a section of one ArrayHandle to another. More...
 
static viskores::Id CountSetBits (const viskores::cont::BitField &bits)
 Returns the total number of "1" bits in BitField. More...
 
template<typename T , class CIn , class CVal , class COut >
static void LowerBounds (const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< T, CVal > &values, viskores::cont::ArrayHandle< viskores::Id, COut > &output)
 Output is the first index in input for each item in values that wouldn't alter the ordering of input. More...
 
template<typename T , class CIn , class CVal , class COut , class BinaryCompare >
static void LowerBounds (const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< T, CVal > &values, viskores::cont::ArrayHandle< viskores::Id, COut > &output, BinaryCompare binary_compare)
 Output is the first index in input for each item in values that wouldn't alter the ordering of input. More...
 
template<class CIn , class COut >
static void LowerBounds (const viskores::cont::ArrayHandle< viskores::Id, CIn > &input, viskores::cont::ArrayHandle< viskores::Id, COut > &values_output)
 A special version of LowerBounds that does an in place operation. More...
 
template<typename T , typename U , class CIn >
static U Reduce (const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue)
 Compute a accumulated sum operation on the input ArrayHandle. More...
 
template<typename T , typename U , class CIn , class BinaryFunctor >
static U Reduce (const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryFunctor binary_functor)
 Compute a accumulated sum operation on the input ArrayHandle. More...
 
template<typename T , typename U , class CKeyIn , class CValIn , class CKeyOut , class CValOut , class BinaryFunctor >
static void ReduceByKey (const viskores::cont::ArrayHandle< T, CKeyIn > &keys, const viskores::cont::ArrayHandle< U, CValIn > &values, viskores::cont::ArrayHandle< T, CKeyOut > &keys_output, viskores::cont::ArrayHandle< U, CValOut > &values_output, BinaryFunctor binary_functor)
 Compute a accumulated sum operation on the input key value pairs. More...
 
template<typename T , class CIn , class COut >
static T ScanInclusive (const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
 Compute an inclusive prefix sum operation on the input ArrayHandle. More...
 
template<typename T , class CIn , class COut , class BinaryFunctor >
static T ScanInclusive (const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryFunctor binary_functor)
 Compute an inclusive prefix sum operation on the input ArrayHandle. More...
 
template<typename T , typename U , typename KIn , typename VIn , typename VOut , typename BinaryFunctor >
static void ScanInclusiveByKey (const viskores::cont::ArrayHandle< T, KIn > &keys, const viskores::cont::ArrayHandle< U, VIn > &values, viskores::cont::ArrayHandle< U, VOut > &values_output, BinaryFunctor binary_functor)
 Compute a segmented inclusive prefix sum operation on the input key value pairs. More...
 
template<typename T , typename U , typename KIn , typename VIn , typename VOut >
static void ScanInclusiveByKey (const viskores::cont::ArrayHandle< T, KIn > &keys, const viskores::cont::ArrayHandle< U, VIn > &values, viskores::cont::ArrayHandle< U, VOut > &values_output)
 Compute a segmented inclusive prefix sum operation on the input key value pairs. More...
 
template<typename T , class CIn , class COut >
static T ScanExclusive (const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
 Compute an exclusive prefix sum operation on the input ArrayHandle. More...
 
template<typename T , class CIn , class COut , class BinaryFunctor >
static T ScanExclusive (const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue) template< typename T
 Compute an exclusive prefix sum operation on the input ArrayHandle. More...
 
template<typename T , typename U , class KIn , typename VIn , typename VOut >
static void ScanExclusiveByKey (const viskores::cont::ArrayHandle< T, KIn > &keys, const viskores::cont::ArrayHandle< U, VIn > &values, viskores::cont::ArrayHandle< U, VOut > &output)
 Compute a segmented exclusive prefix sum operation on the input key value pairs. More...
 
template<typename T , class CIn , class COut >
static void ScanExtended (const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
 Compute an extended prefix sum operation on the input ArrayHandle. More...
 
template<typename T , class CIn , class COut , class BinaryFunctor >
static void ScanExtended (const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryFunctor binaryFunctor, const T &initialValue)
 Compute an extended prefix sum operation on the input ArrayHandle. More...
 
template<class Functor >
static void Schedule (Functor functor, viskores::Id numInstances)
 Schedule many instances of a function to run on concurrent threads. More...
 
template<class Functor , class IndiceType >
static void Schedule (Functor functor, viskores::Id3 rangeMax)
 Schedule many instances of a function to run on concurrent threads. More...
 
template<typename T , class Storage >
static void Sort (viskores::cont::ArrayHandle< T, Storage > &values)
 Unstable ascending sort of input array. More...
 
template<typename T , class Storage , class BinaryCompare >
static void Sort (viskores::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
 Unstable ascending sort of input array. More...
 
template<typename T , typename U , class StorageT , class StorageU >
static void SortByKey (viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values)
 Unstable ascending sort of keys and values. More...
 
template<typename T , typename U , class StorageT , class StorageU , class BinaryCompare >
static void SortByKey (viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare) static void Synchronize()
 Unstable ascending sort of keys and values. More...
 
template<typename T , typename U , typename V , typename StorageT , typename StorageU , typename StorageV , typename BinaryFunctor >
static void Transform (const viskores::cont::ArrayHandle< T, StorageT > &input1, const viskores::cont::ArrayHandle< U, StorageU > &input2, viskores::cont::ArrayHandle< V, StorageV > &output, BinaryFunctor binaryFunctor)
 Apply a given binary operation function element-wise to input arrays. More...
 
template<typename T , class Storage >
static void Unique (viskores::cont::ArrayHandle< T, Storage > &values)
 Reduce an array to only the unique values it contains. More...
 
template<typename T , class Storage , class BinaryCompare >
static void Unique (viskores::cont::ArrayHandle< T, Storage > &values, BinaryCompare binary_compare)
 Reduce an array to only the unique values it contains. More...
 
template<typename T , class CIn , class CVal , class COut >
static void UpperBounds (const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< T, CVal > &values, viskores::cont::ArrayHandle< viskores::Id, COut > &output)
 Output is the last index in input for each item in values that wouldn't alter the ordering of input. More...
 
template<typename T , class CIn , class CVal , class COut , class BinaryCompare >
static void UpperBounds (const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< T, CVal > &values, viskores::cont::ArrayHandle< viskores::Id, COut > &output, BinaryCompare binary_compare)
 Output is the last index in input for each item in values that wouldn't alter the ordering of input. More...
 
template<class CIn , class COut >
static void UpperBounds (const viskores::cont::ArrayHandle< viskores::Id, CIn > &input, viskores::cont::ArrayHandle< viskores::Id, COut > &values_output)
 A special version of UpperBounds that does an in place operation. More...
 
static void Fill (viskores::cont::BitField &bits, bool value, viskores::Id numBits)
 Fill the BitField with a specific pattern of bits. More...
 
static void Fill (viskores::cont::BitField &bits, bool value)
 Fill the BitField with a specific pattern of bits. More...
 
template<typename WordType >
static void Fill (viskores::cont::BitField &bits, WordType word, viskores::Id numBits)
 Fill the BitField with a specific pattern of bits. More...
 
template<typename WordType >
static void Fill (viskores::cont::BitField &bits, WordType word)
 Fill the BitField with a specific pattern of bits. More...
 
template<typename T , typename S >
static void Fill (viskores::cont::ArrayHandle< T, S > &array, const T &value)
 Fill array with value. More...
 
template<typename T , typename S >
static void Fill (viskores::cont::ArrayHandle< T, S > &array, const T &value, const viskores::Id numValues)
 Fill array with value. More...
 

Public Attributes

static T U
 
static T KIn
 
static T VIn
 
static T VOut
 

Detailed Description

template<class DeviceAdapterTag>
struct viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >

Struct containing device adapter algorithms.

This struct, templated on the device adapter tag, comprises static methods that implement the algorithms provided by the device adapter. The default struct is not implemented. Device adapter implementations must specialize the template.

Member Function Documentation

◆ BitFieldToUnorderedSet()

template<class DeviceAdapterTag >
template<typename IndicesStorage >
static viskores::Id viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::BitFieldToUnorderedSet ( const viskores::cont::BitField bits,
viskores::cont::ArrayHandle< Id, IndicesStorage > &  indices 
)
static

Create a unique, unsorted list of indices denoting which bits are set in a bitfield.

Returns the total number of set bits.

◆ Copy()

template<class DeviceAdapterTag >
template<typename T , typename U , class CIn , class COut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Copy ( const viskores::cont::ArrayHandle< T, CIn > &  input,
viskores::cont::ArrayHandle< U, COut > &  output 
)
static

Copy the contents of one ArrayHandle to another.

Copies the contents of input to output. The array output will be allocated to the same size of input. If output has already been allocated we will reallocate and clear any current values.

◆ CopyIf() [1/2]

template<class DeviceAdapterTag >
template<typename T , typename U , class CIn , class CStencil , class COut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::CopyIf ( const viskores::cont::ArrayHandle< T, CIn > &  input,
const viskores::cont::ArrayHandle< U, CStencil > &  stencil,
viskores::cont::ArrayHandle< T, COut > &  output 
)
static

Conditionally copy elements in the input array to the output array.

Calls the parallel primitive function of stream compaction on the input to remove unwanted elements. The result of the stream compaction is placed in output. The values in stencil are used to determine which input values are placed into output, with all stencil values not equal to the default constructor being considered valid. The size of output will be modified after this call as we can't know the number of elements that will be removed by the stream compaction algorithm.

◆ CopyIf() [2/2]

template<class DeviceAdapterTag >
template<typename T , typename U , class CIn , class CStencil , class COut , class UnaryPredicate >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::CopyIf ( const viskores::cont::ArrayHandle< T, CIn > &  input,
const viskores::cont::ArrayHandle< U, CStencil > &  stencil,
viskores::cont::ArrayHandle< T, COut > &  output,
UnaryPredicate  unary_predicate 
)
static

Conditionally copy elements in the input array to the output array.

Calls the parallel primitive function of stream compaction on the input to remove unwanted elements. The result of the stream compaction is placed in output. The values in stencil are passed to the unary comparison object which is used to determine which /c input values are placed into output. The size of output will be modified after this call as we can't know the number of elements that will be removed by the stream compaction algorithm.

◆ CopySubRange()

template<class DeviceAdapterTag >
template<typename T , typename U , class CIn , class COut >
static bool viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::CopySubRange ( const viskores::cont::ArrayHandle< T, CIn > &  input,
viskores::Id  inputStartIndex,
viskores::Id  numberOfElementsToCopy,
viskores::cont::ArrayHandle< U, COut > &  output,
viskores::Id  outputIndex = 0 
)
static

Copy the contents of a section of one ArrayHandle to another.

Copies the a range of elements of input to output. The number of elements is determined by numberOfElementsToCopy, and initial start position is determined by inputStartIndex. You can control where in the destination the copy should occur by specifying the outputIndex

If inputStartIndex + numberOfElementsToCopy is greater than the length of input we will only copy until we reach the end of the input array

If the outputIndex + numberOfElementsToCopy is greater than the length of output we will reallocate the output array so it can fit the number of elements we desire.

Requirements:
  • If input and output share memory, the input and output ranges must not overlap.

◆ CountSetBits()

template<class DeviceAdapterTag >
static viskores::Id viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::CountSetBits ( const viskores::cont::BitField bits)
static

Returns the total number of "1" bits in BitField.

◆ Fill() [1/6]

template<class DeviceAdapterTag >
template<typename T , typename S >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Fill ( viskores::cont::ArrayHandle< T, S > &  array,
const T &  value 
)
static

Fill array with value.

If numValues is specified, the array will be resized.

◆ Fill() [2/6]

template<class DeviceAdapterTag >
template<typename T , typename S >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Fill ( viskores::cont::ArrayHandle< T, S > &  array,
const T &  value,
const viskores::Id  numValues 
)
static

Fill array with value.

If numValues is specified, the array will be resized.

◆ Fill() [3/6]

template<class DeviceAdapterTag >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Fill ( viskores::cont::BitField bits,
bool  value 
)
static

Fill the BitField with a specific pattern of bits.

For boolean values, all bits are set to 1 if value is true, or 0 if value is false. For word masks, the word type must be an unsigned integral type, which will be stamped across the BitField. If numBits is provided, the BitField is resized appropriately.

◆ Fill() [4/6]

template<class DeviceAdapterTag >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Fill ( viskores::cont::BitField bits,
bool  value,
viskores::Id  numBits 
)
static

Fill the BitField with a specific pattern of bits.

For boolean values, all bits are set to 1 if value is true, or 0 if value is false. For word masks, the word type must be an unsigned integral type, which will be stamped across the BitField. If numBits is provided, the BitField is resized appropriately.

◆ Fill() [5/6]

template<class DeviceAdapterTag >
template<typename WordType >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Fill ( viskores::cont::BitField bits,
WordType  word 
)
static

Fill the BitField with a specific pattern of bits.

For boolean values, all bits are set to 1 if value is true, or 0 if value is false. For word masks, the word type must be an unsigned integral type, which will be stamped across the BitField. If numBits is provided, the BitField is resized appropriately.

◆ Fill() [6/6]

template<class DeviceAdapterTag >
template<typename WordType >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Fill ( viskores::cont::BitField bits,
WordType  word,
viskores::Id  numBits 
)
static

Fill the BitField with a specific pattern of bits.

For boolean values, all bits are set to 1 if value is true, or 0 if value is false. For word masks, the word type must be an unsigned integral type, which will be stamped across the BitField. If numBits is provided, the BitField is resized appropriately.

◆ LowerBounds() [1/3]

template<class DeviceAdapterTag >
template<typename T , class CIn , class CVal , class COut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::LowerBounds ( const viskores::cont::ArrayHandle< T, CIn > &  input,
const viskores::cont::ArrayHandle< T, CVal > &  values,
viskores::cont::ArrayHandle< viskores::Id, COut > &  output 
)
static

Output is the first index in input for each item in values that wouldn't alter the ordering of input.

LowerBounds is a vectorized search. From each value in values it finds the first place the item can be inserted in the ordered input array and stores the index in output.

Requirements:
  • input must already be sorted

◆ LowerBounds() [2/3]

template<class DeviceAdapterTag >
template<typename T , class CIn , class CVal , class COut , class BinaryCompare >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::LowerBounds ( const viskores::cont::ArrayHandle< T, CIn > &  input,
const viskores::cont::ArrayHandle< T, CVal > &  values,
viskores::cont::ArrayHandle< viskores::Id, COut > &  output,
BinaryCompare  binary_compare 
)
static

Output is the first index in input for each item in values that wouldn't alter the ordering of input.

LowerBounds is a vectorized search. From each value in values it finds the first place the item can be inserted in the ordered input array and stores the index in output. Uses the custom comparison functor to determine the correct location for each item.

Requirements:
  • input must already be sorted

◆ LowerBounds() [3/3]

template<class DeviceAdapterTag >
template<class CIn , class COut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::LowerBounds ( const viskores::cont::ArrayHandle< viskores::Id, CIn > &  input,
viskores::cont::ArrayHandle< viskores::Id, COut > &  values_output 
)
static

A special version of LowerBounds that does an in place operation.

This version of lower bounds performs an in place operation where each value in the values_output array is replaced by the index in input where it occurs. Because this is an in place operation, the type of the arrays is limited to viskores::Id.

◆ Reduce() [1/2]

template<class DeviceAdapterTag >
template<typename T , typename U , class CIn >
static U viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Reduce ( const viskores::cont::ArrayHandle< T, CIn > &  input,
U  initialValue 
)
static

Compute a accumulated sum operation on the input ArrayHandle.

Computes an accumulated sum on the input ArrayHandle, returning the total sum. Reduce is similar to the stl accumulate sum function, exception that Reduce doesn't do a serial summation. This means that if you have defined a custom plus operator for T it must be commutative, or you will get inconsistent results.

Returns
The total sum.

◆ Reduce() [2/2]

template<class DeviceAdapterTag >
template<typename T , typename U , class CIn , class BinaryFunctor >
static U viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Reduce ( const viskores::cont::ArrayHandle< T, CIn > &  input,
U  initialValue,
BinaryFunctor  binary_functor 
)
static

Compute a accumulated sum operation on the input ArrayHandle.

Computes an accumulated sum (or any user binary operation) on the input ArrayHandle, returning the total sum. Reduce is similar to the stl accumulate sum function, exception that Reduce doesn't do a serial summation. This means that if you have defined a custom plus operator for T it must be commutative, or you will get inconsistent results.

Returns
The total sum.

◆ ReduceByKey()

template<class DeviceAdapterTag >
template<typename T , typename U , class CKeyIn , class CValIn , class CKeyOut , class CValOut , class BinaryFunctor >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ReduceByKey ( const viskores::cont::ArrayHandle< T, CKeyIn > &  keys,
const viskores::cont::ArrayHandle< U, CValIn > &  values,
viskores::cont::ArrayHandle< T, CKeyOut > &  keys_output,
viskores::cont::ArrayHandle< U, CValOut > &  values_output,
BinaryFunctor  binary_functor 
)
static

Compute a accumulated sum operation on the input key value pairs.

Computes a segmented accumulated sum (or any user binary operation) on the keys and values ArrayHandle(s). Each segmented accumulated sum is run on consecutive equal keys with the binary operation applied to all values inside that range. Once finished a single key and value is created for each segment.

◆ ScanExclusive() [1/2]

template<class DeviceAdapterTag >
template<typename T , class CIn , class COut >
static T viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanExclusive ( const viskores::cont::ArrayHandle< T, CIn > &  input,
viskores::cont::ArrayHandle< T, COut > &  output 
)
static

Compute an exclusive prefix sum operation on the input ArrayHandle.

Computes an exclusive prefix sum operation on the input ArrayHandle, storing the results in the output ArrayHandle. ExclusiveScan is similar to the stl partial sum function, exception that ExclusiveScan doesn't do a serial summation. This means that if you have defined a custom plus operator for T it must be associative, or you will get inconsistent results. When the input and output ArrayHandles are the same ArrayHandle the operation will be done inplace.

Returns
The total sum.

◆ ScanExclusive() [2/2]

template<class DeviceAdapterTag >
template<typename T , class CIn , class COut , class BinaryFunctor >
static T viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanExclusive ( const viskores::cont::ArrayHandle< T, CIn > &  input,
viskores::cont::ArrayHandle< T, COut > &  output,
BinaryFunctor  binaryFunctor,
const T &  initialValue 
)
static

Compute an exclusive prefix sum operation on the input ArrayHandle.

Computes an exclusive prefix sum operation on the input ArrayHandle, storing the results in the output ArrayHandle. ExclusiveScan is similar to the stl partial sum function, exception that ExclusiveScan doesn't do a serial summation. This means that if you have defined a custom plus operator for T it must be associative, or you will get inconsistent results. When the input and output ArrayHandles are the same ArrayHandle the operation will be done inplace.

Returns
The total sum.

Compute a segmented exclusive prefix sum operation on the input key value pairs.

Computes a segmented exclusive prefix sum (or any user binary operation) on the keys and values ArrayHandle(s). Each segmented exclusive prefix sum is run on consecutive equal keys with the binary operation applied to all values inside that range. Once finished the result is stored in values_output ArrayHandle.

◆ ScanExclusiveByKey() [1/2]

template<class DeviceAdapterTag >
template<typename T , typename U , class KIn , typename VIn , typename VOut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanExclusiveByKey ( const viskores::cont::ArrayHandle< T, KIn > &  keys,
const viskores::cont::ArrayHandle< U, VIn > &  values,
viskores::cont::ArrayHandle< U, VOut > &  output 
)
static

Compute a segmented exclusive prefix sum operation on the input key value pairs.

Computes a segmented inclusive prefix sum on the keys and values ArrayHandle(s). Each segmented inclusive prefix sum is run on consecutive equal keys with the binary operation viskores::Add applied to all values inside that range. Once finished the result is stored in values_output ArrayHandle.

◆ ScanExclusiveByKey() [2/2]

template<class DeviceAdapterTag >
static T class BinaryFunctor static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanExclusiveByKey ( const viskores::cont::ArrayHandle< T, KIn > &  keys,
const viskores::cont::ArrayHandle< U, VIn > &  values,
viskores::cont::ArrayHandle< U, VOut > &  output,
const U initialValue,
BinaryFunctor  binaryFunctor 
)

◆ ScanExtended() [1/2]

template<class DeviceAdapterTag >
template<typename T , class CIn , class COut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanExtended ( const viskores::cont::ArrayHandle< T, CIn > &  input,
viskores::cont::ArrayHandle< T, COut > &  output 
)
static

Compute an extended prefix sum operation on the input ArrayHandle.

Computes an extended prefix sum operation on the input ArrayHandle, storing the results in the output ArrayHandle. The output array is one element longer than the input array. This produces an output array that contains both an inclusive scan (in elements [1, size]) and an exclusive scan (in elements [0, size-1]). As such, the first element of the output array always has the initial value and the last element of the output array always has the total sum. By using ArrayHandleView, arrays containing both inclusive and exclusive scans can be generated from an extended scan with minimal memory usage.

This algorithm may also be more efficient than ScanInclusive and ScanExclusive on some devices, since it may be able to avoid copying the total sum to the control environment to return.

ScanExtended is similar to the stl partial sum function, exception that ScanExtended doesn't do a serial summation. This means that if you have defined a custom plus operator for T it must be associative, or you will get inconsistent results.

This overload of ScanExtended uses viskores::Add for the binary functor, and uses zero for the initial value of the scan operation.

◆ ScanExtended() [2/2]

template<class DeviceAdapterTag >
template<typename T , class CIn , class COut , class BinaryFunctor >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanExtended ( const viskores::cont::ArrayHandle< T, CIn > &  input,
viskores::cont::ArrayHandle< T, COut > &  output,
BinaryFunctor  binaryFunctor,
const T &  initialValue 
)
static

Compute an extended prefix sum operation on the input ArrayHandle.

Computes an extended prefix sum operation on the input ArrayHandle, storing the results in the output ArrayHandle. The output array is one element longer than the input array. This produces an output array that contains both an inclusive scan (in elements [1, size]) and an exclusive scan (in elements [0, size-1]). As such, the first element of the output array always has the initial value and the last element of the output array always has the total sum. By using ArrayHandleView, arrays containing both inclusive and exclusive scans can be generated from an extended scan with minimal memory usage.

This algorithm may also be more efficient than ScanInclusive and ScanExclusive on some devices, since it may be able to avoid copying the total sum to the control environment to return.

ScanExtended is similar to the stl partial sum function, exception that ScanExtended doesn't do a serial summation. This means that if you have defined a custom plus operator for T it must be associative, or you will get inconsistent results.

◆ ScanInclusive() [1/2]

template<class DeviceAdapterTag >
template<typename T , class CIn , class COut >
static T viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanInclusive ( const viskores::cont::ArrayHandle< T, CIn > &  input,
viskores::cont::ArrayHandle< T, COut > &  output 
)
static

Compute an inclusive prefix sum operation on the input ArrayHandle.

Computes an inclusive prefix sum operation on the input ArrayHandle, storing the results in the output ArrayHandle. InclusiveScan is similar to the stl partial sum function, exception that InclusiveScan doesn't do a serial summation. This means that if you have defined a custom plus operator for T it must be associative, or you will get inconsistent results. When the input and output ArrayHandles are the same ArrayHandle the operation will be done inplace.

Returns
The total sum.

◆ ScanInclusive() [2/2]

template<class DeviceAdapterTag >
template<typename T , class CIn , class COut , class BinaryFunctor >
static T viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanInclusive ( const viskores::cont::ArrayHandle< T, CIn > &  input,
viskores::cont::ArrayHandle< T, COut > &  output,
BinaryFunctor  binary_functor 
)
static

Compute an inclusive prefix sum operation on the input ArrayHandle.

Computes an inclusive prefix sum operation on the input ArrayHandle, storing the results in the output ArrayHandle. InclusiveScan is similar to the stl partial sum function, exception that InclusiveScan doesn't do a serial summation. This means that if you have defined a custom plus operator for T it must be associative, or you will get inconsistent results. When the input and output ArrayHandles are the same ArrayHandle the operation will be done inplace.

Returns
The total sum.

◆ ScanInclusiveByKey() [1/2]

template<class DeviceAdapterTag >
template<typename T , typename U , typename KIn , typename VIn , typename VOut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanInclusiveByKey ( const viskores::cont::ArrayHandle< T, KIn > &  keys,
const viskores::cont::ArrayHandle< U, VIn > &  values,
viskores::cont::ArrayHandle< U, VOut > &  values_output 
)
static

Compute a segmented inclusive prefix sum operation on the input key value pairs.

Computes a segmented inclusive prefix sum on the keys and values ArrayHandle(s). Each segmented inclusive prefix sum is run on consecutive equal keys with the binary operation viskores::Add applied to all values inside that range. Once finished the result is stored in values_output ArrayHandle.

◆ ScanInclusiveByKey() [2/2]

template<class DeviceAdapterTag >
template<typename T , typename U , typename KIn , typename VIn , typename VOut , typename BinaryFunctor >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::ScanInclusiveByKey ( const viskores::cont::ArrayHandle< T, KIn > &  keys,
const viskores::cont::ArrayHandle< U, VIn > &  values,
viskores::cont::ArrayHandle< U, VOut > &  values_output,
BinaryFunctor  binary_functor 
)
static

Compute a segmented inclusive prefix sum operation on the input key value pairs.

Computes a segmented inclusive prefix sum (or any user binary operation) on the keys and values ArrayHandle(s). Each segmented inclusive prefix sum is run on consecutive equal keys with the binary operation applied to all values inside that range. Once finished the result is stored in values_output ArrayHandle.

◆ Schedule() [1/2]

template<class DeviceAdapterTag >
template<class Functor >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Schedule ( Functor  functor,
viskores::Id  numInstances 
)
static

Schedule many instances of a function to run on concurrent threads.

Calls the functor on several threads. This is the function used in the control environment to spawn activity in the execution environment. functor is a function-like object that can be invoked with the calling specification functor(viskores::Id index). It also has a method called from the control environment to establish the error reporting buffer with the calling specification functor.SetErrorMessageBuffer(const viskores::exec::internal::ErrorMessageBuffer &errorMessage). This object can be stored in the functor's state such that if RaiseError is called on it in the execution environment, an ErrorExecution will be thrown from Schedule.

The argument of the invoked functor uniquely identifies the thread or instance of the invocation. There should be one invocation for each index in the range [0, numInstances].

◆ Schedule() [2/2]

template<class DeviceAdapterTag >
template<class Functor , class IndiceType >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Schedule ( Functor  functor,
viskores::Id3  rangeMax 
)
static

Schedule many instances of a function to run on concurrent threads.

Calls the functor on several threads. This is the function used in the control environment to spawn activity in the execution environment. functor is a function-like object that can be invoked with the calling specification functor(viskores::Id3 index) or functor(viskores::Id index). It also has a method called from the control environment to establish the error reporting buffer with the calling specification functor.SetErrorMessageBuffer(const viskores::exec::internal::ErrorMessageBuffer &errorMessage). This object can be stored in the functor's state such that if RaiseError is called on it in the execution environment, an ErrorExecution will be thrown from Schedule.

The argument of the invoked functor uniquely identifies the thread or instance of the invocation. It is at the device adapter's discretion whether to schedule on 1D or 3D indices, so the functor should have an operator() overload for each index type. If 3D indices are used, there is one invocation for every i, j, k value between [0, 0, 0] and rangeMax. If 1D indices are used, this Schedule behaves as if Schedule(functor, rangeMax[0]*rangeMax[1]*rangeMax[2]) were called.

◆ Sort() [1/2]

template<class DeviceAdapterTag >
template<typename T , class Storage >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Sort ( viskores::cont::ArrayHandle< T, Storage > &  values)
static

Unstable ascending sort of input array.

Sorts the contents of values so that they in ascending value. Doesn't guarantee stability

◆ Sort() [2/2]

template<class DeviceAdapterTag >
template<typename T , class Storage , class BinaryCompare >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Sort ( viskores::cont::ArrayHandle< T, Storage > &  values,
BinaryCompare  binary_compare 
)
static

Unstable ascending sort of input array.

Sorts the contents of values so that they in ascending value based on the custom compare functor.

BinaryCompare should be a strict weak ordering comparison operator

◆ SortByKey() [1/2]

template<class DeviceAdapterTag >
template<typename T , typename U , class StorageT , class StorageU >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::SortByKey ( viskores::cont::ArrayHandle< T, StorageT > &  keys,
viskores::cont::ArrayHandle< U, StorageU > &  values 
)
static

Unstable ascending sort of keys and values.

Sorts the contents of keys and values so that they in ascending value based on the values of keys.

◆ SortByKey() [2/2]

template<class DeviceAdapterTag >
template<typename T , typename U , class StorageT , class StorageU , class BinaryCompare >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::SortByKey ( viskores::cont::ArrayHandle< T, StorageT > &  keys,
viskores::cont::ArrayHandle< U, StorageU > &  values,
BinaryCompare  binary_compare 
)
static

Unstable ascending sort of keys and values.

Sorts the contents of keys and values so that they in ascending value based on the custom compare functor.

BinaryCompare should be a strict weak ordering comparison operator

Completes any asynchronous operations running on the device.

Waits for any asynchronous operations running on the device to complete.

◆ Transform()

template<class DeviceAdapterTag >
template<typename T , typename U , typename V , typename StorageT , typename StorageU , typename StorageV , typename BinaryFunctor >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Transform ( const viskores::cont::ArrayHandle< T, StorageT > &  input1,
const viskores::cont::ArrayHandle< U, StorageU > &  input2,
viskores::cont::ArrayHandle< V, StorageV > &  output,
BinaryFunctor  binaryFunctor 
)
static

Apply a given binary operation function element-wise to input arrays.

Apply the give binary operation to pairs of elements from the two input array input1 and input2. The number of elements in the input arrays do not have to be the same, in this case, only the smaller of the two numbers of elements will be applied. Outputs of the binary operation is stored in output.

◆ Unique() [1/2]

template<class DeviceAdapterTag >
template<typename T , class Storage >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Unique ( viskores::cont::ArrayHandle< T, Storage > &  values)
static

Reduce an array to only the unique values it contains.

Removes all duplicate values in values that are adjacent to each other. Which means you should sort the input array unless you want duplicate values that aren't adjacent. Note the values array size might be modified by this operation.

◆ Unique() [2/2]

template<class DeviceAdapterTag >
template<typename T , class Storage , class BinaryCompare >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::Unique ( viskores::cont::ArrayHandle< T, Storage > &  values,
BinaryCompare  binary_compare 
)
static

Reduce an array to only the unique values it contains.

Removes all duplicate values in values that are adjacent to each other. Which means you should sort the input array unless you want duplicate values that aren't adjacent. Note the values array size might be modified by this operation.

Uses the custom binary predicate Comparison to determine if something is unique. The predicate must return true if the two items are the same.

◆ UpperBounds() [1/3]

template<class DeviceAdapterTag >
template<typename T , class CIn , class CVal , class COut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::UpperBounds ( const viskores::cont::ArrayHandle< T, CIn > &  input,
const viskores::cont::ArrayHandle< T, CVal > &  values,
viskores::cont::ArrayHandle< viskores::Id, COut > &  output 
)
static

Output is the last index in input for each item in values that wouldn't alter the ordering of input.

UpperBounds is a vectorized search. From each value in values it finds the last place the item can be inserted in the ordered input array and stores the index in output.

Requirements:
  • input must already be sorted

◆ UpperBounds() [2/3]

template<class DeviceAdapterTag >
template<typename T , class CIn , class CVal , class COut , class BinaryCompare >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::UpperBounds ( const viskores::cont::ArrayHandle< T, CIn > &  input,
const viskores::cont::ArrayHandle< T, CVal > &  values,
viskores::cont::ArrayHandle< viskores::Id, COut > &  output,
BinaryCompare  binary_compare 
)
static

Output is the last index in input for each item in values that wouldn't alter the ordering of input.

LowerBounds is a vectorized search. From each value in values it finds the last place the item can be inserted in the ordered input array and stores the index in output. Uses the custom comparison functor to determine the correct location for each item.

Requirements:
  • input must already be sorted

◆ UpperBounds() [3/3]

template<class DeviceAdapterTag >
template<class CIn , class COut >
static void viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::UpperBounds ( const viskores::cont::ArrayHandle< viskores::Id, CIn > &  input,
viskores::cont::ArrayHandle< viskores::Id, COut > &  values_output 
)
static

A special version of UpperBounds that does an in place operation.

This version of lower bounds performs an in place operation where each value in the values_output array is replaced by the last index in input where it occurs. Because this is an in place operation, the type of the arrays is limited to viskores::Id.

Member Data Documentation

◆ KIn

template<class DeviceAdapterTag >
T viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::KIn

◆ U

template<class DeviceAdapterTag >
T viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::U

◆ VIn

template<class DeviceAdapterTag >
T viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::VIn

◆ VOut

template<class DeviceAdapterTag >
T viskores::cont::DeviceAdapterAlgorithm< DeviceAdapterTag >::VOut

The documentation for this struct was generated from the following file: