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®
filenamesnvcc 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. For more information, see Supported Host Compilers.
mexcuda builds with the specified build options. The option1 ... optionN filenamesoption1 ... 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 CUDA Toolkit (Optional).If the CUDA toolkit is not detected or is not a supported version,
mexcudacompiles the CUDA code using the NVIDIAnvcccompiler installed with MATLAB. To check which compilermexcudais using, use the-vflag for verbose output in themexcudacommand.If you have installed the CUDA toolkit in a non-default location, you can specify the location of
nvccon your system by storing it in the environment variableMW_NVCC_PATH. You can set this variable using the MATLABsetenvcommand. For example,setenv("MW_NVCC_PATH","/usr/local/CUDA/bin")
Version History
Introduced in R2015b