
325Explicit Parallelization Using MathWorks Toolboxes
MEX did not support NVCC compilation directly until R2013a (8.1). On earlier MATLAB
releases, we need to provide additional compile options in the mexopts.sh or mexopts.bat le.
957
These steps can also be automated using Janaka Liyanage’s
958
nvmex tool.
959
The nvmex_
tool.zip le contains ve les:
• nvmex.pl — copy this le to MATLAB’s “bin” folder
• nvmex_ helper.m
• nvmex.m
• nvmexopts.bat — for MATLAB releases 2007 and up*
• nvmexopts_old.bat — for pre-2007 MATLAB releases
With this tool, we can compile CU les from within MATLAB as follows:
nvmex -f nvmexopts.bat my_cuda_kernel.cu -IF:\path\to\cuda\includes ...