Compile MEX-function for GPU computation
mexcuda
compiles and
links source files into a shared library called a MEX-file, executable from
within MATLAB®. The function compiles MEX-files written using the CUDA® C++ framework with the NVIDIA®
filenames
nvcc
compiler, allowing the files to define and launch
GPU kernels. In addition, the mexcuda
function exposes
the GPU MEX API to allow the MEX-file to read and write gpuArrays.
mexcuda
is an extension of the MATLAB
mex
function. Only a subset
of the compilers supported by mex
is supported for
mexcuda
. The supported compilers depend on the
CUDA Toolkit version supported by MATLAB.
mexcuda
builds with the specified build options. The option1 ... optionN
filenames
option1 ...
optionN
arguments supplement or override the default
mexcuda
build configuration. You can use the most
of the options available in mex
with
mexcuda
.
If the CUDA toolkit is not detected or is not a supported version,
MATLAB compiles the CUDA code using the NVIDIA
nvcc
compiler installed with MATLAB. To check which compiler mexcuda
is using,
use the -v
flag for verbose output in the
mexcuda
command.
The CUDA toolkit installed with MATLAB does not contain all libraries that are available in the
CUDA toolkit. If you want to link a specific library that is not
installed with MATLAB, install the CUDA toolkit. You can check which CUDA toolkit version MATLAB requires using gpuDevice
. For more
information about the CUDA Toolkit, see CUDA Toolkit.