gpucoder.reduce
Description
aggregates the values present in the input array S
= gpucoder.reduce(A
,FUN
)A
to a single value
using the given function handle FUN
. The output S
is a
scalar.
accepts an input array and a cell array of function handles. It aggregates the values
present in the input array to a single value for every function handle provided in the cell
array. The size of output is 1-by-N, where N is the number of function handles.S
= gpucoder.reduce(A
,{@FUN1,@FUN2,...})
The code generator uses shuffle
intrinsics to perform efficient
reduction on the GPU. Multiple function handles are aggregated inside a single kernel on the
GPU.
Examples
Input Arguments
Output Arguments
Limitations
gpucoder.reduce
does not support input arrays that are of complex data type.The user-defined function must accept two inputs and returns one output. The type of the inputs and output to the function must match the type of the input array
A
.The user-defined function must be commutative and associative, otherwise the behavior is undefined.
For some inputs that are of the integer data type, the generated code may contain intermediate computations that reach saturation. In such cases, the results from the generated code may not match the simulation results from MATLAB®.
Version History
Introduced in R2019b
See Also
Apps
Functions
codegen
|coder.gpu.kernel
|coder.gpu.kernelfun
|gpucoder.stencilKernel
|coder.gpu.constantMemory
|gpucoder.sort