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
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:
initialize MathWorks GPU library.
contain GPU data.
mxGPUArray objects from
mxArray arguments, and get pointers to
the input elements on the device.
mxGPUArray objects 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
mxGPUArray as an
return to MATLAB.
The header file that contains this type is
You include it with the line: