mexcuda
Compile MEX functions or PTX files for GPU computation
Description
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 GPU arrays.
mexcuda
is an extension of the MATLAB
mex
function. Only a subset
of the compilers supported by the mex
function are
supported by 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
.
Examples
Input Arguments
Tips
The CUDA toolkit installed with MATLAB does not contain all libraries that are available in the CUDA toolkit. If you want to use a specific library that is not installed with MATLAB, install the CUDA toolkit. You can check which CUDA toolkit version MATLAB supports using
gpuDevice
. For more information about the CUDA Toolkit, see Install the CUDA Toolkit (Optional).If the CUDA toolkit is not detected or is not a supported version,
mexcuda
compiles the CUDA code using the NVIDIAnvcc
compiler installed with MATLAB. To check which compilermexcuda
is using, use the-v
flag for verbose output in themexcuda
command.If you have installed the CUDA toolkit in a non-default location, you can specify the location of
nvcc
on your system by storing it in the environment variableMW_NVCC_PATH
. You can set this variable using the MATLABsetenv
command. For example,setenv("MW_NVCC_PATH","/usr/local/CUDA/bin")
Version History
Introduced in R2015b