Type for MATLAB gpuArray
mxGPUArray is an opaque C language type that allows a MEX function access to the elements in a MATLAB gpuArray. Using the mxGPU API, you can perform calculations on a MATLAB gpuArray, and return gpuArray results to MATLAB.
All MEX functions receive inputs and pass outputs as mxArrays. A gpuArray in MATLAB is a special kind of mxArray that represents an array stored on the GPU. In your MEX function, you use mxGPUArray objects to access an array stored on the GPU: these objects correspond to MATLAB gpuArrays.
The mxGPU API contains functions that manipulate
objects. These functions allow you to extract mxGPUArrays from input mxArrays, to
wrap output mxGPUArrays as mxArrays for return to MATLAB, to determine the
characteristics of the arrays, and to get pointers to the underlying elements. You
can perform calculations by passing the pointers to CUDA functions that you write or
that are available in external libraries.
The basic structure of a GPU MEX function is:
mxInitGPUto initialize MathWorks GPU library.
mxArrayinputs contain GPU data.
mxGPUArrayobjects from the input
mxArrayarguments, and get pointers to the input elements on the device.
mxGPUArrayobjects to hold the outputs, and get the pointers to the output elements on the device.
Call a CUDA function, passing it the device pointers.
Wrap the output
mxArrayfor return to MATLAB.
mxGPUArrayobjects you created.
The header file that contains this type is
include it with the line:
Introduced in R2013a