feval

Evaluate kernel on GPU

Syntax

feval(KERN, x1, ..., xn)
[y1, ..., ym] = feval(KERN, x1, ..., xn)

Description

feval(KERN, x1, ..., xn) evaluates the CUDA kernel KERN with the given arguments x1, ..., xn. The number of input arguments, n, must equal 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 a mixture of the two.

[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-const pointer inputs to the CUDA kernel after it has executed. The output from feval running a kernel on the GPU is always gpuArray type, even if all the inputs are data from the MATLAB workspace. The number of output arguments, m, must not exceed the value of the MaxNumLHSArguments property of KERN.

Examples

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

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

The corresponding kernel object in MATLAB then has the properties:

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

You can use feval on this code’s kernel (KERN) with the 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 types, and correspond to the values of pInOut1 and pInOut2 after the CUDA kernel has executed.

Introduced in R2010b

Was this topic helpful?