Main Content

feval

Evaluate kernel on GPU

Description

feval(kern,x1,...,xn) evaluates the CUDA kernel kern with the arguments x1,...,xn. The number of input arguments, n, must be equal to the value of the NumRHSArguments property of kern, and their types must match the description in the ArgumentTypes property of kern. The input data can be regular MATLAB® data, GPU arrays, or both.

[y1,...,ym] = feval(kern,x1,...,xn) returns multiple output arguments from the evaluation of the kernel. Each output argument corresponds to the value of the non-constant pointer inputs to the CUDA kernel after it has executed. The output from feval running a kernel on the GPU is always a gpuArray, even if all the inputs are stored in host memory. The number of output arguments, m, must not exceed the value of the MaxNumLHSArguments property of kern.

example

Examples

collapse all

If the CUDA kernel within a CU file has this signature:

void myKernel(const float * pIn, float * pInOut1, float * pInOut2)

Then, the corresponding kernel object in MATLAB has these properties:

MaxNumLHSArguments: 2
   NumRHSArguments: 3
     ArgumentTypes: {'in single vector'  ...
                     'inout single vector' 'inout single vector'}

Use feval on this kernel (KERN) with this syntax:

[y1, y2] = feval(KERN,x1,x2,x3)    

The three input arguments, x1, x2, and x3, correspond to the three arguments that are passed into the CUDA function. The output arguments, y1 and y2, are gpuArray objects, and correspond to the values of pInOut1 and pInOut2 after the CUDA kernel has executed.

Input Arguments

collapse all

CUDA kernel, specified as a parallel.gpu.CUDAKernel object.

Arguments to evaluate the kernel with, specified as MATLAB data, a gpuArray object, or a mixture of the two. The number of these arguments must be equal to the value of the NumRHSArguments property of the kern argument, and their types must match the description in the ArgumentTypes property of the kern argument.

Output Arguments

collapse all

Output from the evaluation of the CUDA kernel, returned as a gpuArray object. The number of these arguments must not exceed the value of the MaxNumLHSArguments property of the kern input argument.

Version History

Introduced in R2010b